@hailin-zheng/editor-core 1.0.3 → 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/package.json +6 -2
- package/dist/doc-ruler.d.ts +0 -51
- package/dist/doc-ruler.js +0 -313
- package/dist/doc-ruler.js.map +0 -1
- package/dist/framework/common-util.d.ts +0 -63
- package/dist/framework/common-util.js +0 -178
- package/dist/framework/common-util.js.map +0 -1
- package/dist/framework/document-change.d.ts +0 -265
- package/dist/framework/document-change.js +0 -1342
- package/dist/framework/document-change.js.map +0 -1
- package/dist/framework/document-combine.d.ts +0 -24
- package/dist/framework/document-combine.js +0 -40
- package/dist/framework/document-combine.js.map +0 -1
- package/dist/framework/document-comment.d.ts +0 -46
- package/dist/framework/document-comment.js +0 -148
- package/dist/framework/document-comment.js.map +0 -1
- package/dist/framework/document-context.d.ts +0 -149
- package/dist/framework/document-context.js +0 -330
- package/dist/framework/document-context.js.map +0 -1
- package/dist/framework/document-eval-func.d.ts +0 -18
- package/dist/framework/document-eval-func.js +0 -48
- package/dist/framework/document-eval-func.js.map +0 -1
- package/dist/framework/document-event.d.ts +0 -213
- package/dist/framework/document-event.js +0 -1054
- package/dist/framework/document-event.js.map +0 -1
- package/dist/framework/document-history.d.ts +0 -26
- package/dist/framework/document-history.js +0 -65
- package/dist/framework/document-history.js.map +0 -1
- package/dist/framework/document-images-loader.d.ts +0 -16
- package/dist/framework/document-images-loader.js +0 -66
- package/dist/framework/document-images-loader.js.map +0 -1
- package/dist/framework/document-input-cursor.d.ts +0 -78
- package/dist/framework/document-input-cursor.js +0 -239
- package/dist/framework/document-input-cursor.js.map +0 -1
- package/dist/framework/document-paint.d.ts +0 -34
- package/dist/framework/document-paint.js +0 -103
- package/dist/framework/document-paint.js.map +0 -1
- package/dist/framework/document-print-offscreen.d.ts +0 -38
- package/dist/framework/document-print-offscreen.js +0 -128
- package/dist/framework/document-print-offscreen.js.map +0 -1
- package/dist/framework/document-print.d.ts +0 -60
- package/dist/framework/document-print.js +0 -203
- package/dist/framework/document-print.js.map +0 -1
- package/dist/framework/document-segmenter.d.ts +0 -2
- package/dist/framework/document-segmenter.js +0 -106
- package/dist/framework/document-segmenter.js.map +0 -1
- package/dist/framework/document-selection.d.ts +0 -89
- package/dist/framework/document-selection.js +0 -358
- package/dist/framework/document-selection.js.map +0 -1
- package/dist/framework/document-template.d.ts +0 -4
- package/dist/framework/document-template.js +0 -20
- package/dist/framework/document-template.js.map +0 -1
- package/dist/framework/document-textline-mode.d.ts +0 -7
- package/dist/framework/document-textline-mode.js +0 -30
- package/dist/framework/document-textline-mode.js.map +0 -1
- package/dist/framework/element-define.d.ts +0 -319
- package/dist/framework/element-define.js +0 -579
- package/dist/framework/element-define.js.map +0 -1
- package/dist/framework/element-event-define.d.ts +0 -99
- package/dist/framework/element-event-define.js +0 -108
- package/dist/framework/element-event-define.js.map +0 -1
- package/dist/framework/element-measure.d.ts +0 -97
- package/dist/framework/element-measure.js +0 -551
- package/dist/framework/element-measure.js.map +0 -1
- package/dist/framework/element-paint.d.ts +0 -42
- package/dist/framework/element-paint.js +0 -170
- package/dist/framework/element-paint.js.map +0 -1
- package/dist/framework/element-props.d.ts +0 -301
- package/dist/framework/element-props.js +0 -809
- package/dist/framework/element-props.js.map +0 -1
- package/dist/framework/element-reader.d.ts +0 -19
- package/dist/framework/element-reader.js +0 -151
- package/dist/framework/element-reader.js.map +0 -1
- package/dist/framework/element-render-cut.d.ts +0 -55
- package/dist/framework/element-render-cut.js +0 -449
- package/dist/framework/element-render-cut.js.map +0 -1
- package/dist/framework/element-serialize.d.ts +0 -30
- package/dist/framework/element-serialize.js +0 -113
- package/dist/framework/element-serialize.js.map +0 -1
- package/dist/framework/element-util.d.ts +0 -369
- package/dist/framework/element-util.js +0 -1463
- package/dist/framework/element-util.js.map +0 -1
- package/dist/framework/impl/checkbox/checkbox-impl.d.ts +0 -24
- package/dist/framework/impl/checkbox/checkbox-impl.js +0 -64
- package/dist/framework/impl/checkbox/checkbox-impl.js.map +0 -1
- package/dist/framework/impl/comments/comment-content-impl.d.ts +0 -40
- package/dist/framework/impl/comments/comment-content-impl.js +0 -105
- package/dist/framework/impl/comments/comment-content-impl.js.map +0 -1
- package/dist/framework/impl/comments/comment-element-impl.d.ts +0 -21
- package/dist/framework/impl/comments/comment-element-impl.js +0 -62
- package/dist/framework/impl/comments/comment-element-impl.js.map +0 -1
- package/dist/framework/impl/comments/comments-container-impl.d.ts +0 -22
- package/dist/framework/impl/comments/comments-container-impl.js +0 -62
- package/dist/framework/impl/comments/comments-container-impl.js.map +0 -1
- package/dist/framework/impl/comments/comments-util.d.ts +0 -12
- package/dist/framework/impl/comments/comments-util.js +0 -67
- package/dist/framework/impl/comments/comments-util.js.map +0 -1
- package/dist/framework/impl/comments/validate-msg-impl.d.ts +0 -21
- package/dist/framework/impl/comments/validate-msg-impl.js +0 -83
- package/dist/framework/impl/comments/validate-msg-impl.js.map +0 -1
- package/dist/framework/impl/data-element/data-decorate-impl.d.ts +0 -30
- package/dist/framework/impl/data-element/data-decorate-impl.js +0 -91
- package/dist/framework/impl/data-element/data-decorate-impl.js.map +0 -1
- package/dist/framework/impl/data-element/data-element-barcode.d.ts +0 -31
- package/dist/framework/impl/data-element/data-element-barcode.js +0 -115
- package/dist/framework/impl/data-element/data-element-barcode.js.map +0 -1
- package/dist/framework/impl/data-element/data-element-base-impl.d.ts +0 -68
- package/dist/framework/impl/data-element/data-element-base-impl.js +0 -205
- package/dist/framework/impl/data-element/data-element-base-impl.js.map +0 -1
- package/dist/framework/impl/data-element/data-element-check-impl.d.ts +0 -35
- package/dist/framework/impl/data-element/data-element-check-impl.js +0 -133
- package/dist/framework/impl/data-element/data-element-check-impl.js.map +0 -1
- package/dist/framework/impl/data-element/data-element-date-impl.d.ts +0 -23
- package/dist/framework/impl/data-element/data-element-date-impl.js +0 -111
- package/dist/framework/impl/data-element/data-element-date-impl.js.map +0 -1
- package/dist/framework/impl/data-element/data-element-group-impl.d.ts +0 -23
- package/dist/framework/impl/data-element/data-element-group-impl.js +0 -130
- package/dist/framework/impl/data-element/data-element-group-impl.js.map +0 -1
- package/dist/framework/impl/data-element/data-element-image-impl.d.ts +0 -30
- package/dist/framework/impl/data-element/data-element-image-impl.js +0 -137
- package/dist/framework/impl/data-element/data-element-image-impl.js.map +0 -1
- package/dist/framework/impl/data-element/data-element-list-impl.d.ts +0 -22
- package/dist/framework/impl/data-element/data-element-list-impl.js +0 -131
- package/dist/framework/impl/data-element/data-element-list-impl.js.map +0 -1
- package/dist/framework/impl/data-element/data-element-text-impl.d.ts +0 -23
- package/dist/framework/impl/data-element/data-element-text-impl.js +0 -103
- package/dist/framework/impl/data-element/data-element-text-impl.js.map +0 -1
- package/dist/framework/impl/decorate/fill-null-space-imple.d.ts +0 -21
- package/dist/framework/impl/decorate/fill-null-space-imple.js +0 -43
- package/dist/framework/impl/decorate/fill-null-space-imple.js.map +0 -1
- package/dist/framework/impl/document/doc-body-impl.d.ts +0 -27
- package/dist/framework/impl/document/doc-body-impl.js +0 -79
- package/dist/framework/impl/document/doc-body-impl.js.map +0 -1
- package/dist/framework/impl/document/doc-body-part-impl.d.ts +0 -30
- package/dist/framework/impl/document/doc-body-part-impl.js +0 -94
- package/dist/framework/impl/document/doc-body-part-impl.js.map +0 -1
- package/dist/framework/impl/document/doc-container-impl.d.ts +0 -16
- package/dist/framework/impl/document/doc-container-impl.js +0 -21
- package/dist/framework/impl/document/doc-container-impl.js.map +0 -1
- package/dist/framework/impl/document/doc-footer-impl.d.ts +0 -26
- package/dist/framework/impl/document/doc-footer-impl.js +0 -77
- package/dist/framework/impl/document/doc-footer-impl.js.map +0 -1
- package/dist/framework/impl/document/doc-header-impl.d.ts +0 -26
- package/dist/framework/impl/document/doc-header-impl.js +0 -83
- package/dist/framework/impl/document/doc-header-impl.js.map +0 -1
- package/dist/framework/impl/document/doc-impl.d.ts +0 -61
- package/dist/framework/impl/document/doc-impl.js +0 -209
- package/dist/framework/impl/document/doc-impl.js.map +0 -1
- package/dist/framework/impl/media-formula/menstrual-history.d.ts +0 -35
- package/dist/framework/impl/media-formula/menstrual-history.js +0 -153
- package/dist/framework/impl/media-formula/menstrual-history.js.map +0 -1
- package/dist/framework/impl/paragraph/p-impl.d.ts +0 -45
- package/dist/framework/impl/paragraph/p-impl.js +0 -156
- package/dist/framework/impl/paragraph/p-impl.js.map +0 -1
- package/dist/framework/impl/picture/image-impl.d.ts +0 -31
- package/dist/framework/impl/picture/image-impl.js +0 -124
- package/dist/framework/impl/picture/image-impl.js.map +0 -1
- package/dist/framework/impl/radio/radio-impl.d.ts +0 -22
- package/dist/framework/impl/radio/radio-impl.js +0 -72
- package/dist/framework/impl/radio/radio-impl.js.map +0 -1
- package/dist/framework/impl/symbol/br-symbol-impl.d.ts +0 -22
- package/dist/framework/impl/symbol/br-symbol-impl.js +0 -54
- package/dist/framework/impl/symbol/br-symbol-impl.js.map +0 -1
- package/dist/framework/impl/symbol/p-symbol-impl.d.ts +0 -19
- package/dist/framework/impl/symbol/p-symbol-impl.js +0 -54
- package/dist/framework/impl/symbol/p-symbol-impl.js.map +0 -1
- package/dist/framework/impl/table/table-cell-impl.d.ts +0 -37
- package/dist/framework/impl/table/table-cell-impl.js +0 -145
- package/dist/framework/impl/table/table-cell-impl.js.map +0 -1
- package/dist/framework/impl/table/table-impl.d.ts +0 -55
- package/dist/framework/impl/table/table-impl.js +0 -363
- package/dist/framework/impl/table/table-impl.js.map +0 -1
- package/dist/framework/impl/table/table-row-impl.d.ts +0 -26
- package/dist/framework/impl/table/table-row-impl.js +0 -75
- package/dist/framework/impl/table/table-row-impl.js.map +0 -1
- package/dist/framework/impl/table/table-split-cell-patch.d.ts +0 -20
- package/dist/framework/impl/table/table-split-cell-patch.js +0 -89
- package/dist/framework/impl/table/table-split-cell-patch.js.map +0 -1
- package/dist/framework/impl/table/table-split-cell.d.ts +0 -90
- package/dist/framework/impl/table/table-split-cell.js +0 -464
- package/dist/framework/impl/table/table-split-cell.js.map +0 -1
- package/dist/framework/impl/table/table-util.d.ts +0 -150
- package/dist/framework/impl/table/table-util.js +0 -678
- package/dist/framework/impl/table/table-util.js.map +0 -1
- package/dist/framework/impl/text/text-impl.d.ts +0 -32
- package/dist/framework/impl/text/text-impl.js +0 -149
- package/dist/framework/impl/text/text-impl.js.map +0 -1
- package/dist/framework/impl/text/track-run-impl.d.ts +0 -27
- package/dist/framework/impl/text/track-run-impl.js +0 -112
- package/dist/framework/impl/text/track-run-impl.js.map +0 -1
- package/dist/framework/notify.d.ts +0 -13
- package/dist/framework/notify.js +0 -116
- package/dist/framework/notify.js.map +0 -1
- package/dist/framework/range-util.d.ts +0 -40
- package/dist/framework/range-util.js +0 -312
- package/dist/framework/range-util.js.map +0 -1
- package/dist/framework/render-context.d.ts +0 -91
- package/dist/framework/render-context.js +0 -384
- package/dist/framework/render-context.js.map +0 -1
- package/dist/framework/render-define.d.ts +0 -109
- package/dist/framework/render-define.js +0 -195
- package/dist/framework/render-define.js.map +0 -1
- package/dist/framework/selection-overlays.d.ts +0 -30
- package/dist/framework/selection-overlays.js +0 -124
- package/dist/framework/selection-overlays.js.map +0 -1
- package/dist/texteditor.d.ts +0 -318
- package/dist/texteditor.js +0 -913
- package/dist/texteditor.js.map +0 -1
- package/dist/util/subject.d.ts +0 -34
- package/dist/util/subject.js +0 -88
- package/dist/util/subject.js.map +0 -1
- package/dist/util/table-bind.d.ts +0 -5
- package/dist/util/table-bind.js +0 -6
- package/dist/util/table-bind.js.map +0 -1
- package/src/med_editor/doc-ruler.ts +0 -340
- package/src/med_editor/framework/common-util.ts +0 -200
- package/src/med_editor/framework/document-change.ts +0 -1392
- package/src/med_editor/framework/document-combine.ts +0 -44
- package/src/med_editor/framework/document-comment.ts +0 -168
- package/src/med_editor/framework/document-context.ts +0 -410
- package/src/med_editor/framework/document-eval-func.ts +0 -53
- package/src/med_editor/framework/document-event.ts +0 -1082
- package/src/med_editor/framework/document-history.ts +0 -76
- package/src/med_editor/framework/document-images-loader.ts +0 -74
- package/src/med_editor/framework/document-input-cursor.ts +0 -244
- package/src/med_editor/framework/document-paint.ts +0 -110
- package/src/med_editor/framework/document-print-offscreen.ts +0 -134
- package/src/med_editor/framework/document-print.ts +0 -219
- package/src/med_editor/framework/document-segmenter.ts +0 -211
- package/src/med_editor/framework/document-selection.ts +0 -391
- package/src/med_editor/framework/document-template.ts +0 -20
- package/src/med_editor/framework/document-textline-mode.ts +0 -34
- package/src/med_editor/framework/element-define.ts +0 -674
- package/src/med_editor/framework/element-event-define.ts +0 -142
- package/src/med_editor/framework/element-measure.ts +0 -573
- package/src/med_editor/framework/element-paint.ts +0 -176
- package/src/med_editor/framework/element-props.ts +0 -938
- package/src/med_editor/framework/element-reader.ts +0 -159
- package/src/med_editor/framework/element-render-cut.ts +0 -456
- package/src/med_editor/framework/element-serialize.ts +0 -128
- package/src/med_editor/framework/element-util.ts +0 -1565
- package/src/med_editor/framework/impl/checkbox/checkbox-impl.ts +0 -71
- package/src/med_editor/framework/impl/comments/comment-content-impl.ts +0 -119
- package/src/med_editor/framework/impl/comments/comment-element-impl.ts +0 -65
- package/src/med_editor/framework/impl/comments/comments-container-impl.ts +0 -68
- package/src/med_editor/framework/impl/comments/comments-util.ts +0 -84
- package/src/med_editor/framework/impl/comments/validate-msg-impl.ts +0 -94
- package/src/med_editor/framework/impl/data-element/data-decorate-impl.ts +0 -95
- package/src/med_editor/framework/impl/data-element/data-element-barcode.ts +0 -127
- package/src/med_editor/framework/impl/data-element/data-element-base-impl.ts +0 -234
- package/src/med_editor/framework/impl/data-element/data-element-check-impl.ts +0 -146
- package/src/med_editor/framework/impl/data-element/data-element-date-impl.ts +0 -128
- package/src/med_editor/framework/impl/data-element/data-element-group-impl.ts +0 -150
- package/src/med_editor/framework/impl/data-element/data-element-image-impl.ts +0 -147
- package/src/med_editor/framework/impl/data-element/data-element-list-impl.ts +0 -142
- package/src/med_editor/framework/impl/data-element/data-element-text-impl.ts +0 -117
- package/src/med_editor/framework/impl/decorate/fill-null-space-imple.ts +0 -48
- package/src/med_editor/framework/impl/document/doc-body-impl.ts +0 -95
- package/src/med_editor/framework/impl/document/doc-body-part-impl.ts +0 -104
- package/src/med_editor/framework/impl/document/doc-container-impl.ts +0 -24
- package/src/med_editor/framework/impl/document/doc-footer-impl.ts +0 -88
- package/src/med_editor/framework/impl/document/doc-header-impl.ts +0 -100
- package/src/med_editor/framework/impl/document/doc-impl.ts +0 -226
- package/src/med_editor/framework/impl/media-formula/menstrual-history.ts +0 -175
- package/src/med_editor/framework/impl/paragraph/p-impl.ts +0 -190
- package/src/med_editor/framework/impl/picture/image-impl.ts +0 -136
- package/src/med_editor/framework/impl/radio/radio-impl.ts +0 -79
- package/src/med_editor/framework/impl/symbol/br-symbol-impl.ts +0 -60
- package/src/med_editor/framework/impl/symbol/p-symbol-impl.ts +0 -57
- package/src/med_editor/framework/impl/table/table-cell-impl.ts +0 -156
- package/src/med_editor/framework/impl/table/table-impl.ts +0 -401
- package/src/med_editor/framework/impl/table/table-row-impl.ts +0 -83
- package/src/med_editor/framework/impl/table/table-split-cell-patch.ts +0 -98
- package/src/med_editor/framework/impl/table/table-split-cell.ts +0 -475
- package/src/med_editor/framework/impl/table/table-util.ts +0 -716
- package/src/med_editor/framework/impl/text/text-impl.ts +0 -164
- package/src/med_editor/framework/impl/text/track-run-impl.ts +0 -135
- package/src/med_editor/framework/notify.ts +0 -130
- package/src/med_editor/framework/range-util.ts +0 -321
- package/src/med_editor/framework/render-context.ts +0 -431
- package/src/med_editor/framework/render-define.ts +0 -224
- package/src/med_editor/framework/selection-overlays.ts +0 -134
- package/src/med_editor/texteditor.ts +0 -1011
- package/src/med_editor/util/subject.ts +0 -118
- package/src/med_editor/util/table-bind.ts +0 -6
- 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,321 +0,0 @@
|
|
1
|
-
import { BranchElement, Element, LeafElement, SelectionContentRange } from "./element-define";
|
2
|
-
import { ElementUtil } from "./element-util";
|
3
|
-
import { TableCellElement } from "./impl/table/table-cell-impl";
|
4
|
-
import { TableElement } from "./impl/table/table-impl";
|
5
|
-
import { TableRowElement } from "./impl/table/table-row-impl";
|
6
|
-
import { SelectionRange, SelectionState } from './document-selection'
|
7
|
-
import { TextGroupElement } from "./impl/text/text-impl";
|
8
|
-
|
9
|
-
|
10
|
-
export class RangeUtil {
|
11
|
-
|
12
|
-
static getSelctionRange(startControl: LeafElement, startOffset: number, endControl: LeafElement, endOffset: number, ancestorCommonControl: BranchElement): SelectionContentRange {
|
13
|
-
if (ancestorCommonControl instanceof TableElement || ancestorCommonControl instanceof TableRowElement) {
|
14
|
-
const tbElement = ancestorCommonControl instanceof TableElement ? ancestorCommonControl : ancestorCommonControl.parent as TableElement;
|
15
|
-
return this.getTableSelectionRange(startControl, startOffset, endControl, endOffset, tbElement);
|
16
|
-
}
|
17
|
-
if (startControl === endControl && startControl.parent === ancestorCommonControl) {
|
18
|
-
return this.getCollapsedRange(startControl, startOffset, endOffset, ancestorCommonControl);
|
19
|
-
}
|
20
|
-
const startRange = this.getStartForbackTreeData(startControl, ancestorCommonControl, null, startOffset).selectedChildren[0];
|
21
|
-
const endRange = this.getEndForwardTreeData(endControl, ancestorCommonControl, null, endOffset).selectedChildren[0];
|
22
|
-
const startIndex = ancestorCommonControl.getChildIndex(startRange.target);
|
23
|
-
const endIndex = ancestorCommonControl.getChildIndex(endRange.target);
|
24
|
-
const commonRange = this.getChildTreeData(ancestorCommonControl, startIndex + 1, endIndex);
|
25
|
-
if (this.rangeEquals(startRange, endRange)) {
|
26
|
-
commonRange.selectedChildren.unshift(startRange);
|
27
|
-
} else {
|
28
|
-
commonRange.selectedChildren.unshift(startRange);
|
29
|
-
commonRange.selectedChildren.push(endRange);
|
30
|
-
}
|
31
|
-
this.setRangeFullSelected(commonRange);
|
32
|
-
return commonRange;
|
33
|
-
}
|
34
|
-
|
35
|
-
static getCollapsedRange(startControl: LeafElement, startOffset: number, endOffset: number, ancestorCommonControl: BranchElement): SelectionContentRange {
|
36
|
-
const range = {
|
37
|
-
target: ancestorCommonControl,
|
38
|
-
isFullSelected: false,
|
39
|
-
startOffset: startControl.getIndex(),
|
40
|
-
endOffset: startControl.getIndex() + 1,
|
41
|
-
selectedChildren: [this.getChildTreeData(startControl, startOffset, endOffset)]
|
42
|
-
}
|
43
|
-
this.setRangeFullSelected(range);
|
44
|
-
return range;
|
45
|
-
|
46
|
-
}
|
47
|
-
|
48
|
-
/**
|
49
|
-
* 获取表格选区的内容
|
50
|
-
* @param startControl
|
51
|
-
* @param startOffset
|
52
|
-
* @param endControl
|
53
|
-
* @param endOffset
|
54
|
-
* @param tb
|
55
|
-
*/
|
56
|
-
static getTableSelectionRange(startControl: LeafElement, startOffset: number, endControl: LeafElement, endOffset: number, tb: TableElement): SelectionContentRange {
|
57
|
-
const startCell = ElementUtil.getParentByType(startControl, TableCellElement);
|
58
|
-
const endCell = ElementUtil.getParentByType(endControl, TableCellElement);
|
59
|
-
if (startCell && endCell && startCell.parent.parent === tb && endCell.parent.parent === tb) {
|
60
|
-
let startRowIndex = startCell.parent.getIndex();
|
61
|
-
let endRowIndex = endCell.parent.getIndex();
|
62
|
-
let startColIndex = startCell.getIndex();
|
63
|
-
let endColIndex = endCell.getIndex();
|
64
|
-
if (startColIndex > endColIndex) {
|
65
|
-
[startColIndex, endColIndex] = [endColIndex, startColIndex];
|
66
|
-
}
|
67
|
-
if (startRowIndex > endRowIndex) {
|
68
|
-
[startRowIndex, endRowIndex] = [endRowIndex, startRowIndex];
|
69
|
-
}
|
70
|
-
const region = { startRow: startRowIndex, endRow: endRowIndex, startCol: startColIndex, endCol: endColIndex };//this.getTableRectSelectedRegion(tb, { startRow: startRowIndex, endRow: endRowIndex, startCol: startColIndex, endCol: endColIndex });
|
71
|
-
startRowIndex = region.startRow;
|
72
|
-
endRowIndex = region.endRow;
|
73
|
-
startColIndex = region.startCol;
|
74
|
-
endColIndex = region.endCol;
|
75
|
-
const rowRanges: Array<SelectionContentRange> = [];
|
76
|
-
for (let i = startRowIndex; i <= endRowIndex; i++) {
|
77
|
-
const cellRanges: Array<SelectionContentRange> = [];
|
78
|
-
const row = tb.getChild(i) as TableRowElement;
|
79
|
-
for (let j = startColIndex; j <= endColIndex; j++) {
|
80
|
-
const cell = row.getChild(j) as TableCellElement;
|
81
|
-
const cellFirstLeafElement = ElementUtil.getFirstLeafElement(cell) as LeafElement;
|
82
|
-
const cellLastLeafElement = ElementUtil.getLastLeafElement(cell) as LeafElement;
|
83
|
-
if (!cellFirstLeafElement && !cell.isNotBeMergedCell()) {
|
84
|
-
cellRanges.push({
|
85
|
-
target: cell,
|
86
|
-
isFullSelected: true,
|
87
|
-
startOffset: 0,
|
88
|
-
endOffset: 1,
|
89
|
-
selectedChildren: []
|
90
|
-
});
|
91
|
-
} else {
|
92
|
-
const cellRange = this.getSelctionRange(cellFirstLeafElement, 0, cellLastLeafElement, 1, cell);
|
93
|
-
cellRanges.push(cellRange);
|
94
|
-
}
|
95
|
-
}
|
96
|
-
const rowRange: SelectionContentRange = {
|
97
|
-
target: row,
|
98
|
-
isFullSelected: false,
|
99
|
-
startOffset: startColIndex,
|
100
|
-
endOffset: endColIndex,
|
101
|
-
selectedChildren: [...cellRanges]
|
102
|
-
};
|
103
|
-
rowRange.isFullSelected = startColIndex === 0 && endColIndex === row.length - 1;
|
104
|
-
rowRanges.push(rowRange);
|
105
|
-
}
|
106
|
-
const tableRange: SelectionContentRange = {
|
107
|
-
target: tb,
|
108
|
-
isFullSelected: false,
|
109
|
-
startOffset: startRowIndex,
|
110
|
-
endOffset: endRowIndex,
|
111
|
-
selectedChildren: [...rowRanges]
|
112
|
-
};
|
113
|
-
tableRange.isFullSelected = startRowIndex === 0 && endRowIndex === tb.length - 1 && tableRange.selectedChildren.every(item => item.isFullSelected);
|
114
|
-
return tableRange;
|
115
|
-
} else {
|
116
|
-
throw new Error('当前单元格和表格不对应');
|
117
|
-
}
|
118
|
-
}
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
private static getStartForbackTreeData(control: Element, ancestorCommonControl: BranchElement, childData: SelectionContentRange | null, offset: number): SelectionContentRange {
|
123
|
-
if (!control) {
|
124
|
-
debugger;
|
125
|
-
}
|
126
|
-
const parent = control.parent;
|
127
|
-
if (parent !== ancestorCommonControl) {
|
128
|
-
const range = this.getChildTreeData(parent, parent.getChildIndex(control) + 1, -1);
|
129
|
-
if (childData) {
|
130
|
-
range.selectedChildren.unshift(childData);
|
131
|
-
} else {
|
132
|
-
range.selectedChildren.unshift(this.getChildTreeData(control, offset, -1));
|
133
|
-
}
|
134
|
-
this.setRangeFullSelected(range);
|
135
|
-
return this.getStartForbackTreeData(parent, ancestorCommonControl, range, -99);
|
136
|
-
} else {
|
137
|
-
const ancestorRange: SelectionContentRange = {
|
138
|
-
target: ancestorCommonControl,
|
139
|
-
startOffset: -1,
|
140
|
-
endOffset: -1,
|
141
|
-
isFullSelected: false,
|
142
|
-
selectedChildren: []
|
143
|
-
};
|
144
|
-
if (!childData) {
|
145
|
-
childData = this.getChildTreeData(control, offset, -1);
|
146
|
-
}
|
147
|
-
ancestorRange.selectedChildren.push(childData);
|
148
|
-
this.setRangeFullSelected(ancestorRange);
|
149
|
-
return ancestorRange;
|
150
|
-
}
|
151
|
-
}
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
private static getEndForwardTreeData(control: Element, ancestorCommonControl: BranchElement, childData: SelectionContentRange | null, offset: number): SelectionContentRange {
|
156
|
-
const parent = control.parent;
|
157
|
-
if (parent !== ancestorCommonControl) {
|
158
|
-
const range = this.getChildTreeData(parent, 0, parent.getChildIndex(control));
|
159
|
-
if (childData) {
|
160
|
-
range.selectedChildren.push(childData);
|
161
|
-
} else {
|
162
|
-
range.selectedChildren.push(this.getChildTreeData(control, 0, offset));
|
163
|
-
}
|
164
|
-
this.setRangeFullSelected(range);
|
165
|
-
return this.getEndForwardTreeData(parent, ancestorCommonControl, range, -99);
|
166
|
-
} else {
|
167
|
-
const ancestorRange: SelectionContentRange = {
|
168
|
-
target: ancestorCommonControl,
|
169
|
-
startOffset: 0,
|
170
|
-
endOffset: 0,
|
171
|
-
isFullSelected: false,
|
172
|
-
selectedChildren: []
|
173
|
-
};
|
174
|
-
if (!childData) {
|
175
|
-
childData = this.getChildTreeData(control, 0, offset)
|
176
|
-
}
|
177
|
-
ancestorRange.selectedChildren.push(childData);
|
178
|
-
this.setRangeFullSelected(ancestorRange);
|
179
|
-
return ancestorRange;
|
180
|
-
}
|
181
|
-
}
|
182
|
-
|
183
|
-
private static getChildTreeData(control: Element, start: number, end: number): SelectionContentRange {
|
184
|
-
const range: SelectionContentRange = {
|
185
|
-
target: control,
|
186
|
-
isFullSelected: false,
|
187
|
-
startOffset: start,
|
188
|
-
endOffset: end,
|
189
|
-
selectedChildren: []
|
190
|
-
};
|
191
|
-
if (control instanceof LeafElement) {
|
192
|
-
if (control instanceof TextGroupElement) {
|
193
|
-
range.endOffset = end === -1 ? control.text.length : end;
|
194
|
-
} else {
|
195
|
-
range.endOffset = end === -1 ? 1 : end;
|
196
|
-
}
|
197
|
-
|
198
|
-
} else if (control instanceof BranchElement) {
|
199
|
-
end = end === -1 ? control.length : end;
|
200
|
-
for (let i = start; i < end; i++) {
|
201
|
-
const child = control.getChild(i);
|
202
|
-
range.selectedChildren.push(this.getChildTreeData(child, 0, -1));
|
203
|
-
}
|
204
|
-
}
|
205
|
-
this.setRangeFullSelected(range);
|
206
|
-
return range;
|
207
|
-
}
|
208
|
-
|
209
|
-
private static setRangeFullSelected(selectionRange: SelectionContentRange): void {
|
210
|
-
if (selectionRange.target instanceof LeafElement) {
|
211
|
-
const { startOffset, endOffset } = selectionRange;
|
212
|
-
if (selectionRange.target instanceof TextGroupElement) {
|
213
|
-
selectionRange.isFullSelected = startOffset === 0 && endOffset === selectionRange.target.text.length
|
214
|
-
} else {
|
215
|
-
selectionRange.isFullSelected = startOffset === 0 && endOffset === 1;
|
216
|
-
}
|
217
|
-
} else if (selectionRange.target instanceof BranchElement) {
|
218
|
-
const parent = selectionRange.target;
|
219
|
-
const selectedChildren = selectionRange.selectedChildren;
|
220
|
-
//被合并的table-cell,内容为empty
|
221
|
-
if (selectedChildren.length === 0) {
|
222
|
-
if (selectionRange.startOffset === 0 && selectionRange.endOffset === -1) {
|
223
|
-
selectionRange.isFullSelected = true;
|
224
|
-
return;
|
225
|
-
}
|
226
|
-
selectionRange.isFullSelected = false;
|
227
|
-
return;
|
228
|
-
}
|
229
|
-
const firstItem = selectedChildren[0];
|
230
|
-
const firstItemIndex = parent.getChildIndex(firstItem.target);
|
231
|
-
const lastItem = selectedChildren[selectedChildren.length - 1];
|
232
|
-
const lastItemIndex = parent.getChildIndex(lastItem.target);
|
233
|
-
selectionRange.startOffset = firstItemIndex;
|
234
|
-
selectionRange.endOffset = lastItemIndex;
|
235
|
-
selectionRange.isFullSelected = firstItemIndex === 0 && firstItem.isFullSelected && lastItemIndex === parent.length - 1 && lastItem.isFullSelected;
|
236
|
-
}
|
237
|
-
}
|
238
|
-
|
239
|
-
static rangeEquals(selRange1: SelectionContentRange, selRange2: SelectionContentRange): boolean {
|
240
|
-
return selRange1.target === selRange2.target && selRange1.startOffset === selRange2.startOffset && selRange1.endOffset === selRange2.endOffset;
|
241
|
-
}
|
242
|
-
|
243
|
-
|
244
|
-
/**
|
245
|
-
* 根据选区范围更正选区内容状态
|
246
|
-
* @param selectedRange
|
247
|
-
* @param selectionState
|
248
|
-
*/
|
249
|
-
static fixSelectionStateByRange(selectionState: SelectionState): boolean {
|
250
|
-
const { startControl, startOffset, endControl, endOffset, selectedRange } = selectionState;
|
251
|
-
if (!selectedRange || !startControl) {
|
252
|
-
return false;
|
253
|
-
}
|
254
|
-
const startRange = this.getStartRangeTarget(selectedRange) as SelectionContentRange;
|
255
|
-
const endRange = this.getEndRangeTarget(selectedRange) as SelectionContentRange;
|
256
|
-
if (startRange.target !== startControl || startRange.startOffset !== startOffset || endRange.target !== endControl || endRange.endOffset !== endOffset) {
|
257
|
-
selectionState.clear();
|
258
|
-
const ssRange = new SelectionRange();
|
259
|
-
ssRange.setStart(startRange.target, startRange.startOffset);
|
260
|
-
ssRange.setEnd(endRange.target, endRange.endOffset);
|
261
|
-
selectionState.addRange(ssRange);
|
262
|
-
return true;
|
263
|
-
}
|
264
|
-
return false;
|
265
|
-
}
|
266
|
-
|
267
|
-
static getStartRangeTarget(parentRange: SelectionContentRange): SelectionContentRange | null {
|
268
|
-
if (parentRange.target instanceof LeafElement) {
|
269
|
-
return parentRange;
|
270
|
-
} else {
|
271
|
-
for (let i = 0; i < parentRange.selectedChildren.length; i++) {
|
272
|
-
const res = this.getStartRangeTarget(parentRange.selectedChildren[i]);
|
273
|
-
if (res) {
|
274
|
-
return res;
|
275
|
-
}
|
276
|
-
}
|
277
|
-
}
|
278
|
-
return null;
|
279
|
-
}
|
280
|
-
|
281
|
-
static getEndRangeTarget(parentRange: SelectionContentRange): SelectionContentRange | null {
|
282
|
-
if (parentRange.target instanceof LeafElement) {
|
283
|
-
return parentRange;
|
284
|
-
} else {
|
285
|
-
for (let i = parentRange.selectedChildren.length - 1; i >= 0; i--) {
|
286
|
-
const res = this.getEndRangeTarget(parentRange.selectedChildren[i]);
|
287
|
-
if (res) {
|
288
|
-
return res;
|
289
|
-
}
|
290
|
-
}
|
291
|
-
}
|
292
|
-
return null;
|
293
|
-
}
|
294
|
-
|
295
|
-
/**
|
296
|
-
* 循环递归执行选区对象方法
|
297
|
-
* @param range
|
298
|
-
* @param handler
|
299
|
-
*/
|
300
|
-
static recursionTraversalRangeHandler(range: SelectionContentRange, handler: (range: SelectionContentRange) => void): void {
|
301
|
-
handler(range);
|
302
|
-
for (let i = 0; i < range.selectedChildren.length; i++) {
|
303
|
-
this.recursionTraversalRangeHandler(range.selectedChildren[i], handler);
|
304
|
-
}
|
305
|
-
}
|
306
|
-
|
307
|
-
/**
|
308
|
-
* 判断元素是否被完全选中
|
309
|
-
* @param range
|
310
|
-
*/
|
311
|
-
static checkElementFullInRange(range: SelectionContentRange, ele: Element): boolean {
|
312
|
-
let res = false;
|
313
|
-
this.recursionTraversalRangeHandler(range, (childRange) => {
|
314
|
-
if (childRange.target === ele && childRange.isFullSelected) {
|
315
|
-
res = true;
|
316
|
-
}
|
317
|
-
});
|
318
|
-
return res;
|
319
|
-
}
|
320
|
-
|
321
|
-
}
|