Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
sdkjs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
sdkjs
Commits
7abc9f18
Commit
7abc9f18
authored
Oct 25, 2017
by
SergeyLuzyanin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
paste simple text to equations
parent
7065b77b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
209 additions
and
38 deletions
+209
-38
cell/model/clipboard.js
cell/model/clipboard.js
+50
-11
common/wordcopypaste.js
common/wordcopypaste.js
+45
-2
slide/Editor/Format/Presentation.js
slide/Editor/Format/Presentation.js
+47
-11
word/Editor/Document.js
word/Editor/Document.js
+67
-14
No files found.
cell/model/clipboard.js
View file @
7abc9f18
...
...
@@ -1504,6 +1504,7 @@
{
var
NearPos
=
{
Paragraph
:
paragraph
,
ContentPos
:
paragraph
.
Get_ParaContentPos
(
false
,
false
)};
selectedContent
.
On_EndCollectElements
(
target_doc_content
,
false
);
NearPos
=
{
Paragraph
:
paragraph
,
ContentPos
:
paragraph
.
Get_ParaContentPos
(
false
,
false
)
};
paragraph
.
Check_NearestPos
(
NearPos
);
...
...
@@ -1520,25 +1521,63 @@
if
(
1
!==
selectedContent
.
Elements
.
length
||
type_Paragraph
!==
Element
.
Get_Type
()
||
null
===
LastClass
.
Parent
)
return
;
if
(
!
selectedContent
.
CanConvertToMath
)
{
var
Math
=
null
;
var
Count
=
Element
.
Content
.
length
;
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
{
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
{
var
Item
=
Element
.
Content
[
Index
];
if
(
para_Math
===
Item
.
Type
&&
null
===
Math
)
Math
=
Element
.
Content
[
Index
];
else
if
(
true
!==
Item
.
Is_Empty
({
SkipEnd
:
true
}))
else
if
(
true
!==
Item
.
Is_Empty
({
SkipEnd
:
true
}))
return
;
}
}
}
else
if
(
para_Run
!==
LastClass
.
Type
)
return
;
if
(
null
===
paragraph
.
Parent
||
undefined
===
paragraph
.
Parent
)
return
;
var
Para
=
NearPos
.
Paragraph
;
var
ParaNearPos
=
Para
.
Get_ParaNearestPos
(
NearPos
);
var
LastClass
=
ParaNearPos
.
Classes
[
ParaNearPos
.
Classes
.
length
-
1
];
var
bInsertMath
=
false
;
if
(
para_Math_Run
===
LastClass
.
Type
)
{
var
MathRun
=
LastClass
;
var
NewMathRun
=
MathRun
.
Split
(
ParaNearPos
.
NearPos
.
ContentPos
,
ParaNearPos
.
Classes
.
length
-
1
);
var
MathContent
=
ParaNearPos
.
Classes
[
ParaNearPos
.
Classes
.
length
-
2
];
var
MathContentPos
=
ParaNearPos
.
NearPos
.
ContentPos
.
Data
[
ParaNearPos
.
Classes
.
length
-
2
];
var
Element
=
selectedContent
.
Elements
[
0
].
Element
;
var
InsertMathContent
=
null
;
for
(
var
nPos
=
0
,
nParaLen
=
Element
.
Content
.
length
;
nPos
<
nParaLen
;
nPos
++
)
{
if
(
para_Math
===
Element
.
Content
[
nPos
].
Type
)
{
InsertMathContent
=
Element
.
Content
[
nPos
];
break
;
}
}
if
(
null
===
InsertMathContent
)
{
//try to convert content to ParaMath in simple cases.
InsertMathContent
=
selectedContent
.
ConvertToMath
();
}
if
(
null
!==
InsertMathContent
)
{
MathContent
.
Add_ToContent
(
MathContentPos
+
1
,
NewMathRun
);
MathContent
.
Insert_MathContent
(
InsertMathContent
.
Root
,
MathContentPos
+
1
,
true
);
bInsertMath
=
true
;
}
}
if
(
!
bInsertMath
){
paragraph
.
Check_NearestPos
(
NearPos
);
target_doc_content
.
Insert_Content
(
selectedContent
,
NearPos
);
}
worksheet
.
objectRender
.
controller
.
cursorMoveRight
(
false
,
false
);
...
...
common/wordcopypaste.js
View file @
7abc9f18
...
...
@@ -2119,7 +2119,50 @@ PasteProcessor.prototype =
return
;
}
var
bPasteMath
=
false
;
if
(
this
.
pasteInExcel
)
{
var
Para
=
NearPos
.
Paragraph
;
var
ParaNearPos
=
Para
.
Get_ParaNearestPos
(
NearPos
);
var
LastClass
=
ParaNearPos
.
Classes
[
ParaNearPos
.
Classes
.
length
-
1
];
if
(
para_Math_Run
===
LastClass
.
Type
)
{
var
MathRun
=
LastClass
;
var
NewMathRun
=
MathRun
.
Split
(
ParaNearPos
.
NearPos
.
ContentPos
,
ParaNearPos
.
Classes
.
length
-
1
);
var
MathContent
=
ParaNearPos
.
Classes
[
ParaNearPos
.
Classes
.
length
-
2
];
var
MathContentPos
=
ParaNearPos
.
NearPos
.
ContentPos
.
Data
[
ParaNearPos
.
Classes
.
length
-
2
];
var
Element
=
oSelectedContent
.
Elements
[
0
].
Element
;
var
InsertMathContent
=
null
;
for
(
var
nPos
=
0
,
nParaLen
=
Element
.
Content
.
length
;
nPos
<
nParaLen
;
nPos
++
)
{
if
(
para_Math
===
Element
.
Content
[
nPos
].
Type
)
{
InsertMathContent
=
Element
.
Content
[
nPos
];
break
;
}
}
if
(
null
===
InsertMathContent
)
{
//try to convert content to ParaMath in simple cases.
InsertMathContent
=
oSelectedContent
.
ConvertToMath
();
}
if
(
null
!==
InsertMathContent
)
{
MathContent
.
Add_ToContent
(
MathContentPos
+
1
,
NewMathRun
);
MathContent
.
Insert_MathContent
(
InsertMathContent
.
Root
,
MathContentPos
+
1
,
true
);
bPasteMath
=
true
;
}
}
}
if
(
!
bPasteMath
)
{
paragraph
.
Parent
.
Insert_Content
(
oSelectedContent
,
NearPos
);
}
if
(
oSelectedContent
.
Elements
.
length
===
1
)
{
...
...
slide/Editor/Format/Presentation.js
View file @
7abc9f18
...
...
@@ -4786,6 +4786,7 @@ CPresentation.prototype =
}
else
if
(
Content
.
DocContent
)
{
Content
.
DocContent
.
On_EndCollectElements
(
this
,
false
);
if
(
Content
.
DocContent
.
Elements
.
length
>
0
){
var
oController
=
this
.
GetCurrentController
();
var
target_doc_content
=
oController
.
getTargetDocContent
(
true
),
paragraph
,
NearPos
;
...
...
@@ -4813,18 +4814,18 @@ CPresentation.prototype =
var
Element
=
Content
.
DocContent
.
Elements
[
0
].
Element
;
if
(
1
!==
Content
.
DocContent
.
Elements
.
length
||
type_Paragraph
!==
Element
.
Get_Type
()
||
null
===
LastClass
.
Parent
)
return
;
if
(
!
Content
.
DocContent
.
CanConvertToMath
)
{
var
Math
=
null
;
var
Count
=
Element
.
Content
.
length
;
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
{
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
{
var
Item
=
Element
.
Content
[
Index
];
if
(
para_Math
===
Item
.
Type
&&
null
===
Math
)
Math
=
Element
.
Content
[
Index
];
else
if
(
true
!==
Item
.
Is_Empty
({
SkipEnd
:
true
}))
else
if
(
true
!==
Item
.
Is_Empty
({
SkipEnd
:
true
}))
return
;
}
}
}
else
if
(
para_Run
!==
LastClass
.
Type
)
return
;
...
...
@@ -4832,7 +4833,42 @@ CPresentation.prototype =
return
;
target_doc_content
.
Insert_Content
(
Content
.
DocContent
,
NearPos
);
var
Para
=
NearPos
.
Paragraph
;
var
ParaNearPos
=
Para
.
Get_ParaNearestPos
(
NearPos
);
var
LastClass
=
ParaNearPos
.
Classes
[
ParaNearPos
.
Classes
.
length
-
1
];
var
bInsertMath
=
false
;
if
(
para_Math_Run
===
LastClass
.
Type
)
{
var
MathRun
=
LastClass
;
var
NewMathRun
=
MathRun
.
Split
(
ParaNearPos
.
NearPos
.
ContentPos
,
ParaNearPos
.
Classes
.
length
-
1
);
var
MathContent
=
ParaNearPos
.
Classes
[
ParaNearPos
.
Classes
.
length
-
2
];
var
MathContentPos
=
ParaNearPos
.
NearPos
.
ContentPos
.
Data
[
ParaNearPos
.
Classes
.
length
-
2
];
var
Element
=
Content
.
DocContent
.
Elements
[
0
].
Element
;
var
InsertMathContent
=
null
;
for
(
var
nPos
=
0
,
nParaLen
=
Element
.
Content
.
length
;
nPos
<
nParaLen
;
nPos
++
)
{
if
(
para_Math
===
Element
.
Content
[
nPos
].
Type
)
{
InsertMathContent
=
Element
.
Content
[
nPos
];
break
;
}
}
if
(
null
===
InsertMathContent
)
{
//try to convert content to ParaMath in simple cases.
InsertMathContent
=
Content
.
DocContent
.
ConvertToMath
();
}
if
(
null
!==
InsertMathContent
)
{
MathContent
.
Add_ToContent
(
MathContentPos
+
1
,
NewMathRun
);
MathContent
.
Insert_MathContent
(
InsertMathContent
.
Root
,
MathContentPos
+
1
,
true
);
bInsertMath
=
true
;
}
}
!
bInsertMath
&&
target_doc_content
.
Insert_Content
(
Content
.
DocContent
,
NearPos
);
}
var
oTargetTextObject
=
AscFormat
.
getTargetTextObject
(
this
.
Slides
[
this
.
CurPage
].
graphicObjects
);
oTargetTextObject
&&
oTargetTextObject
.
checkExtentsByDocContent
&&
oTargetTextObject
.
checkExtentsByDocContent
();
...
...
word/Editor/Document.js
View file @
7abc9f18
...
...
@@ -347,6 +347,7 @@ function CSelectedContent()
this
.
HaveShape
=
false
;
this
.
MoveDrawing
=
false
;
// Только для переноса автофигур
this
.
HaveMath
=
false
;
this
.
CanConvertToMath
=
false
;
}
CSelectedContent
.
prototype
=
...
...
@@ -392,6 +393,20 @@ CSelectedContent.prototype =
this
.
HaveMath
=
(
this
.
Maths
.
length
>
0
?
true
:
false
);
// Проверка возможности конвертации имеющегося контента в контент для вставки в формулу.
// Если формулы уже имеются, то ничего не конвертируем.
if
(
!
this
.
HaveMath
)
{
if
(
1
===
Count
)
{
Element
=
this
.
Elements
[
0
];
if
(
type_Paragraph
===
Element
.
Element
.
GetType
()
&&
!
Element
.
Element
.
Is_Empty
({
SkipEnd
:
true
,
SkipAnchor
:
true
,
SkipNewLine
:
true
,
SkipPlcHldr
:
true
})
&&
!
Element
.
SelectedAll
)
{
this
.
CanConvertToMath
=
true
;
}
}
}
// Относительно картинок нас интересует только наличие автофигур с текстом.
Count
=
this
.
DrawingObjects
.
length
;
for
(
var
Pos
=
0
;
Pos
<
Count
;
Pos
++
)
...
...
@@ -479,6 +494,36 @@ CSelectedContent.prototype =
}
}
}
},
/**
* Converts current content to ParaMath if it possible. Doesn't change current SelectedContent.
* @returns {?AscCommonWord.ParaMath}
* */
ConvertToMath
:
function
()
{
if
(
!
this
.
CanConvertToMath
)
{
return
null
;
}
var
oParagraph
=
this
.
Elements
[
0
].
Element
;
var
aContent
=
oParagraph
.
Content
,
aRunContent
;
var
oParaMath
=
new
AscCommonWord
.
ParaMath
();
oParaMath
.
Root
.
Load_FromMenu
(
c_oAscMathType
.
Default_Text
,
oParagraph
);
oParaMath
.
Root
.
Correct_Content
(
true
);
for
(
var
i
=
0
;
i
<
aContent
.
length
;
++
i
)
{
if
(
aContent
[
i
].
Get_Type
()
===
para_Run
)
{
aRunContent
=
aContent
[
i
].
Content
;
for
(
var
j
=
0
;
j
<
aRunContent
.
length
;
++
j
)
{
oParaMath
.
Add
(
aRunContent
[
j
]);
}
}
}
return
oParaMath
;
}
};
...
...
@@ -5729,17 +5774,19 @@ CDocument.prototype.Can_InsertContent = function(SelectedContent, NearPos)
if
(
1
!==
SelectedContent
.
Elements
.
length
||
type_Paragraph
!==
Element
.
GetType
()
||
null
===
LastClass
.
Parent
)
return
false
;
if
(
!
SelectedContent
.
CanConvertToMath
)
{
var
Math
=
null
;
var
Count
=
Element
.
Content
.
length
;
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
{
for
(
var
Index
=
0
;
Index
<
Count
;
Index
++
)
{
var
Item
=
Element
.
Content
[
Index
];
if
(
para_Math
===
Item
.
Type
&&
null
===
Math
)
Math
=
Element
.
Content
[
Index
];
else
if
(
true
!==
Item
.
Is_Empty
({
SkipEnd
:
true
}))
else
if
(
true
!==
Item
.
Is_Empty
({
SkipEnd
:
true
}))
return
false
;
}
}
}
else
if
(
para_Run
!==
LastClass
.
Type
)
return
false
;
...
...
@@ -5771,6 +5818,12 @@ CDocument.prototype.Insert_Content = function(SelectedContent, NearPos)
}
}
if
(
null
===
InsertMathContent
)
{
//try to convert content to ParaMath in simple cases.
InsertMathContent
=
SelectedContent
.
ConvertToMath
();
}
if
(
null
!==
InsertMathContent
)
{
MathContent
.
Add_ToContent
(
MathContentPos
+
1
,
NewMathRun
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment