@hufe921/canvas-editor 0.9.104 → 0.9.105
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 +19 -0
- package/dist/canvas-editor.es.js +83 -23
- package/dist/canvas-editor.es.js.map +1 -1
- package/dist/canvas-editor.umd.js +23 -23
- 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 +2 -0
- package/dist/src/editor/core/draw/particle/previewer/Previewer.d.ts +1 -0
- package/dist/src/editor/core/range/RangeManager.d.ts +1 -0
- package/dist/src/editor/interface/Element.d.ts +5 -0
- package/dist/src/editor/interface/EventBus.d.ts +2 -1
- package/dist/src/editor/interface/Listener.d.ts +4 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## [0.9.105](https://github.com/Hufe921/canvas-editor/compare/v0.9.104...v0.9.105) (2025-03-15)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* delete hidden control boundary error #1036 ([960e918](https://github.com/Hufe921/canvas-editor/commit/960e91841f4b8a6c8a176f3f09f8cb2d3f1fccee)), closes [#1036](https://github.com/Hufe921/canvas-editor/issues/1036)
|
|
7
|
+
* initial print mode settings invalid #1034 ([6d95284](https://github.com/Hufe921/canvas-editor/commit/6d95284609edf855b8bd049fff15816cb2710cd1)), closes [#1034](https://github.com/Hufe921/canvas-editor/issues/1034)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Features
|
|
11
|
+
|
|
12
|
+
* add border width to table option #897 ([17550b9](https://github.com/Hufe921/canvas-editor/commit/17550b98b4798e6887c7320d7125d54287b92bcf)), closes [#897](https://github.com/Hufe921/canvas-editor/issues/897)
|
|
13
|
+
* add imageSizeChange event #1035 ([f93f3a7](https://github.com/Hufe921/canvas-editor/commit/f93f3a73be31aaf8c569869928970a4787ca7244)), closes [#1035](https://github.com/Hufe921/canvas-editor/issues/1035)
|
|
14
|
+
* add isReplace option to executeInsertElementList api #1031 ([076302a](https://github.com/Hufe921/canvas-editor/commit/076302a9192cff9990a8d5f76672d16e32151f33)), closes [#1031](https://github.com/Hufe921/canvas-editor/issues/1031)
|
|
15
|
+
* add table external border width option #897 ([9df856f](https://github.com/Hufe921/canvas-editor/commit/9df856f61272098d5a004bb2df7eb07d1f34d078)), closes [#897](https://github.com/Hufe921/canvas-editor/issues/897)
|
|
16
|
+
* update cursor on right-click #1022 ([edd5df3](https://github.com/Hufe921/canvas-editor/commit/edd5df3029c3aaa6763bcbe1dc9152c70cf3b330)), closes [#1022](https://github.com/Hufe921/canvas-editor/issues/1022)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
1
20
|
## [0.9.104](https://github.com/Hufe921/canvas-editor/compare/v0.9.103...v0.9.104) (2025-02-22)
|
|
2
21
|
|
|
3
22
|
|
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.105";
|
|
27
27
|
var MaxHeightRatio;
|
|
28
28
|
(function(MaxHeightRatio2) {
|
|
29
29
|
MaxHeightRatio2["HALF"] = "half";
|
|
@@ -6265,14 +6265,15 @@ function hitRadio(element, draw) {
|
|
|
6265
6265
|
}
|
|
6266
6266
|
function mousedown(evt, host) {
|
|
6267
6267
|
var _a, _b;
|
|
6268
|
-
if (evt.button === MouseEventButton.RIGHT)
|
|
6269
|
-
return;
|
|
6270
6268
|
const draw = host.getDraw();
|
|
6271
6269
|
const isReadonly = draw.isReadonly();
|
|
6272
6270
|
const rangeManager = draw.getRange();
|
|
6273
6271
|
const position = draw.getPosition();
|
|
6272
|
+
const range = rangeManager.getRange();
|
|
6273
|
+
if (evt.button === MouseEventButton.RIGHT && (range.isCrossRowCol || !rangeManager.getIsCollapsed())) {
|
|
6274
|
+
return;
|
|
6275
|
+
}
|
|
6274
6276
|
if (!host.isAllowDrag) {
|
|
6275
|
-
const range = rangeManager.getRange();
|
|
6276
6277
|
if (!isReadonly && range.startIndex !== range.endIndex) {
|
|
6277
6278
|
const isPointInRange = rangeManager.getIsPointInRange(evt.offsetX, evt.offsetY);
|
|
6278
6279
|
if (isPointInRange) {
|
|
@@ -9275,6 +9276,14 @@ class RangeManager {
|
|
|
9275
9276
|
replaceRange(range) {
|
|
9276
9277
|
this.setRange(range.startIndex, range.endIndex, range.tableId, range.startTdIndex, range.endTdIndex, range.startTrIndex, range.endTrIndex);
|
|
9277
9278
|
}
|
|
9279
|
+
shrinkRange() {
|
|
9280
|
+
const { startIndex, endIndex } = this.range;
|
|
9281
|
+
if (startIndex === endIndex || !~startIndex && !~endIndex)
|
|
9282
|
+
return;
|
|
9283
|
+
this.replaceRange(__spreadProps(__spreadValues({}, this.range), {
|
|
9284
|
+
startIndex: endIndex
|
|
9285
|
+
}));
|
|
9286
|
+
}
|
|
9278
9287
|
setRangeStyle() {
|
|
9279
9288
|
var _a, _b;
|
|
9280
9289
|
const rangeStyleChangeListener = this.listener.rangeStyleChange;
|
|
@@ -10530,7 +10539,12 @@ class TableParticle {
|
|
|
10530
10539
|
return rowCol.length ? rowCol : null;
|
|
10531
10540
|
}
|
|
10532
10541
|
_drawOuterBorder(payload) {
|
|
10533
|
-
const { ctx, startX, startY, width, height, isDrawFullBorder } = payload;
|
|
10542
|
+
const { ctx, startX, startY, width, height, isDrawFullBorder, borderExternalWidth } = payload;
|
|
10543
|
+
const { scale } = this.options;
|
|
10544
|
+
const lineWidth = ctx.lineWidth;
|
|
10545
|
+
if (borderExternalWidth) {
|
|
10546
|
+
ctx.lineWidth = borderExternalWidth * scale;
|
|
10547
|
+
}
|
|
10534
10548
|
ctx.beginPath();
|
|
10535
10549
|
const x = Math.round(startX);
|
|
10536
10550
|
const y = Math.round(startY);
|
|
@@ -10543,6 +10557,9 @@ class TableParticle {
|
|
|
10543
10557
|
ctx.lineTo(x + width, y);
|
|
10544
10558
|
}
|
|
10545
10559
|
ctx.stroke();
|
|
10560
|
+
if (borderExternalWidth) {
|
|
10561
|
+
ctx.lineWidth = lineWidth;
|
|
10562
|
+
}
|
|
10546
10563
|
ctx.translate(-0.5, -0.5);
|
|
10547
10564
|
}
|
|
10548
10565
|
_drawSlash(ctx, td, startX, startY) {
|
|
@@ -10566,7 +10583,7 @@ class TableParticle {
|
|
|
10566
10583
|
}
|
|
10567
10584
|
_drawBorder(ctx, element, startX, startY) {
|
|
10568
10585
|
var _a, _b, _c, _d, _e, _f;
|
|
10569
|
-
const { colgroup, trList, borderType, borderColor } = element;
|
|
10586
|
+
const { colgroup, trList, borderType, borderColor, borderWidth = 1, borderExternalWidth } = element;
|
|
10570
10587
|
if (!colgroup || !trList)
|
|
10571
10588
|
return;
|
|
10572
10589
|
const { scale, table: { defaultBorderColor } } = this.options;
|
|
@@ -10579,7 +10596,7 @@ class TableParticle {
|
|
|
10579
10596
|
if (borderType === TableBorder.DASH) {
|
|
10580
10597
|
ctx.setLineDash([3, 3]);
|
|
10581
10598
|
}
|
|
10582
|
-
ctx.lineWidth = scale;
|
|
10599
|
+
ctx.lineWidth = borderWidth * scale;
|
|
10583
10600
|
ctx.strokeStyle = borderColor || defaultBorderColor;
|
|
10584
10601
|
if (!isEmptyBorderType && !isInternalBorderType) {
|
|
10585
10602
|
this._drawOuterBorder({
|
|
@@ -10588,6 +10605,7 @@ class TableParticle {
|
|
|
10588
10605
|
startY,
|
|
10589
10606
|
width: tableWidth,
|
|
10590
10607
|
height: tableHeight,
|
|
10608
|
+
borderExternalWidth,
|
|
10591
10609
|
isDrawFullBorder: isExternalBorderType
|
|
10592
10610
|
});
|
|
10593
10611
|
}
|
|
@@ -10631,10 +10649,29 @@ class TableParticle {
|
|
|
10631
10649
|
if (!isInternalBorderType || td.colIndex + td.colspan < colgroup.length) {
|
|
10632
10650
|
ctx.moveTo(x, y);
|
|
10633
10651
|
ctx.lineTo(x, y + height);
|
|
10652
|
+
if (borderExternalWidth && borderExternalWidth !== borderWidth && td.colIndex + td.colspan === colgroup.length) {
|
|
10653
|
+
const lineWidth = ctx.lineWidth;
|
|
10654
|
+
ctx.lineWidth = borderExternalWidth * scale;
|
|
10655
|
+
ctx.stroke();
|
|
10656
|
+
ctx.beginPath();
|
|
10657
|
+
ctx.lineWidth = lineWidth;
|
|
10658
|
+
}
|
|
10634
10659
|
}
|
|
10635
10660
|
if (!isInternalBorderType || td.rowIndex + td.rowspan < trList.length) {
|
|
10661
|
+
const isSetExternalBottomBorder = borderExternalWidth && borderExternalWidth !== borderWidth && td.rowIndex + td.rowspan === trList.length;
|
|
10662
|
+
if (isSetExternalBottomBorder) {
|
|
10663
|
+
ctx.stroke();
|
|
10664
|
+
ctx.beginPath();
|
|
10665
|
+
}
|
|
10636
10666
|
ctx.moveTo(x, y + height);
|
|
10637
10667
|
ctx.lineTo(x - width, y + height);
|
|
10668
|
+
if (isSetExternalBottomBorder) {
|
|
10669
|
+
const lineWidth = ctx.lineWidth;
|
|
10670
|
+
ctx.lineWidth = borderExternalWidth * scale;
|
|
10671
|
+
ctx.stroke();
|
|
10672
|
+
ctx.beginPath();
|
|
10673
|
+
ctx.lineWidth = lineWidth;
|
|
10674
|
+
}
|
|
10638
10675
|
}
|
|
10639
10676
|
ctx.stroke();
|
|
10640
10677
|
}
|
|
@@ -13407,9 +13444,10 @@ class Control {
|
|
|
13407
13444
|
};
|
|
13408
13445
|
}
|
|
13409
13446
|
removeControl(startIndex, context = {}) {
|
|
13447
|
+
var _a;
|
|
13410
13448
|
const elementList = context.elementList || this.getElementList();
|
|
13411
13449
|
const startElement = elementList[startIndex];
|
|
13412
|
-
if (!this.draw.isDesignMode()) {
|
|
13450
|
+
if (!this.draw.isDesignMode() && !((_a = startElement == null ? void 0 : startElement.control) == null ? void 0 : _a.hide)) {
|
|
13413
13451
|
const { deletable = true } = startElement.control;
|
|
13414
13452
|
if (!deletable)
|
|
13415
13453
|
return null;
|
|
@@ -14430,6 +14468,7 @@ class Previewer {
|
|
|
14430
14468
|
__publicField(this, "curElementSrc");
|
|
14431
14469
|
__publicField(this, "previewerDrawOption");
|
|
14432
14470
|
__publicField(this, "curPosition");
|
|
14471
|
+
__publicField(this, "eventBus");
|
|
14433
14472
|
__publicField(this, "resizerSelection");
|
|
14434
14473
|
__publicField(this, "resizerHandleList");
|
|
14435
14474
|
__publicField(this, "resizerImageContainer");
|
|
@@ -14456,6 +14495,7 @@ class Previewer {
|
|
|
14456
14495
|
this.curElementSrc = "";
|
|
14457
14496
|
this.previewerDrawOption = {};
|
|
14458
14497
|
this.curPosition = null;
|
|
14498
|
+
this.eventBus = draw.getEventBus();
|
|
14459
14499
|
const { resizerSelection, resizerHandleList, resizerImageContainer, resizerImage, resizerSize } = this._createResizerDom();
|
|
14460
14500
|
this.resizerSelection = resizerSelection;
|
|
14461
14501
|
this.resizerHandleList = resizerHandleList;
|
|
@@ -14631,6 +14671,11 @@ class Previewer {
|
|
|
14631
14671
|
this._updateResizerRect(elementWidth, elementHeight);
|
|
14632
14672
|
this._updateResizerSizeView(elementWidth, elementHeight);
|
|
14633
14673
|
evt.preventDefault();
|
|
14674
|
+
if (this.eventBus.isSubscribe("imageSizeChange")) {
|
|
14675
|
+
this.eventBus.emit("imageSizeChange", {
|
|
14676
|
+
element: this.curElement
|
|
14677
|
+
});
|
|
14678
|
+
}
|
|
14634
14679
|
}
|
|
14635
14680
|
_drawPreviewer() {
|
|
14636
14681
|
const previewerContainer = document.createElement("div");
|
|
@@ -17416,12 +17461,34 @@ class Draw {
|
|
|
17416
17461
|
this.intersectionPageNo = 0;
|
|
17417
17462
|
this.lazyRenderIntersectionObserver = null;
|
|
17418
17463
|
this.printModeData = null;
|
|
17464
|
+
if (this.mode === EditorMode.PRINT) {
|
|
17465
|
+
this.setPrintData();
|
|
17466
|
+
}
|
|
17419
17467
|
this.render({
|
|
17420
17468
|
isInit: true,
|
|
17421
17469
|
isSetCursor: false,
|
|
17422
17470
|
isFirstRender: true
|
|
17423
17471
|
});
|
|
17424
17472
|
}
|
|
17473
|
+
setPrintData() {
|
|
17474
|
+
this.printModeData = {
|
|
17475
|
+
header: this.header.getElementList(),
|
|
17476
|
+
main: this.elementList,
|
|
17477
|
+
footer: this.footer.getElementList()
|
|
17478
|
+
};
|
|
17479
|
+
const clonePrintModeData = deepClone(this.printModeData);
|
|
17480
|
+
const editorDataKeys = ["header", "main", "footer"];
|
|
17481
|
+
editorDataKeys.forEach((key) => {
|
|
17482
|
+
clonePrintModeData[key] = this.control.filterAssistElement(clonePrintModeData[key]);
|
|
17483
|
+
});
|
|
17484
|
+
this.setEditorData(clonePrintModeData);
|
|
17485
|
+
}
|
|
17486
|
+
clearPrintData() {
|
|
17487
|
+
if (this.printModeData) {
|
|
17488
|
+
this.setEditorData(this.printModeData);
|
|
17489
|
+
this.printModeData = null;
|
|
17490
|
+
}
|
|
17491
|
+
}
|
|
17425
17492
|
getLetterReg() {
|
|
17426
17493
|
return this.LETTER_REG;
|
|
17427
17494
|
}
|
|
@@ -17432,21 +17499,10 @@ class Draw {
|
|
|
17432
17499
|
if (this.mode === payload)
|
|
17433
17500
|
return;
|
|
17434
17501
|
if (payload === EditorMode.PRINT) {
|
|
17435
|
-
this.
|
|
17436
|
-
header: this.header.getElementList(),
|
|
17437
|
-
main: this.elementList,
|
|
17438
|
-
footer: this.footer.getElementList()
|
|
17439
|
-
};
|
|
17440
|
-
const clonePrintModeData = deepClone(this.printModeData);
|
|
17441
|
-
const editorDataKeys = ["header", "main", "footer"];
|
|
17442
|
-
editorDataKeys.forEach((key) => {
|
|
17443
|
-
clonePrintModeData[key] = this.control.filterAssistElement(clonePrintModeData[key]);
|
|
17444
|
-
});
|
|
17445
|
-
this.setEditorData(clonePrintModeData);
|
|
17502
|
+
this.setPrintData();
|
|
17446
17503
|
}
|
|
17447
|
-
if (this.mode === EditorMode.PRINT
|
|
17448
|
-
this.
|
|
17449
|
-
this.printModeData = null;
|
|
17504
|
+
if (this.mode === EditorMode.PRINT) {
|
|
17505
|
+
this.clearPrintData();
|
|
17450
17506
|
}
|
|
17451
17507
|
this.clearSideEffect();
|
|
17452
17508
|
this.range.clearRange();
|
|
@@ -20963,12 +21019,16 @@ class CommandAdapt {
|
|
|
20963
21019
|
isSubmitHistory: false
|
|
20964
21020
|
});
|
|
20965
21021
|
}
|
|
20966
|
-
insertElementList(payload) {
|
|
21022
|
+
insertElementList(payload, options = {}) {
|
|
20967
21023
|
if (!payload.length)
|
|
20968
21024
|
return;
|
|
20969
21025
|
const isDisabled = this.draw.isReadonly() || this.draw.isDisabled();
|
|
20970
21026
|
if (isDisabled)
|
|
20971
21027
|
return;
|
|
21028
|
+
const { isReplace = true } = options;
|
|
21029
|
+
if (!isReplace) {
|
|
21030
|
+
this.range.shrinkRange();
|
|
21031
|
+
}
|
|
20972
21032
|
const cloneElementList = deepClone(payload);
|
|
20973
21033
|
const { startIndex } = this.range.getRange();
|
|
20974
21034
|
const elementList = this.draw.getElementList();
|