@ones-editor/editor 2.8.13 → 2.8.14-beta.2

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/index.js CHANGED
@@ -12978,7 +12978,7 @@ var __publicField = (obj, key, value) => {
12978
12978
  }
12979
12979
  return {};
12980
12980
  }
12981
- function getOptions$9(editor) {
12981
+ function getOptions$a(editor) {
12982
12982
  const commandMap = /* @__PURE__ */ new Map();
12983
12983
  const insertBlockCommandItems = [];
12984
12984
  editor.editorEmbeds.forEach((embedClass) => {
@@ -13071,7 +13071,7 @@ var __publicField = (obj, key, value) => {
13071
13071
  convertFrom: convertFrom$9,
13072
13072
  convertTo: convertTo$l,
13073
13073
  getBlockProperties: getBlockProperties$c,
13074
- getOptions: getOptions$9,
13074
+ getOptions: getOptions$a,
13075
13075
  handleDeleteBlock: handleDeleteBlock$9,
13076
13076
  handleUpdateBlock: handleUpdateBlock$6,
13077
13077
  handleDropOver: handleDropOver$2,
@@ -40623,6 +40623,7 @@ ${codeText}
40623
40623
  const TabIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M14 2L2 2" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M14 6H7" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M2 10.5V5.5L5.5 8L2 10.5Z" fill="#2D2D2E"/>\n<path d="M14 10H7" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M14 14H2" stroke="#2D2D2E" stroke-linejoin="round"/>\n</svg>\n';
40624
40624
  const ShiftTabIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M2 2H14" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M7 6H14" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M5.5 10.5V5.5L2 8L5.5 10.5Z" fill="#2D2D2E"/>\n<path d="M7 10H14" stroke="#2D2D2E" stroke-linejoin="round"/>\n<path d="M2 14H14" stroke="#2D2D2E" stroke-linejoin="round"/>\n</svg>\n';
40625
40625
  const TableEditIcon = '<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M8 14.5H2.5C1.94772 14.5 1.5 14.0523 1.5 13.5V2.5C1.5 1.94772 1.94772 1.5 2.5 1.5H13.5C14.0523 1.5 14.5 1.94772 14.5 2.5V8" stroke="#2D2D2E"/>\n<path d="M1.6 4.8H14.4" stroke="#2D2D2E"/>\n<path d="M1.6 9.6H8.00078" stroke="#2D2D2E"/>\n<path d="M5.6 1.6L5.6 14.4" stroke="#2D2D2E"/>\n<path fill-rule="evenodd" clip-rule="evenodd" d="M11.5043 8.98727L11.6789 8.22924C11.7097 8.09564 11.8387 8 11.9881 8H12.8119C12.9613 8 13.0903 8.09564 13.1211 8.22924L13.2957 8.98727C13.3177 9.08256 13.3912 9.16027 13.488 9.20102C13.569 9.23514 13.648 9.2726 13.7248 9.31318C13.8018 9.35372 13.877 9.3976 13.95 9.44477C14.037 9.50098 14.1474 9.52034 14.2487 9.49008L15.0543 9.24927C15.1963 9.20683 15.3514 9.26108 15.4261 9.37933L15.9576 10.2206C16.0323 10.3389 16.0062 10.4888 15.895 10.5799L15.2639 11.0972C15.1846 11.1622 15.1477 11.2593 15.1575 11.3562C15.1657 11.4375 15.1698 11.5189 15.1697 11.6C15.1698 11.6811 15.1658 11.7625 15.1576 11.8438C15.1478 11.9407 15.1847 12.0378 15.264 12.1028L15.895 12.62C16.0062 12.7112 16.0324 12.8611 15.9577 12.9793L15.4262 13.8206C15.3515 13.9389 15.1963 13.9931 15.0544 13.9507L14.2487 13.7099C14.1474 13.6796 14.037 13.699 13.95 13.7552C13.877 13.8024 13.8018 13.8463 13.7248 13.8868C13.648 13.9274 13.569 13.9649 13.488 13.999C13.3912 14.0397 13.3177 14.1174 13.2957 14.2127L13.1211 14.9708C13.0903 15.1044 12.9613 15.2 12.8119 15.2H11.9881C11.8387 15.2 11.7097 15.1044 11.6789 14.9708L11.5043 14.2127C11.4823 14.1174 11.4088 14.0397 11.312 13.999C11.231 13.9649 11.152 13.9274 11.0752 13.8868C10.9982 13.8463 10.923 13.8024 10.85 13.7552C10.763 13.699 10.6526 13.6796 10.5513 13.7099L9.74565 13.9507C9.60366 13.9931 9.44854 13.9389 9.37384 13.8206L8.84234 12.9793C8.76764 12.8611 8.79378 12.7112 8.905 12.62L9.53602 12.1028C9.61534 12.0378 9.6522 11.9407 9.64243 11.8438C9.63424 11.7625 9.63023 11.6811 9.63031 11.6C9.63023 11.5189 9.63426 11.4375 9.64247 11.3562C9.65226 11.2593 9.61539 11.1622 9.53607 11.0972L8.90506 10.5799C8.79384 10.4888 8.7677 10.3389 8.8424 10.2206L9.3739 9.37933C9.4486 9.26108 9.60371 9.20683 9.74571 9.24927L10.5514 9.49008C10.6526 9.52034 10.7631 9.50098 10.8501 9.44477C10.923 9.3976 10.9982 9.35372 11.0752 9.31318C11.152 9.2726 11.231 9.23514 11.312 9.20102C11.4088 9.16027 11.4823 9.08256 11.5043 8.98727ZM12.3278 12.5136C12.8866 12.5136 13.3396 12.0996 13.3396 11.5889C13.3396 11.0783 12.8866 10.6643 12.3278 10.6643C11.769 10.6643 11.316 11.0783 11.316 11.5889C11.316 12.0996 11.769 12.5136 12.3278 12.5136Z" fill="#2D2D2E"/>\n</svg>\n';
40626
+ const AdjustWidthIcon = '<svg width="15" height="15" viewBox="0 0 15 15" fill="none" xmlns="http://www.w3.org/2000/svg">\n<path d="M7.10156 13.7031V1.625H8.17188V13.7031H7.10156ZM3.14844 14.4297C2.39323 14.4297 1.82552 14.2422 1.44531 13.8672C1.07031 13.4974 0.882812 12.9401 0.882812 12.1953V3.16406C0.882812 2.41927 1.07031 1.86198 1.44531 1.49219C1.82552 1.11719 2.39323 0.929688 3.14844 0.929688H12.1328C12.888 0.929688 13.4531 1.11719 13.8281 1.49219C14.2031 1.86719 14.3906 2.42448 14.3906 3.16406V12.1953C14.3906 12.9349 14.2031 13.4922 13.8281 13.8672C13.4531 14.2422 12.888 14.4297 12.1328 14.4297H3.14844ZM3.16406 13.3516H12.1172C12.4974 13.3516 12.7917 13.25 13 13.0469C13.2083 12.8438 13.3125 12.5417 13.3125 12.1406V3.21875C13.3125 2.81771 13.2083 2.51562 13 2.3125C12.7917 2.10938 12.4974 2.00781 12.1172 2.00781H3.16406C2.77865 2.00781 2.48177 2.10938 2.27344 2.3125C2.07031 2.51562 1.96875 2.81771 1.96875 3.21875V12.1406C1.96875 12.5417 2.07031 12.8438 2.27344 13.0469C2.48177 13.25 2.77865 13.3516 3.16406 13.3516Z" fill="#2D2D2E"/>\n</svg>\n';
40626
40627
  const index$f = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
40627
40628
  __proto__: null,
40628
40629
  TableEditIcon,
@@ -40750,7 +40751,8 @@ ${codeText}
40750
40751
  SearchIcon,
40751
40752
  CalloutIcon: CalloutIcon$1,
40752
40753
  LoadingCircleIcon,
40753
- TextGroupIcon
40754
+ TextGroupIcon,
40755
+ AdjustWidthIcon
40754
40756
  }, Symbol.toStringTag, { value: "Module" }));
40755
40757
  function createLoading() {
40756
40758
  const loading2 = createElement("span", ["editor-loading-icon"], null);
@@ -44004,6 +44006,9 @@ ${codeText}
44004
44006
  "insert-emoji": {
44005
44007
  shortcut: "/emoji"
44006
44008
  },
44009
+ "insert-toc": {
44010
+ shortcut: "/toc"
44011
+ },
44007
44012
  ...fontShortCuts()
44008
44013
  };
44009
44014
  function getShortcutById(id) {
@@ -46553,6 +46558,91 @@ ${codeText}
46553
46558
  editor.deleteChildContainers(deletedContainers);
46554
46559
  });
46555
46560
  }
46561
+ var TABLE_CLASS = /* @__PURE__ */ ((TABLE_CLASS2) => {
46562
+ TABLE_CLASS2["COL_TITLE_TABLE"] = "col-title-table";
46563
+ TABLE_CLASS2["COL_TITLE_ITEM"] = "col-title-item";
46564
+ TABLE_CLASS2["STRIPE_STYLE_TABLE"] = "stripe-style-table";
46565
+ TABLE_CLASS2["NO_BORDER"] = "table-no-border";
46566
+ return TABLE_CLASS2;
46567
+ })(TABLE_CLASS || {});
46568
+ const TABLE_BAR_WIDTH = 6;
46569
+ const INSERT_BUTTON_SIZE = 20;
46570
+ const TABLE_CELL_MENU_BUTTON_CLASS = "table-cell-menu-btn";
46571
+ const logger$2r = getLogger("table-resize-gripper");
46572
+ const GRIPPER_SIZE = 7;
46573
+ const GRIPPER_SIZE_HALF = (GRIPPER_SIZE - 1) / 2;
46574
+ const CONTAINER_CELL_DELTA = 3;
46575
+ function getCellFromRightBorder(table, x, y) {
46576
+ const { rows } = table;
46577
+ for (let i = 0; i < rows.length; i++) {
46578
+ const row = rows[i];
46579
+ const cells = Array.from(row.cells);
46580
+ for (let j = 0; j < cells.length; j++) {
46581
+ const cell = cells[j];
46582
+ const rect = cell.getBoundingClientRect();
46583
+ const pos = Math.round(rect.right);
46584
+ if (Math.abs(x - pos) <= GRIPPER_SIZE_HALF && rect.top <= y && y <= rect.bottom) {
46585
+ return cell;
46586
+ }
46587
+ }
46588
+ }
46589
+ return null;
46590
+ }
46591
+ function editorHasExistsResizeGripper(editor) {
46592
+ return !!editor.rootContainer.querySelector(".table-resize-gripper");
46593
+ }
46594
+ function getExistsResizeGripper$1(editor, block) {
46595
+ const tools = getTableTools(editor, block);
46596
+ const gripper = tools.querySelector(".table-resize-gripper");
46597
+ return gripper;
46598
+ }
46599
+ function createResizeGripper$2(editor, block) {
46600
+ const exists = getExistsResizeGripper$1(editor, block);
46601
+ assert(logger$2r, !exists, "resize gripper has already exists");
46602
+ const tools = getTableTools(editor, block);
46603
+ const gripper = createElement("div", ["table-resize-gripper", "table-indicator"], tools);
46604
+ createElement("div", ["table-resize-gripper-indicator"], gripper);
46605
+ return gripper;
46606
+ }
46607
+ function updateResizeGripper$1(editor, block, cell) {
46608
+ let gripper = getExistsResizeGripper$1(editor, block);
46609
+ if (!gripper) {
46610
+ gripper = createResizeGripper$2(editor, block);
46611
+ }
46612
+ const table = getBlockTable(block);
46613
+ const tableRect = table.getBoundingClientRect();
46614
+ const cellRect = cell.getBoundingClientRect();
46615
+ const top = 0;
46616
+ const height = tableRect.height;
46617
+ const scrollContentRect = editor.getCustom(getTableScrollKey(block)).contentElement.getBoundingClientRect();
46618
+ const left = cellRect.right - scrollContentRect.left;
46619
+ gripper.style.left = `${left - GRIPPER_SIZE_HALF - TABLE_BAR_WIDTH - INSERT_BUTTON_SIZE}px`;
46620
+ gripper.style.top = `${top}px`;
46621
+ gripper.style.height = `${height}px`;
46622
+ gripper.style.width = `${GRIPPER_SIZE}px`;
46623
+ }
46624
+ function removeAllResizeGripper(editor) {
46625
+ editor.rootContainer.querySelectorAll(".table-resize-gripper").forEach((gripper) => {
46626
+ gripper.remove();
46627
+ });
46628
+ }
46629
+ function setTableColumnWidths(editor, block, colsWidth) {
46630
+ const oldData = editor.getBlockData(block);
46631
+ const newData = {
46632
+ ...oldData,
46633
+ colsWidth
46634
+ };
46635
+ editor.updateBlockData(block, newData, void 0, { noScroll: true });
46636
+ }
46637
+ function adjustColumnWidthsEvenly(editor, tableBlock) {
46638
+ const tableData = editor.getBlockData(tableBlock);
46639
+ const grid = tableData2Grid(tableData);
46640
+ const colCount = grid.colCount;
46641
+ const table = getBlockTable(tableBlock);
46642
+ const tableWidth = table.getBoundingClientRect().width;
46643
+ const colWidth = tableWidth / colCount;
46644
+ setTableColumnWidths(editor, tableBlock, Array(colCount).fill(colWidth));
46645
+ }
46556
46646
  const TABLE_COMMAND_GROUP_INDEX = 10;
46557
46647
  const TableCommands = [
46558
46648
  "table/merge-cells",
@@ -46561,7 +46651,8 @@ ${codeText}
46561
46651
  "table/insert-row",
46562
46652
  "table/delete-rows",
46563
46653
  "table/delete-columns",
46564
- "table/delete"
46654
+ "table/delete",
46655
+ "table/adjust-column-widths-evenly"
46565
46656
  ];
46566
46657
  class TableBlockCommandProvider {
46567
46658
  constructor() {
@@ -46573,6 +46664,8 @@ ${codeText}
46573
46664
  return [];
46574
46665
  }
46575
46666
  const commands = [];
46667
+ const deleteColumns2 = canDeleteColumns(editor, block, range);
46668
+ const deleteRows2 = canDeleteRows(editor, block, range);
46576
46669
  if (canMergeCells(editor, block, range)) {
46577
46670
  commands.push({
46578
46671
  id: "table/merge-cells",
@@ -46587,8 +46680,6 @@ ${codeText}
46587
46680
  icon: SplitCellIcon
46588
46681
  });
46589
46682
  }
46590
- const deleteColumns2 = canDeleteColumns(editor, block, range);
46591
- const deleteRows2 = canDeleteRows(editor, block, range);
46592
46683
  if (deleteColumns2 && deleteRows2) {
46593
46684
  commands.push({
46594
46685
  id: "table/delete",
@@ -46596,6 +46687,14 @@ ${codeText}
46596
46687
  icon: DeleteTableIcon
46597
46688
  });
46598
46689
  }
46690
+ const allColumnsSelected = deleteRows2;
46691
+ if (allColumnsSelected) {
46692
+ commands.push({
46693
+ id: "table/adjust-column-widths-evenly",
46694
+ name: i18n$1.t("table.adjustColumnWidthsEvenly"),
46695
+ icon: AdjustWidthIcon
46696
+ });
46697
+ }
46599
46698
  return commands;
46600
46699
  }
46601
46700
  executeCommand(editor, block, range, command, params, result) {
@@ -46625,19 +46724,13 @@ ${codeText}
46625
46724
  editor.deleteBlock(block);
46626
46725
  return true;
46627
46726
  }
46727
+ if (command.id === "table/adjust-column-widths-evenly") {
46728
+ adjustColumnWidthsEvenly(editor, block);
46729
+ return true;
46730
+ }
46628
46731
  return false;
46629
46732
  }
46630
46733
  }
46631
- var TABLE_CLASS = /* @__PURE__ */ ((TABLE_CLASS2) => {
46632
- TABLE_CLASS2["COL_TITLE_TABLE"] = "col-title-table";
46633
- TABLE_CLASS2["COL_TITLE_ITEM"] = "col-title-item";
46634
- TABLE_CLASS2["STRIPE_STYLE_TABLE"] = "stripe-style-table";
46635
- TABLE_CLASS2["NO_BORDER"] = "table-no-border";
46636
- return TABLE_CLASS2;
46637
- })(TABLE_CLASS || {});
46638
- const TABLE_BAR_WIDTH = 6;
46639
- const INSERT_BUTTON_SIZE = 20;
46640
- const TABLE_CELL_MENU_BUTTON_CLASS = "table-cell-menu-btn";
46641
46734
  function setColTitle(editor, tableBlock) {
46642
46735
  if (!editor.isBlockWritable(tableBlock)) {
46643
46736
  return;
@@ -46715,26 +46808,26 @@ ${codeText}
46715
46808
  };
46716
46809
  editor.updateBlockData(tableBlock, newBlockData);
46717
46810
  }
46718
- const logger$2r = getLogger("table-cell-dom");
46811
+ const logger$2q = getLogger("table-cell-dom");
46719
46812
  function getCellElementByChildBlockId(editor, tableBlock, blockId) {
46720
46813
  let blockElement = editor.getBlockById(blockId);
46721
46814
  while (blockElement) {
46722
46815
  const cell = blockElement.closest("td");
46723
- assert(logger$2r, cell, "no parent cell");
46816
+ assert(logger$2q, cell, "no parent cell");
46724
46817
  const cellParentBlock = getParentBlock(cell);
46725
- assert(logger$2r, cellParentBlock, "no parent block");
46818
+ assert(logger$2q, cellParentBlock, "no parent block");
46726
46819
  if (cellParentBlock === tableBlock) {
46727
46820
  return cell;
46728
46821
  }
46729
46822
  blockElement = cellParentBlock;
46730
46823
  }
46731
- assert(logger$2r, false, "filed to get cell by child block id");
46824
+ assert(logger$2q, false, "filed to get cell by child block id");
46732
46825
  return null;
46733
46826
  }
46734
46827
  function createComplexPosFromBlockPos(editor, tableBlock, blockPosition) {
46735
46828
  const blockElement = editor.getBlockById(blockPosition.blockId);
46736
46829
  if (blockElement === tableBlock && !blockPosition.isSimple()) {
46737
- assert(logger$2r, blockPosition.childContainerId, "block position must have childContainerId attribute");
46830
+ assert(logger$2q, blockPosition.childContainerId, "block position must have childContainerId attribute");
46738
46831
  return blockPosition;
46739
46832
  }
46740
46833
  const cellElement = getCellElementByChildBlockId(editor, tableBlock, blockPosition.blockId);
@@ -46748,12 +46841,12 @@ ${codeText}
46748
46841
  return getTableSelectionRange(tableBlock, start, end);
46749
46842
  }
46750
46843
  function updateBarsDangerStatus(editor, tableBlock, selectedRows, selectedColumns) {
46751
- assert(logger$2r, isTableBlock(tableBlock), "invalid table block");
46844
+ assert(logger$2q, isTableBlock(tableBlock), "invalid table block");
46752
46845
  const tools = getTableTools(editor, tableBlock);
46753
46846
  const blockTools = getBlockTools(tableBlock);
46754
46847
  const updateTop = () => {
46755
46848
  const exists = tools.querySelector(".table-border-bar-container.top");
46756
- assert(logger$2r, exists, "no top border bar container");
46849
+ assert(logger$2q, exists, "no top border bar container");
46757
46850
  const cells = exists.querySelectorAll(".table-border-bar-cell.top");
46758
46851
  cells.forEach((cell) => {
46759
46852
  const colIndex = parseInt(cell.getAttribute("data-top-index") || "0", 10);
@@ -46766,7 +46859,7 @@ ${codeText}
46766
46859
  };
46767
46860
  const updateLeft = () => {
46768
46861
  const left = blockTools.querySelector(".table-border-bar-container.left");
46769
- assert(logger$2r, left, "no left border bar container");
46862
+ assert(logger$2q, left, "no left border bar container");
46770
46863
  const cells = left.querySelectorAll(".table-border-bar-cell.left");
46771
46864
  cells.forEach((cell) => {
46772
46865
  const rowIndex = parseInt(cell.getAttribute("data-left-index") || "0", 10);
@@ -46802,7 +46895,7 @@ ${codeText}
46802
46895
  }
46803
46896
  }
46804
46897
  } catch (error2) {
46805
- logger$2r.error("update cells danger status failed: ", error2.message);
46898
+ logger$2q.error("update cells danger status failed: ", error2.message);
46806
46899
  }
46807
46900
  }
46808
46901
  function updateCellBarsDangerStatus(editor, tableBlock, isDanger = true, isCol) {
@@ -46825,7 +46918,7 @@ ${codeText}
46825
46918
  }
46826
46919
  updateBarsDangerStatus(editor, tableBlock, Array.from(selectedRows), Array.from(selectedColumns));
46827
46920
  } catch (error2) {
46828
- logger$2r.error("update cell bars danger status failed: ", error2.message);
46921
+ logger$2q.error("update cell bars danger status failed: ", error2.message);
46829
46922
  }
46830
46923
  }
46831
46924
  function createEntireRowAndColumnRange(editor, tableBlock, isCol) {
@@ -46944,14 +47037,14 @@ ${codeText}
46944
47037
  }
46945
47038
  const DEFAULT_COLUMN_WIDTH$1 = 200;
46946
47039
  const MIN_COLUMN_WIDTH = 40;
46947
- const logger$2q = getLogger("table-insert-column");
47040
+ const logger$2p = getLogger("table-insert-column");
46948
47041
  function insertColumn(editor, tableBlock, insertIndex) {
46949
47042
  editor.undoManager.runInGroup(() => {
46950
47043
  var _a;
46951
47044
  const table = getBlockTable(tableBlock);
46952
47045
  const grid = TableGrid.fromTable(table);
46953
47046
  const colCount = grid.colCount;
46954
- assert(logger$2q, insertIndex >= 0 && insertIndex <= colCount, `insert index ${insertIndex} is out of range [0, ${colCount}]`);
47047
+ assert(logger$2p, insertIndex >= 0 && insertIndex <= colCount, `insert index ${insertIndex} is out of range [0, ${colCount}]`);
46955
47048
  const cells = grid.map((cell) => cell.containerId);
46956
47049
  const spannedContainerIds = /* @__PURE__ */ new Set();
46957
47050
  editor.doc.beginBatchUpdate();
@@ -46972,7 +47065,7 @@ ${codeText}
46972
47065
  spannedContainerIds.forEach((containerId) => {
46973
47066
  const key = `${containerId}_colSpan`;
46974
47067
  const oldSpan = oldBlockData[key];
46975
- assert(logger$2q, typeof oldSpan === "number" && oldSpan > 1, `no colSpan for containerId ${containerId}, ${oldSpan}`);
47068
+ assert(logger$2p, typeof oldSpan === "number" && oldSpan > 1, `no colSpan for containerId ${containerId}, ${oldSpan}`);
46976
47069
  oldBlockData[key] = oldSpan + 1;
46977
47070
  });
46978
47071
  const colsWidth = ((_a = oldBlockData.colsWidth) == null ? void 0 : _a.concat()) || new Array(oldBlockData.cols).fill(0);
@@ -46988,13 +47081,13 @@ ${codeText}
46988
47081
  editor.updateBlockData(tableBlock, newBlockData);
46989
47082
  });
46990
47083
  }
46991
- const logger$2p = getLogger("table-insert-row");
47084
+ const logger$2o = getLogger("table-insert-row");
46992
47085
  function insertRow(editor, tableBlock, insertIndex) {
46993
47086
  editor.undoManager.runInGroup(() => {
46994
47087
  const table = getBlockTable(tableBlock);
46995
47088
  const grid = TableGrid.fromTable(table);
46996
47089
  const rowCount = grid.rowCount;
46997
- assert(logger$2p, insertIndex >= 0 && insertIndex <= rowCount, `insert index ${insertIndex} is out of range [0, ${rowCount}]`);
47090
+ assert(logger$2o, insertIndex >= 0 && insertIndex <= rowCount, `insert index ${insertIndex} is out of range [0, ${rowCount}]`);
46998
47091
  const cells = grid.map((cell) => cell.containerId);
46999
47092
  const spannedContainerIds = /* @__PURE__ */ new Set();
47000
47093
  editor.doc.beginBatchUpdate();
@@ -47002,12 +47095,12 @@ ${codeText}
47002
47095
  for (let col = 0; col < grid.colCount; col++) {
47003
47096
  const top = insertIndex > 0 && cells[insertIndex - 1][col];
47004
47097
  const bottom = insertIndex < grid.rowCount && cells[insertIndex][col];
47005
- assert(logger$2p, top || bottom, "no top and bottom cell");
47098
+ assert(logger$2o, top || bottom, "no top and bottom cell");
47006
47099
  if (insertIndex === 0 || insertIndex === grid.rowCount || top !== bottom) {
47007
47100
  const newContainerId = createEmptyContainer(editor.doc);
47008
47101
  rowData.push(newContainerId);
47009
47102
  } else {
47010
- assert(logger$2p, top, "no top cell");
47103
+ assert(logger$2o, top, "no top cell");
47011
47104
  rowData.push(top);
47012
47105
  spannedContainerIds.add(top);
47013
47106
  }
@@ -47018,7 +47111,7 @@ ${codeText}
47018
47111
  spannedContainerIds.forEach((containerId) => {
47019
47112
  const key = `${containerId}_rowSpan`;
47020
47113
  const oldSpan = oldBlockData[key];
47021
- assert(logger$2p, typeof oldSpan === "number" && oldSpan > 1, `no rowSpan for containerId ${containerId}, ${oldSpan}`);
47114
+ assert(logger$2o, typeof oldSpan === "number" && oldSpan > 1, `no rowSpan for containerId ${containerId}, ${oldSpan}`);
47022
47115
  oldBlockData[key] = oldSpan + 1;
47023
47116
  });
47024
47117
  const newChildren = TableGrid.virtualCellContainersGridToChildren(cells);
@@ -47031,7 +47124,7 @@ ${codeText}
47031
47124
  editor.updateBlockData(tableBlock, newBlockData);
47032
47125
  });
47033
47126
  }
47034
- const logger$2o = getLogger("table-chart");
47127
+ const logger$2n = getLogger("table-chart");
47035
47128
  function removeChart(editor, block) {
47036
47129
  const tableTools = findExistsTableTools(editor, block);
47037
47130
  if (tableTools) {
@@ -47116,7 +47209,7 @@ ${codeText}
47116
47209
  chartContainer = createElement("div", ["editor-table-chart"], tableTools);
47117
47210
  }
47118
47211
  const parent = chartContainer;
47119
- assert(logger$2o, parent, "no chart container");
47212
+ assert(logger$2n, parent, "no chart container");
47120
47213
  const options = editor.getComponentOptions("table");
47121
47214
  const cdn = (options == null ? void 0 : options.chartCdn) || "https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js";
47122
47215
  try {
@@ -47160,7 +47253,7 @@ ${codeText}
47160
47253
  chartContainer.chartObject = chartObject;
47161
47254
  }
47162
47255
  } catch (err) {
47163
- logger$2o.error(`failed to resolve chart cdn: ${JSON.stringify(err)}`);
47256
+ logger$2n.error(`failed to resolve chart cdn: ${JSON.stringify(err)}`);
47164
47257
  }
47165
47258
  }
47166
47259
  async function updateChartCore(editor, block) {
@@ -47317,7 +47410,7 @@ ${codeText}
47317
47410
  const height = document.documentElement.clientHeight;
47318
47411
  return new DOMRect(left, top, width, height);
47319
47412
  }
47320
- const logger$2n = getLogger("scroll-bar-handle");
47413
+ const logger$2m = getLogger("scroll-bar-handle");
47321
47414
  const BOTTOM_FLOAT_HEIGHT = 2;
47322
47415
  function getScrollbarContainer(scrollContainer) {
47323
47416
  const tools = getTools(scrollContainer);
@@ -47328,7 +47421,7 @@ ${codeText}
47328
47421
  scrollbarContainer.style.minHeight = "10px";
47329
47422
  }
47330
47423
  }
47331
- assert(logger$2n, scrollbarContainer instanceof HTMLDivElement, "invalid child for container tools");
47424
+ assert(logger$2m, scrollbarContainer instanceof HTMLDivElement, "invalid child for container tools");
47332
47425
  if (!scrollbarContainer.firstElementChild) {
47333
47426
  createElement("div", [], scrollbarContainer);
47334
47427
  }
@@ -47344,7 +47437,7 @@ ${codeText}
47344
47437
  fixScrollWrapRightBoundary(scrollCore, scrollContainer);
47345
47438
  fixScrollWrapLeftBoundary(scrollCore, scrollContainer);
47346
47439
  const overflowWidth = scrollWidth - clientWidth;
47347
- assert(logger$2n, scrollbarContainer.firstElementChild instanceof HTMLDivElement, "invalid child for scroll bar");
47440
+ assert(logger$2m, scrollbarContainer.firstElementChild instanceof HTMLDivElement, "invalid child for scroll bar");
47348
47441
  scrollbarContainer.style.width = `${getSizeAsScale(scrollContainer, originWidth + maxRight - paddingLeft - paddingRight)}px`;
47349
47442
  scrollbarContainer.firstElementChild.style.width = `${getSizeAsScale(scrollContainer, originWidth + maxRight + overflowWidth - paddingLeft - paddingRight)}px`;
47350
47443
  }
@@ -47431,7 +47524,7 @@ ${codeText}
47431
47524
  this.intersectionObserver.disconnect();
47432
47525
  }
47433
47526
  }
47434
- const logger$2m = getLogger("container-scroll-shadow");
47527
+ const logger$2l = getLogger("container-scroll-shadow");
47435
47528
  function setShadowBottom(shadow, scrollContainer, scrollWrap) {
47436
47529
  const elem = shadow;
47437
47530
  const contentRect = scrollContainer.getBoundingClientRect();
@@ -47450,22 +47543,22 @@ ${codeText}
47450
47543
  }
47451
47544
  function showLeftShadow(scrollContainer) {
47452
47545
  const targetTools = getTools(scrollContainer);
47453
- assert(logger$2m, targetTools, "no container tools");
47546
+ assert(logger$2l, targetTools, "no container tools");
47454
47547
  let shadow = targetTools.querySelector(`.${SHADOW_CLASS.LEFT}`);
47455
47548
  if (!shadow) {
47456
47549
  const scrollWrap = getContainerScrollArea(scrollContainer);
47457
47550
  const classes = [SHADOW_CLASS.COMMON, SHADOW_CLASS.LEFT];
47458
47551
  shadow = createElement("div", classes, targetTools);
47459
- assert(logger$2m, shadow instanceof HTMLDivElement, "invalid child for container tools");
47552
+ assert(logger$2l, shadow instanceof HTMLDivElement, "invalid child for container tools");
47460
47553
  setShadowBottom(shadow, scrollContainer, scrollWrap);
47461
47554
  }
47462
- assert(logger$2m, shadow instanceof HTMLElement, "invalid child for container tools");
47555
+ assert(logger$2l, shadow instanceof HTMLElement, "invalid child for container tools");
47463
47556
  const container = getContainer(scrollContainer);
47464
47557
  const containerRect = container.getBoundingClientRect();
47465
47558
  const scrollContainerRect = scrollContainer.getBoundingClientRect();
47466
47559
  shadow.style.left = `${getSizeAsScale(scrollContainer, scrollContainerRect.left - containerRect.left)}px`;
47467
47560
  const leftRest = getElementScrollSize(scrollContainer).scrollLeft;
47468
- assert(logger$2m, shadow instanceof HTMLDivElement, "invalid child for container tools");
47561
+ assert(logger$2l, shadow instanceof HTMLDivElement, "invalid child for container tools");
47469
47562
  setShadowWidth(shadow, leftRest);
47470
47563
  addClass(shadow, SHADOW_CLASS.ACTIVE);
47471
47564
  }
@@ -47476,17 +47569,17 @@ ${codeText}
47476
47569
  const scrollWrap = getContainerScrollArea(scrollContainer);
47477
47570
  const classes = [SHADOW_CLASS.COMMON, SHADOW_CLASS.RIGHT];
47478
47571
  shadow = createElement("div", classes, tools);
47479
- assert(logger$2m, shadow instanceof HTMLDivElement, "no div, create shadow failed");
47572
+ assert(logger$2l, shadow instanceof HTMLDivElement, "no div, create shadow failed");
47480
47573
  setShadowBottom(shadow, scrollContainer, scrollWrap);
47481
47574
  }
47482
- assert(logger$2m, shadow instanceof HTMLElement, "");
47575
+ assert(logger$2l, shadow instanceof HTMLElement, "");
47483
47576
  const container = getContainer(scrollContainer);
47484
47577
  const containerRect = container.getBoundingClientRect();
47485
47578
  const scrollContainerRect = scrollContainer.getBoundingClientRect();
47486
47579
  shadow.style.right = `${getSizeAsScale(scrollContainer, containerRect.right - scrollContainerRect.right)}px`;
47487
47580
  const { scrollWidth, scrollLeft, clientWidth } = getElementScrollSize(scrollContainer);
47488
47581
  const rightRest = scrollWidth - scrollLeft - clientWidth;
47489
- assert(logger$2m, shadow instanceof HTMLDivElement, "no shadow element");
47582
+ assert(logger$2l, shadow instanceof HTMLDivElement, "no shadow element");
47490
47583
  setShadowWidth(shadow, rightRest);
47491
47584
  addClass(shadow, SHADOW_CLASS.ACTIVE);
47492
47585
  }
@@ -47559,12 +47652,12 @@ ${codeText}
47559
47652
  this.resizeObserver.disconnect();
47560
47653
  }
47561
47654
  }
47562
- const logger$2l = getLogger("container-scroll-observer");
47655
+ const logger$2k = getLogger("container-scroll-observer");
47563
47656
  class ContainerScrollObserver {
47564
47657
  constructor(scrollCore, callback) {
47565
47658
  __publicField(this, "handleContentScroll", (e2) => {
47566
47659
  const scrollContainer = e2.target;
47567
- assert(logger$2l, scrollContainer instanceof Element, "invalid target for scroll event");
47660
+ assert(logger$2k, scrollContainer instanceof Element, "invalid target for scroll event");
47568
47661
  const scrollbarContainer = getScrollbarContainer(scrollContainer);
47569
47662
  scrollbarContainer.removeEventListener("scroll", this.handleScroll);
47570
47663
  const needFixScrollbarContainer = true;
@@ -47575,7 +47668,7 @@ ${codeText}
47575
47668
  });
47576
47669
  __publicField(this, "handleScroll", (e2) => {
47577
47670
  const scrollbarContainer = e2.target;
47578
- assert(logger$2l, scrollbarContainer instanceof HTMLElement, "");
47671
+ assert(logger$2k, scrollbarContainer instanceof HTMLElement, "");
47579
47672
  const scrollLeft = scrollbarContainer.scrollLeft;
47580
47673
  const needFixScrollbarContainer = false;
47581
47674
  const scrollContainer = getScrollContainerByScrollBar(scrollbarContainer);
@@ -47655,7 +47748,7 @@ ${codeText}
47655
47748
  this.scrollContainers.clear();
47656
47749
  }
47657
47750
  }
47658
- const logger$2k = getLogger("scroll-wrap-resize-observer");
47751
+ const logger$2j = getLogger("scroll-wrap-resize-observer");
47659
47752
  class ScrollWrapResizeObserve {
47660
47753
  constructor(scrollCore) {
47661
47754
  __publicField(this, "resizeObserver");
@@ -47671,7 +47764,7 @@ ${codeText}
47671
47764
  });
47672
47765
  __publicField(this, "handleScrollWrapResizeEntry", (entry) => {
47673
47766
  const scrollWrap = entry.target;
47674
- assert(logger$2k, scrollWrap instanceof HTMLElement, "invalid target for observer entry");
47767
+ assert(logger$2j, scrollWrap instanceof HTMLElement, "invalid target for observer entry");
47675
47768
  const scrollContainer = getScrollContainer(scrollWrap);
47676
47769
  resetScrollbar(this.scrollCore, scrollWrap);
47677
47770
  resetScrollWrapShadow(scrollContainer);
@@ -47876,7 +47969,7 @@ ${codeText}
47876
47969
  window.removeEventListener("scroll", this.handleWindowEffect);
47877
47970
  }
47878
47971
  }
47879
- const logger$2j = getLogger("scroll-container");
47972
+ const logger$2i = getLogger("scroll-container");
47880
47973
  const rootScrollMap = /* @__PURE__ */ new Map();
47881
47974
  class ScrollContainer extends tinyTypedEmitter.TypedEmitter {
47882
47975
  constructor() {
@@ -47924,11 +48017,11 @@ ${codeText}
47924
48017
  return this.scrollContainerElement;
47925
48018
  }
47926
48019
  get contentElement() {
47927
- assert(logger$2j, this.scrollContainerElement, "scrollContainerElement cannot be undefined");
48020
+ assert(logger$2i, this.scrollContainerElement, "scrollContainerElement cannot be undefined");
47928
48021
  return getContainerScrollArea(this.scrollContainerElement);
47929
48022
  }
47930
48023
  get scrollOptions() {
47931
- assert(logger$2j, this.options, "options cannot be undefined");
48024
+ assert(logger$2i, this.options, "options cannot be undefined");
47932
48025
  return { ...this.options };
47933
48026
  }
47934
48027
  handleBaseListenerDestroy(baseListener) {
@@ -47952,7 +48045,7 @@ ${codeText}
47952
48045
  function createScrollContainer() {
47953
48046
  return new ScrollContainer();
47954
48047
  }
47955
- const logger$2i = getLogger("column-width");
48048
+ const logger$2h = getLogger("column-width");
47956
48049
  function setColumnWidth(table, colIndex, width) {
47957
48050
  const col = getTableCol(table, colIndex);
47958
48051
  col.style.width = `${width}px`;
@@ -47973,7 +48066,7 @@ ${codeText}
47973
48066
  cellRightOffsets[colIndex] = cell.cell.getBoundingClientRect().right - left;
47974
48067
  }
47975
48068
  });
47976
- logger$2i.debug(`cellRightOffsets1: ${cellRightOffsets.join()}`);
48069
+ logger$2h.debug(`cellRightOffsets1: ${cellRightOffsets.join()}`);
47977
48070
  for (let col = 0; col < cellRightOffsets.length; col++) {
47978
48071
  const offset = cellRightOffsets[col];
47979
48072
  if (offset === -1 || col === 0) {
@@ -47993,7 +48086,7 @@ ${codeText}
47993
48086
  cellRightOffsets[i] = prevOffset + averageWidth * (i - prevCol);
47994
48087
  }
47995
48088
  }
47996
- logger$2i.debug(`cellRightOffsets2: ${cellRightOffsets.join()}`);
48089
+ logger$2h.debug(`cellRightOffsets2: ${cellRightOffsets.join()}`);
47997
48090
  const result = [];
47998
48091
  let prev = 0;
47999
48092
  for (let col = 0; col < cellRightOffsets.length; col++) {
@@ -48001,7 +48094,7 @@ ${codeText}
48001
48094
  result.push(offset - prev);
48002
48095
  prev = offset;
48003
48096
  }
48004
- logger$2i.debug(`widths: ${result.join()}`);
48097
+ logger$2h.debug(`widths: ${result.join()}`);
48005
48098
  return result;
48006
48099
  }
48007
48100
  function getTableColumnWidths(table) {
@@ -48009,72 +48102,6 @@ ${codeText}
48009
48102
  const widths = tableCols.map((col) => col.getBoundingClientRect().width || Number.parseInt(col.style.width, 10));
48010
48103
  return widths;
48011
48104
  }
48012
- const logger$2h = getLogger("table-resize-gripper");
48013
- const GRIPPER_SIZE = 7;
48014
- const GRIPPER_SIZE_HALF = (GRIPPER_SIZE - 1) / 2;
48015
- const CONTAINER_CELL_DELTA = 3;
48016
- function getCellFromRightBorder(table, x, y) {
48017
- const { rows } = table;
48018
- for (let i = 0; i < rows.length; i++) {
48019
- const row = rows[i];
48020
- const cells = Array.from(row.cells);
48021
- for (let j = 0; j < cells.length; j++) {
48022
- const cell = cells[j];
48023
- const rect = cell.getBoundingClientRect();
48024
- const pos = Math.round(rect.right);
48025
- if (Math.abs(x - pos) <= GRIPPER_SIZE_HALF && rect.top <= y && y <= rect.bottom) {
48026
- return cell;
48027
- }
48028
- }
48029
- }
48030
- return null;
48031
- }
48032
- function editorHasExistsResizeGripper(editor) {
48033
- return !!editor.rootContainer.querySelector(".table-resize-gripper");
48034
- }
48035
- function getExistsResizeGripper$1(editor, block) {
48036
- const tools = getTableTools(editor, block);
48037
- const gripper = tools.querySelector(".table-resize-gripper");
48038
- return gripper;
48039
- }
48040
- function createResizeGripper$2(editor, block) {
48041
- const exists = getExistsResizeGripper$1(editor, block);
48042
- assert(logger$2h, !exists, "resize gripper has already exists");
48043
- const tools = getTableTools(editor, block);
48044
- const gripper = createElement("div", ["table-resize-gripper", "table-indicator"], tools);
48045
- createElement("div", ["table-resize-gripper-indicator"], gripper);
48046
- return gripper;
48047
- }
48048
- function updateResizeGripper$1(editor, block, cell) {
48049
- let gripper = getExistsResizeGripper$1(editor, block);
48050
- if (!gripper) {
48051
- gripper = createResizeGripper$2(editor, block);
48052
- }
48053
- const table = getBlockTable(block);
48054
- const tableRect = table.getBoundingClientRect();
48055
- const cellRect = cell.getBoundingClientRect();
48056
- const top = 0;
48057
- const height = tableRect.height;
48058
- const scrollContentRect = editor.getCustom(getTableScrollKey(block)).contentElement.getBoundingClientRect();
48059
- const left = cellRect.right - scrollContentRect.left;
48060
- gripper.style.left = `${left - GRIPPER_SIZE_HALF - TABLE_BAR_WIDTH - INSERT_BUTTON_SIZE}px`;
48061
- gripper.style.top = `${top}px`;
48062
- gripper.style.height = `${height}px`;
48063
- gripper.style.width = `${GRIPPER_SIZE}px`;
48064
- }
48065
- function removeAllResizeGripper(editor) {
48066
- editor.rootContainer.querySelectorAll(".table-resize-gripper").forEach((gripper) => {
48067
- gripper.remove();
48068
- });
48069
- }
48070
- function setTableColumnWidths(editor, block, colsWidth) {
48071
- const oldData = editor.getBlockData(block);
48072
- const newData = {
48073
- ...oldData,
48074
- colsWidth
48075
- };
48076
- editor.updateBlockData(block, newData, void 0, { noScroll: true });
48077
- }
48078
48105
  function getTableResizeMinX(editor, draggingRefCell, table, x) {
48079
48106
  const cell = draggingRefCell;
48080
48107
  const grid = TableGrid.fromTable(table);
@@ -54753,7 +54780,7 @@ ${codeText}
54753
54780
  };
54754
54781
  return { blockData };
54755
54782
  }
54756
- function getOptions$8(editor) {
54783
+ function getOptions$9(editor) {
54757
54784
  return {
54758
54785
  name: "Mathjax"
54759
54786
  };
@@ -54785,7 +54812,7 @@ $$${mathData.mathjaxText}$$
54785
54812
  const MathjaxEmbed = {
54786
54813
  embedType: "math",
54787
54814
  createEmbedContent: createEmbedContent$9,
54788
- getOptions: getOptions$8,
54815
+ getOptions: getOptions$9,
54789
54816
  convertFrom: convertFrom$7,
54790
54817
  handleDeleteBlock: handleDeleteBlock$7,
54791
54818
  convertTo: convertTo$g,
@@ -65255,7 +65282,7 @@ $$${mathData.mathjaxText}$$
65255
65282
  editor.focus();
65256
65283
  return editor.insertBlock(options.containerId, options.blockIndex, blockData, createBlockSimpleRange(editor, focusBlockId, 0));
65257
65284
  }
65258
- function getOptions$7(editor) {
65285
+ function getOptions$8(editor) {
65259
65286
  return {
65260
65287
  name: "CodeBlock",
65261
65288
  insertBlockCommandItems: [
@@ -65320,7 +65347,7 @@ ${codeText}
65320
65347
  getSelectedContainers: getSelectedContainers$2,
65321
65348
  convertFrom: convertToCode,
65322
65349
  handleBlockElementUpdated,
65323
- getOptions: getOptions$7,
65350
+ getOptions: getOptions$8,
65324
65351
  getBlockProperties: getBlockProperties$a,
65325
65352
  convertTo: convertTo$e,
65326
65353
  handleDeleteBlock: handleDeleteBlock$6
@@ -68297,7 +68324,7 @@ ${codeText}
68297
68324
  abstract: `${i18n$1.t("image.abstract")}`
68298
68325
  };
68299
68326
  };
68300
- function getOptions$6() {
68327
+ function getOptions$7() {
68301
68328
  return {
68302
68329
  name: "Image",
68303
68330
  insertEmbedCommandItems: [{
@@ -68397,7 +68424,7 @@ ${codeText}
68397
68424
  convertTo: convertTo$d,
68398
68425
  convertFrom: convertFrom$6,
68399
68426
  getBlockProperties: getBlockProperties$9,
68400
- getOptions: getOptions$6,
68427
+ getOptions: getOptions$7,
68401
68428
  handleDrop: handleDrop$1,
68402
68429
  handleDropOver: handleDropOver$1,
68403
68430
  handleDeleteBlock: handleDeleteBlock$5
@@ -73214,7 +73241,7 @@ ${codeText}
73214
73241
  }
73215
73242
  return createEmptyTableDataByFirstRowText(editor, editor.getBlockString(srcBlock).trim());
73216
73243
  }
73217
- function getOptions$5(editor) {
73244
+ function getOptions$6(editor) {
73218
73245
  return {
73219
73246
  name: "TableBlock",
73220
73247
  insertBlockCommandItems: [{
@@ -73291,7 +73318,7 @@ ${codeText}
73291
73318
  adjustSelectionPos,
73292
73319
  getClientRects,
73293
73320
  selectionToDoc,
73294
- getOptions: getOptions$5,
73321
+ getOptions: getOptions$6,
73295
73322
  getTextToolbarReferenceClient: getTextToolbarReferenceClient$1,
73296
73323
  handleUpdateBlock: handleUpdateBlock$5,
73297
73324
  handleDeleteBlock: handleDeleteBlock$4,
@@ -73327,6 +73354,7 @@ ${codeText}
73327
73354
  splitCell: "\u62C6\u5206\u5355\u5143\u683C",
73328
73355
  tableConfigKey: "\u8868\u683C\u8BBE\u7F6E",
73329
73356
  deleteTable: "\u5220\u9664\u8868\u683C",
73357
+ adjustColumnWidthsEvenly: "\u5E73\u5747\u5206\u914D\u5217\u5BBD",
73330
73358
  insertCol: "\u63D2\u5165\u5217",
73331
73359
  insertRow: "\u63D2\u5165\u884C",
73332
73360
  deleteCol: "\u5220\u9664\u5217",
@@ -73358,6 +73386,7 @@ ${codeText}
73358
73386
  splitCell: "Split cell",
73359
73387
  tableConfigKey: "Table settings",
73360
73388
  deleteTable: "Delete table",
73389
+ adjustColumnWidthsEvenly: "Adjust column widths evenly",
73361
73390
  insertCol: "Insert column",
73362
73391
  insertRow: "Insert row",
73363
73392
  deleteCol: "Delete column",
@@ -73389,6 +73418,7 @@ ${codeText}
73389
73418
  splitCell: "\u30BB\u30EB\u306E\u7D50\u5408\u3092\u89E3\u9664",
73390
73419
  tableConfigKey: "\u30C6\u30FC\u30D6\u30EB\u8A2D\u5B9A",
73391
73420
  deleteTable: "\u30C6\u30FC\u30D6\u30EB\u3092\u524A\u9664",
73421
+ adjustColumnWidthsEvenly: "\u5217\u5E45\u3092\u5747\u7B49\u306B\u8ABF\u6574",
73392
73422
  insertCol: "\u5217\u3092\u633F\u5165",
73393
73423
  insertRow: "\u884C\u3092\u633F\u5165",
73394
73424
  deleteCol: "\u5217\u3092\u524A\u9664",
@@ -76784,25 +76814,8 @@ ${docStr}
76784
76814
  };
76785
76815
  }
76786
76816
  }
76787
- function isContainHyperlink(text2) {
76788
- const pattern = /^([\d\w\u4e00-\u9fa5\s]*[\u4e00-\u9fa5\s]{1}|)((https|http|ftp)?:\/\/)[^\s]+/;
76789
- return pattern.test(text2);
76790
- }
76791
- function transText2TextOp(text2) {
76792
- const ret = [];
76793
- const prefix = text2.split(/https|http|ftp/)[0];
76794
- const link2 = text2.substring(prefix.length).trim();
76795
- if (prefix && prefix.length) {
76796
- const textOp = createTextOp(prefix, null);
76797
- ret.push(textOp, createTextOp(" ", null));
76798
- }
76799
- const linkOp = createTextOp(link2, { link: link2 });
76800
- ret.push(linkOp, createTextOp(" ", null));
76801
- return ret;
76802
- }
76803
76817
  class TextDataConverter {
76804
- async fromData(editor, data2, options) {
76805
- const { toPlainText: toPlainText2 = false } = options || {};
76818
+ async fromData(editor, data2) {
76806
76819
  const result = {};
76807
76820
  const text2 = data2.getData("text/plain");
76808
76821
  if (text2) {
@@ -76812,10 +76825,6 @@ ${docStr}
76812
76825
  id: genId(),
76813
76826
  type: "text"
76814
76827
  };
76815
- if (isContainHyperlink(line) && !toPlainText2) {
76816
- block.text = transText2TextOp(line);
76817
- return block;
76818
- }
76819
76828
  const text22 = line ? [createTextOp(line, null)] : [];
76820
76829
  block.text = text22;
76821
76830
  return block;
@@ -76832,6 +76841,103 @@ ${docStr}
76832
76841
  return result;
76833
76842
  }
76834
76843
  }
76844
+ function findLinks(text2) {
76845
+ const pattern = /https?:\/\/[^\s/$.?#].[^\s]*/g;
76846
+ const results = [];
76847
+ let match;
76848
+ while ((match = pattern.exec(text2)) !== null) {
76849
+ const url = match[0];
76850
+ const startIndex = match.index;
76851
+ const endIndex = pattern.lastIndex;
76852
+ results.push({ url, startIndex, endIndex });
76853
+ }
76854
+ return results;
76855
+ }
76856
+ function urlToLinkOp(result) {
76857
+ const attributes = {
76858
+ link: result.url
76859
+ };
76860
+ return {
76861
+ insert: result.url,
76862
+ attributes
76863
+ };
76864
+ }
76865
+ function opToLinks(op) {
76866
+ var _a, _b;
76867
+ if ((_a = op.attributes) == null ? void 0 : _a.box) {
76868
+ return [op];
76869
+ }
76870
+ if ((_b = op.attributes) == null ? void 0 : _b.link) {
76871
+ return [op];
76872
+ }
76873
+ const text2 = op.insert;
76874
+ const attributes = op.attributes;
76875
+ const results = findLinks(text2);
76876
+ if (results.length === 0) {
76877
+ return [op];
76878
+ }
76879
+ let current = text2;
76880
+ const ops = [];
76881
+ for (let i = results.length - 1; i >= 0; i--) {
76882
+ const result = results[i];
76883
+ const right = current.substring(result.endIndex);
76884
+ if (right) {
76885
+ const rightOp = {
76886
+ insert: right
76887
+ };
76888
+ if (attributes) {
76889
+ rightOp.attributes = JSON.parse(JSON.stringify(attributes));
76890
+ }
76891
+ ops.unshift(rightOp);
76892
+ }
76893
+ const boxOp = urlToLinkOp(result);
76894
+ if (boxOp) {
76895
+ ops.unshift(boxOp);
76896
+ } else {
76897
+ const keepText = current.substring(result.startIndex, result.endIndex);
76898
+ const keepOp = {
76899
+ insert: keepText
76900
+ };
76901
+ if (attributes) {
76902
+ keepOp.attributes = attributes;
76903
+ }
76904
+ ops.unshift(keepOp);
76905
+ }
76906
+ current = current.substring(0, result.startIndex);
76907
+ }
76908
+ if (current) {
76909
+ const lastOp = {
76910
+ insert: current
76911
+ };
76912
+ if (attributes) {
76913
+ lastOp.attributes = attributes;
76914
+ }
76915
+ ops.unshift(lastOp);
76916
+ }
76917
+ return ops;
76918
+ }
76919
+ class ConvertLinkPasteHandler {
76920
+ constructor() {
76921
+ __publicField(this, "order");
76922
+ this.order = 200;
76923
+ }
76924
+ async handleBeforePasteDoc(editor, doc2) {
76925
+ for (const blocks of Object.values(doc2.blocks)) {
76926
+ for (const block of blocks) {
76927
+ if (block.type === "text") {
76928
+ const ops = block.text || [];
76929
+ const newOps = [];
76930
+ for (const op of ops) {
76931
+ const subOps = opToLinks(op);
76932
+ newOps.push(...subOps);
76933
+ }
76934
+ block.text = newOps;
76935
+ }
76936
+ }
76937
+ }
76938
+ return false;
76939
+ }
76940
+ }
76835
76941
  function getImages(files) {
76836
76942
  const images = [];
76837
76943
  for (let i = 0; i < files.length; i++) {
@@ -76845,6 +76951,7 @@ ${docStr}
76845
76951
  }
76846
76952
  class OnesEditorPasteHandler {
76847
76953
  constructor(editor) {
76954
+ editor.input.addHandler(new ConvertLinkPasteHandler());
76848
76955
  editor.dataConverter.addConverter(new HtmlDataConverter());
76849
76956
  editor.dataConverter.addConverter(new TextDataConverter());
76850
76957
  editor.dataConverter.addConverter(new MarkdownDataConverter());
@@ -82047,24 +82154,45 @@ ${docStr}
82047
82154
  };
82048
82155
  return { blockData };
82049
82156
  }
82157
+ function getOptions$5() {
82158
+ return {
82159
+ name: "toc",
82160
+ insertEmbedCommandItems: [{
82161
+ id: "insert-toc",
82162
+ name: i18n$1.t("toc.name"),
82163
+ icon: DividingLineIcon,
82164
+ order: 510,
82165
+ group: "common",
82166
+ subText: getShortcutById("insert-toc")
82167
+ }],
82168
+ handleInsertEmptyEmbed: async (editor, options) => {
82169
+ const { containerId, blockIndex } = options;
82170
+ return editor.insertEmbed(containerId, blockIndex, "toc", {});
82171
+ }
82172
+ };
82173
+ }
82050
82174
  const TocEmbed = {
82051
82175
  embedType: "toc",
82052
82176
  createEmbedContent: createEmbedContent$6,
82053
82177
  convertTo: convertTo$8,
82054
- convertFrom: convertFrom$4
82178
+ convertFrom: convertFrom$4,
82179
+ getOptions: getOptions$5
82055
82180
  };
82056
82181
  const zhCN$c = {
82057
82182
  toc: {
82183
+ name: "\u6807\u9898\u76EE\u5F55",
82058
82184
  empty: "No Toc"
82059
82185
  }
82060
82186
  };
82061
82187
  const enUS$c = {
82062
82188
  toc: {
82189
+ name: "Toc",
82063
82190
  empty: "No Toc"
82064
82191
  }
82065
82192
  };
82066
82193
  const jaJP$c = {
82067
82194
  toc: {
82195
+ name: "Toc",
82068
82196
  empty: "No Toc"
82069
82197
  }
82070
82198
  };
@@ -84010,13 +84138,17 @@ ${docStr}
84010
84138
  var _a;
84011
84139
  const header = this.block.querySelector(".embed-graph-header");
84012
84140
  assert(logger$l, header, "header does not exist");
84013
- const data2 = this.editor.getBlockData(this.block);
84014
- const { flex = DEFAULT_FLEX, code, src, view } = this.getGraphData(data2);
84015
- header.style.display = editor.readonly || clientType.isMobile ? "none" : "flex";
84016
- const realView = this.getRealView(view);
84017
- (_a = this.viewSelect) == null ? void 0 : _a.setSelectedView(realView);
84018
- this.updateLayout(realView, flex);
84019
- this.updateDraw(src, code);
84141
+ try {
84142
+ const data2 = this.editor.getBlockData(this.block);
84143
+ const { flex = DEFAULT_FLEX, code, src, view } = this.getGraphData(data2);
84144
+ header.style.display = editor.readonly || clientType.isMobile ? "none" : "flex";
84145
+ const realView = this.getRealView(view);
84146
+ (_a = this.viewSelect) == null ? void 0 : _a.setSelectedView(realView);
84147
+ this.updateLayout(realView, flex);
84148
+ this.updateDraw(src, code);
84149
+ } catch (err) {
84150
+ logger$l.debug(`handleReadonlyChanged error: ${err}`);
84151
+ }
84020
84152
  });
84021
84153
  __publicField(this, "updateLayoutData", () => {
84022
84154
  var _a;
@@ -92607,7 +92739,7 @@ ${data2.plantumlText}
92607
92739
  }
92608
92740
  }
92609
92741
  });
92610
- editor.version = "2.8.13";
92742
+ editor.version = "2.8.14-beta.2";
92611
92743
  return editor;
92612
92744
  }
92613
92745
  function isDoc(doc2) {
@@ -92720,7 +92852,7 @@ ${data2.plantumlText}
92720
92852
  }
92721
92853
  });
92722
92854
  OnesEditorToolbar.register(editor);
92723
- editor.version = "2.8.13";
92855
+ editor.version = "2.8.14-beta.2";
92724
92856
  return editor;
92725
92857
  }
92726
92858
  async function showDocVersions(editor, options, serverUrl) {
@@ -138497,6 +138629,7 @@ ${data2.plantumlText}
138497
138629
  exports2.AddCommentToOldDocCommandProvider = AddCommentToOldDocCommandProvider;
138498
138630
  exports2.AddEmojiIcon = AddEmojiIcon;
138499
138631
  exports2.AddIcon = AddIcon;
138632
+ exports2.AdjustWidthIcon = AdjustWidthIcon;
138500
138633
  exports2.AlertDialog = AlertDialog;
138501
138634
  exports2.AlertEmojiIcon = alterEmoji;
138502
138635
  exports2.AlignCenterIcon = AlignCenterIcon;