@hufe921/canvas-editor 0.9.99 → 0.9.100

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 CHANGED
@@ -1,3 +1,21 @@
1
+ ## [0.9.100](https://github.com/Hufe921/canvas-editor/compare/v0.9.99...v0.9.100) (2025-01-03)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * get or update elements within a table by id #951 ([951de97](https://github.com/Hufe921/canvas-editor/commit/951de9794186cb6225e1f668f1021f6e7f04b1bc)), closes [#951](https://github.com/Hufe921/canvas-editor/issues/951)
7
+ * set default style boundary error #942 ([2fd9d10](https://github.com/Hufe921/canvas-editor/commit/2fd9d10c10705df57fbc67455edb8da05df92d0a)), closes [#942](https://github.com/Hufe921/canvas-editor/issues/942)
8
+
9
+
10
+ ### Features
11
+
12
+ * add table tool disabled option #954 ([a6eccc7](https://github.com/Hufe921/canvas-editor/commit/a6eccc7a78569e881d80c745f8a77455b91df0ad)), closes [#954](https://github.com/Hufe921/canvas-editor/issues/954)
13
+ * adjust watermark rendering layer #948 ([0f53552](https://github.com/Hufe921/canvas-editor/commit/0f5355216c1c092ea59ecb737f447c0a0ff11558)), closes [#948](https://github.com/Hufe921/canvas-editor/issues/948)
14
+ * optimize cursor focus in readonly mode #936 ([2e0ac96](https://github.com/Hufe921/canvas-editor/commit/2e0ac966e839a2dc9df911b04d24577c46d930e4)), closes [#936](https://github.com/Hufe921/canvas-editor/issues/936)
15
+ * preserve cell content when merging cells #932 ([167bfa1](https://github.com/Hufe921/canvas-editor/commit/167bfa1e7c44a580f29c06bccd9bf5675e4d166f)), closes [#932](https://github.com/Hufe921/canvas-editor/issues/932)
16
+
17
+
18
+
1
19
  ## [0.9.99](https://github.com/Hufe921/canvas-editor/compare/v0.9.98...v0.9.99) (2024-12-20)
2
20
 
3
21
 
@@ -23,7 +23,7 @@ var __publicField = (obj, key, value) => {
23
23
  return value;
24
24
  };
25
25
  var index = "";
26
- const version = "0.9.99";
26
+ const version = "0.9.100";
27
27
  var MaxHeightRatio;
28
28
  (function(MaxHeightRatio2) {
29
29
  MaxHeightRatio2["HALF"] = "half";
@@ -412,6 +412,9 @@ var MoveDirection;
412
412
  MoveDirection2["LEFT"] = "left";
413
413
  MoveDirection2["RIGHT"] = "right";
414
414
  })(MoveDirection || (MoveDirection = {}));
415
+ const isApple = typeof navigator !== "undefined" && /Mac OS X/.test(navigator.userAgent);
416
+ const isIOS = typeof navigator !== "undefined" && /iPad|iPhone/.test(navigator.userAgent);
417
+ const isMobile = /Mobile|Android|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
415
418
  var ElementType;
416
419
  (function(ElementType2) {
417
420
  ElementType2["TEXT"] = "text";
@@ -5747,6 +5750,8 @@ class Cursor {
5747
5750
  }
5748
5751
  }
5749
5752
  focus() {
5753
+ if (isMobile && this.draw.isReadonly())
5754
+ return;
5750
5755
  const agentCursorDom = this.cursorAgent.getAgentCursorDom();
5751
5756
  if (document.activeElement !== agentCursorDom) {
5752
5757
  agentCursorDom.focus();
@@ -5845,8 +5850,6 @@ var MouseEventButton;
5845
5850
  MouseEventButton2[MouseEventButton2["CENTER"] = 1] = "CENTER";
5846
5851
  MouseEventButton2[MouseEventButton2["RIGHT"] = 2] = "RIGHT";
5847
5852
  })(MouseEventButton || (MouseEventButton = {}));
5848
- const isApple = typeof navigator !== "undefined" && /Mac OS X/.test(navigator.userAgent);
5849
- const isIOS = typeof navigator !== "undefined" && /iPad|iPhone/.test(navigator.userAgent);
5850
5853
  function isMod(evt) {
5851
5854
  return isApple ? evt.metaKey : evt.ctrlKey;
5852
5855
  }
@@ -7391,7 +7394,7 @@ function keydown(evt, host) {
7391
7394
  }
7392
7395
  }
7393
7396
  function input(data2, host) {
7394
- var _a;
7397
+ var _a, _b;
7395
7398
  const draw = host.getDraw();
7396
7399
  if (draw.isReadonly() || draw.isDisabled())
7397
7400
  return;
@@ -7405,6 +7408,7 @@ function input(data2, host) {
7405
7408
  const rangeManager = draw.getRange();
7406
7409
  if (!rangeManager.getIsCanInput())
7407
7410
  return;
7411
+ const defaultStyle = rangeManager.getDefaultStyle() || ((_b = host.compositionInfo) == null ? void 0 : _b.defaultStyle) || null;
7408
7412
  removeComposingInput(host);
7409
7413
  if (!isComposing) {
7410
7414
  const cursor = draw.getCursor();
@@ -7420,11 +7424,11 @@ function input(data2, host) {
7420
7424
  return;
7421
7425
  const isDesignMode = draw.isDesignMode();
7422
7426
  const inputData = splitText(text).map((value) => {
7423
- var _a2, _b;
7427
+ var _a2, _b2;
7424
7428
  const newElement = {
7425
7429
  value
7426
7430
  };
7427
- if (isDesignMode || !((_a2 = copyElement.title) == null ? void 0 : _a2.disabled) && !((_b = copyElement.control) == null ? void 0 : _b.disabled)) {
7431
+ if (isDesignMode || !((_a2 = copyElement.title) == null ? void 0 : _a2.disabled) && !((_b2 = copyElement.control) == null ? void 0 : _b2.disabled)) {
7428
7432
  const nextElement = elementList[endIndex + 1];
7429
7433
  if (!copyElement.type || copyElement.type === TEXT || copyElement.type === HYPERLINK && (nextElement == null ? void 0 : nextElement.type) === HYPERLINK || copyElement.type === DATE && (nextElement == null ? void 0 : nextElement.type) === DATE || copyElement.type === SUBSCRIPT && (nextElement == null ? void 0 : nextElement.type) === SUBSCRIPT || copyElement.type === SUPERSCRIPT && (nextElement == null ? void 0 : nextElement.type) === SUPERSCRIPT) {
7430
7434
  EDITOR_ELEMENT_COPY_ATTR.forEach((attr) => {
@@ -7436,6 +7440,14 @@ function input(data2, host) {
7436
7440
  }
7437
7441
  });
7438
7442
  }
7443
+ if (defaultStyle) {
7444
+ EDITOR_ELEMENT_STYLE_ATTR.forEach((attr) => {
7445
+ const value2 = defaultStyle[attr];
7446
+ if (value2 !== void 0) {
7447
+ newElement[attr] = value2;
7448
+ }
7449
+ });
7450
+ }
7439
7451
  if (isComposing) {
7440
7452
  newElement.underline = true;
7441
7453
  }
@@ -7469,7 +7481,8 @@ function input(data2, host) {
7469
7481
  elementList,
7470
7482
  value: text,
7471
7483
  startIndex: curIndex - inputData.length,
7472
- endIndex: curIndex
7484
+ endIndex: curIndex,
7485
+ defaultStyle
7473
7486
  };
7474
7487
  }
7475
7488
  }
@@ -10559,10 +10572,12 @@ class TableTool {
10559
10572
  if (!isTable)
10560
10573
  return;
10561
10574
  this.dispose();
10562
- const { scale } = this.options;
10563
10575
  const elementList = this.draw.getOriginalElementList();
10564
10576
  const positionList = this.position.getOriginalPositionList();
10565
10577
  const element = elementList[index2];
10578
+ if (element.tableToolDisabled && !this.draw.isDesignMode())
10579
+ return;
10580
+ const { scale } = this.options;
10566
10581
  const position = positionList[index2];
10567
10582
  const { colgroup, trList } = element;
10568
10583
  const { coordinate: { leftTop } } = position;
@@ -16233,6 +16248,7 @@ class TableOperate {
16233
16248
  }
16234
16249
  const mergeTdIdList = [];
16235
16250
  const anchorTd = rowCol[0][0];
16251
+ const anchorElement = anchorTd.value[0];
16236
16252
  for (let t = 0; t < rowCol.length; t++) {
16237
16253
  const tr = rowCol[t];
16238
16254
  for (let d = 0; d < tr.length; d++) {
@@ -16240,6 +16256,11 @@ class TableOperate {
16240
16256
  const isAnchorTd = t === 0 && d === 0;
16241
16257
  if (!isAnchorTd) {
16242
16258
  mergeTdIdList.push(td.id);
16259
+ for (let d2 = 0; d2 < td.value.length; d2++) {
16260
+ const tdElement = td.value[d2];
16261
+ cloneProperty(TABLE_CONTEXT_ATTR, anchorElement, tdElement);
16262
+ anchorTd.value.push(tdElement);
16263
+ }
16243
16264
  }
16244
16265
  if (t === 0 && d !== 0) {
16245
16266
  anchorTd.colspan += td.colspan;
@@ -18436,6 +18457,9 @@ class Draw {
18436
18457
  if (!isPrintMode) {
18437
18458
  this.area.render(ctx, pageNo);
18438
18459
  }
18460
+ if (pageMode !== PageMode.CONTINUITY && this.options.watermark.data) {
18461
+ this.waterMark.render(ctx);
18462
+ }
18439
18463
  if (!isPrintMode) {
18440
18464
  this.margin.render(ctx, pageNo);
18441
18465
  }
@@ -18474,9 +18498,6 @@ class Draw {
18474
18498
  if (!isPrintMode && this.search.getSearchKeyword()) {
18475
18499
  this.search.render(ctx, pageNo);
18476
18500
  }
18477
- if (pageMode !== PageMode.CONTINUITY && this.options.watermark.data) {
18478
- this.waterMark.render(ctx);
18479
- }
18480
18501
  if (this.elementList.length <= 1 && !((_b = this.elementList[0]) == null ? void 0 : _b.listId)) {
18481
18502
  this.placeholder.render(ctx);
18482
18503
  }
@@ -20510,35 +20531,51 @@ class CommandAdapt {
20510
20531
  const { id, conceptId } = payload;
20511
20532
  if (!id && !conceptId)
20512
20533
  return;
20513
- function getElementIndexById(elementList) {
20514
- for (let e = 0; e < elementList.length; e++) {
20515
- const element = elementList[e];
20516
- if (id && element.id === id || conceptId && element.conceptId === conceptId) {
20517
- return e;
20534
+ const updateElementInfoList = [];
20535
+ function getElementInfoById(elementList) {
20536
+ let i = 0;
20537
+ while (i < elementList.length) {
20538
+ const element = elementList[i];
20539
+ i++;
20540
+ if (element.type === ElementType.TABLE) {
20541
+ const trList = element.trList;
20542
+ for (let r = 0; r < trList.length; r++) {
20543
+ const tr = trList[r];
20544
+ for (let d = 0; d < tr.tdList.length; d++) {
20545
+ const td = tr.tdList[d];
20546
+ getElementInfoById(td.value);
20547
+ }
20548
+ }
20549
+ }
20550
+ if (id && (element.id === id || element.controlId === id) || conceptId && element.conceptId === conceptId) {
20551
+ updateElementInfoList.push({
20552
+ elementList,
20553
+ index: i - 1
20554
+ });
20518
20555
  }
20519
20556
  }
20520
- return -1;
20521
20557
  }
20522
- const getElementListFnList = [
20523
- this.draw.getOriginalMainElementList,
20524
- this.draw.getHeaderElementList,
20525
- this.draw.getFooterElementList
20558
+ const data2 = [
20559
+ this.draw.getOriginalMainElementList(),
20560
+ this.draw.getHeaderElementList(),
20561
+ this.draw.getFooterElementList()
20526
20562
  ];
20527
- for (const getElementList of getElementListFnList) {
20528
- const elementList = getElementList.call(this.draw);
20529
- const elementIndex = getElementIndexById(elementList);
20530
- if (~elementIndex) {
20531
- elementList[elementIndex] = __spreadValues(__spreadValues({}, elementList[elementIndex]), payload.properties);
20532
- formatElementList(zipElementList([elementList[elementIndex]]), {
20533
- isHandleFirstElement: false,
20534
- editorOptions: this.options
20535
- });
20536
- this.draw.render({
20537
- isSetCursor: false
20538
- });
20539
- break;
20540
- }
20563
+ for (const elementList of data2) {
20564
+ getElementInfoById(elementList);
20541
20565
  }
20566
+ if (!updateElementInfoList.length)
20567
+ return;
20568
+ for (let i = 0; i < updateElementInfoList.length; i++) {
20569
+ const { elementList, index: index2 } = updateElementInfoList[i];
20570
+ elementList[index2] = __spreadValues(__spreadValues({}, elementList[index2]), payload.properties);
20571
+ formatElementList(zipElementList([elementList[index2]]), {
20572
+ isHandleFirstElement: false,
20573
+ editorOptions: this.options
20574
+ });
20575
+ }
20576
+ this.draw.render({
20577
+ isSetCursor: false
20578
+ });
20542
20579
  }
20543
20580
  getElementById(payload) {
20544
20581
  const { id, conceptId } = payload;
@@ -20550,7 +20587,17 @@ class CommandAdapt {
20550
20587
  while (i < elementList.length) {
20551
20588
  const element = elementList[i];
20552
20589
  i++;
20553
- if (id && element.controlId !== id || conceptId && element.conceptId !== conceptId) {
20590
+ if (element.type === ElementType.TABLE) {
20591
+ const trList = element.trList;
20592
+ for (let r = 0; r < trList.length; r++) {
20593
+ const tr = trList[r];
20594
+ for (let d = 0; d < tr.tdList.length; d++) {
20595
+ const td = tr.tdList[d];
20596
+ getElement(td.value);
20597
+ }
20598
+ }
20599
+ }
20600
+ if (id && element.controlId !== id && element.id !== id || conceptId && element.conceptId !== conceptId) {
20554
20601
  continue;
20555
20602
  }
20556
20603
  result.push(element);