@hufe921/canvas-editor 0.9.68 → 0.9.69
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 +28 -0
- package/dist/canvas-editor.es.js +131 -21
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +26 -25
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/Command.d.ts +1 -0
- package/dist/src/editor/core/command/CommandAdapt.d.ts +3 -2
- package/dist/src/editor/core/draw/control/Control.d.ts +1 -0
- package/dist/src/editor/core/draw/particle/date/DateParticle.d.ts +0 -2
- package/dist/src/editor/interface/Element.d.ts +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
## [0.9.69](https://github.com/Hufe921/canvas-editor/compare/v0.9.68...v0.9.69) (2024-03-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* adjust the style of converting table element to html #458 ([0003686](https://github.com/Hufe921/canvas-editor/commit/000368636cba3547e3b280e1960e72198b41cb01)), closes [#458](https://github.com/Hufe921/canvas-editor/issues/458)
|
|
7
|
+
* copy html boundary error #470 ([4e46afa](https://github.com/Hufe921/canvas-editor/commit/4e46afab687c696360a96f45dd3cd97551f951ec)), closes [#470](https://github.com/Hufe921/canvas-editor/issues/470)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* add getControlList api #455 ([0523fc2](https://github.com/Hufe921/canvas-editor/commit/0523fc257ae6f2c9b2511e912a4272c6b962d41e)), closes [#455](https://github.com/Hufe921/canvas-editor/issues/455)
|
|
13
|
+
* add parameter for clearing font color and highlight color #461 ([73f9cfd](https://github.com/Hufe921/canvas-editor/commit/73f9cfdf88afcfab4376bf3c4011b171c0669d2f)), closes [#461](https://github.com/Hufe921/canvas-editor/issues/461)
|
|
14
|
+
* cancel painter style setting #453 ([51427c7](https://github.com/Hufe921/canvas-editor/commit/51427c7dc462ea5a33ae6a92836d1e7ded7cf43d)), closes [#453](https://github.com/Hufe921/canvas-editor/issues/453)
|
|
15
|
+
* table element can be merged after paging #41 ([33a2dd8](https://github.com/Hufe921/canvas-editor/commit/33a2dd8faa7a46bc9290b744dad93a761ed6e1cf)), closes [#41](https://github.com/Hufe921/canvas-editor/issues/41)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
### Refactor
|
|
19
|
+
|
|
20
|
+
* date element renderer #460 ([788f96a](https://github.com/Hufe921/canvas-editor/commit/788f96aa89766cecf0e835fd0ffe64140bb94e87)), closes [#460](https://github.com/Hufe921/canvas-editor/issues/460)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Tests
|
|
24
|
+
|
|
25
|
+
* update painter test case (#459) ([a058c59](https://github.com/Hufe921/canvas-editor/commit/a058c5956cc2c26b347e5528d8164e2e1eff1225)), closes [#459](https://github.com/Hufe921/canvas-editor/issues/459)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
1
29
|
## [0.9.68](https://github.com/Hufe921/canvas-editor/compare/v0.9.67...v0.9.68) (2024-03-10)
|
|
2
30
|
|
|
3
31
|
|
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.69";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -4074,6 +4074,22 @@ function zipElementList(payload) {
|
|
|
4074
4074
|
listElement.valueList = zipElementList(valueList);
|
|
4075
4075
|
element = listElement;
|
|
4076
4076
|
} else if (element.type === ElementType.TABLE) {
|
|
4077
|
+
if (element.pagingId) {
|
|
4078
|
+
let tableIndex = e + 1;
|
|
4079
|
+
let combineCount = 0;
|
|
4080
|
+
while (tableIndex < elementList.length) {
|
|
4081
|
+
const nextElement = elementList[tableIndex];
|
|
4082
|
+
if (nextElement.pagingId === element.pagingId) {
|
|
4083
|
+
element.height += nextElement.height;
|
|
4084
|
+
element.trList.push(...nextElement.trList);
|
|
4085
|
+
tableIndex++;
|
|
4086
|
+
combineCount++;
|
|
4087
|
+
} else {
|
|
4088
|
+
break;
|
|
4089
|
+
}
|
|
4090
|
+
}
|
|
4091
|
+
e += combineCount;
|
|
4092
|
+
}
|
|
4077
4093
|
if (element.trList) {
|
|
4078
4094
|
for (let t = 0; t < element.trList.length; t++) {
|
|
4079
4095
|
const tr = element.trList[t];
|
|
@@ -4301,16 +4317,31 @@ function createDomFromElementList(elementList, options) {
|
|
|
4301
4317
|
const element = payload[e];
|
|
4302
4318
|
if (element.type === ElementType.TABLE) {
|
|
4303
4319
|
const tableDom = document.createElement("table");
|
|
4320
|
+
tableDom.setAttribute("cellSpacing", "0");
|
|
4321
|
+
tableDom.setAttribute("cellpadding", "0");
|
|
4322
|
+
tableDom.setAttribute("border", "0");
|
|
4323
|
+
tableDom.style.borderTop = tableDom.style.borderLeft = "1px solid";
|
|
4324
|
+
tableDom.style.width = `${element.width}px`;
|
|
4325
|
+
const colgroupDom = document.createElement("colgroup");
|
|
4326
|
+
for (let c = 0; c < element.colgroup.length; c++) {
|
|
4327
|
+
const colgroup = element.colgroup[c];
|
|
4328
|
+
const colDom = document.createElement("col");
|
|
4329
|
+
colDom.setAttribute("width", `${colgroup.width}`);
|
|
4330
|
+
colgroupDom.append(colDom);
|
|
4331
|
+
}
|
|
4332
|
+
tableDom.append(colgroupDom);
|
|
4304
4333
|
const trList = element.trList;
|
|
4305
4334
|
for (let t = 0; t < trList.length; t++) {
|
|
4306
4335
|
const trDom = document.createElement("tr");
|
|
4307
4336
|
const tr = trList[t];
|
|
4337
|
+
trDom.style.height = `${tr.height}px`;
|
|
4308
4338
|
for (let d = 0; d < tr.tdList.length; d++) {
|
|
4309
4339
|
const tdDom = document.createElement("td");
|
|
4310
|
-
tdDom.style.
|
|
4340
|
+
tdDom.style.borderBottom = tdDom.style.borderRight = "1px solid";
|
|
4311
4341
|
const td = tr.tdList[d];
|
|
4312
4342
|
tdDom.colSpan = td.colspan;
|
|
4313
4343
|
tdDom.rowSpan = td.rowspan;
|
|
4344
|
+
tdDom.style.verticalAlign = td.verticalAlign || "top";
|
|
4314
4345
|
const childDom = buildDom(zipElementList(td.value));
|
|
4315
4346
|
tdDom.innerHTML = childDom.innerHTML;
|
|
4316
4347
|
if (td.backgroundColor) {
|
|
@@ -4684,6 +4715,9 @@ function writeClipboardItem(text, html, elementList) {
|
|
|
4684
4715
|
document.body.append(fakeElement);
|
|
4685
4716
|
const selection = window.getSelection();
|
|
4686
4717
|
const range = document.createRange();
|
|
4718
|
+
const br = document.createElement("span");
|
|
4719
|
+
br.innerText = "\n";
|
|
4720
|
+
fakeElement.append(br);
|
|
4687
4721
|
range.selectNodeContents(fakeElement);
|
|
4688
4722
|
selection == null ? void 0 : selection.removeAllRanges();
|
|
4689
4723
|
selection == null ? void 0 : selection.addRange(range);
|
|
@@ -10493,6 +10527,23 @@ class Control {
|
|
|
10493
10527
|
isSetCursor: false
|
|
10494
10528
|
});
|
|
10495
10529
|
}
|
|
10530
|
+
getList() {
|
|
10531
|
+
const data2 = [
|
|
10532
|
+
this.draw.getHeader().getElementList(),
|
|
10533
|
+
this.draw.getOriginalMainElementList(),
|
|
10534
|
+
this.draw.getFooter().getElementList()
|
|
10535
|
+
];
|
|
10536
|
+
const controlElementList = [];
|
|
10537
|
+
for (const elementList of data2) {
|
|
10538
|
+
for (let e = 0; e < elementList.length; e++) {
|
|
10539
|
+
const element = elementList[e];
|
|
10540
|
+
if (element.controlId) {
|
|
10541
|
+
controlElementList.push(element);
|
|
10542
|
+
}
|
|
10543
|
+
}
|
|
10544
|
+
}
|
|
10545
|
+
return zipElementList(controlElementList);
|
|
10546
|
+
}
|
|
10496
10547
|
}
|
|
10497
10548
|
class CheckboxParticle {
|
|
10498
10549
|
constructor(draw) {
|
|
@@ -11620,15 +11671,6 @@ class DateParticle {
|
|
|
11620
11671
|
startTop
|
|
11621
11672
|
});
|
|
11622
11673
|
}
|
|
11623
|
-
render(ctx, element, x, y) {
|
|
11624
|
-
ctx.save();
|
|
11625
|
-
ctx.font = element.style;
|
|
11626
|
-
if (element.color) {
|
|
11627
|
-
ctx.fillStyle = element.color;
|
|
11628
|
-
}
|
|
11629
|
-
ctx.fillText(element.value, x, y);
|
|
11630
|
-
ctx.restore();
|
|
11631
|
-
}
|
|
11632
11674
|
}
|
|
11633
11675
|
var BlockType;
|
|
11634
11676
|
(function(BlockType2) {
|
|
@@ -13490,6 +13532,23 @@ class Draw {
|
|
|
13490
13532
|
} else if (element.type === ElementType.TABLE) {
|
|
13491
13533
|
const tdPaddingWidth = tdPadding[1] + tdPadding[3];
|
|
13492
13534
|
const tdPaddingHeight = tdPadding[0] + tdPadding[2];
|
|
13535
|
+
if (element.pagingId) {
|
|
13536
|
+
let tableIndex = i + 1;
|
|
13537
|
+
let combineCount = 0;
|
|
13538
|
+
while (tableIndex < elementList.length) {
|
|
13539
|
+
const nextElement2 = elementList[tableIndex];
|
|
13540
|
+
if (nextElement2.pagingId === element.pagingId) {
|
|
13541
|
+
element.trList.push(...nextElement2.trList);
|
|
13542
|
+
tableIndex++;
|
|
13543
|
+
combineCount++;
|
|
13544
|
+
} else {
|
|
13545
|
+
break;
|
|
13546
|
+
}
|
|
13547
|
+
}
|
|
13548
|
+
if (combineCount) {
|
|
13549
|
+
elementList.splice(i + 1, combineCount);
|
|
13550
|
+
}
|
|
13551
|
+
}
|
|
13493
13552
|
this.tableParticle.computeRowColInfo(element);
|
|
13494
13553
|
const trList = element.trList;
|
|
13495
13554
|
for (let t = 0; t < trList.length; t++) {
|
|
@@ -13591,18 +13650,38 @@ class Draw {
|
|
|
13591
13650
|
if (deleteCount) {
|
|
13592
13651
|
const cloneTrList = trList2.splice(deleteStart, deleteCount);
|
|
13593
13652
|
const cloneTrHeight = cloneTrList.reduce((pre, cur) => pre + cur.height, 0);
|
|
13653
|
+
const pagingId = getUUID();
|
|
13654
|
+
element.pagingId = pagingId;
|
|
13594
13655
|
element.height -= cloneTrHeight;
|
|
13595
13656
|
metrics.height -= cloneTrHeight;
|
|
13596
13657
|
metrics.boundingBoxDescent -= cloneTrHeight;
|
|
13597
13658
|
const cloneElement = deepClone(element);
|
|
13659
|
+
cloneElement.pagingId = pagingId;
|
|
13598
13660
|
cloneElement.trList = cloneTrList;
|
|
13599
13661
|
cloneElement.id = getUUID();
|
|
13600
13662
|
this.spliceElementList(elementList, i + 1, 0, cloneElement);
|
|
13601
13663
|
const positionContext = this.position.getPositionContext();
|
|
13602
|
-
if (positionContext.isTable
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13664
|
+
if (positionContext.isTable) {
|
|
13665
|
+
let newPositionContextIndex = -1;
|
|
13666
|
+
let newPositionContextTrIndex = -1;
|
|
13667
|
+
let tableIndex = i;
|
|
13668
|
+
while (tableIndex < elementList.length) {
|
|
13669
|
+
const curElement = elementList[tableIndex];
|
|
13670
|
+
if (curElement.pagingId !== pagingId)
|
|
13671
|
+
break;
|
|
13672
|
+
const trIndex = curElement.trList.findIndex((r) => r.id === positionContext.trId);
|
|
13673
|
+
if (~trIndex) {
|
|
13674
|
+
newPositionContextIndex = tableIndex;
|
|
13675
|
+
newPositionContextTrIndex = trIndex;
|
|
13676
|
+
break;
|
|
13677
|
+
}
|
|
13678
|
+
tableIndex++;
|
|
13679
|
+
}
|
|
13680
|
+
if (~newPositionContextIndex) {
|
|
13681
|
+
positionContext.index = newPositionContextIndex;
|
|
13682
|
+
positionContext.trIndex = newPositionContextTrIndex;
|
|
13683
|
+
this.position.setPositionContext(positionContext);
|
|
13684
|
+
}
|
|
13606
13685
|
}
|
|
13607
13686
|
}
|
|
13608
13687
|
}
|
|
@@ -13845,8 +13924,14 @@ class Draw {
|
|
|
13845
13924
|
this._drawRichText(ctx);
|
|
13846
13925
|
this.hyperlinkParticle.render(ctx, element, x, y + offsetY);
|
|
13847
13926
|
} else if (element.type === ElementType.DATE) {
|
|
13848
|
-
|
|
13849
|
-
|
|
13927
|
+
const nextElement = curRow.elementList[j + 1];
|
|
13928
|
+
if (!preElement || preElement.dateId !== element.dateId) {
|
|
13929
|
+
this._drawRichText(ctx);
|
|
13930
|
+
}
|
|
13931
|
+
this.textParticle.record(ctx, element, x, y + offsetY);
|
|
13932
|
+
if (!nextElement || nextElement.dateId !== element.dateId) {
|
|
13933
|
+
this._drawRichText(ctx);
|
|
13934
|
+
}
|
|
13850
13935
|
} else if (element.type === ElementType.SUPERSCRIPT) {
|
|
13851
13936
|
this._drawRichText(ctx);
|
|
13852
13937
|
this.superscriptParticle.render(ctx, element, x, y + offsetY);
|
|
@@ -14302,6 +14387,7 @@ class Command {
|
|
|
14302
14387
|
__publicField(this, "getLocale");
|
|
14303
14388
|
__publicField(this, "getGroupIds");
|
|
14304
14389
|
__publicField(this, "getControlValue");
|
|
14390
|
+
__publicField(this, "getControlList");
|
|
14305
14391
|
__publicField(this, "getContainer");
|
|
14306
14392
|
this.executeMode = adapt.mode.bind(adapt);
|
|
14307
14393
|
this.executeCut = adapt.cut.bind(adapt);
|
|
@@ -14410,6 +14496,7 @@ class Command {
|
|
|
14410
14496
|
this.executeSetControlProperties = adapt.setControlProperties.bind(adapt);
|
|
14411
14497
|
this.executeSetControlHighlight = adapt.setControlHighlight.bind(adapt);
|
|
14412
14498
|
this.getControlValue = adapt.getControlValue.bind(adapt);
|
|
14499
|
+
this.getControlList = adapt.getControlList.bind(adapt);
|
|
14413
14500
|
}
|
|
14414
14501
|
}
|
|
14415
14502
|
const defaultWatermarkOption = {
|
|
@@ -14599,6 +14686,10 @@ class CommandAdapt {
|
|
|
14599
14686
|
this.historyManager.redo();
|
|
14600
14687
|
}
|
|
14601
14688
|
painter(options) {
|
|
14689
|
+
if (!options.isDblclick && this.draw.getPainterStyle()) {
|
|
14690
|
+
this.canvasEvent.clearPainterStyle();
|
|
14691
|
+
return;
|
|
14692
|
+
}
|
|
14602
14693
|
const selection = this.range.getSelection();
|
|
14603
14694
|
if (!selection)
|
|
14604
14695
|
return;
|
|
@@ -14934,7 +15025,11 @@ class CommandAdapt {
|
|
|
14934
15025
|
const selection = this.range.getSelectionElementList();
|
|
14935
15026
|
if (selection == null ? void 0 : selection.length) {
|
|
14936
15027
|
selection.forEach((el) => {
|
|
14937
|
-
|
|
15028
|
+
if (payload) {
|
|
15029
|
+
el.color = payload;
|
|
15030
|
+
} else {
|
|
15031
|
+
delete el.color;
|
|
15032
|
+
}
|
|
14938
15033
|
});
|
|
14939
15034
|
this.draw.render({
|
|
14940
15035
|
isSetCursor: false,
|
|
@@ -14945,7 +15040,11 @@ class CommandAdapt {
|
|
|
14945
15040
|
const elementList = this.draw.getElementList();
|
|
14946
15041
|
const enterElement = elementList[endIndex];
|
|
14947
15042
|
if ((enterElement == null ? void 0 : enterElement.value) === ZERO) {
|
|
14948
|
-
|
|
15043
|
+
if (payload) {
|
|
15044
|
+
enterElement.color = payload;
|
|
15045
|
+
} else {
|
|
15046
|
+
delete enterElement.color;
|
|
15047
|
+
}
|
|
14949
15048
|
this.draw.render({ curIndex: endIndex, isCompute: false });
|
|
14950
15049
|
}
|
|
14951
15050
|
}
|
|
@@ -14957,7 +15056,11 @@ class CommandAdapt {
|
|
|
14957
15056
|
const selection = this.range.getSelectionElementList();
|
|
14958
15057
|
if (selection == null ? void 0 : selection.length) {
|
|
14959
15058
|
selection.forEach((el) => {
|
|
14960
|
-
|
|
15059
|
+
if (payload) {
|
|
15060
|
+
el.highlight = payload;
|
|
15061
|
+
} else {
|
|
15062
|
+
delete el.highlight;
|
|
15063
|
+
}
|
|
14961
15064
|
});
|
|
14962
15065
|
this.draw.render({
|
|
14963
15066
|
isSetCursor: false,
|
|
@@ -14968,7 +15071,11 @@ class CommandAdapt {
|
|
|
14968
15071
|
const elementList = this.draw.getElementList();
|
|
14969
15072
|
const enterElement = elementList[endIndex];
|
|
14970
15073
|
if ((enterElement == null ? void 0 : enterElement.value) === ZERO) {
|
|
14971
|
-
|
|
15074
|
+
if (payload) {
|
|
15075
|
+
enterElement.highlight = payload;
|
|
15076
|
+
} else {
|
|
15077
|
+
delete enterElement.highlight;
|
|
15078
|
+
}
|
|
14972
15079
|
this.draw.render({ curIndex: endIndex, isCompute: false });
|
|
14973
15080
|
}
|
|
14974
15081
|
}
|
|
@@ -16523,6 +16630,9 @@ class CommandAdapt {
|
|
|
16523
16630
|
setControlHighlight(payload) {
|
|
16524
16631
|
this.draw.getControl().setHighlightList(payload);
|
|
16525
16632
|
}
|
|
16633
|
+
getControlList() {
|
|
16634
|
+
return this.draw.getControl().getList();
|
|
16635
|
+
}
|
|
16526
16636
|
getContainer() {
|
|
16527
16637
|
return this.draw.getContainer();
|
|
16528
16638
|
}
|