@hailin-zheng/editor-core 1.0.7 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -4
- package/{lib/doc-ruler.js → src/med_editor/doc-ruler.ts} +101 -74
- package/src/med_editor/framework/common-util.ts +200 -0
- package/{lib/framework/document-change.js → src/med_editor/framework/document-change.ts} +308 -259
- package/{lib/framework/document-combine.js → src/med_editor/framework/document-combine.ts} +15 -11
- package/{lib/framework/document-comment.js → src/med_editor/framework/document-comment.ts} +52 -37
- package/{lib/framework/document-context.js → src/med_editor/framework/document-context.ts} +181 -101
- package/{lib/framework/document-eval-func.js → src/med_editor/framework/document-eval-func.ts} +16 -11
- package/{lib/framework/document-event.js → src/med_editor/framework/document-event.ts} +244 -216
- package/{lib/framework/document-history.js → src/med_editor/framework/document-history.ts} +25 -14
- package/{lib/framework/document-images-loader.js → src/med_editor/framework/document-images-loader.ts} +25 -17
- package/{lib/framework/document-input-cursor.js → src/med_editor/framework/document-input-cursor.ts} +76 -71
- package/{lib/framework/document-paint.js → src/med_editor/framework/document-paint.ts} +35 -28
- package/{lib/framework/document-print-offscreen.js → src/med_editor/framework/document-print-offscreen.ts} +25 -19
- package/{lib/framework/document-print.js → src/med_editor/framework/document-print.ts} +57 -41
- package/src/med_editor/framework/document-segmenter.ts +211 -0
- package/{lib/framework/document-selection.js → src/med_editor/framework/document-selection.ts} +116 -85
- package/{lib/framework/document-template.js → src/med_editor/framework/document-template.ts} +3 -3
- package/src/med_editor/framework/document-textline-mode.ts +34 -0
- package/{lib/framework/element-define.js → src/med_editor/framework/element-define.ts} +301 -206
- package/src/med_editor/framework/element-event-define.ts +141 -0
- package/{lib/framework/element-measure.js → src/med_editor/framework/element-measure.ts} +143 -121
- package/{lib/framework/element-paint.js → src/med_editor/framework/element-paint.ts} +44 -38
- package/{lib/framework/element-props.js → src/med_editor/framework/element-props.ts} +331 -202
- package/{lib/framework/element-reader.js → src/med_editor/framework/element-reader.ts} +39 -31
- package/{lib/framework/element-render-cut.js → src/med_editor/framework/element-render-cut.ts} +113 -106
- package/{lib/framework/element-serialize.js → src/med_editor/framework/element-serialize.ts} +37 -24
- package/{lib/framework/element-util.js → src/med_editor/framework/element-util.ts} +317 -216
- package/{lib/framework/impl/checkbox/checkbox-impl.js → src/med_editor/framework/impl/checkbox/checkbox-impl.ts} +27 -20
- package/{lib/framework/impl/comments/comment-content-impl.js → src/med_editor/framework/impl/comments/comment-content-impl.ts} +45 -31
- package/{lib/framework/impl/comments/comment-element-impl.js → src/med_editor/framework/impl/comments/comment-element-impl.ts} +23 -20
- package/{lib/framework/impl/comments/comments-container-impl.js → src/med_editor/framework/impl/comments/comments-container-impl.ts} +22 -16
- package/{lib/framework/impl/comments/comments-util.js → src/med_editor/framework/impl/comments/comments-util.ts} +34 -17
- package/{lib/framework/impl/comments/validate-msg-impl.js → src/med_editor/framework/impl/comments/validate-msg-impl.ts} +28 -17
- package/{lib/framework/impl/data-element/data-decorate-impl.js → src/med_editor/framework/impl/data-element/data-decorate-impl.ts} +26 -22
- package/{lib/framework/impl/data-element/data-element-barcode.js → src/med_editor/framework/impl/data-element/data-element-barcode.ts} +41 -29
- package/{lib/framework/impl/data-element/data-element-base-impl.js → src/med_editor/framework/impl/data-element/data-element-base-impl.ts} +73 -44
- package/{lib/framework/impl/data-element/data-element-check-impl.js → src/med_editor/framework/impl/data-element/data-element-check-impl.ts} +48 -35
- package/{lib/framework/impl/data-element/data-element-date-impl.js → src/med_editor/framework/impl/data-element/data-element-date-impl.ts} +41 -24
- package/{lib/framework/impl/data-element/data-element-group-impl.js → src/med_editor/framework/impl/data-element/data-element-group-impl.ts} +52 -32
- package/{lib/framework/impl/data-element/data-element-image-impl.js → src/med_editor/framework/impl/data-element/data-element-image-impl.ts} +38 -28
- package/{lib/framework/impl/data-element/data-element-list-impl.js → src/med_editor/framework/impl/data-element/data-element-list-impl.ts} +42 -31
- package/{lib/framework/impl/data-element/data-element-text-impl.js → src/med_editor/framework/impl/data-element/data-element-text-impl.ts} +36 -22
- package/{lib/framework/impl/decorate/fill-null-space-imple.js → src/med_editor/framework/impl/decorate/fill-null-space-imple.ts} +15 -10
- package/{lib/framework/impl/document/doc-body-impl.js → src/med_editor/framework/impl/document/doc-body-impl.ts} +32 -16
- package/{lib/framework/impl/document/doc-body-part-impl.js → src/med_editor/framework/impl/document/doc-body-part-impl.ts} +27 -17
- package/src/med_editor/framework/impl/document/doc-container-impl.ts +24 -0
- package/{lib/framework/impl/document/doc-footer-impl.js → src/med_editor/framework/impl/document/doc-footer-impl.ts} +30 -19
- package/{lib/framework/impl/document/doc-header-impl.js → src/med_editor/framework/impl/document/doc-header-impl.ts} +34 -17
- package/{lib/framework/impl/document/doc-impl.js → src/med_editor/framework/impl/document/doc-impl.ts} +62 -45
- package/{lib/framework/impl/media-formula/menstrual-history.js → src/med_editor/framework/impl/media-formula/menstrual-history.ts} +58 -36
- package/{lib/framework/impl/paragraph/p-impl.js → src/med_editor/framework/impl/paragraph/p-impl.ts} +64 -30
- package/{lib/framework/impl/picture/image-impl.js → src/med_editor/framework/impl/picture/image-impl.ts} +37 -25
- package/{lib/framework/impl/radio/radio-impl.js → src/med_editor/framework/impl/radio/radio-impl.ts} +28 -21
- package/{lib/framework/impl/symbol/br-symbol-impl.js → src/med_editor/framework/impl/symbol/br-symbol-impl.ts} +21 -15
- package/{lib/framework/impl/symbol/p-symbol-impl.js → src/med_editor/framework/impl/symbol/p-symbol-impl.ts} +15 -12
- package/{lib/framework/impl/table/table-cell-impl.js → src/med_editor/framework/impl/table/table-cell-impl.ts} +41 -30
- package/{lib/framework/impl/table/table-impl.js → src/med_editor/framework/impl/table/table-impl.ts} +122 -84
- package/{lib/framework/impl/table/table-row-impl.js → src/med_editor/framework/impl/table/table-row-impl.ts} +26 -18
- package/{lib/framework/impl/table/table-split-cell-patch.js → src/med_editor/framework/impl/table/table-split-cell-patch.ts} +31 -22
- package/{lib/framework/impl/table/table-split-cell.js → src/med_editor/framework/impl/table/table-split-cell.ts} +105 -94
- package/{lib/framework/impl/table/table-util.js → src/med_editor/framework/impl/table/table-util.ts} +197 -159
- package/{lib/framework/impl/text/text-impl.js → src/med_editor/framework/impl/text/text-impl.ts} +49 -35
- package/{lib/framework/impl/text/track-run-impl.js → src/med_editor/framework/impl/text/track-run-impl.ts} +53 -30
- package/{lib/framework/notify.js → src/med_editor/framework/notify.ts} +50 -36
- package/{lib/framework/range-util.js → src/med_editor/framework/range-util.ts} +80 -71
- package/{lib/framework/render-context.js → src/med_editor/framework/render-context.ts} +111 -64
- package/{lib/framework/render-define.js → src/med_editor/framework/render-define.ts} +90 -61
- package/{lib/framework/selection-overlays.js → src/med_editor/framework/selection-overlays.ts} +25 -16
- package/{lib/texteditor.js → src/med_editor/texteditor.ts} +288 -191
- package/src/med_editor/util/subject.ts +118 -0
- package/{lib/util/table-bind.js → src/med_editor/util/table-bind.ts} +2 -2
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225.json +3573 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225.json +3573 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225bug.json +315 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/346/211/271/346/263/250.json +122 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/346/226/207/346/241/243/351/252/214/350/257/201.json +3599 -0
- package/src/med_editor//345/205/245/351/231/242/350/256/260/345/275/225/346/265/213/350/257/225/351/225/277/346/226/207/346/234/254.json +24586 -0
- package/src/med_editor//345/220/210/345/271/266/347/227/205/347/250/213/345/275/225.json +2874 -0
- package/src/med_editor//346/211/213/346/234/257/350/256/260/345/275/225.json +341 -0
- package/src/med_editor//346/231/256/351/200/232doc/347/261/273/346/226/207/346/241/243.json +2201 -0
- package/src/med_editor//346/243/200/351/252/214/347/224/263/350/257/267/345/215/225.json +1069 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//345/206/205/351/225/234/344/270/213/346/262/273/347/226/227/350/256/260/345/275/225.json +125 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//345/220/210/345/271/266/347/227/205/347/250/213/345/275/225/346/250/241/346/235/277.json +86 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//346/227/245/345/270/270/347/227/205/347/250/213/350/256/260/345/275/225.json +115 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//346/237/245/346/210/277/350/256/260/345/275/2251.json +108 -0
- package/src/med_editor//347/227/205/347/250/213/345/275/225//351/246/226/346/254/241/344/270/212/347/272/247/345/214/273/345/270/210/346/237/245/346/210/277/350/256/260/345/275/225.json +272 -0
- package/src/med_editor//351/225/277/346/234/237/345/214/273/345/230/261/345/215/225.json +1070 -0
- package/lib/doc-ruler.d.ts +0 -51
- package/lib/doc-ruler.js.map +0 -1
- package/lib/framework/common-util.d.ts +0 -63
- package/lib/framework/common-util.js +0 -178
- package/lib/framework/common-util.js.map +0 -1
- package/lib/framework/document-change.d.ts +0 -265
- package/lib/framework/document-change.js.map +0 -1
- package/lib/framework/document-combine.d.ts +0 -24
- package/lib/framework/document-combine.js.map +0 -1
- package/lib/framework/document-comment.d.ts +0 -46
- package/lib/framework/document-comment.js.map +0 -1
- package/lib/framework/document-context.d.ts +0 -149
- package/lib/framework/document-context.js.map +0 -1
- package/lib/framework/document-eval-func.d.ts +0 -18
- package/lib/framework/document-eval-func.js.map +0 -1
- package/lib/framework/document-event.d.ts +0 -213
- package/lib/framework/document-event.js.map +0 -1
- package/lib/framework/document-history.d.ts +0 -26
- package/lib/framework/document-history.js.map +0 -1
- package/lib/framework/document-images-loader.d.ts +0 -16
- package/lib/framework/document-images-loader.js.map +0 -1
- package/lib/framework/document-input-cursor.d.ts +0 -78
- package/lib/framework/document-input-cursor.js.map +0 -1
- package/lib/framework/document-paint.d.ts +0 -34
- package/lib/framework/document-paint.js.map +0 -1
- package/lib/framework/document-print-offscreen.d.ts +0 -38
- package/lib/framework/document-print-offscreen.js.map +0 -1
- package/lib/framework/document-print.d.ts +0 -60
- package/lib/framework/document-print.js.map +0 -1
- package/lib/framework/document-segmenter.d.ts +0 -2
- package/lib/framework/document-segmenter.js +0 -106
- package/lib/framework/document-segmenter.js.map +0 -1
- package/lib/framework/document-selection.d.ts +0 -89
- package/lib/framework/document-selection.js.map +0 -1
- package/lib/framework/document-template.d.ts +0 -4
- package/lib/framework/document-template.js.map +0 -1
- package/lib/framework/document-textline-mode.d.ts +0 -7
- package/lib/framework/document-textline-mode.js +0 -30
- package/lib/framework/document-textline-mode.js.map +0 -1
- package/lib/framework/element-define.d.ts +0 -319
- package/lib/framework/element-define.js.map +0 -1
- package/lib/framework/element-event-define.d.ts +0 -99
- package/lib/framework/element-event-define.js +0 -108
- package/lib/framework/element-event-define.js.map +0 -1
- package/lib/framework/element-measure.d.ts +0 -97
- package/lib/framework/element-measure.js.map +0 -1
- package/lib/framework/element-paint.d.ts +0 -42
- package/lib/framework/element-paint.js.map +0 -1
- package/lib/framework/element-props.d.ts +0 -301
- package/lib/framework/element-props.js.map +0 -1
- package/lib/framework/element-reader.d.ts +0 -19
- package/lib/framework/element-reader.js.map +0 -1
- package/lib/framework/element-render-cut.d.ts +0 -55
- package/lib/framework/element-render-cut.js.map +0 -1
- package/lib/framework/element-serialize.d.ts +0 -30
- package/lib/framework/element-serialize.js.map +0 -1
- package/lib/framework/element-util.d.ts +0 -369
- package/lib/framework/element-util.js.map +0 -1
- package/lib/framework/impl/checkbox/checkbox-impl.d.ts +0 -24
- package/lib/framework/impl/checkbox/checkbox-impl.js.map +0 -1
- package/lib/framework/impl/comments/comment-content-impl.d.ts +0 -40
- package/lib/framework/impl/comments/comment-content-impl.js.map +0 -1
- package/lib/framework/impl/comments/comment-element-impl.d.ts +0 -21
- package/lib/framework/impl/comments/comment-element-impl.js.map +0 -1
- package/lib/framework/impl/comments/comments-container-impl.d.ts +0 -22
- package/lib/framework/impl/comments/comments-container-impl.js.map +0 -1
- package/lib/framework/impl/comments/comments-util.d.ts +0 -12
- package/lib/framework/impl/comments/comments-util.js.map +0 -1
- package/lib/framework/impl/comments/validate-msg-impl.d.ts +0 -21
- package/lib/framework/impl/comments/validate-msg-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-decorate-impl.d.ts +0 -30
- package/lib/framework/impl/data-element/data-decorate-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-barcode.d.ts +0 -31
- package/lib/framework/impl/data-element/data-element-barcode.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-base-impl.d.ts +0 -68
- package/lib/framework/impl/data-element/data-element-base-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-check-impl.d.ts +0 -35
- package/lib/framework/impl/data-element/data-element-check-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-date-impl.d.ts +0 -23
- package/lib/framework/impl/data-element/data-element-date-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-group-impl.d.ts +0 -23
- package/lib/framework/impl/data-element/data-element-group-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-image-impl.d.ts +0 -30
- package/lib/framework/impl/data-element/data-element-image-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-list-impl.d.ts +0 -22
- package/lib/framework/impl/data-element/data-element-list-impl.js.map +0 -1
- package/lib/framework/impl/data-element/data-element-text-impl.d.ts +0 -23
- package/lib/framework/impl/data-element/data-element-text-impl.js.map +0 -1
- package/lib/framework/impl/decorate/fill-null-space-imple.d.ts +0 -21
- package/lib/framework/impl/decorate/fill-null-space-imple.js.map +0 -1
- package/lib/framework/impl/document/doc-body-impl.d.ts +0 -27
- package/lib/framework/impl/document/doc-body-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-body-part-impl.d.ts +0 -30
- package/lib/framework/impl/document/doc-body-part-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-container-impl.d.ts +0 -16
- package/lib/framework/impl/document/doc-container-impl.js +0 -21
- package/lib/framework/impl/document/doc-container-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-footer-impl.d.ts +0 -26
- package/lib/framework/impl/document/doc-footer-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-header-impl.d.ts +0 -26
- package/lib/framework/impl/document/doc-header-impl.js.map +0 -1
- package/lib/framework/impl/document/doc-impl.d.ts +0 -61
- package/lib/framework/impl/document/doc-impl.js.map +0 -1
- package/lib/framework/impl/media-formula/menstrual-history.d.ts +0 -35
- package/lib/framework/impl/media-formula/menstrual-history.js.map +0 -1
- package/lib/framework/impl/paragraph/p-impl.d.ts +0 -45
- package/lib/framework/impl/paragraph/p-impl.js.map +0 -1
- package/lib/framework/impl/picture/image-impl.d.ts +0 -31
- package/lib/framework/impl/picture/image-impl.js.map +0 -1
- package/lib/framework/impl/radio/radio-impl.d.ts +0 -22
- package/lib/framework/impl/radio/radio-impl.js.map +0 -1
- package/lib/framework/impl/symbol/br-symbol-impl.d.ts +0 -22
- package/lib/framework/impl/symbol/br-symbol-impl.js.map +0 -1
- package/lib/framework/impl/symbol/p-symbol-impl.d.ts +0 -19
- package/lib/framework/impl/symbol/p-symbol-impl.js.map +0 -1
- package/lib/framework/impl/table/table-cell-impl.d.ts +0 -37
- package/lib/framework/impl/table/table-cell-impl.js.map +0 -1
- package/lib/framework/impl/table/table-impl.d.ts +0 -55
- package/lib/framework/impl/table/table-impl.js.map +0 -1
- package/lib/framework/impl/table/table-row-impl.d.ts +0 -26
- package/lib/framework/impl/table/table-row-impl.js.map +0 -1
- package/lib/framework/impl/table/table-split-cell-patch.d.ts +0 -20
- package/lib/framework/impl/table/table-split-cell-patch.js.map +0 -1
- package/lib/framework/impl/table/table-split-cell.d.ts +0 -90
- package/lib/framework/impl/table/table-split-cell.js.map +0 -1
- package/lib/framework/impl/table/table-util.d.ts +0 -150
- package/lib/framework/impl/table/table-util.js.map +0 -1
- package/lib/framework/impl/text/text-impl.d.ts +0 -32
- package/lib/framework/impl/text/text-impl.js.map +0 -1
- package/lib/framework/impl/text/track-run-impl.d.ts +0 -27
- package/lib/framework/impl/text/track-run-impl.js.map +0 -1
- package/lib/framework/notify.d.ts +0 -13
- package/lib/framework/notify.js.map +0 -1
- package/lib/framework/range-util.d.ts +0 -40
- package/lib/framework/range-util.js.map +0 -1
- package/lib/framework/render-context.d.ts +0 -91
- package/lib/framework/render-context.js.map +0 -1
- package/lib/framework/render-define.d.ts +0 -109
- package/lib/framework/render-define.js.map +0 -1
- package/lib/framework/selection-overlays.d.ts +0 -30
- package/lib/framework/selection-overlays.js.map +0 -1
- package/lib/texteditor.d.ts +0 -318
- package/lib/texteditor.js.map +0 -1
- package/lib/util/subject.d.ts +0 -34
- package/lib/util/subject.js +0 -88
- package/lib/util/subject.js.map +0 -1
- package/lib/util/table-bind.d.ts +0 -5
- package/lib/util/table-bind.js.map +0 -1
- package/tsconfig.json +0 -25
package/{lib/framework/impl/text/text-impl.js → src/med_editor/framework/impl/text/text-impl.ts}
RENAMED
@@ -1,13 +1,16 @@
|
|
1
|
-
import { SelectionRange } from "
|
2
|
-
import {
|
3
|
-
import {
|
4
|
-
import {
|
5
|
-
import {
|
1
|
+
import { SelectionRange } from "../../document-selection";
|
2
|
+
import { ContextMenuElementEvent } from "../../element-event-define";
|
3
|
+
import { TextProps } from "../../element-props";
|
4
|
+
import { ElementUtil } from "../../element-util";
|
5
|
+
import { LeafRenderObject, RenderObject } from "../../render-define";
|
6
|
+
import { LeafElement, ElementFactory, Element, SerializeProps, ViewOptions, ModifyFlag } from "../../element-define";
|
6
7
|
import { watchChanged } from "../../notify";
|
7
|
-
|
8
|
+
import { RenderContenxtType, TextUnits } from "../../render-context";
|
9
|
+
|
10
|
+
export class TextGroupElement extends LeafElement<TextProps> {
|
8
11
|
//props: TextProps;
|
9
|
-
textMeasures = [];
|
10
|
-
isMeasure = false;
|
12
|
+
textMeasures: Array<TextUnits> = [];
|
13
|
+
isMeasure: boolean = false;
|
11
14
|
constructor() {
|
12
15
|
super('text');
|
13
16
|
this.props = new TextProps();
|
@@ -17,7 +20,7 @@ export class TextGroupElement extends LeafElement {
|
|
17
20
|
});
|
18
21
|
//this.addPropValueChangedSub(this.props);
|
19
22
|
//this.addsubscribe(this, this.props.onPropertyChangedSubject.subscribe(() => { this.clearTextCache() }));
|
20
|
-
this.addEvent('ElementContextMenu', (evt) => {
|
23
|
+
this.addEvent<ContextMenuElementEvent>('ElementContextMenu', (evt) => {
|
21
24
|
const ss = evt.selectionState;
|
22
25
|
evt.menus.push({
|
23
26
|
icon: "EditStyle", caption: "选中样式组合", eventObj: {
|
@@ -28,28 +31,30 @@ export class TextGroupElement extends LeafElement {
|
|
28
31
|
ss.addRange(range);
|
29
32
|
}
|
30
33
|
}
|
31
|
-
})
|
34
|
+
})
|
32
35
|
});
|
33
36
|
}
|
34
|
-
set text(val) {
|
37
|
+
set text(val: string) {
|
35
38
|
this.splice(0, this.textMeasures.length, val);
|
36
39
|
}
|
37
|
-
|
40
|
+
|
41
|
+
splice(index: number, deleteCount: number, addText: string | null = null): void {
|
38
42
|
this.isMeasure = false;
|
39
43
|
addText = addText ?? '';
|
40
44
|
const addTextUnits = addText.split('').map(char => ({ sourceSize: 0, actualSize: 0, char }));
|
41
45
|
if (this.textMeasures.length === 0) {
|
42
46
|
this.textMeasures = addTextUnits;
|
43
|
-
}
|
44
|
-
else {
|
47
|
+
} else {
|
45
48
|
this.textMeasures.splice(index, deleteCount, ...addTextUnits);
|
46
49
|
}
|
47
50
|
this.pubOnChange('self');
|
48
51
|
}
|
52
|
+
|
49
53
|
get text() {
|
50
54
|
return this.textMeasures.map(item => item.char).join('');
|
51
55
|
}
|
52
|
-
|
56
|
+
|
57
|
+
createRenderObject(options: ViewOptions, renderCtx: RenderContenxtType): RenderObject {
|
53
58
|
if (!this.isMeasure || this.modifyFlag !== ModifyFlag.None) {
|
54
59
|
renderCtx.contentContext.measureTextUnits(this.textMeasures, this.props);
|
55
60
|
this.isMeasure = true;
|
@@ -60,7 +65,8 @@ export class TextGroupElement extends LeafElement {
|
|
60
65
|
render.measure();
|
61
66
|
return render;
|
62
67
|
}
|
63
|
-
|
68
|
+
|
69
|
+
serialize(viewOptions: ViewOptions): SerializeProps & any {
|
64
70
|
//修饰元素不序列化
|
65
71
|
if (this.isDecorate) {
|
66
72
|
return null;
|
@@ -72,18 +78,21 @@ export class TextGroupElement extends LeafElement {
|
|
72
78
|
},
|
73
79
|
content: this.text,
|
74
80
|
complete: true
|
75
|
-
}
|
81
|
+
}
|
76
82
|
}
|
77
|
-
|
83
|
+
|
84
|
+
clone(data: boolean): TextGroupElement {
|
78
85
|
const clone = new TextGroupElement();
|
79
86
|
this.props.clone(clone.props);
|
80
87
|
clone.text = this.text;
|
81
88
|
return clone;
|
82
89
|
}
|
83
|
-
|
90
|
+
|
91
|
+
destroy(): void {
|
84
92
|
super.destroy();
|
85
93
|
}
|
86
|
-
|
94
|
+
|
95
|
+
spliceText(startOffset: number, endOffset: number, xCopy: boolean): TextGroupElement | null {
|
87
96
|
endOffset = endOffset === -1 ? this.textMeasures.length : endOffset;
|
88
97
|
if (endOffset === startOffset) {
|
89
98
|
return null;
|
@@ -92,20 +101,22 @@ export class TextGroupElement extends LeafElement {
|
|
92
101
|
this.props.clone(clone.props);
|
93
102
|
if (xCopy) {
|
94
103
|
clone.textMeasures = this.textMeasures.splice(startOffset, endOffset - startOffset);
|
95
|
-
}
|
96
|
-
else {
|
104
|
+
} else {
|
97
105
|
clone.textMeasures = this.textMeasures.filter((item, index) => index >= startOffset && index < endOffset);
|
98
106
|
}
|
99
107
|
clone.textMeasures = clone.textMeasures.map(item => ({ sourceSize: 0, actualSize: 0, char: item.char }));
|
100
108
|
return clone;
|
101
109
|
}
|
102
|
-
|
110
|
+
|
111
|
+
clearTextCache(): void {
|
103
112
|
this.isMeasure = false;
|
104
113
|
}
|
105
114
|
}
|
106
|
-
|
107
|
-
|
108
|
-
|
115
|
+
|
116
|
+
|
117
|
+
export class TextGroupRenderObject extends LeafRenderObject<TextGroupElement> {
|
118
|
+
textMeasures!: Array<TextUnits>;
|
119
|
+
render(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
109
120
|
//null-text不打印
|
110
121
|
if (ctx.drawMode === 'print' && this.element.isDecorate) {
|
111
122
|
return;
|
@@ -117,33 +128,36 @@ export class TextGroupRenderObject extends LeafRenderObject {
|
|
117
128
|
// if (this.element.isMouseenter) {
|
118
129
|
// ctx.overlaysContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, CommonUtil.randomColor());
|
119
130
|
// }
|
131
|
+
|
120
132
|
}
|
121
|
-
constructor(element) {
|
133
|
+
constructor(element: TextGroupElement) {
|
122
134
|
super(element);
|
123
135
|
}
|
124
|
-
clone() {
|
136
|
+
clone(): RenderObject {
|
125
137
|
const cloneRender = new TextGroupRenderObject(this.element);
|
126
138
|
cloneRender.disableClick = this.disableClick;
|
127
139
|
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
128
140
|
cloneRender.textMeasures = [...this.textMeasures];
|
129
141
|
return cloneRender;
|
130
142
|
}
|
131
|
-
|
143
|
+
|
144
|
+
measure(): void {
|
132
145
|
this.rect.width = this.textMeasures.reduce((prev, curr) => prev + curr.actualSize, 0);
|
133
146
|
this.rect.height = this.element.props.fontSize;
|
134
147
|
}
|
135
148
|
}
|
136
|
-
|
137
|
-
|
149
|
+
|
150
|
+
export class TextGroupFactory extends ElementFactory<null> {
|
151
|
+
match(type: string): boolean {
|
138
152
|
return type === 'text';
|
139
153
|
}
|
140
|
-
createElement(data, renderCtx) {
|
141
|
-
const props = data.props;
|
142
|
-
const text = data.content;
|
154
|
+
createElement(data: any, renderCtx: RenderContenxtType): Element {
|
155
|
+
const props = data.props as TextProps;
|
156
|
+
const text = data.content as string;
|
143
157
|
const textGroup = new TextGroupElement();
|
144
158
|
textGroup.text = text;
|
145
159
|
ElementUtil.readTextProps(textGroup.props, props, this.options);
|
146
160
|
return textGroup;
|
147
161
|
}
|
162
|
+
|
148
163
|
}
|
149
|
-
//# sourceMappingURL=text-impl.js.map
|
@@ -1,31 +1,42 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
import {
|
2
|
+
InlineGroupElement,
|
3
|
+
Position,
|
4
|
+
SerializeProps,
|
5
|
+
ViewOptions,
|
6
|
+
Element,
|
7
|
+
ElementFactory, readElementProps
|
8
|
+
} from "../../element-define";
|
9
|
+
import { RenderContenxtType } from "../../render-context";
|
10
|
+
import { InlineGroupRenderObject, RenderObject } from "../../render-define";
|
11
|
+
import { TrackRunProps } from "../../element-props";
|
12
|
+
import { ElementUtil } from "../../element-util";
|
5
13
|
import { ElementSerialize } from "../../element-serialize";
|
14
|
+
import { GetTrackTipsEvent } from "../../element-event-define";
|
6
15
|
import { nanoid } from "nanoid";
|
7
|
-
export
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
export class TrackRunElement extends InlineGroupElement {
|
13
|
-
constructor(trackType) {
|
16
|
+
export enum TrackRunTypeEnum {
|
17
|
+
Inserted = 'ins-run',
|
18
|
+
Deleted = 'del-run',
|
19
|
+
}
|
20
|
+
type NullableType<T> = T | null;
|
21
|
+
export class TrackRunElement extends InlineGroupElement<TrackRunProps> {
|
22
|
+
constructor(trackType: TrackRunTypeEnum) {
|
14
23
|
super(trackType);
|
15
24
|
this.props = new TrackRunProps(trackType);
|
16
|
-
this.addEvent('GetTrackTips', (evt) => {
|
25
|
+
this.addEvent<GetTrackTipsEvent>('GetTrackTips', (evt) => {
|
17
26
|
evt.trackTips = {
|
18
|
-
trackRunType: this.type,
|
27
|
+
trackRunType: this.type as TrackRunTypeEnum,
|
19
28
|
name: this.props.userName,
|
20
29
|
date: this.props.date,
|
21
30
|
content: ElementSerialize.serializeString(this, { all: true })
|
22
31
|
};
|
23
32
|
console.log(evt.trackTips.content);
|
33
|
+
|
24
34
|
evt.isCancel = true;
|
25
35
|
});
|
26
36
|
}
|
27
|
-
|
28
|
-
|
37
|
+
|
38
|
+
clone(data: boolean): Element {
|
39
|
+
const clone = new TrackRunElement(this.type as TrackRunTypeEnum);
|
29
40
|
this.props.clone(clone.props);
|
30
41
|
if (data) {
|
31
42
|
const length = this.length;
|
@@ -35,25 +46,28 @@ export class TrackRunElement extends InlineGroupElement {
|
|
35
46
|
}
|
36
47
|
return clone;
|
37
48
|
}
|
38
|
-
|
49
|
+
|
50
|
+
createRenderObject(options: ViewOptions, renderCtx: RenderContenxtType): NullableType<RenderObject> {
|
39
51
|
if (!options.showTrackChanges && this.type === TrackRunTypeEnum.Deleted) {
|
40
52
|
return null;
|
41
53
|
}
|
42
54
|
return new TrackRunRenderObject(this);
|
43
55
|
}
|
44
|
-
|
56
|
+
|
57
|
+
serialize(viewOptions: ViewOptions): SerializeProps | null {
|
45
58
|
return {
|
46
59
|
type: this.type,
|
47
60
|
props: this.props.getSerializeProps()
|
48
61
|
};
|
49
62
|
}
|
50
|
-
|
63
|
+
|
64
|
+
split(index: number): TrackRunElement | null {
|
51
65
|
if (index === 0 || index === this.length) {
|
52
66
|
return null;
|
53
67
|
}
|
54
|
-
const clone = new TrackRunElement(this.type);
|
68
|
+
const clone = new TrackRunElement(this.type as TrackRunTypeEnum);
|
55
69
|
this.props.clone(clone.props);
|
56
|
-
const items = [];
|
70
|
+
const items: Array<Element> = [];
|
57
71
|
for (let i = index; i < this.length; i++) {
|
58
72
|
const child = this.getChild(i);
|
59
73
|
items.push(child);
|
@@ -65,15 +79,18 @@ export class TrackRunElement extends InlineGroupElement {
|
|
65
79
|
return clone;
|
66
80
|
}
|
67
81
|
}
|
68
|
-
|
69
|
-
|
82
|
+
|
83
|
+
export class TrackRunRenderObject extends InlineGroupRenderObject<TrackRunElement> {
|
84
|
+
constructor(ele: TrackRunElement) {
|
70
85
|
super(ele);
|
71
86
|
}
|
72
|
-
|
87
|
+
|
88
|
+
beginRender(ctx: RenderContenxtType, position: Position): void {
|
73
89
|
const color = this.element.type === 'ins-run' ? 'green' : 'red';
|
74
90
|
//ctx.overlaysContext.strokeRect(position.x, position.y, this.rect.width, this.rect.height, color);
|
75
91
|
}
|
76
|
-
|
92
|
+
|
93
|
+
clone(): RenderObject {
|
77
94
|
const cloneRender = new TrackRunRenderObject(this.element);
|
78
95
|
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
79
96
|
for (let i = 0; i < this.length; i++) {
|
@@ -81,7 +98,8 @@ export class TrackRunRenderObject extends InlineGroupRenderObject {
|
|
81
98
|
}
|
82
99
|
return cloneRender;
|
83
100
|
}
|
84
|
-
|
101
|
+
|
102
|
+
endRender(ctx: RenderContenxtType, position: Position): void {
|
85
103
|
const { x, y } = position;
|
86
104
|
const color = this.element.type === 'ins-run' ? 'green' : 'red';
|
87
105
|
for (let i = 0; i < this.length; i++) {
|
@@ -96,17 +114,22 @@ export class TrackRunRenderObject extends InlineGroupRenderObject {
|
|
96
114
|
}
|
97
115
|
}
|
98
116
|
}
|
99
|
-
|
100
|
-
|
101
|
-
|
117
|
+
|
118
|
+
export class RunElementFactory extends ElementFactory<TrackRunProps>{
|
119
|
+
|
120
|
+
createElement(data: readElementProps<TrackRunProps>, renderCtx: RenderContenxtType): TrackRunElement {
|
121
|
+
const ele = new TrackRunElement(data.type as TrackRunTypeEnum);
|
102
122
|
ele.props.userId = data.props?.userId ?? '';
|
103
123
|
ele.props.userName = data.props?.userName ?? '';
|
104
124
|
ele.props.date = data.props?.date ?? '';
|
105
125
|
ele.props.id = data.props?.id ?? nanoid(5);
|
106
126
|
return ele;
|
107
127
|
}
|
108
|
-
|
128
|
+
|
129
|
+
match(type: string): boolean {
|
109
130
|
return type === TrackRunTypeEnum.Inserted || type === TrackRunTypeEnum.Deleted;
|
110
131
|
}
|
132
|
+
|
133
|
+
|
111
134
|
}
|
112
|
-
|
135
|
+
|
@@ -1,24 +1,31 @@
|
|
1
1
|
const EDITOR_REACTIVE = '__editor_reactive';
|
2
|
-
const ITERATOR_KEY = Symbol('iterator-key')
|
3
|
-
export const reactiveMap = new WeakMap();
|
4
|
-
export const targetMaps = new WeakMap();
|
5
|
-
|
6
|
-
|
2
|
+
const ITERATOR_KEY = Symbol('iterator-key')
|
3
|
+
export const reactiveMap = new WeakMap<object, object>();
|
4
|
+
export const targetMaps = new WeakMap<object, Map<propType, Set<notifyCallback>>>();
|
5
|
+
type propType = string | number | symbol;
|
6
|
+
interface notifyCallback {
|
7
|
+
(target: object, p: propType, oldValue: any, newValue: any): string | undefined | void;
|
8
|
+
}
|
9
|
+
|
10
|
+
|
11
|
+
const activeFns: Array<notifyCallback> = [];
|
12
|
+
function track(target: object, p: propType) {
|
7
13
|
const activeFn = activeFns[activeFns.length - 1];
|
8
14
|
if (!activeFn) {
|
9
15
|
return;
|
10
16
|
}
|
11
|
-
let targetMap = targetMaps.get(target)
|
17
|
+
let targetMap = targetMaps.get(target)
|
12
18
|
if (!targetMap) {
|
13
|
-
targetMaps.set(target, (targetMap = new Map()))
|
19
|
+
targetMaps.set(target, (targetMap = new Map()))
|
14
20
|
}
|
15
21
|
let effectFns = targetMap.get(p);
|
16
22
|
if (!effectFns) {
|
17
|
-
targetMap.set(p, (effectFns = new Set()))
|
23
|
+
targetMap.set(p, (effectFns = new Set()))
|
18
24
|
}
|
19
|
-
effectFns.add(activeFn)
|
25
|
+
effectFns.add(activeFn)
|
20
26
|
}
|
21
|
-
|
27
|
+
|
28
|
+
function trigger(target: object, p: propType, oldValue: any, newValue: any): void {
|
22
29
|
//不需要触发
|
23
30
|
if (p.toString().startsWith('__')) {
|
24
31
|
return;
|
@@ -29,21 +36,22 @@ function trigger(target, p, oldValue, newValue) {
|
|
29
36
|
}
|
30
37
|
const effectFns = targetMap.get(p);
|
31
38
|
const iteratorFns = targetMap.get(ITERATOR_KEY);
|
32
|
-
const fns = new Set();
|
39
|
+
const fns = new Set<notifyCallback>();
|
33
40
|
effectFns && effectFns.forEach(item => fns.add(item));
|
34
41
|
iteratorFns && iteratorFns.forEach(item => fns.add(item));
|
35
42
|
const activeFn = activeFns[activeFns.length - 1];
|
36
43
|
//防止死循环,过滤正在运行的副作用
|
37
44
|
if (activeFn) {
|
38
|
-
fns.delete(activeFn)
|
45
|
+
fns.delete(activeFn)
|
39
46
|
}
|
40
47
|
fns.forEach(fn => {
|
41
|
-
fn(target, p, oldValue, newValue)
|
48
|
+
fn(target, p, oldValue, newValue)
|
42
49
|
});
|
43
50
|
}
|
44
|
-
|
45
|
-
|
46
|
-
|
51
|
+
|
52
|
+
export function watchChanged<T extends object>(source: T, cb: notifyCallback): T {
|
53
|
+
if ((<any>source)[EDITOR_REACTIVE]) {
|
54
|
+
addToTrack((<any>source)['raw'], source, cb);
|
47
55
|
return source;
|
48
56
|
}
|
49
57
|
if (isDate(source)) {
|
@@ -51,7 +59,7 @@ export function watchChanged(source, cb) {
|
|
51
59
|
}
|
52
60
|
const existProxy = reactiveMap.get(source);
|
53
61
|
if (existProxy) {
|
54
|
-
return existProxy;
|
62
|
+
return existProxy as T;
|
55
63
|
}
|
56
64
|
const proxy = new Proxy(source, {
|
57
65
|
get(target, p, receiver) {
|
@@ -61,7 +69,7 @@ export function watchChanged(source, cb) {
|
|
61
69
|
if (p === EDITOR_REACTIVE) {
|
62
70
|
return true;
|
63
71
|
}
|
64
|
-
const res = Reflect.get(target, p, receiver)
|
72
|
+
const res = Reflect.get(target, p, receiver)
|
65
73
|
if (typeof res === 'object' && res) {
|
66
74
|
return watchChanged(res, cb);
|
67
75
|
}
|
@@ -69,9 +77,9 @@ export function watchChanged(source, cb) {
|
|
69
77
|
},
|
70
78
|
set(target, p, newValue, receiver) {
|
71
79
|
//console.log('设置' + p.toString())
|
72
|
-
const oldValue = target[p];
|
80
|
+
const oldValue = (<any>target)[p];
|
73
81
|
const res = Reflect.set(target, p, newValue, receiver);
|
74
|
-
if (receiver.raw === target) {
|
82
|
+
if ((<any>receiver).raw === target) {
|
75
83
|
if (oldValue !== newValue && (oldValue === oldValue || newValue === newValue)) {
|
76
84
|
trigger(target, p, oldValue, newValue);
|
77
85
|
}
|
@@ -84,33 +92,39 @@ export function watchChanged(source, cb) {
|
|
84
92
|
return res;
|
85
93
|
},
|
86
94
|
defineProperty(target, p, attributes) {
|
87
|
-
const res = Reflect.defineProperty(target, p, attributes)
|
95
|
+
const res = Reflect.defineProperty(target, p, attributes)
|
88
96
|
trigger(target, p, null, null);
|
89
97
|
return res;
|
90
98
|
}
|
91
|
-
})
|
99
|
+
})
|
92
100
|
addToTrack(source, proxy, cb);
|
93
101
|
return proxy;
|
94
102
|
}
|
95
|
-
|
103
|
+
|
104
|
+
function addToTrack(source: object, proxy: object, cb: notifyCallback): void {
|
96
105
|
activeFns.push(cb);
|
97
106
|
track(source, ITERATOR_KEY);
|
98
107
|
activeFns.pop();
|
99
108
|
reactiveMap.set(source, proxy);
|
100
109
|
}
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
110
|
+
|
111
|
+
|
112
|
+
export function setNotifyChangedCallback(target: object, p: propType, cb: notifyCallback): void {
|
113
|
+
let trackTarget: any = target;
|
114
|
+
if ((<any>target)[EDITOR_REACTIVE]) {
|
115
|
+
trackTarget = (<any>target)['raw'];
|
105
116
|
}
|
106
|
-
activeFns.push(cb)
|
117
|
+
activeFns.push(cb)
|
107
118
|
track(trackTarget, p);
|
108
|
-
activeFns.pop()
|
119
|
+
activeFns.pop()
|
120
|
+
}
|
121
|
+
|
122
|
+
export const isDate = (val: unknown): val is Date => val instanceof Date
|
123
|
+
|
124
|
+
export const objectToString = Object.prototype.toString
|
125
|
+
export const toTypeString = (value: unknown): string =>
|
126
|
+
objectToString.call(value)
|
127
|
+
|
128
|
+
export const toRawType = (value: unknown): string => {
|
129
|
+
return toTypeString(value).slice(8, -1)
|
109
130
|
}
|
110
|
-
export const isDate = (val) => val instanceof Date;
|
111
|
-
export const objectToString = Object.prototype.toString;
|
112
|
-
export const toTypeString = (value) => objectToString.call(value);
|
113
|
-
export const toRawType = (value) => {
|
114
|
-
return toTypeString(value).slice(8, -1);
|
115
|
-
};
|
116
|
-
//# sourceMappingURL=notify.js.map
|