@hailin-zheng/editor-core 1.0.6 → 1.0.9
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 +2 -2
- 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/{lib/framework/impl/table/table-impl.js → src/med_editor/framework/impl/table/table-impl.ts}
RENAMED
@@ -1,59 +1,71 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
import {
|
2
|
+
BlockContainerElement,
|
3
|
+
Element,
|
4
|
+
ElementFactory,
|
5
|
+
Position,
|
6
|
+
SerializeProps,
|
7
|
+
ViewOptions
|
8
|
+
} from "../../element-define";
|
9
|
+
import { ContentMenuItem, ContextMenuElementEvent, KeyboradElementEvent } from "../../element-event-define";
|
10
|
+
import { TableProps } from "../../element-props";
|
11
|
+
import { ElementUtil } from "../../element-util";
|
12
|
+
import { RenderContenxtType } from "../../render-context";
|
13
|
+
import { MuiltBlockLineRenderObject, RenderObject } from "../../render-define";
|
14
|
+
import { ParagraphElement, ParagraphRenderObject } from "../paragraph/p-impl";
|
15
|
+
import { TableCellRenderObject } from "./table-cell-impl";
|
16
|
+
import { TableRowElement, TableRowRenderObject } from "./table-row-impl";
|
7
17
|
import { TableSplitCell } from "./table-split-cell";
|
8
18
|
import { TableUtil } from "./table-util";
|
19
|
+
|
9
20
|
/**
|
10
21
|
* 计算表格列
|
11
22
|
*/
|
12
|
-
function calcTableCols(element) {
|
13
|
-
const percentCols = [];
|
23
|
+
function calcTableCols(element: TableElement): Array<{ width: number, offset: number }> {
|
24
|
+
const percentCols: Array<{ width: string | number }> = [];
|
14
25
|
let sum = 0;
|
15
26
|
let percentSum = 0;
|
16
27
|
for (const col of element.props.cols) {
|
17
28
|
if (typeof col.width === 'string') {
|
18
29
|
percentCols.push(col);
|
19
30
|
percentSum += Number.parseFloat(col.width);
|
20
|
-
}
|
21
|
-
|
22
|
-
sum += col.width;
|
31
|
+
} else {
|
32
|
+
sum += col.width as number;
|
23
33
|
}
|
24
34
|
}
|
25
|
-
const measureRender = element.measureRender;
|
26
|
-
const tbWidth = measureRender.rect.maxWidth;
|
35
|
+
const measureRender = element.measureRender as RenderObject;
|
36
|
+
const tbWidth = measureRender.rect.maxWidth as number;
|
27
37
|
if (percentCols.length > 0) {
|
28
38
|
const remainWidth = tbWidth - sum;
|
29
39
|
let remainSum = 0;
|
30
40
|
for (const percentCol of percentCols) {
|
31
41
|
const percentWidth = Number.parseFloat(percentCol.width.toString());
|
42
|
+
|
32
43
|
percentCol.width = Math.floor(remainWidth * percentWidth / percentSum);
|
33
|
-
remainSum += percentCol.width;
|
44
|
+
remainSum += percentCol.width as number;
|
34
45
|
}
|
35
46
|
if (remainWidth - remainSum > 0) {
|
36
|
-
const colWidth = percentCols[percentCols.length - 1].width;
|
47
|
+
const colWidth = percentCols[percentCols.length - 1].width as number;
|
37
48
|
percentCols[percentCols.length - 1].width = colWidth + (remainWidth - remainSum);
|
38
49
|
}
|
39
50
|
}
|
40
|
-
const array = [];
|
51
|
+
const array: Array<{ width: number, offset: number }> = [];
|
41
52
|
let offset = 0;
|
42
53
|
for (let i = 0; i < element.props.cols.length; i++) {
|
43
|
-
const width = element.props.cols[i].width;
|
54
|
+
const width = element.props.cols[i].width as number;
|
44
55
|
array.push({ width, offset });
|
45
56
|
offset += width;
|
46
57
|
}
|
47
58
|
return array;
|
48
59
|
}
|
49
|
-
|
60
|
+
|
61
|
+
export class TableElement extends BlockContainerElement<TableProps> {
|
50
62
|
//props: TableProps;
|
51
|
-
_actualColsProps;
|
63
|
+
private _actualColsProps!: Array<{ width: number, offset: number }> | null;
|
52
64
|
constructor() {
|
53
65
|
super('tb');
|
54
66
|
this.props = new TableProps();
|
55
67
|
//this.addPropValueChangedSub(this.props);
|
56
|
-
this.addEvent('ElementContextMenu', (evt) => {
|
68
|
+
this.addEvent<ContextMenuElementEvent>('ElementContextMenu', (evt) => {
|
57
69
|
const { selectionState } = evt;
|
58
70
|
if (TableUtil.canDeleteTable(selectionState)) {
|
59
71
|
evt.menus.push({
|
@@ -71,17 +83,20 @@ export class TableElement extends BlockContainerElement {
|
|
71
83
|
});
|
72
84
|
}
|
73
85
|
if (TableUtil.canMergeCells(selectionState)) {
|
74
|
-
evt.menus.push({ icon: 'MergeDuplicate', caption: '合并单元格', eventObj: { onClick: (cevt) => { TableUtil.mergeCells(selectionState)
|
86
|
+
evt.menus.push({ icon: 'MergeDuplicate', caption: '合并单元格', eventObj: { onClick: (cevt) => { TableUtil.mergeCells(selectionState) } } });
|
75
87
|
}
|
76
88
|
if (TableUtil.canSplitCell(selectionState)) {
|
77
|
-
evt.menus.push({ icon: 'Split', caption: '拆分单元格', eventObj: { onClick: (cevt) => { TableSplitCell.splitCell(selectionState, 0, 2)
|
78
|
-
evt.menus.push({ icon: 'Combine', caption: '合并单元格还原', eventObj: { onClick: (cevt) => { TableUtil.restoreCell(selectionState)
|
89
|
+
evt.menus.push({ icon: 'Split', caption: '拆分单元格', eventObj: { onClick: (cevt) => { TableSplitCell.splitCell(selectionState, 0, 2) } } });
|
90
|
+
evt.menus.push({ icon: 'Combine', caption: '合并单元格还原', eventObj: { onClick: (cevt) => { TableUtil.restoreCell(selectionState) } } });
|
91
|
+
|
79
92
|
}
|
80
|
-
evt.menus.push({ icon: "Insert", caption: '上方插入段落', eventObj: { onClick: (cevt) => { this.parent.addChild(ParagraphElement.createElement(), this.getIndex()); this.refreshView()
|
81
|
-
evt.menus.push({ icon: "Insert", caption: '下方插入段落', eventObj: { onClick: (cevt) => { this.parent.addChild(ParagraphElement.createElement(), this.getIndex() + 1); this.refreshView()
|
93
|
+
evt.menus.push({ icon: "Insert", caption: '上方插入段落', eventObj: { onClick: (cevt) => { this.parent.addChild(ParagraphElement.createElement(), this.getIndex()); this.refreshView() } } });
|
94
|
+
evt.menus.push({ icon: "Insert", caption: '下方插入段落', eventObj: { onClick: (cevt) => { this.parent.addChild(ParagraphElement.createElement(), this.getIndex() + 1); this.refreshView() } } });
|
95
|
+
|
96
|
+
|
82
97
|
evt.menus = removeDuplicatesEvent(evt.menus);
|
83
98
|
}, true);
|
84
|
-
this.addEvent('ElementKeyDown', (evt) => {
|
99
|
+
this.addEvent<KeyboradElementEvent>('ElementKeyDown', (evt) => {
|
85
100
|
//console.log('表格ElementKeyDown', evt);
|
86
101
|
const sourceEvent = evt.sourceEvent;
|
87
102
|
//按下tab键
|
@@ -101,42 +116,48 @@ export class TableElement extends BlockContainerElement {
|
|
101
116
|
}
|
102
117
|
return this._actualColsProps;
|
103
118
|
}
|
104
|
-
|
119
|
+
|
120
|
+
getCellWidth(cellIndex: number): number {
|
105
121
|
if (cellIndex >= this.actualColsProps.length || cellIndex < 0) {
|
106
122
|
return -1;
|
107
123
|
}
|
108
124
|
return this.actualColsProps[cellIndex].width;
|
109
125
|
}
|
110
|
-
|
126
|
+
|
127
|
+
getCellOffsetX(cellIndex: number): number {
|
111
128
|
return this.actualColsProps[cellIndex].offset;
|
112
129
|
}
|
113
|
-
|
130
|
+
|
131
|
+
setCellWidth(cellIndex: number, width: number): void {
|
114
132
|
//this.actualColsProps[index].width = width;
|
115
133
|
if (cellIndex >= this.actualColsProps.length || cellIndex < 0) {
|
116
134
|
return;
|
117
135
|
}
|
118
136
|
this.props.cols[cellIndex].width = width;
|
119
137
|
}
|
138
|
+
|
120
139
|
/**
|
121
140
|
* 插入列的定义
|
122
|
-
* @param index
|
123
|
-
* @param width
|
141
|
+
* @param index
|
142
|
+
* @param width
|
124
143
|
*/
|
125
|
-
insertCol(index, width) {
|
144
|
+
insertCol(index: number, width: number | string): void {
|
126
145
|
this.props.cols.splice(index, 0, { width });
|
127
146
|
this._actualColsProps = null;
|
128
147
|
}
|
148
|
+
|
129
149
|
/**
|
130
150
|
* 移除列的定义
|
131
|
-
* @param index
|
151
|
+
* @param index
|
132
152
|
*/
|
133
|
-
removeCol(index) {
|
153
|
+
removeCol(index: number): void {
|
134
154
|
this.props.cols.splice(index, 1);
|
135
155
|
}
|
136
|
-
|
156
|
+
|
157
|
+
getColsCount(): number {
|
137
158
|
return this.actualColsProps.length;
|
138
159
|
}
|
139
|
-
clone(data) {
|
160
|
+
clone(data: boolean): Element {
|
140
161
|
const clone = new TableElement();
|
141
162
|
this.props.clone(clone.props);
|
142
163
|
if (data) {
|
@@ -146,23 +167,27 @@ export class TableElement extends BlockContainerElement {
|
|
146
167
|
}
|
147
168
|
return clone;
|
148
169
|
}
|
149
|
-
|
170
|
+
|
171
|
+
createRenderObject(options: ViewOptions, renderCtx: RenderContenxtType): RenderObject {
|
150
172
|
return new TableRenderObject(this);
|
151
173
|
}
|
152
|
-
|
174
|
+
|
175
|
+
beginMeasure(): void {
|
153
176
|
super.beginMeasure();
|
154
177
|
this._actualColsProps = null;
|
155
178
|
}
|
156
|
-
|
179
|
+
|
180
|
+
serialize(options: ViewOptions): SerializeProps {
|
157
181
|
//this.props.width = this.measureRender?.rect.width as number;
|
158
182
|
const props = {
|
159
183
|
type: 'tb',
|
160
184
|
props: { ...this.props.getSerializeProps(options) }
|
161
|
-
}
|
162
|
-
props.props.width = this.measureRender?.rect.width;
|
185
|
+
}
|
186
|
+
props.props.width = this.measureRender?.rect.width as number;
|
163
187
|
return props;
|
164
188
|
}
|
165
|
-
|
189
|
+
|
190
|
+
static createTable(rows: number, cols: number): TableElement {
|
166
191
|
const table = new TableElement();
|
167
192
|
const tbProps = new TableProps();
|
168
193
|
table.props = tbProps;
|
@@ -177,8 +202,9 @@ export class TableElement extends BlockContainerElement {
|
|
177
202
|
return table;
|
178
203
|
}
|
179
204
|
}
|
180
|
-
|
181
|
-
|
205
|
+
|
206
|
+
function removeDuplicatesEvent(events: ContentMenuItem[]): ContentMenuItem[] {
|
207
|
+
let arr: ContentMenuItem[] = [];
|
182
208
|
for (let i = events.length - 1; i >= 0; i--) {
|
183
209
|
let keys = arr.map(item => item.caption);
|
184
210
|
if (!keys.includes(events[i].caption)) {
|
@@ -187,21 +213,23 @@ function removeDuplicatesEvent(events) {
|
|
187
213
|
}
|
188
214
|
return arr;
|
189
215
|
}
|
190
|
-
|
191
|
-
|
216
|
+
|
217
|
+
export class TableRenderObject extends MuiltBlockLineRenderObject<TableElement> {
|
218
|
+
setRenderWidth(maxWidth: number): void {
|
192
219
|
super.setRenderWidth(maxWidth);
|
193
220
|
}
|
194
|
-
|
221
|
+
|
222
|
+
beginRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
195
223
|
//绘制表格线
|
196
224
|
if (this.element.props.border !== 'all') {
|
197
225
|
return;
|
198
226
|
}
|
199
227
|
for (let i = 0; i < this.length; i++) {
|
200
|
-
const rowRender = this.getChild(i);
|
201
|
-
const rowPos = { x: rowRender.rect.x + position.x, y: rowRender.rect.y + position.y };
|
228
|
+
const rowRender = this.getChild(i) as TableRowRenderObject;
|
229
|
+
const rowPos: Position = { x: rowRender.rect.x + position.x, y: rowRender.rect.y + position.y };
|
202
230
|
for (let j = 0; j < rowRender.length; j++) {
|
203
|
-
const cellRender = rowRender.getChild(j);
|
204
|
-
const cellPos = { x: cellRender.rect.x + rowPos.x, y: cellRender.rect.y + rowPos.y };
|
231
|
+
const cellRender = rowRender.getChild(j) as TableCellRenderObject;
|
232
|
+
const cellPos: Position = { x: cellRender.rect.x + rowPos.x, y: cellRender.rect.y + rowPos.y };
|
205
233
|
//绘制单元格上边框
|
206
234
|
if (i === 0) {
|
207
235
|
//ctx.contentContext.fillRect(cellPos.x, cellPos.y, cellRender.rect.width, 1);
|
@@ -226,9 +254,10 @@ export class TableRenderObject extends MuiltBlockLineRenderObject {
|
|
226
254
|
}
|
227
255
|
}
|
228
256
|
}
|
229
|
-
|
257
|
+
|
258
|
+
endRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
230
259
|
}
|
231
|
-
clone() {
|
260
|
+
clone(): RenderObject {
|
232
261
|
const cloneRender = new TableRenderObject(this.element);
|
233
262
|
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
234
263
|
for (let i = 0; i < this.length; i++) {
|
@@ -237,12 +266,14 @@ export class TableRenderObject extends MuiltBlockLineRenderObject {
|
|
237
266
|
return cloneRender;
|
238
267
|
}
|
239
268
|
}
|
240
|
-
|
241
|
-
|
269
|
+
|
270
|
+
|
271
|
+
export class TableFactory extends ElementFactory<TableProps> {
|
272
|
+
match(type: string): boolean {
|
242
273
|
return type === 'tb';
|
243
274
|
}
|
244
|
-
createElement(data, renderCtx) {
|
245
|
-
const props = data.props;
|
275
|
+
createElement(data: any, renderCtx: RenderContenxtType): Element {
|
276
|
+
const props = data.props as TableProps;
|
246
277
|
const tb = new TableElement();
|
247
278
|
const cols = props.cols;
|
248
279
|
const tbProps = tb.props;
|
@@ -256,17 +287,19 @@ export class TableFactory extends ElementFactory {
|
|
256
287
|
tb.props = tbProps;
|
257
288
|
return tb;
|
258
289
|
}
|
290
|
+
|
259
291
|
}
|
292
|
+
|
260
293
|
/**
|
261
294
|
* 行-表格渲染模式
|
262
295
|
*/
|
263
|
-
export function textLineRenderMode(ele, options, renderCtx) {
|
264
|
-
const tb = ele.measureRender;
|
265
|
-
const rows = []
|
296
|
+
export function textLineRenderMode(ele: TableElement, options: ViewOptions, renderCtx: RenderContenxtType): boolean {
|
297
|
+
const tb = ele.measureRender as TableRenderObject;
|
298
|
+
const rows: Array<TableRowRenderObject> = []
|
266
299
|
for (let i = 0; i < tb.length; i++) {
|
267
|
-
const row = tb.getChild(i);
|
300
|
+
const row = tb.getChild(i) as TableRowRenderObject;
|
268
301
|
//表格头不做处理
|
269
|
-
if (row.element.props.headerRow) {
|
302
|
+
if ((<TableRowElement>row.element).props.headerRow) {
|
270
303
|
continue;
|
271
304
|
}
|
272
305
|
rows.push(row);
|
@@ -277,16 +310,16 @@ export function textLineRenderMode(ele, options, renderCtx) {
|
|
277
310
|
const maxLinesCount = getRowMaxTextLines(row);
|
278
311
|
if (maxLinesCount > 1) {
|
279
312
|
for (let j = 1; j < maxLinesCount; j++) {
|
280
|
-
const newRow = row.element.createRenderObject();
|
313
|
+
const newRow = row.element.createRenderObject() as TableRowRenderObject;
|
281
314
|
newRow.rect = ElementUtil.cloneRect(row.rect);
|
282
315
|
tb.insertChild(newRow, row.getIndex() + 1);
|
283
316
|
//复制行文字到新行中
|
284
317
|
for (let k = 0; k < row.length; k++) {
|
285
|
-
const cell = row.getChild(k);
|
286
|
-
const newCell = cell.element.createRenderObject(options, renderCtx)
|
318
|
+
const cell = row.getChild(k) as TableCellRenderObject;
|
319
|
+
const newCell = cell.element.createRenderObject(options, renderCtx) as TableCellRenderObject
|
287
320
|
newCell.rect = ElementUtil.cloneRect(cell.rect);
|
288
321
|
if (newCell) {
|
289
|
-
newRow.addChild(newCell)
|
322
|
+
newRow.addChild(newCell)
|
290
323
|
}
|
291
324
|
}
|
292
325
|
}
|
@@ -296,68 +329,73 @@ export function textLineRenderMode(ele, options, renderCtx) {
|
|
296
329
|
ElementUtil.remeasure(tb);
|
297
330
|
return true;
|
298
331
|
}
|
332
|
+
|
299
333
|
/**
|
300
334
|
* 获取当前行的文字行数
|
301
|
-
* @param row
|
302
|
-
* @returns
|
335
|
+
* @param row
|
336
|
+
* @returns
|
303
337
|
*/
|
304
|
-
function getRowMaxTextLines(row) {
|
338
|
+
function getRowMaxTextLines(row: TableRowRenderObject): number {
|
305
339
|
let count = 0;
|
306
340
|
for (let j = 0; j < row.length; j++) {
|
307
|
-
const cell = row.getChild(j);
|
341
|
+
const cell = row.getChild(j) as TableCellRenderObject;
|
308
342
|
let cellMaxLines = 0;
|
309
343
|
for (let k = 0; k < cell.length; k++) {
|
310
|
-
const paraRender = cell.getChild(k);
|
344
|
+
const paraRender = cell.getChild(k) as ParagraphRenderObject;
|
311
345
|
cellMaxLines += paraRender.length;
|
312
346
|
}
|
313
347
|
count = cellMaxLines > count ? cellMaxLines : count;
|
314
348
|
}
|
315
349
|
return count;
|
316
350
|
}
|
351
|
+
|
317
352
|
/**
|
318
353
|
* 将多行文本移动到新行中
|
319
|
-
* @param row
|
320
|
-
* @param maxLinesCount
|
321
|
-
* @returns
|
354
|
+
* @param row
|
355
|
+
* @param maxLinesCount
|
356
|
+
* @returns
|
322
357
|
*/
|
323
|
-
function splitTextlineToNewRow(row, maxLinesCount, options, renderCtx) {
|
358
|
+
function splitTextlineToNewRow(row: TableRowRenderObject, maxLinesCount: number, options: ViewOptions, renderCtx: RenderContenxtType): void {
|
324
359
|
if (maxLinesCount === 1) {
|
325
360
|
return;
|
326
361
|
}
|
327
362
|
for (let i = 0; i < row.length; i++) {
|
328
|
-
const cell = row.getChild(i);
|
363
|
+
const cell = row.getChild(i) as TableCellRenderObject;
|
329
364
|
const paraLines = ElementUtil.getCellParaLines(cell);
|
330
365
|
if (paraLines.length === 1) {
|
331
366
|
continue;
|
332
367
|
}
|
333
368
|
for (let j = 1; j < paraLines.length; j++) {
|
334
369
|
const outterLineRect = paraLines[j];
|
335
|
-
const paraRender = outterLineRect.parent;
|
336
|
-
|
370
|
+
const paraRender = outterLineRect.parent as ParagraphRenderObject;
|
371
|
+
|
372
|
+
const newParaRender = paraRender.element.createRenderObject(options, renderCtx) as ParagraphRenderObject;
|
337
373
|
newParaRender.rect = ElementUtil.cloneRect(paraRender.rect);
|
374
|
+
|
338
375
|
const newOutterLineRect = outterLineRect.clone();
|
339
376
|
newOutterLineRect.rect = ElementUtil.cloneRect(outterLineRect.rect);
|
340
377
|
newParaRender.addChild(newOutterLineRect);
|
378
|
+
|
341
379
|
paraRender.removeChild(outterLineRect);
|
342
380
|
ElementUtil.remeasure(paraRender);
|
381
|
+
|
343
382
|
if (paraRender.length === 0) {
|
344
383
|
cell.removeChild(paraRender);
|
345
384
|
}
|
346
|
-
const splitRow = row.parent.getChild(row.getIndex() + j);
|
347
|
-
const splitCell = splitRow.getChild(i);
|
385
|
+
const splitRow = row.parent.getChild(row.getIndex() + j) as TableRowRenderObject;
|
386
|
+
const splitCell = splitRow.getChild(i) as TableCellRenderObject;
|
348
387
|
splitCell.addChild(newParaRender);
|
349
388
|
ElementUtil.remeasure(newParaRender);
|
350
389
|
}
|
351
390
|
}
|
352
|
-
const tb = row.parent;
|
391
|
+
const tb = row.parent as TableRenderObject;
|
353
392
|
const rowIndex = row.getIndex();
|
354
393
|
for (let i = 0; i < maxLinesCount; i++) {
|
355
|
-
const row = tb.getChild(rowIndex + i);
|
394
|
+
const row = tb.getChild(rowIndex + i) as TableRowRenderObject;
|
356
395
|
for (let j = 0; j < row.length; j++) {
|
357
|
-
const cell = row.getChild(j);
|
396
|
+
const cell = row.getChild(j) as TableCellRenderObject;
|
358
397
|
ElementUtil.remeasure(cell);
|
359
398
|
}
|
360
399
|
ElementUtil.remeasure(row);
|
361
400
|
}
|
362
401
|
}
|
363
|
-
//# sourceMappingURL=table-impl.js.map
|
@@ -1,9 +1,11 @@
|
|
1
|
-
import { BlockContainerElement, ElementFactory, ModifyFlag } from "
|
2
|
-
import { TableRowProps } from "
|
3
|
-
import { ElementUtil } from "
|
4
|
-
import {
|
1
|
+
import { BlockContainerElement, Element, ElementFactory, ModifyFlag, readElementProps, SerializeProps, ViewOptions } from "../../element-define";
|
2
|
+
import { TableRowProps } from "../../element-props";
|
3
|
+
import { ElementUtil } from "../../element-util";
|
4
|
+
import { RenderContenxtType } from "../../render-context";
|
5
|
+
import { MuiltBlockLineRenderObject, RenderObject } from "../../render-define";
|
5
6
|
import { TableCellElement } from "./table-cell-impl";
|
6
|
-
|
7
|
+
|
8
|
+
export class TableRowElement extends BlockContainerElement<TableRowProps> {
|
7
9
|
//props: TableRowProps;
|
8
10
|
constructor() {
|
9
11
|
super('tr');
|
@@ -17,10 +19,12 @@ export class TableRowElement extends BlockContainerElement {
|
|
17
19
|
});
|
18
20
|
this.addsubscribe(this, changeSub);
|
19
21
|
}
|
20
|
-
|
22
|
+
|
23
|
+
createRenderObject(): RenderObject {
|
21
24
|
return new TableRowRenderObject(this);
|
22
25
|
}
|
23
|
-
|
26
|
+
|
27
|
+
serialize(viewOptions: ViewOptions): SerializeProps {
|
24
28
|
return {
|
25
29
|
type: 'tr',
|
26
30
|
props: {
|
@@ -28,7 +32,7 @@ export class TableRowElement extends BlockContainerElement {
|
|
28
32
|
}
|
29
33
|
};
|
30
34
|
}
|
31
|
-
clone(data) {
|
35
|
+
clone(data: boolean): Element {
|
32
36
|
const clone = new TableRowElement();
|
33
37
|
this.props.clone(clone.props);
|
34
38
|
if (data) {
|
@@ -38,7 +42,8 @@ export class TableRowElement extends BlockContainerElement {
|
|
38
42
|
}
|
39
43
|
return clone;
|
40
44
|
}
|
41
|
-
|
45
|
+
|
46
|
+
static createRow(cols: number): TableRowElement {
|
42
47
|
const tr = new TableRowElement();
|
43
48
|
for (let i = 0; i < cols; i++) {
|
44
49
|
tr.addChild(TableCellElement.createCell());
|
@@ -46,12 +51,14 @@ export class TableRowElement extends BlockContainerElement {
|
|
46
51
|
return tr;
|
47
52
|
}
|
48
53
|
}
|
49
|
-
|
50
|
-
|
54
|
+
|
55
|
+
export class TableRowRenderObject extends MuiltBlockLineRenderObject<TableRowElement> {
|
56
|
+
beginRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
51
57
|
}
|
52
|
-
endRender(ctx, position) {
|
58
|
+
endRender(ctx: RenderContenxtType, position: { x: number; y: number; }): void {
|
53
59
|
}
|
54
|
-
|
60
|
+
|
61
|
+
clone(): RenderObject {
|
55
62
|
const cloneRender = new TableRowRenderObject(this.element);
|
56
63
|
cloneRender.rect = ElementUtil.cloneRect(this.rect);
|
57
64
|
for (let i = 0; i < this.length; i++) {
|
@@ -60,16 +67,17 @@ export class TableRowRenderObject extends MuiltBlockLineRenderObject {
|
|
60
67
|
return cloneRender;
|
61
68
|
}
|
62
69
|
}
|
63
|
-
|
64
|
-
|
70
|
+
|
71
|
+
export class TableRowFactory extends ElementFactory<TableRowProps> {
|
72
|
+
match(type: string): boolean {
|
65
73
|
return type === 'tr';
|
66
74
|
}
|
67
|
-
createElement(data
|
68
|
-
const props = data.props;
|
75
|
+
createElement(data: readElementProps<TableRowProps>, renderCtx: RenderContenxtType): Element {
|
76
|
+
const props = data.props as TableRowProps;
|
69
77
|
const tr = new TableRowElement();
|
70
78
|
tr.props.minHeight = props?.minHeight ?? -1;
|
71
79
|
tr.props.headerRow = props?.headerRow;
|
72
80
|
return tr;
|
73
81
|
}
|
82
|
+
|
74
83
|
}
|
75
|
-
//# sourceMappingURL=table-row-impl.js.map
|
@@ -1,9 +1,12 @@
|
|
1
|
+
export interface ColumnPartOffset extends ColumnPart { offset: number }
|
2
|
+
export interface ColumnPart { index: number, width: number }
|
3
|
+
export interface ColumnPatch { type: 'modify' | 'insert', data: ColumnPart }
|
1
4
|
export class ColumnPatchUtil {
|
2
|
-
static getPatchPacks(cols
|
5
|
+
static getPatchPacks(cols: Array<ColumnPart>, splitCols: Array<ColumnPart>): [Array<{ part: ColumnPartOffset, patchs: Array<ColumnPatch> }>, Array<Array<ColumnPart>>] {
|
3
6
|
const oldLinePointMap = this.getLinePointMap(cols);
|
4
7
|
//要分割的列坐标
|
5
8
|
const newLinePointMap = this.getLinePointMap(splitCols);
|
6
|
-
const resArray = new Set();
|
9
|
+
const resArray: Set<number> = new Set();
|
7
10
|
const allPointMap = oldLinePointMap.concat(newLinePointMap);
|
8
11
|
for (let i = 0; i < allPointMap.length; i++) {
|
9
12
|
const part = allPointMap[i];
|
@@ -11,7 +14,7 @@ export class ColumnPatchUtil {
|
|
11
14
|
resArray.add(part.offset + part.width);
|
12
15
|
}
|
13
16
|
const points = Array.from(resArray).sort((first, second) => first - second);
|
14
|
-
const patchs = [];
|
17
|
+
const patchs: Array<{ part: ColumnPartOffset, patchs: Array<ColumnPatch> }> = [];
|
15
18
|
//获取其他行的拆分补丁
|
16
19
|
for (let i = 0; i < points.length - 1; i++) {
|
17
20
|
const partStartOffset = points[i];
|
@@ -19,11 +22,13 @@ export class ColumnPatchUtil {
|
|
19
22
|
const joinPart = oldLinePointMap.find(item => {
|
20
23
|
const startOffset = item.offset;
|
21
24
|
const endOffset = item.offset + item.width;
|
22
|
-
return (
|
25
|
+
return (
|
26
|
+
(startOffset >= partStartOffset && startOffset < partEndOffset)
|
23
27
|
||
|
24
|
-
|
28
|
+
(endOffset > partStartOffset && endOffset <= partEndOffset)
|
25
29
|
||
|
26
|
-
|
30
|
+
(startOffset <= partStartOffset && endOffset >= partEndOffset)
|
31
|
+
)
|
27
32
|
});
|
28
33
|
if (joinPart) {
|
29
34
|
if (joinPart.offset === partStartOffset && joinPart.offset + joinPart.width === partEndOffset) {
|
@@ -31,18 +36,17 @@ export class ColumnPatchUtil {
|
|
31
36
|
}
|
32
37
|
const patch = patchs.find(item => item.part === joinPart);
|
33
38
|
if (patch) {
|
34
|
-
patch.patchs.push({ type: 'insert', data: { width: partEndOffset - partStartOffset, index: joinPart.index } })
|
35
|
-
}
|
36
|
-
else {
|
39
|
+
patch.patchs.push({ type: 'insert', data: { width: partEndOffset - partStartOffset, index: joinPart.index } })
|
40
|
+
} else {
|
37
41
|
patchs.push({
|
38
42
|
part: joinPart,
|
39
43
|
patchs: [{ type: 'modify', data: { width: partEndOffset - partStartOffset, index: joinPart.index } }]
|
40
|
-
})
|
44
|
+
})
|
41
45
|
}
|
42
46
|
}
|
43
47
|
}
|
44
48
|
//获取当前行的拆分补丁
|
45
|
-
const currRowPaths = [];
|
49
|
+
const currRowPaths: Array<Array<ColumnPart>> = [];
|
46
50
|
const allColumnMap = this.getLinePointMap(this.getColumn(points));
|
47
51
|
for (let i = 0; i < newLinePointMap.length; i++) {
|
48
52
|
const partStartOffset = newLinePointMap[i].offset;
|
@@ -50,33 +54,39 @@ export class ColumnPatchUtil {
|
|
50
54
|
const joinParts = allColumnMap.filter(item => {
|
51
55
|
const startOffset = item.offset;
|
52
56
|
const endOffset = item.offset + item.width;
|
53
|
-
return (
|
57
|
+
return (
|
58
|
+
(startOffset >= partStartOffset && startOffset < partEndOffset)
|
54
59
|
||
|
55
|
-
|
60
|
+
(endOffset > partStartOffset && endOffset <= partEndOffset)
|
56
61
|
||
|
57
|
-
|
62
|
+
(startOffset <= partStartOffset && endOffset >= partEndOffset)
|
63
|
+
)
|
58
64
|
});
|
59
65
|
currRowPaths.push(joinParts);
|
60
66
|
}
|
61
67
|
return [patchs, currRowPaths];
|
62
68
|
}
|
63
|
-
|
64
|
-
|
69
|
+
|
70
|
+
|
71
|
+
private static getColumn(points: Array<number>): Array<ColumnPart> {
|
72
|
+
const items: Array<ColumnPart> = [];
|
65
73
|
for (let index = 0; index < points.length - 1; index++) {
|
66
74
|
items.push({ index, width: points[index + 1] - points[index] });
|
67
75
|
}
|
68
76
|
return items;
|
69
77
|
}
|
70
|
-
|
71
|
-
|
78
|
+
|
79
|
+
private static getSplitCols(width: number, cols: number): Array<ColumnPart> {
|
80
|
+
const items: Array<ColumnPart> = [];
|
72
81
|
for (let i = 0; i < cols; i++) {
|
73
82
|
items.push({ width: Math.floor(width / cols), index: i });
|
74
83
|
}
|
75
84
|
items[items.length - 1].width += width - items.reduce((prev, curr) => prev + curr.width, 0);
|
76
85
|
return items;
|
77
86
|
}
|
78
|
-
|
79
|
-
|
87
|
+
|
88
|
+
private static getLinePointMap(hMergeCols: Array<ColumnPart>): Array<ColumnPartOffset> {
|
89
|
+
const linePointMap: Array<ColumnPartOffset> = [];
|
80
90
|
let x = 0;
|
81
91
|
for (let i = 0; i < hMergeCols.length; i++) {
|
82
92
|
const col = hMergeCols[i];
|
@@ -85,5 +95,4 @@ export class ColumnPatchUtil {
|
|
85
95
|
}
|
86
96
|
return linePointMap;
|
87
97
|
}
|
88
|
-
}
|
89
|
-
//# sourceMappingURL=table-split-cell-patch.js.map
|
98
|
+
}
|