@hufe921/canvas-editor 0.9.64 → 0.9.65
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 +17 -0
- package/dist/canvas-editor.es.js +33 -18
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +21 -21
- 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 +1 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
+
## [0.9.65](https://github.com/Hufe921/canvas-editor/compare/v0.9.64...v0.9.65) (2024-02-06)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* cursor position error when scaling the page #434 ([e03feb2](https://github.com/Hufe921/canvas-editor/commit/e03feb210282779ecebb7af3d9a3801392b66979)), closes [#434](https://github.com/Hufe921/canvas-editor/issues/434)
|
|
7
|
+
* insert image render error when scaling the page #433 ([acb0d3f](https://github.com/Hufe921/canvas-editor/commit/acb0d3fc47953c822b2daa5b1b437780a2c0f67e)), closes [#433](https://github.com/Hufe921/canvas-editor/issues/433)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* add getRange api #429 ([2a6a41c](https://github.com/Hufe921/canvas-editor/commit/2a6a41c8c9ebe8188de08d43f10db89c77016950)), closes [#429](https://github.com/Hufe921/canvas-editor/issues/429)
|
|
13
|
+
* paste original elements by api ([7ab103e](https://github.com/Hufe921/canvas-editor/commit/7ab103edd9c3dbfa3c94b31167fc68487656a4d0))
|
|
14
|
+
* set margin style when printing #431 ([4015707](https://github.com/Hufe921/canvas-editor/commit/4015707025689648be2d3082dfbcbe2e597b55d1)), closes [#431](https://github.com/Hufe921/canvas-editor/issues/431)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
1
18
|
## [0.9.64](https://github.com/Hufe921/canvas-editor/compare/v0.9.63...v0.9.64) (2024-01-28)
|
|
2
19
|
|
|
3
20
|
|
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.65";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -4744,10 +4744,16 @@ async function pasteByApi(host, options) {
|
|
|
4744
4744
|
paste();
|
|
4745
4745
|
return;
|
|
4746
4746
|
}
|
|
4747
|
+
const clipboardText = await navigator.clipboard.readText();
|
|
4748
|
+
const editorClipboardData = getClipboardData();
|
|
4749
|
+
if (clipboardText === (editorClipboardData == null ? void 0 : editorClipboardData.text)) {
|
|
4750
|
+
pasteElement(host, editorClipboardData.elementList);
|
|
4751
|
+
return;
|
|
4752
|
+
}
|
|
4753
|
+
removeClipboardData();
|
|
4747
4754
|
if (options == null ? void 0 : options.isPlainText) {
|
|
4748
|
-
|
|
4749
|
-
|
|
4750
|
-
host.input(text);
|
|
4755
|
+
if (clipboardText) {
|
|
4756
|
+
host.input(clipboardText);
|
|
4751
4757
|
}
|
|
4752
4758
|
} else {
|
|
4753
4759
|
const clipboardData = await navigator.clipboard.read();
|
|
@@ -8986,7 +8992,8 @@ class SeparatorParticle {
|
|
|
8986
8992
|
}
|
|
8987
8993
|
render(ctx, element, x, y) {
|
|
8988
8994
|
ctx.save();
|
|
8989
|
-
|
|
8995
|
+
const { scale } = this.options;
|
|
8996
|
+
ctx.lineWidth = scale;
|
|
8990
8997
|
if (element.color) {
|
|
8991
8998
|
ctx.strokeStyle = element.color;
|
|
8992
8999
|
}
|
|
@@ -8996,7 +9003,7 @@ class SeparatorParticle {
|
|
|
8996
9003
|
ctx.translate(0, 0.5);
|
|
8997
9004
|
ctx.beginPath();
|
|
8998
9005
|
ctx.moveTo(x, y);
|
|
8999
|
-
ctx.lineTo(x + element.width, y);
|
|
9006
|
+
ctx.lineTo(x + element.width * scale, y);
|
|
9000
9007
|
ctx.stroke();
|
|
9001
9008
|
ctx.restore();
|
|
9002
9009
|
}
|
|
@@ -9015,7 +9022,7 @@ class PageBreakParticle {
|
|
|
9015
9022
|
const displayName = this.i18n.t("pageBreak.displayName");
|
|
9016
9023
|
const { scale, defaultRowMargin } = this.options;
|
|
9017
9024
|
const size = fontSize * scale;
|
|
9018
|
-
const elementWidth = element.width;
|
|
9025
|
+
const elementWidth = element.width * scale;
|
|
9019
9026
|
const offsetY = this.draw.getDefaultBasicRowMarginHeight() * defaultRowMargin;
|
|
9020
9027
|
ctx.save();
|
|
9021
9028
|
ctx.font = `${size}px ${font}`;
|
|
@@ -12898,9 +12905,11 @@ class Draw {
|
|
|
12898
12905
|
p.style.marginBottom = `${this.getPageGap()}px`;
|
|
12899
12906
|
this._initPageContext(this.ctxList[i]);
|
|
12900
12907
|
});
|
|
12908
|
+
const cursorPosition = this.position.getCursorPosition();
|
|
12901
12909
|
this.render({
|
|
12902
12910
|
isSubmitHistory: false,
|
|
12903
|
-
isSetCursor:
|
|
12911
|
+
isSetCursor: !!cursorPosition,
|
|
12912
|
+
curIndex: cursorPosition == null ? void 0 : cursorPosition.index
|
|
12904
12913
|
});
|
|
12905
12914
|
if (this.listener.pageScaleChange) {
|
|
12906
12915
|
this.listener.pageScaleChange(payload);
|
|
@@ -13121,11 +13130,12 @@ class Draw {
|
|
|
13121
13130
|
if (curRowWidth2 + elementWidth > availableWidth) {
|
|
13122
13131
|
const surplusWidth = availableWidth - curRowWidth2;
|
|
13123
13132
|
const adaptiveWidth = surplusWidth > 0 ? surplusWidth : Math.min(elementWidth, availableWidth);
|
|
13124
|
-
|
|
13125
|
-
element.
|
|
13126
|
-
|
|
13127
|
-
metrics.
|
|
13128
|
-
metrics.
|
|
13133
|
+
const adaptiveHeight = elementHeight * adaptiveWidth / elementWidth;
|
|
13134
|
+
element.width = adaptiveWidth / scale;
|
|
13135
|
+
element.height = adaptiveHeight / scale;
|
|
13136
|
+
metrics.width = adaptiveWidth;
|
|
13137
|
+
metrics.height = adaptiveHeight;
|
|
13138
|
+
metrics.boundingBoxDescent = adaptiveHeight;
|
|
13129
13139
|
} else {
|
|
13130
13140
|
metrics.width = elementWidth;
|
|
13131
13141
|
metrics.height = elementHeight;
|
|
@@ -13252,20 +13262,20 @@ class Draw {
|
|
|
13252
13262
|
}
|
|
13253
13263
|
}
|
|
13254
13264
|
} else if (element.type === ElementType.SEPARATOR) {
|
|
13255
|
-
element.width = availableWidth;
|
|
13265
|
+
element.width = availableWidth / scale;
|
|
13256
13266
|
metrics.width = availableWidth;
|
|
13257
13267
|
metrics.height = defaultSize;
|
|
13258
13268
|
metrics.boundingBoxAscent = -rowMargin;
|
|
13259
13269
|
metrics.boundingBoxDescent = -rowMargin;
|
|
13260
13270
|
} else if (element.type === ElementType.PAGE_BREAK) {
|
|
13261
|
-
element.width = availableWidth;
|
|
13271
|
+
element.width = availableWidth / scale;
|
|
13262
13272
|
metrics.width = availableWidth;
|
|
13263
13273
|
metrics.height = defaultSize;
|
|
13264
13274
|
} else if (element.type === ElementType.CHECKBOX || element.controlComponent === ControlComponent.CHECKBOX) {
|
|
13265
13275
|
const { width, height: height2, gap } = this.options.checkbox;
|
|
13266
|
-
const elementWidth =
|
|
13276
|
+
const elementWidth = width + gap * 2;
|
|
13267
13277
|
element.width = elementWidth;
|
|
13268
|
-
metrics.width = elementWidth;
|
|
13278
|
+
metrics.width = elementWidth * scale;
|
|
13269
13279
|
metrics.height = height2 * scale;
|
|
13270
13280
|
} else if (element.type === ElementType.TAB) {
|
|
13271
13281
|
metrics.width = defaultTabWidth * scale;
|
|
@@ -13909,6 +13919,7 @@ class Command {
|
|
|
13909
13919
|
__publicField(this, "getHTML");
|
|
13910
13920
|
__publicField(this, "getText");
|
|
13911
13921
|
__publicField(this, "getWordCount");
|
|
13922
|
+
__publicField(this, "getRange");
|
|
13912
13923
|
__publicField(this, "getRangeText");
|
|
13913
13924
|
__publicField(this, "getRangeContext");
|
|
13914
13925
|
__publicField(this, "getRangeRow");
|
|
@@ -14010,6 +14021,7 @@ class Command {
|
|
|
14010
14021
|
this.getHTML = adapt.getHTML.bind(adapt);
|
|
14011
14022
|
this.getText = adapt.getText.bind(adapt);
|
|
14012
14023
|
this.getWordCount = adapt.getWordCount.bind(adapt);
|
|
14024
|
+
this.getRange = adapt.getRange.bind(adapt);
|
|
14013
14025
|
this.getRangeText = adapt.getRangeText.bind(adapt);
|
|
14014
14026
|
this.getRangeContext = adapt.getRangeContext.bind(adapt);
|
|
14015
14027
|
this.getRangeRow = adapt.getRangeRow.bind(adapt);
|
|
@@ -14063,7 +14075,7 @@ function printImageBase64(base64List, width, height) {
|
|
|
14063
14075
|
container.append(image);
|
|
14064
14076
|
});
|
|
14065
14077
|
const style = document.createElement("style");
|
|
14066
|
-
const stylesheet = `*{margin:0;padding:0;}`;
|
|
14078
|
+
const stylesheet = `*{margin:0;padding:0;}@page{margin:0;}`;
|
|
14067
14079
|
style.append(document.createTextNode(stylesheet));
|
|
14068
14080
|
setTimeout(() => {
|
|
14069
14081
|
doc.write(`${style.outerHTML}${container.innerHTML}`);
|
|
@@ -15796,6 +15808,9 @@ class CommandAdapt {
|
|
|
15796
15808
|
getWordCount() {
|
|
15797
15809
|
return this.workerManager.getWordCount();
|
|
15798
15810
|
}
|
|
15811
|
+
getRange() {
|
|
15812
|
+
return deepClone(this.range.getRange());
|
|
15813
|
+
}
|
|
15799
15814
|
getRangeText() {
|
|
15800
15815
|
return this.range.toString();
|
|
15801
15816
|
}
|