@hufe921/canvas-editor 0.9.14 → 0.9.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +20 -20
- package/README.md +54 -54
- package/dist/canvas-editor.es.js +155 -50
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +9 -9
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +150 -150
- package/dist/src/editor/core/command/CommandAdapt.d.ts +93 -93
- package/dist/src/editor/core/contextmenu/ContextMenu.d.ts +28 -28
- package/dist/src/editor/core/contextmenu/menus/controlMenus.d.ts +2 -2
- package/dist/src/editor/core/contextmenu/menus/globalMenus.d.ts +2 -2
- package/dist/src/editor/core/contextmenu/menus/hyperlinkMenus.d.ts +2 -2
- package/dist/src/editor/core/contextmenu/menus/imageMenus.d.ts +2 -2
- package/dist/src/editor/core/contextmenu/menus/tableMenus.d.ts +2 -2
- package/dist/src/editor/core/cursor/Cursor.d.ts +17 -15
- package/dist/src/editor/core/cursor/CursorAgent.d.ts +15 -15
- package/dist/src/editor/core/draw/Draw.d.ts +143 -142
- package/dist/src/editor/core/draw/control/Control.d.ts +35 -35
- package/dist/src/editor/core/draw/control/checkbox/CheckboxControl.d.ts +15 -15
- package/dist/src/editor/core/draw/control/select/SelectControl.d.ts +21 -21
- package/dist/src/editor/core/draw/control/text/TextControl.d.ts +13 -13
- package/dist/src/editor/core/draw/frame/Background.d.ts +6 -6
- package/dist/src/editor/core/draw/frame/Header.d.ts +7 -7
- package/dist/src/editor/core/draw/frame/Margin.d.ts +7 -7
- package/dist/src/editor/core/draw/frame/PageNumber.d.ts +7 -7
- package/dist/src/editor/core/draw/frame/Watermark.d.ts +7 -7
- package/dist/src/editor/core/draw/interactive/Search.d.ts +26 -26
- package/dist/src/editor/core/draw/particle/CheckboxParticle.d.ts +7 -7
- package/dist/src/editor/core/draw/particle/HyperlinkParticle.d.ts +16 -16
- package/dist/src/editor/core/draw/particle/ImageParticle.d.ts +9 -9
- package/dist/src/editor/core/draw/particle/PageBreak.d.ts +12 -12
- package/dist/src/editor/core/draw/particle/Separator.d.ts +4 -4
- package/dist/src/editor/core/draw/particle/Subscript.d.ts +4 -4
- package/dist/src/editor/core/draw/particle/Superscript.d.ts +4 -4
- package/dist/src/editor/core/draw/particle/TextParticle.d.ts +18 -18
- package/dist/src/editor/core/draw/particle/block/BlockParticle.d.ts +14 -14
- package/dist/src/editor/core/draw/particle/block/modules/BaseBlock.d.ts +15 -15
- package/dist/src/editor/core/draw/particle/block/modules/IFrameBlock.d.ts +7 -7
- package/dist/src/editor/core/draw/particle/block/modules/VideoBlock.d.ts +6 -6
- package/dist/src/editor/core/draw/particle/date/DateParticle.d.ts +14 -14
- package/dist/src/editor/core/draw/particle/date/DatePicker.d.ts +64 -64
- package/dist/src/editor/core/draw/particle/latex/LaTexParticle.d.ts +7 -7
- package/dist/src/editor/core/draw/particle/latex/utils/LaTexUtils.d.ts +47 -47
- package/dist/src/editor/core/draw/particle/latex/utils/hershey.d.ts +10 -10
- package/dist/src/editor/core/draw/particle/latex/utils/symbols.d.ts +8 -8
- package/dist/src/editor/core/draw/particle/previewer/Previewer.d.ts +34 -34
- package/dist/src/editor/core/draw/particle/table/TableParticle.d.ts +11 -11
- package/dist/src/editor/core/draw/particle/table/TableTool.d.ts +22 -22
- package/dist/src/editor/core/draw/richtext/AbstractRichText.d.ts +14 -14
- package/dist/src/editor/core/draw/richtext/Highlight.d.ts +7 -7
- package/dist/src/editor/core/draw/richtext/Strikeout.d.ts +7 -7
- package/dist/src/editor/core/draw/richtext/Underline.d.ts +7 -7
- package/dist/src/editor/core/event/CanvasEvent.d.ts +48 -41
- package/dist/src/editor/core/event/GlobalEvent.d.ts +26 -24
- package/dist/src/editor/core/event/handlers/click.d.ts +8 -8
- package/dist/src/editor/core/event/handlers/composition.d.ts +8 -8
- package/dist/src/editor/core/event/handlers/copy.d.ts +2 -2
- package/dist/src/editor/core/event/handlers/cut.d.ts +2 -2
- package/dist/src/editor/core/event/handlers/drag.d.ts +6 -6
- package/dist/src/editor/core/event/handlers/drop.d.ts +2 -2
- package/dist/src/editor/core/event/handlers/input.d.ts +3 -2
- package/dist/src/editor/core/event/handlers/keydown.d.ts +2 -2
- package/dist/src/editor/core/event/handlers/mousedown.d.ts +2 -2
- package/dist/src/editor/core/event/handlers/mouseleave.d.ts +2 -2
- package/dist/src/editor/core/event/handlers/mousemove.d.ts +2 -2
- package/dist/src/editor/core/event/handlers/mouseup.d.ts +2 -2
- package/dist/src/editor/core/history/HistoryManager.d.ts +10 -10
- package/dist/src/editor/core/i18n/I18n.d.ts +10 -9
- package/dist/src/editor/core/listener/Listener.d.ts +13 -13
- package/dist/src/editor/core/observer/ScrollObserver.d.ts +11 -11
- package/dist/src/editor/core/observer/SelectionObserver.d.ts +18 -18
- package/dist/src/editor/core/position/Position.d.ts +20 -20
- package/dist/src/editor/core/range/RangeManager.d.ts +22 -22
- package/dist/src/editor/core/register/Register.d.ts +19 -18
- package/dist/src/editor/core/shortcut/Shortcut.d.ts +16 -16
- package/dist/src/editor/core/shortcut/keys/richtextKeys.d.ts +2 -2
- package/dist/src/editor/core/worker/WorkerManager.d.ts +7 -7
- package/dist/src/editor/core/worker/works/wordCount.d.ts +1 -1
- package/dist/src/editor/dataset/constant/Checkbox.d.ts +2 -2
- package/dist/src/editor/dataset/constant/Common.d.ts +4 -4
- package/dist/src/editor/dataset/constant/ContextMenu.d.ts +3 -3
- package/dist/src/editor/dataset/constant/Control.d.ts +2 -2
- package/dist/src/editor/dataset/constant/Cursor.d.ts +1 -1
- package/dist/src/editor/dataset/constant/Editor.d.ts +2 -2
- package/dist/src/editor/dataset/constant/Element.d.ts +6 -6
- package/dist/src/editor/dataset/constant/Header.d.ts +2 -2
- package/dist/src/editor/dataset/constant/Regular.d.ts +4 -4
- package/dist/src/editor/dataset/constant/Watermark.d.ts +2 -2
- package/dist/src/editor/dataset/enum/Block.d.ts +4 -4
- package/dist/src/editor/dataset/enum/Control.d.ts +16 -16
- package/dist/src/editor/dataset/enum/Editor.d.ts +21 -21
- package/dist/src/editor/dataset/enum/Element.d.ts +16 -16
- package/dist/src/editor/dataset/enum/ElementStyle.d.ts +12 -12
- package/dist/src/editor/dataset/enum/Event.d.ts +5 -5
- package/dist/src/editor/dataset/enum/KeyMap.d.ts +83 -82
- package/dist/src/editor/dataset/enum/Observer.d.ts +6 -6
- package/dist/src/editor/dataset/enum/Row.d.ts +6 -6
- package/dist/src/editor/dataset/enum/table/TableTool.d.ts +4 -4
- package/dist/src/editor/index.d.ts +27 -27
- package/dist/src/editor/interface/Block.d.ts +12 -12
- package/dist/src/editor/interface/Checkbox.d.ts +13 -13
- package/dist/src/editor/interface/Common.d.ts +8 -5
- package/dist/src/editor/interface/Control.d.ts +50 -50
- package/dist/src/editor/interface/Draw.d.ts +30 -30
- package/dist/src/editor/interface/Editor.d.ts +55 -55
- package/dist/src/editor/interface/Element.d.ts +99 -99
- package/dist/src/editor/interface/Header.d.ts +6 -6
- package/dist/src/editor/interface/Listener.d.ts +29 -29
- package/dist/src/editor/interface/Margin.d.ts +1 -1
- package/dist/src/editor/interface/Position.d.ts +37 -37
- package/dist/src/editor/interface/Previewer.d.ts +11 -11
- package/dist/src/editor/interface/Range.d.ts +11 -11
- package/dist/src/editor/interface/Row.d.ts +14 -14
- package/dist/src/editor/interface/Search.d.ts +14 -14
- package/dist/src/editor/interface/Watermark.d.ts +7 -7
- package/dist/src/editor/interface/contextmenu/ContextMenu.d.ts +60 -60
- package/dist/src/editor/interface/i18n/I18n.d.ts +6 -6
- package/dist/src/editor/interface/shortcut/Shortcut.d.ts +12 -10
- package/dist/src/editor/interface/table/Colgroup.d.ts +4 -4
- package/dist/src/editor/interface/table/Td.d.ts +19 -19
- package/dist/src/editor/interface/table/Tr.d.ts +6 -6
- package/dist/src/editor/utils/clipboard.d.ts +9 -9
- package/dist/src/editor/utils/element.d.ts +11 -11
- package/dist/src/editor/utils/hotkey.d.ts +1 -0
- package/dist/src/editor/utils/index.d.ts +11 -8
- package/dist/src/editor/utils/print.d.ts +1 -1
- package/dist/src/editor/utils/ua.d.ts +1 -0
- package/package.json +64 -64
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2021-present, hufe
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in
|
|
13
|
-
all copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2021-present, hufe
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
21
|
THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
<h1 align="center">canvas-editor</h1>
|
|
2
|
-
|
|
3
|
-
<p align="center"> a rich text editor by canvas/svg</p>
|
|
4
|
-
|
|
5
|
-
## tips
|
|
6
|
-
|
|
7
|
-
1. [docs](https://hufe.club/canvas-editor-docs/)
|
|
8
|
-
2. The render layer by svg is under development, see [feature/svg](https://github.com/Hufe921/canvas-editor/tree/feature/svg)
|
|
9
|
-
3. The export pdf feature is available now, see [feature/pdf](https://github.com/Hufe921/canvas-editor/tree/feature/pdf)
|
|
10
|
-
|
|
11
|
-
## usage
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm i @hufe921/canvas-editor --save
|
|
15
|
-
```
|
|
16
|
-
```html
|
|
17
|
-
<div class="canvas-editor"></div>
|
|
18
|
-
```
|
|
19
|
-
```javascript
|
|
20
|
-
import Editor from "@hufe921/canvas-editor"
|
|
21
|
-
|
|
22
|
-
new Editor(document.querySelector(".canvas-editor"), [
|
|
23
|
-
{
|
|
24
|
-
value: "Hello World"
|
|
25
|
-
}
|
|
26
|
-
])
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
## snapshot
|
|
30
|
-
|
|
31
|
-

|
|
32
|
-
|
|
33
|
-
## next features
|
|
34
|
-
|
|
35
|
-
1.
|
|
36
|
-
2.
|
|
37
|
-
3.
|
|
38
|
-
4.
|
|
39
|
-
5.
|
|
40
|
-
|
|
41
|
-
## install
|
|
42
|
-
|
|
43
|
-
`yarn`
|
|
44
|
-
|
|
45
|
-
## dev
|
|
46
|
-
|
|
47
|
-
`yarn run dev`
|
|
48
|
-
|
|
49
|
-
## build
|
|
50
|
-
|
|
51
|
-
#### app
|
|
52
|
-
`yarn run build`
|
|
53
|
-
|
|
54
|
-
#### lib
|
|
1
|
+
<h1 align="center">canvas-editor</h1>
|
|
2
|
+
|
|
3
|
+
<p align="center"> a rich text editor by canvas/svg</p>
|
|
4
|
+
|
|
5
|
+
## tips
|
|
6
|
+
|
|
7
|
+
1. [docs](https://hufe.club/canvas-editor-docs/)
|
|
8
|
+
2. The render layer by svg is under development, see [feature/svg](https://github.com/Hufe921/canvas-editor/tree/feature/svg)
|
|
9
|
+
3. The export pdf feature is available now, see [feature/pdf](https://github.com/Hufe921/canvas-editor/tree/feature/pdf)
|
|
10
|
+
|
|
11
|
+
## usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm i @hufe921/canvas-editor --save
|
|
15
|
+
```
|
|
16
|
+
```html
|
|
17
|
+
<div class="canvas-editor"></div>
|
|
18
|
+
```
|
|
19
|
+
```javascript
|
|
20
|
+
import Editor from "@hufe921/canvas-editor"
|
|
21
|
+
|
|
22
|
+
new Editor(document.querySelector(".canvas-editor"), [
|
|
23
|
+
{
|
|
24
|
+
value: "Hello World"
|
|
25
|
+
}
|
|
26
|
+
])
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## snapshot
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
33
|
+
## next features
|
|
34
|
+
|
|
35
|
+
1. support mac os
|
|
36
|
+
2. drag text (optimization)
|
|
37
|
+
3. page header and footer
|
|
38
|
+
4. control rules
|
|
39
|
+
5. table paging
|
|
40
|
+
|
|
41
|
+
## install
|
|
42
|
+
|
|
43
|
+
`yarn`
|
|
44
|
+
|
|
45
|
+
## dev
|
|
46
|
+
|
|
47
|
+
`yarn run dev`
|
|
48
|
+
|
|
49
|
+
## build
|
|
50
|
+
|
|
51
|
+
#### app
|
|
52
|
+
`yarn run build`
|
|
53
|
+
|
|
54
|
+
#### lib
|
|
55
55
|
`yarn run lib`
|
package/dist/canvas-editor.es.js
CHANGED
|
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
25
25
|
var index = "";
|
|
26
|
-
const version = "0.9.
|
|
26
|
+
const version = "0.9.16";
|
|
27
27
|
const ZERO = "\u200B";
|
|
28
28
|
const WRAP = "\n";
|
|
29
29
|
var RowFlex;
|
|
@@ -109,6 +109,27 @@ function nClickEvent(n, dom, fn) {
|
|
|
109
109
|
};
|
|
110
110
|
dom.addEventListener("click", handler);
|
|
111
111
|
}
|
|
112
|
+
function isObject(type) {
|
|
113
|
+
return Object.prototype.toString.call(type) === "[object Object]";
|
|
114
|
+
}
|
|
115
|
+
function isArray(type) {
|
|
116
|
+
return Array.isArray(type);
|
|
117
|
+
}
|
|
118
|
+
function mergeObject(source, target) {
|
|
119
|
+
if (isObject(source) && isObject(target)) {
|
|
120
|
+
const objectTarget = target;
|
|
121
|
+
for (const [key, val] of Object.entries(source)) {
|
|
122
|
+
if (!objectTarget[key]) {
|
|
123
|
+
objectTarget[key] = val;
|
|
124
|
+
} else {
|
|
125
|
+
objectTarget[key] = mergeObject(val, objectTarget[key]);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
} else if (isArray(source) && isArray(target)) {
|
|
129
|
+
target.push(...source);
|
|
130
|
+
}
|
|
131
|
+
return target;
|
|
132
|
+
}
|
|
112
133
|
const CURSOR_AGENT_HEIGHT = 12;
|
|
113
134
|
const EDITOR_COMPONENT = "editor-component";
|
|
114
135
|
const EDITOR_PREFIX = "ce";
|
|
@@ -3907,8 +3928,8 @@ class CursorAgent {
|
|
|
3907
3928
|
_compositionstart() {
|
|
3908
3929
|
this.canvasEvent.compositionstart();
|
|
3909
3930
|
}
|
|
3910
|
-
_compositionend() {
|
|
3911
|
-
this.canvasEvent.compositionend();
|
|
3931
|
+
_compositionend(evt) {
|
|
3932
|
+
this.canvasEvent.compositionend(evt);
|
|
3912
3933
|
}
|
|
3913
3934
|
}
|
|
3914
3935
|
class Cursor {
|
|
@@ -3934,6 +3955,12 @@ class Cursor {
|
|
|
3934
3955
|
getAgentDom() {
|
|
3935
3956
|
return this.cursorAgent.getAgentCursorDom();
|
|
3936
3957
|
}
|
|
3958
|
+
getAgentDomValue() {
|
|
3959
|
+
return this.getAgentDom().value;
|
|
3960
|
+
}
|
|
3961
|
+
clearAgentDomValue() {
|
|
3962
|
+
return this.getAgentDom().value = "";
|
|
3963
|
+
}
|
|
3937
3964
|
drawCursor() {
|
|
3938
3965
|
const isReadonly = this.draw.isReadonly();
|
|
3939
3966
|
const cursorPosition = this.position.getCursorPosition();
|
|
@@ -3986,6 +4013,7 @@ var KeyMap;
|
|
|
3986
4013
|
KeyMap2["Down"] = "ArrowDown";
|
|
3987
4014
|
KeyMap2["ESC"] = "Escape";
|
|
3988
4015
|
KeyMap2["TAB"] = "Tab";
|
|
4016
|
+
KeyMap2["META"] = "Meta";
|
|
3989
4017
|
KeyMap2["LEFT_BRACKET"] = "[";
|
|
3990
4018
|
KeyMap2["RIGHT_BRACKET"] = "]";
|
|
3991
4019
|
KeyMap2["COMMA"] = ",";
|
|
@@ -4371,8 +4399,14 @@ function mousemove(evt, host) {
|
|
|
4371
4399
|
isComputeRowList: false
|
|
4372
4400
|
});
|
|
4373
4401
|
}
|
|
4402
|
+
const isApple = typeof navigator !== "undefined" && /Mac OS X/.test(navigator.userAgent);
|
|
4403
|
+
function isMod(evt) {
|
|
4404
|
+
return isApple ? evt.metaKey : evt.ctrlKey;
|
|
4405
|
+
}
|
|
4374
4406
|
function keydown(evt, host) {
|
|
4375
4407
|
var _a;
|
|
4408
|
+
if (host.isComposing)
|
|
4409
|
+
return;
|
|
4376
4410
|
const draw = host.getDraw();
|
|
4377
4411
|
const position = draw.getPosition();
|
|
4378
4412
|
const cursorPosition = position.getCursorPosition();
|
|
@@ -4588,26 +4622,26 @@ function keydown(evt, host) {
|
|
|
4588
4622
|
isComputeRowList: false
|
|
4589
4623
|
});
|
|
4590
4624
|
}
|
|
4591
|
-
} else if (evt
|
|
4625
|
+
} else if (isMod(evt) && evt.key === KeyMap.Z) {
|
|
4592
4626
|
if (isReadonly)
|
|
4593
4627
|
return;
|
|
4594
4628
|
historyManager.undo();
|
|
4595
4629
|
evt.preventDefault();
|
|
4596
|
-
} else if (evt
|
|
4630
|
+
} else if (isMod(evt) && evt.key === KeyMap.Y) {
|
|
4597
4631
|
if (isReadonly)
|
|
4598
4632
|
return;
|
|
4599
4633
|
historyManager.redo();
|
|
4600
4634
|
evt.preventDefault();
|
|
4601
|
-
} else if (evt
|
|
4635
|
+
} else if (isMod(evt) && evt.key === KeyMap.C) {
|
|
4602
4636
|
host.copy();
|
|
4603
4637
|
evt.preventDefault();
|
|
4604
|
-
} else if (evt
|
|
4638
|
+
} else if (isMod(evt) && evt.key === KeyMap.X) {
|
|
4605
4639
|
host.cut();
|
|
4606
4640
|
evt.preventDefault();
|
|
4607
|
-
} else if (evt
|
|
4641
|
+
} else if (isMod(evt) && evt.key === KeyMap.A) {
|
|
4608
4642
|
host.selectAll();
|
|
4609
4643
|
evt.preventDefault();
|
|
4610
|
-
} else if (evt
|
|
4644
|
+
} else if (isMod(evt) && evt.key === KeyMap.S) {
|
|
4611
4645
|
if (isReadonly)
|
|
4612
4646
|
return;
|
|
4613
4647
|
const listener = draw.getListener();
|
|
@@ -4634,23 +4668,24 @@ function input(data2, host) {
|
|
|
4634
4668
|
return;
|
|
4635
4669
|
const position = draw.getPosition();
|
|
4636
4670
|
const cursorPosition = position.getCursorPosition();
|
|
4637
|
-
if (!data2 || !cursorPosition
|
|
4671
|
+
if (!data2 || !cursorPosition)
|
|
4638
4672
|
return;
|
|
4639
4673
|
const control = draw.getControl();
|
|
4640
4674
|
if (control.isPartRangeInControlOutside()) {
|
|
4641
4675
|
return;
|
|
4642
4676
|
}
|
|
4677
|
+
if (!host.isComposing) {
|
|
4678
|
+
const cursor = draw.getCursor();
|
|
4679
|
+
cursor.clearAgentDomValue();
|
|
4680
|
+
} else {
|
|
4681
|
+
removeComposingInput(host);
|
|
4682
|
+
}
|
|
4643
4683
|
const activeControl = control.getActiveControl();
|
|
4644
4684
|
const { TEXT, HYPERLINK, SUBSCRIPT, SUPERSCRIPT, DATE } = ElementType;
|
|
4645
4685
|
const text = data2.replaceAll(`
|
|
4646
4686
|
`, ZERO);
|
|
4647
|
-
const cursor = draw.getCursor();
|
|
4648
|
-
const agentDom = cursor.getAgentDom();
|
|
4649
|
-
agentDom.value = "";
|
|
4650
|
-
const { index: index2 } = cursorPosition;
|
|
4651
4687
|
const rangeManager = draw.getRange();
|
|
4652
4688
|
const { startIndex, endIndex } = rangeManager.getRange();
|
|
4653
|
-
const isCollapsed = startIndex === endIndex;
|
|
4654
4689
|
const positionContext = position.getPositionContext();
|
|
4655
4690
|
let restArg = {};
|
|
4656
4691
|
if (positionContext.isTable) {
|
|
@@ -4672,26 +4707,45 @@ function input(data2, host) {
|
|
|
4672
4707
|
}
|
|
4673
4708
|
});
|
|
4674
4709
|
}
|
|
4710
|
+
if (host.isComposing) {
|
|
4711
|
+
newElement.underline = true;
|
|
4712
|
+
}
|
|
4675
4713
|
return newElement;
|
|
4676
4714
|
});
|
|
4677
4715
|
let curIndex;
|
|
4678
4716
|
if (activeControl && ((_a = elementList[endIndex + 1]) == null ? void 0 : _a.controlId) === element.controlId) {
|
|
4679
4717
|
curIndex = control.setValue(inputData);
|
|
4680
4718
|
} else {
|
|
4681
|
-
|
|
4682
|
-
if (
|
|
4683
|
-
start
|
|
4684
|
-
} else {
|
|
4685
|
-
start = startIndex + 1;
|
|
4686
|
-
elementList.splice(startIndex + 1, endIndex - startIndex);
|
|
4719
|
+
const start = startIndex + 1;
|
|
4720
|
+
if (startIndex !== endIndex) {
|
|
4721
|
+
elementList.splice(start, endIndex - startIndex);
|
|
4687
4722
|
}
|
|
4688
4723
|
for (let i = 0; i < inputData.length; i++) {
|
|
4689
4724
|
elementList.splice(start + i, 0, inputData[i]);
|
|
4690
4725
|
}
|
|
4691
|
-
curIndex =
|
|
4726
|
+
curIndex = startIndex + inputData.length;
|
|
4692
4727
|
}
|
|
4693
4728
|
rangeManager.setRange(curIndex, curIndex);
|
|
4694
|
-
draw.render({
|
|
4729
|
+
draw.render({
|
|
4730
|
+
curIndex
|
|
4731
|
+
});
|
|
4732
|
+
if (host.isComposing) {
|
|
4733
|
+
host.compositionInfo = {
|
|
4734
|
+
elementList,
|
|
4735
|
+
value: text,
|
|
4736
|
+
startIndex: curIndex - inputData.length,
|
|
4737
|
+
endIndex: curIndex
|
|
4738
|
+
};
|
|
4739
|
+
}
|
|
4740
|
+
}
|
|
4741
|
+
function removeComposingInput(host) {
|
|
4742
|
+
if (!host.compositionInfo)
|
|
4743
|
+
return;
|
|
4744
|
+
const { elementList, startIndex, endIndex } = host.compositionInfo;
|
|
4745
|
+
elementList.splice(startIndex + 1, endIndex - startIndex);
|
|
4746
|
+
const rangeManager = host.getDraw().getRange();
|
|
4747
|
+
rangeManager.setRange(startIndex, startIndex);
|
|
4748
|
+
host.compositionInfo = null;
|
|
4695
4749
|
}
|
|
4696
4750
|
function cut(host) {
|
|
4697
4751
|
const draw = host.getDraw();
|
|
@@ -4845,10 +4899,26 @@ var click = {
|
|
|
4845
4899
|
threeClick
|
|
4846
4900
|
};
|
|
4847
4901
|
function compositionstart(host) {
|
|
4848
|
-
host.
|
|
4902
|
+
host.isComposing = true;
|
|
4849
4903
|
}
|
|
4850
|
-
function compositionend(host) {
|
|
4851
|
-
host.
|
|
4904
|
+
function compositionend(host, evt) {
|
|
4905
|
+
host.isComposing = false;
|
|
4906
|
+
removeComposingInput(host);
|
|
4907
|
+
const draw = host.getDraw();
|
|
4908
|
+
const cursor = draw.getCursor();
|
|
4909
|
+
if (!evt.data) {
|
|
4910
|
+
const agentText = cursor.getAgentDomValue();
|
|
4911
|
+
if (agentText) {
|
|
4912
|
+
input(agentText, host);
|
|
4913
|
+
} else {
|
|
4914
|
+
const rangeManager = draw.getRange();
|
|
4915
|
+
const { endIndex: curIndex } = rangeManager.getRange();
|
|
4916
|
+
draw.render({
|
|
4917
|
+
curIndex
|
|
4918
|
+
});
|
|
4919
|
+
}
|
|
4920
|
+
}
|
|
4921
|
+
cursor.clearAgentDomValue();
|
|
4852
4922
|
}
|
|
4853
4923
|
var composition = {
|
|
4854
4924
|
compositionstart,
|
|
@@ -4890,7 +4960,8 @@ var drag = {
|
|
|
4890
4960
|
class CanvasEvent {
|
|
4891
4961
|
constructor(draw) {
|
|
4892
4962
|
__publicField(this, "isAllowSelection");
|
|
4893
|
-
__publicField(this, "
|
|
4963
|
+
__publicField(this, "isComposing");
|
|
4964
|
+
__publicField(this, "compositionInfo");
|
|
4894
4965
|
__publicField(this, "isAllowDrag");
|
|
4895
4966
|
__publicField(this, "isAllowDrop");
|
|
4896
4967
|
__publicField(this, "cacheRange");
|
|
@@ -4908,7 +4979,8 @@ class CanvasEvent {
|
|
|
4908
4979
|
this.range = this.draw.getRange();
|
|
4909
4980
|
this.position = this.draw.getPosition();
|
|
4910
4981
|
this.isAllowSelection = false;
|
|
4911
|
-
this.
|
|
4982
|
+
this.isComposing = false;
|
|
4983
|
+
this.compositionInfo = null;
|
|
4912
4984
|
this.isAllowDrag = false;
|
|
4913
4985
|
this.isAllowDrop = false;
|
|
4914
4986
|
this.cacheRange = null;
|
|
@@ -5007,8 +5079,8 @@ class CanvasEvent {
|
|
|
5007
5079
|
compositionstart() {
|
|
5008
5080
|
composition.compositionstart(this);
|
|
5009
5081
|
}
|
|
5010
|
-
compositionend() {
|
|
5011
|
-
composition.compositionend(this);
|
|
5082
|
+
compositionend(evt) {
|
|
5083
|
+
composition.compositionend(this, evt);
|
|
5012
5084
|
}
|
|
5013
5085
|
drop(evt) {
|
|
5014
5086
|
drop(evt, this);
|
|
@@ -5030,6 +5102,7 @@ class GlobalEvent {
|
|
|
5030
5102
|
__publicField(this, "hyperlinkParticle");
|
|
5031
5103
|
__publicField(this, "control");
|
|
5032
5104
|
__publicField(this, "dateParticle");
|
|
5105
|
+
__publicField(this, "dprMediaQueryList");
|
|
5033
5106
|
__publicField(this, "recoverEffect", (evt) => {
|
|
5034
5107
|
if (!this.cursor)
|
|
5035
5108
|
return;
|
|
@@ -5083,6 +5156,9 @@ class GlobalEvent {
|
|
|
5083
5156
|
(_a = this.cursor) == null ? void 0 : _a.drawCursor();
|
|
5084
5157
|
}
|
|
5085
5158
|
});
|
|
5159
|
+
__publicField(this, "_handleDprChange", () => {
|
|
5160
|
+
this.draw.setPageDevicePixel();
|
|
5161
|
+
});
|
|
5086
5162
|
this.draw = draw;
|
|
5087
5163
|
this.canvas = draw.getPage();
|
|
5088
5164
|
this.options = draw.getOptions();
|
|
@@ -5094,6 +5170,7 @@ class GlobalEvent {
|
|
|
5094
5170
|
this.hyperlinkParticle = draw.getHyperlinkParticle();
|
|
5095
5171
|
this.dateParticle = draw.getDateParticle();
|
|
5096
5172
|
this.control = draw.getControl();
|
|
5173
|
+
this.dprMediaQueryList = window.matchMedia(`(resolution: ${window.devicePixelRatio}dppx)`);
|
|
5097
5174
|
}
|
|
5098
5175
|
register() {
|
|
5099
5176
|
this.cursor = this.draw.getCursor();
|
|
@@ -5106,6 +5183,7 @@ class GlobalEvent {
|
|
|
5106
5183
|
document.addEventListener("mouseup", this.setCanvasEventAbility);
|
|
5107
5184
|
document.addEventListener("wheel", this.setPageScale, { passive: false });
|
|
5108
5185
|
document.addEventListener("visibilitychange", this._handleVisibilityChange);
|
|
5186
|
+
this.dprMediaQueryList.addEventListener("change", this._handleDprChange);
|
|
5109
5187
|
}
|
|
5110
5188
|
removeEvent() {
|
|
5111
5189
|
window.removeEventListener("blur", this.recoverEffect);
|
|
@@ -5114,6 +5192,7 @@ class GlobalEvent {
|
|
|
5114
5192
|
document.removeEventListener("mouseup", this.setCanvasEventAbility);
|
|
5115
5193
|
document.removeEventListener("wheel", this.setPageScale);
|
|
5116
5194
|
document.removeEventListener("visibilitychange", this._handleVisibilityChange);
|
|
5195
|
+
this.dprMediaQueryList.removeEventListener("change", this._handleDprChange);
|
|
5117
5196
|
}
|
|
5118
5197
|
}
|
|
5119
5198
|
class HistoryManager {
|
|
@@ -8540,7 +8619,8 @@ class I18n {
|
|
|
8540
8619
|
__publicField(this, "currentLocale", "zhCN");
|
|
8541
8620
|
}
|
|
8542
8621
|
registerLangMap(locale, lang) {
|
|
8543
|
-
this.langMap.
|
|
8622
|
+
const sourceLang = this.langMap.get(locale);
|
|
8623
|
+
this.langMap.set(locale, mergeObject(sourceLang || zhCN, lang));
|
|
8544
8624
|
}
|
|
8545
8625
|
setLocale(locale) {
|
|
8546
8626
|
this.currentLocale = locale;
|
|
@@ -8910,16 +8990,20 @@ class Draw {
|
|
|
8910
8990
|
});
|
|
8911
8991
|
}
|
|
8912
8992
|
setPageScale(payload) {
|
|
8993
|
+
const dpr = window.devicePixelRatio;
|
|
8913
8994
|
this.options.scale = payload;
|
|
8914
8995
|
const width = this.getWidth();
|
|
8915
8996
|
const height = this.getHeight();
|
|
8916
8997
|
this.container.style.width = `${width}px`;
|
|
8917
|
-
this.pageList.forEach((p) => {
|
|
8998
|
+
this.pageList.forEach((p, i) => {
|
|
8918
8999
|
p.width = width;
|
|
8919
9000
|
p.height = height;
|
|
8920
9001
|
p.style.width = `${width}px`;
|
|
8921
9002
|
p.style.height = `${height}px`;
|
|
8922
9003
|
p.style.marginBottom = `${this.getPageGap()}px`;
|
|
9004
|
+
p.width = width * dpr;
|
|
9005
|
+
p.height = height * dpr;
|
|
9006
|
+
this.ctxList[i].scale(dpr, dpr);
|
|
8923
9007
|
});
|
|
8924
9008
|
this.render({
|
|
8925
9009
|
isSubmitHistory: false,
|
|
@@ -8929,6 +9013,20 @@ class Draw {
|
|
|
8929
9013
|
this.listener.pageScaleChange(payload);
|
|
8930
9014
|
}
|
|
8931
9015
|
}
|
|
9016
|
+
setPageDevicePixel() {
|
|
9017
|
+
const dpr = window.devicePixelRatio;
|
|
9018
|
+
const width = this.getWidth();
|
|
9019
|
+
const height = this.getHeight();
|
|
9020
|
+
this.pageList.forEach((p, i) => {
|
|
9021
|
+
p.width = width * dpr;
|
|
9022
|
+
p.height = height * dpr;
|
|
9023
|
+
this.ctxList[i].scale(dpr, dpr);
|
|
9024
|
+
});
|
|
9025
|
+
this.render({
|
|
9026
|
+
isSubmitHistory: false,
|
|
9027
|
+
isSetCursor: false
|
|
9028
|
+
});
|
|
9029
|
+
}
|
|
8932
9030
|
setPaperSize(width, height) {
|
|
8933
9031
|
this.options.width = width;
|
|
8934
9032
|
this.options.height = height;
|
|
@@ -9320,14 +9418,21 @@ class Draw {
|
|
|
9320
9418
|
} else {
|
|
9321
9419
|
this.textParticle.record(ctx, element, x, y + offsetY);
|
|
9322
9420
|
}
|
|
9421
|
+
const preElement = curRow.elementList[j - 1];
|
|
9323
9422
|
if (element.underline) {
|
|
9324
9423
|
this.underline.recordFillInfo(ctx, x, y + curRow.height, metrics.width, 0, element.color);
|
|
9424
|
+
} else if (preElement && preElement.underline) {
|
|
9425
|
+
this.underline.render(ctx);
|
|
9325
9426
|
}
|
|
9326
9427
|
if (element.strikeout) {
|
|
9327
9428
|
this.strikeout.recordFillInfo(ctx, x, y + curRow.height / 2, metrics.width);
|
|
9429
|
+
} else if (preElement && preElement.strikeout) {
|
|
9430
|
+
this.strikeout.render(ctx);
|
|
9328
9431
|
}
|
|
9329
9432
|
if (element.highlight) {
|
|
9330
9433
|
this.highlight.recordFillInfo(ctx, x, y, metrics.width, curRow.height, element.highlight);
|
|
9434
|
+
} else if (preElement && preElement.highlight) {
|
|
9435
|
+
this.highlight.render(ctx);
|
|
9331
9436
|
}
|
|
9332
9437
|
const { startIndex: startIndex2, endIndex } = this.range.getRange();
|
|
9333
9438
|
if (startIndex2 !== endIndex && startIndex2 <= index2 && index2 <= endIndex) {
|
|
@@ -11386,7 +11491,7 @@ const controlMenus = [
|
|
|
11386
11491
|
const globalMenus = [
|
|
11387
11492
|
{
|
|
11388
11493
|
i18nPath: "contextmenu.global.cut",
|
|
11389
|
-
shortCut: "Ctrl + X
|
|
11494
|
+
shortCut: `${isApple ? "\u2318" : "Ctrl"} + X`,
|
|
11390
11495
|
when: (payload) => {
|
|
11391
11496
|
return !payload.isReadonly;
|
|
11392
11497
|
},
|
|
@@ -11396,7 +11501,7 @@ const globalMenus = [
|
|
|
11396
11501
|
},
|
|
11397
11502
|
{
|
|
11398
11503
|
i18nPath: "contextmenu.global.copy",
|
|
11399
|
-
shortCut: "Ctrl + C
|
|
11504
|
+
shortCut: `${isApple ? "\u2318" : "Ctrl"} + C`,
|
|
11400
11505
|
when: (payload) => {
|
|
11401
11506
|
return payload.editorHasSelection;
|
|
11402
11507
|
},
|
|
@@ -11406,7 +11511,7 @@ const globalMenus = [
|
|
|
11406
11511
|
},
|
|
11407
11512
|
{
|
|
11408
11513
|
i18nPath: "contextmenu.global.paste",
|
|
11409
|
-
shortCut: "Ctrl + V
|
|
11514
|
+
shortCut: `${isApple ? "\u2318" : "Ctrl"} + V`,
|
|
11410
11515
|
when: (payload) => {
|
|
11411
11516
|
return !payload.isReadonly && payload.editorTextFocus;
|
|
11412
11517
|
},
|
|
@@ -11416,7 +11521,7 @@ const globalMenus = [
|
|
|
11416
11521
|
},
|
|
11417
11522
|
{
|
|
11418
11523
|
i18nPath: "contextmenu.global.selectAll",
|
|
11419
|
-
shortCut: "Ctrl + A
|
|
11524
|
+
shortCut: `${isApple ? "\u2318" : "Ctrl"} + A`,
|
|
11420
11525
|
when: (payload) => {
|
|
11421
11526
|
return payload.editorTextFocus;
|
|
11422
11527
|
},
|
|
@@ -11870,50 +11975,50 @@ const richtextKeys = [
|
|
|
11870
11975
|
},
|
|
11871
11976
|
{
|
|
11872
11977
|
key: KeyMap.LEFT_BRACKET,
|
|
11873
|
-
|
|
11978
|
+
mod: true,
|
|
11874
11979
|
callback: (command) => {
|
|
11875
11980
|
command.executeSizeAdd();
|
|
11876
11981
|
}
|
|
11877
11982
|
},
|
|
11878
11983
|
{
|
|
11879
11984
|
key: KeyMap.RIGHT_BRACKET,
|
|
11880
|
-
|
|
11985
|
+
mod: true,
|
|
11881
11986
|
callback: (command) => {
|
|
11882
11987
|
command.executeSizeMinus();
|
|
11883
11988
|
}
|
|
11884
11989
|
},
|
|
11885
11990
|
{
|
|
11886
11991
|
key: KeyMap.B,
|
|
11887
|
-
|
|
11992
|
+
mod: true,
|
|
11888
11993
|
callback: (command) => {
|
|
11889
11994
|
command.executeBold();
|
|
11890
11995
|
}
|
|
11891
11996
|
},
|
|
11892
11997
|
{
|
|
11893
11998
|
key: KeyMap.I,
|
|
11894
|
-
|
|
11999
|
+
mod: true,
|
|
11895
12000
|
callback: (command) => {
|
|
11896
12001
|
command.executeItalic();
|
|
11897
12002
|
}
|
|
11898
12003
|
},
|
|
11899
12004
|
{
|
|
11900
12005
|
key: KeyMap.U,
|
|
11901
|
-
|
|
12006
|
+
mod: true,
|
|
11902
12007
|
callback: (command) => {
|
|
11903
12008
|
command.executeUnderline();
|
|
11904
12009
|
}
|
|
11905
12010
|
},
|
|
11906
12011
|
{
|
|
11907
|
-
key: KeyMap.RIGHT_ANGLE_BRACKET,
|
|
11908
|
-
|
|
12012
|
+
key: isApple ? KeyMap.COMMA : KeyMap.RIGHT_ANGLE_BRACKET,
|
|
12013
|
+
mod: true,
|
|
11909
12014
|
shift: true,
|
|
11910
12015
|
callback: (command) => {
|
|
11911
12016
|
command.executeSuperscript();
|
|
11912
12017
|
}
|
|
11913
12018
|
},
|
|
11914
12019
|
{
|
|
11915
|
-
key: KeyMap.LEFT_ANGLE_BRACKET,
|
|
11916
|
-
|
|
12020
|
+
key: isApple ? KeyMap.PERIOD : KeyMap.LEFT_ANGLE_BRACKET,
|
|
12021
|
+
mod: true,
|
|
11917
12022
|
shift: true,
|
|
11918
12023
|
callback: (command) => {
|
|
11919
12024
|
command.executeSubscript();
|
|
@@ -11921,28 +12026,28 @@ const richtextKeys = [
|
|
|
11921
12026
|
},
|
|
11922
12027
|
{
|
|
11923
12028
|
key: KeyMap.L,
|
|
11924
|
-
|
|
12029
|
+
mod: true,
|
|
11925
12030
|
callback: (command) => {
|
|
11926
12031
|
command.executeLeft();
|
|
11927
12032
|
}
|
|
11928
12033
|
},
|
|
11929
12034
|
{
|
|
11930
12035
|
key: KeyMap.E,
|
|
11931
|
-
|
|
12036
|
+
mod: true,
|
|
11932
12037
|
callback: (command) => {
|
|
11933
12038
|
command.executeCenter();
|
|
11934
12039
|
}
|
|
11935
12040
|
},
|
|
11936
12041
|
{
|
|
11937
12042
|
key: KeyMap.R,
|
|
11938
|
-
|
|
12043
|
+
mod: true,
|
|
11939
12044
|
callback: (command) => {
|
|
11940
12045
|
command.executeRight();
|
|
11941
12046
|
}
|
|
11942
12047
|
},
|
|
11943
12048
|
{
|
|
11944
12049
|
key: KeyMap.J,
|
|
11945
|
-
|
|
12050
|
+
mod: true,
|
|
11946
12051
|
callback: (command) => {
|
|
11947
12052
|
command.executeAlignment();
|
|
11948
12053
|
}
|
|
@@ -11995,7 +12100,7 @@ class Shortcut {
|
|
|
11995
12100
|
_execute(evt, shortCutList) {
|
|
11996
12101
|
for (let s = 0; s < shortCutList.length; s++) {
|
|
11997
12102
|
const shortCut = shortCutList[s];
|
|
11998
|
-
if (evt.ctrlKey === !!shortCut.ctrl && evt.shiftKey === !!shortCut.shift && evt.altKey === !!shortCut.alt && evt.key === shortCut.key) {
|
|
12103
|
+
if ((shortCut.mod ? isMod(evt) === !!shortCut.mod : evt.ctrlKey === !!shortCut.ctrl && evt.metaKey === !!shortCut.meta) && evt.shiftKey === !!shortCut.shift && evt.altKey === !!shortCut.alt && evt.key === shortCut.key) {
|
|
11999
12104
|
shortCut.callback(this.command);
|
|
12000
12105
|
evt.preventDefault();
|
|
12001
12106
|
break;
|