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