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