@hufe921/canvas-editor 0.9.55 → 0.9.56
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,13 @@
|
|
|
1
|
+
## [0.9.56](https://github.com/Hufe921/canvas-editor/compare/v0.9.55...v0.9.56) (2023-11-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* compute table row and col info boundary error #324 ([455b397](https://github.com/Hufe921/canvas-editor/commit/455b397fbc5de18ffe5a22bc9f9f68e23f9874eb)), closes [#324](https://github.com/Hufe921/canvas-editor/issues/324)
|
|
7
|
+
* get and set control property in table #323 ([17cd6cc](https://github.com/Hufe921/canvas-editor/commit/17cd6ccd09e7c368e2ef98c0be2b8de526e8a4c3)), closes [#323](https://github.com/Hufe921/canvas-editor/issues/323)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
1
11
|
## [0.9.55](https://github.com/Hufe921/canvas-editor/compare/v0.9.54...v0.9.55) (2023-11-10)
|
|
2
12
|
|
|
3
13
|
|
package/dist/canvas-editor.es.js
CHANGED
|
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
|
|
|
23
23
|
return value;
|
|
24
24
|
};
|
|
25
25
|
var index = "";
|
|
26
|
-
const version = "0.9.
|
|
26
|
+
const version = "0.9.56";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -7923,6 +7923,7 @@ class TableParticle {
|
|
|
7923
7923
|
this.options = draw.getOptions();
|
|
7924
7924
|
}
|
|
7925
7925
|
getTrListGroupByCol(payload) {
|
|
7926
|
+
var _a;
|
|
7926
7927
|
const trList = deepClone(payload);
|
|
7927
7928
|
for (let t = 0; t < payload.length; t++) {
|
|
7928
7929
|
const tr = trList[t];
|
|
@@ -7932,7 +7933,7 @@ class TableParticle {
|
|
|
7932
7933
|
const curRowIndex = rowIndex + rowspan - 1;
|
|
7933
7934
|
if (curRowIndex !== d) {
|
|
7934
7935
|
const changeTd = tr.tdList.splice(d, 1)[0];
|
|
7935
|
-
trList[curRowIndex].tdList.splice(colIndex, 0, changeTd);
|
|
7936
|
+
(_a = trList[curRowIndex]) == null ? void 0 : _a.tdList.splice(colIndex, 0, changeTd);
|
|
7936
7937
|
}
|
|
7937
7938
|
}
|
|
7938
7939
|
}
|
|
@@ -8084,6 +8085,33 @@ class TableParticle {
|
|
|
8084
8085
|
}
|
|
8085
8086
|
}
|
|
8086
8087
|
}
|
|
8088
|
+
getTableWidth(element) {
|
|
8089
|
+
return element.colgroup.reduce((pre, cur) => pre + cur.width, 0);
|
|
8090
|
+
}
|
|
8091
|
+
getTableHeight(element) {
|
|
8092
|
+
const trList = element.trList;
|
|
8093
|
+
if (!(trList == null ? void 0 : trList.length))
|
|
8094
|
+
return 0;
|
|
8095
|
+
return this.getTdListByColIndex(trList, 0).reduce((pre, cur) => pre + cur.height, 0);
|
|
8096
|
+
}
|
|
8097
|
+
getRowCountByColIndex(trList, colIndex) {
|
|
8098
|
+
return this.getTdListByColIndex(trList, colIndex).reduce((pre, cur) => pre + cur.rowspan, 0);
|
|
8099
|
+
}
|
|
8100
|
+
getTdListByColIndex(trList, colIndex) {
|
|
8101
|
+
const data2 = [];
|
|
8102
|
+
for (let r = 0; r < trList.length; r++) {
|
|
8103
|
+
const tdList = trList[r].tdList;
|
|
8104
|
+
for (let d = 0; d < tdList.length; d++) {
|
|
8105
|
+
const td = tdList[d];
|
|
8106
|
+
const min = td.colIndex;
|
|
8107
|
+
const max = min + td.colspan - 1;
|
|
8108
|
+
if (colIndex >= min && colIndex <= max) {
|
|
8109
|
+
data2.push(td);
|
|
8110
|
+
}
|
|
8111
|
+
}
|
|
8112
|
+
}
|
|
8113
|
+
return data2;
|
|
8114
|
+
}
|
|
8087
8115
|
computeRowColInfo(element) {
|
|
8088
8116
|
const { colgroup, trList } = element;
|
|
8089
8117
|
if (!colgroup || !trList)
|
|
@@ -8096,42 +8124,27 @@ class TableParticle {
|
|
|
8096
8124
|
let rowMinHeight = 0;
|
|
8097
8125
|
for (let d = 0; d < tr.tdList.length; d++) {
|
|
8098
8126
|
const td = tr.tdList[d];
|
|
8099
|
-
let
|
|
8127
|
+
let colIndex = 0;
|
|
8100
8128
|
if (trList.length > 1 && t !== 0) {
|
|
8101
|
-
|
|
8102
|
-
|
|
8103
|
-
|
|
8104
|
-
|
|
8105
|
-
|
|
8106
|
-
|
|
8107
|
-
|
|
8108
|
-
|
|
8109
|
-
|
|
8110
|
-
continue;
|
|
8111
|
-
if (pTdX > x)
|
|
8112
|
-
break;
|
|
8113
|
-
if (pTdX === x && pTdY + pTdHeight > y) {
|
|
8114
|
-
const nextPTd = pTr.tdList[pD + 1];
|
|
8115
|
-
if (nextPTd && pTd.colIndex + pTd.colspan !== nextPTd.colIndex) {
|
|
8116
|
-
x = nextPTd.x;
|
|
8117
|
-
offsetXIndex = nextPTd.colIndex;
|
|
8118
|
-
} else {
|
|
8119
|
-
x += pTdWidth;
|
|
8120
|
-
offsetXIndex += pTd.colspan;
|
|
8121
|
-
}
|
|
8129
|
+
const preTd = tr.tdList[d - 1];
|
|
8130
|
+
const start = preTd ? preTd.colIndex + preTd.colspan : d;
|
|
8131
|
+
for (let c = start; c < colgroup.length; c++) {
|
|
8132
|
+
const rowCount = this.getRowCountByColIndex(trList.slice(0, t), c);
|
|
8133
|
+
if (rowCount === t) {
|
|
8134
|
+
colIndex = c;
|
|
8135
|
+
let preColWidth = 0;
|
|
8136
|
+
for (let preC = 0; preC < c; preC++) {
|
|
8137
|
+
preColWidth += colgroup[preC].width;
|
|
8122
8138
|
}
|
|
8139
|
+
x = preColWidth;
|
|
8140
|
+
break;
|
|
8123
8141
|
}
|
|
8124
8142
|
}
|
|
8125
|
-
}
|
|
8126
|
-
let colIndex = 0;
|
|
8127
|
-
const preTd = tr.tdList[d - 1];
|
|
8128
|
-
if (preTd) {
|
|
8129
|
-
colIndex = preTd.colIndex + offsetXIndex + 1;
|
|
8130
|
-
if (preTd.colspan > 1) {
|
|
8131
|
-
colIndex += preTd.colspan - 1;
|
|
8132
|
-
}
|
|
8133
8143
|
} else {
|
|
8134
|
-
|
|
8144
|
+
const preTd = tr.tdList[d - 1];
|
|
8145
|
+
if (preTd) {
|
|
8146
|
+
colIndex = preTd.colIndex + preTd.colspan;
|
|
8147
|
+
}
|
|
8135
8148
|
}
|
|
8136
8149
|
let width = 0;
|
|
8137
8150
|
for (let col = 0; col < td.colspan; col++) {
|
|
@@ -8139,7 +8152,8 @@ class TableParticle {
|
|
|
8139
8152
|
}
|
|
8140
8153
|
let height = 0;
|
|
8141
8154
|
for (let row = 0; row < td.rowspan; row++) {
|
|
8142
|
-
|
|
8155
|
+
const curTr = trList[row + t] || trList[t];
|
|
8156
|
+
height += curTr.height;
|
|
8143
8157
|
}
|
|
8144
8158
|
if (rowMinHeight === 0 || rowMinHeight > height) {
|
|
8145
8159
|
rowMinHeight = height;
|
|
@@ -8427,7 +8441,8 @@ class TableTool {
|
|
|
8427
8441
|
var _a;
|
|
8428
8442
|
let isChangeSize = false;
|
|
8429
8443
|
if (order === TableOrder.ROW) {
|
|
8430
|
-
const
|
|
8444
|
+
const trList = element.trList;
|
|
8445
|
+
const tr = trList[index2] || trList[index2 - 1];
|
|
8431
8446
|
const { defaultTrMinHeight } = this.options;
|
|
8432
8447
|
if (dy < 0 && tr.height + dy < defaultTrMinHeight) {
|
|
8433
8448
|
dy = defaultTrMinHeight - tr.height;
|
|
@@ -9432,49 +9447,62 @@ class Control {
|
|
|
9432
9447
|
return this.activeControl.cut();
|
|
9433
9448
|
}
|
|
9434
9449
|
getValueByConceptId(payload) {
|
|
9435
|
-
var _a;
|
|
9436
9450
|
const { conceptId } = payload;
|
|
9451
|
+
const result = [];
|
|
9452
|
+
const getValue = (elementList2) => {
|
|
9453
|
+
var _a;
|
|
9454
|
+
let i = 0;
|
|
9455
|
+
while (i < elementList2.length) {
|
|
9456
|
+
const element = elementList2[i];
|
|
9457
|
+
i++;
|
|
9458
|
+
if (element.type === ElementType.TABLE) {
|
|
9459
|
+
const trList = element.trList;
|
|
9460
|
+
for (let r = 0; r < trList.length; r++) {
|
|
9461
|
+
const tr = trList[r];
|
|
9462
|
+
for (let d = 0; d < tr.tdList.length; d++) {
|
|
9463
|
+
const td = tr.tdList[d];
|
|
9464
|
+
getValue(td.value);
|
|
9465
|
+
}
|
|
9466
|
+
}
|
|
9467
|
+
}
|
|
9468
|
+
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
9469
|
+
continue;
|
|
9470
|
+
const { type, code, valueSets } = element.control;
|
|
9471
|
+
let j = i;
|
|
9472
|
+
let textControlValue = "";
|
|
9473
|
+
while (j < elementList2.length) {
|
|
9474
|
+
const nextElement = elementList2[j];
|
|
9475
|
+
if (nextElement.controlId !== element.controlId)
|
|
9476
|
+
break;
|
|
9477
|
+
if (type === ControlType.TEXT && nextElement.controlComponent === ControlComponent.VALUE) {
|
|
9478
|
+
textControlValue += nextElement.value;
|
|
9479
|
+
}
|
|
9480
|
+
j++;
|
|
9481
|
+
}
|
|
9482
|
+
if (type === ControlType.TEXT) {
|
|
9483
|
+
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
9484
|
+
value: textControlValue || null,
|
|
9485
|
+
innerText: textControlValue || null
|
|
9486
|
+
}));
|
|
9487
|
+
} else if (type === ControlType.SELECT || type === ControlType.CHECKBOX) {
|
|
9488
|
+
const innerText = code == null ? void 0 : code.split(",").map((selectCode) => {
|
|
9489
|
+
var _a2;
|
|
9490
|
+
return (_a2 = valueSets == null ? void 0 : valueSets.find((valueSet) => valueSet.code === selectCode)) == null ? void 0 : _a2.value;
|
|
9491
|
+
}).filter(Boolean).join("");
|
|
9492
|
+
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
9493
|
+
value: code || null,
|
|
9494
|
+
innerText: innerText || null
|
|
9495
|
+
}));
|
|
9496
|
+
}
|
|
9497
|
+
i = j;
|
|
9498
|
+
}
|
|
9499
|
+
};
|
|
9437
9500
|
const elementList = [
|
|
9438
9501
|
...this.draw.getHeaderElementList(),
|
|
9439
9502
|
...this.draw.getOriginalMainElementList(),
|
|
9440
9503
|
...this.draw.getFooterElementList()
|
|
9441
9504
|
];
|
|
9442
|
-
|
|
9443
|
-
let i = 0;
|
|
9444
|
-
while (i < elementList.length) {
|
|
9445
|
-
const element = elementList[i];
|
|
9446
|
-
i++;
|
|
9447
|
-
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
9448
|
-
continue;
|
|
9449
|
-
const { type, code, valueSets } = element.control;
|
|
9450
|
-
let j = i;
|
|
9451
|
-
let textControlValue = "";
|
|
9452
|
-
while (j < elementList.length) {
|
|
9453
|
-
const nextElement = elementList[j];
|
|
9454
|
-
if (nextElement.controlId !== element.controlId)
|
|
9455
|
-
break;
|
|
9456
|
-
if (type === ControlType.TEXT && nextElement.controlComponent === ControlComponent.VALUE) {
|
|
9457
|
-
textControlValue += nextElement.value;
|
|
9458
|
-
}
|
|
9459
|
-
j++;
|
|
9460
|
-
}
|
|
9461
|
-
if (type === ControlType.TEXT) {
|
|
9462
|
-
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
9463
|
-
value: textControlValue || null,
|
|
9464
|
-
innerText: textControlValue || null
|
|
9465
|
-
}));
|
|
9466
|
-
} else if (type === ControlType.SELECT || type === ControlType.CHECKBOX) {
|
|
9467
|
-
const innerText = code == null ? void 0 : code.split(",").map((selectCode) => {
|
|
9468
|
-
var _a2;
|
|
9469
|
-
return (_a2 = valueSets == null ? void 0 : valueSets.find((valueSet) => valueSet.code === selectCode)) == null ? void 0 : _a2.value;
|
|
9470
|
-
}).filter(Boolean).join("");
|
|
9471
|
-
result.push(__spreadProps(__spreadValues({}, element.control), {
|
|
9472
|
-
value: code || null,
|
|
9473
|
-
innerText: innerText || null
|
|
9474
|
-
}));
|
|
9475
|
-
}
|
|
9476
|
-
i = j;
|
|
9477
|
-
}
|
|
9505
|
+
getValue(elementList);
|
|
9478
9506
|
return result;
|
|
9479
9507
|
}
|
|
9480
9508
|
setValueByConceptId(payload) {
|
|
@@ -9574,21 +9602,26 @@ class Control {
|
|
|
9574
9602
|
}
|
|
9575
9603
|
}
|
|
9576
9604
|
setExtensionByConceptId(payload) {
|
|
9577
|
-
var _a;
|
|
9578
9605
|
const isReadonly = this.draw.isReadonly();
|
|
9579
9606
|
if (isReadonly)
|
|
9580
9607
|
return;
|
|
9581
9608
|
const { conceptId, extension } = payload;
|
|
9582
|
-
const
|
|
9583
|
-
|
|
9584
|
-
this.draw.getOriginalMainElementList(),
|
|
9585
|
-
this.draw.getFooterElementList()
|
|
9586
|
-
];
|
|
9587
|
-
for (const elementList of data2) {
|
|
9609
|
+
const setExtension = (elementList) => {
|
|
9610
|
+
var _a;
|
|
9588
9611
|
let i = 0;
|
|
9589
9612
|
while (i < elementList.length) {
|
|
9590
9613
|
const element = elementList[i];
|
|
9591
9614
|
i++;
|
|
9615
|
+
if (element.type === ElementType.TABLE) {
|
|
9616
|
+
const trList = element.trList;
|
|
9617
|
+
for (let r = 0; r < trList.length; r++) {
|
|
9618
|
+
const tr = trList[r];
|
|
9619
|
+
for (let d = 0; d < tr.tdList.length; d++) {
|
|
9620
|
+
const td = tr.tdList[d];
|
|
9621
|
+
setExtension(td.value);
|
|
9622
|
+
}
|
|
9623
|
+
}
|
|
9624
|
+
}
|
|
9592
9625
|
if (((_a = element == null ? void 0 : element.control) == null ? void 0 : _a.conceptId) !== conceptId)
|
|
9593
9626
|
continue;
|
|
9594
9627
|
element.control.extension = extension;
|
|
@@ -9601,6 +9634,14 @@ class Control {
|
|
|
9601
9634
|
}
|
|
9602
9635
|
i = newEndIndex;
|
|
9603
9636
|
}
|
|
9637
|
+
};
|
|
9638
|
+
const data2 = [
|
|
9639
|
+
this.draw.getHeaderElementList(),
|
|
9640
|
+
this.draw.getOriginalMainElementList(),
|
|
9641
|
+
this.draw.getFooterElementList()
|
|
9642
|
+
];
|
|
9643
|
+
for (const elementList of data2) {
|
|
9644
|
+
setExtension(elementList);
|
|
9604
9645
|
}
|
|
9605
9646
|
}
|
|
9606
9647
|
}
|
|
@@ -12356,7 +12397,7 @@ class Draw {
|
|
|
12356
12397
|
let curTdRealHeight = 0;
|
|
12357
12398
|
let i2 = 0;
|
|
12358
12399
|
while (i2 < td.rowspan) {
|
|
12359
|
-
const curTr = trList[i2 + t];
|
|
12400
|
+
const curTr = trList[i2 + t] || trList[t];
|
|
12360
12401
|
curTdMinHeight += curTr.minHeight;
|
|
12361
12402
|
curTdRealHeight += curTr.height;
|
|
12362
12403
|
i2++;
|
|
@@ -12389,8 +12430,8 @@ class Draw {
|
|
|
12389
12430
|
}
|
|
12390
12431
|
}
|
|
12391
12432
|
this.tableParticle.computeRowColInfo(element);
|
|
12392
|
-
const tableHeight =
|
|
12393
|
-
const tableWidth =
|
|
12433
|
+
const tableHeight = this.tableParticle.getTableHeight(element);
|
|
12434
|
+
const tableWidth = this.tableParticle.getTableWidth(element);
|
|
12394
12435
|
element.width = tableWidth;
|
|
12395
12436
|
element.height = tableHeight;
|
|
12396
12437
|
const elementWidth = tableWidth * scale;
|