@hufe921/canvas-editor 0.9.81 → 0.9.82
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 +16 -0
- package/dist/canvas-editor.es.js +94 -22
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +37 -37
- 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 +2 -1
- package/dist/src/editor/core/draw/control/Control.d.ts +1 -0
- package/dist/src/editor/core/override/Override.d.ts +1 -0
- package/dist/src/editor/interface/Element.d.ts +4 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
## [0.9.82](https://github.com/Hufe921/canvas-editor/compare/v0.9.81...v0.9.82) (2024-06-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* table cell merge boundary error #645 ([f7da332](https://github.com/Hufe921/canvas-editor/commit/f7da33235419aadb2aea024d3cba4444d6d719fd)), closes [#645](https://github.com/Hufe921/canvas-editor/issues/645)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add executeUpdateElementById api #648 ([5c896bf](https://github.com/Hufe921/canvas-editor/commit/5c896bf95814c6ef2956221763e7df560b3fe98a)), closes [#648](https://github.com/Hufe921/canvas-editor/issues/648)
|
|
12
|
+
* add override internal drop function api #643 ([ec7e076](https://github.com/Hufe921/canvas-editor/commit/ec7e0760c113711fdafc13374ea521605308f867)), closes [#643](https://github.com/Hufe921/canvas-editor/issues/643)
|
|
13
|
+
* move control position by dragging #456 ([cdb0788](https://github.com/Hufe921/canvas-editor/commit/cdb0788dfcecadb70e680eb40a31551e0e096401)), closes [#456](https://github.com/Hufe921/canvas-editor/issues/456)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
1
17
|
## [0.9.81](https://github.com/Hufe921/canvas-editor/compare/v0.9.80...v0.9.81) (2024-06-07)
|
|
2
18
|
|
|
3
19
|
|
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.82";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -4779,9 +4779,7 @@ function getElementListByHTML(htmlText, options) {
|
|
|
4779
4779
|
}
|
|
4780
4780
|
tr.tdList.push(td);
|
|
4781
4781
|
});
|
|
4782
|
-
|
|
4783
|
-
element.trList.push(tr);
|
|
4784
|
-
}
|
|
4782
|
+
element.trList.push(tr);
|
|
4785
4783
|
});
|
|
4786
4784
|
if (element.trList.length) {
|
|
4787
4785
|
const tdCount = element.trList[0].tdList.reduce((pre, cur) => pre + cur.colspan, 0);
|
|
@@ -5799,14 +5797,20 @@ function mouseup(evt, host) {
|
|
|
5799
5797
|
return;
|
|
5800
5798
|
}
|
|
5801
5799
|
}
|
|
5802
|
-
const
|
|
5800
|
+
const control = draw.getControl();
|
|
5803
5801
|
const elementList = draw.getElementList();
|
|
5802
|
+
const isOmitControlAttr = !isContainControl || !!elementList[range.startIndex].controlId || !control.getIsElementListContainFullControl(dragElementList);
|
|
5803
|
+
const editorOptions = draw.getOptions();
|
|
5804
5804
|
const replaceElementList = dragElementList.map((el) => {
|
|
5805
5805
|
if (!el.type || el.type === ElementType.TEXT) {
|
|
5806
5806
|
const newElement = {
|
|
5807
5807
|
value: el.value
|
|
5808
5808
|
};
|
|
5809
|
-
|
|
5809
|
+
const copyAttr = EDITOR_ELEMENT_STYLE_ATTR;
|
|
5810
|
+
if (!isOmitControlAttr) {
|
|
5811
|
+
copyAttr.push(...CONTROL_CONTEXT_ATTR);
|
|
5812
|
+
}
|
|
5813
|
+
copyAttr.forEach((attr) => {
|
|
5810
5814
|
const value = el[attr];
|
|
5811
5815
|
if (value !== void 0) {
|
|
5812
5816
|
newElement[attr] = value;
|
|
@@ -5814,7 +5818,10 @@ function mouseup(evt, host) {
|
|
|
5814
5818
|
});
|
|
5815
5819
|
return newElement;
|
|
5816
5820
|
} else {
|
|
5817
|
-
|
|
5821
|
+
let newElement = deepClone(el);
|
|
5822
|
+
if (isOmitControlAttr) {
|
|
5823
|
+
newElement = omitObject(newElement, CONTROL_CONTEXT_ATTR);
|
|
5824
|
+
}
|
|
5818
5825
|
formatElementList([newElement], {
|
|
5819
5826
|
isHandleFirstElement: false,
|
|
5820
5827
|
editorOptions
|
|
@@ -5830,7 +5837,6 @@ function mouseup(evt, host) {
|
|
|
5830
5837
|
const replaceLength = replaceElementList.length;
|
|
5831
5838
|
let rangeStart = range.startIndex;
|
|
5832
5839
|
let rangeEnd = rangeStart + replaceLength;
|
|
5833
|
-
const control = draw.getControl();
|
|
5834
5840
|
const activeControl = control.getActiveControl();
|
|
5835
5841
|
if (activeControl && cacheElementList[rangeStart].controlComponent !== ControlComponent.POSTFIX) {
|
|
5836
5842
|
rangeEnd = activeControl.setValue(replaceElementList);
|
|
@@ -6979,6 +6985,12 @@ function copy(host) {
|
|
|
6979
6985
|
}
|
|
6980
6986
|
function drop(evt, host) {
|
|
6981
6987
|
var _a, _b;
|
|
6988
|
+
const draw = host.getDraw();
|
|
6989
|
+
const { drop: drop2 } = draw.getOverride();
|
|
6990
|
+
if (drop2) {
|
|
6991
|
+
drop2(evt);
|
|
6992
|
+
return;
|
|
6993
|
+
}
|
|
6982
6994
|
evt.preventDefault();
|
|
6983
6995
|
const data2 = (_a = evt.dataTransfer) == null ? void 0 : _a.getData("text");
|
|
6984
6996
|
if (data2) {
|
|
@@ -9641,12 +9653,10 @@ class TableParticle {
|
|
|
9641
9653
|
const { colgroup, trList } = element;
|
|
9642
9654
|
if (!colgroup || !trList)
|
|
9643
9655
|
return;
|
|
9644
|
-
let
|
|
9645
|
-
let y = 0;
|
|
9656
|
+
let preX = 0;
|
|
9646
9657
|
for (let t = 0; t < trList.length; t++) {
|
|
9647
9658
|
const tr = trList[t];
|
|
9648
9659
|
const isLastTr = trList.length - 1 === t;
|
|
9649
|
-
let rowMinHeight = 0;
|
|
9650
9660
|
for (let d = 0; d < tr.tdList.length; d++) {
|
|
9651
9661
|
const td = tr.tdList[d];
|
|
9652
9662
|
let colIndex = 0;
|
|
@@ -9661,7 +9671,7 @@ class TableParticle {
|
|
|
9661
9671
|
for (let preC = 0; preC < c; preC++) {
|
|
9662
9672
|
preColWidth += colgroup[preC].width;
|
|
9663
9673
|
}
|
|
9664
|
-
|
|
9674
|
+
preX = preColWidth;
|
|
9665
9675
|
break;
|
|
9666
9676
|
}
|
|
9667
9677
|
}
|
|
@@ -9680,9 +9690,6 @@ class TableParticle {
|
|
|
9680
9690
|
const curTr = trList[row + t] || trList[t];
|
|
9681
9691
|
height += curTr.height;
|
|
9682
9692
|
}
|
|
9683
|
-
if (rowMinHeight === 0 || rowMinHeight > height) {
|
|
9684
|
-
rowMinHeight = height;
|
|
9685
|
-
}
|
|
9686
9693
|
const isLastRowTd = tr.tdList.length - 1 === d;
|
|
9687
9694
|
let isLastColTd = isLastTr;
|
|
9688
9695
|
if (!isLastColTd) {
|
|
@@ -9695,16 +9702,26 @@ class TableParticle {
|
|
|
9695
9702
|
td.isLastRowTd = isLastRowTd;
|
|
9696
9703
|
td.isLastColTd = isLastColTd;
|
|
9697
9704
|
td.isLastTd = isLastTd;
|
|
9698
|
-
td.x =
|
|
9699
|
-
|
|
9705
|
+
td.x = preX;
|
|
9706
|
+
let preY = 0;
|
|
9707
|
+
for (let preR = 0; preR < t; preR++) {
|
|
9708
|
+
const preTdList = trList[preR].tdList;
|
|
9709
|
+
for (let preD = 0; preD < preTdList.length; preD++) {
|
|
9710
|
+
const td2 = preTdList[preD];
|
|
9711
|
+
if (colIndex >= td2.colIndex && colIndex < td2.colIndex + td2.colspan) {
|
|
9712
|
+
preY += td2.height;
|
|
9713
|
+
break;
|
|
9714
|
+
}
|
|
9715
|
+
}
|
|
9716
|
+
}
|
|
9717
|
+
td.y = preY;
|
|
9700
9718
|
td.width = width;
|
|
9701
9719
|
td.height = height;
|
|
9702
9720
|
td.rowIndex = t;
|
|
9703
9721
|
td.colIndex = colIndex;
|
|
9704
|
-
|
|
9722
|
+
preX += width;
|
|
9705
9723
|
if (isLastRowTd && !isLastTd) {
|
|
9706
|
-
|
|
9707
|
-
y += rowMinHeight;
|
|
9724
|
+
preX = 0;
|
|
9708
9725
|
}
|
|
9709
9726
|
}
|
|
9710
9727
|
}
|
|
@@ -11697,6 +11714,23 @@ class Control {
|
|
|
11697
11714
|
}
|
|
11698
11715
|
return false;
|
|
11699
11716
|
}
|
|
11717
|
+
getIsElementListContainFullControl(elementList) {
|
|
11718
|
+
if (!elementList.some((element) => element.controlId))
|
|
11719
|
+
return false;
|
|
11720
|
+
let prefixCount = 0;
|
|
11721
|
+
let postfixCount = 0;
|
|
11722
|
+
for (let e = 0; e < elementList.length; e++) {
|
|
11723
|
+
const element = elementList[e];
|
|
11724
|
+
if (element.controlComponent === ControlComponent.PREFIX) {
|
|
11725
|
+
prefixCount++;
|
|
11726
|
+
} else if (element.controlComponent === ControlComponent.POSTFIX) {
|
|
11727
|
+
postfixCount++;
|
|
11728
|
+
}
|
|
11729
|
+
}
|
|
11730
|
+
if (!prefixCount || !postfixCount)
|
|
11731
|
+
return false;
|
|
11732
|
+
return prefixCount === postfixCount;
|
|
11733
|
+
}
|
|
11700
11734
|
getIsDisabledControl() {
|
|
11701
11735
|
var _a, _b;
|
|
11702
11736
|
return !!((_b = (_a = this.activeControl) == null ? void 0 : _a.getElement().control) == null ? void 0 : _b.disabled);
|
|
@@ -16164,6 +16198,7 @@ class Command {
|
|
|
16164
16198
|
__publicField(this, "executeSetPaperMargin");
|
|
16165
16199
|
__publicField(this, "executeInsertElementList");
|
|
16166
16200
|
__publicField(this, "executeAppendElementList");
|
|
16201
|
+
__publicField(this, "executeUpdateElementById");
|
|
16167
16202
|
__publicField(this, "executeSetValue");
|
|
16168
16203
|
__publicField(this, "executeRemoveControl");
|
|
16169
16204
|
__publicField(this, "executeSetLocale");
|
|
@@ -16276,6 +16311,7 @@ class Command {
|
|
|
16276
16311
|
this.executeSetPaperMargin = adapt.setPaperMargin.bind(adapt);
|
|
16277
16312
|
this.executeInsertElementList = adapt.insertElementList.bind(adapt);
|
|
16278
16313
|
this.executeAppendElementList = adapt.appendElementList.bind(adapt);
|
|
16314
|
+
this.executeUpdateElementById = adapt.updateElementById.bind(adapt);
|
|
16279
16315
|
this.executeSetValue = adapt.setValue.bind(adapt);
|
|
16280
16316
|
this.executeRemoveControl = adapt.removeControl.bind(adapt);
|
|
16281
16317
|
this.executeSetLocale = adapt.setLocale.bind(adapt);
|
|
@@ -18334,8 +18370,12 @@ class CommandAdapt {
|
|
|
18334
18370
|
const selectionText = this.range.toString();
|
|
18335
18371
|
const selectionElementList = zipElementList(this.range.getSelectionElementList() || []);
|
|
18336
18372
|
const elementList = this.draw.getElementList();
|
|
18337
|
-
const startElement = pickElementAttr(elementList[isCollapsed ? startIndex : startIndex + 1]
|
|
18338
|
-
|
|
18373
|
+
const startElement = pickElementAttr(elementList[isCollapsed ? startIndex : startIndex + 1], {
|
|
18374
|
+
extraPickAttrs: ["id"]
|
|
18375
|
+
});
|
|
18376
|
+
const endElement = pickElementAttr(elementList[endIndex], {
|
|
18377
|
+
extraPickAttrs: ["id"]
|
|
18378
|
+
});
|
|
18339
18379
|
const positionList = this.position.getPositionList();
|
|
18340
18380
|
const startPageNo = positionList[startIndex].pageNo;
|
|
18341
18381
|
const endPageNo = positionList[endIndex].pageNo;
|
|
@@ -18471,6 +18511,37 @@ class CommandAdapt {
|
|
|
18471
18511
|
return;
|
|
18472
18512
|
this.draw.appendElementList(deepClone(elementList), options);
|
|
18473
18513
|
}
|
|
18514
|
+
updateElementById(payload) {
|
|
18515
|
+
function getElementIndexById(elementList) {
|
|
18516
|
+
for (let e = 0; e < elementList.length; e++) {
|
|
18517
|
+
const element = elementList[e];
|
|
18518
|
+
if (element.id === payload.id) {
|
|
18519
|
+
return e;
|
|
18520
|
+
}
|
|
18521
|
+
}
|
|
18522
|
+
return -1;
|
|
18523
|
+
}
|
|
18524
|
+
const getElementListFnList = [
|
|
18525
|
+
this.draw.getOriginalMainElementList,
|
|
18526
|
+
this.draw.getHeaderElementList,
|
|
18527
|
+
this.draw.getFooterElementList
|
|
18528
|
+
];
|
|
18529
|
+
for (const getElementList of getElementListFnList) {
|
|
18530
|
+
const elementList = getElementList.call(this.draw);
|
|
18531
|
+
const elementIndex = getElementIndexById(elementList);
|
|
18532
|
+
if (~elementIndex) {
|
|
18533
|
+
elementList[elementIndex] = __spreadValues(__spreadValues({}, elementList[elementIndex]), payload.properties);
|
|
18534
|
+
formatElementList([elementList[elementIndex]], {
|
|
18535
|
+
isHandleFirstElement: false,
|
|
18536
|
+
editorOptions: this.options
|
|
18537
|
+
});
|
|
18538
|
+
this.draw.render({
|
|
18539
|
+
isSetCursor: false
|
|
18540
|
+
});
|
|
18541
|
+
break;
|
|
18542
|
+
}
|
|
18543
|
+
}
|
|
18544
|
+
}
|
|
18474
18545
|
setValue(payload) {
|
|
18475
18546
|
this.draw.setValue(payload);
|
|
18476
18547
|
}
|
|
@@ -19861,6 +19932,7 @@ class Override {
|
|
|
19861
19932
|
constructor() {
|
|
19862
19933
|
__publicField(this, "paste");
|
|
19863
19934
|
__publicField(this, "copy");
|
|
19935
|
+
__publicField(this, "drop");
|
|
19864
19936
|
}
|
|
19865
19937
|
}
|
|
19866
19938
|
class Editor {
|