@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,84 +1,81 @@
|
|
1
1
|
import { RenderContenxt } from './framework/render-context';
|
2
|
-
import {
|
2
|
+
import { ContextMenuElementEvent, EventMap } from './framework/element-event-define';
|
3
3
|
import { DocumentPaint } from './framework/document-paint';
|
4
4
|
import { ElementReader } from './framework/element-reader';
|
5
5
|
import { DocumentEvent } from './framework/document-event';
|
6
6
|
import { Subject } from 'rxjs';
|
7
7
|
import { DocumentInput } from './framework/document-input-cursor';
|
8
|
-
import { DocumentCursor, DocumentSelection
|
8
|
+
import { DocumentCursor, DocumentSelection } from './framework/document-selection';
|
9
9
|
import { ElementUtil } from './framework/element-util';
|
10
10
|
import { DocumentChange } from './framework/document-change';
|
11
|
-
import { CursorType } from './framework/render-define';
|
12
11
|
import { SelectionOverlays } from './framework/selection-overlays';
|
13
|
-
import {
|
14
|
-
BranchElement,
|
15
|
-
DocMode,
|
16
|
-
Element,
|
17
|
-
ICancelTokenFn,
|
18
|
-
LeafElement,
|
19
|
-
MarginProps,
|
20
|
-
OrientType,
|
21
|
-
PageOptions,
|
22
|
-
Position,
|
23
|
-
TextAlign,
|
24
|
-
ViewOptions
|
25
|
-
} from './framework/element-define';
|
12
|
+
import { BranchElement, DocMode, PageOptions, ViewOptions } from './framework/element-define';
|
26
13
|
import { ElementSerialize } from './framework/element-serialize';
|
27
14
|
import { TableElement } from './framework/impl/table/table-impl';
|
28
15
|
import { documentPrint } from './framework/document-print';
|
29
16
|
import { DocumentTemplate } from './framework/document-template';
|
30
|
-
import {
|
31
|
-
DataElementInlineGroup,
|
32
|
-
DataElementLeaf, IsInSideDataElement,
|
33
|
-
validateDataEle
|
34
|
-
} from './framework/impl/data-element/data-element-base-impl';
|
17
|
+
import { IsInSideDataElement, validateDataEle } from './framework/impl/data-element/data-element-base-impl';
|
35
18
|
import { DocRule } from './doc-ruler';
|
36
|
-
import { ParagraphProps, TextProps } from './framework/element-props';
|
37
19
|
import { TextGroupElement } from './framework/impl/text/text-impl';
|
38
20
|
import { ParagraphElement } from './framework/impl/paragraph/p-impl';
|
39
21
|
import { TableUtil } from './framework/impl/table/table-util';
|
40
22
|
import { EditorContext } from './framework/document-context';
|
41
|
-
import {
|
23
|
+
import { DocumentRenderObject } from './framework/impl/document/doc-impl';
|
42
24
|
import { DocumentComment } from './framework/document-comment';
|
43
25
|
import { CommContentBaseElement } from './framework/impl/comments/comment-content-impl';
|
44
26
|
import { DocumentHistory } from './framework/document-history';
|
45
27
|
import { TableRowElement } from './framework/impl/table/table-row-impl';
|
46
28
|
import { getFocusTextSegment } from "./framework/document-segmenter";
|
47
|
-
|
48
29
|
import { saveAs } from 'file-saver';
|
49
30
|
import { DocumentBodyElement } from "./framework/impl/document/doc-body-impl";
|
50
|
-
|
51
31
|
export class CanvasTextEditor {
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
32
|
+
docScroll;
|
33
|
+
holdSpace;
|
34
|
+
ruleCanvas;
|
35
|
+
editCanvasContainer;
|
36
|
+
editCanvas;
|
37
|
+
editInput;
|
38
|
+
editCursor;
|
39
|
+
cursorWrapper;
|
40
|
+
scaleContainer;
|
41
|
+
contentCtx;
|
42
|
+
viewOptions;
|
43
|
+
docCtx;
|
44
|
+
docComment;
|
45
|
+
renderContext;
|
46
|
+
documentPaint;
|
47
|
+
elementReader;
|
48
|
+
documentEvent;
|
49
|
+
documentSelection;
|
50
|
+
documentInput;
|
51
|
+
documentChange;
|
52
|
+
selectionOverlays;
|
53
|
+
docRule;
|
54
|
+
docHistory;
|
55
|
+
eventMap = new EventMap();
|
56
|
+
selectionChanged = new Subject();
|
57
|
+
beforeRenderSubject = new Subject();
|
58
|
+
afterRenderSubject = new Subject();
|
59
|
+
selectionState;
|
71
60
|
//显示右键菜单
|
72
|
-
onContextMenuItemChanged
|
61
|
+
onContextMenuItemChanged = new Subject();
|
73
62
|
//显示数据元编辑框
|
74
|
-
onShowDataElementEditPanelEvent
|
75
|
-
onDblClickEvent
|
76
|
-
onClickEvent
|
77
|
-
onScrollViewEvent
|
63
|
+
onShowDataElementEditPanelEvent = new Subject();
|
64
|
+
onDblClickEvent = new Subject();
|
65
|
+
onClickEvent = new Subject();
|
66
|
+
onScrollViewEvent = new Subject();
|
78
67
|
//文档改变事件:内容及样式,业务模块需要根据此事件,来追踪当前文档是否改变的状态
|
79
|
-
onDocChangedEvent
|
80
|
-
|
81
|
-
|
68
|
+
onDocChangedEvent = new Subject();
|
69
|
+
constructor(docScroll, holdSpace, ruleCanvas, editCanvasContainer, editCanvas, editInput, editCursor, cursorWrapper, scaleContainer) {
|
70
|
+
this.docScroll = docScroll;
|
71
|
+
this.holdSpace = holdSpace;
|
72
|
+
this.ruleCanvas = ruleCanvas;
|
73
|
+
this.editCanvasContainer = editCanvasContainer;
|
74
|
+
this.editCanvas = editCanvas;
|
75
|
+
this.editInput = editInput;
|
76
|
+
this.editCursor = editCursor;
|
77
|
+
this.cursorWrapper = cursorWrapper;
|
78
|
+
this.scaleContainer = scaleContainer;
|
82
79
|
this.viewOptions = new ViewOptions();
|
83
80
|
this.documentSelection = new DocumentSelection();
|
84
81
|
this.docCtx = new EditorContext(this.documentSelection.selectionState, this.viewOptions);
|
@@ -87,7 +84,7 @@ export class CanvasTextEditor {
|
|
87
84
|
this.viewOptions.showLineRect = true;
|
88
85
|
this.viewOptions.docSpace = 20;
|
89
86
|
this.viewOptions.reviewWindowWidth = 200;
|
90
|
-
this.viewOptions.defaultFontName = '宋体'
|
87
|
+
this.viewOptions.defaultFontName = '宋体';
|
91
88
|
//整个画布的尺寸
|
92
89
|
this.viewOptions.viewSettings = {
|
93
90
|
width: 1000,
|
@@ -101,7 +98,7 @@ export class CanvasTextEditor {
|
|
101
98
|
this.viewOptions.enableUndo = true;
|
102
99
|
this.createDocViewer();
|
103
100
|
this.docComment = new DocumentComment(this.docCtx);
|
104
|
-
this.contentCtx = editCanvas.getContext('2d')
|
101
|
+
this.contentCtx = editCanvas.getContext('2d');
|
105
102
|
this.renderContext = new RenderContenxt(this.contentCtx, this.viewOptions, this.docCtx);
|
106
103
|
this.setCanvasProps();
|
107
104
|
this.selectionState = this.documentSelection.selectionState;
|
@@ -114,81 +111,80 @@ export class CanvasTextEditor {
|
|
114
111
|
this.docHistory = new DocumentHistory(this.docCtx, this.elementReader, this.onDocChangedEvent);
|
115
112
|
this.documentInput = new DocumentInput(editInput, editCursor, cursorWrapper, this.docCtx);
|
116
113
|
this.documentEvent.hitInfoChanged.subscribe((hitInfo) => {
|
117
|
-
this.hitInfoChanged(hitInfo)
|
114
|
+
this.hitInfoChanged(hitInfo);
|
118
115
|
});
|
119
116
|
this.documentEvent.clickEvent.subscribe((evt) => {
|
120
|
-
this.docClickHandle(evt)
|
117
|
+
this.docClickHandle(evt);
|
121
118
|
});
|
122
119
|
this.documentEvent.dblClickEvent.subscribe((evt) => {
|
123
|
-
this.docDblClickHandle(evt)
|
120
|
+
this.docDblClickHandle(evt);
|
124
121
|
});
|
125
122
|
this.documentEvent.changeCursor.subscribe((cursor) => {
|
126
|
-
this.changeCursor(cursor)
|
123
|
+
this.changeCursor(cursor);
|
127
124
|
});
|
128
125
|
this.documentEvent.contextMenu.subscribe(evt => {
|
129
|
-
this.onContextMenu(evt)
|
126
|
+
this.onContextMenu(evt);
|
130
127
|
});
|
131
128
|
this.documentEvent.trackTipsChanged.subscribe(data => {
|
132
129
|
});
|
133
130
|
this.documentInput.onInputEvent.subscribe(data => {
|
134
|
-
this.documentChange.newInput(data)
|
131
|
+
this.documentChange.newInput(data);
|
135
132
|
});
|
136
133
|
this.documentInput.onBackspaceEvent.subscribe((evt) => {
|
137
|
-
this.documentChange.onBackspace(evt)
|
134
|
+
this.documentChange.onBackspace(evt);
|
138
135
|
});
|
139
136
|
this.documentInput.onEnterEvent.subscribe(() => {
|
140
|
-
this.documentChange.onEnter()
|
137
|
+
this.documentChange.onEnter();
|
141
138
|
});
|
142
139
|
this.documentInput.onCopyEvent.subscribe((evt) => {
|
143
|
-
this.documentChange.onCopy(evt)
|
140
|
+
this.documentChange.onCopy(evt);
|
144
141
|
});
|
145
142
|
this.documentInput.onCutEvent.subscribe((evt) => {
|
146
143
|
this.documentChange.onCut(evt);
|
147
144
|
});
|
148
145
|
this.documentInput.onPasteEvent.subscribe((evt) => {
|
149
|
-
this.documentChange.onPaste(evt)
|
146
|
+
this.documentChange.onPaste(evt);
|
150
147
|
});
|
151
148
|
this.documentInput.onInsertBr.subscribe(() => {
|
152
|
-
this.documentChange.insertSoftBr()
|
153
|
-
})
|
149
|
+
this.documentChange.insertSoftBr();
|
150
|
+
});
|
154
151
|
this.documentInput.onLeftEvent.subscribe(() => {
|
155
|
-
this.documentEvent.moveCursorToLeft()
|
152
|
+
this.documentEvent.moveCursorToLeft();
|
156
153
|
});
|
157
154
|
this.documentInput.onRightEvent.subscribe(() => {
|
158
|
-
this.documentEvent.moveCursorToRight()
|
155
|
+
this.documentEvent.moveCursorToRight();
|
159
156
|
});
|
160
157
|
this.documentInput.onDeleteEvent.subscribe((evt) => this.documentChange.onDeleteKeyHandler(evt));
|
161
158
|
this.documentInput.onSelectAllEvent.subscribe(() => {
|
162
|
-
this.documentEvent.selectAll()
|
159
|
+
this.documentEvent.selectAll();
|
163
160
|
});
|
164
161
|
this.documentInput.onHomeEvent.subscribe(() => {
|
165
|
-
this.documentEvent.moveCursorToLineStart()
|
166
|
-
})
|
162
|
+
this.documentEvent.moveCursorToLineStart();
|
163
|
+
});
|
167
164
|
this.documentInput.onEndEvent.subscribe(() => {
|
168
|
-
this.documentEvent.moveCursorToLineEnd()
|
169
|
-
})
|
165
|
+
this.documentEvent.moveCursorToLineEnd();
|
166
|
+
});
|
170
167
|
this.documentInput.onUpEvent.subscribe(() => {
|
171
|
-
this.documentEvent.moveCursorToUpOrDown(true)
|
172
|
-
})
|
168
|
+
this.documentEvent.moveCursorToUpOrDown(true);
|
169
|
+
});
|
173
170
|
this.documentInput.onDownEvent.subscribe(() => {
|
174
|
-
this.documentEvent.moveCursorToUpOrDown(false)
|
175
|
-
})
|
171
|
+
this.documentEvent.moveCursorToUpOrDown(false);
|
172
|
+
});
|
176
173
|
this.docCtx.docChange = this.documentChange;
|
177
174
|
this.listenContainerHeight();
|
178
175
|
this.refreshDocRule();
|
179
176
|
this.docCtx.syncRefresh = () => {
|
180
|
-
this.flushToSchedule()
|
177
|
+
this.flushToSchedule();
|
181
178
|
};
|
182
179
|
this.viewOptions.onChange.subscribe((type) => {
|
183
|
-
this.resetViewer(type)
|
184
|
-
})
|
180
|
+
this.resetViewer(type);
|
181
|
+
});
|
185
182
|
}
|
186
|
-
|
187
183
|
/**
|
188
184
|
* 设置标尺
|
189
185
|
*/
|
190
|
-
refreshDocRule()
|
191
|
-
let docLeft = 0//CommonUtil.getOffsetX(this.editCanvas.parentElement as HTMLDivElement);
|
186
|
+
refreshDocRule() {
|
187
|
+
let docLeft = 0; //CommonUtil.getOffsetX(this.editCanvas.parentElement as HTMLDivElement);
|
192
188
|
let pagePL = 0, pagePR = 0;
|
193
189
|
if (this.documentPaint.docContainer) {
|
194
190
|
docLeft += this.documentPaint.docContainer.rect.x;
|
@@ -201,8 +197,7 @@ export class CanvasTextEditor {
|
|
201
197
|
this.docRule.setRuleOptions({ width: this.viewOptions.docPageSettings.width, pagePL, pagePR, docLeft });
|
202
198
|
this.docRule.refreshRule();
|
203
199
|
}
|
204
|
-
|
205
|
-
createDocViewer(): void {
|
200
|
+
createDocViewer() {
|
206
201
|
this.viewOptions.mmToPixelsRatio = this.measureMMToPixs();
|
207
202
|
const width = Math.floor(210 * this.viewOptions.mmToPixelsRatio);
|
208
203
|
const height = Math.floor(297 * this.viewOptions.mmToPixelsRatio);
|
@@ -211,8 +206,7 @@ export class CanvasTextEditor {
|
|
211
206
|
this.scrollView(evt);
|
212
207
|
};
|
213
208
|
}
|
214
|
-
|
215
|
-
measureMMToPixs(): number {
|
209
|
+
measureMMToPixs() {
|
216
210
|
const div = document.createElement('div');
|
217
211
|
div.style.width = '100mm';
|
218
212
|
document.body.appendChild(div);
|
@@ -220,12 +214,11 @@ export class CanvasTextEditor {
|
|
220
214
|
document.body.removeChild(div);
|
221
215
|
return width / 100;
|
222
216
|
}
|
223
|
-
|
224
|
-
|
225
|
-
flushTaskThen: Array<(() => void)> = [];
|
217
|
+
flushTask;
|
218
|
+
flushTaskThen = [];
|
226
219
|
//是否用于跟踪修改状态,在初始化、数据元赋值等情况不需要跟踪修改标志
|
227
|
-
|
228
|
-
flushToSchedule()
|
220
|
+
trackChangeState = true;
|
221
|
+
flushToSchedule() {
|
229
222
|
if (this.docCtx.refreshType === 'content') {
|
230
223
|
//触发动态脚本
|
231
224
|
this.docCtx.dynamicFunc.invokedScripts();
|
@@ -246,51 +239,45 @@ export class CanvasTextEditor {
|
|
246
239
|
}
|
247
240
|
});
|
248
241
|
}
|
249
|
-
|
250
242
|
/**
|
251
243
|
* 触发文档改变事件
|
252
244
|
* @returns
|
253
245
|
*/
|
254
|
-
triggerDocChange()
|
246
|
+
triggerDocChange() {
|
255
247
|
if (!this.trackChangeState) {
|
256
248
|
return;
|
257
249
|
}
|
258
250
|
this.onDocChangedEvent.next();
|
259
251
|
}
|
260
|
-
|
261
252
|
/**
|
262
253
|
* fn函数执行时,不触发onDocChange
|
263
254
|
* @param fn
|
264
255
|
*/
|
265
|
-
noEffectChange(fn
|
256
|
+
noEffectChange(fn) {
|
266
257
|
const prev = this.trackChangeState;
|
267
258
|
this.trackChangeState = false;
|
268
259
|
try {
|
269
260
|
fn();
|
270
|
-
}
|
261
|
+
}
|
262
|
+
catch (e) {
|
271
263
|
console.error(e);
|
272
264
|
}
|
273
265
|
this.trackChangeState = prev;
|
274
266
|
}
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
loadDoc(data: any | DocumentElement): void {
|
267
|
+
loadDoc(data) {
|
279
268
|
this.elementReader.read(data);
|
280
269
|
this.refreshDocument();
|
281
270
|
this.refreshDocRule();
|
282
271
|
this.docHistory.clear();
|
283
272
|
}
|
284
|
-
|
285
273
|
/**
|
286
274
|
* 更新文档容器高度尺寸
|
287
275
|
*/
|
288
|
-
updateDocumentContainerSize()
|
276
|
+
updateDocumentContainerSize() {
|
289
277
|
this.holdSpace.style.height = this.documentPaint.getDocumentContainerHeight() + 'px';
|
290
278
|
}
|
291
|
-
|
292
|
-
|
293
|
-
const target = evt.target as HTMLDivElement;
|
279
|
+
scrollView(evt) {
|
280
|
+
const target = evt.target;
|
294
281
|
const top = Math.floor(target.scrollTop);
|
295
282
|
this.editCanvasContainer.style.top = top + 'px';
|
296
283
|
this.cursorWrapper.style.transform = "translate(0,-" + top + "px)";
|
@@ -298,15 +285,12 @@ export class CanvasTextEditor {
|
|
298
285
|
this.documentPaint.refreshView();
|
299
286
|
this.documentEvent.onScrollView();
|
300
287
|
this.onScrollViewEvent.next(top);
|
301
|
-
|
302
288
|
}
|
303
|
-
|
304
|
-
private refreshDocument(): void {
|
289
|
+
refreshDocument() {
|
305
290
|
let rePaint = this.docCtx.refreshType === 'content';
|
306
291
|
if (rePaint) {
|
307
292
|
this.documentSelection.clearSnapshot();
|
308
293
|
this.docComment.readComments();
|
309
|
-
|
310
294
|
this.documentPaint.rePages();
|
311
295
|
this.beforeRenderSubject.next();
|
312
296
|
}
|
@@ -317,19 +301,16 @@ export class CanvasTextEditor {
|
|
317
301
|
this.setCursor();
|
318
302
|
ssChanged && this.selectionChanged.next(this.documentSelection.selectionState);
|
319
303
|
this.docRule.refreshRule();
|
320
|
-
|
321
304
|
}
|
322
|
-
|
323
|
-
private hitInfoChanged(hitInfo: { startHitInfo: HitEventInfo, endHitInfo: HitEventInfo }): void {
|
305
|
+
hitInfoChanged(hitInfo) {
|
324
306
|
this.documentSelection.setSelectionState(hitInfo);
|
325
307
|
this.refreshDocument();
|
326
308
|
this.selectionChanged.next(this.documentSelection.selectionState);
|
327
309
|
}
|
328
|
-
|
329
310
|
/**
|
330
311
|
* 设置光标
|
331
312
|
*/
|
332
|
-
|
313
|
+
setCursor() {
|
333
314
|
const { startControl, startOffset } = this.selectionState;
|
334
315
|
if (!this.canSetCursor()) {
|
335
316
|
this.selectionState.editable = false;
|
@@ -343,19 +324,18 @@ export class CanvasTextEditor {
|
|
343
324
|
return;
|
344
325
|
}
|
345
326
|
}
|
346
|
-
const { startRegion, hitDocIndex } = this.documentEvent.startHitInfo
|
327
|
+
const { startRegion, hitDocIndex } = this.documentEvent.startHitInfo;
|
347
328
|
const cursorPos = DocumentCursor.getElementCursorPos(startControl, startOffset, startRegion, hitDocIndex);
|
348
329
|
this.docCtx.cursorRect = ElementUtil.cloneRect(cursorPos.rect);
|
349
330
|
this.documentInput.setCursorPosition(cursorPos.rect);
|
350
331
|
this.selectionState.cursorPos = cursorPos.rect;
|
351
332
|
this.documentEvent.invokeCursor(startControl);
|
352
333
|
}
|
353
|
-
|
354
334
|
/**
|
355
335
|
* 判断是否光标可以设置接受编辑
|
356
336
|
* @returns
|
357
337
|
*/
|
358
|
-
|
338
|
+
canSetCursor() {
|
359
339
|
const { startControl, startOffset, editable } = this.selectionState;
|
360
340
|
if (!startControl || !editable) {
|
361
341
|
return false;
|
@@ -385,100 +365,91 @@ export class CanvasTextEditor {
|
|
385
365
|
}
|
386
366
|
return true;
|
387
367
|
}
|
388
|
-
|
389
368
|
/**
|
390
369
|
* 修改光标
|
391
370
|
* @param newCursor
|
392
371
|
*/
|
393
|
-
|
372
|
+
changeCursor(newCursor) {
|
394
373
|
this.editCanvas.style.cursor = newCursor;
|
395
374
|
this.viewOptions.cursor = newCursor;
|
396
375
|
}
|
397
|
-
|
398
376
|
/**
|
399
377
|
* 文档点击事件
|
400
378
|
*/
|
401
|
-
|
379
|
+
docClickHandle(evt) {
|
402
380
|
this.setCursor();
|
403
381
|
this.selectionOverlays.getSelectionTreeData();
|
404
382
|
this.onClickEvent.next(evt);
|
405
383
|
}
|
406
|
-
|
407
384
|
/**
|
408
385
|
* 文档双击事件
|
409
386
|
* 处理全选当前段落
|
410
387
|
*/
|
411
|
-
|
388
|
+
docDblClickHandle(evt) {
|
412
389
|
const res = getFocusTextSegment(this.selectionState);
|
413
390
|
if (res) {
|
414
391
|
this.refreshDocument();
|
415
392
|
}
|
416
393
|
this.onDblClickEvent.next(evt);
|
417
394
|
}
|
418
|
-
|
419
395
|
/**
|
420
396
|
* 获取当前光标所在的数据元
|
421
397
|
* @returns
|
422
398
|
*/
|
423
|
-
getCurrentDataElement()
|
399
|
+
getCurrentDataElement() {
|
424
400
|
const selectionState = this.documentSelection.selectionState;
|
425
401
|
const { startControl } = selectionState;
|
426
402
|
if (startControl) {
|
427
403
|
if (!ElementUtil.verifyHitable(startControl)) {
|
428
404
|
return null;
|
429
405
|
}
|
430
|
-
return ElementUtil.getParent(startControl, validateDataEle)
|
406
|
+
return ElementUtil.getParent(startControl, validateDataEle);
|
431
407
|
}
|
432
408
|
return null;
|
433
409
|
}
|
434
|
-
|
435
410
|
/**
|
436
411
|
* 设置当前光标所在的数据元的值
|
437
412
|
* @param val
|
438
413
|
*/
|
439
|
-
setCurrentDataElementValue(val
|
414
|
+
setCurrentDataElementValue(val) {
|
440
415
|
const dataEle = this.getCurrentDataElement();
|
441
416
|
if (dataEle) {
|
442
417
|
dataEle?.setValue(val);
|
443
418
|
this.selectionState.clear();
|
444
419
|
}
|
445
420
|
}
|
446
|
-
|
447
421
|
/**
|
448
422
|
* 获取数据元位置
|
449
423
|
* @param element
|
450
424
|
* @returns
|
451
425
|
*/
|
452
|
-
getDataElementPosition(element
|
426
|
+
getDataElementPosition(element) {
|
453
427
|
const startDecorateRender = this.documentPaint.elementPaint.getLeafElementPaintMap(element);
|
454
428
|
if (!startDecorateRender) {
|
455
429
|
console.error('未找到数据元开始渲染元素');
|
456
430
|
return;
|
457
431
|
}
|
458
432
|
const { x, height, y, width } = startDecorateRender.rect;
|
459
|
-
const pos = ElementUtil.getRenderAbsolutePaintPos(startDecorateRender)
|
433
|
+
const pos = ElementUtil.getRenderAbsolutePaintPos(startDecorateRender);
|
460
434
|
const position = { x: pos.x + width, y: pos.y + height + 5, translateY: this.viewOptions.translateY };
|
461
|
-
return position
|
435
|
+
return position;
|
462
436
|
}
|
463
|
-
|
464
437
|
/**
|
465
438
|
* 获取文档模型
|
466
439
|
* @returns
|
467
440
|
*/
|
468
|
-
getDocSchema()
|
441
|
+
getDocSchema() {
|
469
442
|
return ElementSerialize.serialize(this.docCtx.document, this.viewOptions);
|
470
443
|
}
|
471
|
-
|
472
|
-
getDocSchemaJSON(): string {
|
444
|
+
getDocSchemaJSON() {
|
473
445
|
const res = JSON.stringify(this.getDocSchema());
|
474
446
|
return res;
|
475
447
|
}
|
476
|
-
|
477
448
|
/**
|
478
449
|
* 右键菜单
|
479
450
|
* @param evt
|
480
451
|
*/
|
481
|
-
onContextMenu(evt
|
452
|
+
onContextMenu(evt) {
|
482
453
|
evt.preventDefault();
|
483
454
|
const { selectionState } = this.documentSelection;
|
484
455
|
const { startControl } = selectionState;
|
@@ -489,21 +460,17 @@ export class CanvasTextEditor {
|
|
489
460
|
elementEvent.source = startControl;
|
490
461
|
DocumentEvent.invokeEvent('ElementContextMenu', startControl, elementEvent, 'All', this.docCtx);
|
491
462
|
const position = { x: evt.offsetX + 10, y: evt.offsetY, translateY: this.viewOptions.translateY };
|
492
|
-
this.onContextMenuItemChanged.next({ pos: position, menus: elementEvent.menus })
|
463
|
+
this.onContextMenuItemChanged.next({ pos: position, menus: elementEvent.menus });
|
493
464
|
}
|
494
|
-
|
495
|
-
|
496
|
-
|
497
|
-
listenContainerHeight(): void {
|
465
|
+
resizeObserver = null;
|
466
|
+
listenContainerHeight() {
|
498
467
|
this.resizeObserver = new ResizeObserver(entries => {
|
499
468
|
this.updateDocHeight();
|
500
|
-
}
|
501
|
-
);
|
469
|
+
});
|
502
470
|
this.resizeObserver.observe(this.docScroll);
|
503
471
|
this.updateDocHeight();
|
504
472
|
}
|
505
|
-
|
506
|
-
private updateDocHeight(): void {
|
473
|
+
updateDocHeight() {
|
507
474
|
const { width, height } = this.getContainerHeight();
|
508
475
|
this.viewOptions.viewSettings.width = width;
|
509
476
|
this.viewOptions.viewSettings.height = height;
|
@@ -512,8 +479,7 @@ export class CanvasTextEditor {
|
|
512
479
|
}
|
513
480
|
this.resetViewer();
|
514
481
|
}
|
515
|
-
|
516
|
-
resetViewer(type: 'demand' | 'force' | undefined = undefined): void {
|
482
|
+
resetViewer(type = undefined) {
|
517
483
|
const refreshType = type === 'force' ? 'content' : 'appearance';
|
518
484
|
if (refreshType === 'content') {
|
519
485
|
this.docCtx.document.pubOnChange('self');
|
@@ -524,13 +490,12 @@ export class CanvasTextEditor {
|
|
524
490
|
this.refreshDocRule();
|
525
491
|
});
|
526
492
|
}
|
527
|
-
|
528
493
|
/**
|
529
494
|
* 缩放视图
|
530
495
|
* @param scale
|
531
496
|
* @returns
|
532
497
|
*/
|
533
|
-
scaleView(scale
|
498
|
+
scaleView(scale) {
|
534
499
|
scale = scale < 0.5 ? 0.5 : scale;
|
535
500
|
scale = scale > 2 ? 2 : scale;
|
536
501
|
this.viewOptions.scale = scale;
|
@@ -545,57 +510,50 @@ export class CanvasTextEditor {
|
|
545
510
|
this.flushToSchedule();
|
546
511
|
return scale;
|
547
512
|
}
|
548
|
-
|
549
|
-
getContainerHeight(): { height: number, width: number } {
|
513
|
+
getContainerHeight() {
|
550
514
|
let { height, width } = this.docScroll.getBoundingClientRect();
|
551
515
|
// const div=this.docScroll.children[0] as HTMLElement;
|
552
516
|
// const { height, width } = div.getBoundingClientRect();
|
553
517
|
return { height: Math.floor(height), width: Math.floor(width) };
|
554
518
|
}
|
555
|
-
|
556
|
-
setCanvasProps(): void {
|
519
|
+
setCanvasProps() {
|
557
520
|
this.renderContext?.clear();
|
558
521
|
this.renderContext.setCanvasProps();
|
559
522
|
this.renderContext?.clear();
|
560
523
|
}
|
561
|
-
|
562
524
|
/**
|
563
525
|
* 在当前位置插入表格
|
564
526
|
* @param row
|
565
527
|
* @param col
|
566
528
|
*/
|
567
|
-
insertTable(rows
|
529
|
+
insertTable(rows, cols) {
|
568
530
|
const tb = TableElement.createTable(rows, cols);
|
569
531
|
this.documentChange.insertTable(tb);
|
570
532
|
}
|
571
|
-
|
572
533
|
/**
|
573
534
|
* 打印所有文档
|
574
535
|
*/
|
575
|
-
printAllPages()
|
576
|
-
documentPrint.print(this.documentSelection.selectionState, this.viewOptions, this.docCtx)
|
536
|
+
printAllPages() {
|
537
|
+
documentPrint.print(this.documentSelection.selectionState, this.viewOptions, this.docCtx);
|
577
538
|
}
|
578
|
-
|
579
539
|
/**
|
580
540
|
* 导出所有页到base64
|
581
541
|
*/
|
582
|
-
exportAllPagesToBase64(fileName
|
583
|
-
const imgs = documentPrint.exportCanvasNodes(this.documentSelection.selectionState, this.viewOptions, this.docCtx)
|
542
|
+
exportAllPagesToBase64(fileName) {
|
543
|
+
const imgs = documentPrint.exportCanvasNodes(this.documentSelection.selectionState, this.viewOptions, this.docCtx);
|
584
544
|
imgs.forEach((item, i) => item.toBlob(blog => {
|
585
545
|
if (blog) {
|
586
|
-
saveAs(blog, fileName + i + '.png')
|
546
|
+
saveAs(blog, fileName + i + '.png');
|
587
547
|
}
|
588
|
-
}))
|
548
|
+
}));
|
589
549
|
}
|
590
|
-
|
591
|
-
|
592
|
-
documentPrint.exportPDF('', this.documentSelection.selectionState, this.viewOptions, this.docCtx)
|
550
|
+
exportPDF() {
|
551
|
+
documentPrint.exportPDF('', this.documentSelection.selectionState, this.viewOptions, this.docCtx);
|
593
552
|
}
|
594
|
-
|
595
553
|
/**
|
596
554
|
* 清除文档
|
597
555
|
*/
|
598
|
-
clearDoc()
|
556
|
+
clearDoc() {
|
599
557
|
if (this.docCtx.document) {
|
600
558
|
this.docCtx.document.destroy();
|
601
559
|
this.documentSelection.selectionState.clear();
|
@@ -603,32 +561,28 @@ export class CanvasTextEditor {
|
|
603
561
|
}
|
604
562
|
this.docCtx.clear();
|
605
563
|
}
|
606
|
-
|
607
564
|
/**
|
608
565
|
* 新建文档
|
609
566
|
* @param options
|
610
567
|
*/
|
611
|
-
createNewDoc(doc
|
568
|
+
createNewDoc(doc = null) {
|
612
569
|
//this.docCtx.clear();
|
613
570
|
const newDoc = doc ?? DocumentTemplate.createA4Doc();
|
614
571
|
// this.elementReader.setDocument(newDoc);
|
615
572
|
// this.refreshDocument('content');
|
616
573
|
this.loadDoc(ElementSerialize.serialize(newDoc, this.viewOptions));
|
617
574
|
}
|
618
|
-
|
619
|
-
destroy(): void {
|
575
|
+
destroy() {
|
620
576
|
this.docCtx.destroy();
|
621
577
|
this.documentEvent.clearSubEvent();
|
622
578
|
this.documentInput.destroy();
|
623
579
|
this.flushTask = null;
|
624
580
|
}
|
625
|
-
|
626
|
-
|
627
581
|
/**
|
628
582
|
* 获取选区文本属性
|
629
583
|
* @returns
|
630
584
|
*/
|
631
|
-
getSelectionTextGroupProps()
|
585
|
+
getSelectionTextGroupProps() {
|
632
586
|
const selectionState = this.selectionState;
|
633
587
|
const range = selectionState.selectedRange;
|
634
588
|
if (!range) {
|
@@ -646,77 +600,70 @@ export class CanvasTextEditor {
|
|
646
600
|
}
|
647
601
|
return null;
|
648
602
|
}
|
649
|
-
|
650
|
-
getSelectionParaProps(): ParagraphProps | null {
|
603
|
+
getSelectionParaProps() {
|
651
604
|
const selectionState = this.selectionState;
|
652
605
|
if (!selectionState || !selectionState.startControl) {
|
653
606
|
return null;
|
654
607
|
}
|
655
|
-
const para = ElementUtil.getParentByType(selectionState.startControl, ParagraphElement)
|
608
|
+
const para = ElementUtil.getParentByType(selectionState.startControl, ParagraphElement);
|
656
609
|
return para.props;
|
657
610
|
}
|
658
|
-
|
659
611
|
/**
|
660
612
|
* 设置文本字体大小
|
661
613
|
* @param fontSize
|
662
614
|
* @returns
|
663
615
|
*/
|
664
|
-
setTextFontSize(fontSize
|
616
|
+
setTextFontSize(fontSize) {
|
665
617
|
if (isNaN(fontSize)) {
|
666
618
|
return;
|
667
619
|
}
|
668
|
-
const setterFunc = (textProps
|
620
|
+
const setterFunc = (textProps) => {
|
669
621
|
textProps.fontSize = fontSize;
|
670
622
|
};
|
671
623
|
DocumentChange.setTextStyle(this.selectionState, setterFunc);
|
672
624
|
}
|
673
|
-
|
674
625
|
/**
|
675
626
|
* 设置文本颜色
|
676
627
|
* @param color \
|
677
628
|
*/
|
678
|
-
setTextColor(color
|
629
|
+
setTextColor(color) {
|
679
630
|
color = color || "rgb(0,0,0)";
|
680
|
-
const setterFunc = (textProps
|
631
|
+
const setterFunc = (textProps) => {
|
681
632
|
textProps.color = color;
|
682
633
|
};
|
683
634
|
DocumentChange.setTextStyle(this.selectionState, setterFunc);
|
684
635
|
}
|
685
|
-
|
686
636
|
/**
|
687
637
|
* 设置文本字体名称
|
688
638
|
* @param font
|
689
639
|
*/
|
690
|
-
setTextFont(font
|
640
|
+
setTextFont(font) {
|
691
641
|
font = font || "宋体";
|
692
|
-
const setterFunc = (textProps
|
642
|
+
const setterFunc = (textProps) => {
|
693
643
|
textProps.fontName = font;
|
694
644
|
};
|
695
645
|
DocumentChange.setTextStyle(this.selectionState, setterFunc);
|
696
646
|
}
|
697
|
-
|
698
647
|
/**
|
699
648
|
* 应用选中文本格式,用于批量设置格式,例如:格式刷
|
700
649
|
* @param newStyle
|
701
650
|
*/
|
702
|
-
applyStyle(newStyle
|
703
|
-
const setterFunc = (textProps
|
651
|
+
applyStyle(newStyle) {
|
652
|
+
const setterFunc = (textProps) => {
|
704
653
|
textProps.setPropsValue(newStyle, textProps);
|
705
654
|
};
|
706
655
|
DocumentChange.setTextStyle(this.selectionState, setterFunc);
|
707
656
|
}
|
708
|
-
|
709
657
|
/**
|
710
658
|
* 开启格式刷
|
711
659
|
*/
|
712
|
-
enableFormatBrush()
|
660
|
+
enableFormatBrush() {
|
713
661
|
const startControl = this.selectionState.startControl;
|
714
662
|
if (startControl instanceof TextGroupElement) {
|
715
663
|
const selectedStyle = startControl.props.clone(null);
|
716
664
|
const selectionOverlayColor = this.viewOptions.selectionOverlaysColor;
|
717
665
|
this.viewOptions.selectionOverlaysColor = "rgba(0,58,140,0.8)";
|
718
|
-
|
719
|
-
const cancelToken: ICancelTokenFn = {};
|
666
|
+
const cancelToken = {};
|
720
667
|
const sub = this.onClickEvent.subscribe(() => {
|
721
668
|
sub.unsubscribe();
|
722
669
|
this.applyStyle(selectedStyle);
|
@@ -733,205 +680,180 @@ export class CanvasTextEditor {
|
|
733
680
|
}
|
734
681
|
return null;
|
735
682
|
}
|
736
|
-
|
737
683
|
/**
|
738
684
|
* 设置文本背景颜色
|
739
685
|
* @param color
|
740
686
|
*/
|
741
|
-
setTextBackColor(color
|
742
|
-
const setterFunc = (textProps
|
687
|
+
setTextBackColor(color) {
|
688
|
+
const setterFunc = (textProps) => {
|
743
689
|
textProps.background = color;
|
744
690
|
};
|
745
691
|
DocumentChange.setTextStyle(this.selectionState, setterFunc);
|
746
692
|
}
|
747
|
-
|
748
693
|
/**
|
749
694
|
* 切换文本加粗、下划线、删除等文本样式
|
750
695
|
* @param isEffective
|
751
696
|
* @param style
|
752
697
|
* @param matchValue
|
753
698
|
*/
|
754
|
-
switchTextStyle
|
755
|
-
const setterFunc = (textProps
|
699
|
+
switchTextStyle(isEffective, style, matchValue, defaultValue = undefined) {
|
700
|
+
const setterFunc = (textProps) => {
|
756
701
|
if (isEffective) {
|
757
|
-
textProps[style] = defaultValue
|
702
|
+
textProps[style] = defaultValue;
|
758
703
|
//delete textProps[style];
|
759
|
-
}
|
704
|
+
}
|
705
|
+
else {
|
760
706
|
textProps[style] = matchValue;
|
761
707
|
}
|
762
708
|
};
|
763
709
|
DocumentChange.setTextStyle(this.selectionState, setterFunc);
|
764
710
|
}
|
765
|
-
|
766
711
|
/**
|
767
712
|
* 修改字间距
|
768
713
|
*/
|
769
|
-
setLetterSpace(letterSpace
|
714
|
+
setLetterSpace(letterSpace) {
|
770
715
|
letterSpace = letterSpace <= 0 ? 0 : letterSpace;
|
771
|
-
const setterFunc = (textProps
|
716
|
+
const setterFunc = (textProps) => {
|
772
717
|
textProps.letterSpace = letterSpace;
|
773
718
|
};
|
774
719
|
DocumentChange.setTextStyle(this.selectionState, setterFunc);
|
775
720
|
}
|
776
|
-
|
777
|
-
|
778
721
|
/**
|
779
722
|
* 设置段落对齐
|
780
723
|
* @param align
|
781
724
|
*/
|
782
|
-
switchParaAlign(align
|
783
|
-
const setterFunc = (paraProps
|
725
|
+
switchParaAlign(align) {
|
726
|
+
const setterFunc = (paraProps) => {
|
784
727
|
paraProps.textAlign = align;
|
785
728
|
};
|
786
729
|
DocumentChange.setParaAlign(this.selectionState, setterFunc);
|
787
730
|
}
|
788
|
-
|
789
|
-
|
790
|
-
combineCell(): void {
|
791
|
-
TableUtil.mergeCells(this.selectionState)
|
731
|
+
combineCell() {
|
732
|
+
TableUtil.mergeCells(this.selectionState);
|
792
733
|
}
|
793
|
-
|
794
734
|
/**
|
795
735
|
* 切换当前段落项目符号状态
|
796
736
|
*/
|
797
|
-
setParagraphNumberType()
|
737
|
+
setParagraphNumberType() {
|
798
738
|
this.documentChange.setParagraphNumberType();
|
799
739
|
}
|
800
|
-
|
801
740
|
/**
|
802
741
|
* 删除当前批注
|
803
742
|
* @param id
|
804
743
|
*/
|
805
|
-
removeComment(id
|
744
|
+
removeComment(id) {
|
806
745
|
this.docComment.removeComment(id);
|
807
746
|
this.selectionState.clear();
|
808
747
|
}
|
809
|
-
|
810
748
|
/**
|
811
749
|
* 移除焦点所在的批注
|
812
750
|
*/
|
813
|
-
removeCurrentComment()
|
814
|
-
const comment = ElementUtil.getParent(this.selectionState.startControl, (item => item instanceof CommContentBaseElement))
|
751
|
+
removeCurrentComment() {
|
752
|
+
const comment = ElementUtil.getParent(this.selectionState.startControl, (item => item instanceof CommContentBaseElement));
|
815
753
|
if (comment) {
|
816
754
|
this.removeComment(comment.props.id);
|
817
755
|
}
|
818
756
|
}
|
819
|
-
|
820
757
|
/**
|
821
758
|
* 插入批注
|
822
759
|
*/
|
823
|
-
insertComment()
|
760
|
+
insertComment() {
|
824
761
|
this.documentChange.insertComment();
|
825
762
|
}
|
826
|
-
|
827
763
|
/**
|
828
764
|
* 清除所有批注
|
829
765
|
*/
|
830
|
-
clearAllComments()
|
766
|
+
clearAllComments() {
|
831
767
|
this.docComment.clearAllComments();
|
832
768
|
}
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
const row = ElementUtil.getParentByType(this.selectionState.startControl, TableRowElement) as TableRowElement;
|
837
|
-
const tb = row?.parent as TableElement;
|
769
|
+
cutTable() {
|
770
|
+
const row = ElementUtil.getParentByType(this.selectionState.startControl, TableRowElement);
|
771
|
+
const tb = row?.parent;
|
838
772
|
TableUtil.cutTable(tb, row.getIndex());
|
839
773
|
const para = new ParagraphElement();
|
840
774
|
tb.parent.addChild(para, tb.getIndex() + 1);
|
841
775
|
}
|
842
|
-
|
843
776
|
/**
|
844
777
|
* 初始化当前文档创建用户信息
|
845
778
|
* 一份文档只需要设置一次
|
846
779
|
*/
|
847
|
-
initCurrentDocUser(userId
|
780
|
+
initCurrentDocUser(userId, userName, date) {
|
848
781
|
const doc = this.docCtx.document;
|
849
782
|
doc.props.createUserId = userId;
|
850
783
|
doc.props.createUserName = userName;
|
851
784
|
doc.props.createDate = date;
|
852
785
|
}
|
853
|
-
|
854
786
|
/**
|
855
787
|
* 验证文档内容
|
856
788
|
* @returns
|
857
789
|
*/
|
858
|
-
validate()
|
790
|
+
validate() {
|
859
791
|
this.docComment.clearAllValidates();
|
860
792
|
return this.documentChange.validate();
|
861
793
|
}
|
862
|
-
|
863
794
|
/**
|
864
795
|
* 撤销
|
865
796
|
*/
|
866
|
-
undo()
|
797
|
+
undo() {
|
867
798
|
this.docHistory.undo();
|
868
799
|
}
|
869
|
-
|
870
800
|
/**
|
871
801
|
* 恢复
|
872
802
|
*/
|
873
|
-
redo()
|
803
|
+
redo() {
|
874
804
|
this.docHistory.redo();
|
875
805
|
}
|
876
|
-
|
877
806
|
/**
|
878
807
|
* 是否可以撤销
|
879
808
|
*/
|
880
|
-
canUndo()
|
809
|
+
canUndo() {
|
881
810
|
return this.docHistory.canUndo;
|
882
811
|
}
|
883
|
-
|
884
812
|
/**
|
885
813
|
* 是否可以恢复
|
886
814
|
*/
|
887
|
-
canRedo()
|
815
|
+
canRedo() {
|
888
816
|
return this.docHistory.canRedo;
|
889
817
|
}
|
890
|
-
|
891
|
-
switchTrackChanges(eleCtx: BranchElement | null = null): void {
|
818
|
+
switchTrackChanges(eleCtx = null) {
|
892
819
|
eleCtx = eleCtx || this.docCtx.document;
|
893
|
-
const body = eleCtx.treeFind(item => item instanceof DocumentBodyElement)
|
820
|
+
const body = eleCtx.treeFind(item => item instanceof DocumentBodyElement);
|
894
821
|
if (body) {
|
895
822
|
body.trackChanges = !body.trackChanges;
|
896
|
-
}
|
823
|
+
}
|
824
|
+
else {
|
897
825
|
throw new Error('未找到doc-body');
|
898
826
|
}
|
899
827
|
}
|
900
|
-
|
901
828
|
get trackTipsChanged() {
|
902
829
|
return this.documentEvent.trackTipsChanged;
|
903
830
|
}
|
904
|
-
|
905
|
-
switchFullViewPage(): void {
|
831
|
+
switchFullViewPage() {
|
906
832
|
this.viewOptions.fullPageView = !this.viewOptions.fullPageView;
|
907
833
|
}
|
908
|
-
|
909
|
-
getSelectedJSON(): string {
|
834
|
+
getSelectedJSON() {
|
910
835
|
return ElementSerialize.getSelectedJSON(this.selectionState, this.viewOptions);
|
911
836
|
}
|
912
|
-
|
913
|
-
getSelectedText(): string {
|
837
|
+
getSelectedText() {
|
914
838
|
const copySerializeStr = ElementSerialize.getSelectedStruct(this.selectionState, this.viewOptions);
|
915
|
-
return ElementSerialize.serializeString(copySerializeStr
|
839
|
+
return ElementSerialize.serializeString(copySerializeStr);
|
916
840
|
}
|
917
|
-
|
918
841
|
/**
|
919
842
|
* 设置纸张方向
|
920
843
|
* @param orientation
|
921
844
|
*/
|
922
|
-
setPaperOrient(orientation
|
845
|
+
setPaperOrient(orientation) {
|
923
846
|
this.docCtx.document.props.orient = orientation;
|
924
847
|
this.viewOptions.docPageSettings.orient = orientation;
|
925
848
|
this.resetViewer('force');
|
926
849
|
this.selectionState.clear();
|
927
850
|
}
|
928
|
-
|
929
851
|
/**
|
930
852
|
* 设置纸张大小,单位为毫米(mm)
|
931
853
|
* @param width
|
932
854
|
* @param height
|
933
855
|
*/
|
934
|
-
setPaperSize(width
|
856
|
+
setPaperSize(width, height) {
|
935
857
|
const docProps = this.docCtx.document.props;
|
936
858
|
docProps.width = width;
|
937
859
|
docProps.height = height;
|
@@ -940,24 +862,22 @@ export class CanvasTextEditor {
|
|
940
862
|
this.viewOptions.docPageSettings = new PageOptions(width, height, docProps.orient);
|
941
863
|
this.resetViewer('force');
|
942
864
|
}
|
943
|
-
|
944
865
|
/**
|
945
866
|
* 插入强制换页符
|
946
867
|
*/
|
947
|
-
insertPageBreakPara()
|
868
|
+
insertPageBreakPara() {
|
948
869
|
this.documentChange.insertPageBreakPara();
|
949
870
|
}
|
950
|
-
|
951
871
|
/**
|
952
872
|
* 显示当前元素到视图中
|
953
873
|
* @param element
|
954
874
|
*/
|
955
|
-
bringToView(element
|
956
|
-
const ele = element instanceof BranchElement ? ElementUtil.getFirstLeafElement(element) : element
|
875
|
+
bringToView(element) {
|
876
|
+
const ele = element instanceof BranchElement ? ElementUtil.getFirstLeafElement(element) : element;
|
957
877
|
if (ele) {
|
958
878
|
const region = ElementUtil.getElementRegion(ele);
|
959
879
|
const renderObj = ele.paintRenders[0];
|
960
|
-
const docRender = ElementUtil.getParentRender(renderObj, DocumentRenderObject)
|
880
|
+
const docRender = ElementUtil.getParentRender(renderObj, DocumentRenderObject);
|
961
881
|
const index = docRender.getIndex();
|
962
882
|
const cursorPos = DocumentCursor.getElementCursorPos(ele, 0, region, index);
|
963
883
|
this.selectionState.surround(element);
|
@@ -967,17 +887,15 @@ export class CanvasTextEditor {
|
|
967
887
|
this.docScroll.scrollTo(cursorPos.rect.x, cursorPos.rect.y - this.viewOptions.translateY);
|
968
888
|
}
|
969
889
|
}
|
970
|
-
|
971
890
|
/**
|
972
891
|
* 设置当前文档页边距
|
973
892
|
*/
|
974
|
-
setDocumentMargin(pageMargin
|
893
|
+
setDocumentMargin(pageMargin) {
|
975
894
|
if (!this.docCtx.document) {
|
976
895
|
return;
|
977
896
|
}
|
978
897
|
this.docCtx.document.updateMargin(pageMargin);
|
979
898
|
}
|
980
|
-
|
981
899
|
/**
|
982
900
|
* 插入元素
|
983
901
|
* @param targetElement
|
@@ -985,26 +903,11 @@ export class CanvasTextEditor {
|
|
985
903
|
* @param destEleArray
|
986
904
|
* @returns
|
987
905
|
*/
|
988
|
-
insertElement(targetElement
|
906
|
+
insertElement(targetElement, targetOffset, destEleArray) {
|
989
907
|
if (!this.selectionState.editable) {
|
990
908
|
return null;
|
991
909
|
}
|
992
910
|
return this.documentChange.insertElement(targetElement, targetOffset, destEleArray);
|
993
911
|
}
|
994
|
-
|
995
|
-
|
996
912
|
}
|
997
|
-
|
998
|
-
|
999
|
-
export type EditorCurrentPos = {
|
1000
|
-
pos: Position
|
1001
|
-
};
|
1002
|
-
|
1003
|
-
export type EditorContenxtProps = {
|
1004
|
-
menus: Array<ContentMenuItem>
|
1005
|
-
} & EditorCurrentPos
|
1006
|
-
|
1007
|
-
export type EditorPanelProps = {
|
1008
|
-
type: string;
|
1009
|
-
} & EditorCurrentPos;
|
1010
|
-
|
913
|
+
//# sourceMappingURL=texteditor.js.map
|