@vervedoc/core 3.0.10 → 3.3.11
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/README.md +194 -71
- package/dist/assets/editor-worker-CG2Et0Mg.js +244 -0
- package/dist/assets/editor-worker-CG2Et0Mg.js.map +1 -0
- package/dist/assets/thumbnail-worker-BGjZ82h0.js +52 -0
- package/dist/assets/thumbnail-worker-BGjZ82h0.js.map +1 -0
- package/dist/command-chain.d.ts +40 -0
- package/dist/constants.d.ts +21 -0
- package/dist/core.js +16073 -3790
- package/dist/core.js.map +1 -1
- package/dist/core.umd.cjs +413 -134
- package/dist/core.umd.cjs.map +1 -1
- package/dist/docx-editor.d.ts +110 -0
- package/dist/index.d.ts +20 -23
- package/dist/shortcut.d.ts +60 -0
- package/dist/workers/compute.d.ts +17 -0
- package/dist/workers/thumbnail-manager.d.ts +19 -0
- package/dist/workers/worker-manager.d.ts +44 -0
- package/package.json +55 -60
- package/dist/DocxEditor.d.ts +0 -17
- package/dist/actuator/Actuator.d.ts +0 -22
- package/dist/assets/runtime.worker-BUGfHnel.js.map +0 -1
- package/dist/docxParser/constants.d.ts +0 -42
- package/dist/docxParser/docx.parser.d.ts +0 -13
- package/dist/docxParser/index.d.ts +0 -13
- package/dist/docxParser/types.d.ts +0 -170
- package/dist/docxParser/worker/builder/element.builder.d.ts +0 -6
- package/dist/docxParser/worker/numbering.resolver.d.ts +0 -29
- package/dist/docxParser/worker/parsers/chart.parser.d.ts +0 -16
- package/dist/docxParser/worker/parsers/comment.parser.d.ts +0 -5
- package/dist/docxParser/worker/parsers/hyperlink.parser.d.ts +0 -14
- package/dist/docxParser/worker/parsers/image.parser.d.ts +0 -12
- package/dist/docxParser/worker/parsers/list.parser.d.ts +0 -6
- package/dist/docxParser/worker/parsers/ooxml.chart.parser.d.ts +0 -4
- package/dist/docxParser/worker/parsers/paragraph.parser.d.ts +0 -10
- package/dist/docxParser/worker/parsers/run.parser.d.ts +0 -22
- package/dist/docxParser/worker/parsers/section.parser.d.ts +0 -20
- package/dist/docxParser/worker/parsers/table.parser.d.ts +0 -11
- package/dist/docxParser/worker/parsers/toc.parser.d.ts +0 -13
- package/dist/docxParser/worker/relationship.resolver.d.ts +0 -17
- package/dist/docxParser/worker/style.resolver.d.ts +0 -33
- package/dist/docxParser/worker/theme.resolver.d.ts +0 -21
- package/dist/docxParser/worker/xml.helper.d.ts +0 -36
- package/dist/export/ExportComponent.d.ts +0 -9
- package/dist/i18n/I18n.d.ts +0 -8
- package/dist/index-OrDfS8Mp.js +0 -16762
- package/dist/index-OrDfS8Mp.js.map +0 -1
- package/dist/table-contextmenu/TableContextMenu.d.ts +0 -48
- package/dist/table-contextmenu/TableContextMenuComponent.d.ts +0 -7
- package/dist/utils/clipboard.d.ts +0 -11
- package/dist/utils/print.d.ts +0 -7
- package/dist/worker/WorkerComponent.d.ts +0 -8
- package/dist/worker/WorkerManager.d.ts +0 -21
- package/dist/worker/WorkerMessage.d.ts +0 -21
- /package/dist/{docxParser/worker/docx.parse.worker.d.ts → workers/editor-worker.d.ts} +0 -0
- /package/dist/{worker/runtime.worker.d.ts → workers/thumbnail-worker.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ const editor = new DocxEditor(container, {
|
|
|
38
38
|
// 使用命令 API
|
|
39
39
|
editor.command.executeUndo() // 撤销
|
|
40
40
|
editor.command.executeRedo() // 重做
|
|
41
|
-
editor.command.
|
|
41
|
+
editor.command.executeSetBold() // 加粗
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
## 配置选项
|
|
@@ -51,24 +51,24 @@ interface IEditorOption {
|
|
|
51
51
|
width?: number // 页面宽度(毫米)
|
|
52
52
|
height?: number // 页面高度(毫米)
|
|
53
53
|
scale?: number // 缩放比例(0-1)
|
|
54
|
-
|
|
54
|
+
|
|
55
55
|
// 边距设置
|
|
56
56
|
margins?: [number, number, number, number] // [上, 右, 下, 左](毫米)
|
|
57
|
-
|
|
57
|
+
|
|
58
58
|
// 页眉页脚
|
|
59
59
|
header?: IHeader // 页眉配置
|
|
60
60
|
footer?: IFooter // 页脚配置
|
|
61
|
-
|
|
61
|
+
|
|
62
62
|
// 水印
|
|
63
63
|
watermark?: IWatermark // 水印配置
|
|
64
|
-
|
|
64
|
+
|
|
65
65
|
// 字体
|
|
66
66
|
defaultFont?: string // 默认字体
|
|
67
67
|
defaultSize?: number // 默认字号
|
|
68
|
-
|
|
68
|
+
|
|
69
69
|
// 模式
|
|
70
70
|
mode?: EditorMode // 编辑模式:edit | readonly | form | print
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
// 其他
|
|
73
73
|
placeholder?: IPlaceholder // 占位符配置
|
|
74
74
|
pageNumber?: IPageNumber // 页码配置
|
|
@@ -86,7 +86,7 @@ interface IElement {
|
|
|
86
86
|
id?: string // 元素 ID
|
|
87
87
|
type?: ElementType // 元素类型
|
|
88
88
|
value: string // 文本内容
|
|
89
|
-
|
|
89
|
+
|
|
90
90
|
// 文本样式
|
|
91
91
|
font?: string // 字体
|
|
92
92
|
size?: number // 字号
|
|
@@ -96,27 +96,27 @@ interface IElement {
|
|
|
96
96
|
strikeout?: boolean // 删除线
|
|
97
97
|
color?: string // 文字颜色
|
|
98
98
|
highlight?: string // 高亮颜色
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
// 段落样式
|
|
101
101
|
rowFlex?: RowFlex // 对齐方式
|
|
102
102
|
rowMargin?: number // 行距
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
// 图片属性
|
|
105
105
|
width?: number // 图片宽度
|
|
106
106
|
height?: number // 图片高度
|
|
107
107
|
imgDisplay?: ImageDisplay // 图片显示模式
|
|
108
|
-
|
|
108
|
+
|
|
109
109
|
// 表格属性(type: 'table')
|
|
110
110
|
trList?: ITr[] // 表格行列表
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
// 列表属性
|
|
113
113
|
listType?: ListType // 列表类型
|
|
114
114
|
listStyle?: ListStyle // 列表样式
|
|
115
115
|
listId?: string // 列表组 ID
|
|
116
|
-
|
|
116
|
+
|
|
117
117
|
// 超链接
|
|
118
118
|
url?: string // 链接地址
|
|
119
|
-
|
|
119
|
+
|
|
120
120
|
// 控件属性
|
|
121
121
|
control?: IControl // 控件配置
|
|
122
122
|
}
|
|
@@ -155,49 +155,49 @@ editor.command.executeBackspace()
|
|
|
155
155
|
|
|
156
156
|
```typescript
|
|
157
157
|
// 字体样式
|
|
158
|
-
editor.command.
|
|
159
|
-
editor.command.
|
|
160
|
-
editor.command.
|
|
161
|
-
editor.command.
|
|
162
|
-
editor.command.
|
|
163
|
-
editor.command.
|
|
158
|
+
editor.command.executeSetBold() // 加粗
|
|
159
|
+
editor.command.executeSetItalic() // 斜体
|
|
160
|
+
editor.command.executeSetUnderline() // 下划线
|
|
161
|
+
editor.command.executeSetStrikeout() // 删除线
|
|
162
|
+
editor.command.executeSetSuperscript() // 上标
|
|
163
|
+
editor.command.executeSetSubscript() // 下标
|
|
164
164
|
|
|
165
165
|
// 字体设置
|
|
166
|
-
editor.command.
|
|
167
|
-
editor.command.
|
|
168
|
-
editor.command.
|
|
169
|
-
editor.command.
|
|
166
|
+
editor.command.executeSetFont('宋体') // 设置字体
|
|
167
|
+
editor.command.executeSetSize(16) // 设置字号
|
|
168
|
+
editor.command.executeSetColor('#ff0000') // 设置颜色
|
|
169
|
+
editor.command.executeSetHighlight('#ffff00') // 设置高亮
|
|
170
170
|
```
|
|
171
171
|
|
|
172
172
|
### 段落格式
|
|
173
173
|
|
|
174
174
|
```typescript
|
|
175
175
|
// 对齐方式
|
|
176
|
-
editor.command.
|
|
177
|
-
editor.command.
|
|
178
|
-
editor.command.
|
|
179
|
-
editor.command.
|
|
176
|
+
editor.command.executeSetRowFlex(RowFlex.LEFT) // 左对齐
|
|
177
|
+
editor.command.executeSetRowFlex(RowFlex.CENTER) // 居中
|
|
178
|
+
editor.command.executeSetRowFlex(RowFlex.RIGHT) // 右对齐
|
|
179
|
+
editor.command.executeSetRowFlex(RowFlex.JUSTIFY) // 两端对齐
|
|
180
180
|
|
|
181
181
|
// 行距
|
|
182
|
-
editor.command.
|
|
182
|
+
editor.command.executeSetRowMargin(1.5) // 设置行距
|
|
183
183
|
|
|
184
184
|
// 标题
|
|
185
|
-
editor.command.
|
|
186
|
-
editor.command.
|
|
187
|
-
editor.command.
|
|
185
|
+
editor.command.executeSetTitle(TitleLevel.FIRST) // 一级标题
|
|
186
|
+
editor.command.executeSetTitle(TitleLevel.SECOND) // 二级标题
|
|
187
|
+
editor.command.executeSetTitle(null) // 取消标题
|
|
188
188
|
```
|
|
189
189
|
|
|
190
190
|
### 列表
|
|
191
191
|
|
|
192
192
|
```typescript
|
|
193
193
|
// 有序列表
|
|
194
|
-
editor.command.
|
|
194
|
+
editor.command.executeSetList(ListType.OL, ListStyle.DECIMAL)
|
|
195
195
|
|
|
196
196
|
// 无序列表
|
|
197
|
-
editor.command.
|
|
197
|
+
editor.command.executeSetList(ListType.UL, ListStyle.DISC)
|
|
198
198
|
|
|
199
199
|
// 取消列表
|
|
200
|
-
editor.command.
|
|
200
|
+
editor.command.executeSetList(null, null)
|
|
201
201
|
```
|
|
202
202
|
|
|
203
203
|
### 插入内容
|
|
@@ -209,7 +209,7 @@ editor.command.executeInsertElementList([
|
|
|
209
209
|
])
|
|
210
210
|
|
|
211
211
|
// 插入图片
|
|
212
|
-
editor.command.
|
|
212
|
+
editor.command.executeInsertImage({
|
|
213
213
|
value: 'base64...', // 或图片 URL
|
|
214
214
|
width: 200,
|
|
215
215
|
height: 150
|
|
@@ -222,7 +222,7 @@ editor.command.executeInsertTable(3, 4) // 3行4列
|
|
|
222
222
|
editor.command.executePageBreak()
|
|
223
223
|
|
|
224
224
|
// 插入水印
|
|
225
|
-
editor.command.
|
|
225
|
+
editor.command.executeAddWatermark({
|
|
226
226
|
data: '机密文件',
|
|
227
227
|
color: '#cccccc',
|
|
228
228
|
size: 60
|
|
@@ -233,23 +233,22 @@ editor.command.executeWatermark({
|
|
|
233
233
|
|
|
234
234
|
```typescript
|
|
235
235
|
// 插入行/列
|
|
236
|
-
editor.command.
|
|
237
|
-
editor.command.
|
|
238
|
-
editor.command.
|
|
239
|
-
editor.command.
|
|
236
|
+
editor.command.executeInsertTableRow('above') // 上方插入行
|
|
237
|
+
editor.command.executeInsertTableRow('below') // 下方插入行
|
|
238
|
+
editor.command.executeInsertTableCol('left') // 左侧插入列
|
|
239
|
+
editor.command.executeInsertTableCol('right') // 右侧插入列
|
|
240
240
|
|
|
241
241
|
// 删除行/列
|
|
242
242
|
editor.command.executeDeleteTableRow() // 删除行
|
|
243
243
|
editor.command.executeDeleteTableCol() // 删除列
|
|
244
244
|
|
|
245
|
-
//
|
|
246
|
-
editor.command.
|
|
247
|
-
editor.command.executeCancelMergeTableCell() // 取消合并
|
|
245
|
+
// 合并单元格
|
|
246
|
+
editor.command.executeMergeTableCells() // 合并选中单元格
|
|
248
247
|
|
|
249
248
|
// 表格边框
|
|
250
|
-
editor.command.
|
|
251
|
-
editor.command.
|
|
252
|
-
editor.command.
|
|
249
|
+
editor.command.executeSetTableBorderType(TableBorder.ALL) // 所有边框
|
|
250
|
+
editor.command.executeSetTableBorderType(TableBorder.NONE) // 无边框
|
|
251
|
+
editor.command.executeSetTableBorderType(TableBorder.OUTSIDE) // 外边框
|
|
253
252
|
```
|
|
254
253
|
|
|
255
254
|
### 搜索替换
|
|
@@ -271,38 +270,162 @@ editor.command.executeReplaceAll('旧文本', '新文本')
|
|
|
271
270
|
// 获取编辑器数据
|
|
272
271
|
const data = editor.command.getValue()
|
|
273
272
|
|
|
274
|
-
//
|
|
275
|
-
const
|
|
276
|
-
|
|
277
|
-
// 获取 HTML
|
|
278
|
-
const html = editor.command.getHTML()
|
|
273
|
+
// 获取字数统计
|
|
274
|
+
const wordCount = editor.command.getWordCount()
|
|
279
275
|
|
|
280
|
-
//
|
|
281
|
-
const images =
|
|
276
|
+
// 获取页面缩略图
|
|
277
|
+
const images = editor.command.getPageThumbnails()
|
|
282
278
|
```
|
|
283
279
|
|
|
284
280
|
## 事件监听
|
|
285
281
|
|
|
282
|
+
编辑器通过 `listener` 提供分组事件订阅 API,每个分组返回取消订阅函数。所有事件名使用 camelCase,命名空间方法不带 on 前缀、不带 Change 后缀,以 Listener 结尾。
|
|
283
|
+
|
|
284
|
+
### 内容事件
|
|
285
|
+
|
|
286
286
|
```typescript
|
|
287
|
-
//
|
|
288
|
-
editor.listener.
|
|
287
|
+
// 内容变更(文本增删/格式修改等)
|
|
288
|
+
const off = editor.listener.content.contentListener(() => {
|
|
289
289
|
console.log('内容已变化')
|
|
290
|
-
}
|
|
290
|
+
})
|
|
291
|
+
|
|
292
|
+
// 文档保存完成
|
|
293
|
+
editor.listener.content.savedListener(() => {
|
|
294
|
+
console.log('已保存')
|
|
295
|
+
})
|
|
296
|
+
|
|
297
|
+
// 取消订阅
|
|
298
|
+
off()
|
|
299
|
+
```
|
|
291
300
|
|
|
292
|
-
|
|
293
|
-
|
|
301
|
+
### 选区事件
|
|
302
|
+
|
|
303
|
+
```typescript
|
|
304
|
+
// 选区变更(光标移动/选区改变)
|
|
305
|
+
editor.listener.range.rangeListener((range) => {
|
|
306
|
+
console.log('当前选区:', range)
|
|
307
|
+
})
|
|
308
|
+
|
|
309
|
+
// 格式变更(bold/italic 等回显状态)
|
|
310
|
+
editor.listener.range.formatListener((style) => {
|
|
294
311
|
console.log('当前样式:', style)
|
|
295
|
-
}
|
|
312
|
+
})
|
|
296
313
|
|
|
297
|
-
//
|
|
298
|
-
editor.listener.
|
|
299
|
-
console.log('
|
|
300
|
-
}
|
|
314
|
+
// 光标位置变更
|
|
315
|
+
editor.listener.range.positionListener((pos) => {
|
|
316
|
+
console.log('光标位置:', pos)
|
|
317
|
+
})
|
|
318
|
+
```
|
|
301
319
|
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
320
|
+
### 页面事件
|
|
321
|
+
|
|
322
|
+
```typescript
|
|
323
|
+
// 缩放比例变更
|
|
324
|
+
editor.listener.page.pageScaleListener((scale) => {
|
|
325
|
+
console.log('缩放比例:', scale)
|
|
326
|
+
})
|
|
327
|
+
|
|
328
|
+
// 页面尺寸变更(宽高)
|
|
329
|
+
editor.listener.page.pageSizeListener((size) => {
|
|
330
|
+
console.log('页面尺寸:', size)
|
|
331
|
+
})
|
|
332
|
+
|
|
333
|
+
// 总页数变更
|
|
334
|
+
editor.listener.page.pageCountListener((count) => {
|
|
335
|
+
console.log('总页数:', count)
|
|
336
|
+
})
|
|
337
|
+
|
|
338
|
+
// 当前页码变更
|
|
339
|
+
editor.listener.page.currentPageNoListener((pageNo) => {
|
|
340
|
+
console.log('当前页码:', pageNo)
|
|
341
|
+
})
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### 目录事件
|
|
345
|
+
|
|
346
|
+
```typescript
|
|
347
|
+
// 目录变更(由核心 Worker 后台计算后自动推送)
|
|
348
|
+
editor.listener.toc.tocListener((toc) => {
|
|
349
|
+
console.log('目录已更新:', toc)
|
|
350
|
+
})
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
### 缩略图事件
|
|
354
|
+
|
|
355
|
+
```typescript
|
|
356
|
+
// 缩略图变更(由核心 afterRender 自动生成并推送)
|
|
357
|
+
editor.listener.thumbnail.thumbnailListener((images) => {
|
|
358
|
+
console.log('缩略图数量:', images.length)
|
|
359
|
+
})
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### 能力事件
|
|
363
|
+
|
|
364
|
+
```typescript
|
|
365
|
+
// 编辑器能力变更(readonly/disabled/canUndo/canRedo)
|
|
366
|
+
editor.listener.ability.abilityListener((ability) => {
|
|
367
|
+
console.log('编辑器能力:', ability)
|
|
368
|
+
})
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### 区域事件
|
|
372
|
+
|
|
373
|
+
```typescript
|
|
374
|
+
// 编辑区域切换(正文/页眉/页脚)
|
|
375
|
+
editor.listener.zone.zoneListener((zone) => {
|
|
376
|
+
console.log('当前区域:', zone) // 'main' | 'header' | 'footer'
|
|
377
|
+
})
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
### 生命周期事件
|
|
381
|
+
|
|
382
|
+
```typescript
|
|
383
|
+
// 编辑器获得焦点
|
|
384
|
+
editor.listener.lifecycle.focusListener(() => {
|
|
385
|
+
console.log('获得焦点')
|
|
386
|
+
})
|
|
387
|
+
|
|
388
|
+
// 编辑器失去焦点
|
|
389
|
+
editor.listener.lifecycle.blurListener(() => {
|
|
390
|
+
console.log('失去焦点')
|
|
391
|
+
})
|
|
392
|
+
```
|
|
393
|
+
|
|
394
|
+
### 请求事件
|
|
395
|
+
|
|
396
|
+
```typescript
|
|
397
|
+
// 请求插入图片(右键菜单触发)
|
|
398
|
+
editor.listener.request.requestInsertImageListener(() => {
|
|
399
|
+
console.log('请求插入图片')
|
|
400
|
+
})
|
|
401
|
+
|
|
402
|
+
// 请求插入超链接
|
|
403
|
+
editor.listener.request.requestInsertHyperlinkListener(() => {
|
|
404
|
+
console.log('请求插入超链接')
|
|
405
|
+
})
|
|
406
|
+
|
|
407
|
+
// 请求插入公式
|
|
408
|
+
editor.listener.request.requestInsertFormulaListener(() => {
|
|
409
|
+
console.log('请求插入公式')
|
|
410
|
+
})
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
### 底层事件 API
|
|
414
|
+
|
|
415
|
+
```typescript
|
|
416
|
+
// 直接通过事件名订阅(camelCase)
|
|
417
|
+
const off = editor.listener.on('contentChange', () => {
|
|
418
|
+
console.log('内容已变化')
|
|
419
|
+
})
|
|
420
|
+
|
|
421
|
+
// 取消订阅
|
|
422
|
+
editor.listener.off('contentChange', handler)
|
|
423
|
+
|
|
424
|
+
// 所有可用事件名:
|
|
425
|
+
// 'contentChange' | 'saved' | 'rangeChange' | 'formatChange' | 'positionChange'
|
|
426
|
+
// 'pageScaleChange' | 'pageSizeChange' | 'pageCountChange' | 'currentPageNoChange'
|
|
427
|
+
// 'tocChange' | 'thumbnailChange' | 'abilityChange' | 'zoneChange'
|
|
428
|
+
// 'focus' | 'blur' | 'requestInsertImage' | 'requestInsertHyperlink' | 'requestInsertFormula'
|
|
306
429
|
```
|
|
307
430
|
|
|
308
431
|
## 插件系统
|
|
@@ -360,7 +483,7 @@ import {
|
|
|
360
483
|
DocxEditor,
|
|
361
484
|
Editor, // DocxEditor 别名
|
|
362
485
|
Command,
|
|
363
|
-
|
|
486
|
+
|
|
364
487
|
// 枚举
|
|
365
488
|
RowFlex,
|
|
366
489
|
VerticalAlign,
|
|
@@ -377,7 +500,7 @@ import {
|
|
|
377
500
|
TitleLevel,
|
|
378
501
|
ListType,
|
|
379
502
|
ListStyle,
|
|
380
|
-
|
|
503
|
+
|
|
381
504
|
// 类型
|
|
382
505
|
IElement,
|
|
383
506
|
IEditorData,
|
|
@@ -385,7 +508,7 @@ import {
|
|
|
385
508
|
IEditorResult,
|
|
386
509
|
IWatermark,
|
|
387
510
|
IRange,
|
|
388
|
-
|
|
511
|
+
|
|
389
512
|
// 工具函数
|
|
390
513
|
splitText,
|
|
391
514
|
getElementListByHTML,
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
const d = [
|
|
2
|
+
{ label: "宋体", value: "SimSun", css: '"SimSun", "Songti SC", "Noto Serif CJK SC", serif', aliases: ["宋体", "simsun"] },
|
|
3
|
+
{ label: "黑体", value: "SimHei", css: '"SimHei", "STHeiti", "PingFang SC", "Noto Sans CJK SC", sans-serif', aliases: ["黑体", "simhei"] },
|
|
4
|
+
{ label: "楷体", value: "KaiTi", css: '"KaiTi", "Kaiti SC", "STKaiti", "LXGW WenKai", serif', aliases: ["楷体", "kaiti"] },
|
|
5
|
+
{ label: "仿宋", value: "FangSong", css: '"FangSong", "STFangsong", "Noto Serif CJK SC", serif', aliases: ["仿宋", "fangsong"] },
|
|
6
|
+
{ label: "微软雅黑", value: "Microsoft YaHei", css: '"Microsoft YaHei", "PingFang SC", "Noto Sans CJK SC", sans-serif', aliases: ["微软雅黑", "microsoft yahei"] },
|
|
7
|
+
{ label: "等线", value: "DengXian", css: '"DengXian", "Noto Sans CJK SC", sans-serif', aliases: ["等线", "dengxian"] },
|
|
8
|
+
{ label: "华文宋体", value: "STSong", css: '"STSong", "SimSun", "Songti SC", "Noto Serif CJK SC", serif', aliases: ["华文宋体"] },
|
|
9
|
+
{ label: "华文黑体", value: "STHeiti", css: '"STHeiti", "SimHei", "PingFang SC", "Noto Sans CJK SC", sans-serif', aliases: ["华文黑体"] },
|
|
10
|
+
{ label: "华文楷体", value: "STKaiti", css: '"STKaiti", "KaiTi", "Kaiti SC", "LXGW WenKai", serif', aliases: ["华文楷体"] },
|
|
11
|
+
{ label: "华文仿宋", value: "STFangsong", css: '"STFangsong", "FangSong", "Noto Serif CJK SC", serif', aliases: ["华文仿宋"] },
|
|
12
|
+
{ label: "华文中宋", value: "STZhongsong", css: '"STZhongsong", "STSong", "SimSun", "Noto Serif CJK SC", serif', aliases: ["华文中宋"] },
|
|
13
|
+
{ label: "华文细黑", value: "STXihei", css: '"STXihei", "STHeiti", "SimHei", "Noto Sans CJK SC", sans-serif', aliases: ["华文细黑"] },
|
|
14
|
+
{ label: "华文行楷", value: "STXingkai", css: '"STXingkai", "STKaiti", "KaiTi", "LXGW WenKai", serif', aliases: ["华文行楷"] },
|
|
15
|
+
{ label: "华文隶书", value: "STLiti", css: '"STLiti", "STFangsong", "FangSong", "Noto Serif CJK SC", serif', aliases: ["华文隶书"] },
|
|
16
|
+
{ label: "华文新魏", value: "STXinwei", css: '"STXinwei", "STXihei", "SimHei", "Noto Sans CJK SC", sans-serif', aliases: ["华文新魏"] },
|
|
17
|
+
{ label: "华文彩云", value: "STCaiyun", css: '"STCaiyun", "STSong", "SimSun", "Noto Serif CJK SC", serif', aliases: ["华文彩云"] },
|
|
18
|
+
{ label: "Times New Roman", value: "Times New Roman", css: '"Times New Roman", "Liberation Serif", serif' },
|
|
19
|
+
{ label: "Arial", value: "Arial", css: 'Arial, "Liberation Sans", sans-serif' },
|
|
20
|
+
{ label: "Calibri", value: "Calibri", css: 'Calibri, "Liberation Sans", sans-serif' },
|
|
21
|
+
{ label: "Courier New", value: "Courier New", css: '"Courier New", "Liberation Mono", monospace' },
|
|
22
|
+
{ label: "Verdana", value: "Verdana", css: 'Verdana, "DejaVu Sans", sans-serif' }
|
|
23
|
+
];
|
|
24
|
+
d.map((t) => t.label);
|
|
25
|
+
Object.fromEntries(
|
|
26
|
+
d.map((t) => [t.label, t.value])
|
|
27
|
+
);
|
|
28
|
+
Object.fromEntries(
|
|
29
|
+
d.flatMap((t) => [
|
|
30
|
+
[t.value, t.label],
|
|
31
|
+
...(t.aliases ?? []).map((u) => [u, t.label])
|
|
32
|
+
])
|
|
33
|
+
);
|
|
34
|
+
Object.fromEntries(
|
|
35
|
+
d.flatMap((t) => [
|
|
36
|
+
[t.value, t.css],
|
|
37
|
+
...(t.aliases ?? []).map((u) => [u, t.css])
|
|
38
|
+
])
|
|
39
|
+
);
|
|
40
|
+
function j(t) {
|
|
41
|
+
return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
|
|
42
|
+
}
|
|
43
|
+
var C, w;
|
|
44
|
+
function A() {
|
|
45
|
+
if (w) return C;
|
|
46
|
+
w = 1, C = u;
|
|
47
|
+
function t(a) {
|
|
48
|
+
return a instanceof Buffer ? Buffer.from(a) : new a.constructor(a.buffer.slice(), a.byteOffset, a.length);
|
|
49
|
+
}
|
|
50
|
+
function u(a) {
|
|
51
|
+
if (a = a || {}, a.circles) return p(a);
|
|
52
|
+
const o = /* @__PURE__ */ new Map();
|
|
53
|
+
if (o.set(Date, (s) => new Date(s)), o.set(Map, (s, i) => new Map(g(Array.from(s), i))), o.set(Set, (s, i) => new Set(g(Array.from(s), i))), a.constructorHandlers)
|
|
54
|
+
for (const s of a.constructorHandlers)
|
|
55
|
+
o.set(s[0], s[1]);
|
|
56
|
+
let l = null;
|
|
57
|
+
return a.proto ? b : c;
|
|
58
|
+
function g(s, i) {
|
|
59
|
+
const e = Object.keys(s), r = new Array(e.length);
|
|
60
|
+
for (let f = 0; f < e.length; f++) {
|
|
61
|
+
const n = e[f], S = s[n];
|
|
62
|
+
typeof S != "object" || S === null ? r[n] = S : S.constructor !== Object && (l = o.get(S.constructor)) ? r[n] = l(S, i) : ArrayBuffer.isView(S) ? r[n] = t(S) : r[n] = i(S);
|
|
63
|
+
}
|
|
64
|
+
return r;
|
|
65
|
+
}
|
|
66
|
+
function c(s) {
|
|
67
|
+
if (typeof s != "object" || s === null) return s;
|
|
68
|
+
if (Array.isArray(s)) return g(s, c);
|
|
69
|
+
if (s.constructor !== Object && (l = o.get(s.constructor)))
|
|
70
|
+
return l(s, c);
|
|
71
|
+
const i = {};
|
|
72
|
+
for (const e in s) {
|
|
73
|
+
if (Object.hasOwnProperty.call(s, e) === !1) continue;
|
|
74
|
+
const r = s[e];
|
|
75
|
+
typeof r != "object" || r === null ? i[e] = r : r.constructor !== Object && (l = o.get(r.constructor)) ? i[e] = l(r, c) : ArrayBuffer.isView(r) ? i[e] = t(r) : i[e] = c(r);
|
|
76
|
+
}
|
|
77
|
+
return i;
|
|
78
|
+
}
|
|
79
|
+
function b(s) {
|
|
80
|
+
if (typeof s != "object" || s === null) return s;
|
|
81
|
+
if (Array.isArray(s)) return g(s, b);
|
|
82
|
+
if (s.constructor !== Object && (l = o.get(s.constructor)))
|
|
83
|
+
return l(s, b);
|
|
84
|
+
const i = {};
|
|
85
|
+
for (const e in s) {
|
|
86
|
+
const r = s[e];
|
|
87
|
+
typeof r != "object" || r === null ? i[e] = r : r.constructor !== Object && (l = o.get(r.constructor)) ? i[e] = l(r, b) : ArrayBuffer.isView(r) ? i[e] = t(r) : i[e] = b(r);
|
|
88
|
+
}
|
|
89
|
+
return i;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function p(a) {
|
|
93
|
+
const o = [], l = [], g = /* @__PURE__ */ new Map();
|
|
94
|
+
if (g.set(Date, (e) => new Date(e)), g.set(Map, (e, r) => new Map(b(Array.from(e), r))), g.set(Set, (e, r) => new Set(b(Array.from(e), r))), a.constructorHandlers)
|
|
95
|
+
for (const e of a.constructorHandlers)
|
|
96
|
+
g.set(e[0], e[1]);
|
|
97
|
+
let c = null;
|
|
98
|
+
return a.proto ? i : s;
|
|
99
|
+
function b(e, r) {
|
|
100
|
+
const f = Object.keys(e), n = new Array(f.length);
|
|
101
|
+
for (let S = 0; S < f.length; S++) {
|
|
102
|
+
const h = f[S], y = e[h];
|
|
103
|
+
if (typeof y != "object" || y === null)
|
|
104
|
+
n[h] = y;
|
|
105
|
+
else if (y.constructor !== Object && (c = g.get(y.constructor)))
|
|
106
|
+
n[h] = c(y, r);
|
|
107
|
+
else if (ArrayBuffer.isView(y))
|
|
108
|
+
n[h] = t(y);
|
|
109
|
+
else {
|
|
110
|
+
const v = o.indexOf(y);
|
|
111
|
+
v !== -1 ? n[h] = l[v] : n[h] = r(y);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return n;
|
|
115
|
+
}
|
|
116
|
+
function s(e) {
|
|
117
|
+
if (typeof e != "object" || e === null) return e;
|
|
118
|
+
if (Array.isArray(e)) return b(e, s);
|
|
119
|
+
if (e.constructor !== Object && (c = g.get(e.constructor)))
|
|
120
|
+
return c(e, s);
|
|
121
|
+
const r = {};
|
|
122
|
+
o.push(e), l.push(r);
|
|
123
|
+
for (const f in e) {
|
|
124
|
+
if (Object.hasOwnProperty.call(e, f) === !1) continue;
|
|
125
|
+
const n = e[f];
|
|
126
|
+
if (typeof n != "object" || n === null)
|
|
127
|
+
r[f] = n;
|
|
128
|
+
else if (n.constructor !== Object && (c = g.get(n.constructor)))
|
|
129
|
+
r[f] = c(n, s);
|
|
130
|
+
else if (ArrayBuffer.isView(n))
|
|
131
|
+
r[f] = t(n);
|
|
132
|
+
else {
|
|
133
|
+
const S = o.indexOf(n);
|
|
134
|
+
S !== -1 ? r[f] = l[S] : r[f] = s(n);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return o.pop(), l.pop(), r;
|
|
138
|
+
}
|
|
139
|
+
function i(e) {
|
|
140
|
+
if (typeof e != "object" || e === null) return e;
|
|
141
|
+
if (Array.isArray(e)) return b(e, i);
|
|
142
|
+
if (e.constructor !== Object && (c = g.get(e.constructor)))
|
|
143
|
+
return c(e, i);
|
|
144
|
+
const r = {};
|
|
145
|
+
o.push(e), l.push(r);
|
|
146
|
+
for (const f in e) {
|
|
147
|
+
const n = e[f];
|
|
148
|
+
if (typeof n != "object" || n === null)
|
|
149
|
+
r[f] = n;
|
|
150
|
+
else if (n.constructor !== Object && (c = g.get(n.constructor)))
|
|
151
|
+
r[f] = c(n, i);
|
|
152
|
+
else if (ArrayBuffer.isView(n))
|
|
153
|
+
r[f] = t(n);
|
|
154
|
+
else {
|
|
155
|
+
const S = o.indexOf(n);
|
|
156
|
+
S !== -1 ? r[f] = l[S] : r[f] = i(n);
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return o.pop(), l.pop(), r;
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return C;
|
|
163
|
+
}
|
|
164
|
+
var O = A(), K = /* @__PURE__ */ j(O);
|
|
165
|
+
const N = K({ proto: !1, circles: !1 });
|
|
166
|
+
function L(t) {
|
|
167
|
+
return t === null || typeof t != "object" ? t : N(t);
|
|
168
|
+
}
|
|
169
|
+
function M(t) {
|
|
170
|
+
return ((t == null ? void 0 : t.type) === "title" || (t == null ? void 0 : t.type) === "list") && Array.isArray(t.valueList);
|
|
171
|
+
}
|
|
172
|
+
function k(t) {
|
|
173
|
+
return (t == null ? void 0 : t.type) === "table" && Array.isArray(t.trList);
|
|
174
|
+
}
|
|
175
|
+
function m(t, u, p = []) {
|
|
176
|
+
for (let a = 0; a < t.length; a++) {
|
|
177
|
+
const o = t[a], l = [...p, a];
|
|
178
|
+
if (u(o, { parent: t, path: l, index: a }) !== !1) {
|
|
179
|
+
if (M(o))
|
|
180
|
+
m(o.valueList, u, [...l, "valueList"]);
|
|
181
|
+
else if (k(o))
|
|
182
|
+
for (let c = 0; c < o.trList.length; c++) {
|
|
183
|
+
const b = o.trList[c];
|
|
184
|
+
for (let s = 0; s < b.tdList.length; s++) {
|
|
185
|
+
const i = b.tdList[s];
|
|
186
|
+
m(i.value, u, [...l, "trList", c, "tdList", s, "value"]);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
const H = { first: 1, second: 2, third: 3, fourth: 4, fifth: 5, sixth: 6 };
|
|
193
|
+
function F(t) {
|
|
194
|
+
const u = [], p = /* @__PURE__ */ new Map();
|
|
195
|
+
return m(t, (a, o) => {
|
|
196
|
+
if (a.type !== "title") return;
|
|
197
|
+
const l = a, g = (l.valueList ?? []).map((i) => i.type === "text" ? i.value : "").join(""), c = H[l.level] ?? 1;
|
|
198
|
+
let b;
|
|
199
|
+
const s = l.listNumbering;
|
|
200
|
+
if (s && s.numFmt !== "bullet") {
|
|
201
|
+
const i = s.numId ?? s.abstractNumId ?? "default", e = s.level ?? 0, r = `${i}:${e}`, f = p.get(r), n = (f ?? (s.start ?? 1) - 1) + 1;
|
|
202
|
+
p.set(r, n);
|
|
203
|
+
for (const S of p.keys())
|
|
204
|
+
S.startsWith(`${i}:`) && Number(S.slice(i.length + 1)) > e && p.delete(S);
|
|
205
|
+
b = (s.lvlText ?? "%1.").replace(/%([1-9])/g, (S, h) => {
|
|
206
|
+
const y = Number(h) - 1;
|
|
207
|
+
return String(y === e ? n : p.get(`${i}:${y}`) ?? s.start ?? 1);
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
u.push({ id: JSON.stringify(o.path), level: c, name: g, number: b });
|
|
211
|
+
}), { toc: u };
|
|
212
|
+
}
|
|
213
|
+
function J(t, u) {
|
|
214
|
+
const p = [];
|
|
215
|
+
if (!u) return { results: p, count: 0 };
|
|
216
|
+
const a = u.toLowerCase();
|
|
217
|
+
return m(t, (o, l) => {
|
|
218
|
+
if (o.type !== "text") return;
|
|
219
|
+
const g = (o.value || "").toLowerCase();
|
|
220
|
+
let c = g.indexOf(a);
|
|
221
|
+
for (; c !== -1; )
|
|
222
|
+
p.push({ path: [...l.path], offset: c, length: u.length }), c = g.indexOf(a, c + 1);
|
|
223
|
+
}), { results: p, count: p.length };
|
|
224
|
+
}
|
|
225
|
+
let T = [];
|
|
226
|
+
self.onmessage = (t) => {
|
|
227
|
+
try {
|
|
228
|
+
const u = t.data;
|
|
229
|
+
switch (u.type) {
|
|
230
|
+
case "update":
|
|
231
|
+
T = u.elements, self.postMessage({ type: "toc-result", ...F(T) });
|
|
232
|
+
break;
|
|
233
|
+
case "search":
|
|
234
|
+
self.postMessage({ type: "search-result", ...J(T, u.keyword) });
|
|
235
|
+
break;
|
|
236
|
+
case "clone":
|
|
237
|
+
self.postMessage({ type: "clone-result", data: L(u.data) });
|
|
238
|
+
break;
|
|
239
|
+
}
|
|
240
|
+
} catch (u) {
|
|
241
|
+
self.postMessage({ type: "error", message: (u == null ? void 0 : u.message) || String(u) });
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
//# sourceMappingURL=editor-worker-CG2Et0Mg.js.map
|