@hufe921/canvas-editor 0.9.67 → 0.9.68
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 +20 -0
- package/dist/canvas-editor.es.js +64 -27
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +40 -32
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/draw/particle/TextParticle.d.ts +2 -1
- package/dist/src/editor/core/event/CanvasEvent.d.ts +2 -1
- package/dist/src/editor/interface/Text.d.ts +9 -0
- package/dist/src/editor/utils/element.d.ts +1 -0
- package/dist/src/editor/utils/index.d.ts +1 -0
- package/dist/src/editor/utils/print.d.ts +7 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,23 @@
|
|
|
1
|
+
## [0.9.68](https://github.com/Hufe921/canvas-editor/compare/v0.9.67...v0.9.68) (2024-03-10)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* dragging element boundary error ([a2d8dd5](https://github.com/Hufe921/canvas-editor/commit/a2d8dd55b36a09b42fae377e06bf667dced3857e))
|
|
7
|
+
* hyperlink word count statistics #449 ([180bd08](https://github.com/Hufe921/canvas-editor/commit/180bd088397159e32dc70da4eefd507721ced432)), closes [#449](https://github.com/Hufe921/canvas-editor/issues/449)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* set print layout format when printing #448 ([c6534f7](https://github.com/Hufe921/canvas-editor/commit/c6534f766d8640cbea4e441541065d25e0dd8b82)), closes [#448](https://github.com/Hufe921/canvas-editor/issues/448)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Performance Improvements
|
|
16
|
+
|
|
17
|
+
* history stack memory ([5044c31](https://github.com/Hufe921/canvas-editor/commit/5044c319211322c0ab2a2db461b029f34b292939))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
1
21
|
## [0.9.67](https://github.com/Hufe921/canvas-editor/compare/v0.9.66...v0.9.67) (2024-03-01)
|
|
2
22
|
|
|
3
23
|
|
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.68";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -119,6 +119,22 @@ function throttle(func, delay) {
|
|
|
119
119
|
}
|
|
120
120
|
};
|
|
121
121
|
}
|
|
122
|
+
function deepCloneOmitKeys(obj, omitKeys) {
|
|
123
|
+
if (!obj || typeof obj !== "object") {
|
|
124
|
+
return obj;
|
|
125
|
+
}
|
|
126
|
+
let newObj = {};
|
|
127
|
+
if (Array.isArray(obj)) {
|
|
128
|
+
newObj = obj.map((item) => deepCloneOmitKeys(item, omitKeys));
|
|
129
|
+
} else {
|
|
130
|
+
Object.keys(obj).forEach((key) => {
|
|
131
|
+
if (omitKeys.includes(key))
|
|
132
|
+
return;
|
|
133
|
+
return newObj[key] = deepCloneOmitKeys(obj[key], omitKeys);
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
return newObj;
|
|
137
|
+
}
|
|
122
138
|
function deepClone(obj) {
|
|
123
139
|
if (!obj || typeof obj !== "object") {
|
|
124
140
|
return obj;
|
|
@@ -4631,6 +4647,12 @@ ${listIndex + 1}.${buildText(listElementList)}${isLast ? `
|
|
|
4631
4647
|
}
|
|
4632
4648
|
return buildText(zipElementList(elementList));
|
|
4633
4649
|
}
|
|
4650
|
+
function getSlimCloneElementList(elementList) {
|
|
4651
|
+
return deepCloneOmitKeys(elementList, [
|
|
4652
|
+
"metrics",
|
|
4653
|
+
"style"
|
|
4654
|
+
]);
|
|
4655
|
+
}
|
|
4634
4656
|
function setClipboardData(data2) {
|
|
4635
4657
|
localStorage.setItem(EDITOR_CLIPBOARD, JSON.stringify({
|
|
4636
4658
|
text: data2.text,
|
|
@@ -5250,6 +5272,7 @@ function setRangeCache(host) {
|
|
|
5250
5272
|
host.cacheRange = deepClone(rangeManager.getRange());
|
|
5251
5273
|
host.cacheElementList = draw.getElementList();
|
|
5252
5274
|
host.cachePositionList = position.getPositionList();
|
|
5275
|
+
host.cachePositionContext = position.getPositionContext();
|
|
5253
5276
|
}
|
|
5254
5277
|
function mousedown(evt, host) {
|
|
5255
5278
|
var _a;
|
|
@@ -5387,13 +5410,14 @@ function moveImgPosition(element, evt, host) {
|
|
|
5387
5410
|
draw.getImageParticle().destroyFloatImage();
|
|
5388
5411
|
}
|
|
5389
5412
|
function mouseup(evt, host) {
|
|
5390
|
-
var _a, _b, _c;
|
|
5413
|
+
var _a, _b, _c, _d;
|
|
5391
5414
|
if (host.isAllowDrop) {
|
|
5392
5415
|
const draw = host.getDraw();
|
|
5393
5416
|
if (draw.isReadonly())
|
|
5394
5417
|
return;
|
|
5395
5418
|
const position = draw.getPosition();
|
|
5396
5419
|
const positionList = position.getPositionList();
|
|
5420
|
+
const positionContext = position.getPositionContext();
|
|
5397
5421
|
const rangeManager = draw.getRange();
|
|
5398
5422
|
const cacheRange = host.cacheRange;
|
|
5399
5423
|
const cacheElementList = host.cacheElementList;
|
|
@@ -5402,7 +5426,7 @@ function mouseup(evt, host) {
|
|
|
5402
5426
|
const isCacheRangeCollapsed = cacheRange.startIndex === cacheRange.endIndex;
|
|
5403
5427
|
const cacheStartIndex = isCacheRangeCollapsed ? cacheRange.startIndex - 1 : cacheRange.startIndex;
|
|
5404
5428
|
const cacheEndIndex = cacheRange.endIndex;
|
|
5405
|
-
if (range.startIndex >= cacheStartIndex && range.endIndex <= cacheEndIndex) {
|
|
5429
|
+
if (range.startIndex >= cacheStartIndex && range.endIndex <= cacheEndIndex && ((_a = host.cachePositionContext) == null ? void 0 : _a.tdId) === positionContext.tdId) {
|
|
5406
5430
|
draw.clearSideEffect();
|
|
5407
5431
|
let isSubmitHistory = false;
|
|
5408
5432
|
if (isCacheRangeCollapsed) {
|
|
@@ -5431,7 +5455,7 @@ function mouseup(evt, host) {
|
|
|
5431
5455
|
if (isContainControl) {
|
|
5432
5456
|
const cacheStartElement2 = cacheElementList[cacheStartIndex + 1];
|
|
5433
5457
|
const cacheEndElement2 = cacheElementList[cacheEndIndex];
|
|
5434
|
-
const isAllowDragControl = (!cacheStartElement2.controlId || cacheStartElement2.controlComponent === ControlComponent.PREFIX) && (!cacheEndElement2.controlId || cacheEndElement2.controlComponent === ControlComponent.POSTFIX) || cacheStartElement2.controlId === cacheEndElement2.controlId && cacheStartElement2.controlComponent === ControlComponent.PREFIX && cacheEndElement2.controlComponent === ControlComponent.POSTFIX || ((
|
|
5458
|
+
const isAllowDragControl = (!cacheStartElement2.controlId || cacheStartElement2.controlComponent === ControlComponent.PREFIX) && (!cacheEndElement2.controlId || cacheEndElement2.controlComponent === ControlComponent.POSTFIX) || cacheStartElement2.controlId === cacheEndElement2.controlId && cacheStartElement2.controlComponent === ControlComponent.PREFIX && cacheEndElement2.controlComponent === ControlComponent.POSTFIX || ((_b = cacheStartElement2.control) == null ? void 0 : _b.type) === ControlType.TEXT && cacheStartElement2.controlComponent === ControlComponent.VALUE && ((_c = cacheEndElement2.control) == null ? void 0 : _c.type) === ControlType.TEXT && cacheEndElement2.controlComponent === ControlComponent.VALUE;
|
|
5435
5459
|
if (!isAllowDragControl) {
|
|
5436
5460
|
draw.render({
|
|
5437
5461
|
curIndex: range.startIndex,
|
|
@@ -5465,6 +5489,8 @@ function mouseup(evt, host) {
|
|
|
5465
5489
|
}
|
|
5466
5490
|
});
|
|
5467
5491
|
formatElementContext(elementList, replaceElementList, range.startIndex);
|
|
5492
|
+
const cacheStartElement = cacheElementList[cacheStartIndex];
|
|
5493
|
+
const cacheStartPosition = cachePositionList[cacheStartIndex];
|
|
5468
5494
|
const cacheRangeStartId = createDragId(cacheElementList[cacheStartIndex]);
|
|
5469
5495
|
const cacheRangeEndId = createDragId(cacheElementList[cacheEndIndex]);
|
|
5470
5496
|
const replaceLength = replaceElementList.length;
|
|
@@ -5494,15 +5520,12 @@ function mouseup(evt, host) {
|
|
|
5494
5520
|
startIndex: cacheRangeStartIndex,
|
|
5495
5521
|
endIndex: cacheRangeEndIndex
|
|
5496
5522
|
}));
|
|
5497
|
-
(
|
|
5523
|
+
(_d = control.getActiveControl()) == null ? void 0 : _d.cut();
|
|
5498
5524
|
} else {
|
|
5499
5525
|
draw.spliceElementList(cacheElementList, cacheRangeStartIndex + 1, cacheRangeEndIndex - cacheRangeStartIndex);
|
|
5500
5526
|
}
|
|
5501
5527
|
const startElement = elementList[range.startIndex];
|
|
5502
|
-
const cacheStartElement = cacheElementList[cacheStartIndex];
|
|
5503
5528
|
const startPosition = positionList[range.startIndex];
|
|
5504
|
-
const cacheStartPosition = cachePositionList[cacheStartIndex];
|
|
5505
|
-
const positionContext = position.getPositionContext();
|
|
5506
5529
|
let positionContextIndex = positionContext.index;
|
|
5507
5530
|
if (positionContextIndex) {
|
|
5508
5531
|
if (startElement.tableId && !cacheStartElement.tableId) {
|
|
@@ -6395,6 +6418,7 @@ class CanvasEvent {
|
|
|
6395
6418
|
__publicField(this, "cacheRange");
|
|
6396
6419
|
__publicField(this, "cacheElementList");
|
|
6397
6420
|
__publicField(this, "cachePositionList");
|
|
6421
|
+
__publicField(this, "cachePositionContext");
|
|
6398
6422
|
__publicField(this, "mouseDownStartPosition");
|
|
6399
6423
|
__publicField(this, "draw");
|
|
6400
6424
|
__publicField(this, "pageContainer");
|
|
@@ -6414,6 +6438,7 @@ class CanvasEvent {
|
|
|
6414
6438
|
this.cacheRange = null;
|
|
6415
6439
|
this.cacheElementList = null;
|
|
6416
6440
|
this.cachePositionList = null;
|
|
6441
|
+
this.cachePositionContext = null;
|
|
6417
6442
|
this.mouseDownStartPosition = null;
|
|
6418
6443
|
}
|
|
6419
6444
|
getDraw() {
|
|
@@ -10525,7 +10550,7 @@ class CheckboxParticle {
|
|
|
10525
10550
|
ctx.restore();
|
|
10526
10551
|
}
|
|
10527
10552
|
}
|
|
10528
|
-
const encodedJs$2 = "
|
|
10553
|
+
const encodedJs$2 = "KCgpPT57KGZ1bmN0aW9uKCl7InVzZSBzdHJpY3QiO3ZhciBmOyhmdW5jdGlvbih0KXt0LlRFWFQ9InRleHQiLHQuVEFCTEU9InRhYmxlIix0LkhZUEVSTElOSz0iaHlwZXJsaW5rIix0LkNPTlRST0w9ImNvbnRyb2wifSkoZnx8KGY9e30pKTt2YXIgcDsoZnVuY3Rpb24odCl7dC5WQUxVRT0idmFsdWUifSkocHx8KHA9e30pKTtjb25zdCBoPSJcdTIwMEIiLGc9YApgO2Z1bmN0aW9uIGEodCl7bGV0IGw9IiIsbj0wO2Zvcig7bjx0Lmxlbmd0aDspe2NvbnN0IG89dFtuXTtpZihvLnR5cGU9PT1mLlRBQkxFKXtpZihvLnRyTGlzdClmb3IobGV0IHI9MDtyPG8udHJMaXN0Lmxlbmd0aDtyKyspe2NvbnN0IHM9by50ckxpc3Rbcl07Zm9yKGxldCBlPTA7ZTxzLnRkTGlzdC5sZW5ndGg7ZSsrKXtjb25zdCBpPXMudGRMaXN0W2VdO2wrPWEoaS52YWx1ZSl9fX1lbHNlIGlmKG8udHlwZT09PWYuSFlQRVJMSU5LKXtjb25zdCByPW8uaHlwZXJsaW5rSWQscz1bXTtmb3IoO248dC5sZW5ndGg7KXtjb25zdCBlPXRbbl07aWYociE9PWUuaHlwZXJsaW5rSWQpe24tLTticmVha31kZWxldGUgZS50eXBlLHMucHVzaChlKSxuKyt9bCs9YShzKX1lbHNlIGlmKG8uY29udHJvbElkKXtjb25zdCByPW8uY29udHJvbElkLHM9W107Zm9yKDtuPHQubGVuZ3RoOyl7Y29uc3QgZT10W25dO2lmKHIhPT1lLmNvbnRyb2xJZCl7bi0tO2JyZWFrfWUuY29udHJvbENvbXBvbmVudD09PXAuVkFMVUUmJihkZWxldGUgZS5jb250cm9sSWQscy5wdXNoKGUpKSxuKyt9bCs9YShzKX1lbHNlKCFvLnR5cGV8fG8udHlwZT09PWYuVEVYVCkmJihsKz1vLnZhbHVlKTtuKyt9cmV0dXJuIGx9ZnVuY3Rpb24gZCh0KXtjb25zdCBsPVtdLG49L1swLTldLyxvPS9bQS1aYS16XS8scj0vXHMvO2xldCBzPSExLGU9ITEsaT0iIjtmdW5jdGlvbiB1KCl7aSYmKGwucHVzaChpKSxpPSIiKX1mb3IoY29uc3QgYyBvZiB0KW8udGVzdChjKT8oc3x8dSgpLGkrPWMscz0hMCxlPSExKTpuLnRlc3QoYyk/KGV8fHUoKSxpKz1jLHM9ITEsZT0hMCk6KHUoKSxzPSExLGU9ITEsci50ZXN0KGMpfHxsLnB1c2goYykpO3JldHVybiB1KCksbH1vbm1lc3NhZ2U9dD0+e2NvbnN0IGw9dC5kYXRhLG89YShsKS5yZXBsYWNlKG5ldyBSZWdFeHAoYF4ke2h9YCksIiIpLnJlcGxhY2UobmV3IFJlZ0V4cChoLCJnIiksZykscj1kKG8pO3Bvc3RNZXNzYWdlKHIubGVuZ3RoKX19KSgpO30pKCk7Cg==";
|
|
10529
10554
|
const blob$2 = typeof window !== "undefined" && window.Blob && new Blob([atob(encodedJs$2)], { type: "text/javascript;charset=utf-8" });
|
|
10530
10555
|
function WorkerWrapper$2() {
|
|
10531
10556
|
const objURL = blob$2 && (window.URL || window.webkitURL).createObjectURL(blob$2);
|
|
@@ -14111,23 +14136,22 @@ class Draw {
|
|
|
14111
14136
|
this.cursor.drawCursor();
|
|
14112
14137
|
}
|
|
14113
14138
|
if (isSubmitHistory) {
|
|
14114
|
-
const
|
|
14115
|
-
const
|
|
14116
|
-
const
|
|
14117
|
-
const
|
|
14118
|
-
const { startIndex, endIndex } = this.range.getRange();
|
|
14139
|
+
const oldElementList = getSlimCloneElementList(this.elementList);
|
|
14140
|
+
const oldHeaderElementList = getSlimCloneElementList(this.header.getElementList());
|
|
14141
|
+
const oldFooterElementList = getSlimCloneElementList(this.footer.getElementList());
|
|
14142
|
+
const oldRange = deepClone(this.range.getRange());
|
|
14119
14143
|
const pageNo = this.pageNo;
|
|
14120
14144
|
const oldPositionContext = deepClone(positionContext);
|
|
14121
14145
|
const zone2 = this.zone.getZone();
|
|
14122
|
-
this.historyManager.execute(
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
14128
|
-
|
|
14129
|
-
|
|
14130
|
-
|
|
14146
|
+
this.historyManager.execute(() => {
|
|
14147
|
+
this.zone.setZone(zone2);
|
|
14148
|
+
this.setPageNo(pageNo);
|
|
14149
|
+
this.position.setPositionContext(deepClone(oldPositionContext));
|
|
14150
|
+
this.header.setElementList(deepClone(oldHeaderElementList));
|
|
14151
|
+
this.footer.setElementList(deepClone(oldFooterElementList));
|
|
14152
|
+
this.elementList = deepClone(oldElementList);
|
|
14153
|
+
this.range.replaceRange(deepClone(oldRange));
|
|
14154
|
+
this.render({
|
|
14131
14155
|
curIndex,
|
|
14132
14156
|
isSubmitHistory: false,
|
|
14133
14157
|
isSourceHistory: true
|
|
@@ -14401,7 +14425,8 @@ var VerticalAlign;
|
|
|
14401
14425
|
VerticalAlign2["MIDDLE"] = "middle";
|
|
14402
14426
|
VerticalAlign2["BOTTOM"] = "bottom";
|
|
14403
14427
|
})(VerticalAlign || (VerticalAlign = {}));
|
|
14404
|
-
function printImageBase64(base64List,
|
|
14428
|
+
function printImageBase64(base64List, options) {
|
|
14429
|
+
const { width, height, direction = PaperDirection.VERTICAL } = options;
|
|
14405
14430
|
const iframe = document.createElement("iframe");
|
|
14406
14431
|
iframe.style.visibility = "hidden";
|
|
14407
14432
|
iframe.style.position = "absolute";
|
|
@@ -14423,7 +14448,15 @@ function printImageBase64(base64List, width, height) {
|
|
|
14423
14448
|
container.append(image);
|
|
14424
14449
|
});
|
|
14425
14450
|
const style = document.createElement("style");
|
|
14426
|
-
const stylesheet =
|
|
14451
|
+
const stylesheet = `
|
|
14452
|
+
* {
|
|
14453
|
+
margin: 0;
|
|
14454
|
+
padding: 0;
|
|
14455
|
+
}
|
|
14456
|
+
@page {
|
|
14457
|
+
margin: 0;
|
|
14458
|
+
size: ${direction === PaperDirection.HORIZONTAL ? `landscape` : `portrait`};
|
|
14459
|
+
}`;
|
|
14427
14460
|
style.append(document.createTextNode(stylesheet));
|
|
14428
14461
|
setTimeout(() => {
|
|
14429
14462
|
doc.write(`${style.outerHTML}${container.innerHTML}`);
|
|
@@ -16112,7 +16145,7 @@ class CommandAdapt {
|
|
|
16112
16145
|
});
|
|
16113
16146
|
}
|
|
16114
16147
|
async print() {
|
|
16115
|
-
const { scale, printPixelRatio } = this.options;
|
|
16148
|
+
const { scale, printPixelRatio, paperDirection } = this.options;
|
|
16116
16149
|
if (scale !== 1) {
|
|
16117
16150
|
this.draw.setPageScale(1);
|
|
16118
16151
|
}
|
|
@@ -16122,7 +16155,11 @@ class CommandAdapt {
|
|
|
16122
16155
|
pixelRatio: printPixelRatio,
|
|
16123
16156
|
mode: EditorMode.PRINT
|
|
16124
16157
|
});
|
|
16125
|
-
printImageBase64(base64List,
|
|
16158
|
+
printImageBase64(base64List, {
|
|
16159
|
+
width,
|
|
16160
|
+
height,
|
|
16161
|
+
direction: paperDirection
|
|
16162
|
+
});
|
|
16126
16163
|
if (scale !== 1) {
|
|
16127
16164
|
this.draw.setPageScale(scale);
|
|
16128
16165
|
}
|