@jvs-milkdown/components 1.1.9 → 1.2.1

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.
Files changed (139) hide show
  1. package/lib/code-block/index.js +37 -2
  2. package/lib/code-block/index.js.map +1 -1
  3. package/lib/image-block/index.js +628 -107
  4. package/lib/image-block/index.js.map +1 -1
  5. package/lib/table-block/index.js +135 -64
  6. package/lib/table-block/index.js.map +1 -1
  7. package/lib/tsconfig.tsbuildinfo +1 -1
  8. package/package.json +10 -10
  9. package/src/code-block/config.ts +4 -0
  10. package/src/code-block/view/components/code-block.tsx +24 -0
  11. package/src/code-block/view/node-view.ts +15 -0
  12. package/src/image-block/config.ts +10 -0
  13. package/src/image-block/schema.ts +16 -0
  14. package/src/image-block/view/components/__tests__/image-viewer.onImageLoadError.spec.tsx +14 -0
  15. package/src/image-block/view/components/image-block.tsx +40 -0
  16. package/src/image-block/view/components/image-viewer.tsx +548 -65
  17. package/src/image-block/view/index.ts +42 -0
  18. package/src/table-block/view/component.tsx +116 -46
  19. package/src/table-block/view/operation.ts +55 -30
  20. package/lib/__internal__/components/icon.d.ts +0 -24
  21. package/lib/__internal__/components/icon.d.ts.map +0 -1
  22. package/lib/__internal__/components/image-input.d.ts +0 -17
  23. package/lib/__internal__/components/image-input.d.ts.map +0 -1
  24. package/lib/__internal__/keep-alive.d.ts +0 -2
  25. package/lib/__internal__/keep-alive.d.ts.map +0 -1
  26. package/lib/__internal__/meta.d.ts +0 -3
  27. package/lib/__internal__/meta.d.ts.map +0 -1
  28. package/lib/__tests__/setup.d.ts +0 -2
  29. package/lib/__tests__/setup.d.ts.map +0 -1
  30. package/lib/code-block/config.d.ts +0 -23
  31. package/lib/code-block/config.d.ts.map +0 -1
  32. package/lib/code-block/index.d.ts +0 -5
  33. package/lib/code-block/index.d.ts.map +0 -1
  34. package/lib/code-block/view/components/code-block.d.ts +0 -16
  35. package/lib/code-block/view/components/code-block.d.ts.map +0 -1
  36. package/lib/code-block/view/components/copy-button.d.ts +0 -9
  37. package/lib/code-block/view/components/copy-button.d.ts.map +0 -1
  38. package/lib/code-block/view/components/language-picker.d.ts +0 -5
  39. package/lib/code-block/view/components/language-picker.d.ts.map +0 -1
  40. package/lib/code-block/view/components/preview-panel.d.ts +0 -9
  41. package/lib/code-block/view/components/preview-panel.d.ts.map +0 -1
  42. package/lib/code-block/view/index.d.ts +0 -3
  43. package/lib/code-block/view/index.d.ts.map +0 -1
  44. package/lib/code-block/view/loader.d.ts +0 -13
  45. package/lib/code-block/view/loader.d.ts.map +0 -1
  46. package/lib/code-block/view/node-view.d.ts +0 -40
  47. package/lib/code-block/view/node-view.d.ts.map +0 -1
  48. package/lib/image-block/config.d.ts +0 -16
  49. package/lib/image-block/config.d.ts.map +0 -1
  50. package/lib/image-block/convert-plugin.d.ts +0 -2
  51. package/lib/image-block/convert-plugin.d.ts.map +0 -1
  52. package/lib/image-block/index.d.ts +0 -9
  53. package/lib/image-block/index.d.ts.map +0 -1
  54. package/lib/image-block/paste-rule.d.ts +0 -2
  55. package/lib/image-block/paste-rule.d.ts.map +0 -1
  56. package/lib/image-block/remark-plugin.d.ts +0 -2
  57. package/lib/image-block/remark-plugin.d.ts.map +0 -1
  58. package/lib/image-block/schema.d.ts +0 -3
  59. package/lib/image-block/schema.d.ts.map +0 -1
  60. package/lib/image-block/view/components/__tests__/image-viewer.onImageLoadError.spec.d.ts +0 -2
  61. package/lib/image-block/view/components/__tests__/image-viewer.onImageLoadError.spec.d.ts.map +0 -1
  62. package/lib/image-block/view/components/image-block.d.ts +0 -19
  63. package/lib/image-block/view/components/image-block.d.ts.map +0 -1
  64. package/lib/image-block/view/components/image-viewer.d.ts +0 -3
  65. package/lib/image-block/view/components/image-viewer.d.ts.map +0 -1
  66. package/lib/image-block/view/index.d.ts +0 -3
  67. package/lib/image-block/view/index.d.ts.map +0 -1
  68. package/lib/image-inline/components/image-inline.d.ts +0 -18
  69. package/lib/image-inline/components/image-inline.d.ts.map +0 -1
  70. package/lib/image-inline/config.d.ts +0 -11
  71. package/lib/image-inline/config.d.ts.map +0 -1
  72. package/lib/image-inline/index.d.ts +0 -5
  73. package/lib/image-inline/index.d.ts.map +0 -1
  74. package/lib/image-inline/view.d.ts +0 -3
  75. package/lib/image-inline/view.d.ts.map +0 -1
  76. package/lib/index.d.ts +0 -2
  77. package/lib/index.d.ts.map +0 -1
  78. package/lib/link-tooltip/command.d.ts +0 -2
  79. package/lib/link-tooltip/command.d.ts.map +0 -1
  80. package/lib/link-tooltip/configure.d.ts +0 -3
  81. package/lib/link-tooltip/configure.d.ts.map +0 -1
  82. package/lib/link-tooltip/edit/component.d.ts +0 -11
  83. package/lib/link-tooltip/edit/component.d.ts.map +0 -1
  84. package/lib/link-tooltip/edit/edit-configure.d.ts +0 -3
  85. package/lib/link-tooltip/edit/edit-configure.d.ts.map +0 -1
  86. package/lib/link-tooltip/edit/edit-view.d.ts +0 -15
  87. package/lib/link-tooltip/edit/edit-view.d.ts.map +0 -1
  88. package/lib/link-tooltip/index.d.ts +0 -7
  89. package/lib/link-tooltip/index.d.ts.map +0 -1
  90. package/lib/link-tooltip/preview/component.d.ts +0 -11
  91. package/lib/link-tooltip/preview/component.d.ts.map +0 -1
  92. package/lib/link-tooltip/preview/preview-configure.d.ts +0 -3
  93. package/lib/link-tooltip/preview/preview-configure.d.ts.map +0 -1
  94. package/lib/link-tooltip/preview/preview-view.d.ts +0 -14
  95. package/lib/link-tooltip/preview/preview-view.d.ts.map +0 -1
  96. package/lib/link-tooltip/slices.d.ts +0 -34
  97. package/lib/link-tooltip/slices.d.ts.map +0 -1
  98. package/lib/link-tooltip/tooltips.d.ts +0 -3
  99. package/lib/link-tooltip/tooltips.d.ts.map +0 -1
  100. package/lib/link-tooltip/utils.d.ts +0 -14
  101. package/lib/link-tooltip/utils.d.ts.map +0 -1
  102. package/lib/list-item-block/component.d.ts +0 -19
  103. package/lib/list-item-block/component.d.ts.map +0 -1
  104. package/lib/list-item-block/config.d.ts +0 -13
  105. package/lib/list-item-block/config.d.ts.map +0 -1
  106. package/lib/list-item-block/index.d.ts +0 -6
  107. package/lib/list-item-block/index.d.ts.map +0 -1
  108. package/lib/list-item-block/view.d.ts +0 -3
  109. package/lib/list-item-block/view.d.ts.map +0 -1
  110. package/lib/table-block/config.d.ts +0 -8
  111. package/lib/table-block/config.d.ts.map +0 -1
  112. package/lib/table-block/dnd/calc-drag-over.d.ts +0 -3
  113. package/lib/table-block/dnd/calc-drag-over.d.ts.map +0 -1
  114. package/lib/table-block/dnd/create-drag-handler.d.ts +0 -5
  115. package/lib/table-block/dnd/create-drag-handler.d.ts.map +0 -1
  116. package/lib/table-block/dnd/drag-over-handler.d.ts +0 -3
  117. package/lib/table-block/dnd/drag-over-handler.d.ts.map +0 -1
  118. package/lib/table-block/dnd/prepare-dnd-context.d.ts +0 -3
  119. package/lib/table-block/dnd/prepare-dnd-context.d.ts.map +0 -1
  120. package/lib/table-block/dnd/preview.d.ts +0 -3
  121. package/lib/table-block/dnd/preview.d.ts.map +0 -1
  122. package/lib/table-block/index.d.ts +0 -5
  123. package/lib/table-block/index.d.ts.map +0 -1
  124. package/lib/table-block/view/component.d.ts +0 -16
  125. package/lib/table-block/view/component.d.ts.map +0 -1
  126. package/lib/table-block/view/drag.d.ts +0 -10
  127. package/lib/table-block/view/drag.d.ts.map +0 -1
  128. package/lib/table-block/view/index.d.ts +0 -2
  129. package/lib/table-block/view/index.d.ts.map +0 -1
  130. package/lib/table-block/view/operation.d.ts +0 -13
  131. package/lib/table-block/view/operation.d.ts.map +0 -1
  132. package/lib/table-block/view/pointer.d.ts +0 -7
  133. package/lib/table-block/view/pointer.d.ts.map +0 -1
  134. package/lib/table-block/view/types.d.ts +0 -28
  135. package/lib/table-block/view/types.d.ts.map +0 -1
  136. package/lib/table-block/view/utils.d.ts +0 -12
  137. package/lib/table-block/view/utils.d.ts.map +0 -1
  138. package/lib/table-block/view/view.d.ts +0 -22
  139. package/lib/table-block/view/view.d.ts.map +0 -1
@@ -1,8 +1,8 @@
1
1
  import { $ctx, $view } from '@jvs-milkdown/utils';
2
- import { selectColCommand, moveColCommand, selectRowCommand, moveRowCommand, mergeCellsCommand, setAlignCommand, deleteSelectedCellsCommand, addColAfterCommand, addColBeforeCommand, addRowAfterCommand, addRowBeforeCommand, tableSchema } from '@jvs-milkdown/preset-gfm';
2
+ import { selectColCommand, moveColCommand, selectRowCommand, moveRowCommand, mergeCellsCommand, setAlignCommand, deleteSelectedCellsCommand, addRowWithAlignment, tableSchema } from '@jvs-milkdown/preset-gfm';
3
3
  import { h, defineComponent, ref, onMounted, watch, onBeforeUnmount, shallowRef, createApp, triggerRef } from 'vue';
4
4
  import { computePosition, offset } from '@floating-ui/dom';
5
- import { findTable, CellSelection, selectedRect, splitCellWithType, mergeCells, splitCell } from '@jvs-milkdown/prose/tables';
5
+ import { findTable, CellSelection, selectedRect, splitCellWithType, TableMap, addColumn, mergeCells, splitCell } from '@jvs-milkdown/prose/tables';
6
6
  import clsx from 'clsx';
7
7
  import DOMPurify from 'dompurify';
8
8
  import { editorViewCtx, commandsCtx } from '@jvs-milkdown/core';
@@ -502,40 +502,52 @@ function useDragHandlers(refs, ctx, getPos) {
502
502
  }
503
503
 
504
504
  function useOperation(refs, ctx, getPos) {
505
- const { contentWrapperRef, hoverIndex } = refs;
505
+ const { hoverIndex } = refs;
506
506
  const addRowByIndex = (index) => {
507
- var _a, _b, _c;
508
507
  if (!ctx || !ctx.get(editorViewCtx).editable) return;
509
- const rows = Array.from(
510
- (_b = (_a = contentWrapperRef.value) == null ? void 0 : _a.querySelectorAll("tr")) != null ? _b : []
511
- );
512
- const commands = ctx.get(commandsCtx);
513
- const pos = ((_c = getPos == null ? void 0 : getPos()) != null ? _c : 0) + 1;
514
- if (rows.length === index) {
515
- commands.call(selectRowCommand.key, { pos, index: index - 1 });
516
- commands.call(addRowAfterCommand.key);
517
- } else {
518
- commands.call(selectRowCommand.key, { pos, index });
519
- commands.call(addRowBeforeCommand.key);
520
- }
521
- commands.call(selectRowCommand.key, { pos, index });
508
+ const view = ctx.get(editorViewCtx);
509
+ const tablePos = getPos == null ? void 0 : getPos();
510
+ if (tablePos == null) return;
511
+ const table = view.state.doc.nodeAt(tablePos);
512
+ if (!table) return;
513
+ const tableStart = tablePos + 1;
514
+ const map = TableMap.get(table);
515
+ const insertRow = Math.min(index, map.height);
516
+ const tr = view.state.tr;
517
+ const rect = {
518
+ map,
519
+ tableStart,
520
+ table,
521
+ left: 0,
522
+ right: map.width,
523
+ top: 0,
524
+ bottom: map.height
525
+ };
526
+ addRowWithAlignment(ctx, tr, rect, insertRow);
527
+ view.dispatch(tr);
522
528
  };
523
529
  const addColByIndex = (index) => {
524
- var _a, _b, _c, _d;
525
530
  if (!ctx || !ctx.get(editorViewCtx).editable) return;
526
- const cols = Array.from(
527
- (_c = (_b = (_a = contentWrapperRef.value) == null ? void 0 : _a.querySelector("tr")) == null ? void 0 : _b.children) != null ? _c : []
528
- );
529
- const commands = ctx.get(commandsCtx);
530
- const pos = ((_d = getPos == null ? void 0 : getPos()) != null ? _d : 0) + 1;
531
- if (cols.length === index) {
532
- commands.call(selectColCommand.key, { pos, index: index - 1 });
533
- commands.call(addColAfterCommand.key);
534
- } else {
535
- commands.call(selectColCommand.key, { pos, index });
536
- commands.call(addColBeforeCommand.key);
537
- }
538
- commands.call(selectColCommand.key, { pos, index });
531
+ const view = ctx.get(editorViewCtx);
532
+ const tablePos = getPos == null ? void 0 : getPos();
533
+ if (tablePos == null) return;
534
+ const table = view.state.doc.nodeAt(tablePos);
535
+ if (!table) return;
536
+ const tableStart = tablePos + 1;
537
+ const map = TableMap.get(table);
538
+ const insertCol = Math.min(index, map.width);
539
+ const tr = view.state.tr;
540
+ const rect = {
541
+ map,
542
+ tableStart,
543
+ table,
544
+ left: 0,
545
+ right: map.width,
546
+ top: 0,
547
+ bottom: map.height
548
+ };
549
+ addColumn(tr, rect, insertCol);
550
+ view.dispatch(tr);
539
551
  };
540
552
  const selectCol = () => {
541
553
  var _a;
@@ -556,6 +568,7 @@ function useOperation(refs, ctx, getPos) {
556
568
  const deleteSelected = (e) => {
557
569
  if (!ctx) return;
558
570
  if (!ctx.get(editorViewCtx).editable) return;
571
+ if (e.button !== 0) return;
559
572
  e.preventDefault();
560
573
  e.stopPropagation();
561
574
  const commands = ctx.get(commandsCtx);
@@ -567,6 +580,7 @@ function useOperation(refs, ctx, getPos) {
567
580
  const onAlign = (direction) => (e) => {
568
581
  if (!ctx) return;
569
582
  if (!ctx.get(editorViewCtx).editable) return;
583
+ if (e.button !== 0) return;
570
584
  e.preventDefault();
571
585
  e.stopPropagation();
572
586
  const commands = ctx.get(commandsCtx);
@@ -578,6 +592,7 @@ function useOperation(refs, ctx, getPos) {
578
592
  const onMergeCells = (e) => {
579
593
  if (!ctx) return;
580
594
  if (!ctx.get(editorViewCtx).editable) return;
595
+ if (e.button !== 0) return;
581
596
  e.preventDefault();
582
597
  e.stopPropagation();
583
598
  const commands = ctx.get(commandsCtx);
@@ -590,6 +605,7 @@ function useOperation(refs, ctx, getPos) {
590
605
  var _a, _b;
591
606
  if (!ctx) return;
592
607
  if (!ctx.get(editorViewCtx).editable) return;
608
+ if (e.button !== 0) return;
593
609
  e.preventDefault();
594
610
  e.stopPropagation();
595
611
  const view = ctx.get(editorViewCtx);
@@ -728,22 +744,68 @@ const TableBlock = defineComponent({
728
744
  const xLineHandleRef = ref();
729
745
  const resizingCol = ref(-1);
730
746
  const colWidths = ref([]);
747
+ const getColCount = () => {
748
+ let maxCols = 0;
749
+ node.value.forEach((row) => {
750
+ let cols = 0;
751
+ row.forEach((cell) => {
752
+ cols += cell.attrs.colspan || 1;
753
+ });
754
+ if (cols > maxCols) maxCols = cols;
755
+ });
756
+ return maxCols;
757
+ };
731
758
  const syncColWidths = () => {
732
759
  if (resizingCol.value >= 0) return;
733
- const firstRow = node.value.firstChild;
734
- if (!firstRow) return;
735
- const colCount = firstRow.content.childCount;
760
+ const colCount = getColCount();
761
+ const prevColCount = colWidths.value.length;
736
762
  const widths = [];
737
- const hasBounds = colBounds.value.length === colCount;
763
+ const hasBounds = colBounds.value.length >= colCount;
764
+ const existingNonZero = colWidths.value.filter((w) => w > 0);
765
+ const avgWidth = existingNonZero.length > 0 ? Math.round(
766
+ existingNonZero.reduce((a, b) => a + b, 0) / existingNonZero.length
767
+ ) : 0;
738
768
  for (let i = 0; i < colCount; i++) {
739
- const cell = firstRow.content.child(i);
740
- const w = cell.attrs.colwidth;
741
- if (Array.isArray(w) && w[0]) {
742
- widths.push(w[0]);
743
- } else if (hasBounds) {
744
- widths.push(Math.round(colBounds.value[i].width));
745
- } else {
746
- widths.push(0);
769
+ const isNewColumn = i >= prevColCount;
770
+ let found = false;
771
+ node.value.forEach((row) => {
772
+ if (found) return;
773
+ let colIdx = 0;
774
+ row.forEach((cell) => {
775
+ if (found) return;
776
+ const colspan = cell.attrs.colspan || 1;
777
+ const colwidth = cell.attrs.colwidth;
778
+ if (colIdx === i) {
779
+ if (colspan > 1) {
780
+ if (Array.isArray(colwidth) && colwidth.length > 0) {
781
+ const totalW = colwidth.reduce(
782
+ (sum, w) => sum + (w || 0),
783
+ 0
784
+ );
785
+ widths.push(Math.round(totalW / colspan));
786
+ } else if (!isNewColumn && hasBounds && colBounds.value[i]) {
787
+ widths.push(Math.round(colBounds.value[i].width));
788
+ } else {
789
+ widths.push(avgWidth);
790
+ }
791
+ } else {
792
+ if (Array.isArray(colwidth) && colwidth[0]) {
793
+ widths.push(colwidth[0]);
794
+ } else if (!isNewColumn && hasBounds && colBounds.value[i]) {
795
+ widths.push(Math.round(colBounds.value[i].width));
796
+ } else {
797
+ widths.push(avgWidth);
798
+ }
799
+ }
800
+ found = true;
801
+ }
802
+ colIdx += colspan;
803
+ });
804
+ });
805
+ if (!found) {
806
+ widths.push(
807
+ !isNewColumn && hasBounds && colBounds.value[i] ? Math.round(colBounds.value[i].width) : avgWidth
808
+ );
747
809
  }
748
810
  }
749
811
  colWidths.value = widths;
@@ -839,15 +901,23 @@ const TableBlock = defineComponent({
839
901
  const updateBounds = () => {
840
902
  const content = contentWrapperRef.value;
841
903
  if (!content) return;
842
- const firstRow = content.querySelector("tr");
904
+ const rows = content.querySelectorAll("tr");
843
905
  const tableRect = content.getBoundingClientRect();
844
- if (firstRow) {
845
- colBounds.value = Array.from(firstRow.children).map((c) => {
906
+ const expectedColCount = getColCount();
907
+ let bestRow = null;
908
+ rows.forEach((row) => {
909
+ if (bestRow) return;
910
+ if (row.children.length === expectedColCount) {
911
+ bestRow = row;
912
+ }
913
+ });
914
+ const measureRow = bestRow != null ? bestRow : content.querySelector("tr");
915
+ if (measureRow) {
916
+ colBounds.value = Array.from(measureRow.children).map((c) => {
846
917
  const rect = c.getBoundingClientRect();
847
918
  return { left: rect.left - tableRect.left, width: rect.width };
848
919
  });
849
920
  }
850
- const rows = content.querySelectorAll("tr");
851
921
  rowBounds.value = Array.from(rows).map((c) => {
852
922
  const rect = c.getBoundingClientRect();
853
923
  return { top: rect.top - tableRect.top, height: rect.height };
@@ -971,6 +1041,7 @@ const TableBlock = defineComponent({
971
1041
  });
972
1042
  watch(node, () => {
973
1043
  dispatchListener();
1044
+ requestAnimationFrame(updateBounds);
974
1045
  });
975
1046
  onBeforeUnmount(() => {
976
1047
  view.dom.removeEventListener("keyup", dispatchListener);
@@ -1012,7 +1083,7 @@ const TableBlock = defineComponent({
1012
1083
  contenteditable: "false",
1013
1084
  onPointerdown: (e) => e.stopPropagation()
1014
1085
  },
1015
- /* @__PURE__ */ h(
1086
+ canMerge.value ? /* @__PURE__ */ h(
1016
1087
  "button",
1017
1088
  {
1018
1089
  type: "button",
@@ -1020,8 +1091,7 @@ const TableBlock = defineComponent({
1020
1091
  onPointerdown: onMergeCells
1021
1092
  },
1022
1093
  /* @__PURE__ */ h(Icon, { icon: config.renderButton("merge_cells") })
1023
- ),
1024
- /* @__PURE__ */ h(
1094
+ ) : canSplit.value ? /* @__PURE__ */ h(
1025
1095
  "button",
1026
1096
  {
1027
1097
  type: "button",
@@ -1029,7 +1099,7 @@ const TableBlock = defineComponent({
1029
1099
  onPointerdown: onSplitCell
1030
1100
  },
1031
1101
  /* @__PURE__ */ h(Icon, { icon: config.renderButton("split_cell") })
1032
- )
1102
+ ) : void 0
1033
1103
  ),
1034
1104
  /* @__PURE__ */ h("div", { class: "table-wrapper", ref: tableWrapperRef }, /* @__PURE__ */ h("div", { contenteditable: "false", class: "fixed-handles-col" }, colBounds.value.map((bound, i) => /* @__PURE__ */ h(
1035
1105
  "div",
@@ -1060,6 +1130,7 @@ const TableBlock = defineComponent({
1060
1130
  "data-show": activeColIndex.value === i ? "true" : "false",
1061
1131
  onPointermove: (e) => e.stopPropagation()
1062
1132
  },
1133
+ canMerge.value ? /* @__PURE__ */ h("button", { type: "button", onPointerdown: onMergeCells }, /* @__PURE__ */ h(Icon, { icon: config.renderButton("merge_cells") })) : canSplit.value ? /* @__PURE__ */ h("button", { type: "button", onPointerdown: onSplitCell }, /* @__PURE__ */ h(Icon, { icon: config.renderButton("split_cell") })) : void 0,
1063
1134
  /* @__PURE__ */ h(
1064
1135
  "button",
1065
1136
  {
@@ -1103,9 +1174,7 @@ const TableBlock = defineComponent({
1103
1174
  }
1104
1175
  },
1105
1176
  /* @__PURE__ */ h(Icon, { icon: config.renderButton("delete_col") })
1106
- ),
1107
- canMerge.value && /* @__PURE__ */ h("button", { type: "button", onPointerdown: onMergeCells }, /* @__PURE__ */ h(Icon, { icon: config.renderButton("merge_cells") })),
1108
- canSplit.value && /* @__PURE__ */ h("button", { type: "button", onPointerdown: onSplitCell }, /* @__PURE__ */ h(Icon, { icon: config.renderButton("split_cell") }))
1177
+ )
1109
1178
  )
1110
1179
  ))), /* @__PURE__ */ h("div", { contenteditable: "false", class: "add-dots-col" }, [
1111
1180
  ...colBounds.value.map((b) => b.left),
@@ -1161,6 +1230,7 @@ const TableBlock = defineComponent({
1161
1230
  "data-show": activeRowIndex.value === i ? "true" : "false",
1162
1231
  onPointermove: (e) => e.stopPropagation()
1163
1232
  },
1233
+ canMerge.value ? /* @__PURE__ */ h("button", { type: "button", onPointerdown: onMergeCells }, /* @__PURE__ */ h(Icon, { icon: config.renderButton("merge_cells") })) : canSplit.value ? /* @__PURE__ */ h("button", { type: "button", onPointerdown: onSplitCell }, /* @__PURE__ */ h(Icon, { icon: config.renderButton("split_cell") })) : void 0,
1164
1234
  /* @__PURE__ */ h(
1165
1235
  "button",
1166
1236
  {
@@ -1171,9 +1241,7 @@ const TableBlock = defineComponent({
1171
1241
  }
1172
1242
  },
1173
1243
  /* @__PURE__ */ h(Icon, { icon: config.renderButton("delete_row") })
1174
- ),
1175
- canMerge.value && /* @__PURE__ */ h("button", { type: "button", onPointerdown: onMergeCells }, /* @__PURE__ */ h(Icon, { icon: config.renderButton("merge_cells") })),
1176
- canSplit.value && /* @__PURE__ */ h("button", { type: "button", onPointerdown: onSplitCell }, /* @__PURE__ */ h(Icon, { icon: config.renderButton("split_cell") }))
1244
+ )
1177
1245
  )
1178
1246
  ))), /* @__PURE__ */ h("div", { contenteditable: "false", class: "add-dots-row" }, [
1179
1247
  ...rowBounds.value.map((b) => b.top),
@@ -1217,13 +1285,16 @@ const TableBlock = defineComponent({
1217
1285
  class: "handle line-handle",
1218
1286
  ref: yLineHandleRef
1219
1287
  }
1220
- ), /* @__PURE__ */ h("table", { ref: contentWrapperFunctionRef, class: "children" }, /* @__PURE__ */ h("colgroup", null, colWidths.value.map((w, i) => /* @__PURE__ */ h(
1221
- "col",
1222
- {
1223
- key: i,
1224
- style: w > 0 ? { width: `${w}px` } : void 0
1225
- }
1226
- )))))
1288
+ ), /* @__PURE__ */ h("table", { ref: contentWrapperFunctionRef, class: "children" }, /* @__PURE__ */ h("colgroup", null, Array.from({ length: getColCount() }, (_, i) => {
1289
+ const w = colWidths.value[i];
1290
+ return /* @__PURE__ */ h(
1291
+ "col",
1292
+ {
1293
+ key: i,
1294
+ style: w && w > 0 ? { width: `${w}px` } : void 0
1295
+ }
1296
+ );
1297
+ }))))
1227
1298
  );
1228
1299
  };
1229
1300
  }