@hufe921/canvas-editor 0.9.89 → 0.9.90
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 +21 -0
- package/dist/canvas-editor.es.js +174 -44
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +31 -31
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/command/CommandAdapt.d.ts +2 -2
- package/dist/src/editor/core/draw/Draw.d.ts +1 -0
- package/dist/src/editor/core/draw/particle/CheckboxParticle.d.ts +10 -2
- package/dist/src/editor/core/draw/particle/RadioParticle.d.ts +10 -2
- package/dist/src/editor/dataset/enum/Common.d.ts +4 -0
- package/dist/src/editor/index.d.ts +2 -2
- package/dist/src/editor/interface/Checkbox.d.ts +2 -0
- package/dist/src/editor/interface/Control.d.ts +4 -0
- package/dist/src/editor/interface/Radio.d.ts +2 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,24 @@
|
|
|
1
|
+
## [0.9.90](https://github.com/Hufe921/canvas-editor/compare/v0.9.89...v0.9.90) (2024-08-18)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* float image position when scaling the page #766 ([c249b9e](https://github.com/Hufe921/canvas-editor/commit/c249b9eec215fe573b325d1430212f5f01c32099)), closes [#766](https://github.com/Hufe921/canvas-editor/issues/766)
|
|
7
|
+
* get range paragraph info boundary error #758 ([4653fe7](https://github.com/Hufe921/canvas-editor/commit/4653fe7427f4a9ec40700f6a86ff284d1d46088a)), closes [#758](https://github.com/Hufe921/canvas-editor/issues/758)
|
|
8
|
+
* insert block element row flex error #754 ([136b1ff](https://github.com/Hufe921/canvas-editor/commit/136b1ffa55b7b0b78bf3d114400489e1bbab4f17)), closes [#754](https://github.com/Hufe921/canvas-editor/issues/754)
|
|
9
|
+
* paper printing size setting #760 ([7a6dd75](https://github.com/Hufe921/canvas-editor/commit/7a6dd753e59bde4cb581ac215b038dd1cd08c96f)), closes [#760](https://github.com/Hufe921/canvas-editor/issues/760)
|
|
10
|
+
* set editor mode option error #755 ([500cec3](https://github.com/Hufe921/canvas-editor/commit/500cec3e0b63e012f6572dcedb071befa114956e)), closes [#755](https://github.com/Hufe921/canvas-editor/issues/755)
|
|
11
|
+
* set row flex boundary error when deleting element ([2f272de](https://github.com/Hufe921/canvas-editor/commit/2f272dee58169607783e4cfd1347534f49db0834))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* add location property to executeLocationControl api #753 ([d1a1aaa](https://github.com/Hufe921/canvas-editor/commit/d1a1aaa6ae08d8395df1df664d47bfe4fe821869)), closes [#753](https://github.com/Hufe921/canvas-editor/issues/753)
|
|
17
|
+
* add radio and checkbox vertical align setting ([c375466](https://github.com/Hufe921/canvas-editor/commit/c3754663cee25003a7021a6079dd46e2a3a0abd8))
|
|
18
|
+
* get context content width ([187498e](https://github.com/Hufe921/canvas-editor/commit/187498ed3dfba4386375d812d41b31c057ac3af8))
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
1
22
|
## [0.9.89](https://github.com/Hufe921/canvas-editor/compare/v0.9.88...v0.9.89) (2024-08-09)
|
|
2
23
|
|
|
3
24
|
|
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.90";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -42,6 +42,11 @@ var ImageDisplay;
|
|
|
42
42
|
ImageDisplay2["FLOAT_TOP"] = "float-top";
|
|
43
43
|
ImageDisplay2["FLOAT_BOTTOM"] = "float-bottom";
|
|
44
44
|
})(ImageDisplay || (ImageDisplay = {}));
|
|
45
|
+
var LocationPosition;
|
|
46
|
+
(function(LocationPosition2) {
|
|
47
|
+
LocationPosition2["BEFORE"] = "before";
|
|
48
|
+
LocationPosition2["AFTER"] = "after";
|
|
49
|
+
})(LocationPosition || (LocationPosition = {}));
|
|
45
50
|
const ZERO = "\u200B";
|
|
46
51
|
const WRAP = "\n";
|
|
47
52
|
const NBSP = " ";
|
|
@@ -508,8 +513,7 @@ const CONTROL_STYLE_ATTR = [
|
|
|
508
513
|
const EDITOR_ELEMENT_CONTEXT_ATTR = [
|
|
509
514
|
...TABLE_CONTEXT_ATTR,
|
|
510
515
|
...TITLE_CONTEXT_ATTR,
|
|
511
|
-
...LIST_CONTEXT_ATTR
|
|
512
|
-
...EDITOR_ROW_ATTR
|
|
516
|
+
...LIST_CONTEXT_ATTR
|
|
513
517
|
];
|
|
514
518
|
const TEXTLIKE_ELEMENT_TYPE = [
|
|
515
519
|
ElementType.TEXT,
|
|
@@ -3893,7 +3897,10 @@ function formatElementList(elementList, options) {
|
|
|
3893
3897
|
const { editorOptions: { control: controlOption, checkbox: checkboxOption, radio: radioOption } } = options;
|
|
3894
3898
|
const controlId = getUUID();
|
|
3895
3899
|
elementList.splice(i, 1);
|
|
3896
|
-
const controlContext = pickObject(el,
|
|
3900
|
+
const controlContext = pickObject(el, [
|
|
3901
|
+
...EDITOR_ELEMENT_CONTEXT_ATTR,
|
|
3902
|
+
...EDITOR_ROW_ATTR
|
|
3903
|
+
]);
|
|
3897
3904
|
const controlDefaultStyle = pickObject(el.control, CONTROL_STYLE_ATTR);
|
|
3898
3905
|
const thePrePostfixArg = __spreadProps(__spreadValues({}, controlDefaultStyle), {
|
|
3899
3906
|
color: editorOptions.control.bracketColor
|
|
@@ -4358,17 +4365,21 @@ function formatElementContext(sourceElementList, formatElementList2, anchorIndex
|
|
|
4358
4365
|
isBreakWarped = true;
|
|
4359
4366
|
}
|
|
4360
4367
|
if (isBreakWarped || !copyElement.listId && targetElement.type === ElementType.LIST) {
|
|
4361
|
-
const
|
|
4362
|
-
cloneProperty(
|
|
4368
|
+
const cloneAttr2 = [...TABLE_CONTEXT_ATTR, ...EDITOR_ROW_ATTR];
|
|
4369
|
+
cloneProperty(cloneAttr2, copyElement, targetElement);
|
|
4363
4370
|
(_b = targetElement.valueList) == null ? void 0 : _b.forEach((valueItem) => {
|
|
4364
|
-
cloneProperty(
|
|
4371
|
+
cloneProperty(cloneAttr2, copyElement, valueItem);
|
|
4365
4372
|
});
|
|
4366
4373
|
continue;
|
|
4367
4374
|
}
|
|
4368
4375
|
if ((_c = targetElement.valueList) == null ? void 0 : _c.length) {
|
|
4369
4376
|
formatElementContext(sourceElementList, targetElement.valueList, anchorIndex);
|
|
4370
4377
|
}
|
|
4371
|
-
|
|
4378
|
+
const cloneAttr = [...EDITOR_ELEMENT_CONTEXT_ATTR];
|
|
4379
|
+
if (!getIsBlockElement(targetElement)) {
|
|
4380
|
+
cloneAttr.push(...EDITOR_ROW_ATTR);
|
|
4381
|
+
}
|
|
4382
|
+
cloneProperty(cloneAttr, copyElement, targetElement);
|
|
4372
4383
|
}
|
|
4373
4384
|
}
|
|
4374
4385
|
function convertElementToDom(element, options) {
|
|
@@ -6112,13 +6123,13 @@ function backspace(evt, host) {
|
|
|
6112
6123
|
}
|
|
6113
6124
|
const startElement = elementList[startIndex];
|
|
6114
6125
|
if (isCollapsed && startElement.rowFlex && startElement.value === ZERO) {
|
|
6115
|
-
const
|
|
6116
|
-
|
|
6117
|
-
|
|
6118
|
-
|
|
6119
|
-
|
|
6120
|
-
|
|
6121
|
-
}
|
|
6126
|
+
const rowFlexElementList = rangeManager.getRangeRowElementList();
|
|
6127
|
+
if (rowFlexElementList) {
|
|
6128
|
+
const preElement = elementList[startIndex - 1];
|
|
6129
|
+
rowFlexElementList.forEach((element) => {
|
|
6130
|
+
element.rowFlex = preElement == null ? void 0 : preElement.rowFlex;
|
|
6131
|
+
});
|
|
6132
|
+
}
|
|
6122
6133
|
}
|
|
6123
6134
|
if (!isCollapsed) {
|
|
6124
6135
|
draw.spliceElementList(elementList, startIndex + 1, endIndex - startIndex);
|
|
@@ -8351,7 +8362,8 @@ class RangeManager {
|
|
|
8351
8362
|
}
|
|
8352
8363
|
start--;
|
|
8353
8364
|
}
|
|
8354
|
-
|
|
8365
|
+
const isCollapsed = startIndex === endIndex;
|
|
8366
|
+
if (!isCollapsed) {
|
|
8355
8367
|
let middle = startIndex + 1;
|
|
8356
8368
|
while (middle < endIndex) {
|
|
8357
8369
|
const { pageNo, rowNo } = positionList[middle];
|
|
@@ -8367,6 +8379,9 @@ class RangeManager {
|
|
|
8367
8379
|
}
|
|
8368
8380
|
}
|
|
8369
8381
|
let end = endIndex;
|
|
8382
|
+
if (isCollapsed && elementList[startIndex].value === ZERO) {
|
|
8383
|
+
end += 1;
|
|
8384
|
+
}
|
|
8370
8385
|
while (end < positionList.length) {
|
|
8371
8386
|
const element = elementList[end];
|
|
8372
8387
|
const nextElement = elementList[end + 1];
|
|
@@ -12774,6 +12789,12 @@ class Control {
|
|
|
12774
12789
|
});
|
|
12775
12790
|
}
|
|
12776
12791
|
}
|
|
12792
|
+
var VerticalAlign;
|
|
12793
|
+
(function(VerticalAlign2) {
|
|
12794
|
+
VerticalAlign2["TOP"] = "top";
|
|
12795
|
+
VerticalAlign2["MIDDLE"] = "middle";
|
|
12796
|
+
VerticalAlign2["BOTTOM"] = "bottom";
|
|
12797
|
+
})(VerticalAlign || (VerticalAlign = {}));
|
|
12777
12798
|
class CheckboxParticle {
|
|
12778
12799
|
constructor(draw) {
|
|
12779
12800
|
__publicField(this, "draw");
|
|
@@ -12795,9 +12816,32 @@ class CheckboxParticle {
|
|
|
12795
12816
|
isSetCursor: false
|
|
12796
12817
|
});
|
|
12797
12818
|
}
|
|
12798
|
-
render(
|
|
12799
|
-
const {
|
|
12800
|
-
|
|
12819
|
+
render(payload) {
|
|
12820
|
+
const { ctx, x, index: index2, row } = payload;
|
|
12821
|
+
let { y } = payload;
|
|
12822
|
+
const { checkbox: { gap, lineWidth, fillStyle, strokeStyle, verticalAlign }, scale } = this.options;
|
|
12823
|
+
const { metrics, checkbox } = row.elementList[index2];
|
|
12824
|
+
if (verticalAlign === VerticalAlign.TOP || verticalAlign === VerticalAlign.MIDDLE) {
|
|
12825
|
+
let nextIndex = index2 + 1;
|
|
12826
|
+
let nextElement = null;
|
|
12827
|
+
while (nextIndex < row.elementList.length) {
|
|
12828
|
+
nextElement = row.elementList[nextIndex];
|
|
12829
|
+
if (nextElement.value !== ZERO && nextElement.value !== NBSP)
|
|
12830
|
+
break;
|
|
12831
|
+
nextIndex++;
|
|
12832
|
+
}
|
|
12833
|
+
if (nextElement) {
|
|
12834
|
+
const { metrics: { boundingBoxAscent, boundingBoxDescent } } = nextElement;
|
|
12835
|
+
const textHeight = boundingBoxAscent + boundingBoxDescent;
|
|
12836
|
+
if (textHeight > metrics.height) {
|
|
12837
|
+
if (verticalAlign === VerticalAlign.TOP) {
|
|
12838
|
+
y -= boundingBoxAscent - metrics.height;
|
|
12839
|
+
} else if (verticalAlign === VerticalAlign.MIDDLE) {
|
|
12840
|
+
y -= (textHeight - metrics.height) / 2;
|
|
12841
|
+
}
|
|
12842
|
+
}
|
|
12843
|
+
}
|
|
12844
|
+
}
|
|
12801
12845
|
const left2 = Math.round(x + gap * scale);
|
|
12802
12846
|
const top = Math.round(y - metrics.height + lineWidth);
|
|
12803
12847
|
const width = metrics.width - gap * 2 * scale;
|
|
@@ -12850,9 +12894,32 @@ class RadioParticle {
|
|
|
12850
12894
|
isSetCursor: false
|
|
12851
12895
|
});
|
|
12852
12896
|
}
|
|
12853
|
-
render(
|
|
12854
|
-
const {
|
|
12855
|
-
|
|
12897
|
+
render(payload) {
|
|
12898
|
+
const { ctx, x, index: index2, row } = payload;
|
|
12899
|
+
let { y } = payload;
|
|
12900
|
+
const { radio: { gap, lineWidth, fillStyle, strokeStyle, verticalAlign }, scale } = this.options;
|
|
12901
|
+
const { metrics, radio } = row.elementList[index2];
|
|
12902
|
+
if (verticalAlign === VerticalAlign.TOP || verticalAlign === VerticalAlign.MIDDLE) {
|
|
12903
|
+
let nextIndex = index2 + 1;
|
|
12904
|
+
let nextElement = null;
|
|
12905
|
+
while (nextIndex < row.elementList.length) {
|
|
12906
|
+
nextElement = row.elementList[nextIndex];
|
|
12907
|
+
if (nextElement.value !== ZERO && nextElement.value !== NBSP)
|
|
12908
|
+
break;
|
|
12909
|
+
nextIndex++;
|
|
12910
|
+
}
|
|
12911
|
+
if (nextElement) {
|
|
12912
|
+
const { metrics: { boundingBoxAscent, boundingBoxDescent } } = nextElement;
|
|
12913
|
+
const textHeight = boundingBoxAscent + boundingBoxDescent;
|
|
12914
|
+
if (textHeight > metrics.height) {
|
|
12915
|
+
if (verticalAlign === VerticalAlign.TOP) {
|
|
12916
|
+
y -= boundingBoxAscent - metrics.height;
|
|
12917
|
+
} else if (verticalAlign === VerticalAlign.MIDDLE) {
|
|
12918
|
+
y -= (textHeight - metrics.height) / 2;
|
|
12919
|
+
}
|
|
12920
|
+
}
|
|
12921
|
+
}
|
|
12922
|
+
}
|
|
12856
12923
|
const left2 = Math.round(x + gap * scale);
|
|
12857
12924
|
const top = Math.round(y - metrics.height + lineWidth);
|
|
12858
12925
|
const width = metrics.width - gap * 2 * scale;
|
|
@@ -14279,7 +14346,15 @@ class ListParticle {
|
|
|
14279
14346
|
height: height * scale
|
|
14280
14347
|
})
|
|
14281
14348
|
});
|
|
14282
|
-
this.draw.getCheckboxParticle().render(
|
|
14349
|
+
this.draw.getCheckboxParticle().render({
|
|
14350
|
+
ctx,
|
|
14351
|
+
x: x - gap * scale,
|
|
14352
|
+
y,
|
|
14353
|
+
index: 0,
|
|
14354
|
+
row: __spreadProps(__spreadValues({}, row), {
|
|
14355
|
+
elementList: [checkboxRowElement, ...row.elementList]
|
|
14356
|
+
})
|
|
14357
|
+
});
|
|
14283
14358
|
} else {
|
|
14284
14359
|
let text = "";
|
|
14285
14360
|
if (startElement.listType === ListType.UL) {
|
|
@@ -14813,6 +14888,7 @@ class Draw {
|
|
|
14813
14888
|
this.clearSideEffect();
|
|
14814
14889
|
this.range.clearRange();
|
|
14815
14890
|
this.mode = payload;
|
|
14891
|
+
this.options.mode = payload;
|
|
14816
14892
|
this.render({
|
|
14817
14893
|
isSetCursor: false,
|
|
14818
14894
|
isSubmitHistory: false
|
|
@@ -14886,6 +14962,17 @@ class Draw {
|
|
|
14886
14962
|
const margins = this.getOriginalMargins();
|
|
14887
14963
|
return width - margins[1] - margins[3];
|
|
14888
14964
|
}
|
|
14965
|
+
getContextInnerWidth() {
|
|
14966
|
+
const positionContext = this.position.getPositionContext();
|
|
14967
|
+
if (positionContext.isTable) {
|
|
14968
|
+
const { index: index2, trIndex, tdIndex } = positionContext;
|
|
14969
|
+
const elementList = this.getOriginalElementList();
|
|
14970
|
+
const td = elementList[index2].trList[trIndex].tdList[tdIndex];
|
|
14971
|
+
const tdPadding = this.getTdPadding();
|
|
14972
|
+
return td.width - tdPadding[1] - tdPadding[3];
|
|
14973
|
+
}
|
|
14974
|
+
return this.getOriginalInnerWidth();
|
|
14975
|
+
}
|
|
14889
14976
|
getMargins() {
|
|
14890
14977
|
return this.getOriginalMargins().map((m) => m * this.options.scale);
|
|
14891
14978
|
}
|
|
@@ -16039,10 +16126,22 @@ class Draw {
|
|
|
16039
16126
|
}
|
|
16040
16127
|
} else if (element.type === ElementType.CHECKBOX || element.controlComponent === ControlComponent.CHECKBOX) {
|
|
16041
16128
|
this.textParticle.complete();
|
|
16042
|
-
this.checkboxParticle.render(
|
|
16129
|
+
this.checkboxParticle.render({
|
|
16130
|
+
ctx,
|
|
16131
|
+
x,
|
|
16132
|
+
y: y + offsetY,
|
|
16133
|
+
index: j,
|
|
16134
|
+
row: curRow
|
|
16135
|
+
});
|
|
16043
16136
|
} else if (element.type === ElementType.RADIO || element.controlComponent === ControlComponent.RADIO) {
|
|
16044
16137
|
this.textParticle.complete();
|
|
16045
|
-
this.radioParticle.render(
|
|
16138
|
+
this.radioParticle.render({
|
|
16139
|
+
ctx,
|
|
16140
|
+
x,
|
|
16141
|
+
y: y + offsetY,
|
|
16142
|
+
index: j,
|
|
16143
|
+
row: curRow
|
|
16144
|
+
});
|
|
16046
16145
|
} else if (element.type === ElementType.TAB) {
|
|
16047
16146
|
this.textParticle.complete();
|
|
16048
16147
|
} else if (element.rowFlex === RowFlex.ALIGNMENT || element.rowFlex === RowFlex.JUSTIFY) {
|
|
@@ -16175,6 +16274,7 @@ class Draw {
|
|
|
16175
16274
|
}
|
|
16176
16275
|
}
|
|
16177
16276
|
_drawFloat(ctx, payload) {
|
|
16277
|
+
const { scale } = this.options;
|
|
16178
16278
|
const floatPositionList = this.position.getFloatPositionList();
|
|
16179
16279
|
const { imgDisplay, pageNo } = payload;
|
|
16180
16280
|
for (let e = 0; e < floatPositionList.length; e++) {
|
|
@@ -16182,7 +16282,7 @@ class Draw {
|
|
|
16182
16282
|
const element = floatPosition.element;
|
|
16183
16283
|
if ((pageNo === floatPosition.pageNo || floatPosition.zone === EditorZone.HEADER || floatPosition.zone == EditorZone.FOOTER) && element.imgDisplay === imgDisplay && element.type === ElementType.IMAGE) {
|
|
16184
16284
|
const imgFloatPosition = element.imgFloatPosition;
|
|
16185
|
-
this.imageParticle.render(ctx, element, imgFloatPosition.x, imgFloatPosition.y);
|
|
16285
|
+
this.imageParticle.render(ctx, element, imgFloatPosition.x * scale, imgFloatPosition.y * scale);
|
|
16186
16286
|
}
|
|
16187
16287
|
}
|
|
16188
16288
|
}
|
|
@@ -16673,12 +16773,6 @@ const defaultWatermarkOption = {
|
|
|
16673
16773
|
size: 200,
|
|
16674
16774
|
font: "Microsoft YaHei"
|
|
16675
16775
|
};
|
|
16676
|
-
var VerticalAlign;
|
|
16677
|
-
(function(VerticalAlign2) {
|
|
16678
|
-
VerticalAlign2["TOP"] = "top";
|
|
16679
|
-
VerticalAlign2["MIDDLE"] = "middle";
|
|
16680
|
-
VerticalAlign2["BOTTOM"] = "bottom";
|
|
16681
|
-
})(VerticalAlign || (VerticalAlign = {}));
|
|
16682
16776
|
const defaultBackground = {
|
|
16683
16777
|
color: "#FFFFFF",
|
|
16684
16778
|
image: "",
|
|
@@ -16692,7 +16786,8 @@ const defaultCheckboxOption = {
|
|
|
16692
16786
|
gap: 5,
|
|
16693
16787
|
lineWidth: 1,
|
|
16694
16788
|
fillStyle: "#5175f4",
|
|
16695
|
-
strokeStyle: "#ffffff"
|
|
16789
|
+
strokeStyle: "#ffffff",
|
|
16790
|
+
verticalAlign: VerticalAlign.BOTTOM
|
|
16696
16791
|
};
|
|
16697
16792
|
const defaultControlOption = {
|
|
16698
16793
|
placeholderColor: "#9c9b9b",
|
|
@@ -16742,7 +16837,8 @@ const defaultRadioOption = {
|
|
|
16742
16837
|
gap: 5,
|
|
16743
16838
|
lineWidth: 1,
|
|
16744
16839
|
fillStyle: "#5175f4",
|
|
16745
|
-
strokeStyle: "#000000"
|
|
16840
|
+
strokeStyle: "#000000",
|
|
16841
|
+
verticalAlign: VerticalAlign.BOTTOM
|
|
16746
16842
|
};
|
|
16747
16843
|
const defaultSeparatorOption = {
|
|
16748
16844
|
lineWidth: 1,
|
|
@@ -16845,6 +16941,34 @@ function mergeOption(options = {}) {
|
|
|
16845
16941
|
lineNumber: lineNumberOptions
|
|
16846
16942
|
});
|
|
16847
16943
|
}
|
|
16944
|
+
function convertPxToPaperSize(width, height) {
|
|
16945
|
+
if (width === 1125 && height === 1593) {
|
|
16946
|
+
return {
|
|
16947
|
+
size: "a3",
|
|
16948
|
+
width: "297mm",
|
|
16949
|
+
height: "420mm"
|
|
16950
|
+
};
|
|
16951
|
+
}
|
|
16952
|
+
if (width === 794 && height === 1123) {
|
|
16953
|
+
return {
|
|
16954
|
+
size: "a4",
|
|
16955
|
+
width: "210mm",
|
|
16956
|
+
height: "297mm"
|
|
16957
|
+
};
|
|
16958
|
+
}
|
|
16959
|
+
if (width === 565 && height === 796) {
|
|
16960
|
+
return {
|
|
16961
|
+
size: "a5",
|
|
16962
|
+
width: "148mm",
|
|
16963
|
+
height: "210mm"
|
|
16964
|
+
};
|
|
16965
|
+
}
|
|
16966
|
+
return {
|
|
16967
|
+
size: "",
|
|
16968
|
+
width: `${width}px`,
|
|
16969
|
+
height: `${height}px`
|
|
16970
|
+
};
|
|
16971
|
+
}
|
|
16848
16972
|
function printImageBase64(base64List, options) {
|
|
16849
16973
|
const { width, height, direction = PaperDirection.VERTICAL } = options;
|
|
16850
16974
|
const iframe = document.createElement("iframe");
|
|
@@ -16860,10 +16984,11 @@ function printImageBase64(base64List, options) {
|
|
|
16860
16984
|
const doc = contentWindow.document;
|
|
16861
16985
|
doc.open();
|
|
16862
16986
|
const container = document.createElement("div");
|
|
16987
|
+
const paperSize = convertPxToPaperSize(width, height);
|
|
16863
16988
|
base64List.forEach((base64) => {
|
|
16864
16989
|
const image = document.createElement("img");
|
|
16865
|
-
image.style.width =
|
|
16866
|
-
image.style.height =
|
|
16990
|
+
image.style.width = direction === PaperDirection.HORIZONTAL ? paperSize.height : paperSize.width;
|
|
16991
|
+
image.style.height = direction === PaperDirection.HORIZONTAL ? paperSize.width : paperSize.height;
|
|
16867
16992
|
image.src = base64;
|
|
16868
16993
|
container.append(image);
|
|
16869
16994
|
});
|
|
@@ -16875,7 +17000,7 @@ function printImageBase64(base64List, options) {
|
|
|
16875
17000
|
}
|
|
16876
17001
|
@page {
|
|
16877
17002
|
margin: 0;
|
|
16878
|
-
size: ${direction === PaperDirection.HORIZONTAL ? `landscape` : `portrait`};
|
|
17003
|
+
size: ${paperSize.size} ${direction === PaperDirection.HORIZONTAL ? `landscape` : `portrait`};
|
|
16879
17004
|
}`;
|
|
16880
17005
|
style.append(document.createTextNode(stylesheet));
|
|
16881
17006
|
setTimeout(() => {
|
|
@@ -17509,7 +17634,7 @@ class CommandAdapt {
|
|
|
17509
17634
|
const row2 = rowList[rowIndex];
|
|
17510
17635
|
offsetX = (row2 == null ? void 0 : row2.offsetX) || 0;
|
|
17511
17636
|
}
|
|
17512
|
-
const innerWidth = this.draw.
|
|
17637
|
+
const innerWidth = this.draw.getContextInnerWidth() - offsetX;
|
|
17513
17638
|
const colgroup = [];
|
|
17514
17639
|
const colWidth = innerWidth / col;
|
|
17515
17640
|
for (let c = 0; c < col; c++) {
|
|
@@ -18578,12 +18703,10 @@ class CommandAdapt {
|
|
|
18578
18703
|
});
|
|
18579
18704
|
}
|
|
18580
18705
|
async print() {
|
|
18581
|
-
const { scale, printPixelRatio, paperDirection } = this.options;
|
|
18706
|
+
const { scale, printPixelRatio, paperDirection, width, height } = this.options;
|
|
18582
18707
|
if (scale !== 1) {
|
|
18583
18708
|
this.draw.setPageScale(1);
|
|
18584
18709
|
}
|
|
18585
|
-
const width = this.draw.getOriginalWidth();
|
|
18586
|
-
const height = this.draw.getOriginalHeight();
|
|
18587
18710
|
const base64List = await this.draw.getDataURL({
|
|
18588
18711
|
pixelRatio: printPixelRatio,
|
|
18589
18712
|
mode: EditorMode.PRINT
|
|
@@ -19015,7 +19138,8 @@ class CommandAdapt {
|
|
|
19015
19138
|
getControlList() {
|
|
19016
19139
|
return this.draw.getControl().getList();
|
|
19017
19140
|
}
|
|
19018
|
-
locationControl(controlId) {
|
|
19141
|
+
locationControl(controlId, options) {
|
|
19142
|
+
const isLocationAfter = (options == null ? void 0 : options.position) === LocationPosition.AFTER;
|
|
19019
19143
|
function location(elementList, zone2) {
|
|
19020
19144
|
let i = 0;
|
|
19021
19145
|
while (i < elementList.length) {
|
|
@@ -19046,7 +19170,13 @@ class CommandAdapt {
|
|
|
19046
19170
|
}
|
|
19047
19171
|
if ((element == null ? void 0 : element.controlId) !== controlId)
|
|
19048
19172
|
continue;
|
|
19049
|
-
|
|
19173
|
+
let curIndex = i - 1;
|
|
19174
|
+
if (isLocationAfter) {
|
|
19175
|
+
curIndex -= 1;
|
|
19176
|
+
if (element.controlComponent !== ControlComponent.PLACEHOLDER && element.controlComponent !== ControlComponent.POSTFIX) {
|
|
19177
|
+
continue;
|
|
19178
|
+
}
|
|
19179
|
+
}
|
|
19050
19180
|
return {
|
|
19051
19181
|
zone: zone2,
|
|
19052
19182
|
range: {
|
|
@@ -20368,5 +20498,5 @@ class Editor {
|
|
|
20368
20498
|
this.use = plugin.use.bind(plugin);
|
|
20369
20499
|
}
|
|
20370
20500
|
}
|
|
20371
|
-
export { BackgroundRepeat, BackgroundSize, BlockType, Command, ControlIndentation, ControlType, EDITOR_COMPONENT, Editor, EditorComponent, EditorMode, EditorZone, ElementType, INTERNAL_CONTEXT_MENU_KEY, ImageDisplay, KeyMap, LETTER_CLASS, LineNumberType, ListStyle, ListType, MaxHeightRatio, NumberType, PageMode, PaperDirection, RenderMode, RowFlex, TableBorder, TdBorder, TdSlash, TextDecorationStyle, TitleLevel, VerticalAlign, WordBreak, Editor as default, splitText };
|
|
20501
|
+
export { BackgroundRepeat, BackgroundSize, BlockType, Command, ControlIndentation, ControlType, EDITOR_COMPONENT, Editor, EditorComponent, EditorMode, EditorZone, ElementType, INTERNAL_CONTEXT_MENU_KEY, ImageDisplay, KeyMap, LETTER_CLASS, LineNumberType, ListStyle, ListType, LocationPosition, MaxHeightRatio, NumberType, PageMode, PaperDirection, RenderMode, RowFlex, TableBorder, TdBorder, TdSlash, TextDecorationStyle, TitleLevel, VerticalAlign, WordBreak, Editor as default, splitText };
|
|
20372
20502
|
//# sourceMappingURL=canvas-editor.es.js.map
|