@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
@@ -1,30 +1,30 @@
|
|
1
|
+
import { SelectionState } from "../../document-selection";
|
1
2
|
import { ElementUtil } from "../../element-util";
|
2
3
|
import { TableCellElement } from "./table-cell-impl";
|
3
4
|
import { TableElement } from "./table-impl";
|
4
5
|
import { TableRowElement } from "./table-row-impl";
|
5
|
-
import { ColumnPatchUtil } from "./table-split-cell-patch";
|
6
|
+
import { ColumnPart, ColumnPartOffset, ColumnPatch, ColumnPatchUtil } from "./table-split-cell-patch";
|
6
7
|
import { TableUtil } from "./table-util";
|
7
8
|
/**
|
8
9
|
* 拆分单元格
|
9
10
|
* 蜀道难,难于上青天;拆分单元格,头发秃,精神衰,眼睛昏,身体废。
|
10
|
-
*
|
11
|
+
*
|
11
12
|
* 1.拆分为多列规则:不影响其他列宽度,将当前列宽度均分
|
12
13
|
*/
|
13
14
|
export class TableSplitCell {
|
14
15
|
/**
|
15
|
-
*
|
16
|
+
*
|
16
17
|
* 普通单元格可以任意拆分行和列
|
17
18
|
* 已合并的单元格,可以拆分任意数量的列;可以拆分的数量必须为合并单元格数量的约数
|
18
19
|
*/
|
19
|
-
static splitCell(ss, rows, cols) {
|
20
|
+
static splitCell(ss: SelectionState, rows: number, cols: number): void {
|
20
21
|
const focusCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
|
21
22
|
if (!focusCell) {
|
22
|
-
throw new Error('focusCell is null')
|
23
|
+
throw new Error('focusCell is null')
|
23
24
|
}
|
24
25
|
if (!focusCell.props.hMerge && !focusCell.props.vMerge) {
|
25
26
|
this.splitNormalCell(ss, rows, cols);
|
26
|
-
}
|
27
|
-
else {
|
27
|
+
} else {
|
28
28
|
this.splitMergeCell(ss, rows, cols);
|
29
29
|
}
|
30
30
|
// else if (!focusCell.cellProps.hMerge) {
|
@@ -37,10 +37,12 @@ export class TableSplitCell {
|
|
37
37
|
// this.verSplitVerMergeCell(ss, rows, endColIndex);
|
38
38
|
// }
|
39
39
|
}
|
40
|
+
|
41
|
+
|
40
42
|
/**
|
41
43
|
* 拆分普通的单元格
|
42
44
|
*/
|
43
|
-
static splitNormalCell(ss, rows, cols) {
|
45
|
+
private static splitNormalCell(ss: SelectionState, rows: number, cols: number): void {
|
44
46
|
rows = rows < 1 ? 1 : rows;
|
45
47
|
cols = cols < 1 ? 1 : cols;
|
46
48
|
if (rows === 1 && cols === 1) {
|
@@ -66,9 +68,9 @@ export class TableSplitCell {
|
|
66
68
|
tb.insertCol(focusCellIndex + i, splitCellWidths[i].width);
|
67
69
|
}
|
68
70
|
for (let i = 0; i < tb.length; i++) {
|
69
|
-
const row = tb.getChild(i);
|
71
|
+
const row = tb.getChild(i) as TableRowElement;
|
70
72
|
//获取主单元格
|
71
|
-
const masterCell = row.getChild(focusCellIndex);
|
73
|
+
const masterCell = row.getChild(focusCellIndex) as TableCellElement;
|
72
74
|
for (let j = 1; j < cols; j++) {
|
73
75
|
const newCell = new TableCellElement();
|
74
76
|
row.addChild(newCell, focusCellIndex + j);
|
@@ -85,25 +87,24 @@ export class TableSplitCell {
|
|
85
87
|
if (rows > 1) {
|
86
88
|
for (let i = 1; i < rows; i++) {
|
87
89
|
const newRow = TableRowElement.createRow(tb.getColsCount());
|
88
|
-
tb.addChild(newRow, focusRowIndex + i)
|
90
|
+
tb.addChild(newRow, focusRowIndex + i)
|
89
91
|
for (let j = 0; j < newRow.length; j++) {
|
90
|
-
const cell = newRow.getChild(j);
|
91
|
-
const masterCell = focusRow.getChild(j)
|
92
|
+
const cell = newRow.getChild<TableCellElement>(j);
|
93
|
+
const masterCell = focusRow.getChild<TableCellElement>(j)
|
92
94
|
if (j < focusCellIndex || j > focusCellIndex + cols - 1)
|
93
95
|
//紧挨上级的单元格存在横向合并
|
94
96
|
if (masterCell.props.hMerge) {
|
95
97
|
if (masterCell.props.hMerge === 'restart') {
|
96
98
|
if (!masterCell.props.vMerge) {
|
97
|
-
masterCell.props.vMerge = 'restart'
|
99
|
+
masterCell.props.vMerge = 'restart'
|
98
100
|
}
|
99
101
|
cell.props.vMerge = 'continue';
|
100
102
|
}
|
101
|
-
}
|
102
|
-
else {
|
103
|
+
} else {
|
103
104
|
if (!masterCell.props.vMerge) {
|
104
|
-
masterCell.props.vMerge = 'restart'
|
105
|
+
masterCell.props.vMerge = 'restart'
|
105
106
|
}
|
106
|
-
cell.props.vMerge = 'continue'
|
107
|
+
cell.props.vMerge = 'continue'
|
107
108
|
}
|
108
109
|
}
|
109
110
|
}
|
@@ -111,13 +112,14 @@ export class TableSplitCell {
|
|
111
112
|
tb.pubOnChange('self');
|
112
113
|
tb.refreshView();
|
113
114
|
}
|
115
|
+
|
114
116
|
/**
|
115
117
|
* 拆分合并的单元格
|
116
|
-
* @param ss
|
117
|
-
* @param rows
|
118
|
-
* @param cols
|
118
|
+
* @param ss
|
119
|
+
* @param rows
|
120
|
+
* @param cols
|
119
121
|
*/
|
120
|
-
static splitMergeCell(ss, rows, cols) {
|
122
|
+
static splitMergeCell(ss: SelectionState, rows: number, cols: number): void {
|
121
123
|
rows = rows < 1 ? 1 : rows;
|
122
124
|
cols = cols < 1 ? 1 : cols;
|
123
125
|
if (rows === 1 && cols === 1) {
|
@@ -140,7 +142,7 @@ export class TableSplitCell {
|
|
140
142
|
//只有拆分的行数需要满足此条件
|
141
143
|
if (mergeRows > 1 && rows > 1) {
|
142
144
|
if (rows % mergeRows !== 0) {
|
143
|
-
throw new Error(`当前合并的行数为:${mergeRows},当前可拆分的行数是${mergeRows}的约数`)
|
145
|
+
throw new Error(`当前合并的行数为:${mergeRows},当前可拆分的行数是${mergeRows}的约数`)
|
144
146
|
}
|
145
147
|
}
|
146
148
|
//拆分的行数、列数等于合并的行数、列数
|
@@ -149,6 +151,7 @@ export class TableSplitCell {
|
|
149
151
|
TableUtil.restoreCell(ss);
|
150
152
|
return;
|
151
153
|
}
|
154
|
+
|
152
155
|
if (mergeCols === 1) {
|
153
156
|
const { endColIndex } = this.horSplitHorNormalCell(ss, rows, cols);
|
154
157
|
this.verSplitVerMergeCell(ss, rows, endColIndex);
|
@@ -159,13 +162,14 @@ export class TableSplitCell {
|
|
159
162
|
this.verSplitVerMergeCell(ss, rows, endColIndex);
|
160
163
|
}
|
161
164
|
}
|
165
|
+
|
162
166
|
/**
|
163
167
|
* 拆分横向正常的单元格
|
164
|
-
* @param ss
|
165
|
-
* @param rows
|
166
|
-
* @param cols
|
168
|
+
* @param ss
|
169
|
+
* @param rows
|
170
|
+
* @param cols
|
167
171
|
*/
|
168
|
-
static horSplitHorNormalCell(ss, rows, cols) {
|
172
|
+
static horSplitHorNormalCell(ss: SelectionState, rows: number, cols: number): { startColIndex: number, endColIndex: number } {
|
169
173
|
const focusCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
|
170
174
|
const focusRow = ElementUtil.getParentByType(focusCell, TableRowElement);
|
171
175
|
const tb = ElementUtil.getParentByType(focusRow, TableElement);
|
@@ -185,9 +189,9 @@ export class TableSplitCell {
|
|
185
189
|
//向指定的列插入拆分单元格
|
186
190
|
if (cols > 1) {
|
187
191
|
for (let i = 0; i < tb.length; i++) {
|
188
|
-
const currRow = tb.getChild(i);
|
192
|
+
const currRow = tb.getChild(i) as TableRowElement;
|
189
193
|
//获取主单元格
|
190
|
-
const masterCell = currRow.getChild(focusCellIndex);
|
194
|
+
const masterCell = currRow.getChild(focusCellIndex) as TableCellElement;
|
191
195
|
for (let j = 1; j < cols; j++) {
|
192
196
|
const newCell = new TableCellElement();
|
193
197
|
currRow.addChild(newCell, focusCellIndex + j);
|
@@ -197,8 +201,7 @@ export class TableSplitCell {
|
|
197
201
|
masterCell.props.hMerge = 'restart';
|
198
202
|
}
|
199
203
|
newCell.props.hMerge = 'continue';
|
200
|
-
}
|
201
|
-
else {
|
204
|
+
} else {
|
202
205
|
newCell.props.vMerge = masterCell.props.vMerge;
|
203
206
|
}
|
204
207
|
}
|
@@ -207,7 +210,7 @@ export class TableSplitCell {
|
|
207
210
|
//在选中行下插入拆分行
|
208
211
|
//如果当前是普通单元格
|
209
212
|
if (!focusCell.props.vMerge) {
|
210
|
-
debugger
|
213
|
+
debugger
|
211
214
|
for (let i = 1; i < rows; i++) {
|
212
215
|
const newRow = TableRowElement.createRow(tb.getColsCount());
|
213
216
|
tb.addChild(newRow, focusRowIndex + i);
|
@@ -218,15 +221,16 @@ export class TableSplitCell {
|
|
218
221
|
return {
|
219
222
|
startColIndex: focusCellIndex,
|
220
223
|
endColIndex: focusCellIndex + cols - 1
|
221
|
-
}
|
224
|
+
}
|
222
225
|
}
|
226
|
+
|
223
227
|
/**
|
224
|
-
* 横向拆分合并的单元格
|
225
|
-
* @param ss
|
226
|
-
* @param rows
|
227
|
-
* @param cols
|
228
|
+
* 横向拆分合并的单元格
|
229
|
+
* @param ss
|
230
|
+
* @param rows
|
231
|
+
* @param cols
|
228
232
|
*/
|
229
|
-
static horSplitHorMergeCell(ss, rows, cols) {
|
233
|
+
static horSplitHorMergeCell(ss: SelectionState, rows: number, cols: number): { startColIndex: number, endColIndex: number } {
|
230
234
|
const focusCell = ElementUtil.getParentByType(ss.startControl, TableCellElement);
|
231
235
|
const focusRow = ElementUtil.getParentByType(focusCell, TableRowElement);
|
232
236
|
const tb = ElementUtil.getParentByType(focusRow, TableElement);
|
@@ -236,7 +240,7 @@ export class TableSplitCell {
|
|
236
240
|
const focusCellIndex = focusRow.getChildIndex(focusCell);
|
237
241
|
const focusRowIndex = focusRow.getIndex();
|
238
242
|
const hMergeCols = this.getHMergeCols(tb, focusRowIndex, focusCellIndex, cols);
|
239
|
-
const colsWidth = hMergeCols.reduce((prev, curr) => prev + curr.width, 0)
|
243
|
+
const colsWidth = hMergeCols.reduce((prev, curr) => prev + curr.width, 0)
|
240
244
|
const splitCols = this.getSplitCols(colsWidth, cols);
|
241
245
|
const [otherPacks, currPacks] = ColumnPatchUtil.getPatchPacks(hMergeCols, splitCols);
|
242
246
|
this.applyHorSplitColumnPatchPacks(tb, focusRowIndex, 1, otherPacks);
|
@@ -246,12 +250,13 @@ export class TableSplitCell {
|
|
246
250
|
return {
|
247
251
|
startColIndex: focusCellIndex,
|
248
252
|
endColIndex: this.getPrepareNewColCounts(otherPacks, hMergeCols)
|
249
|
-
}
|
253
|
+
}
|
250
254
|
}
|
255
|
+
|
251
256
|
/**
|
252
257
|
* 获取需要新创建的列数量
|
253
258
|
*/
|
254
|
-
static getPrepareNewColCounts(packs, hMergeCols) {
|
259
|
+
private static getPrepareNewColCounts(packs: Array<{ part: ColumnPartOffset, patchs: Array<ColumnPatch> }>, hMergeCols: Array<ColumnPart>): number {
|
255
260
|
const lastColIndex = hMergeCols[hMergeCols.length - 1].index;
|
256
261
|
if (packs.length === 0) {
|
257
262
|
return lastColIndex;
|
@@ -260,12 +265,13 @@ export class TableSplitCell {
|
|
260
265
|
if (!lastColPack) {
|
261
266
|
return lastColIndex;
|
262
267
|
}
|
263
|
-
return lastColIndex + lastColPack.patchs.filter(item => item.type === 'insert').length
|
268
|
+
return lastColIndex + lastColPack.patchs.filter(item => item.type === 'insert').length
|
264
269
|
}
|
270
|
+
|
265
271
|
/**
|
266
272
|
* 应用横向拆分单元格补丁
|
267
273
|
*/
|
268
|
-
static applyHorSplitColumnPatchPacks(tb, focusRowIndex, splitRows, packs) {
|
274
|
+
private static applyHorSplitColumnPatchPacks(tb: TableElement, focusRowIndex: number, splitRows: number, packs: Array<{ part: ColumnPartOffset, patchs: Array<ColumnPatch> }>): void {
|
269
275
|
for (let i = packs.length - 1; i >= 0; i--) {
|
270
276
|
const pack = packs[i];
|
271
277
|
const colIndex = pack.part.index;
|
@@ -273,14 +279,13 @@ export class TableSplitCell {
|
|
273
279
|
const patch = pack.patchs[j];
|
274
280
|
if (patch.type === 'modify') {
|
275
281
|
tb.setCellWidth(colIndex, patch.data.width);
|
276
|
-
}
|
277
|
-
else if (patch.type === 'insert') {
|
282
|
+
} else if (patch.type === 'insert') {
|
278
283
|
tb.insertCol(colIndex + 1, patch.data.width);
|
279
284
|
//向指定的列插入拆分单元格
|
280
285
|
for (let i = 0; i < tb.length; i++) {
|
281
|
-
const currRow = tb.getChild(i);
|
286
|
+
const currRow = tb.getChild(i) as TableRowElement;
|
282
287
|
//获取主单元格
|
283
|
-
const masterCell = currRow.getChild(colIndex);
|
288
|
+
const masterCell = currRow.getChild(colIndex) as TableCellElement;
|
284
289
|
const newCell = new TableCellElement();
|
285
290
|
currRow.addChild(newCell, colIndex + 1);
|
286
291
|
if (!masterCell.props.hMerge) {
|
@@ -292,44 +297,46 @@ export class TableSplitCell {
|
|
292
297
|
}
|
293
298
|
}
|
294
299
|
}
|
300
|
+
|
295
301
|
/**
|
296
302
|
* 存在横向合并的单元格,进行单元格分拆,打补丁
|
297
|
-
* @param tb
|
298
|
-
* @param focusRowIndex
|
299
|
-
* @param focusColInex
|
300
|
-
* @param splitRows
|
301
|
-
* @param packs
|
303
|
+
* @param tb
|
304
|
+
* @param focusRowIndex
|
305
|
+
* @param focusColInex
|
306
|
+
* @param splitRows
|
307
|
+
* @param packs
|
302
308
|
*/
|
303
|
-
static applyHorSplitColumnCurrPatchPacks(tb, focusRowIndex, focusColInex, splitRows, packs) {
|
309
|
+
private static applyHorSplitColumnCurrPatchPacks(tb: TableElement, focusRowIndex: number, focusColInex: number, splitRows: number, packs: Array<Array<ColumnPart>>): void {
|
304
310
|
//获取当前列的合并行数
|
305
311
|
let vMergeRows = this.getVMergeRowsCount(tb, focusRowIndex, focusColInex);
|
306
312
|
vMergeRows = vMergeRows === 1 ? 0 : vMergeRows;
|
307
|
-
const startRow = tb.getChild(focusRowIndex);
|
308
|
-
const endRow = tb.getChild(focusRowIndex + vMergeRows - 1);
|
313
|
+
const startRow = tb.getChild(focusRowIndex) as TableRowElement;
|
314
|
+
const endRow = tb.getChild(focusRowIndex + vMergeRows - 1) as TableRowElement;
|
309
315
|
for (let i = 0; i < packs.length; i++) {
|
310
316
|
const mergeCols = packs[i];
|
311
317
|
if (mergeCols.length === 1) {
|
312
|
-
const startCell = startRow.getChild(focusColInex + mergeCols[0].index);
|
313
|
-
const endCell = endRow.getChild(focusColInex + mergeCols[0].index);
|
318
|
+
const startCell = startRow.getChild(focusColInex + mergeCols[0].index) as TableCellElement;
|
319
|
+
const endCell = endRow.getChild(focusColInex + mergeCols[0].index) as TableCellElement;
|
314
320
|
TableUtil.combineCells(tb, startCell, endCell);
|
315
|
-
}
|
316
|
-
else {
|
321
|
+
} else {
|
317
322
|
// for (let j = 0; j < mergeCols.length; j++) {
|
318
323
|
// const cell = focusRow.getChild(focusColInex + mergeCols[j].index) as TableCellElement;
|
319
324
|
// cell.cellProps.hMerge = j === 0 ? 'restart' : 'continue';
|
320
325
|
// }
|
321
|
-
const startCell = startRow.getChild(focusColInex + mergeCols[0].index);
|
322
|
-
const endCell = endRow.getChild(focusColInex + mergeCols[mergeCols.length - 1].index);
|
326
|
+
const startCell = startRow.getChild(focusColInex + mergeCols[0].index) as TableCellElement;
|
327
|
+
const endCell = endRow.getChild(focusColInex + mergeCols[mergeCols.length - 1].index) as TableCellElement;
|
323
328
|
TableUtil.combineCells(tb, startCell, endCell);
|
324
329
|
}
|
325
330
|
}
|
326
331
|
}
|
332
|
+
|
333
|
+
|
327
334
|
/**
|
328
335
|
* 纵向拆分合并的单元格
|
329
336
|
* 在指定行下插入复制行
|
330
337
|
* 存在
|
331
338
|
*/
|
332
|
-
static verSplitVerMergeCell(ss, rows, endColIndex) {
|
339
|
+
private static verSplitVerMergeCell(ss: SelectionState, rows: number, endColIndex: number): void {
|
333
340
|
if (rows === 1) {
|
334
341
|
return;
|
335
342
|
}
|
@@ -353,7 +360,7 @@ export class TableSplitCell {
|
|
353
360
|
for (let i = 0; i < rows - 1; i++) {
|
354
361
|
const newRow = new TableRowElement();
|
355
362
|
for (let i = 0; i < focusRow.length; i++) {
|
356
|
-
const focusRowCell = focusRow.getChild(i);
|
363
|
+
const focusRowCell = focusRow.getChild(i) as TableCellElement;
|
357
364
|
const cell = new TableCellElement();
|
358
365
|
//其他列要纵向合并
|
359
366
|
if (i < focusCellIndex || i > endColIndex) {
|
@@ -373,92 +380,96 @@ export class TableSplitCell {
|
|
373
380
|
//拆分行和合并行相等,则执行还原
|
374
381
|
if (rows === mergeRows) {
|
375
382
|
for (let i = 0; i < mergeRows; i++) {
|
376
|
-
const row = tb.getChild(focusRowIndex + i);
|
383
|
+
const row = tb.getChild(focusRowIndex + i) as TableRowElement;
|
377
384
|
for (let j = focusCellIndex; j <= endColIndex; j++) {
|
378
|
-
const cell = row.getChild(j);
|
385
|
+
const cell = row.getChild(j) as TableCellElement;
|
379
386
|
cell.props.vMerge = null;
|
380
387
|
}
|
381
388
|
}
|
382
|
-
}
|
383
|
-
else {
|
389
|
+
} else {
|
384
390
|
for (let i = 0; i < mergeRows; i++) {
|
385
391
|
if (i % rows === 0) {
|
386
|
-
const row = tb.getChild(focusRowIndex + i);
|
387
|
-
const cell = row.getChild(focusCellIndex);
|
392
|
+
const row = tb.getChild(focusRowIndex + i) as TableRowElement;
|
393
|
+
const cell = row.getChild(focusCellIndex) as TableCellElement;
|
388
394
|
cell.props.vMerge = 'restart';
|
389
395
|
}
|
390
396
|
}
|
391
397
|
}
|
392
398
|
}
|
393
399
|
}
|
394
|
-
|
395
|
-
|
400
|
+
|
401
|
+
|
402
|
+
|
403
|
+
private static getSplitCols(width: number, cols: number): Array<ColumnPart> {
|
404
|
+
const items: Array<ColumnPart> = [];
|
396
405
|
for (let i = 0; i < cols; i++) {
|
397
406
|
items.push({ width: Math.floor(width / cols), index: i });
|
398
407
|
}
|
399
408
|
items[items.length - 1].width += width - items.reduce((prev, curr) => prev + curr.width, 0);
|
400
409
|
return items;
|
401
410
|
}
|
411
|
+
|
402
412
|
/**
|
403
413
|
* 获取横向合并的列
|
404
|
-
* @param tb
|
405
|
-
* @param currRowIndex
|
406
|
-
* @param currColIndex
|
407
|
-
* @param splitCols
|
414
|
+
* @param tb
|
415
|
+
* @param currRowIndex
|
416
|
+
* @param currColIndex
|
417
|
+
* @param splitCols
|
408
418
|
*/
|
409
|
-
static getHMergeCols(tb, currRowIndex, currColIndex, splitCols) {
|
410
|
-
const row = tb.getChild(currRowIndex);
|
411
|
-
const items = [{ width: tb.getCellWidth(currColIndex), index: currColIndex }];
|
419
|
+
private static getHMergeCols(tb: TableElement, currRowIndex: number, currColIndex: number, splitCols: number): Array<ColumnPart> {
|
420
|
+
const row = tb.getChild(currRowIndex) as TableRowElement;
|
421
|
+
const items: Array<ColumnPart> = [{ width: tb.getCellWidth(currColIndex), index: currColIndex }];
|
412
422
|
for (let i = currColIndex + 1; i < tb.getColsCount(); i++) {
|
413
|
-
const cell = row.getChild(i);
|
423
|
+
const cell = row.getChild(i) as TableCellElement;
|
414
424
|
if (cell.props.hMerge === 'continue') {
|
415
425
|
items.push({ width: tb.getCellWidth(i), index: i });
|
416
|
-
}
|
417
|
-
else {
|
426
|
+
} else {
|
418
427
|
break;
|
419
428
|
}
|
420
429
|
}
|
421
430
|
return items;
|
422
431
|
}
|
432
|
+
|
423
433
|
/**
|
424
434
|
* 获取纵向合并的行数
|
425
|
-
* @param tb
|
426
|
-
* @param currRowIndex
|
435
|
+
* @param tb
|
436
|
+
* @param currRowIndex
|
427
437
|
*/
|
428
|
-
static getVMergeRowsCount(tb, rowIndex, colIndex) {
|
429
|
-
const startCell = tb.getChild(rowIndex).getChild(colIndex)
|
438
|
+
private static getVMergeRowsCount(tb: TableElement, rowIndex: number, colIndex: number): number {
|
439
|
+
const startCell = <TableCellElement>(<TableRowElement>tb.getChild(rowIndex)).getChild(colIndex)
|
430
440
|
if (startCell.props.vMerge !== 'restart') {
|
431
441
|
return 1;
|
432
442
|
}
|
433
443
|
let i = 0;
|
434
444
|
for (i = rowIndex + 1; i < tb.length; i++) {
|
435
|
-
const row = tb.getChild(i);
|
436
|
-
const cell = row.getChild(colIndex);
|
445
|
+
const row = tb.getChild(i) as TableRowElement;
|
446
|
+
const cell = row.getChild(colIndex) as TableCellElement;
|
437
447
|
if (cell.props.vMerge !== 'continue') {
|
438
448
|
return i - rowIndex;
|
439
449
|
}
|
440
450
|
}
|
441
451
|
return i - rowIndex;
|
442
452
|
}
|
453
|
+
|
443
454
|
/**
|
444
455
|
* 获取纵向合并的行数
|
445
|
-
* @param tb
|
446
|
-
* @param currRowIndex
|
456
|
+
* @param tb
|
457
|
+
* @param currRowIndex
|
447
458
|
*/
|
448
|
-
static getHMergeColsCount(tb, rowIndex, colIndex) {
|
449
|
-
const row = tb.getChild(rowIndex);
|
450
|
-
const startCell = row.getChild(colIndex)
|
459
|
+
private static getHMergeColsCount(tb: TableElement, rowIndex: number, colIndex: number): number {
|
460
|
+
const row = tb.getChild<TableRowElement>(rowIndex);
|
461
|
+
const startCell = row.getChild<TableCellElement>(colIndex)
|
451
462
|
if (startCell.props.hMerge !== 'restart') {
|
452
463
|
return 1;
|
453
464
|
}
|
454
465
|
let i = 0;
|
455
466
|
for (i = colIndex + 1; i < row.length; i++) {
|
456
|
-
const cell = row.getChild(i);
|
467
|
+
const cell = row.getChild(i) as TableCellElement;
|
457
468
|
if (cell.props.hMerge !== 'continue') {
|
458
469
|
return i - colIndex;
|
459
470
|
}
|
460
471
|
}
|
461
472
|
return i - colIndex;
|
462
473
|
}
|
474
|
+
|
463
475
|
}
|
464
|
-
//# sourceMappingURL=table-split-cell.js.map
|