@hailin-zheng/editor-core 1.0.7 → 1.0.10
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/package.json +3 -4
- package/{lib/doc-ruler.js → src/med_editor/doc-ruler.ts} +101 -74
- package/src/med_editor/framework/common-util.ts +200 -0
- package/{lib/framework/document-change.js → src/med_editor/framework/document-change.ts} +308 -259
- package/{lib/framework/document-combine.js → src/med_editor/framework/document-combine.ts} +15 -11
- package/{lib/framework/document-comment.js → src/med_editor/framework/document-comment.ts} +52 -37
- package/{lib/framework/document-context.js → src/med_editor/framework/document-context.ts} +181 -101
- package/{lib/framework/document-eval-func.js → src/med_editor/framework/document-eval-func.ts} +16 -11
- package/{lib/framework/document-event.js → src/med_editor/framework/document-event.ts} +244 -216
- package/{lib/framework/document-history.js → src/med_editor/framework/document-history.ts} +25 -14
- package/{lib/framework/document-images-loader.js → src/med_editor/framework/document-images-loader.ts} +25 -17
- package/{lib/framework/document-input-cursor.js → src/med_editor/framework/document-input-cursor.ts} +76 -71
- package/{lib/framework/document-paint.js → src/med_editor/framework/document-paint.ts} +35 -28
- package/{lib/framework/document-print-offscreen.js → src/med_editor/framework/document-print-offscreen.ts} +25 -19
- package/{lib/framework/document-print.js → src/med_editor/framework/document-print.ts} +57 -41
- package/src/med_editor/framework/document-segmenter.ts +211 -0
- package/{lib/framework/document-selection.js → src/med_editor/framework/document-selection.ts} +116 -85
- package/{lib/framework/document-template.js → src/med_editor/framework/document-template.ts} +3 -3
- package/src/med_editor/framework/document-textline-mode.ts +34 -0
- package/{lib/framework/element-define.js → src/med_editor/framework/element-define.ts} +301 -206
- package/src/med_editor/framework/element-event-define.ts +141 -0
- package/{lib/framework/element-measure.js → src/med_editor/framework/element-measure.ts} +143 -121
- package/{lib/framework/element-paint.js → src/med_editor/framework/element-paint.ts} +44 -38
- package/{lib/framework/element-props.js → src/med_editor/framework/element-props.ts} +331 -202
- package/{lib/framework/element-reader.js → src/med_editor/framework/element-reader.ts} +39 -31
- package/{lib/framework/element-render-cut.js → src/med_editor/framework/element-render-cut.ts} +113 -106
- package/{lib/framework/element-serialize.js → src/med_editor/framework/element-serialize.ts} +37 -24
- package/{lib/framework/element-util.js → src/med_editor/framework/element-util.ts} +317 -216
- package/{lib/framework/impl/checkbox/checkbox-impl.js → src/med_editor/framework/impl/checkbox/checkbox-impl.ts} +27 -20
- package/{lib/framework/impl/comments/comment-content-impl.js → src/med_editor/framework/impl/comments/comment-content-impl.ts} +45 -31
- package/{lib/framework/impl/comments/comment-element-impl.js → src/med_editor/framework/impl/comments/comment-element-impl.ts} +23 -20
- package/{lib/framework/impl/comments/comments-container-impl.js → src/med_editor/framework/impl/comments/comments-container-impl.ts} +22 -16
- package/{lib/framework/impl/comments/comments-util.js → src/med_editor/framework/impl/comments/comments-util.ts} +34 -17
- package/{lib/framework/impl/comments/validate-msg-impl.js → src/med_editor/framework/impl/comments/validate-msg-impl.ts} +28 -17
- package/{lib/framework/impl/data-element/data-decorate-impl.js → src/med_editor/framework/impl/data-element/data-decorate-impl.ts} +26 -22
- package/{lib/framework/impl/data-element/data-element-barcode.js → src/med_editor/framework/impl/data-element/data-element-barcode.ts} +41 -29
- package/{lib/framework/impl/data-element/data-element-base-impl.js → src/med_editor/framework/impl/data-element/data-element-base-impl.ts} +73 -44
- package/{lib/framework/impl/data-element/data-element-check-impl.js → src/med_editor/framework/impl/data-element/data-element-check-impl.ts} +48 -35
- package/{lib/framework/impl/data-element/data-element-date-impl.js → src/med_editor/framework/impl/data-element/data-element-date-impl.ts} +41 -24
- package/{lib/framework/impl/data-element/data-element-group-impl.js → src/med_editor/framework/impl/data-element/data-element-group-impl.ts} +52 -32
- package/{lib/framework/impl/data-element/data-element-image-impl.js → src/med_editor/framework/impl/data-element/data-element-image-impl.ts} +38 -28
- package/{lib/framework/impl/data-element/data-element-list-impl.js → src/med_editor/framework/impl/data-element/data-element-list-impl.ts} +42 -31
- package/{lib/framework/impl/data-element/data-element-text-impl.js → src/med_editor/framework/impl/data-element/data-element-text-impl.ts} +36 -22
- package/{lib/framework/impl/decorate/fill-null-space-imple.js → src/med_editor/framework/impl/decorate/fill-null-space-imple.ts} +15 -10
- package/{lib/framework/impl/document/doc-body-impl.js → src/med_editor/framework/impl/document/doc-body-impl.ts} +32 -16
- package/{lib/framework/impl/document/doc-body-part-impl.js → src/med_editor/framework/impl/document/doc-body-part-impl.ts} +27 -17
- package/src/med_editor/framework/impl/document/doc-container-impl.ts +24 -0
- package/{lib/framework/impl/document/doc-footer-impl.js → src/med_editor/framework/impl/document/doc-footer-impl.ts} +30 -19
- package/{lib/framework/impl/document/doc-header-impl.js → src/med_editor/framework/impl/document/doc-header-impl.ts} +34 -17
- package/{lib/framework/impl/document/doc-impl.js → src/med_editor/framework/impl/document/doc-impl.ts} +62 -45
- package/{lib/framework/impl/media-formula/menstrual-history.js → src/med_editor/framework/impl/media-formula/menstrual-history.ts} +58 -36
- package/{lib/framework/impl/paragraph/p-impl.js → src/med_editor/framework/impl/paragraph/p-impl.ts} +64 -30
- package/{lib/framework/impl/picture/image-impl.js → src/med_editor/framework/impl/picture/image-impl.ts} +37 -25
- package/{lib/framework/impl/radio/radio-impl.js → src/med_editor/framework/impl/radio/radio-impl.ts} +28 -21
- package/{lib/framework/impl/symbol/br-symbol-impl.js → src/med_editor/framework/impl/symbol/br-symbol-impl.ts} +21 -15
- package/{lib/framework/impl/symbol/p-symbol-impl.js → src/med_editor/framework/impl/symbol/p-symbol-impl.ts} +15 -12
- package/{lib/framework/impl/table/table-cell-impl.js → src/med_editor/framework/impl/table/table-cell-impl.ts} +41 -30
- package/{lib/framework/impl/table/table-impl.js → src/med_editor/framework/impl/table/table-impl.ts} +122 -84
- package/{lib/framework/impl/table/table-row-impl.js → src/med_editor/framework/impl/table/table-row-impl.ts} +26 -18
- package/{lib/framework/impl/table/table-split-cell-patch.js → src/med_editor/framework/impl/table/table-split-cell-patch.ts} +31 -22
- package/{lib/framework/impl/table/table-split-cell.js → src/med_editor/framework/impl/table/table-split-cell.ts} +105 -94
- package/{lib/framework/impl/table/table-util.js → src/med_editor/framework/impl/table/table-util.ts} +197 -159
- package/{lib/framework/impl/text/text-impl.js → src/med_editor/framework/impl/text/text-impl.ts} +49 -35
- package/{lib/framework/impl/text/track-run-impl.js → src/med_editor/framework/impl/text/track-run-impl.ts} +53 -30
- package/{lib/framework/notify.js → src/med_editor/framework/notify.ts} +50 -36
- package/{lib/framework/range-util.js → src/med_editor/framework/range-util.ts} +80 -71
- package/{lib/framework/render-context.js → src/med_editor/framework/render-context.ts} +111 -64
- package/{lib/framework/render-define.js → src/med_editor/framework/render-define.ts} +90 -61
- package/{lib/framework/selection-overlays.js → src/med_editor/framework/selection-overlays.ts} +25 -16
- package/{lib/texteditor.js → src/med_editor/texteditor.ts} +288 -191
- package/src/med_editor/util/subject.ts +118 -0
- package/{lib/util/table-bind.js → src/med_editor/util/table-bind.ts} +2 -2
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225.json +3573 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225.json +3573 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225bug.json +315 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/346/211/271/346/263/250.json +122 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/346/226/207/346/241/243/351/252/214/350/257/201.json +3599 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/351/225/277/346/226/207/346/234/254.json +24586 -0
- package/src/med_editor//345/220/210/345/271/266/347/227/205/347/250/213/345/275/225.json +2874 -0
- package/src/med_editor//346/211/213/346/234/257/350/256/260/345/275/225.json +341 -0
- package/src/med_editor//346/231/256/351/200/232doc/347/261/273/346/226/207/346/241/243.json +2201 -0
- package/src/med_editor//346/243/200/351/252/214/347/224/263/350/257/267/345/215/225.json +1069 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//345/206/205/351/225/234/344/270/213/346/262/273/347/226/227/350/256/260/345/275/225.json +125 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//345/220/210/345/271/266/347/227/205/347/250/213/345/275/225/346/250/241/346/235/277.json +86 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//346/227/245/345/270/270/347/227/205/347/250/213/350/256/260/345/275/225.json +115 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//346/237/245/346/210/277/350/256/260/345/275/2251.json +108 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//351/246/226/346/254/241/344/270/212/347/272/247/345/214/273/345/270/210/346/237/245/346/210/277/350/256/260/345/275/225.json +272 -0
- package/src/med_editor//351/225/277/346/234/237/345/214/273/345/230/261/345/215/225.json +1070 -0
- package/lib/doc-ruler.d.ts +0 -51
- package/lib/doc-ruler.js.map +0 -1
- package/lib/framework/common-util.d.ts +0 -63
- package/lib/framework/common-util.js +0 -178
- package/lib/framework/common-util.js.map +0 -1
- package/lib/framework/document-change.d.ts +0 -265
- package/lib/framework/document-change.js.map +0 -1
- package/lib/framework/document-combine.d.ts +0 -24
- package/lib/framework/document-combine.js.map +0 -1
- package/lib/framework/document-comment.d.ts +0 -46
- package/lib/framework/document-comment.js.map +0 -1
- package/lib/framework/document-context.d.ts +0 -149
- package/lib/framework/document-context.js.map +0 -1
- package/lib/framework/document-eval-func.d.ts +0 -18
- package/lib/framework/document-eval-func.js.map +0 -1
- package/lib/framework/document-event.d.ts +0 -213
- package/lib/framework/document-event.js.map +0 -1
- package/lib/framework/document-history.d.ts +0 -26
- package/lib/framework/document-history.js.map +0 -1
- package/lib/framework/document-images-loader.d.ts +0 -16
- package/lib/framework/document-images-loader.js.map +0 -1
- package/lib/framework/document-input-cursor.d.ts +0 -78
- package/lib/framework/document-input-cursor.js.map +0 -1
- package/lib/framework/document-paint.d.ts +0 -34
- package/lib/framework/document-paint.js.map +0 -1
- package/lib/framework/document-print-offscreen.d.ts +0 -38
- package/lib/framework/document-print-offscreen.js.map +0 -1
- package/lib/framework/document-print.d.ts +0 -60
- package/lib/framework/document-print.js.map +0 -1
- package/lib/framework/document-segmenter.d.ts +0 -2
- package/lib/framework/document-segmenter.js +0 -106
- package/lib/framework/document-segmenter.js.map +0 -1
- package/lib/framework/document-selection.d.ts +0 -89
- package/lib/framework/document-selection.js.map +0 -1
- package/lib/framework/document-template.d.ts +0 -4
- package/lib/framework/document-template.js.map +0 -1
- package/lib/framework/document-textline-mode.d.ts +0 -7
- package/lib/framework/document-textline-mode.js +0 -30
- package/lib/framework/document-textline-mode.js.map +0 -1
- package/lib/framework/element-define.d.ts +0 -319
- package/lib/framework/element-define.js.map +0 -1
- package/lib/framework/element-event-define.d.ts +0 -99
- package/lib/framework/element-event-define.js +0 -108
- package/lib/framework/element-event-define.js.map +0 -1
- package/lib/framework/element-measure.d.ts +0 -97
- package/lib/framework/element-measure.js.map +0 -1
- package/lib/framework/element-paint.d.ts +0 -42
- package/lib/framework/element-paint.js.map +0 -1
- package/lib/framework/element-props.d.ts +0 -301
- package/lib/framework/element-props.js.map +0 -1
- package/lib/framework/element-reader.d.ts +0 -19
- package/lib/framework/element-reader.js.map +0 -1
- package/lib/framework/element-render-cut.d.ts +0 -55
- package/lib/framework/element-render-cut.js.map +0 -1
- package/lib/framework/element-serialize.d.ts +0 -30
- package/lib/framework/element-serialize.js.map +0 -1
- package/lib/framework/element-util.d.ts +0 -369
- package/lib/framework/element-util.js.map +0 -1
- package/lib/framework/impl/checkbox/checkbox-impl.d.ts +0 -24
- package/lib/framework/impl/checkbox/checkbox-impl.js.map +0 -1
- package/lib/framework/impl/comments/comment-content-impl.d.ts +0 -40
- package/lib/framework/impl/comments/comment-content-impl.js.map +0 -1
- package/lib/framework/impl/comments/comment-element-impl.d.ts +0 -21
- package/lib/framework/impl/comments/comment-element-impl.js.map +0 -1
- package/lib/framework/impl/comments/comments-container-impl.d.ts +0 -22
- package/lib/framework/impl/comments/comments-container-impl.js.map +0 -1
- package/lib/framework/impl/comments/comments-util.d.ts +0 -12
- package/lib/framework/impl/comments/comments-util.js.map +0 -1
- package/lib/framework/impl/comments/validate-msg-impl.d.ts +0 -21
- package/lib/framework/impl/comments/validate-msg-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-decorate-impl.d.ts +0 -30
- package/lib/framework/impl/data-element/data-decorate-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-barcode.d.ts +0 -31
- package/lib/framework/impl/data-element/data-element-barcode.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-base-impl.d.ts +0 -68
- package/lib/framework/impl/data-element/data-element-base-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-check-impl.d.ts +0 -35
- package/lib/framework/impl/data-element/data-element-check-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-date-impl.d.ts +0 -23
- package/lib/framework/impl/data-element/data-element-date-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-group-impl.d.ts +0 -23
- package/lib/framework/impl/data-element/data-element-group-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-image-impl.d.ts +0 -30
- package/lib/framework/impl/data-element/data-element-image-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-list-impl.d.ts +0 -22
- package/lib/framework/impl/data-element/data-element-list-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-text-impl.d.ts +0 -23
- package/lib/framework/impl/data-element/data-element-text-impl.js.map +0 -1
- package/lib/framework/impl/decorate/fill-null-space-imple.d.ts +0 -21
- package/lib/framework/impl/decorate/fill-null-space-imple.js.map +0 -1
- package/lib/framework/impl/document/doc-body-impl.d.ts +0 -27
- package/lib/framework/impl/document/doc-body-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-body-part-impl.d.ts +0 -30
- package/lib/framework/impl/document/doc-body-part-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-container-impl.d.ts +0 -16
- package/lib/framework/impl/document/doc-container-impl.js +0 -21
- package/lib/framework/impl/document/doc-container-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-footer-impl.d.ts +0 -26
- package/lib/framework/impl/document/doc-footer-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-header-impl.d.ts +0 -26
- package/lib/framework/impl/document/doc-header-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-impl.d.ts +0 -61
- package/lib/framework/impl/document/doc-impl.js.map +0 -1
- package/lib/framework/impl/media-formula/menstrual-history.d.ts +0 -35
- package/lib/framework/impl/media-formula/menstrual-history.js.map +0 -1
- package/lib/framework/impl/paragraph/p-impl.d.ts +0 -45
- package/lib/framework/impl/paragraph/p-impl.js.map +0 -1
- package/lib/framework/impl/picture/image-impl.d.ts +0 -31
- package/lib/framework/impl/picture/image-impl.js.map +0 -1
- package/lib/framework/impl/radio/radio-impl.d.ts +0 -22
- package/lib/framework/impl/radio/radio-impl.js.map +0 -1
- package/lib/framework/impl/symbol/br-symbol-impl.d.ts +0 -22
- package/lib/framework/impl/symbol/br-symbol-impl.js.map +0 -1
- package/lib/framework/impl/symbol/p-symbol-impl.d.ts +0 -19
- package/lib/framework/impl/symbol/p-symbol-impl.js.map +0 -1
- package/lib/framework/impl/table/table-cell-impl.d.ts +0 -37
- package/lib/framework/impl/table/table-cell-impl.js.map +0 -1
- package/lib/framework/impl/table/table-impl.d.ts +0 -55
- package/lib/framework/impl/table/table-impl.js.map +0 -1
- package/lib/framework/impl/table/table-row-impl.d.ts +0 -26
- package/lib/framework/impl/table/table-row-impl.js.map +0 -1
- package/lib/framework/impl/table/table-split-cell-patch.d.ts +0 -20
- package/lib/framework/impl/table/table-split-cell-patch.js.map +0 -1
- package/lib/framework/impl/table/table-split-cell.d.ts +0 -90
- package/lib/framework/impl/table/table-split-cell.js.map +0 -1
- package/lib/framework/impl/table/table-util.d.ts +0 -150
- package/lib/framework/impl/table/table-util.js.map +0 -1
- package/lib/framework/impl/text/text-impl.d.ts +0 -32
- package/lib/framework/impl/text/text-impl.js.map +0 -1
- package/lib/framework/impl/text/track-run-impl.d.ts +0 -27
- package/lib/framework/impl/text/track-run-impl.js.map +0 -1
- package/lib/framework/notify.d.ts +0 -13
- package/lib/framework/notify.js.map +0 -1
- package/lib/framework/range-util.d.ts +0 -40
- package/lib/framework/range-util.js.map +0 -1
- package/lib/framework/render-context.d.ts +0 -91
- package/lib/framework/render-context.js.map +0 -1
- package/lib/framework/render-define.d.ts +0 -109
- package/lib/framework/render-define.js.map +0 -1
- package/lib/framework/selection-overlays.d.ts +0 -30
- package/lib/framework/selection-overlays.js.map +0 -1
- package/lib/texteditor.d.ts +0 -318
- package/lib/texteditor.js.map +0 -1
- package/lib/util/subject.d.ts +0 -34
- package/lib/util/subject.js +0 -88
- package/lib/util/subject.js.map +0 -1
- package/lib/util/table-bind.d.ts +0 -5
- package/lib/util/table-bind.js.map +0 -1
- package/tsconfig.json +0 -25
@@ -1,5 +1,7 @@
|
|
1
1
|
import { DocumentBodyElement } from "./impl/document/doc-body-impl";
|
2
2
|
import { DocumentBodyPartElement } from "./impl/document/doc-body-part-impl";
|
3
|
+
import { DocumentElement } from "./impl/document/doc-impl";
|
4
|
+
|
3
5
|
/**
|
4
6
|
* 文档合并
|
5
7
|
*/
|
@@ -8,33 +10,35 @@ export class DocumentCombine {
|
|
8
10
|
* 合并模板文档
|
9
11
|
* 用于设置合并后,页眉页脚等统一部分
|
10
12
|
*/
|
11
|
-
mainTemplate
|
12
|
-
|
13
|
+
mainTemplate!: DocumentElement
|
14
|
+
|
15
|
+
docParts: Array<{ doc: DocumentElement, docId: string }> = [];
|
13
16
|
/**
|
14
17
|
* 添加需要合并的文档部分
|
15
18
|
*/
|
16
|
-
add(docPart, id) {
|
17
|
-
this.docParts.push({ doc: docPart, docId: id })
|
19
|
+
add(docPart: DocumentElement, id: string): void {
|
20
|
+
this.docParts.push({ doc: docPart, docId: id })
|
18
21
|
}
|
19
|
-
|
22
|
+
|
23
|
+
dispose(): void {
|
20
24
|
this.docParts.length = 0;
|
21
25
|
}
|
26
|
+
|
22
27
|
/**
|
23
28
|
* 用于合并文档计算
|
24
29
|
*/
|
25
|
-
load() {
|
30
|
+
load(): DocumentElement {
|
26
31
|
const template = this.mainTemplate.clone();
|
27
|
-
const body = template.find((item) => item instanceof DocumentBodyElement);
|
32
|
+
const body = template.find((item) => item instanceof DocumentBodyElement) as DocumentBodyElement;
|
28
33
|
body.clearItems();
|
29
34
|
for (let i = 0; i < this.docParts.length; i++) {
|
30
35
|
const part = this.docParts[i];
|
31
36
|
const docPartContainer = new DocumentBodyPartElement();
|
32
37
|
docPartContainer.props.partId = part.docId;
|
33
|
-
const docPartBody = part.doc.find(item => item instanceof DocumentBodyElement)
|
38
|
+
const docPartBody = part.doc.find(item => item instanceof DocumentBodyElement) as DocumentBodyElement
|
34
39
|
docPartContainer.addChild(docPartBody.clone(true));
|
35
|
-
body.addChild(docPartContainer)
|
40
|
+
body.addChild(docPartContainer)
|
36
41
|
}
|
37
42
|
return template;
|
38
43
|
}
|
39
|
-
}
|
40
|
-
//# sourceMappingURL=document-combine.js.map
|
44
|
+
}
|
@@ -1,55 +1,57 @@
|
|
1
|
+
import { EditorContext } from "./document-context";
|
1
2
|
import { ElementUtil } from "./element-util";
|
3
|
+
import { CommContentBaseElement, CommContentElement } from "./impl/comments/comment-content-impl";
|
2
4
|
import { CommentElement } from "./impl/comments/comment-element-impl";
|
3
5
|
import { TextGroupElement } from "./impl/text/text-impl";
|
4
6
|
import { RangeUtil } from "./range-util";
|
7
|
+
|
5
8
|
/**
|
6
9
|
* 处理文档批注
|
7
10
|
*/
|
8
11
|
export class DocumentComment {
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
this.docCtx = docCtx;
|
15
|
-
}
|
12
|
+
commMarkList: Array<CommentElement> = [];
|
13
|
+
commContentList: Array<CommContentBaseElement> = [];
|
14
|
+
isDirty: boolean = true;
|
15
|
+
constructor(public docCtx: EditorContext) { }
|
16
|
+
|
16
17
|
/**
|
17
18
|
* 读取审阅标记符号
|
18
19
|
*/
|
19
|
-
readComments() {
|
20
|
+
readComments(): void {
|
20
21
|
if (!this.isDirty) {
|
21
22
|
return;
|
22
23
|
}
|
23
|
-
const commList = this.docCtx.document.treeFilter(item => item.type === 'comm')
|
24
|
+
const commList = this.docCtx.document.treeFilter(item => item.type === 'comm') as Array<CommentElement>;
|
24
25
|
const startCommList = commList.filter(item => item.props.markType === "start");
|
25
26
|
const endCommList = commList.filter(item => item.props.markType === "end");
|
26
27
|
const commMaps = startCommList.map(startItem => {
|
27
28
|
const end = endCommList.find(endItem => endItem.props.id === startItem.props.id);
|
28
29
|
if (!end) {
|
29
|
-
throw new Error('未找到匹配的结束审阅符号')
|
30
|
+
throw new Error('未找到匹配的结束审阅符号')
|
30
31
|
}
|
31
|
-
return { start: startItem, end }
|
32
|
-
})
|
33
|
-
const commContentList = [];
|
32
|
+
return { start: startItem, end }
|
33
|
+
})
|
34
|
+
const commContentList: Array<CommContentBaseElement> = [];
|
34
35
|
for (let i = 0; i < this.docCtx.document.commentsContainerElement.length; i++) {
|
35
|
-
const commContent = this.docCtx.document.commentsContainerElement.getChild(i);
|
36
|
+
const commContent = this.docCtx.document.commentsContainerElement.getChild(i) as CommContentBaseElement;
|
36
37
|
const commMap = commMaps.find(item => item.start.props.id === commContent.props.id);
|
37
38
|
if (!commMap) {
|
38
39
|
throw new Error('未找到审阅内容对应的审阅符号');
|
39
40
|
}
|
40
41
|
commContent.startMark = commMap.start;
|
41
42
|
commContent.endMark = commMap.end;
|
42
|
-
commContentList.push(commContent)
|
43
|
+
commContentList.push(commContent)
|
43
44
|
}
|
44
45
|
this.commMarkList = commList;
|
45
46
|
this.commContentList = commContentList;
|
46
47
|
this.docCtx.viewOptions.showReviewWindow = this.commContentList.length > 0;
|
47
48
|
this.isDirty = false;
|
48
49
|
}
|
50
|
+
|
49
51
|
/**
|
50
52
|
* 执行删除前,需要更新批注节点位置
|
51
53
|
*/
|
52
|
-
updateComments() {
|
54
|
+
updateComments(): void {
|
53
55
|
const { selectionState } = this.docCtx;
|
54
56
|
const { startControl, startOffset, collapsed, selectedRange } = selectionState;
|
55
57
|
if (collapsed) {
|
@@ -63,39 +65,37 @@ export class DocumentComment {
|
|
63
65
|
if (startControl.textMeasures.length === startOffset) {
|
64
66
|
this.removeComment(nextSiblingEle.props.id);
|
65
67
|
}
|
66
|
-
}
|
67
|
-
else {
|
68
|
+
} else {
|
68
69
|
this.removeComment(nextSiblingEle.props.id);
|
69
70
|
}
|
70
71
|
}
|
71
|
-
}
|
72
|
-
else {
|
72
|
+
} else {
|
73
73
|
//如果开始批注被选中,则需要移动开始批注元素到选区末尾
|
74
74
|
//如果结束批注被选中,则需要删除当前批注
|
75
75
|
if (!selectedRange) {
|
76
|
-
return
|
76
|
+
return
|
77
77
|
}
|
78
78
|
const endRange = RangeUtil.getEndRangeTarget(selectedRange);
|
79
79
|
if (!endRange) {
|
80
|
-
return
|
80
|
+
return
|
81
81
|
}
|
82
|
-
const commPairs = [];
|
82
|
+
const commPairs: Array<CommMarkSelectedStatus> = [];
|
83
83
|
for (let i = 0; i < this.commContentList.length; i++) {
|
84
84
|
const { startMark, endMark } = this.commContentList[i];
|
85
|
-
const commPair = {
|
85
|
+
const commPair: CommMarkSelectedStatus = {
|
86
86
|
startMark,
|
87
87
|
endMark,
|
88
88
|
startMarkStatus: RangeUtil.checkElementFullInRange(selectedRange, startMark),
|
89
89
|
endMarkStatus: RangeUtil.checkElementFullInRange(selectedRange, endMark),
|
90
90
|
};
|
91
|
-
commPairs.push(commPair)
|
91
|
+
commPairs.push(commPair)
|
92
92
|
}
|
93
|
+
|
93
94
|
for (let i = 0; i < commPairs.length; i++) {
|
94
95
|
const commPair = commPairs[i];
|
95
96
|
if (commPair.endMarkStatus) {
|
96
97
|
this.removeComment(commPair.endMark.props.id);
|
97
|
-
}
|
98
|
-
else if (commPair.startMarkStatus) {
|
98
|
+
} else if (commPair.startMarkStatus) {
|
99
99
|
// const newStartMark = new CommentElement();
|
100
100
|
// newStartMark.props.id = commPair.startMark.props.id;
|
101
101
|
// commPair.startMark.isDecorate = false;
|
@@ -104,45 +104,60 @@ export class DocumentComment {
|
|
104
104
|
}
|
105
105
|
}
|
106
106
|
}
|
107
|
+
|
108
|
+
|
107
109
|
/**
|
108
110
|
* 删除批注
|
109
|
-
* @param id
|
111
|
+
* @param id
|
110
112
|
*/
|
111
|
-
removeComment(id) {
|
113
|
+
removeComment(id: string): void {
|
112
114
|
const commentMarks = this.commMarkList.filter(item => item.props.id === id);
|
113
115
|
const commentContent = this.commContentList.find(item => item.props.id === id);
|
114
|
-
commentMarks.forEach(item => item.remove())
|
116
|
+
commentMarks.forEach(item => item.remove())
|
115
117
|
commentContent?.remove();
|
116
118
|
this.afterCommentsChanged();
|
117
119
|
}
|
118
|
-
|
120
|
+
|
121
|
+
getCommMarkIndex(commMark: CommentElement): number {
|
119
122
|
const markType = commMark.props.markType;
|
120
|
-
const commList = this.docCtx.document.treeFilter(item => item.type === 'comm')
|
123
|
+
const commList = this.docCtx.document.treeFilter(item => item.type === 'comm') as Array<CommentElement>;
|
121
124
|
const startCommList = commList.filter(item => item.props.markType === markType);
|
122
125
|
return startCommList.indexOf(commMark);
|
123
126
|
}
|
127
|
+
|
124
128
|
/**
|
125
129
|
* 清除所有批注
|
126
130
|
*/
|
127
|
-
clearAllComments() {
|
131
|
+
clearAllComments(): void {
|
128
132
|
this.readComments();
|
129
133
|
for (let i = 0; i < this.commContentList.length; i++) {
|
130
134
|
this.removeComment(this.commContentList[i].props.id);
|
131
135
|
}
|
132
136
|
this.docCtx.selectionState.clear();
|
133
137
|
}
|
138
|
+
|
134
139
|
/**
|
135
140
|
* 清除所有的验证批注
|
136
141
|
*/
|
137
|
-
clearAllValidates() {
|
138
|
-
this.docCtx.document.treeFilter(item => item.type === 'validate').forEach(item => { this.removeComment(item.props.id)
|
142
|
+
clearAllValidates(): void {
|
143
|
+
this.docCtx.document.treeFilter(item => item.type === 'validate').forEach(item => { this.removeComment(item.props.id) })
|
139
144
|
}
|
145
|
+
|
140
146
|
/**
|
141
147
|
* 批注修改后事件
|
142
148
|
* 用于标注当前文档的批注发生更改了,不再重复读取批注,提高性能
|
143
149
|
*/
|
144
|
-
afterCommentsChanged() {
|
150
|
+
afterCommentsChanged(): void {
|
145
151
|
this.isDirty = true;
|
146
152
|
}
|
153
|
+
|
154
|
+
|
155
|
+
}
|
156
|
+
|
157
|
+
|
158
|
+
export interface CommMarkSelectedStatus {
|
159
|
+
startMark: CommentElement,
|
160
|
+
endMark: CommentElement,
|
161
|
+
startMarkStatus: boolean,
|
162
|
+
endMarkStatus: boolean
|
147
163
|
}
|
148
|
-
//# sourceMappingURL=document-comment.js.map
|