@univerjs/docs-ui 0.24.0 → 0.25.0
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/lib/cjs/facade.js +42 -11
- package/lib/cjs/index.js +4487 -1456
- package/lib/cjs/locale/ar-SA.js +124 -0
- package/lib/cjs/locale/ca-ES.js +11 -10
- package/lib/cjs/locale/de-DE.js +124 -0
- package/lib/cjs/locale/en-US.js +11 -10
- package/lib/cjs/locale/es-ES.js +11 -10
- package/lib/cjs/locale/fa-IR.js +11 -10
- package/lib/cjs/locale/fr-FR.js +11 -10
- package/lib/cjs/locale/id-ID.js +124 -0
- package/lib/cjs/locale/it-IT.js +124 -0
- package/lib/cjs/locale/ja-JP.js +11 -10
- package/lib/cjs/locale/ko-KR.js +11 -10
- package/lib/cjs/locale/pl-PL.js +124 -0
- package/lib/cjs/locale/pt-BR.js +124 -0
- package/lib/cjs/locale/ru-RU.js +13 -12
- package/lib/cjs/locale/sk-SK.js +11 -10
- package/lib/cjs/locale/vi-VN.js +22 -21
- package/lib/cjs/locale/zh-CN.js +11 -10
- package/lib/cjs/locale/zh-HK.js +124 -0
- package/lib/cjs/locale/zh-TW.js +22 -21
- package/lib/es/facade.js +42 -11
- package/lib/es/index.js +4476 -1462
- package/lib/es/locale/ar-SA.js +123 -0
- package/lib/es/locale/ca-ES.js +11 -10
- package/lib/es/locale/de-DE.js +123 -0
- package/lib/es/locale/en-US.js +11 -10
- package/lib/es/locale/es-ES.js +11 -10
- package/lib/es/locale/fa-IR.js +11 -10
- package/lib/es/locale/fr-FR.js +11 -10
- package/lib/es/locale/id-ID.js +123 -0
- package/lib/es/locale/it-IT.js +123 -0
- package/lib/es/locale/ja-JP.js +11 -10
- package/lib/es/locale/ko-KR.js +11 -10
- package/lib/es/locale/pl-PL.js +123 -0
- package/lib/es/locale/pt-BR.js +123 -0
- package/lib/es/locale/ru-RU.js +13 -12
- package/lib/es/locale/sk-SK.js +11 -10
- package/lib/es/locale/vi-VN.js +22 -21
- package/lib/es/locale/zh-CN.js +11 -10
- package/lib/es/locale/zh-HK.js +123 -0
- package/lib/es/locale/zh-TW.js +22 -21
- package/lib/facade.js +42 -11
- package/lib/index.css +240 -26
- package/lib/index.js +4476 -1462
- package/lib/locale/ar-SA.js +123 -0
- package/lib/locale/ca-ES.js +11 -10
- package/lib/locale/de-DE.js +123 -0
- package/lib/locale/en-US.js +11 -10
- package/lib/locale/es-ES.js +11 -10
- package/lib/locale/fa-IR.js +11 -10
- package/lib/locale/fr-FR.js +11 -10
- package/lib/locale/id-ID.js +123 -0
- package/lib/locale/it-IT.js +123 -0
- package/lib/locale/ja-JP.js +11 -10
- package/lib/locale/ko-KR.js +11 -10
- package/lib/locale/pl-PL.js +123 -0
- package/lib/locale/pt-BR.js +123 -0
- package/lib/locale/ru-RU.js +13 -12
- package/lib/locale/sk-SK.js +11 -10
- package/lib/locale/vi-VN.js +22 -21
- package/lib/locale/zh-CN.js +11 -10
- package/lib/locale/zh-HK.js +123 -0
- package/lib/locale/zh-TW.js +22 -21
- package/lib/types/commands/commands/doc-block-move.command.d.ts +40 -0
- package/lib/types/commands/commands/doc-delete.command.d.ts +2 -1
- package/lib/types/commands/commands/doc-page-setup.command.d.ts +2 -0
- package/lib/types/commands/commands/list.command.d.ts +1 -0
- package/lib/types/components/paragraph-menu/index.d.ts +23 -1
- package/lib/types/controllers/render-controllers/doc-contextmenu.render-controller.d.ts +8 -2
- package/lib/types/controllers/render-controllers/doc.render-controller.d.ts +8 -2
- package/lib/types/controllers/render-controllers/zoom.render-controller.d.ts +3 -3
- package/lib/types/facade/f-document.d.ts +18 -0
- package/lib/types/index.d.ts +6 -1
- package/lib/types/locale/ar-SA.d.ts +18 -0
- package/lib/types/locale/de-DE.d.ts +18 -0
- package/lib/types/locale/en-US.d.ts +117 -110
- package/lib/types/locale/id-ID.d.ts +18 -0
- package/lib/types/locale/it-IT.d.ts +18 -0
- package/lib/types/locale/pl-PL.d.ts +18 -0
- package/lib/types/locale/pt-BR.d.ts +18 -0
- package/lib/types/locale/zh-HK.d.ts +18 -0
- package/lib/types/menu/menu.d.ts +9 -1
- package/lib/types/menu/paragraph-menu.d.ts +21 -2
- package/lib/types/menu/schema.d.ts +1 -0
- package/lib/types/services/clipboard/clipboard.service.d.ts +5 -1
- package/lib/types/services/clipboard/html-to-udm/converter.d.ts +12 -0
- package/lib/types/services/clipboard/html-to-udm/paste-plugins/type.d.ts +1 -0
- package/lib/types/services/clipboard/internal-fragment.d.ts +30 -0
- package/lib/types/services/doc-content-insert.service.d.ts +28 -0
- package/lib/types/services/doc-event-manager.service.d.ts +19 -1
- package/lib/types/services/doc-paragraph-menu.service.d.ts +51 -3
- package/lib/types/services/doc-popup-manager.service.d.ts +2 -2
- package/lib/types/services/docs-render.service.d.ts +2 -1
- package/lib/types/services/editor/editor.d.ts +1 -0
- package/lib/types/services/selection/convert-text-range.d.ts +1 -0
- package/lib/types/services/selection/doc-selection-render.service.d.ts +4 -0
- package/lib/types/views/page-settings/index.d.ts +4 -2
- package/lib/types/views/rich-text-editor/hooks/use-editor.d.ts +2 -1
- package/lib/umd/facade.js +5 -1
- package/lib/umd/index.js +37 -10
- package/lib/umd/locale/ar-SA.js +1 -0
- package/lib/umd/locale/ca-ES.js +1 -1
- package/lib/umd/locale/de-DE.js +1 -0
- package/lib/umd/locale/en-US.js +1 -1
- package/lib/umd/locale/es-ES.js +1 -1
- package/lib/umd/locale/fa-IR.js +1 -1
- package/lib/umd/locale/fr-FR.js +1 -1
- package/lib/umd/locale/id-ID.js +1 -0
- package/lib/umd/locale/it-IT.js +1 -0
- package/lib/umd/locale/ja-JP.js +1 -1
- package/lib/umd/locale/ko-KR.js +1 -1
- package/lib/umd/locale/pl-PL.js +1 -0
- package/lib/umd/locale/pt-BR.js +1 -0
- package/lib/umd/locale/ru-RU.js +1 -1
- package/lib/umd/locale/sk-SK.js +1 -1
- package/lib/umd/locale/vi-VN.js +1 -1
- package/lib/umd/locale/zh-CN.js +1 -1
- package/lib/umd/locale/zh-HK.js +1 -0
- package/lib/umd/locale/zh-TW.js +1 -1
- package/package.json +11 -11
package/lib/cjs/locale/zh-CN.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/locale/zh-CN.ts
|
|
3
|
-
const locale = {
|
|
3
|
+
const locale = { "docs-ui": {
|
|
4
4
|
toolbar: {
|
|
5
5
|
undo: "撤销",
|
|
6
6
|
redo: "重做",
|
|
@@ -12,14 +12,8 @@ const locale = {
|
|
|
12
12
|
subscript: "下标",
|
|
13
13
|
superscript: "上标",
|
|
14
14
|
underline: "下划线",
|
|
15
|
-
textColor: {
|
|
16
|
-
|
|
17
|
-
right: "颜色选择"
|
|
18
|
-
},
|
|
19
|
-
fillColor: {
|
|
20
|
-
main: "文本背景色",
|
|
21
|
-
right: "背景色选择"
|
|
22
|
-
},
|
|
15
|
+
textColor: { main: "文本颜色" },
|
|
16
|
+
fillColor: { main: "文本背景色" },
|
|
23
17
|
table: {
|
|
24
18
|
main: "表格",
|
|
25
19
|
insert: "插入表格",
|
|
@@ -91,6 +85,13 @@ const locale = {
|
|
|
91
85
|
},
|
|
92
86
|
"page-settings": {
|
|
93
87
|
"document-setting": "文档设置",
|
|
88
|
+
mode: "模式",
|
|
89
|
+
"modern-mode": "现代模式",
|
|
90
|
+
"classic-mode": "经典模式",
|
|
91
|
+
"modern-width": "内容宽度",
|
|
92
|
+
"modern-width-narrow": "窄",
|
|
93
|
+
"modern-width-medium": "适中",
|
|
94
|
+
"modern-width-wide": "宽",
|
|
94
95
|
"page-size": {
|
|
95
96
|
main: "纸张大小",
|
|
96
97
|
a4: "A4",
|
|
@@ -117,7 +118,7 @@ const locale = {
|
|
|
117
118
|
cancel: "取消",
|
|
118
119
|
confirm: "确认"
|
|
119
120
|
}
|
|
120
|
-
};
|
|
121
|
+
} };
|
|
121
122
|
|
|
122
123
|
//#endregion
|
|
123
124
|
module.exports = locale;
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/locale/zh-HK.ts
|
|
3
|
+
const locale = { "docs-ui": {
|
|
4
|
+
toolbar: {
|
|
5
|
+
undo: "撤銷",
|
|
6
|
+
redo: "重做",
|
|
7
|
+
font: "字型",
|
|
8
|
+
fontSize: "字號",
|
|
9
|
+
bold: "粗體",
|
|
10
|
+
italic: "斜體",
|
|
11
|
+
strikethrough: "刪除線",
|
|
12
|
+
subscript: "下標",
|
|
13
|
+
superscript: "上標",
|
|
14
|
+
underline: "底線",
|
|
15
|
+
textColor: { main: "文字顏色" },
|
|
16
|
+
fillColor: { main: "文字背景色" },
|
|
17
|
+
table: {
|
|
18
|
+
main: "Table",
|
|
19
|
+
insert: "Insert Table",
|
|
20
|
+
colCount: "Column count",
|
|
21
|
+
rowCount: "Row count"
|
|
22
|
+
},
|
|
23
|
+
resetColor: "重置顏色",
|
|
24
|
+
order: "有序列表",
|
|
25
|
+
unorder: "無序列表",
|
|
26
|
+
checklist: "任務列表",
|
|
27
|
+
documentFlavor: "现代模式",
|
|
28
|
+
alignLeft: "左對齊",
|
|
29
|
+
alignCenter: "居中對齊",
|
|
30
|
+
alignRight: "右對齊",
|
|
31
|
+
alignJustify: "兩端對齊",
|
|
32
|
+
horizontalLine: "Horizontal line",
|
|
33
|
+
headerFooter: "頁眉頁腳",
|
|
34
|
+
pageSetup: "頁面設置"
|
|
35
|
+
},
|
|
36
|
+
table: {
|
|
37
|
+
insert: "Insert",
|
|
38
|
+
insertRowAbove: "Insert row above",
|
|
39
|
+
insertRowBelow: "Insert row below",
|
|
40
|
+
insertColumnLeft: "Insert column left",
|
|
41
|
+
insertColumnRight: "Insert column right",
|
|
42
|
+
delete: "Table delete",
|
|
43
|
+
deleteRows: "Delete row",
|
|
44
|
+
deleteColumns: "Delete column",
|
|
45
|
+
deleteTable: "Delete table"
|
|
46
|
+
},
|
|
47
|
+
headerFooter: {
|
|
48
|
+
header: "頁眉",
|
|
49
|
+
footer: "頁腳",
|
|
50
|
+
panel: "頁眉頁腳設置",
|
|
51
|
+
firstPageCheckBox: "首頁不同",
|
|
52
|
+
oddEvenCheckBox: "奇偶頁不同",
|
|
53
|
+
headerTopMargin: "頁眉頂端距離(px)",
|
|
54
|
+
footerBottomMargin: "頁腳底端距離(px)",
|
|
55
|
+
closeHeaderFooter: "關閉頁眉頁腳",
|
|
56
|
+
disableText: "頁眉頁腳設置不可用"
|
|
57
|
+
},
|
|
58
|
+
doc: {
|
|
59
|
+
menu: { paragraphSetting: "Paragraph Setting" },
|
|
60
|
+
slider: { paragraphSetting: "Paragraph Setting" },
|
|
61
|
+
paragraphSetting: {
|
|
62
|
+
alignment: "Alignment",
|
|
63
|
+
indentation: "Indentation",
|
|
64
|
+
left: "Left",
|
|
65
|
+
right: "Right",
|
|
66
|
+
firstLine: "First Line",
|
|
67
|
+
hanging: "Hanging",
|
|
68
|
+
spacing: "Spacing",
|
|
69
|
+
before: "Before",
|
|
70
|
+
after: "After",
|
|
71
|
+
lineSpace: "Line Space",
|
|
72
|
+
multiSpace: "Multi Space",
|
|
73
|
+
fixedValue: "Fixed Value(px)"
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
rightClick: {
|
|
77
|
+
copy: "複製",
|
|
78
|
+
cut: "剪切",
|
|
79
|
+
paste: "貼上",
|
|
80
|
+
delete: "刪除",
|
|
81
|
+
bulletList: "無序列表",
|
|
82
|
+
orderList: "有序列表",
|
|
83
|
+
checkList: "任務列表",
|
|
84
|
+
insertBellow: "在下方插入"
|
|
85
|
+
},
|
|
86
|
+
"page-settings": {
|
|
87
|
+
"document-setting": "文檔設置",
|
|
88
|
+
mode: "模式",
|
|
89
|
+
"modern-mode": "現代模式",
|
|
90
|
+
"classic-mode": "經典模式",
|
|
91
|
+
"modern-width": "內容寬度",
|
|
92
|
+
"modern-width-narrow": "窄",
|
|
93
|
+
"modern-width-medium": "適中",
|
|
94
|
+
"modern-width-wide": "寬",
|
|
95
|
+
"paper-size": "紙張大小",
|
|
96
|
+
"page-size": {
|
|
97
|
+
main: "紙張大小",
|
|
98
|
+
a4: "A4",
|
|
99
|
+
a3: "A3",
|
|
100
|
+
a5: "A5",
|
|
101
|
+
b4: "B4",
|
|
102
|
+
b5: "B5",
|
|
103
|
+
letter: "美式信紙",
|
|
104
|
+
legal: "美式法律用紙",
|
|
105
|
+
tabloid: "小報尺寸",
|
|
106
|
+
statement: "聲明用紙",
|
|
107
|
+
executive: "行政用紙",
|
|
108
|
+
folio: "對開紙"
|
|
109
|
+
},
|
|
110
|
+
orientation: "方向",
|
|
111
|
+
portrait: "縱向",
|
|
112
|
+
landscape: "橫向",
|
|
113
|
+
"custom-paper-size": "自定義紙張大小",
|
|
114
|
+
top: "上",
|
|
115
|
+
bottom: "下",
|
|
116
|
+
left: "左",
|
|
117
|
+
right: "右",
|
|
118
|
+
cancel: "取消",
|
|
119
|
+
confirm: "確認"
|
|
120
|
+
}
|
|
121
|
+
} };
|
|
122
|
+
|
|
123
|
+
//#endregion
|
|
124
|
+
module.exports = locale;
|
package/lib/cjs/locale/zh-TW.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/locale/zh-TW.ts
|
|
3
|
-
const locale = {
|
|
3
|
+
const locale = { "docs-ui": {
|
|
4
4
|
toolbar: {
|
|
5
5
|
undo: "撤銷",
|
|
6
6
|
redo: "重做",
|
|
@@ -12,14 +12,8 @@ const locale = {
|
|
|
12
12
|
subscript: "下標",
|
|
13
13
|
superscript: "上標",
|
|
14
14
|
underline: "底線",
|
|
15
|
-
textColor: {
|
|
16
|
-
|
|
17
|
-
right: "顏色選擇"
|
|
18
|
-
},
|
|
19
|
-
fillColor: {
|
|
20
|
-
main: "文字背景色",
|
|
21
|
-
right: "背景色選擇"
|
|
22
|
-
},
|
|
15
|
+
textColor: { main: "文字顏色" },
|
|
16
|
+
fillColor: { main: "文字背景色" },
|
|
23
17
|
table: {
|
|
24
18
|
main: "Table",
|
|
25
19
|
insert: "Insert Table",
|
|
@@ -29,26 +23,26 @@ const locale = {
|
|
|
29
23
|
resetColor: "重置顏色",
|
|
30
24
|
order: "有序列表",
|
|
31
25
|
unorder: "無序列表",
|
|
26
|
+
checklist: "任務列表",
|
|
27
|
+
documentFlavor: "现代模式",
|
|
32
28
|
alignLeft: "左對齊",
|
|
33
29
|
alignCenter: "居中對齊",
|
|
34
30
|
alignRight: "右對齊",
|
|
35
31
|
alignJustify: "兩端對齊",
|
|
36
32
|
horizontalLine: "Horizontal line",
|
|
37
33
|
headerFooter: "頁眉頁腳",
|
|
38
|
-
checklist: "任務列表",
|
|
39
|
-
documentFlavor: "现代模式",
|
|
40
34
|
pageSetup: "頁面設置"
|
|
41
35
|
},
|
|
42
36
|
table: {
|
|
43
|
-
insert: "
|
|
44
|
-
insertRowAbove: "
|
|
45
|
-
insertRowBelow: "
|
|
46
|
-
insertColumnLeft: "
|
|
47
|
-
insertColumnRight: "
|
|
48
|
-
delete: "
|
|
49
|
-
deleteRows: "
|
|
50
|
-
deleteColumns: "
|
|
51
|
-
deleteTable: "
|
|
37
|
+
insert: "插入",
|
|
38
|
+
insertRowAbove: "在上方插入行",
|
|
39
|
+
insertRowBelow: "在下方插入行",
|
|
40
|
+
insertColumnLeft: "在左側插入列",
|
|
41
|
+
insertColumnRight: "在右側插入列",
|
|
42
|
+
delete: "刪除表格",
|
|
43
|
+
deleteRows: "刪除行",
|
|
44
|
+
deleteColumns: "刪除列",
|
|
45
|
+
deleteTable: "刪除表格"
|
|
52
46
|
},
|
|
53
47
|
headerFooter: {
|
|
54
48
|
header: "頁眉",
|
|
@@ -91,6 +85,13 @@ const locale = {
|
|
|
91
85
|
},
|
|
92
86
|
"page-settings": {
|
|
93
87
|
"document-setting": "文檔設置",
|
|
88
|
+
mode: "模式",
|
|
89
|
+
"modern-mode": "現代模式",
|
|
90
|
+
"classic-mode": "經典模式",
|
|
91
|
+
"modern-width": "內容寬度",
|
|
92
|
+
"modern-width-narrow": "窄",
|
|
93
|
+
"modern-width-medium": "適中",
|
|
94
|
+
"modern-width-wide": "寬",
|
|
94
95
|
"page-size": {
|
|
95
96
|
main: "紙張大小",
|
|
96
97
|
a4: "A4",
|
|
@@ -117,7 +118,7 @@ const locale = {
|
|
|
117
118
|
cancel: "取消",
|
|
118
119
|
confirm: "確認"
|
|
119
120
|
}
|
|
120
|
-
};
|
|
121
|
+
} };
|
|
121
122
|
|
|
122
123
|
//#endregion
|
|
123
124
|
module.exports = locale;
|
package/lib/es/facade.js
CHANGED
|
@@ -3,7 +3,7 @@ import { FUniver } from "@univerjs/core/facade";
|
|
|
3
3
|
import { DocSelectionRenderService, InsertCommand } from "@univerjs/docs-ui";
|
|
4
4
|
import { IRenderManagerService } from "@univerjs/engine-render";
|
|
5
5
|
|
|
6
|
-
//#region \0@oxc-project+runtime@0.
|
|
6
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/typeof.js
|
|
7
7
|
function _typeof(o) {
|
|
8
8
|
"@babel/helpers - typeof";
|
|
9
9
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -14,7 +14,7 @@ function _typeof(o) {
|
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
//#endregion
|
|
17
|
-
//#region \0@oxc-project+runtime@0.
|
|
17
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPrimitive.js
|
|
18
18
|
function toPrimitive(t, r) {
|
|
19
19
|
if ("object" != _typeof(t) || !t) return t;
|
|
20
20
|
var e = t[Symbol.toPrimitive];
|
|
@@ -27,14 +27,14 @@ function toPrimitive(t, r) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
//#endregion
|
|
30
|
-
//#region \0@oxc-project+runtime@0.
|
|
30
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/toPropertyKey.js
|
|
31
31
|
function toPropertyKey(t) {
|
|
32
32
|
var i = toPrimitive(t, "string");
|
|
33
33
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
//#endregion
|
|
37
|
-
//#region \0@oxc-project+runtime@0.
|
|
37
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/defineProperty.js
|
|
38
38
|
function _defineProperty(e, r, t) {
|
|
39
39
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
40
40
|
value: t,
|
|
@@ -45,7 +45,7 @@ function _defineProperty(e, r, t) {
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
//#endregion
|
|
48
|
-
//#region \0@oxc-project+runtime@0.
|
|
48
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorateParam.js
|
|
49
49
|
function __decorateParam(paramIndex, decorator) {
|
|
50
50
|
return function(target, key) {
|
|
51
51
|
decorator(target, key, paramIndex);
|
|
@@ -53,7 +53,7 @@ function __decorateParam(paramIndex, decorator) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
//#endregion
|
|
56
|
-
//#region \0@oxc-project+runtime@0.
|
|
56
|
+
//#region \0@oxc-project+runtime@0.133.0/helpers/esm/decorate.js
|
|
57
57
|
function __decorate(decorators, target, key, desc) {
|
|
58
58
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
59
59
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -99,22 +99,53 @@ let FDocument = class FDocument {
|
|
|
99
99
|
* @param text - The text to be added to the end of this text region.
|
|
100
100
|
*/
|
|
101
101
|
appendText(text) {
|
|
102
|
-
const unitId = this.id;
|
|
103
102
|
const { body } = this.getSnapshot();
|
|
104
103
|
if (!body) throw new Error("The document body is empty");
|
|
105
104
|
const lastPosition = body.dataStream.length - 2;
|
|
106
|
-
|
|
105
|
+
return this.insertText(text, {
|
|
107
106
|
startOffset: lastPosition,
|
|
108
107
|
endOffset: lastPosition,
|
|
109
|
-
collapsed: true,
|
|
110
108
|
segmentId: ""
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Inserts text at the provided document range. Defaults to appending before the final section break.
|
|
113
|
+
* @param text - The text to insert.
|
|
114
|
+
* @param options - Optional target range, segment id, and cursor offset.
|
|
115
|
+
*/
|
|
116
|
+
insertText(text, options = {}) {
|
|
117
|
+
var _options$startOffset, _options$endOffset, _options$segmentId;
|
|
118
|
+
const unitId = this.id;
|
|
119
|
+
const { body } = this.getSnapshot();
|
|
120
|
+
if (!body) throw new Error("The document body is empty");
|
|
121
|
+
const startOffset = (_options$startOffset = options.startOffset) !== null && _options$startOffset !== void 0 ? _options$startOffset : Math.max(0, body.dataStream.length - 2);
|
|
122
|
+
const endOffset = (_options$endOffset = options.endOffset) !== null && _options$endOffset !== void 0 ? _options$endOffset : startOffset;
|
|
123
|
+
const segmentId = (_options$segmentId = options.segmentId) !== null && _options$segmentId !== void 0 ? _options$segmentId : "";
|
|
124
|
+
const activeRange = {
|
|
125
|
+
startOffset,
|
|
126
|
+
endOffset,
|
|
127
|
+
collapsed: startOffset === endOffset,
|
|
128
|
+
segmentId
|
|
111
129
|
};
|
|
112
|
-
const { segmentId } = activeRange;
|
|
113
130
|
return this._commandService.executeCommand(InsertCommand.id, {
|
|
114
131
|
unitId,
|
|
115
132
|
body: { dataStream: text },
|
|
116
133
|
range: activeRange,
|
|
117
|
-
segmentId
|
|
134
|
+
segmentId,
|
|
135
|
+
...options.cursorOffset == null ? {} : { cursorOffset: options.cursorOffset }
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Inserts one or more plain-text paragraphs at the provided document range.
|
|
140
|
+
* @param text - Paragraph text. Newlines are normalized to document paragraph separators.
|
|
141
|
+
* @param options - Optional target range, segment id, and cursor offset.
|
|
142
|
+
*/
|
|
143
|
+
insertParagraph(text = "", options = {}) {
|
|
144
|
+
var _options$cursorOffset;
|
|
145
|
+
const dataStream = `${text.replace(/\r\n/g, "\n").replace(/\r/g, "\n").split("\n").join("\r\n")}\r\n`;
|
|
146
|
+
return this.insertText(dataStream, {
|
|
147
|
+
...options,
|
|
148
|
+
cursorOffset: (_options$cursorOffset = options.cursorOffset) !== null && _options$cursorOffset !== void 0 ? _options$cursorOffset : dataStream.length
|
|
118
149
|
});
|
|
119
150
|
}
|
|
120
151
|
/**
|