@hailin-zheng/editor-core 1.0.9 → 1.0.13
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/doc-ruler.d.ts +51 -0
- package/{src/med_editor/doc-ruler.ts → lib/doc-ruler.js} +73 -100
- package/lib/doc-ruler.js.map +1 -0
- package/lib/framework/common-util.d.ts +63 -0
- package/lib/framework/common-util.js +178 -0
- package/lib/framework/common-util.js.map +1 -0
- package/lib/framework/document-change.d.ts +265 -0
- package/{src/med_editor/framework/document-change.ts → lib/framework/document-change.js} +257 -306
- package/lib/framework/document-change.js.map +1 -0
- package/lib/framework/document-combine.d.ts +24 -0
- package/{src/med_editor/framework/document-combine.ts → lib/framework/document-combine.js} +11 -15
- package/lib/framework/document-combine.js.map +1 -0
- package/lib/framework/document-comment.d.ts +46 -0
- package/{src/med_editor/framework/document-comment.ts → lib/framework/document-comment.js} +37 -52
- package/lib/framework/document-comment.js.map +1 -0
- package/lib/framework/document-context.d.ts +149 -0
- package/{src/med_editor/framework/document-context.ts → lib/framework/document-context.js} +101 -181
- package/lib/framework/document-context.js.map +1 -0
- package/lib/framework/document-eval-func.d.ts +18 -0
- package/{src/med_editor/framework/document-eval-func.ts → lib/framework/document-eval-func.js} +11 -16
- package/lib/framework/document-eval-func.js.map +1 -0
- package/lib/framework/document-event.d.ts +213 -0
- package/{src/med_editor/framework/document-event.ts → lib/framework/document-event.js} +216 -244
- package/lib/framework/document-event.js.map +1 -0
- package/lib/framework/document-history.d.ts +26 -0
- package/{src/med_editor/framework/document-history.ts → lib/framework/document-history.js} +14 -25
- package/lib/framework/document-history.js.map +1 -0
- package/lib/framework/document-images-loader.d.ts +16 -0
- package/{src/med_editor/framework/document-images-loader.ts → lib/framework/document-images-loader.js} +17 -25
- package/lib/framework/document-images-loader.js.map +1 -0
- package/lib/framework/document-input-cursor.d.ts +78 -0
- package/{src/med_editor/framework/document-input-cursor.ts → lib/framework/document-input-cursor.js} +71 -76
- package/lib/framework/document-input-cursor.js.map +1 -0
- package/lib/framework/document-paint.d.ts +34 -0
- package/{src/med_editor/framework/document-paint.ts → lib/framework/document-paint.js} +28 -35
- package/lib/framework/document-paint.js.map +1 -0
- package/lib/framework/document-print-offscreen.d.ts +38 -0
- package/{src/med_editor/framework/document-print-offscreen.ts → lib/framework/document-print-offscreen.js} +19 -25
- package/lib/framework/document-print-offscreen.js.map +1 -0
- package/lib/framework/document-print.d.ts +60 -0
- package/{src/med_editor/framework/document-print.ts → lib/framework/document-print.js} +41 -57
- package/lib/framework/document-print.js.map +1 -0
- package/lib/framework/document-segmenter.d.ts +2 -0
- package/lib/framework/document-segmenter.js +106 -0
- package/lib/framework/document-segmenter.js.map +1 -0
- package/lib/framework/document-selection.d.ts +89 -0
- package/{src/med_editor/framework/document-selection.ts → lib/framework/document-selection.js} +84 -115
- package/lib/framework/document-selection.js.map +1 -0
- package/lib/framework/document-template.d.ts +4 -0
- package/{src/med_editor/framework/document-template.ts → lib/framework/document-template.js} +3 -3
- package/lib/framework/document-template.js.map +1 -0
- package/lib/framework/document-textline-mode.d.ts +7 -0
- package/lib/framework/document-textline-mode.js +30 -0
- package/lib/framework/document-textline-mode.js.map +1 -0
- package/lib/framework/element-define.d.ts +319 -0
- package/{src/med_editor/framework/element-define.ts → lib/framework/element-define.js} +206 -301
- package/lib/framework/element-define.js.map +1 -0
- package/lib/framework/element-event-define.d.ts +98 -0
- package/lib/framework/element-event-define.js +108 -0
- package/lib/framework/element-event-define.js.map +1 -0
- package/lib/framework/element-measure.d.ts +97 -0
- package/{src/med_editor/framework/element-measure.ts → lib/framework/element-measure.js} +121 -143
- package/lib/framework/element-measure.js.map +1 -0
- package/lib/framework/element-paint.d.ts +42 -0
- package/{src/med_editor/framework/element-paint.ts → lib/framework/element-paint.js} +37 -43
- package/lib/framework/element-paint.js.map +1 -0
- package/lib/framework/element-props.d.ts +301 -0
- package/{src/med_editor/framework/element-props.ts → lib/framework/element-props.js} +202 -331
- package/lib/framework/element-props.js.map +1 -0
- package/lib/framework/element-reader.d.ts +19 -0
- package/{src/med_editor/framework/element-reader.ts → lib/framework/element-reader.js} +30 -38
- package/lib/framework/element-reader.js.map +1 -0
- package/lib/framework/element-render-cut.d.ts +55 -0
- package/{src/med_editor/framework/element-render-cut.ts → lib/framework/element-render-cut.js} +106 -113
- package/lib/framework/element-render-cut.js.map +1 -0
- package/lib/framework/element-serialize.d.ts +30 -0
- package/{src/med_editor/framework/element-serialize.ts → lib/framework/element-serialize.js} +24 -37
- package/lib/framework/element-serialize.js.map +1 -0
- package/lib/framework/element-util.d.ts +369 -0
- package/{src/med_editor/framework/element-util.ts → lib/framework/element-util.js} +216 -317
- package/lib/framework/element-util.js.map +1 -0
- package/lib/framework/impl/checkbox/checkbox-impl.d.ts +24 -0
- package/{src/med_editor/framework/impl/checkbox/checkbox-impl.ts → lib/framework/impl/checkbox/checkbox-impl.js} +18 -25
- package/lib/framework/impl/checkbox/checkbox-impl.js.map +1 -0
- package/lib/framework/impl/comments/comment-content-impl.d.ts +40 -0
- package/{src/med_editor/framework/impl/comments/comment-content-impl.ts → lib/framework/impl/comments/comment-content-impl.js} +31 -45
- package/lib/framework/impl/comments/comment-content-impl.js.map +1 -0
- package/lib/framework/impl/comments/comment-element-impl.d.ts +21 -0
- package/{src/med_editor/framework/impl/comments/comment-element-impl.ts → lib/framework/impl/comments/comment-element-impl.js} +18 -21
- package/lib/framework/impl/comments/comment-element-impl.js.map +1 -0
- package/lib/framework/impl/comments/comments-container-impl.d.ts +22 -0
- package/{src/med_editor/framework/impl/comments/comments-container-impl.ts → lib/framework/impl/comments/comments-container-impl.js} +15 -21
- package/lib/framework/impl/comments/comments-container-impl.js.map +1 -0
- package/lib/framework/impl/comments/comments-util.d.ts +12 -0
- package/{src/med_editor/framework/impl/comments/comments-util.ts → lib/framework/impl/comments/comments-util.js} +17 -34
- package/lib/framework/impl/comments/comments-util.js.map +1 -0
- package/lib/framework/impl/comments/validate-msg-impl.d.ts +21 -0
- package/{src/med_editor/framework/impl/comments/validate-msg-impl.ts → lib/framework/impl/comments/validate-msg-impl.js} +15 -26
- package/lib/framework/impl/comments/validate-msg-impl.js.map +1 -0
- package/lib/framework/impl/data-element/data-decorate-impl.d.ts +30 -0
- package/{src/med_editor/framework/impl/data-element/data-decorate-impl.ts → lib/framework/impl/data-element/data-decorate-impl.js} +21 -25
- package/lib/framework/impl/data-element/data-decorate-impl.js.map +1 -0
- package/lib/framework/impl/data-element/data-element-barcode.d.ts +31 -0
- package/{src/med_editor/framework/impl/data-element/data-element-barcode.ts → lib/framework/impl/data-element/data-element-barcode.js} +27 -39
- package/lib/framework/impl/data-element/data-element-barcode.js.map +1 -0
- package/lib/framework/impl/data-element/data-element-base-impl.d.ts +68 -0
- package/{src/med_editor/framework/impl/data-element/data-element-base-impl.ts → lib/framework/impl/data-element/data-element-base-impl.js} +44 -73
- package/lib/framework/impl/data-element/data-element-base-impl.js.map +1 -0
- package/lib/framework/impl/data-element/data-element-check-impl.d.ts +35 -0
- package/{src/med_editor/framework/impl/data-element/data-element-check-impl.ts → lib/framework/impl/data-element/data-element-check-impl.js} +33 -46
- package/lib/framework/impl/data-element/data-element-check-impl.js.map +1 -0
- package/lib/framework/impl/data-element/data-element-date-impl.d.ts +23 -0
- package/{src/med_editor/framework/impl/data-element/data-element-date-impl.ts → lib/framework/impl/data-element/data-element-date-impl.js} +22 -39
- package/lib/framework/impl/data-element/data-element-date-impl.js.map +1 -0
- package/lib/framework/impl/data-element/data-element-group-impl.d.ts +23 -0
- package/{src/med_editor/framework/impl/data-element/data-element-group-impl.ts → lib/framework/impl/data-element/data-element-group-impl.js} +29 -49
- package/lib/framework/impl/data-element/data-element-group-impl.js.map +1 -0
- package/lib/framework/impl/data-element/data-element-image-impl.d.ts +30 -0
- package/{src/med_editor/framework/impl/data-element/data-element-image-impl.ts → lib/framework/impl/data-element/data-element-image-impl.js} +26 -36
- package/lib/framework/impl/data-element/data-element-image-impl.js.map +1 -0
- package/lib/framework/impl/data-element/data-element-list-impl.d.ts +22 -0
- package/{src/med_editor/framework/impl/data-element/data-element-list-impl.ts → lib/framework/impl/data-element/data-element-list-impl.js} +30 -41
- package/lib/framework/impl/data-element/data-element-list-impl.js.map +1 -0
- package/lib/framework/impl/data-element/data-element-text-impl.d.ts +23 -0
- package/{src/med_editor/framework/impl/data-element/data-element-text-impl.ts → lib/framework/impl/data-element/data-element-text-impl.js} +20 -34
- package/lib/framework/impl/data-element/data-element-text-impl.js.map +1 -0
- package/lib/framework/impl/decorate/fill-null-space-imple.d.ts +21 -0
- package/{src/med_editor/framework/impl/decorate/fill-null-space-imple.ts → lib/framework/impl/decorate/fill-null-space-imple.js} +10 -15
- package/lib/framework/impl/decorate/fill-null-space-imple.js.map +1 -0
- package/lib/framework/impl/document/doc-body-impl.d.ts +27 -0
- package/{src/med_editor/framework/impl/document/doc-body-impl.ts → lib/framework/impl/document/doc-body-impl.js} +15 -31
- package/lib/framework/impl/document/doc-body-impl.js.map +1 -0
- package/lib/framework/impl/document/doc-body-part-impl.d.ts +30 -0
- package/{src/med_editor/framework/impl/document/doc-body-part-impl.ts → lib/framework/impl/document/doc-body-part-impl.js} +16 -26
- package/lib/framework/impl/document/doc-body-part-impl.js.map +1 -0
- package/lib/framework/impl/document/doc-container-impl.d.ts +16 -0
- package/lib/framework/impl/document/doc-container-impl.js +21 -0
- package/lib/framework/impl/document/doc-container-impl.js.map +1 -0
- package/lib/framework/impl/document/doc-footer-impl.d.ts +26 -0
- package/{src/med_editor/framework/impl/document/doc-footer-impl.ts → lib/framework/impl/document/doc-footer-impl.js} +18 -29
- package/lib/framework/impl/document/doc-footer-impl.js.map +1 -0
- package/lib/framework/impl/document/doc-header-impl.d.ts +26 -0
- package/{src/med_editor/framework/impl/document/doc-header-impl.ts → lib/framework/impl/document/doc-header-impl.js} +16 -33
- package/lib/framework/impl/document/doc-header-impl.js.map +1 -0
- package/lib/framework/impl/document/doc-impl.d.ts +61 -0
- package/{src/med_editor/framework/impl/document/doc-impl.ts → lib/framework/impl/document/doc-impl.js} +42 -59
- package/lib/framework/impl/document/doc-impl.js.map +1 -0
- package/lib/framework/impl/media-formula/menstrual-history.d.ts +35 -0
- package/{src/med_editor/framework/impl/media-formula/menstrual-history.ts → lib/framework/impl/media-formula/menstrual-history.js} +35 -57
- package/lib/framework/impl/media-formula/menstrual-history.js.map +1 -0
- package/lib/framework/impl/paragraph/p-impl.d.ts +45 -0
- package/{src/med_editor/framework/impl/paragraph/p-impl.ts → lib/framework/impl/paragraph/p-impl.js} +28 -62
- package/lib/framework/impl/paragraph/p-impl.js.map +1 -0
- package/lib/framework/impl/picture/image-impl.d.ts +31 -0
- package/{src/med_editor/framework/impl/picture/image-impl.ts → lib/framework/impl/picture/image-impl.js} +23 -35
- package/lib/framework/impl/picture/image-impl.js.map +1 -0
- package/lib/framework/impl/radio/radio-impl.d.ts +22 -0
- package/{src/med_editor/framework/impl/radio/radio-impl.ts → lib/framework/impl/radio/radio-impl.js} +19 -26
- package/lib/framework/impl/radio/radio-impl.js.map +1 -0
- package/lib/framework/impl/symbol/br-symbol-impl.d.ts +22 -0
- package/{src/med_editor/framework/impl/symbol/br-symbol-impl.ts → lib/framework/impl/symbol/br-symbol-impl.js} +14 -20
- package/lib/framework/impl/symbol/br-symbol-impl.js.map +1 -0
- package/lib/framework/impl/symbol/p-symbol-impl.d.ts +19 -0
- package/{src/med_editor/framework/impl/symbol/p-symbol-impl.ts → lib/framework/impl/symbol/p-symbol-impl.js} +11 -14
- package/lib/framework/impl/symbol/p-symbol-impl.js.map +1 -0
- package/lib/framework/impl/table/table-cell-impl.d.ts +37 -0
- package/{src/med_editor/framework/impl/table/table-cell-impl.ts → lib/framework/impl/table/table-cell-impl.js} +28 -39
- package/lib/framework/impl/table/table-cell-impl.js.map +1 -0
- package/lib/framework/impl/table/table-impl.d.ts +55 -0
- package/{src/med_editor/framework/impl/table/table-impl.ts → lib/framework/impl/table/table-impl.js} +82 -120
- package/lib/framework/impl/table/table-impl.js.map +1 -0
- package/lib/framework/impl/table/table-row-impl.d.ts +26 -0
- package/{src/med_editor/framework/impl/table/table-row-impl.ts → lib/framework/impl/table/table-row-impl.js} +16 -24
- package/lib/framework/impl/table/table-row-impl.js.map +1 -0
- package/lib/framework/impl/table/table-split-cell-patch.d.ts +20 -0
- package/{src/med_editor/framework/impl/table/table-split-cell-patch.ts → lib/framework/impl/table/table-split-cell-patch.js} +22 -31
- package/lib/framework/impl/table/table-split-cell-patch.js.map +1 -0
- package/lib/framework/impl/table/table-split-cell.d.ts +90 -0
- package/{src/med_editor/framework/impl/table/table-split-cell.ts → lib/framework/impl/table/table-split-cell.js} +94 -105
- package/lib/framework/impl/table/table-split-cell.js.map +1 -0
- package/lib/framework/impl/table/table-util.d.ts +150 -0
- package/{src/med_editor/framework/impl/table/table-util.ts → lib/framework/impl/table/table-util.js} +157 -195
- package/lib/framework/impl/table/table-util.js.map +1 -0
- package/lib/framework/impl/text/text-impl.d.ts +32 -0
- package/{src/med_editor/framework/impl/text/text-impl.ts → lib/framework/impl/text/text-impl.js} +32 -46
- package/lib/framework/impl/text/text-impl.js.map +1 -0
- package/lib/framework/impl/text/track-run-impl.d.ts +27 -0
- package/{src/med_editor/framework/impl/text/track-run-impl.ts → lib/framework/impl/text/track-run-impl.js} +28 -51
- package/lib/framework/impl/text/track-run-impl.js.map +1 -0
- package/lib/framework/notify.d.ts +13 -0
- package/{src/med_editor/framework/notify.ts → lib/framework/notify.js} +36 -50
- package/lib/framework/notify.js.map +1 -0
- package/lib/framework/range-util.d.ts +40 -0
- package/{src/med_editor/framework/range-util.ts → lib/framework/range-util.js} +71 -80
- package/lib/framework/range-util.js.map +1 -0
- package/lib/framework/render-context.d.ts +91 -0
- package/{src/med_editor/framework/render-context.ts → lib/framework/render-context.js} +64 -111
- package/lib/framework/render-context.js.map +1 -0
- package/lib/framework/render-define.d.ts +109 -0
- package/{src/med_editor/framework/render-define.ts → lib/framework/render-define.js} +61 -90
- package/lib/framework/render-define.js.map +1 -0
- package/lib/framework/selection-overlays.d.ts +30 -0
- package/{src/med_editor/framework/selection-overlays.ts → lib/framework/selection-overlays.js} +16 -25
- package/lib/framework/selection-overlays.js.map +1 -0
- package/lib/texteditor.d.ts +318 -0
- package/{src/med_editor/texteditor.ts → lib/texteditor.js} +189 -286
- package/lib/texteditor.js.map +1 -0
- package/lib/util/subject.d.ts +34 -0
- package/lib/util/subject.js +88 -0
- package/lib/util/subject.js.map +1 -0
- package/lib/util/table-bind.d.ts +5 -0
- package/{src/med_editor/util/table-bind.ts → lib/util/table-bind.js} +2 -2
- package/lib/util/table-bind.js.map +1 -0
- package/package.json +2 -2
- package/src/med_editor/framework/common-util.ts +0 -200
- package/src/med_editor/framework/document-segmenter.ts +0 -211
- package/src/med_editor/framework/document-textline-mode.ts +0 -34
- package/src/med_editor/framework/element-event-define.ts +0 -141
- package/src/med_editor/framework/impl/document/doc-container-impl.ts +0 -24
- package/src/med_editor/util/subject.ts +0 -118
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225.json +0 -3573
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225.json +0 -3573
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225bug.json +0 -315
- 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 +0 -122
- 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 +0 -3599
- 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 +0 -24586
- package/src/med_editor//345/220/210/345/271/266/347/227/205/347/250/213/345/275/225.json +0 -2874
- package/src/med_editor//346/211/213/346/234/257/350/256/260/345/275/225.json +0 -341
- package/src/med_editor//346/231/256/351/200/232doc/347/261/273/346/226/207/346/241/243.json +0 -2201
- package/src/med_editor//346/243/200/351/252/214/347/224/263/350/257/267/345/215/225.json +0 -1069
- 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 +0 -125
- 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 +0 -86
- 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 +0 -115
- 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 +0 -108
- 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 +0 -272
- package/src/med_editor//351/225/277/346/234/237/345/214/273/345/230/261/345/215/225.json +0 -1070
@@ -1,17 +1,6 @@
|
|
1
|
-
import {
|
2
|
-
import { SelectionRange, SelectionState } from "./document-selection";
|
1
|
+
import { SelectionRange } from "./document-selection";
|
3
2
|
import { ElementUtil } from "./element-util";
|
4
|
-
import {
|
5
|
-
BlockContainerElement,
|
6
|
-
BlockContentElement,
|
7
|
-
BranchElement,
|
8
|
-
DocMode,
|
9
|
-
Element,
|
10
|
-
InlineGroupElement,
|
11
|
-
LeafElement,
|
12
|
-
SelectionContentRange,
|
13
|
-
ViewOptions
|
14
|
-
} from "./element-define";
|
3
|
+
import { BlockContainerElement, BlockContentElement, BranchElement, DocMode, InlineGroupElement, LeafElement } from "./element-define";
|
15
4
|
import { TextGroupElement } from "./impl/text/text-impl";
|
16
5
|
import { PSymbolElement } from "./impl/symbol/p-symbol-impl";
|
17
6
|
import { ParagraphElement } from "./impl/paragraph/p-impl";
|
@@ -19,19 +8,10 @@ import { RangeUtil } from "./range-util";
|
|
19
8
|
import { TableElement } from "./impl/table/table-impl";
|
20
9
|
import { DocumentEvent } from "./document-event";
|
21
10
|
import { KeyboradElementEvent } from "./element-event-define";
|
22
|
-
import { DataEleBaseProps, ParagraphProps, TextProps } from "./element-props";
|
23
11
|
import { ElementSerialize } from "./element-serialize";
|
24
|
-
import { ElementReader } from "./element-reader";
|
25
12
|
import { BreakElement } from "./impl/symbol/br-symbol-impl";
|
26
13
|
import { DataDecorateElement } from "./impl/data-element/data-decorate-impl";
|
27
|
-
import {
|
28
|
-
import {
|
29
|
-
DataElementInlineGroup,
|
30
|
-
InlineGroupInputElement,
|
31
|
-
IsInSideDataElement,
|
32
|
-
IsInSideInlineGroupInputElement
|
33
|
-
} from "./impl/data-element/data-element-base-impl";
|
34
|
-
import { DocumentComment } from "./document-comment";
|
14
|
+
import { DataElementInlineGroup, InlineGroupInputElement, IsInSideDataElement, IsInSideInlineGroupInputElement } from "./impl/data-element/data-element-base-impl";
|
35
15
|
import { CommentElement } from "./impl/comments/comment-element-impl";
|
36
16
|
import { nanoid } from "nanoid";
|
37
17
|
import { CommContentElement } from "./impl/comments/comment-content-impl";
|
@@ -39,29 +19,37 @@ import { ValidateElement } from "./impl/comments/validate-msg-impl";
|
|
39
19
|
import { CommonUtil } from "./common-util";
|
40
20
|
import { TrackRunElement, TrackRunTypeEnum } from "./impl/text/track-run-impl";
|
41
21
|
import { DocumentBodyElement } from "./impl/document/doc-body-impl";
|
42
|
-
|
43
22
|
/**
|
44
23
|
* 文档内容改变
|
45
24
|
*/
|
46
25
|
export class DocumentChange {
|
47
|
-
|
26
|
+
selectionState;
|
27
|
+
viewOptions;
|
28
|
+
eleReader;
|
29
|
+
docCtx;
|
30
|
+
docComment;
|
31
|
+
constructor(selectionState, viewOptions, eleReader, docCtx, docComment) {
|
32
|
+
this.selectionState = selectionState;
|
33
|
+
this.viewOptions = viewOptions;
|
34
|
+
this.eleReader = eleReader;
|
35
|
+
this.docCtx = docCtx;
|
36
|
+
this.docComment = docComment;
|
48
37
|
}
|
49
|
-
|
50
|
-
newInput(data: InputData): void {
|
38
|
+
newInput(data) {
|
51
39
|
const { startControl, startOffset, collapsed, enableTrackChanges } = this.selectionState;
|
52
40
|
if (!collapsed) {
|
53
41
|
this.onInputBySelection(data);
|
54
42
|
return;
|
55
43
|
}
|
56
44
|
//判断是否需要创建新的留痕区域
|
57
|
-
if (enableTrackChanges && !this.isInCorrectTrackRegion(startControl
|
58
|
-
this.newInputTrackChanges(data, startControl
|
45
|
+
if (enableTrackChanges && !this.isInCorrectTrackRegion(startControl, TrackRunTypeEnum.Inserted)) {
|
46
|
+
this.newInputTrackChanges(data, startControl, startOffset);
|
59
47
|
return;
|
60
48
|
}
|
61
49
|
//当前输入节点是在留痕区域中,但是当前关闭了审阅模式,需要拆分留痕区域,创建新输入节点
|
62
50
|
if (!enableTrackChanges && this.isInTrackBlock(startControl)) {
|
63
51
|
const newInput = this.splitTrackElement(startControl, startOffset);
|
64
|
-
const comp = data.compositionStartInfo
|
52
|
+
const comp = data.compositionStartInfo;
|
65
53
|
comp.element = newInput;
|
66
54
|
comp.offset = 0;
|
67
55
|
this.inputTextGroup(newInput, data);
|
@@ -75,7 +63,8 @@ export class DocumentChange {
|
|
75
63
|
if (siblingTextEle instanceof TextGroupElement) {
|
76
64
|
data.compositionStartInfo.offset = startOffset === 0 ? siblingTextEle.text.length : 0;
|
77
65
|
this.inputTextGroup(siblingTextEle, data);
|
78
|
-
}
|
66
|
+
}
|
67
|
+
else {
|
79
68
|
const inputTextProps = this.getDefaultTextProps(startControl, startOffset);
|
80
69
|
const newTextGroup = ElementUtil.getNewTextGroup(inputTextProps);
|
81
70
|
startControl.parent.addChild(newTextGroup, startControl.getIndex() + startOffset);
|
@@ -85,28 +74,24 @@ export class DocumentChange {
|
|
85
74
|
}
|
86
75
|
this.inputTextGroup(startControl, data);
|
87
76
|
}
|
88
|
-
|
89
|
-
|
90
77
|
/**
|
91
78
|
* 选中区域后进行输入
|
92
79
|
* 需要处理将选中的区域删除后,进行输入的情况
|
93
80
|
*/
|
94
|
-
onInputBySelection(data
|
81
|
+
onInputBySelection(data) {
|
95
82
|
this.onRangeDelete();
|
96
83
|
this.selectionState.afterSelectionChanged = (newVal) => {
|
97
84
|
const { startControl, startOffset, editable } = newVal;
|
98
85
|
if (!editable) {
|
99
86
|
return false;
|
100
87
|
}
|
101
|
-
const comp = data.compositionStartInfo
|
88
|
+
const comp = data.compositionStartInfo;
|
102
89
|
comp.element = startControl;
|
103
90
|
comp.offset = startOffset;
|
104
91
|
this.newInput(data);
|
105
92
|
return true;
|
106
93
|
};
|
107
|
-
|
108
94
|
}
|
109
|
-
|
110
95
|
/**
|
111
96
|
* 当前元素是否在正确的留痕区域(ins-run、del-run),情况分为以下情况
|
112
97
|
* 1.留痕块类型为新增,但是留痕块的创建者为其他用户,此时需要拆分留痕区域
|
@@ -115,24 +100,22 @@ export class DocumentChange {
|
|
115
100
|
* @param trackType
|
116
101
|
* @returns
|
117
102
|
*/
|
118
|
-
isInCorrectTrackRegion(startControl
|
103
|
+
isInCorrectTrackRegion(startControl, trackType) {
|
119
104
|
const parent = startControl.parent;
|
120
105
|
return parent instanceof TrackRunElement
|
121
106
|
&& parent.props.userId === this.viewOptions.editUser.id
|
122
107
|
&& parent.type === trackType
|
123
108
|
&& CommonUtil.getNowDiffSeconds(parent.props.date) <= this.viewOptions.trackChangePeriod;
|
124
109
|
}
|
125
|
-
|
126
110
|
/**
|
127
111
|
* 当前元素是否在留痕区域(ins-run、del-run)中
|
128
112
|
* @param target
|
129
113
|
* @param trackType
|
130
114
|
* @returns
|
131
115
|
*/
|
132
|
-
isInTrackBlock(target
|
116
|
+
isInTrackBlock(target, trackType = null) {
|
133
117
|
return target.parent instanceof TrackRunElement && (trackType === null || target.parent.type === trackType);
|
134
118
|
}
|
135
|
-
|
136
119
|
/**
|
137
120
|
* 留痕输入
|
138
121
|
* @param data
|
@@ -140,9 +123,9 @@ export class DocumentChange {
|
|
140
123
|
* @param startOffset
|
141
124
|
* @returns
|
142
125
|
*/
|
143
|
-
newInputTrackChanges(data
|
126
|
+
newInputTrackChanges(data, startControl, startOffset) {
|
144
127
|
const userId = this.viewOptions.editUser.id;
|
145
|
-
const compInfo = data.compositionStartInfo
|
128
|
+
const compInfo = data.compositionStartInfo;
|
146
129
|
if (this.isInCorrectTrackRegion(startControl, TrackRunTypeEnum.Inserted)) {
|
147
130
|
return;
|
148
131
|
}
|
@@ -152,20 +135,16 @@ export class DocumentChange {
|
|
152
135
|
compInfo.element = newInput;
|
153
136
|
this.inputTextGroup(newInput, data);
|
154
137
|
return;
|
155
|
-
}
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
} = this.createTextTrackElement(startControl, null, TrackRunTypeEnum.Inserted);
|
160
|
-
this.insertElement(startControl, startOffset, [trackElement])
|
138
|
+
}
|
139
|
+
else {
|
140
|
+
const { trackElement, newTextGroup } = this.createTextTrackElement(startControl, null, TrackRunTypeEnum.Inserted);
|
141
|
+
this.insertElement(startControl, startOffset, [trackElement]);
|
161
142
|
compInfo.offset = 0;
|
162
143
|
compInfo.element = newTextGroup;
|
163
144
|
this.inputTextGroup(newTextGroup, data);
|
164
145
|
return;
|
165
146
|
}
|
166
147
|
}
|
167
|
-
|
168
|
-
|
169
148
|
/**
|
170
149
|
* 创建新的留痕块,并返回留痕块输入定位文本
|
171
150
|
* @param startControl
|
@@ -173,11 +152,11 @@ export class DocumentChange {
|
|
173
152
|
* @param trackType
|
174
153
|
* @returns
|
175
154
|
*/
|
176
|
-
createNewTrackInput(startControl
|
155
|
+
createNewTrackInput(startControl, startOffset, trackType) {
|
177
156
|
const textProps = this.getDefaultTextProps(startControl, startOffset);
|
178
|
-
const currTrackEle = startControl.parent
|
157
|
+
const currTrackEle = startControl.parent;
|
179
158
|
if (startControl instanceof TextGroupElement && startOffset > 0 && startOffset < startControl.textMeasures.length) {
|
180
|
-
const splitText = startControl.spliceText(startOffset, startControl.textMeasures.length, true)
|
159
|
+
const splitText = startControl.spliceText(startOffset, startControl.textMeasures.length, true);
|
181
160
|
startControl.parent.addChild(splitText, startControl.getIndex() + 1);
|
182
161
|
startOffset = startControl.textMeasures.length;
|
183
162
|
}
|
@@ -185,75 +164,74 @@ export class DocumentChange {
|
|
185
164
|
const index = startControl.getIndex() + startOffset;
|
186
165
|
//切割留痕块
|
187
166
|
if (index > 0 && index < currTrackEle.length) {
|
188
|
-
const splitTrack = currTrackEle.split(startControl.getIndex() + startOffset)
|
167
|
+
const splitTrack = currTrackEle.split(startControl.getIndex() + startOffset);
|
189
168
|
currTrackEle.parent.addChild(splitTrack, currTrackEle.getIndex() + 1);
|
190
169
|
const { trackElement, newTextGroup } = this.createTextTrackElement(startControl, textProps, trackType);
|
191
170
|
currTrackEle.parent.addChild(trackElement, currTrackEle.getIndex() + 1);
|
192
171
|
return newTextGroup;
|
193
|
-
}
|
172
|
+
}
|
173
|
+
else {
|
194
174
|
const { trackElement, newTextGroup } = this.createTextTrackElement(startControl, textProps, trackType);
|
195
175
|
currTrackEle.parent.addChild(trackElement, currTrackEle.getIndex() + (index === 0 ? 0 : 1));
|
196
176
|
return newTextGroup;
|
197
177
|
}
|
198
178
|
}
|
199
|
-
|
200
179
|
/**
|
201
180
|
* 获取当前输入节点的文本属性
|
202
181
|
* @param startControl
|
203
182
|
* @returns
|
204
183
|
*/
|
205
|
-
getDefaultTextProps(startControl
|
206
|
-
const para = ElementUtil.getParentByType(startControl, ParagraphElement)
|
184
|
+
getDefaultTextProps(startControl, offset) {
|
185
|
+
const para = ElementUtil.getParentByType(startControl, ParagraphElement);
|
207
186
|
let textProps = para.props.textProps;
|
208
187
|
if (startControl instanceof TextGroupElement) {
|
209
188
|
textProps = startControl.props;
|
210
189
|
}
|
211
|
-
const dataEle = ElementUtil.getDataElement(startControl)
|
190
|
+
const dataEle = ElementUtil.getDataElement(startControl);
|
212
191
|
if (dataEle && IsInSideDataElement(startControl, offset)) {
|
213
192
|
return dataEle.props.valueTextProps;
|
214
193
|
}
|
215
194
|
return textProps;
|
216
195
|
}
|
217
|
-
|
218
196
|
/**
|
219
197
|
* 当前元素位于留痕区域内,但是当前编辑模式为非留痕模式,需要将当前留痕元素分割开来,插入新普通文本元素对象,并返回
|
220
198
|
* @param startControl
|
221
199
|
* @param startOffset
|
222
200
|
* @returns
|
223
201
|
*/
|
224
|
-
splitTrackElement(startControl
|
202
|
+
splitTrackElement(startControl, startOffset) {
|
225
203
|
if (!(startControl.parent instanceof TrackRunElement) && startControl instanceof TextGroupElement) {
|
226
204
|
return startControl;
|
227
205
|
}
|
228
206
|
const textProps = this.getDefaultTextProps(startControl, startOffset);
|
229
|
-
const currTrackEle = startControl.parent
|
207
|
+
const currTrackEle = startControl.parent;
|
230
208
|
if (startControl instanceof TextGroupElement && startOffset > 0 && startOffset < startControl.textMeasures.length) {
|
231
|
-
const splitText = startControl.spliceText(startOffset, startControl.textMeasures.length, true)
|
209
|
+
const splitText = startControl.spliceText(startOffset, startControl.textMeasures.length, true);
|
232
210
|
startControl.parent.addChild(splitText, startControl.getIndex() + 1);
|
233
211
|
startOffset = startControl.textMeasures.length;
|
234
212
|
}
|
235
213
|
startOffset = startOffset > 0 ? 1 : 0;
|
236
214
|
const index = startControl.getIndex() + startOffset;
|
237
215
|
if (index > 0 && index < currTrackEle.length) {
|
238
|
-
const splitTrack = currTrackEle.split(startControl.getIndex() + startOffset)
|
216
|
+
const splitTrack = currTrackEle.split(startControl.getIndex() + startOffset);
|
239
217
|
currTrackEle.parent.addChild(splitTrack, currTrackEle.getIndex() + 1);
|
240
218
|
const newInput = ElementUtil.getNewTextGroup(textProps);
|
241
219
|
currTrackEle.parent.addChild(newInput, currTrackEle.getIndex() + 1);
|
242
220
|
return this.splitTrackElement(newInput, 0);
|
243
|
-
}
|
221
|
+
}
|
222
|
+
else {
|
244
223
|
const newInput = ElementUtil.getNewTextGroup(textProps);
|
245
224
|
currTrackEle.parent.addChild(newInput, currTrackEle.getIndex() + (index === 0 ? 0 : 1));
|
246
225
|
return this.splitTrackElement(newInput, 0);
|
247
226
|
}
|
248
227
|
}
|
249
|
-
|
250
228
|
/**
|
251
229
|
* 创建插入(ins-run) 留痕,并且返回留痕的文本元素对象
|
252
230
|
* @param startControl
|
253
231
|
* @returns
|
254
232
|
*/
|
255
|
-
|
256
|
-
const para = ElementUtil.getParentByType(startControl, ParagraphElement)
|
233
|
+
createTextTrackElement(startControl, textProps, trackType) {
|
234
|
+
const para = ElementUtil.getParentByType(startControl, ParagraphElement);
|
257
235
|
const trackElement = this.createTrackElement(trackType);
|
258
236
|
textProps = textProps || para.props.textProps;
|
259
237
|
const newTextGroup = ElementUtil.getNewTextGroup(textProps);
|
@@ -262,11 +240,9 @@ export class DocumentChange {
|
|
262
240
|
return {
|
263
241
|
trackElement,
|
264
242
|
newTextGroup
|
265
|
-
}
|
266
|
-
|
243
|
+
};
|
267
244
|
}
|
268
|
-
|
269
|
-
private createTrackElement(trackType: TrackRunTypeEnum): TrackRunElement {
|
245
|
+
createTrackElement(trackType) {
|
270
246
|
const trackElement = new TrackRunElement(trackType);
|
271
247
|
trackElement.props.userId = this.viewOptions.editUser.id;
|
272
248
|
trackElement.props.userName = this.viewOptions.editUser.name;
|
@@ -274,14 +250,12 @@ export class DocumentChange {
|
|
274
250
|
trackElement.props.id = nanoid(5);
|
275
251
|
return trackElement;
|
276
252
|
}
|
277
|
-
|
278
|
-
private inputTextGroup(text: TextGroupElement, data: InputData): void {
|
253
|
+
inputTextGroup(text, data) {
|
279
254
|
const prevInputData = data.prevInputData || '';
|
280
255
|
const prevInputDataLength = prevInputData.length;
|
281
256
|
if (!data.compositionStartInfo) {
|
282
|
-
throw new Error('compositionStartInfo is null')
|
257
|
+
throw new Error('compositionStartInfo is null');
|
283
258
|
}
|
284
|
-
|
285
259
|
const { element, offset } = data.compositionStartInfo;
|
286
260
|
let startInputOffset = offset;
|
287
261
|
//startInputOffset -= prevInputDataLength;
|
@@ -289,7 +263,8 @@ export class DocumentChange {
|
|
289
263
|
//当前选中元素位于输入元素是起始还是结束位置,如果位于起始位置,则输入偏移量为0,否则为未变更之前的内容length
|
290
264
|
if (ElementUtil.getNextSiblingElement(element) === text) {
|
291
265
|
startInputOffset = 0;
|
292
|
-
}
|
266
|
+
}
|
267
|
+
else {
|
293
268
|
startInputOffset = text.textMeasures.length - prevInputDataLength;
|
294
269
|
}
|
295
270
|
}
|
@@ -297,19 +272,18 @@ export class DocumentChange {
|
|
297
272
|
//输入后撤销,导致文本组内为空
|
298
273
|
if (!text.text.length) {
|
299
274
|
this.removeEmptyText(text);
|
300
|
-
}
|
275
|
+
}
|
276
|
+
else {
|
301
277
|
this.selectionState.resetRange(text, startInputOffset + data.data.length);
|
302
278
|
}
|
303
279
|
}
|
304
|
-
|
305
|
-
|
306
280
|
/**
|
307
281
|
* backspace,向前删除
|
308
282
|
*/
|
309
|
-
onBackspace(evt
|
283
|
+
onBackspace(evt) {
|
310
284
|
const { startControl, startOffset, collapsed } = this.selectionState;
|
311
285
|
if (!startControl) {
|
312
|
-
throw new Error('startControl is null')
|
286
|
+
throw new Error('startControl is null');
|
313
287
|
}
|
314
288
|
const eventElement = new KeyboradElementEvent(this.docCtx);
|
315
289
|
eventElement.key = 'backspace';
|
@@ -323,16 +297,16 @@ export class DocumentChange {
|
|
323
297
|
this.docComment.updateComments();
|
324
298
|
if (collapsed) {
|
325
299
|
this.onBackspaceElement(startControl, startOffset);
|
326
|
-
}
|
300
|
+
}
|
301
|
+
else {
|
327
302
|
this.onRangeDelete();
|
328
303
|
}
|
329
304
|
}
|
330
|
-
|
331
305
|
/**
|
332
306
|
* delete,向后删除
|
333
307
|
* @param evt
|
334
308
|
*/
|
335
|
-
onDeleteKeyHandler(evt
|
309
|
+
onDeleteKeyHandler(evt) {
|
336
310
|
const { startControl, startOffset, collapsed } = this.selectionState;
|
337
311
|
const eventElement = new KeyboradElementEvent(this.docCtx);
|
338
312
|
eventElement.key = 'delete';
|
@@ -345,21 +319,21 @@ export class DocumentChange {
|
|
345
319
|
}
|
346
320
|
if (collapsed) {
|
347
321
|
this.onKeyDeleteElement(startControl, startOffset);
|
348
|
-
}
|
322
|
+
}
|
323
|
+
else {
|
349
324
|
this.onRangeDelete();
|
350
325
|
}
|
351
326
|
}
|
352
|
-
|
353
327
|
/**
|
354
328
|
* 根据选择范围删除
|
355
329
|
*/
|
356
|
-
|
330
|
+
onRangeDelete() {
|
357
331
|
const { selectedRange } = this.selectionState;
|
358
332
|
if (!selectedRange) {
|
359
|
-
throw new Error('selectionRange is null')
|
333
|
+
throw new Error('selectionRange is null');
|
360
334
|
}
|
361
335
|
//用于刷新后定位光标
|
362
|
-
let startPointElement
|
336
|
+
let startPointElement;
|
363
337
|
let startPointOffset = 0;
|
364
338
|
if (selectedRange.isFullSelected) {
|
365
339
|
//某个容器的内容被全部选中
|
@@ -369,21 +343,24 @@ export class DocumentChange {
|
|
369
343
|
}
|
370
344
|
//内容块被选中,需要向上寻找内容块容器
|
371
345
|
else if (selectedRange.target instanceof BlockContentElement) {
|
372
|
-
const parentContainer = ElementUtil.getParent(selectedRange.target, (item) => item instanceof BlockContainerElement)
|
346
|
+
const parentContainer = ElementUtil.getParent(selectedRange.target, (item) => item instanceof BlockContainerElement);
|
373
347
|
if (parentContainer) {
|
374
348
|
startPointElement = parentContainer;
|
375
349
|
startPointOffset = 0;
|
376
|
-
} else {
|
377
|
-
throw new Error('未能向上寻找到定位的内容块容器')
|
378
350
|
}
|
379
|
-
|
380
|
-
|
351
|
+
else {
|
352
|
+
throw new Error('未能向上寻找到定位的内容块容器');
|
353
|
+
}
|
354
|
+
}
|
355
|
+
else {
|
356
|
+
throw new Error('未知条件区间');
|
381
357
|
}
|
382
|
-
}
|
383
|
-
|
384
|
-
const
|
358
|
+
}
|
359
|
+
else {
|
360
|
+
const startRange = RangeUtil.getStartRangeTarget(selectedRange);
|
361
|
+
const endRange = RangeUtil.getEndRangeTarget(selectedRange);
|
385
362
|
if (startRange.isFullSelected) {
|
386
|
-
startPointElement = ElementUtil.getRecursionPrevSiblingElement(startRange.target, false, true)
|
363
|
+
startPointElement = ElementUtil.getRecursionPrevSiblingElement(startRange.target, false, true);
|
387
364
|
startPointOffset = -1;
|
388
365
|
//判断结束选区和开始选区是否在一个段落中,尽量落在同一段落中
|
389
366
|
if (!startPointElement || ElementUtil.isInSameParagraph(startRange.target, endRange.target)) {
|
@@ -392,27 +369,28 @@ export class DocumentChange {
|
|
392
369
|
startPointOffset = 0;
|
393
370
|
}
|
394
371
|
}
|
395
|
-
}
|
396
|
-
|
372
|
+
}
|
373
|
+
else {
|
374
|
+
startPointElement = startRange.target;
|
397
375
|
startPointOffset = startRange.startOffset;
|
398
376
|
}
|
399
377
|
}
|
400
378
|
if (this.viewOptions.docMode === DocMode.FormEdit) {
|
401
|
-
this.deleteRangeInFormEdit(selectedRange)
|
402
|
-
}
|
379
|
+
this.deleteRangeInFormEdit(selectedRange);
|
380
|
+
}
|
381
|
+
else {
|
403
382
|
this.deleteRange(selectedRange);
|
404
383
|
}
|
405
384
|
this.selectionState.resetRange(startPointElement, startPointOffset);
|
406
385
|
return { cursorEle: startPointElement, cursorOffset: startPointOffset };
|
407
386
|
}
|
408
|
-
|
409
387
|
/**
|
410
388
|
* backspace删除
|
411
389
|
* @param control
|
412
390
|
* @param offset
|
413
391
|
* @returns
|
414
392
|
*/
|
415
|
-
|
393
|
+
onBackspaceElement(control, offset) {
|
416
394
|
this.selectionState.clear();
|
417
395
|
if (offset === 0) {
|
418
396
|
const prevEle = ElementUtil.getRecursionPrevSiblingElement(control, false, true);
|
@@ -423,13 +401,15 @@ export class DocumentChange {
|
|
423
401
|
if (ElementUtil.isInSameParagraph(control, prevEle)) {
|
424
402
|
if (ElementUtil.getPrevSiblingElement(control) === prevEle) {
|
425
403
|
this.onBackspaceElement(prevEle, ElementUtil.getElementEndOffset(prevEle));
|
426
|
-
}
|
404
|
+
}
|
405
|
+
else {
|
427
406
|
this.selectionState.resetRange(prevEle, -1);
|
428
407
|
}
|
429
|
-
}
|
408
|
+
}
|
409
|
+
else {
|
430
410
|
//需要判断是否是兄弟段落,兄弟段落,需要合并
|
431
|
-
const prevPara = ElementUtil.getParentByType(prevEle, ParagraphElement)
|
432
|
-
const currPara = ElementUtil.getParentByType(control, ParagraphElement)
|
411
|
+
const prevPara = ElementUtil.getParentByType(prevEle, ParagraphElement);
|
412
|
+
const currPara = ElementUtil.getParentByType(control, ParagraphElement);
|
433
413
|
//表明是紧挨着的两个段落,要进行段落合并
|
434
414
|
if (ElementUtil.getPrevSiblingElement(currPara) === prevPara) {
|
435
415
|
if (this.selectionState.enableTrackChanges) {
|
@@ -437,21 +417,25 @@ export class DocumentChange {
|
|
437
417
|
return;
|
438
418
|
}
|
439
419
|
this.combineParagraph(prevPara, currPara, control);
|
440
|
-
}
|
420
|
+
}
|
421
|
+
else {
|
441
422
|
//不是紧挨着的段落,则前一个段落是位于另一个容器里,例如:处于单元格内的段落
|
442
423
|
//则不向前定位
|
443
|
-
this.selectionState.resetRange(control, offset)
|
424
|
+
this.selectionState.resetRange(control, offset);
|
444
425
|
}
|
445
426
|
}
|
446
|
-
}
|
427
|
+
}
|
428
|
+
else {
|
447
429
|
if (control instanceof TextGroupElement) {
|
448
430
|
this.onDeleteText(control, offset - 1, 1);
|
449
431
|
if (!control.textMeasures.length) {
|
450
432
|
this.removeEmptyText(control);
|
451
|
-
}
|
433
|
+
}
|
434
|
+
else {
|
452
435
|
this.selectionState.resetRange(control, offset - 1);
|
453
436
|
}
|
454
|
-
}
|
437
|
+
}
|
438
|
+
else {
|
455
439
|
if (control.parent instanceof InlineGroupInputElement && control instanceof DataDecorateElement) {
|
456
440
|
const dataEle = control.parent;
|
457
441
|
//空数据元,并且当前光标处于数据元开始位置
|
@@ -474,16 +458,15 @@ export class DocumentChange {
|
|
474
458
|
}
|
475
459
|
}
|
476
460
|
}
|
477
|
-
|
478
461
|
/**
|
479
462
|
* 跳到上一个数据元中
|
480
463
|
* @param currEle
|
481
464
|
*/
|
482
|
-
|
465
|
+
jumpToPrevDataElement(currEle) {
|
483
466
|
if (this.viewOptions.docMode !== DocMode.FormEdit) {
|
484
467
|
return false;
|
485
468
|
}
|
486
|
-
const prevEle = ElementUtil.getPrevDataElement(this.docCtx, currEle
|
469
|
+
const prevEle = ElementUtil.getPrevDataElement(this.docCtx, currEle);
|
487
470
|
if (!prevEle) {
|
488
471
|
return false;
|
489
472
|
}
|
@@ -493,14 +476,13 @@ export class DocumentChange {
|
|
493
476
|
}
|
494
477
|
return false;
|
495
478
|
}
|
496
|
-
|
497
479
|
/**
|
498
480
|
* delete删除
|
499
481
|
* @param control
|
500
482
|
* @param offset
|
501
483
|
* @returns
|
502
484
|
*/
|
503
|
-
|
485
|
+
onKeyDeleteElement(control, offset) {
|
504
486
|
this.selectionState.clear();
|
505
487
|
if (offset === ElementUtil.getElementEndOffset(control)) {
|
506
488
|
const nextEle = ElementUtil.getRecursionNextSiblingElement(control, false, true);
|
@@ -511,13 +493,15 @@ export class DocumentChange {
|
|
511
493
|
if (ElementUtil.isInSameParagraph(control, nextEle)) {
|
512
494
|
if (ElementUtil.getNextSiblingElement(control) === nextEle) {
|
513
495
|
this.onKeyDeleteElement(nextEle, 0);
|
514
|
-
}
|
496
|
+
}
|
497
|
+
else {
|
515
498
|
this.selectionState.resetRange(nextEle, 0);
|
516
499
|
}
|
517
|
-
}
|
500
|
+
}
|
501
|
+
else {
|
518
502
|
//需要判断是否是兄弟段落,兄弟段落,需要合并
|
519
|
-
const nextPara = ElementUtil.getParentByType(nextEle, ParagraphElement)
|
520
|
-
const currPara = ElementUtil.getParentByType(control, ParagraphElement)
|
503
|
+
const nextPara = ElementUtil.getParentByType(nextEle, ParagraphElement);
|
504
|
+
const currPara = ElementUtil.getParentByType(control, ParagraphElement);
|
521
505
|
//表明是紧挨着的两个段落,要进行段落合并
|
522
506
|
if (ElementUtil.getNextSiblingElement(currPara) === nextPara) {
|
523
507
|
if (this.selectionState.enableTrackChanges) {
|
@@ -525,33 +509,39 @@ export class DocumentChange {
|
|
525
509
|
return;
|
526
510
|
}
|
527
511
|
this.combineParagraph(nextPara, currPara, control);
|
528
|
-
}
|
512
|
+
}
|
513
|
+
else {
|
529
514
|
//不是紧挨着的段落,则前一个段落是位于另一个容器里,例如:处于单元格内的段落
|
530
515
|
//则不向前定位
|
531
|
-
this.selectionState.resetRange(control, offset)
|
516
|
+
this.selectionState.resetRange(control, offset);
|
532
517
|
}
|
533
518
|
}
|
534
|
-
}
|
519
|
+
}
|
520
|
+
else {
|
535
521
|
if (control instanceof TextGroupElement) {
|
536
522
|
this.onDeleteText(control, offset, 1);
|
537
523
|
if (!control.textMeasures.length) {
|
538
524
|
this.removeEmptyText(control);
|
539
|
-
}
|
525
|
+
}
|
526
|
+
else {
|
540
527
|
this.selectionState.resetRange(control, offset);
|
541
528
|
}
|
542
|
-
}
|
529
|
+
}
|
530
|
+
else {
|
543
531
|
if (control.parent instanceof DataElementInlineGroup && control instanceof DataDecorateElement) {
|
544
|
-
const dataEle = control.parent
|
532
|
+
const dataEle = control.parent;
|
545
533
|
//空数据元,并且当前光标处于数据元开始位置
|
546
534
|
if (control.isPrefix) {
|
547
535
|
if (this.canDeleteInlineGroup(dataEle)) {
|
548
536
|
this.setCurosrForDeleteAction(dataEle);
|
549
537
|
dataEle.remove();
|
550
|
-
}
|
538
|
+
}
|
539
|
+
else {
|
551
540
|
this.selectionState.resetRange(control, -1);
|
552
541
|
}
|
553
542
|
return;
|
554
|
-
}
|
543
|
+
}
|
544
|
+
else if (!control.isPrefix && dataEle.length === 2) {
|
555
545
|
this.selectionState.resetRange(dataEle.endDecorate, -1);
|
556
546
|
return;
|
557
547
|
}
|
@@ -564,67 +554,61 @@ export class DocumentChange {
|
|
564
554
|
}
|
565
555
|
}
|
566
556
|
}
|
567
|
-
|
568
557
|
/**
|
569
558
|
* 判断是否可以删除数据组
|
570
559
|
* @param dataEle
|
571
560
|
* @private
|
572
561
|
*/
|
573
|
-
|
562
|
+
canDeleteInlineGroup(dataEle) {
|
574
563
|
if (this.viewOptions.docMode === DocMode.FormEdit) {
|
575
564
|
return false;
|
576
565
|
}
|
577
566
|
return dataEle.length === 2;
|
578
567
|
}
|
579
|
-
|
580
|
-
private onDeleteText(text: TextGroupElement, offset: number, len: number): void {
|
568
|
+
onDeleteText(text, offset, len) {
|
581
569
|
if (this.selectionState.enableTrackChanges) {
|
582
|
-
this.updateDeletedTrackText(text, offset, len)
|
583
|
-
}
|
584
|
-
|
570
|
+
this.updateDeletedTrackText(text, offset, len);
|
571
|
+
}
|
572
|
+
else {
|
573
|
+
text.splice(offset, len);
|
585
574
|
}
|
586
575
|
}
|
587
|
-
|
588
|
-
private onDeleteItem(item: LeafElement): void {
|
576
|
+
onDeleteItem(item) {
|
589
577
|
if (this.selectionState.enableTrackChanges) {
|
590
578
|
//删除符号不进行留痕
|
591
579
|
if (item.type === 'psym') {
|
592
|
-
return
|
580
|
+
return;
|
593
581
|
}
|
594
582
|
this.onTrackDeleteElement(item);
|
595
|
-
}
|
583
|
+
}
|
584
|
+
else {
|
596
585
|
item.remove();
|
597
586
|
item.destroy();
|
598
587
|
}
|
599
588
|
}
|
600
|
-
|
601
|
-
|
602
589
|
/**
|
603
590
|
* 当前元素是否在留痕元素内
|
604
591
|
* @param target
|
605
592
|
* @param trackType
|
606
593
|
* @returns
|
607
594
|
*/
|
608
|
-
|
595
|
+
isInCurrentUserTrack(target, trackType) {
|
609
596
|
if (target.parent instanceof TrackRunElement && target.parent.type === trackType && target.parent.props.userId === this.viewOptions.editUser.id) {
|
610
597
|
return true;
|
611
598
|
}
|
612
599
|
return false;
|
613
600
|
}
|
614
|
-
|
615
|
-
private isInTrackElement(target: Element, trackType: TrackRunTypeEnum): boolean {
|
601
|
+
isInTrackElement(target, trackType) {
|
616
602
|
if (target.parent instanceof TrackRunElement && target.parent.type === trackType) {
|
617
603
|
return true;
|
618
604
|
}
|
619
605
|
return false;
|
620
606
|
}
|
621
|
-
|
622
|
-
|
623
607
|
/**
|
624
608
|
* 留痕除文本以外的其他元素
|
625
609
|
* @param control
|
626
610
|
*/
|
627
|
-
|
611
|
+
onTrackDeleteElement(target) {
|
628
612
|
const parent = target.parent;
|
629
613
|
if (this.isInTrackElement(target, TrackRunTypeEnum.Deleted)) {
|
630
614
|
return;
|
@@ -641,11 +625,10 @@ export class DocumentChange {
|
|
641
625
|
target.remove();
|
642
626
|
this.removeEmtpyInlineBlock(parent);
|
643
627
|
}
|
644
|
-
|
645
628
|
/**
|
646
629
|
* 更新文本删除留痕
|
647
630
|
*/
|
648
|
-
|
631
|
+
updateDeletedTrackText(target, offset, len) {
|
649
632
|
if (this.isInTrackElement(target, TrackRunTypeEnum.Deleted)) {
|
650
633
|
return;
|
651
634
|
}
|
@@ -663,52 +646,45 @@ export class DocumentChange {
|
|
663
646
|
return;
|
664
647
|
}
|
665
648
|
const { leftElement } = this.splitText(target, offset + len);
|
666
|
-
target = leftElement
|
667
|
-
let trackText
|
649
|
+
target = leftElement;
|
650
|
+
let trackText = this.getNextTrackInputElement(target, TrackRunTypeEnum.Deleted);
|
668
651
|
const spText = target.spliceText(target.textMeasures.length - len, target.textMeasures.length, true);
|
669
652
|
trackText.splice(0, 0, spText?.text);
|
670
653
|
}
|
671
|
-
|
672
|
-
|
673
|
-
private getNextTrackInputElement(target: Element, trackType: TrackRunTypeEnum): TextGroupElement {
|
674
|
-
const trackElement = ElementUtil.getNextSiblingTrackElement(target, trackType, this.viewOptions.editUser.id)
|
654
|
+
getNextTrackInputElement(target, trackType) {
|
655
|
+
const trackElement = ElementUtil.getNextSiblingTrackElement(target, trackType, this.viewOptions.editUser.id);
|
675
656
|
if (trackElement) {
|
676
657
|
const firstEle = trackElement.getChild(0);
|
677
658
|
if (firstEle && firstEle instanceof TextGroupElement) {
|
678
659
|
return firstEle;
|
679
|
-
}
|
660
|
+
}
|
661
|
+
else {
|
680
662
|
const newInput = new TextGroupElement();
|
681
663
|
trackElement.addChild(newInput, 0);
|
682
664
|
target.props.clone(newInput.props);
|
683
665
|
return newInput;
|
684
666
|
}
|
685
|
-
}
|
686
|
-
|
687
|
-
|
688
|
-
newTextGroup
|
689
|
-
} = this.createTextTrackElement(target, target.props, TrackRunTypeEnum.Deleted);
|
667
|
+
}
|
668
|
+
else {
|
669
|
+
const { trackElement, newTextGroup } = this.createTextTrackElement(target, target.props, TrackRunTypeEnum.Deleted);
|
690
670
|
target.parent.addChild(trackElement, target.getIndex() + 1);
|
691
671
|
return newTextGroup;
|
692
672
|
}
|
693
673
|
}
|
694
|
-
|
695
|
-
|
696
|
-
private getNextTrackElement(target: Element, trackType: TrackRunTypeEnum): TrackRunElement {
|
697
|
-
let trackElement = ElementUtil.getNextSiblingTrackElement(target, trackType, this.viewOptions.editUser.id)
|
674
|
+
getNextTrackElement(target, trackType) {
|
675
|
+
let trackElement = ElementUtil.getNextSiblingTrackElement(target, trackType, this.viewOptions.editUser.id);
|
698
676
|
if (!trackElement) {
|
699
677
|
trackElement = this.createTrackElement(trackType);
|
700
678
|
target.parent.addChild(trackElement, target.getIndex() + 1);
|
701
679
|
}
|
702
680
|
return trackElement;
|
703
681
|
}
|
704
|
-
|
705
|
-
|
706
682
|
/**
|
707
683
|
* 删除元素并定位光标
|
708
684
|
* @param control
|
709
685
|
* @returns
|
710
686
|
*/
|
711
|
-
|
687
|
+
removeElement(control) {
|
712
688
|
const prevEle = ElementUtil.getRecursionPrevSiblingElement(control, false, true);
|
713
689
|
if (!prevEle) {
|
714
690
|
const nextEle = ElementUtil.getRecursionNextSiblingElement(control, true, true);
|
@@ -723,27 +699,27 @@ export class DocumentChange {
|
|
723
699
|
this.selectionState.resetRange(prevEle, -1);
|
724
700
|
control.remove();
|
725
701
|
return;
|
726
|
-
}
|
702
|
+
}
|
703
|
+
else {
|
727
704
|
const nextEle = ElementUtil.getRecursionNextSiblingElement(control, true, true);
|
728
705
|
if (nextEle && ElementUtil.getPrevSiblingElement(nextEle) === control) {
|
729
706
|
this.selectionState.resetRange(nextEle, 0);
|
730
707
|
control.remove();
|
731
708
|
return;
|
732
|
-
}
|
709
|
+
}
|
710
|
+
else {
|
733
711
|
this.selectionState.resetRange(prevEle, -1);
|
734
712
|
control.remove();
|
735
713
|
return;
|
736
714
|
}
|
737
715
|
}
|
738
716
|
}
|
739
|
-
|
740
|
-
|
741
717
|
/**
|
742
718
|
* 回车事件
|
743
719
|
*/
|
744
|
-
onEnter()
|
720
|
+
onEnter() {
|
745
721
|
const { startControl } = this.selectionState;
|
746
|
-
const paragraph = ElementUtil.getParentByType(startControl, ParagraphElement)
|
722
|
+
const paragraph = ElementUtil.getParentByType(startControl, ParagraphElement);
|
747
723
|
const breakPara = this.splitCurrentParagraph();
|
748
724
|
//选中的是一个元素
|
749
725
|
if (breakPara === paragraph) {
|
@@ -751,27 +727,24 @@ export class DocumentChange {
|
|
751
727
|
breakPara.parent.addChild(clonePara, breakPara.getIndex());
|
752
728
|
}
|
753
729
|
this.selectionState.resetRange(breakPara, 0);
|
754
|
-
|
755
730
|
}
|
756
|
-
|
757
731
|
/**
|
758
732
|
* 插入表格
|
759
733
|
* @param tb
|
760
734
|
* @returns
|
761
735
|
*/
|
762
|
-
insertTable(tb
|
736
|
+
insertTable(tb) {
|
763
737
|
const breakPara = this.splitCurrentParagraph();
|
764
738
|
breakPara.parent.addChild(tb, breakPara.getIndex());
|
765
739
|
this.selectionState.resetRange(tb, 0);
|
766
740
|
}
|
767
|
-
|
768
741
|
/**
|
769
742
|
* 分割当前段落用于插入表格或者粘贴的内容
|
770
743
|
* @param insertItems 分割后插入的内容,内容需要是block或者表格对象
|
771
744
|
*/
|
772
|
-
|
745
|
+
splitCurrentParagraph() {
|
773
746
|
const { startControl, startOffset } = this.selectionState;
|
774
|
-
const paragraph = ElementUtil.getParentByType(startControl, ParagraphElement)
|
747
|
+
const paragraph = ElementUtil.getParentByType(startControl, ParagraphElement);
|
775
748
|
const paraContainer = paragraph.parent;
|
776
749
|
//如果选中的是段落第一个元素
|
777
750
|
const firstLeaf = ElementUtil.getFirstLeafElement(paragraph);
|
@@ -779,10 +752,10 @@ export class DocumentChange {
|
|
779
752
|
//this.selectionState.resetRange(paragraph, 0);
|
780
753
|
return paragraph;
|
781
754
|
}
|
782
|
-
const last = ElementUtil.getLastLeafElement(paragraph)
|
755
|
+
const last = ElementUtil.getLastLeafElement(paragraph);
|
783
756
|
const selectedParaRange = RangeUtil.getSelctionRange(startControl, startOffset, last, 1, paragraph);
|
784
757
|
selectedParaRange.isFullSelected = false;
|
785
|
-
const breakPara = ElementUtil.cloneRange(selectedParaRange, true)
|
758
|
+
const breakPara = ElementUtil.cloneRange(selectedParaRange, true);
|
786
759
|
ElementUtil.fixParagraphContent(paragraph);
|
787
760
|
ElementUtil.fixParagraphContent(breakPara);
|
788
761
|
paraContainer.addChild(breakPara, paragraph.getIndex() + 1);
|
@@ -790,11 +763,10 @@ export class DocumentChange {
|
|
790
763
|
//this.selectionState.resetRange(breakPara, 0);
|
791
764
|
return breakPara;
|
792
765
|
}
|
793
|
-
|
794
766
|
/**
|
795
767
|
* 合并段落
|
796
768
|
*/
|
797
|
-
combineParagraph(prevPara
|
769
|
+
combineParagraph(prevPara, currPara, currElement) {
|
798
770
|
const prevParaLength = prevPara.length;
|
799
771
|
for (let i = 0; i < currPara.length; i++) {
|
800
772
|
const child = currPara.getChild(i).clone(true);
|
@@ -806,12 +778,11 @@ export class DocumentChange {
|
|
806
778
|
currParaContainer.removeChild(currPara);
|
807
779
|
this.selectionState.resetRange(prevPara.getChild(prevParaLength), 0);
|
808
780
|
}
|
809
|
-
|
810
781
|
/**
|
811
782
|
* 删除选中的区域内容
|
812
783
|
* @param range
|
813
784
|
*/
|
814
|
-
deleteRange(range
|
785
|
+
deleteRange(range) {
|
815
786
|
const { selectedChildren } = range;
|
816
787
|
for (let i = selectedChildren.length - 1; i >= 0; i--) {
|
817
788
|
const childRange = selectedChildren[i];
|
@@ -819,15 +790,18 @@ export class DocumentChange {
|
|
819
790
|
if (childTarget instanceof LeafElement && !childTarget.isDecorate) {
|
820
791
|
if (childFullSelected) {
|
821
792
|
this.onDeleteItem(childTarget);
|
822
|
-
}
|
793
|
+
}
|
794
|
+
else if (childTarget instanceof TextGroupElement) {
|
823
795
|
const { startOffset, endOffset } = childRange;
|
824
796
|
this.onDeleteText(childTarget, startOffset, endOffset - startOffset);
|
825
797
|
}
|
826
|
-
}
|
798
|
+
}
|
799
|
+
else if (childTarget instanceof BranchElement) {
|
827
800
|
//留痕模式
|
828
801
|
if (this.selectionState.enableTrackChanges) {
|
829
802
|
this.deleteRange(childRange);
|
830
|
-
}
|
803
|
+
}
|
804
|
+
else {
|
831
805
|
//表格全选状态时,执行删除操作
|
832
806
|
if (childTarget instanceof TableElement && childFullSelected) {
|
833
807
|
childTarget.remove();
|
@@ -837,24 +811,24 @@ export class DocumentChange {
|
|
837
811
|
else if (childTarget instanceof BlockContentElement && childFullSelected) {
|
838
812
|
childTarget.remove();
|
839
813
|
childTarget.destroy();
|
840
|
-
}
|
814
|
+
}
|
815
|
+
else if (childTarget instanceof InlineGroupElement && childFullSelected) {
|
841
816
|
childTarget.remove();
|
842
817
|
childTarget.destroy();
|
843
|
-
}
|
818
|
+
}
|
819
|
+
else {
|
844
820
|
this.deleteRange(childRange);
|
845
821
|
}
|
846
822
|
}
|
847
823
|
}
|
848
824
|
}
|
849
825
|
}
|
850
|
-
|
851
|
-
|
852
826
|
/**
|
853
827
|
* 表单区域删除处理
|
854
828
|
* @param range
|
855
829
|
* @returns
|
856
830
|
*/
|
857
|
-
|
831
|
+
deleteRangeInFormEdit(range) {
|
858
832
|
const dataElement = ElementUtil.getDataElement(range.target);
|
859
833
|
//在数据元内删除,调用普通的删除处理
|
860
834
|
if (dataElement) {
|
@@ -866,58 +840,57 @@ export class DocumentChange {
|
|
866
840
|
this.loopForDelDataEleRange(range);
|
867
841
|
}
|
868
842
|
}
|
869
|
-
|
870
843
|
/**
|
871
844
|
* 表单模式:删除选中的区域内容
|
872
845
|
*/
|
873
|
-
|
846
|
+
loopForDelDataEleRange(range) {
|
874
847
|
const { selectedChildren } = range;
|
875
848
|
for (let i = selectedChildren.length - 1; i >= 0; i--) {
|
876
849
|
const childRange = selectedChildren[i];
|
877
850
|
const { target: childTarget } = childRange;
|
878
851
|
if (childTarget instanceof BranchElement) {
|
879
852
|
if (childTarget instanceof DataElementInlineGroup) {
|
880
|
-
const dataEleProps = childTarget.props
|
853
|
+
const dataEleProps = childTarget.props;
|
881
854
|
//数据元可编辑
|
882
855
|
if (dataEleProps.editable) {
|
883
856
|
this.deleteRange(childRange);
|
884
857
|
}
|
885
|
-
}
|
886
|
-
|
858
|
+
}
|
859
|
+
else {
|
860
|
+
this.loopForDelDataEleRange(childRange);
|
887
861
|
}
|
888
862
|
}
|
889
863
|
}
|
890
864
|
}
|
891
|
-
|
892
|
-
|
893
865
|
/**
|
894
866
|
* 向目标移动元素
|
895
867
|
* @param sourceElement
|
896
868
|
* @param moveElement
|
897
869
|
*/
|
898
|
-
moveElement(targetElement
|
870
|
+
moveElement(targetElement, targetOffset, moveElement, moveOffset, ss) {
|
899
871
|
moveElement.remove();
|
900
872
|
if (targetElement instanceof TextGroupElement) {
|
901
873
|
const { leftElement, rightElement } = this.splitText(targetElement, targetOffset);
|
902
874
|
if (leftElement) {
|
903
|
-
leftElement.parent.addChild(moveElement, leftElement.getIndex() + 1)
|
904
|
-
}
|
905
|
-
|
875
|
+
leftElement.parent.addChild(moveElement, leftElement.getIndex() + 1);
|
876
|
+
}
|
877
|
+
else if (rightElement) {
|
878
|
+
rightElement.parent.addChild(moveElement, rightElement.getIndex());
|
906
879
|
}
|
907
|
-
}
|
880
|
+
}
|
881
|
+
else {
|
908
882
|
targetElement.parent.addChild(moveElement, targetElement.getIndex() + targetOffset);
|
909
883
|
}
|
910
884
|
ss.resetRange(moveElement, moveOffset);
|
911
885
|
}
|
912
|
-
|
913
886
|
/**
|
914
887
|
* 向指定的目标插入元素
|
915
888
|
* @param targetElement
|
916
889
|
* @param targetOffset
|
917
890
|
* @param destEleArray
|
918
891
|
*/
|
919
|
-
insertElement(targetElement
|
920
|
-
let lastEle
|
892
|
+
insertElement(targetElement, targetOffset, destEleArray) {
|
893
|
+
let lastEle;
|
921
894
|
if (targetElement instanceof TextGroupElement) {
|
922
895
|
const { leftElement, rightElement } = this.splitText(targetElement, targetOffset);
|
923
896
|
if (leftElement) {
|
@@ -925,22 +898,22 @@ export class DocumentChange {
|
|
925
898
|
lastEle = destEleArray[i];
|
926
899
|
leftElement.parent.addChild(lastEle, leftElement.getIndex() + 1 + i);
|
927
900
|
}
|
928
|
-
}
|
901
|
+
}
|
902
|
+
else if (rightElement) {
|
929
903
|
for (let i = 0; i < destEleArray.length; i++) {
|
930
|
-
lastEle = destEleArray[i]
|
904
|
+
lastEle = destEleArray[i];
|
931
905
|
rightElement.parent.addChild(lastEle, rightElement.getIndex());
|
932
906
|
}
|
933
907
|
}
|
934
|
-
}
|
908
|
+
}
|
909
|
+
else {
|
935
910
|
for (let i = 0; i < destEleArray.length; i++) {
|
936
|
-
lastEle = destEleArray[i]
|
911
|
+
lastEle = destEleArray[i];
|
937
912
|
targetElement.parent.addChild(lastEle, targetElement.getIndex() + targetOffset);
|
938
913
|
}
|
939
914
|
}
|
940
915
|
return lastEle;
|
941
916
|
}
|
942
|
-
|
943
|
-
|
944
917
|
/**
|
945
918
|
* 根据开始位置和结束位置,将字符切割成指定的区间
|
946
919
|
* @param splitTextUnit
|
@@ -948,7 +921,7 @@ export class DocumentChange {
|
|
948
921
|
* @param end
|
949
922
|
* @returns
|
950
923
|
*/
|
951
|
-
static splitTextGroupByRange(text
|
924
|
+
static splitTextGroupByRange(text, start, end) {
|
952
925
|
end = end === -1 ? text.textMeasures.length : end;
|
953
926
|
if (start === end) {
|
954
927
|
return null;
|
@@ -968,33 +941,31 @@ export class DocumentChange {
|
|
968
941
|
throw new Error('middleText is null');
|
969
942
|
}
|
970
943
|
text.parent.addChild(middleTextGroup, text.getIndex() + 1);
|
971
|
-
|
972
944
|
if (text.textMeasures.length === 0) {
|
973
945
|
text.remove();
|
974
946
|
text.destroy();
|
975
947
|
}
|
976
948
|
return middleTextGroup;
|
977
949
|
}
|
978
|
-
|
979
|
-
splitText(text: TextGroupElement, offset: number): { leftElement: TextGroupElement | null, rightElement: TextGroupElement | null } {
|
950
|
+
splitText(text, offset) {
|
980
951
|
offset = offset == -1 ? text.textMeasures.length : offset;
|
981
952
|
if (offset === text.textMeasures.length) {
|
982
953
|
return {
|
983
954
|
leftElement: text,
|
984
955
|
rightElement: null
|
985
|
-
}
|
956
|
+
};
|
986
957
|
}
|
987
958
|
if (offset === 0) {
|
988
959
|
return {
|
989
960
|
leftElement: null,
|
990
961
|
rightElement: text
|
991
|
-
}
|
962
|
+
};
|
992
963
|
}
|
993
964
|
const rightText = text.spliceText(offset, -1, true);
|
994
965
|
if (rightText) {
|
995
966
|
text.parent.addChild(rightText, text.getIndex() + 1);
|
996
967
|
}
|
997
|
-
let leftText
|
968
|
+
let leftText = text;
|
998
969
|
if (text.textMeasures.length === 0) {
|
999
970
|
text.remove();
|
1000
971
|
leftText = null;
|
@@ -1002,16 +973,15 @@ export class DocumentChange {
|
|
1002
973
|
return {
|
1003
974
|
leftElement: leftText,
|
1004
975
|
rightElement: rightText
|
1005
|
-
}
|
976
|
+
};
|
1006
977
|
}
|
1007
|
-
|
1008
978
|
/**
|
1009
979
|
* 设置选中的文本样式
|
1010
980
|
* @param ss
|
1011
981
|
* @param setterFunc
|
1012
982
|
* @returns
|
1013
983
|
*/
|
1014
|
-
static setTextStyle(ss
|
984
|
+
static setTextStyle(ss, setterFunc) {
|
1015
985
|
const range = ss.selectedRange;
|
1016
986
|
if (!range || ss.collapsed) {
|
1017
987
|
return;
|
@@ -1035,58 +1005,62 @@ export class DocumentChange {
|
|
1035
1005
|
newSelectionRange.setEnd(middleElement, -1);
|
1036
1006
|
}
|
1037
1007
|
}
|
1038
|
-
}
|
1008
|
+
}
|
1009
|
+
else {
|
1039
1010
|
if (startRange.isFullSelected) {
|
1040
1011
|
newSelectionRange.setStart(startRange.target, 0);
|
1041
|
-
}
|
1012
|
+
}
|
1013
|
+
else {
|
1042
1014
|
if (startRange.target instanceof TextGroupElement) {
|
1043
1015
|
const middleElement = this.splitTextGroupByRange(startRange.target, startRange.startOffset, -1);
|
1044
1016
|
if (middleElement) {
|
1045
1017
|
setterFunc(middleElement.props);
|
1046
1018
|
newSelectionRange.setStart(middleElement, 0);
|
1047
|
-
}
|
1019
|
+
}
|
1020
|
+
else {
|
1048
1021
|
newSelectionRange.setStart(startRange.target, 0);
|
1049
1022
|
}
|
1050
|
-
}
|
1023
|
+
}
|
1024
|
+
else {
|
1051
1025
|
newSelectionRange.setStart(startRange.target, startRange.startOffset);
|
1052
1026
|
}
|
1053
1027
|
}
|
1054
1028
|
if (endRange.isFullSelected) {
|
1055
1029
|
newSelectionRange.setEnd(endRange.target, -1);
|
1056
|
-
}
|
1030
|
+
}
|
1031
|
+
else {
|
1057
1032
|
if (endRange.target instanceof TextGroupElement) {
|
1058
1033
|
const middleElement = this.splitTextGroupByRange(endRange.target, 0, endRange.endOffset);
|
1059
1034
|
if (middleElement) {
|
1060
1035
|
setterFunc(middleElement.props);
|
1061
1036
|
newSelectionRange.setEnd(middleElement, -1);
|
1062
|
-
}
|
1037
|
+
}
|
1038
|
+
else {
|
1063
1039
|
newSelectionRange.setStart(endRange.target, 0);
|
1064
1040
|
}
|
1065
|
-
|
1066
|
-
|
1041
|
+
}
|
1042
|
+
else {
|
1067
1043
|
newSelectionRange.setEnd(endRange.target, endRange.endOffset);
|
1068
1044
|
}
|
1069
1045
|
}
|
1070
1046
|
}
|
1071
1047
|
ss.addRange(newSelectionRange);
|
1072
1048
|
}
|
1073
|
-
|
1074
|
-
private static recursionSetRangeTextStyle(range: SelectionContentRange, setterFunc: (tp: TextProps) => void): void {
|
1049
|
+
static recursionSetRangeTextStyle(range, setterFunc) {
|
1075
1050
|
RangeUtil.recursionTraversalRangeHandler(range, (itemRange) => {
|
1076
1051
|
if (itemRange.target instanceof TextGroupElement && itemRange.isFullSelected) {
|
1077
|
-
setterFunc(itemRange.target.props)
|
1052
|
+
setterFunc(itemRange.target.props);
|
1078
1053
|
}
|
1079
|
-
})
|
1054
|
+
});
|
1080
1055
|
}
|
1081
|
-
|
1082
|
-
|
1083
|
-
static setParaAlign(ss: SelectionState, setterFunc: (tp: ParagraphProps) => void): void {
|
1056
|
+
static setParaAlign(ss, setterFunc) {
|
1084
1057
|
if (ss.collapsed && ss.startControl) {
|
1085
1058
|
const para = ElementUtil.getParentByType(ss.startControl, ParagraphElement);
|
1086
1059
|
if (para) {
|
1087
1060
|
setterFunc(para.props);
|
1088
1061
|
}
|
1089
|
-
}
|
1062
|
+
}
|
1063
|
+
else {
|
1090
1064
|
const range = ss.selectedRange;
|
1091
1065
|
if (!range) {
|
1092
1066
|
return;
|
@@ -1095,18 +1069,15 @@ export class DocumentChange {
|
|
1095
1069
|
if (itemRange.target instanceof ParagraphElement) {
|
1096
1070
|
setterFunc(itemRange.target.props);
|
1097
1071
|
}
|
1098
|
-
})
|
1072
|
+
});
|
1099
1073
|
}
|
1100
|
-
|
1101
1074
|
}
|
1102
|
-
|
1103
|
-
|
1104
1075
|
/**
|
1105
1076
|
* 复制
|
1106
1077
|
* @param evt
|
1107
1078
|
* @returns
|
1108
1079
|
*/
|
1109
|
-
onCopy(evt
|
1080
|
+
onCopy(evt) {
|
1110
1081
|
evt.preventDefault();
|
1111
1082
|
const copySerializeStr = ElementSerialize.getSelectedJSON(this.selectionState, this.viewOptions);
|
1112
1083
|
if (!copySerializeStr) {
|
@@ -1116,22 +1087,20 @@ export class DocumentChange {
|
|
1116
1087
|
const copyStr = ElementSerialize.getSelectedText(this.selectionState, this.viewOptions);
|
1117
1088
|
evt.clipboardData?.setData('text/plain', copyStr);
|
1118
1089
|
}
|
1119
|
-
|
1120
1090
|
/**
|
1121
1091
|
* 剪切
|
1122
1092
|
* @param evt
|
1123
1093
|
*/
|
1124
|
-
onCut(evt
|
1094
|
+
onCut(evt) {
|
1125
1095
|
this.onCopy(evt);
|
1126
1096
|
this.onRangeDelete();
|
1127
1097
|
}
|
1128
|
-
|
1129
1098
|
/**
|
1130
1099
|
* 粘贴
|
1131
1100
|
* @param evt
|
1132
1101
|
* @returns
|
1133
1102
|
*/
|
1134
|
-
onPaste(evt
|
1103
|
+
onPaste(evt) {
|
1135
1104
|
evt.preventDefault();
|
1136
1105
|
let pasteText = evt.clipboardData?.getData('text/plain');
|
1137
1106
|
const pasteData = evt.clipboardData?.getData('doc/plain');
|
@@ -1166,37 +1135,35 @@ export class DocumentChange {
|
|
1166
1135
|
return;
|
1167
1136
|
}
|
1168
1137
|
if (pasteElement instanceof ParagraphElement || pasteElement instanceof InlineGroupElement) {
|
1169
|
-
const children
|
1138
|
+
const children = [];
|
1170
1139
|
if (pasteElement instanceof ParagraphElement) {
|
1171
1140
|
children.push(...ElementUtil.getChildrenElements(pasteElement));
|
1172
|
-
}
|
1141
|
+
}
|
1142
|
+
else if (pasteElement instanceof InlineGroupElement) {
|
1173
1143
|
children.push(pasteElement);
|
1174
1144
|
}
|
1175
1145
|
if (!children.length) {
|
1176
1146
|
throw new Error('段落子元素为空');
|
1177
1147
|
}
|
1178
|
-
const lastEle = this.insertElement(startControl, startOffset, children)
|
1148
|
+
const lastEle = this.insertElement(startControl, startOffset, children);
|
1179
1149
|
this.selectionState.resetRange(lastEle, -1);
|
1180
1150
|
return;
|
1181
1151
|
}
|
1182
1152
|
console.log('粘贴:' + pasteData);
|
1183
1153
|
}
|
1184
|
-
|
1185
|
-
insertSoftBr(): void {
|
1154
|
+
insertSoftBr() {
|
1186
1155
|
let { startControl, startOffset } = this.selectionState;
|
1187
|
-
const lastEle = this.insertElement(startControl, startOffset, [new BreakElement()])
|
1156
|
+
const lastEle = this.insertElement(startControl, startOffset, [new BreakElement()]);
|
1188
1157
|
const focusEle = ElementUtil.getNextSiblingElement(lastEle);
|
1189
1158
|
if (focusEle) {
|
1190
1159
|
this.selectionState.resetRange(focusEle, 0);
|
1191
1160
|
}
|
1192
|
-
|
1193
1161
|
}
|
1194
|
-
|
1195
1162
|
/**
|
1196
1163
|
* 处理黏贴的纯文本
|
1197
1164
|
* @param text
|
1198
1165
|
*/
|
1199
|
-
|
1166
|
+
pastePlainText(text) {
|
1200
1167
|
const textItems = text.split(/\r?\n/);
|
1201
1168
|
const { startControl, startOffset } = this.selectionState;
|
1202
1169
|
if (this.viewOptions.docMode === DocMode.FormEdit || textItems.length === 1 || IsInSideInlineGroupInputElement(startControl, startOffset)) {
|
@@ -1207,11 +1174,12 @@ export class DocumentChange {
|
|
1207
1174
|
element: startControl,
|
1208
1175
|
offset: startOffset
|
1209
1176
|
}
|
1210
|
-
})
|
1211
|
-
}
|
1177
|
+
});
|
1178
|
+
}
|
1179
|
+
else {
|
1212
1180
|
const breakPara = this.splitCurrentParagraph();
|
1213
1181
|
for (let i = 0; i < textItems.length; i++) {
|
1214
|
-
const newPara = breakPara.clone(false)
|
1182
|
+
const newPara = breakPara.clone(false);
|
1215
1183
|
const inputTextProps = newPara.props.textProps;
|
1216
1184
|
const newTextEle = ElementUtil.getNewTextGroup(inputTextProps);
|
1217
1185
|
newTextEle.text = textItems[i];
|
@@ -1221,29 +1189,28 @@ export class DocumentChange {
|
|
1221
1189
|
this.selectionState.resetRange(breakPara, 0);
|
1222
1190
|
}
|
1223
1191
|
}
|
1224
|
-
|
1225
1192
|
/**
|
1226
1193
|
* 设置当前段落项目符号类型
|
1227
1194
|
*/
|
1228
|
-
setParagraphNumberType()
|
1195
|
+
setParagraphNumberType() {
|
1229
1196
|
const { startControl } = this.selectionState;
|
1230
1197
|
if (!startControl) {
|
1231
1198
|
return;
|
1232
1199
|
}
|
1233
|
-
const para = ElementUtil.getParentByType(startControl, ParagraphElement)
|
1200
|
+
const para = ElementUtil.getParentByType(startControl, ParagraphElement);
|
1234
1201
|
if (para.props.numberType >= 0) {
|
1235
1202
|
para.props.numberType = -1;
|
1236
1203
|
para.props.indent = 0;
|
1237
|
-
}
|
1204
|
+
}
|
1205
|
+
else {
|
1238
1206
|
para.props.numberType = 0;
|
1239
1207
|
para.props.indent = 15;
|
1240
1208
|
}
|
1241
1209
|
}
|
1242
|
-
|
1243
1210
|
/**
|
1244
1211
|
* 插入批注
|
1245
1212
|
*/
|
1246
|
-
insertComment()
|
1213
|
+
insertComment() {
|
1247
1214
|
const { startControl, startOffset, endControl, endOffset, collapsed } = this.selectionState;
|
1248
1215
|
if (collapsed || !startControl || !endControl) {
|
1249
1216
|
return;
|
@@ -1252,14 +1219,11 @@ export class DocumentChange {
|
|
1252
1219
|
const startCommMark = new CommentElement();
|
1253
1220
|
startCommMark.props.id = id;
|
1254
1221
|
startCommMark.props.markType = 'start';
|
1255
|
-
|
1256
1222
|
const endCommMark = new CommentElement();
|
1257
1223
|
endCommMark.props.id = id;
|
1258
1224
|
endCommMark.props.markType = 'end';
|
1259
|
-
|
1260
|
-
this.insertElement(
|
1261
|
-
this.insertElement(startControl, startOffset, [startCommMark])
|
1262
|
-
|
1225
|
+
this.insertElement(endControl, endOffset, [endCommMark]);
|
1226
|
+
this.insertElement(startControl, startOffset, [startCommMark]);
|
1263
1227
|
const commContent = new CommContentElement();
|
1264
1228
|
commContent.props.id = id;
|
1265
1229
|
commContent.props.createId = this.viewOptions.editUser.id;
|
@@ -1271,12 +1235,10 @@ export class DocumentChange {
|
|
1271
1235
|
}
|
1272
1236
|
this.docCtx.document.commentsContainerElement.addChild(commContent, pos);
|
1273
1237
|
this.selectionState.clear();
|
1274
|
-
|
1275
1238
|
this.docComment.afterCommentsChanged();
|
1276
1239
|
}
|
1277
|
-
|
1278
|
-
|
1279
|
-
const dataEleList = this.docCtx.document.treeFilter(item => item instanceof DataElementInlineGroup) as Array<DataElementInlineGroup>;
|
1240
|
+
validate() {
|
1241
|
+
const dataEleList = this.docCtx.document.treeFilter(item => item instanceof DataElementInlineGroup);
|
1280
1242
|
const errorEleList = dataEleList.map(item => ({ error: item.validate(), ele: item })).filter(item => item.error);
|
1281
1243
|
if (!errorEleList.length) {
|
1282
1244
|
return true;
|
@@ -1286,59 +1248,51 @@ export class DocumentChange {
|
|
1286
1248
|
const startCommMark = new CommentElement();
|
1287
1249
|
startCommMark.props.id = id;
|
1288
1250
|
startCommMark.props.markType = 'start';
|
1289
|
-
|
1290
1251
|
const endCommMark = new CommentElement();
|
1291
1252
|
endCommMark.props.id = id;
|
1292
1253
|
endCommMark.props.markType = 'end';
|
1293
|
-
|
1294
1254
|
item.ele.addChild(startCommMark, 0);
|
1295
|
-
item.ele.addChild(endCommMark, item.ele.length)
|
1255
|
+
item.ele.addChild(endCommMark, item.ele.length);
|
1296
1256
|
const caption = CommonUtil.nullToString(item.ele.props.caption);
|
1297
1257
|
const validateElement = new ValidateElement();
|
1298
1258
|
validateElement.props.title = caption + '验证';
|
1299
1259
|
validateElement.props.id = id;
|
1300
1260
|
validateElement.setContent(item.error);
|
1301
|
-
|
1302
1261
|
const pos = this.docComment.getCommMarkIndex(startCommMark);
|
1303
1262
|
this.docCtx.document.commentsContainerElement.addChild(validateElement, pos);
|
1304
|
-
|
1305
|
-
|
1306
|
-
})
|
1263
|
+
});
|
1307
1264
|
this.docCtx.selectionState.clear();
|
1308
1265
|
this.docComment.afterCommentsChanged();
|
1309
|
-
|
1310
1266
|
return false;
|
1311
1267
|
}
|
1312
|
-
|
1313
1268
|
/**
|
1314
1269
|
* 移除空字符串
|
1315
1270
|
* @param text
|
1316
1271
|
*/
|
1317
|
-
removeEmptyText(text
|
1272
|
+
removeEmptyText(text) {
|
1318
1273
|
//const nextLeafElementInPara = ElementUtil.getRecursionNextSiblingElement(text, true, true); getComputedStyle
|
1319
1274
|
this.setCurosrForDeleteAction(text);
|
1320
1275
|
const parent = text.parent;
|
1321
1276
|
text.remove();
|
1322
1277
|
this.removeEmtpyInlineBlock(parent);
|
1323
1278
|
}
|
1324
|
-
|
1325
|
-
setCurosrForDeleteAction(control: Element): void {
|
1279
|
+
setCurosrForDeleteAction(control) {
|
1326
1280
|
const cursorInfo = this.getCursorElementByDeleteAction(control);
|
1327
1281
|
if (cursorInfo) {
|
1328
1282
|
this.selectionState.resetRange(cursorInfo.ele, cursorInfo.offset);
|
1329
|
-
}
|
1283
|
+
}
|
1284
|
+
else {
|
1330
1285
|
this.selectionState.clear();
|
1331
1286
|
}
|
1332
1287
|
}
|
1333
|
-
|
1334
|
-
getCursorElementByDeleteAction(control: Element): { ele: LeafElement, offset: number } | null {
|
1288
|
+
getCursorElementByDeleteAction(control) {
|
1335
1289
|
const prevLeafElementInPara = ElementUtil.getRecursionPrevSiblingElement(control, false, true);
|
1336
1290
|
//判断是否为同一段落
|
1337
1291
|
if (prevLeafElementInPara && ElementUtil.isInSameParagraph(prevLeafElementInPara, control)) {
|
1338
1292
|
return {
|
1339
1293
|
ele: prevLeafElementInPara,
|
1340
1294
|
offset: ElementUtil.getElementEndOffset(prevLeafElementInPara)
|
1341
|
-
}
|
1295
|
+
};
|
1342
1296
|
}
|
1343
1297
|
//同一段落其他元素
|
1344
1298
|
const nextLeafElementInPara = ElementUtil.getRecursionNextSiblingElement(control, true, true);
|
@@ -1346,36 +1300,34 @@ export class DocumentChange {
|
|
1346
1300
|
return {
|
1347
1301
|
ele: nextLeafElementInPara,
|
1348
1302
|
offset: 0
|
1349
|
-
}
|
1303
|
+
};
|
1350
1304
|
}
|
1351
1305
|
//上一段落
|
1352
1306
|
if (prevLeafElementInPara) {
|
1353
1307
|
return {
|
1354
1308
|
ele: prevLeafElementInPara,
|
1355
1309
|
offset: prevLeafElementInPara instanceof PSymbolElement ? 0 : ElementUtil.getElementEndOffset(prevLeafElementInPara)
|
1356
|
-
}
|
1310
|
+
};
|
1357
1311
|
}
|
1358
1312
|
return null;
|
1359
1313
|
}
|
1360
|
-
|
1361
1314
|
/**
|
1362
1315
|
* 移除空行内标签
|
1363
1316
|
* @param ele
|
1364
1317
|
*/
|
1365
|
-
removeEmtpyInlineBlock(ele
|
1318
|
+
removeEmtpyInlineBlock(ele) {
|
1366
1319
|
if (ele instanceof InlineGroupElement && ele.length === 0) {
|
1367
1320
|
const parent = ele.parent;
|
1368
1321
|
ele.remove();
|
1369
1322
|
this.removeEmtpyInlineBlock(parent);
|
1370
1323
|
}
|
1371
1324
|
}
|
1372
|
-
|
1373
1325
|
/**
|
1374
1326
|
* 插入强制换页符号
|
1375
1327
|
*/
|
1376
|
-
insertPageBreakPara()
|
1328
|
+
insertPageBreakPara() {
|
1377
1329
|
const { startControl } = this.selectionState;
|
1378
|
-
const currPara = ElementUtil.getParentByType(startControl, ParagraphElement)
|
1330
|
+
const currPara = ElementUtil.getParentByType(startControl, ParagraphElement);
|
1379
1331
|
if (!currPara) {
|
1380
1332
|
return;
|
1381
1333
|
}
|
@@ -1386,6 +1338,5 @@ export class DocumentChange {
|
|
1386
1338
|
pageBreak.parent.addChild(pageBreak);
|
1387
1339
|
}
|
1388
1340
|
}
|
1389
|
-
|
1390
|
-
|
1391
1341
|
}
|
1342
|
+
//# sourceMappingURL=document-change.js.map
|