@hufe921/canvas-editor 0.9.18 → 0.9.19
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/dist/canvas-editor.es.js +70 -52
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +15 -15
- package/dist/canvas-editor.umd.js.map +1 -1
- package/dist/src/editor/core/draw/Draw.d.ts +3 -3
- package/dist/src/editor/core/draw/control/Control.d.ts +1 -0
- package/dist/src/editor/core/draw/frame/Margin.d.ts +1 -1
- package/package.json +1 -1
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.19";
|
|
27
27
|
const ZERO = "\u200B";
|
|
28
28
|
const WRAP = "\n";
|
|
29
29
|
var RowFlex;
|
|
@@ -3273,7 +3273,9 @@ function formatElementList(elementList, options) {
|
|
|
3273
3273
|
const td = tr.tdList[d];
|
|
3274
3274
|
const tdId = getUUID();
|
|
3275
3275
|
td.id = tdId;
|
|
3276
|
-
formatElementList(td.value, options)
|
|
3276
|
+
formatElementList(td.value, __spreadProps(__spreadValues({}, options), {
|
|
3277
|
+
isHandleFirstElement: true
|
|
3278
|
+
}));
|
|
3277
3279
|
for (let v = 0; v < td.value.length; v++) {
|
|
3278
3280
|
const value = td.value[v];
|
|
3279
3281
|
value.tdId = tdId;
|
|
@@ -4168,8 +4170,7 @@ class CheckboxControl {
|
|
|
4168
4170
|
return data2;
|
|
4169
4171
|
}
|
|
4170
4172
|
setValue() {
|
|
4171
|
-
|
|
4172
|
-
return endIndex;
|
|
4173
|
+
return -1;
|
|
4173
4174
|
}
|
|
4174
4175
|
setSelect() {
|
|
4175
4176
|
const { control } = this.element;
|
|
@@ -4512,7 +4513,7 @@ function keydown(evt, host) {
|
|
|
4512
4513
|
value: ZERO
|
|
4513
4514
|
}, restArg);
|
|
4514
4515
|
let curIndex;
|
|
4515
|
-
if (activeControl) {
|
|
4516
|
+
if (activeControl && !control.isRangInPostfix()) {
|
|
4516
4517
|
curIndex = control.setValue([enterText]);
|
|
4517
4518
|
} else {
|
|
4518
4519
|
if (isCollapsed) {
|
|
@@ -4522,8 +4523,10 @@ function keydown(evt, host) {
|
|
|
4522
4523
|
}
|
|
4523
4524
|
curIndex = index2 + 1;
|
|
4524
4525
|
}
|
|
4525
|
-
|
|
4526
|
-
|
|
4526
|
+
if (~curIndex) {
|
|
4527
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4528
|
+
draw.render({ curIndex });
|
|
4529
|
+
}
|
|
4527
4530
|
evt.preventDefault();
|
|
4528
4531
|
} else if (evt.key === KeyMap.Left) {
|
|
4529
4532
|
if (isReadonly)
|
|
@@ -4699,7 +4702,6 @@ function keydown(evt, host) {
|
|
|
4699
4702
|
}
|
|
4700
4703
|
}
|
|
4701
4704
|
function input(data2, host) {
|
|
4702
|
-
var _a;
|
|
4703
4705
|
const draw = host.getDraw();
|
|
4704
4706
|
const isReadonly = draw.isReadonly();
|
|
4705
4707
|
if (isReadonly)
|
|
@@ -4752,7 +4754,7 @@ function input(data2, host) {
|
|
|
4752
4754
|
return newElement;
|
|
4753
4755
|
});
|
|
4754
4756
|
let curIndex;
|
|
4755
|
-
if (activeControl && (
|
|
4757
|
+
if (activeControl && !control.isRangInPostfix()) {
|
|
4756
4758
|
curIndex = control.setValue(inputData);
|
|
4757
4759
|
} else {
|
|
4758
4760
|
const start = startIndex + 1;
|
|
@@ -4764,11 +4766,13 @@ function input(data2, host) {
|
|
|
4764
4766
|
}
|
|
4765
4767
|
curIndex = startIndex + inputData.length;
|
|
4766
4768
|
}
|
|
4767
|
-
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4769
|
+
if (~curIndex) {
|
|
4770
|
+
rangeManager.setRange(curIndex, curIndex);
|
|
4771
|
+
draw.render({
|
|
4772
|
+
curIndex,
|
|
4773
|
+
isSubmitHistory: !isComposing
|
|
4774
|
+
});
|
|
4775
|
+
}
|
|
4772
4776
|
if (isComposing) {
|
|
4773
4777
|
host.compositionInfo = {
|
|
4774
4778
|
elementList,
|
|
@@ -5890,10 +5894,10 @@ class Margin {
|
|
|
5890
5894
|
this.draw = draw;
|
|
5891
5895
|
this.options = draw.getOptions();
|
|
5892
5896
|
}
|
|
5893
|
-
render(ctx) {
|
|
5897
|
+
render(ctx, pageNo) {
|
|
5894
5898
|
const { marginIndicatorColor, pageMode } = this.options;
|
|
5895
5899
|
const width = this.draw.getWidth();
|
|
5896
|
-
const height = pageMode === PageMode.CONTINUITY ? this.draw.getCanvasHeight() : this.draw.getHeight();
|
|
5900
|
+
const height = pageMode === PageMode.CONTINUITY ? this.draw.getCanvasHeight(pageNo) : this.draw.getHeight();
|
|
5897
5901
|
const margins = this.draw.getMargins();
|
|
5898
5902
|
const marginIndicatorSize = this.draw.getMarginIndicatorSize();
|
|
5899
5903
|
ctx.save();
|
|
@@ -6277,7 +6281,7 @@ class PageNumber {
|
|
|
6277
6281
|
render(ctx, pageNo) {
|
|
6278
6282
|
const { pageNumberSize, pageNumberFont, scale, pageMode } = this.options;
|
|
6279
6283
|
const width = this.draw.getWidth();
|
|
6280
|
-
const height = pageMode === PageMode.CONTINUITY ? this.draw.getCanvasHeight() : this.draw.getHeight();
|
|
6284
|
+
const height = pageMode === PageMode.CONTINUITY ? this.draw.getCanvasHeight(pageNo) : this.draw.getHeight();
|
|
6281
6285
|
const pageNumberBottom = this.draw.getPageNumberBottom();
|
|
6282
6286
|
ctx.save();
|
|
6283
6287
|
ctx.fillStyle = "#00000";
|
|
@@ -7026,8 +7030,7 @@ class SelectControl {
|
|
|
7026
7030
|
return data2;
|
|
7027
7031
|
}
|
|
7028
7032
|
setValue() {
|
|
7029
|
-
|
|
7030
|
-
return range.endIndex;
|
|
7033
|
+
return -1;
|
|
7031
7034
|
}
|
|
7032
7035
|
keydown(evt) {
|
|
7033
7036
|
const elementList = this.control.getElementList();
|
|
@@ -7326,6 +7329,16 @@ class Control {
|
|
|
7326
7329
|
}
|
|
7327
7330
|
return false;
|
|
7328
7331
|
}
|
|
7332
|
+
isRangInPostfix() {
|
|
7333
|
+
if (!this.activeControl)
|
|
7334
|
+
return false;
|
|
7335
|
+
const { startIndex, endIndex } = this.getRange();
|
|
7336
|
+
if (startIndex !== endIndex)
|
|
7337
|
+
return false;
|
|
7338
|
+
const elementList = this.getElementList();
|
|
7339
|
+
const element = elementList[startIndex];
|
|
7340
|
+
return element.controlComponent === ControlComponent.POSTFIX;
|
|
7341
|
+
}
|
|
7329
7342
|
getContainer() {
|
|
7330
7343
|
return this.draw.getContainer();
|
|
7331
7344
|
}
|
|
@@ -8911,12 +8924,12 @@ class Draw {
|
|
|
8911
8924
|
getHeight() {
|
|
8912
8925
|
return Math.floor(this.options.height * this.options.scale);
|
|
8913
8926
|
}
|
|
8914
|
-
getCanvasWidth() {
|
|
8915
|
-
const page = this.getPage();
|
|
8927
|
+
getCanvasWidth(pageNo = -1) {
|
|
8928
|
+
const page = this.getPage(pageNo);
|
|
8916
8929
|
return page.width;
|
|
8917
8930
|
}
|
|
8918
|
-
getCanvasHeight() {
|
|
8919
|
-
const page = this.getPage();
|
|
8931
|
+
getCanvasHeight(pageNo = -1) {
|
|
8932
|
+
const page = this.getPage(pageNo);
|
|
8920
8933
|
return page.height;
|
|
8921
8934
|
}
|
|
8922
8935
|
getInnerWidth() {
|
|
@@ -8982,8 +8995,8 @@ class Draw {
|
|
|
8982
8995
|
setPageNo(payload) {
|
|
8983
8996
|
this.pageNo = payload;
|
|
8984
8997
|
}
|
|
8985
|
-
getPage() {
|
|
8986
|
-
return this.pageList[this.pageNo];
|
|
8998
|
+
getPage(pageNo = -1) {
|
|
8999
|
+
return this.pageList[~pageNo ? pageNo : this.pageNo];
|
|
8987
9000
|
}
|
|
8988
9001
|
getPageList() {
|
|
8989
9002
|
return this.pageList;
|
|
@@ -9023,12 +9036,6 @@ class Draw {
|
|
|
9023
9036
|
insertElementList(payload) {
|
|
9024
9037
|
if (!payload.length)
|
|
9025
9038
|
return;
|
|
9026
|
-
const activeControl = this.control.getActiveControl();
|
|
9027
|
-
if (activeControl) {
|
|
9028
|
-
const element = activeControl.getElement();
|
|
9029
|
-
if (element.controlComponent !== ControlComponent.POSTFIX)
|
|
9030
|
-
return;
|
|
9031
|
-
}
|
|
9032
9039
|
const isPartRangeInControlOutside = this.control.isPartRangeInControlOutside();
|
|
9033
9040
|
if (isPartRangeInControlOutside)
|
|
9034
9041
|
return;
|
|
@@ -9039,27 +9046,35 @@ class Draw {
|
|
|
9039
9046
|
isHandleFirstElement: false,
|
|
9040
9047
|
editorOptions: this.options
|
|
9041
9048
|
});
|
|
9042
|
-
|
|
9043
|
-
const
|
|
9044
|
-
|
|
9045
|
-
|
|
9046
|
-
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9049
|
+
let curIndex = -1;
|
|
9050
|
+
const activeControl = this.control.getActiveControl();
|
|
9051
|
+
if (activeControl && !this.control.isRangInPostfix()) {
|
|
9052
|
+
curIndex = activeControl.setValue(payload);
|
|
9053
|
+
} else {
|
|
9054
|
+
const elementList = this.getElementList();
|
|
9055
|
+
const isCollapsed = startIndex === endIndex;
|
|
9056
|
+
const start = startIndex + 1;
|
|
9057
|
+
if (!isCollapsed) {
|
|
9058
|
+
elementList.splice(start, endIndex - startIndex);
|
|
9059
|
+
}
|
|
9060
|
+
const positionContext = this.position.getPositionContext();
|
|
9061
|
+
for (let i = 0; i < payload.length; i++) {
|
|
9062
|
+
const element = payload[i];
|
|
9063
|
+
if (positionContext.isTable) {
|
|
9064
|
+
element.tdId = positionContext.tdId;
|
|
9065
|
+
element.trId = positionContext.trId;
|
|
9066
|
+
element.tableId = positionContext.tableId;
|
|
9067
|
+
}
|
|
9068
|
+
elementList.splice(start + i, 0, element);
|
|
9055
9069
|
}
|
|
9056
|
-
|
|
9070
|
+
curIndex = startIndex + payload.length;
|
|
9071
|
+
}
|
|
9072
|
+
if (~curIndex) {
|
|
9073
|
+
this.range.setRange(curIndex, curIndex);
|
|
9074
|
+
this.render({
|
|
9075
|
+
curIndex
|
|
9076
|
+
});
|
|
9057
9077
|
}
|
|
9058
|
-
const curIndex = startIndex + payload.length;
|
|
9059
|
-
this.range.setRange(curIndex, curIndex);
|
|
9060
|
-
this.render({
|
|
9061
|
-
curIndex
|
|
9062
|
-
});
|
|
9063
9078
|
}
|
|
9064
9079
|
getOriginalElementList() {
|
|
9065
9080
|
return this.elementList;
|
|
@@ -9145,6 +9160,7 @@ class Draw {
|
|
|
9145
9160
|
const canvas = this.pageList[0];
|
|
9146
9161
|
canvas.style.height = `${height}px`;
|
|
9147
9162
|
canvas.height = height * dpr;
|
|
9163
|
+
this.ctxList[0].scale(dpr, dpr);
|
|
9148
9164
|
}
|
|
9149
9165
|
this.render({
|
|
9150
9166
|
isSubmitHistory: false,
|
|
@@ -9514,6 +9530,7 @@ class Draw {
|
|
|
9514
9530
|
pageDom.style.height = `${reduceHeight}px`;
|
|
9515
9531
|
pageDom.height = reduceHeight * dpr;
|
|
9516
9532
|
}
|
|
9533
|
+
this.ctxList[0].scale(dpr, dpr);
|
|
9517
9534
|
} else {
|
|
9518
9535
|
for (let i = 0; i < this.rowList.length; i++) {
|
|
9519
9536
|
const row = this.rowList[i];
|
|
@@ -9681,7 +9698,7 @@ class Draw {
|
|
|
9681
9698
|
const ctx = this.ctxList[pageNo];
|
|
9682
9699
|
this._clearPage(pageNo);
|
|
9683
9700
|
this.background.render(ctx);
|
|
9684
|
-
this.margin.render(ctx);
|
|
9701
|
+
this.margin.render(ctx, pageNo);
|
|
9685
9702
|
const index2 = rowList[0].startIndex;
|
|
9686
9703
|
this._drawRow(ctx, {
|
|
9687
9704
|
positionList,
|
|
@@ -9723,6 +9740,7 @@ class Draw {
|
|
|
9723
9740
|
}
|
|
9724
9741
|
render(payload) {
|
|
9725
9742
|
var _a;
|
|
9743
|
+
const { pageMode } = this.options;
|
|
9726
9744
|
const { isSubmitHistory = true, isSetCursor = true, isCompute = true, isLazy = true } = payload || {};
|
|
9727
9745
|
let { curIndex } = payload || {};
|
|
9728
9746
|
const innerWidth = this.getInnerWidth();
|
|
@@ -9750,7 +9768,7 @@ class Draw {
|
|
|
9750
9768
|
this.ctxList.splice(curPageCount, deleteCount);
|
|
9751
9769
|
this.pageList.splice(curPageCount, deleteCount).forEach((page) => page.remove());
|
|
9752
9770
|
}
|
|
9753
|
-
if (isLazy) {
|
|
9771
|
+
if (isLazy && pageMode === PageMode.PAGING) {
|
|
9754
9772
|
this._lazyRender();
|
|
9755
9773
|
} else {
|
|
9756
9774
|
this._immediateRender();
|