@dou-ui/editor 0.1.0-alpha.12 → 0.1.0-alpha.14

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 (94) hide show
  1. package/dist/collaboration/cursors.js +42 -10
  2. package/dist/collaboration/cursors.js.map +1 -1
  3. package/dist/collaboration/index.js +30 -3
  4. package/dist/collaboration/index.js.map +1 -1
  5. package/dist/components/block-handle.js.map +1 -1
  6. package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js +73 -15
  7. package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js.map +1 -1
  8. package/dist/components/slash-choices.js +6 -0
  9. package/dist/components/slash-choices.js.map +1 -0
  10. package/dist/components/slash-choices.vue_vue_type_script_setup_true_lang.js +56 -0
  11. package/dist/components/slash-choices.vue_vue_type_script_setup_true_lang.js.map +1 -0
  12. package/dist/components/slash-menu.js.map +1 -1
  13. package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js +185 -20
  14. package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  15. package/dist/core/block-selection.js +32 -4
  16. package/dist/core/block-selection.js.map +1 -1
  17. package/dist/core/blocks.js +21 -3
  18. package/dist/core/blocks.js.map +1 -1
  19. package/dist/core/commands.js +125 -13
  20. package/dist/core/commands.js.map +1 -1
  21. package/dist/core/extension.js +6 -2
  22. package/dist/core/extension.js.map +1 -1
  23. package/dist/core/model.js +8 -2
  24. package/dist/core/model.js.map +1 -1
  25. package/dist/core/schema.js.map +1 -1
  26. package/dist/core/transaction.js +12 -3
  27. package/dist/core/transaction.js.map +1 -1
  28. package/dist/document.js +40 -4
  29. package/dist/document.js.map +1 -1
  30. package/dist/dom.js +96 -13
  31. package/dist/dom.js.map +1 -1
  32. package/dist/editor.vue_vue_type_script_setup_true_lang.js +3 -3
  33. package/dist/editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
  34. package/dist/editor2.js.map +1 -1
  35. package/dist/extensions/columns/column-picker.js +6 -0
  36. package/dist/extensions/columns/column-picker.js.map +1 -0
  37. package/dist/extensions/columns/column-picker.vue_vue_type_script_setup_true_lang.js +57 -0
  38. package/dist/extensions/columns/column-picker.vue_vue_type_script_setup_true_lang.js.map +1 -0
  39. package/dist/extensions/columns/columns-controls.js +6 -0
  40. package/dist/extensions/columns/columns-controls.js.map +1 -0
  41. package/dist/extensions/columns/columns-controls.vue_vue_type_script_setup_true_lang.js +341 -0
  42. package/dist/extensions/columns/columns-controls.vue_vue_type_script_setup_true_lang.js.map +1 -0
  43. package/dist/extensions/columns/html.js +34 -0
  44. package/dist/extensions/columns/html.js.map +1 -0
  45. package/dist/extensions/columns/index.js +57 -0
  46. package/dist/extensions/columns/index.js.map +1 -0
  47. package/dist/extensions/columns/keys.js +53 -0
  48. package/dist/extensions/columns/keys.js.map +1 -0
  49. package/dist/extensions/columns/plugin.js +213 -0
  50. package/dist/extensions/columns/plugin.js.map +1 -0
  51. package/dist/extensions/columns/schema.js +58 -0
  52. package/dist/extensions/columns/schema.js.map +1 -0
  53. package/dist/extensions/columns/select-columns.js +6 -0
  54. package/dist/extensions/columns/select-columns.js.map +1 -0
  55. package/dist/extensions/columns/select-columns.vue_vue_type_script_setup_true_lang.js +71 -0
  56. package/dist/extensions/columns/select-columns.vue_vue_type_script_setup_true_lang.js.map +1 -0
  57. package/dist/extensions/editor-kit.js +3 -1
  58. package/dist/extensions/editor-kit.js.map +1 -1
  59. package/dist/extensions/table/plugin.js +33 -1
  60. package/dist/extensions/table/plugin.js.map +1 -1
  61. package/dist/extensions/table/table-controls.js.map +1 -1
  62. package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js +1 -1
  63. package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js.map +1 -1
  64. package/dist/extensions/table/view.js +25 -1
  65. package/dist/extensions/table/view.js.map +1 -1
  66. package/dist/index.js +3 -2
  67. package/dist/index.js.map +1 -1
  68. package/dist/locale.js +30 -0
  69. package/dist/locale.js.map +1 -1
  70. package/dist/style.css +1 -1
  71. package/dist/types/collaboration/cursors.d.ts +29 -1
  72. package/dist/types/collaboration/index.d.ts +17 -2
  73. package/dist/types/components/slash-choices.vue.d.ts +18 -0
  74. package/dist/types/core/blocks.d.ts +10 -0
  75. package/dist/types/core/commands.d.ts +17 -2
  76. package/dist/types/core/extension.d.ts +53 -2
  77. package/dist/types/core/model.d.ts +6 -1
  78. package/dist/types/core/schema.d.ts +1 -1
  79. package/dist/types/document.d.ts +4 -2
  80. package/dist/types/dom.d.ts +34 -4
  81. package/dist/types/editor.vue.d.ts +10 -0
  82. package/dist/types/extensions/columns/column-picker.vue.d.ts +10 -0
  83. package/dist/types/extensions/columns/columns-controls.vue.d.ts +3 -0
  84. package/dist/types/extensions/columns/html.d.ts +10 -0
  85. package/dist/types/extensions/columns/index.d.ts +9 -0
  86. package/dist/types/extensions/columns/keys.d.ts +6 -0
  87. package/dist/types/extensions/columns/plugin.d.ts +28 -0
  88. package/dist/types/extensions/columns/schema.d.ts +17 -0
  89. package/dist/types/extensions/columns/select-columns.vue.d.ts +13 -0
  90. package/dist/types/extensions/editor-kit.d.ts +4 -1
  91. package/dist/types/extensions/table/view.d.ts +8 -1
  92. package/dist/types/index.d.ts +12 -2
  93. package/dist/types/locale.d.ts +17 -0
  94. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"table-controls.js","names":["_sfc_main"],"sources":["../../../src/extensions/table/table-controls.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n ArrowDownFromLineIcon,\n ArrowDownIcon,\n ArrowLeftIcon,\n ArrowLeftToLineIcon,\n ArrowRightIcon,\n ArrowRightToLineIcon,\n ArrowUpIcon,\n ArrowUpToLineIcon,\n CheckIcon,\n EraserIcon,\n GripHorizontalIcon,\n GripVerticalIcon,\n LayoutColumnsIcon,\n LayoutRowsIcon,\n MergeIcon,\n PlusIcon,\n SplitIcon,\n TextAlignCenterIcon,\n TextAlignLeftIcon,\n TextAlignRightIcon,\n TrashIcon,\n} from '@dou-ui/icons'\nimport { DouDropdown, DouDropdownItem, DouDropdownSub } from 'dou-ui'\nimport { TextSelection, type Command } from 'prosemirror-state'\nimport { CellSelection, TableMap, addColumn, addRow, type Rect } from 'prosemirror-tables'\nimport { computed, onBeforeUnmount, onMounted, shallowRef, watch } from 'vue'\nimport { createId } from '../../core/model'\nimport { useMenuEscape } from '../../components/menu-escape'\nimport { useEditor } from '../../editor'\nimport {\n alignColumns,\n band,\n boundaries,\n clearCells,\n deleteColumns,\n deleteRows,\n inMergedCell,\n insertColumn,\n insertRow,\n mergeCells,\n moveLines,\n moveLinesTo,\n selectLines,\n splitMergedCell,\n tableAt,\n toggleHeader,\n} from './commands'\nimport { fitColumns, type TableAlign } from './schema'\n\nconst { view, state, root, messages } = useEditor()\n\n/** The table and the cell the controls are about: the hovered one, or the selection's. */\ninterface Target {\n /** Position right before the table node. */\n pos: number\n /** The cell's place in the grid. */\n rect: Rect\n}\n\nconst hovered = shallowRef<Target | null>(null)\nconst columnMenu = shallowRef(false)\nconst rowMenu = shallowRef(false)\nconst menuOpen = computed(() => columnMenu.value || rowMenu.value)\nuseMenuEscape(menuOpen, () => {\n columnMenu.value = false\n rowMenu.value = false\n})\nconst barShown = computed(() => !!layout.value?.bar && !menuOpen.value && !dragging.value)\n// the toolbar over selected cells stands in for the handles; a merged cell's goes below it\nconst handlesHidden = computed(() => barShown.value && hasCellSelection.value)\n\nfunction targetOf(cell: HTMLElement): Target | null {\n const current = view.value\n if (!current || !current.dom.contains(cell)) return null\n const $pos = current.state.doc.resolve(current.posAtDOM(cell, 0))\n const found = tableAt($pos)\n if (!found) return null\n // the cell node starts right before its content\n for (let depth = $pos.depth; depth > 0; depth--) {\n const role = $pos.node(depth).type.spec.tableRole\n if (role === 'cell' || role === 'header_cell') {\n const cellPos = $pos.before(depth) - found.pos - 1\n return { pos: found.pos, rect: found.map.findCell(cellPos) }\n }\n }\n return null\n}\n\n/** The selection's cell when the pointer is elsewhere. */\nconst selected = computed<Target | null>(() => {\n const current = state.value\n if (!current) return null\n const selection = current.selection\n const $cell = selection instanceof CellSelection ? selection.$headCell : null\n const found = tableAt(selection.$head)\n if (!found) return null\n const start = found.pos + 1\n if ($cell) return { pos: found.pos, rect: found.map.findCell($cell.pos - start) }\n for (let depth = selection.$head.depth; depth > 0; depth--) {\n const role = selection.$head.node(depth).type.spec.tableRole\n if (role === 'cell' || role === 'header_cell')\n return { pos: found.pos, rect: found.map.findCell(selection.$head.before(depth) - start) }\n }\n return null\n})\n\nconst target = computed(() => hovered.value ?? selected.value)\n\n/* where things go */\n\ninterface Layout {\n /** The table, relative to the editor. */\n table: { top: number; left: number; width: number; height: number }\n /** The visible part of the table, when it scrolls sideways. */\n frame: { left: number; right: number }\n column: { left: number; width: number }\n row: { top: number; height: number }\n /**\n * Where the cell toolbar goes (its centre): above selected cells, or below\n * the merged cell with the cursor.\n */\n bar: { top: number; left: number; below: boolean } | null\n}\n\nconst layout = shallowRef<Layout | null>(null)\n\nfunction cellElement(tablePos: number, row: number, col: number): HTMLElement | null {\n const current = view.value\n const table = current?.state.doc.nodeAt(tablePos)\n if (!current || !table) return null\n const map = TableMap.get(table)\n if (row >= map.height || col >= map.width) return null\n const pos = tablePos + 1 + map.map[row * map.width + col]!\n return current.nodeDOM(pos) as HTMLElement | null\n}\n\nfunction measure() {\n const current = view.value\n const host = root.value\n const at = target.value\n if (!current || !host || !at) return (layout.value = null)\n const tableNode = current.state.doc.nodeAt(at.pos)\n const frameElement = current.nodeDOM(at.pos) as HTMLElement | null\n const tableElement = frameElement?.querySelector('table')\n if (!tableNode || !frameElement || !tableElement) return (layout.value = null)\n const box = host.getBoundingClientRect()\n const tableBox = tableElement.getBoundingClientRect()\n const frameBox = frameElement.getBoundingClientRect()\n const first = cellElement(at.pos, at.rect.top, at.rect.left)?.getBoundingClientRect()\n if (!first) return (layout.value = null)\n let bar: Layout['bar'] = null\n const boxes = barCells(current).map((pos) =>\n (current.nodeDOM(pos) as HTMLElement).getBoundingClientRect(),\n )\n if (boxes.length) {\n const left = Math.max(Math.min(...boxes.map((item) => item.left)), frameBox.left)\n const right = Math.min(Math.max(...boxes.map((item) => item.right)), frameBox.right)\n const below = !(current.state.selection instanceof CellSelection)\n bar = {\n top: below\n ? Math.max(...boxes.map((item) => item.bottom)) - box.top\n : Math.min(...boxes.map((item) => item.top)) - box.top,\n left: (left + right) / 2 - box.left,\n below,\n }\n }\n layout.value = {\n table: {\n top: tableBox.top - box.top,\n left: tableBox.left - box.left,\n width: tableBox.width,\n height: tableBox.height,\n },\n frame: { left: frameBox.left - box.left, right: frameBox.right - box.left },\n column: { left: first.left - box.left, width: first.width },\n row: { top: first.top - box.top, height: first.height },\n bar,\n }\n}\n\n/** The cells the toolbar is about: a cell selection's corners, or the merged cell with the cursor. */\nfunction barCells(current: NonNullable<typeof view.value>): number[] {\n const selection = current.state.selection\n if (selection instanceof CellSelection)\n return selection.$anchorCell.pos === selection.$headCell.pos\n ? []\n : [selection.$anchorCell.pos, selection.$headCell.pos]\n if (!inMergedCell(current.state)) return []\n const $head = selection.$head\n for (let depth = $head.depth; depth > 0; depth--) {\n const role = $head.node(depth).type.spec.tableRole\n if (role === 'cell' || role === 'header_cell') return [$head.before(depth)]\n }\n return []\n}\n\nlet frame = 0\nlet lastTarget: EventTarget | null = null\n\nfunction schedule() {\n if (frame) return\n frame = requestAnimationFrame(() => {\n frame = 0\n if (!menuOpen.value && !dragging.value) {\n const element = lastTarget instanceof Element ? lastTarget : null\n const cell = element?.closest<HTMLElement>('.dou-editor-table td, .dou-editor-table th')\n const inControls = element?.closest('.dou-editor-table-controls')\n if (cell) hovered.value = targetOf(cell)\n else if (!inControls) hovered.value = null\n }\n measure()\n })\n}\n\nfunction track(event: PointerEvent) {\n if (event.pointerType === 'touch') return\n lastTarget = event.target\n schedule()\n}\n\nfunction leave() {\n if (menuOpen.value || dragging.value) return\n lastTarget = null\n hovered.value = null\n schedule()\n}\n\nconst onScroll = () => schedule()\n\nonMounted(() => {\n root.value?.addEventListener('pointermove', track)\n root.value?.addEventListener('pointerleave', leave)\n // the table frame scrolls sideways; the page scrolls too\n window.addEventListener('scroll', onScroll, true)\n window.addEventListener('resize', onScroll)\n})\nonBeforeUnmount(() => {\n root.value?.removeEventListener('pointermove', track)\n root.value?.removeEventListener('pointerleave', leave)\n window.removeEventListener('scroll', onScroll, true)\n window.removeEventListener('resize', onScroll)\n if (frame) cancelAnimationFrame(frame)\n endDrag(false)\n})\n\nwatch([state, target], () => schedule())\n\n/* actions */\n\nfunction run(command: Command) {\n const current = view.value\n if (!current) return\n command(current.state, current.dispatch)\n current.focus()\n}\n\nfunction openMenu(axis: 'row' | 'column', pressed: Drag) {\n // the lines pressed on, even if the handles moved since\n const current = view.value\n if (!current) return\n current.dispatch(\n selectLines(current.state.tr, pressed.tablePos, axis, pressed.start, pressed.end),\n )\n // one menu at a time\n rowMenu.value = axis === 'row'\n columnMenu.value = axis === 'column'\n}\n\n/**\n * Whole lines are selected to show what a menu or a drag is about; after\n * it, the cursor goes into their first cell so the handles come back.\n */\nfunction collapseLines() {\n const current = view.value\n const selection = current?.state.selection\n if (!current || !(selection instanceof CellSelection)) return\n if (!selection.isRowSelection() && !selection.isColSelection()) return\n const $cell = current.state.doc.resolve(selection.$anchorCell.pos + 1)\n current.dispatch(current.state.tr.setSelection(TextSelection.near($cell)))\n}\n\nwatch(menuOpen, (open) => {\n if (open) return\n collapseLines()\n schedule()\n})\n\nconst can = (command: Command) => {\n const current = state.value\n return !!current && command(current)\n}\n\nconst tableNode = computed(() => {\n const at = target.value\n return at ? (state.value?.doc.nodeAt(at.pos) ?? null) : null\n})\n\nconst columnAlign = computed<TableAlign>(() => {\n const node = tableNode.value\n const at = target.value\n if (!node || !at) return 'left'\n return (fitColumns(node.attrs.columns, TableMap.get(node).width)[at.rect.left]?.align ??\n 'left') as TableAlign\n})\n\nconst aligns: { value: TableAlign; icon: unknown; label: () => string }[] = [\n { value: 'left', icon: TextAlignLeftIcon, label: () => messages.value.table.alignLeft },\n { value: 'center', icon: TextAlignCenterIcon, label: () => messages.value.table.alignCenter },\n { value: 'right', icon: TextAlignRightIcon, label: () => messages.value.table.alignRight },\n]\n\n/** The + bars: a column at the right end, a row at the bottom. */\nfunction addAtEnd(axis: 'row' | 'column') {\n const current = view.value\n const at = target.value\n if (!current || !at) return\n const table = current.state.doc.nodeAt(at.pos)!\n const map = TableMap.get(table)\n const rect = {\n left: 0,\n top: 0,\n right: map.width,\n bottom: map.height,\n map,\n table,\n tableStart: at.pos + 1,\n }\n let tr = current.state.tr\n if (axis === 'row') tr = addRow(tr, rect, map.height)\n else {\n const columns = fitColumns(table.attrs.columns, map.width)\n columns.push({ id: createId() })\n tr = addColumn(tr, rect, map.width).setNodeAttribute(at.pos, 'columns', columns)\n }\n current.dispatch(tr)\n}\n\n/* dragging rows and columns by their handle */\n\ninterface Drag {\n axis: 'row' | 'column'\n tablePos: number\n /** The lines that move: the target's, with any merged cells they belong to. */\n start: number\n end: number\n x: number\n y: number\n /** Where they go: the line they go before, or `null` for where they are. */\n to: number | null\n}\n\nlet drag: Drag | null = null\nconst dragging = shallowRef(false)\nconst drop = shallowRef<{ axis: 'row' | 'column'; at: number } | null>(null)\n/** A copy of the dragged lines that follows the pointer. */\nlet ghost: HTMLElement | null = null\n\nfunction onHandleDown(axis: 'row' | 'column', event: PointerEvent) {\n const current = view.value\n const at = target.value\n if (event.button !== 0 || !current || !at || !current.editable) return\n const map = TableMap.get(current.state.doc.nodeAt(at.pos)!)\n const [from, to] = axis === 'row' ? [at.rect.top, at.rect.bottom] : [at.rect.left, at.rect.right]\n const lines = band(map, axis, from, to)\n drag = { axis, tablePos: at.pos, ...lines, x: event.clientX, y: event.clientY, to: null }\n window.addEventListener('pointermove', onDragMove)\n window.addEventListener('pointerup', onDragUp)\n window.addEventListener('pointercancel', onDragCancel)\n}\n\n/** Each boundary a run can go to, and where it is (relative to the editor). */\nfunction cutPlaces(moving: Drag): { cut: number; at: number }[] {\n const current = view.value\n const host = root.value\n const table = current?.state.doc.nodeAt(moving.tablePos)\n const element = (current?.nodeDOM(moving.tablePos) as HTMLElement | null)?.querySelector('table')\n if (!current || !host || !table || !element) return []\n const box = host.getBoundingClientRect()\n const tableBox = element.getBoundingClientRect()\n const map = TableMap.get(table)\n const places: { cut: number; at: number }[] = []\n if (moving.axis === 'row') {\n const tops: number[] = []\n table.forEach((_row, offset) => {\n const row = current.nodeDOM(moving.tablePos + 1 + offset) as HTMLElement | null\n tops.push((row?.getBoundingClientRect().top ?? tableBox.top) - box.top)\n })\n for (const cut of boundaries(map, 'row'))\n places.push({ cut, at: cut < map.height ? tops[cut]! : tableBox.bottom - box.top })\n return places\n }\n for (const cut of boundaries(map, 'column')) {\n if (cut === map.width) {\n places.push({ cut, at: tableBox.right - box.left })\n continue\n }\n // no merged cell crosses a boundary, so the first row has a cell starting there\n let row = 0\n while (row < map.height && map.findCell(map.map[row * map.width + cut]!).left !== cut) row++\n const cell = cellElement(moving.tablePos, row, cut)\n if (cell) places.push({ cut, at: cell.getBoundingClientRect().left - box.left })\n }\n return places\n}\n\nfunction showGhost(moving: Drag) {\n const current = view.value\n const host = root.value\n const table = current?.state.doc.nodeAt(moving.tablePos)\n const element = (current?.nodeDOM(moving.tablePos) as HTMLElement | null)?.querySelector('table')\n if (!current || !host || !table || !element) return\n const map = TableMap.get(table)\n const copy = document.createElement('table')\n copy.className = 'dou-editor-table'\n const body = document.createElement('tbody')\n copy.append(body)\n let width = 0\n const [rows, cols] =\n moving.axis === 'row'\n ? [\n [moving.start, moving.end],\n [0, map.width],\n ]\n : [\n [0, map.height],\n [moving.start, moving.end],\n ]\n for (let row = rows[0]!; row < rows[1]!; row++) {\n const line = document.createElement('tr')\n let lineWidth = 0\n for (let col = cols[0]!; col < cols[1]!; col++) {\n const rect = map.findCell(map.map[row * map.width + col]!)\n if (rect.top !== row || rect.left !== col) continue\n const cell = cellElement(moving.tablePos, row, col)\n if (!cell) continue\n const clone = cell.cloneNode(true) as HTMLElement\n clone.classList.remove('selectedCell')\n clone.style.width = `${cell.getBoundingClientRect().width}px`\n lineWidth += cell.getBoundingClientRect().width\n line.append(clone)\n }\n width = Math.max(width, lineWidth)\n body.append(line)\n }\n ghost = document.createElement('div')\n ghost.className = 'dou-editor__surface dou-editor__ghost dou-editor-table__ghost'\n ghost.setAttribute('aria-hidden', 'true')\n ghost.style.width = `${Math.min(width, 360) + 2}px`\n ghost.append(copy)\n host.append(ghost)\n}\n\nfunction onDragMove(event: PointerEvent) {\n const moving = drag\n if (!moving) return\n if (!dragging.value) {\n if (Math.hypot(event.clientX - moving.x, event.clientY - moving.y) < 4) return\n dragging.value = true\n columnMenu.value = false\n rowMenu.value = false\n const current = view.value\n if (current)\n current.dispatch(\n selectLines(current.state.tr, moving.tablePos, moving.axis, moving.start, moving.end),\n )\n showGhost(moving)\n }\n if (ghost) ghost.style.transform = `translate(${event.clientX + 12}px, ${event.clientY + 12}px)`\n const host = root.value\n if (!host) return\n const box = host.getBoundingClientRect()\n const pointer = moving.axis === 'row' ? event.clientY - box.top : event.clientX - box.left\n let best: { cut: number; at: number } | null = null\n for (const place of cutPlaces(moving))\n if (!best || Math.abs(place.at - pointer) < Math.abs(best.at - pointer)) best = place\n // a boundary of the run itself leaves it where it is\n if (!best || (best.cut >= moving.start && best.cut <= moving.end)) {\n moving.to = null\n drop.value = null\n return\n }\n moving.to = best.cut\n drop.value = { axis: moving.axis, at: best.at }\n}\n\nfunction onDragUp() {\n endDrag(true)\n}\n\nfunction onDragCancel() {\n endDrag(false)\n}\n\nfunction endDrag(apply: boolean) {\n window.removeEventListener('pointermove', onDragMove)\n window.removeEventListener('pointerup', onDragUp)\n window.removeEventListener('pointercancel', onDragCancel)\n const moving = drag\n drag = null\n ghost?.remove()\n ghost = null\n drop.value = null\n if (!dragging.value) {\n // a press without a drag opens the menu; on release rather than on\n // click, as the press may close another menu and move the handles\n if (apply && moving) openMenu(moving.axis, moving)\n return\n }\n dragging.value = false\n if (apply && moving?.to !== null && moving)\n run(moveLinesTo(moving.tablePos, moving.axis, moving.start, moving.end, moving.to))\n collapseLines()\n schedule()\n}\n\nconst hasCellSelection = computed(() => {\n const selection = state.value?.selection\n return selection instanceof CellSelection && selection.$anchorCell.pos !== selection.$headCell.pos\n})\n\nconst visible = computed(() => !!layout.value && !!target.value)\n</script>\n\n<template>\n <div v-if=\"visible && layout\" class=\"dou-editor-table-controls\" @mousedown.prevent>\n <!-- column handle, above the column -->\n <DouDropdown\n v-model:open=\"columnMenu\"\n trigger=\"manual\"\n placement=\"bottom-start\"\n class=\"dou-editor-menu\"\n >\n <button\n type=\"button\"\n tabindex=\"-1\"\n v-show=\"!handlesHidden\"\n class=\"dou-editor-table__handle is-column\"\n :class=\"{ 'is-active': columnMenu }\"\n :style=\"{\n top: `${layout.table.top}px`,\n left: `${Math.min(Math.max(layout.column.left + layout.column.width / 2, layout.frame.left + 12), layout.frame.right - 12)}px`,\n }\"\n :aria-label=\"messages.table.column\"\n :title=\"messages.table.column\"\n @pointerdown=\"onHandleDown('column', $event)\"\n >\n <GripHorizontalIcon />\n </button>\n <template #menu>\n <DouDropdownItem @click=\"run(insertColumn('before'))\">\n <template #prefix><ArrowLeftToLineIcon /></template>\n {{ messages.table.insertLeft }}\n </DouDropdownItem>\n <DouDropdownItem @click=\"run(insertColumn('after'))\">\n <template #prefix><ArrowRightToLineIcon /></template>\n {{ messages.table.insertRight }}\n </DouDropdownItem>\n <DouDropdownItem\n divided\n :disabled=\"!can(moveLines('column', -1))\"\n @click=\"run(moveLines('column', -1))\"\n >\n <template #prefix><ArrowLeftIcon /></template>\n {{ messages.table.moveLeft }}\n </DouDropdownItem>\n <DouDropdownItem\n :disabled=\"!can(moveLines('column', 1))\"\n @click=\"run(moveLines('column', 1))\"\n >\n <template #prefix><ArrowRightIcon /></template>\n {{ messages.table.moveRight }}\n </DouDropdownItem>\n <DouDropdownSub divided :title=\"aligns.find((item) => item.value === columnAlign)!.label()\">\n <template #prefix>\n <component :is=\"aligns.find((item) => item.value === columnAlign)!.icon\" />\n </template>\n <DouDropdownItem\n v-for=\"item in aligns\"\n :key=\"item.value\"\n @click=\"run(alignColumns(item.value))\"\n >\n <template #prefix><component :is=\"item.icon\" /></template>\n {{ item.label() }}\n <template v-if=\"item.value === columnAlign\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n </DouDropdownSub>\n <DouDropdownItem v-if=\"target?.rect.left === 0\" @click=\"run(toggleHeader('headerColumn'))\">\n <template #prefix><LayoutColumnsIcon /></template>\n {{ messages.table.headerColumn }}\n <template v-if=\"tableNode?.attrs.headerColumn\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n <DouDropdownItem divided @click=\"run(clearCells)\">\n <template #prefix><EraserIcon /></template>\n {{ messages.table.clear }}\n </DouDropdownItem>\n <DouDropdownItem tone=\"danger\" :disabled=\"!can(deleteColumns)\" @click=\"run(deleteColumns)\">\n <template #prefix><TrashIcon /></template>\n {{ messages.table.deleteColumn }}\n </DouDropdownItem>\n </template>\n </DouDropdown>\n\n <!-- row handle, left of the row -->\n <DouDropdown\n v-model:open=\"rowMenu\"\n trigger=\"manual\"\n placement=\"right-start\"\n class=\"dou-editor-menu\"\n >\n <button\n type=\"button\"\n tabindex=\"-1\"\n v-show=\"!handlesHidden\"\n class=\"dou-editor-table__handle is-row\"\n :class=\"{ 'is-active': rowMenu }\"\n :style=\"{\n top: `${layout.row.top + layout.row.height / 2}px`,\n left: `${layout.frame.left}px`,\n }\"\n :aria-label=\"messages.table.row\"\n :title=\"messages.table.row\"\n @pointerdown=\"onHandleDown('row', $event)\"\n >\n <GripVerticalIcon />\n </button>\n <template #menu>\n <DouDropdownItem @click=\"run(insertRow('before'))\">\n <template #prefix><ArrowUpToLineIcon /></template>\n {{ messages.table.insertAbove }}\n </DouDropdownItem>\n <DouDropdownItem @click=\"run(insertRow('after'))\">\n <template #prefix><ArrowDownFromLineIcon /></template>\n {{ messages.table.insertBelow }}\n </DouDropdownItem>\n <DouDropdownItem\n divided\n :disabled=\"!can(moveLines('row', -1))\"\n @click=\"run(moveLines('row', -1))\"\n >\n <template #prefix><ArrowUpIcon /></template>\n {{ messages.table.moveUp }}\n </DouDropdownItem>\n <DouDropdownItem :disabled=\"!can(moveLines('row', 1))\" @click=\"run(moveLines('row', 1))\">\n <template #prefix><ArrowDownIcon /></template>\n {{ messages.table.moveDown }}\n </DouDropdownItem>\n <DouDropdownItem\n v-if=\"target?.rect.top === 0\"\n divided\n @click=\"run(toggleHeader('headerRow'))\"\n >\n <template #prefix><LayoutRowsIcon /></template>\n {{ messages.table.headerRow }}\n <template v-if=\"tableNode?.attrs.headerRow\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n <DouDropdownItem divided @click=\"run(clearCells)\">\n <template #prefix><EraserIcon /></template>\n {{ messages.table.clear }}\n </DouDropdownItem>\n <DouDropdownItem tone=\"danger\" :disabled=\"!can(deleteRows)\" @click=\"run(deleteRows)\">\n <template #prefix><TrashIcon /></template>\n {{ messages.table.deleteRow }}\n </DouDropdownItem>\n </template>\n </DouDropdown>\n\n <!-- + bars -->\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__add is-column\"\n :style=\"{\n top: `${layout.table.top}px`,\n left: `${Math.min(layout.table.left + layout.table.width, layout.frame.right)}px`,\n height: `${layout.table.height}px`,\n }\"\n :aria-label=\"messages.table.addColumn\"\n :title=\"messages.table.addColumn\"\n @click=\"addAtEnd('column')\"\n >\n <PlusIcon />\n </button>\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__add is-row\"\n :style=\"{\n top: `${layout.table.top + layout.table.height}px`,\n left: `${layout.frame.left}px`,\n width: `${Math.min(layout.table.left + layout.table.width, layout.frame.right) - layout.frame.left}px`,\n }\"\n :aria-label=\"messages.table.addRow\"\n :title=\"messages.table.addRow\"\n @click=\"addAtEnd('row')\"\n >\n <PlusIcon />\n </button>\n\n <!-- where dragged lines go -->\n <div\n v-if=\"drop\"\n class=\"dou-editor__drop\"\n :class=\"{ 'is-vertical': drop.axis === 'column' }\"\n :style=\"\n drop.axis === 'row'\n ? {\n top: `${drop.at}px`,\n left: `${layout.frame.left}px`,\n width: `${Math.min(layout.table.left + layout.table.width, layout.frame.right) - layout.frame.left}px`,\n }\n : {\n top: `${layout.table.top}px`,\n left: `${drop.at}px`,\n height: `${layout.table.height}px`,\n }\n \"\n />\n\n <!-- cells: merge, unmerge, clear -->\n <div\n v-if=\"barShown && layout.bar && !dragging\"\n class=\"dou-editor-table__cells\"\n :class=\"{ 'is-below': layout.bar.below }\"\n :style=\"{ top: `${layout.bar.top}px`, left: `${layout.bar.left}px` }\"\n >\n <button\n v-if=\"hasCellSelection\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__cells-button\"\n :disabled=\"!can(mergeCells)\"\n @click=\"run(mergeCells)\"\n >\n <MergeIcon />{{ messages.table.merge }}\n </button>\n <button\n v-if=\"can(splitMergedCell)\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__cells-button\"\n @click=\"run(splitMergedCell)\"\n >\n <SplitIcon />{{ messages.table.split }}\n </button>\n <button\n v-if=\"hasCellSelection\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__cells-button\"\n :aria-label=\"messages.table.clear\"\n :title=\"messages.table.clear\"\n @click=\"run(clearCells)\"\n >\n <EraserIcon />\n </button>\n </div>\n </div>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"table-controls.js","names":["_sfc_main"],"sources":["../../../src/extensions/table/table-controls.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n ArrowDownFromLineIcon,\n ArrowDownIcon,\n ArrowLeftIcon,\n ArrowLeftToLineIcon,\n ArrowRightIcon,\n ArrowRightToLineIcon,\n ArrowUpIcon,\n ArrowUpToLineIcon,\n CheckIcon,\n EraserIcon,\n GripHorizontalIcon,\n GripVerticalIcon,\n LayoutColumnsIcon,\n LayoutRowsIcon,\n MergeIcon,\n PlusIcon,\n SplitIcon,\n TextAlignCenterIcon,\n TextAlignLeftIcon,\n TextAlignRightIcon,\n TrashIcon,\n} from '@dou-ui/icons'\nimport { DouDropdown, DouDropdownItem, DouDropdownSub } from 'dou-ui'\nimport { TextSelection, type Command } from 'prosemirror-state'\nimport { CellSelection, TableMap, addColumn, addRow, type Rect } from 'prosemirror-tables'\nimport { computed, onBeforeUnmount, onMounted, shallowRef, watch } from 'vue'\nimport { createId } from '../../core/model'\nimport { useMenuEscape } from '../../components/menu-escape'\nimport { useEditor } from '../../editor'\nimport {\n alignColumns,\n band,\n boundaries,\n clearCells,\n deleteColumns,\n deleteRows,\n inMergedCell,\n insertColumn,\n insertRow,\n mergeCells,\n moveLines,\n moveLinesTo,\n selectLines,\n splitMergedCell,\n tableAt,\n toggleHeader,\n} from './commands'\nimport { fitColumns, type TableAlign } from './schema'\n\nconst { view, state, root, messages } = useEditor()\n\n/** The table and the cell the controls are about: the hovered one, or the selection's. */\ninterface Target {\n /** Position right before the table node. */\n pos: number\n /** The cell's place in the grid. */\n rect: Rect\n}\n\nconst hovered = shallowRef<Target | null>(null)\nconst columnMenu = shallowRef(false)\nconst rowMenu = shallowRef(false)\nconst menuOpen = computed(() => columnMenu.value || rowMenu.value)\nuseMenuEscape(menuOpen, () => {\n columnMenu.value = false\n rowMenu.value = false\n})\nconst barShown = computed(() => !!layout.value?.bar && !menuOpen.value && !dragging.value)\n// the toolbar over selected cells stands in for the handles; a merged cell's goes below it\nconst handlesHidden = computed(() => barShown.value && hasCellSelection.value)\n\nfunction targetOf(cell: HTMLElement): Target | null {\n const current = view.value\n if (!current || !current.dom.contains(cell)) return null\n const $pos = current.state.doc.resolve(current.posAtDOM(cell, 0))\n const found = tableAt($pos)\n if (!found) return null\n // the cell node starts right before its content\n for (let depth = $pos.depth; depth > 0; depth--) {\n const role = $pos.node(depth).type.spec.tableRole\n if (role === 'cell' || role === 'header_cell') {\n const cellPos = $pos.before(depth) - found.pos - 1\n return { pos: found.pos, rect: found.map.findCell(cellPos) }\n }\n }\n return null\n}\n\n/** The selection's cell when the pointer is elsewhere. */\nconst selected = computed<Target | null>(() => {\n const current = state.value\n if (!current) return null\n const selection = current.selection\n const $cell = selection instanceof CellSelection ? selection.$headCell : null\n const found = tableAt(selection.$head)\n if (!found) return null\n const start = found.pos + 1\n if ($cell) return { pos: found.pos, rect: found.map.findCell($cell.pos - start) }\n for (let depth = selection.$head.depth; depth > 0; depth--) {\n const role = selection.$head.node(depth).type.spec.tableRole\n if (role === 'cell' || role === 'header_cell')\n return { pos: found.pos, rect: found.map.findCell(selection.$head.before(depth) - start) }\n }\n return null\n})\n\nconst target = computed(() => hovered.value ?? selected.value)\n\n/* where things go */\n\ninterface Layout {\n /** The table, relative to the editor. */\n table: { top: number; left: number; width: number; height: number }\n /** The visible part of the table, when it scrolls sideways. */\n frame: { left: number; right: number }\n column: { left: number; width: number }\n row: { top: number; height: number }\n /**\n * Where the cell toolbar goes (its centre): above selected cells, or below\n * the merged cell with the cursor.\n */\n bar: { top: number; left: number; below: boolean } | null\n}\n\nconst layout = shallowRef<Layout | null>(null)\n\nfunction cellElement(tablePos: number, row: number, col: number): HTMLElement | null {\n const current = view.value\n const table = current?.state.doc.nodeAt(tablePos)\n if (!current || !table) return null\n const map = TableMap.get(table)\n if (row >= map.height || col >= map.width) return null\n const pos = tablePos + 1 + map.map[row * map.width + col]!\n return current.nodeDOM(pos) as HTMLElement | null\n}\n\nfunction measure() {\n const current = view.value\n const host = root.value\n const at = target.value\n if (!current || !host || !at) return (layout.value = null)\n const tableNode = current.state.doc.nodeAt(at.pos)\n const frameElement = current.nodeDOM(at.pos) as HTMLElement | null\n const tableElement = frameElement?.querySelector('table')\n if (!tableNode || !frameElement || !tableElement) return (layout.value = null)\n const box = host.getBoundingClientRect()\n const tableBox = tableElement.getBoundingClientRect()\n const frameBox = frameElement.getBoundingClientRect()\n const first = cellElement(at.pos, at.rect.top, at.rect.left)?.getBoundingClientRect()\n if (!first) return (layout.value = null)\n let bar: Layout['bar'] = null\n const boxes = barCells(current).map((pos) =>\n (current.nodeDOM(pos) as HTMLElement).getBoundingClientRect(),\n )\n if (boxes.length) {\n const left = Math.max(Math.min(...boxes.map((item) => item.left)), frameBox.left)\n const right = Math.min(Math.max(...boxes.map((item) => item.right)), frameBox.right)\n const below = !(current.state.selection instanceof CellSelection)\n bar = {\n top: below\n ? Math.max(...boxes.map((item) => item.bottom)) - box.top\n : Math.min(...boxes.map((item) => item.top)) - box.top,\n left: (left + right) / 2 - box.left,\n below,\n }\n }\n layout.value = {\n table: {\n top: tableBox.top - box.top,\n left: tableBox.left - box.left,\n width: tableBox.width,\n height: tableBox.height,\n },\n // a top-level table's frame reaches into the margins, the table starting\n // after its padding: what shows of it starts at whichever is further in\n frame: {\n left: Math.max(frameBox.left, tableBox.left) - box.left,\n right: frameBox.right - box.left,\n },\n column: { left: first.left - box.left, width: first.width },\n row: { top: first.top - box.top, height: first.height },\n bar,\n }\n}\n\n/** The cells the toolbar is about: a cell selection's corners, or the merged cell with the cursor. */\nfunction barCells(current: NonNullable<typeof view.value>): number[] {\n const selection = current.state.selection\n if (selection instanceof CellSelection)\n return selection.$anchorCell.pos === selection.$headCell.pos\n ? []\n : [selection.$anchorCell.pos, selection.$headCell.pos]\n if (!inMergedCell(current.state)) return []\n const $head = selection.$head\n for (let depth = $head.depth; depth > 0; depth--) {\n const role = $head.node(depth).type.spec.tableRole\n if (role === 'cell' || role === 'header_cell') return [$head.before(depth)]\n }\n return []\n}\n\nlet frame = 0\nlet lastTarget: EventTarget | null = null\n\nfunction schedule() {\n if (frame) return\n frame = requestAnimationFrame(() => {\n frame = 0\n if (!menuOpen.value && !dragging.value) {\n const element = lastTarget instanceof Element ? lastTarget : null\n const cell = element?.closest<HTMLElement>('.dou-editor-table td, .dou-editor-table th')\n const inControls = element?.closest('.dou-editor-table-controls')\n if (cell) hovered.value = targetOf(cell)\n else if (!inControls) hovered.value = null\n }\n measure()\n })\n}\n\nfunction track(event: PointerEvent) {\n if (event.pointerType === 'touch') return\n lastTarget = event.target\n schedule()\n}\n\nfunction leave() {\n if (menuOpen.value || dragging.value) return\n lastTarget = null\n hovered.value = null\n schedule()\n}\n\nconst onScroll = () => schedule()\n\nonMounted(() => {\n root.value?.addEventListener('pointermove', track)\n root.value?.addEventListener('pointerleave', leave)\n // the table frame scrolls sideways; the page scrolls too\n window.addEventListener('scroll', onScroll, true)\n window.addEventListener('resize', onScroll)\n})\nonBeforeUnmount(() => {\n root.value?.removeEventListener('pointermove', track)\n root.value?.removeEventListener('pointerleave', leave)\n window.removeEventListener('scroll', onScroll, true)\n window.removeEventListener('resize', onScroll)\n if (frame) cancelAnimationFrame(frame)\n endDrag(false)\n})\n\nwatch([state, target], () => schedule())\n\n/* actions */\n\nfunction run(command: Command) {\n const current = view.value\n if (!current) return\n command(current.state, current.dispatch)\n current.focus()\n}\n\nfunction openMenu(axis: 'row' | 'column', pressed: Drag) {\n // the lines pressed on, even if the handles moved since\n const current = view.value\n if (!current) return\n current.dispatch(\n selectLines(current.state.tr, pressed.tablePos, axis, pressed.start, pressed.end),\n )\n // one menu at a time\n rowMenu.value = axis === 'row'\n columnMenu.value = axis === 'column'\n}\n\n/**\n * Whole lines are selected to show what a menu or a drag is about; after\n * it, the cursor goes into their first cell so the handles come back.\n */\nfunction collapseLines() {\n const current = view.value\n const selection = current?.state.selection\n if (!current || !(selection instanceof CellSelection)) return\n if (!selection.isRowSelection() && !selection.isColSelection()) return\n const $cell = current.state.doc.resolve(selection.$anchorCell.pos + 1)\n current.dispatch(current.state.tr.setSelection(TextSelection.near($cell)))\n}\n\nwatch(menuOpen, (open) => {\n if (open) return\n collapseLines()\n schedule()\n})\n\nconst can = (command: Command) => {\n const current = state.value\n return !!current && command(current)\n}\n\nconst tableNode = computed(() => {\n const at = target.value\n return at ? (state.value?.doc.nodeAt(at.pos) ?? null) : null\n})\n\nconst columnAlign = computed<TableAlign>(() => {\n const node = tableNode.value\n const at = target.value\n if (!node || !at) return 'left'\n return (fitColumns(node.attrs.columns, TableMap.get(node).width)[at.rect.left]?.align ??\n 'left') as TableAlign\n})\n\nconst aligns: { value: TableAlign; icon: unknown; label: () => string }[] = [\n { value: 'left', icon: TextAlignLeftIcon, label: () => messages.value.table.alignLeft },\n { value: 'center', icon: TextAlignCenterIcon, label: () => messages.value.table.alignCenter },\n { value: 'right', icon: TextAlignRightIcon, label: () => messages.value.table.alignRight },\n]\n\n/** The + bars: a column at the right end, a row at the bottom. */\nfunction addAtEnd(axis: 'row' | 'column') {\n const current = view.value\n const at = target.value\n if (!current || !at) return\n const table = current.state.doc.nodeAt(at.pos)!\n const map = TableMap.get(table)\n const rect = {\n left: 0,\n top: 0,\n right: map.width,\n bottom: map.height,\n map,\n table,\n tableStart: at.pos + 1,\n }\n let tr = current.state.tr\n if (axis === 'row') tr = addRow(tr, rect, map.height)\n else {\n const columns = fitColumns(table.attrs.columns, map.width)\n columns.push({ id: createId() })\n tr = addColumn(tr, rect, map.width).setNodeAttribute(at.pos, 'columns', columns)\n }\n current.dispatch(tr)\n}\n\n/* dragging rows and columns by their handle */\n\ninterface Drag {\n axis: 'row' | 'column'\n tablePos: number\n /** The lines that move: the target's, with any merged cells they belong to. */\n start: number\n end: number\n x: number\n y: number\n /** Where they go: the line they go before, or `null` for where they are. */\n to: number | null\n}\n\nlet drag: Drag | null = null\nconst dragging = shallowRef(false)\nconst drop = shallowRef<{ axis: 'row' | 'column'; at: number } | null>(null)\n/** A copy of the dragged lines that follows the pointer. */\nlet ghost: HTMLElement | null = null\n\nfunction onHandleDown(axis: 'row' | 'column', event: PointerEvent) {\n const current = view.value\n const at = target.value\n if (event.button !== 0 || !current || !at || !current.editable) return\n const map = TableMap.get(current.state.doc.nodeAt(at.pos)!)\n const [from, to] = axis === 'row' ? [at.rect.top, at.rect.bottom] : [at.rect.left, at.rect.right]\n const lines = band(map, axis, from, to)\n drag = { axis, tablePos: at.pos, ...lines, x: event.clientX, y: event.clientY, to: null }\n window.addEventListener('pointermove', onDragMove)\n window.addEventListener('pointerup', onDragUp)\n window.addEventListener('pointercancel', onDragCancel)\n}\n\n/** Each boundary a run can go to, and where it is (relative to the editor). */\nfunction cutPlaces(moving: Drag): { cut: number; at: number }[] {\n const current = view.value\n const host = root.value\n const table = current?.state.doc.nodeAt(moving.tablePos)\n const element = (current?.nodeDOM(moving.tablePos) as HTMLElement | null)?.querySelector('table')\n if (!current || !host || !table || !element) return []\n const box = host.getBoundingClientRect()\n const tableBox = element.getBoundingClientRect()\n const map = TableMap.get(table)\n const places: { cut: number; at: number }[] = []\n if (moving.axis === 'row') {\n const tops: number[] = []\n table.forEach((_row, offset) => {\n const row = current.nodeDOM(moving.tablePos + 1 + offset) as HTMLElement | null\n tops.push((row?.getBoundingClientRect().top ?? tableBox.top) - box.top)\n })\n for (const cut of boundaries(map, 'row'))\n places.push({ cut, at: cut < map.height ? tops[cut]! : tableBox.bottom - box.top })\n return places\n }\n for (const cut of boundaries(map, 'column')) {\n if (cut === map.width) {\n places.push({ cut, at: tableBox.right - box.left })\n continue\n }\n // no merged cell crosses a boundary, so the first row has a cell starting there\n let row = 0\n while (row < map.height && map.findCell(map.map[row * map.width + cut]!).left !== cut) row++\n const cell = cellElement(moving.tablePos, row, cut)\n if (cell) places.push({ cut, at: cell.getBoundingClientRect().left - box.left })\n }\n return places\n}\n\nfunction showGhost(moving: Drag) {\n const current = view.value\n const host = root.value\n const table = current?.state.doc.nodeAt(moving.tablePos)\n const element = (current?.nodeDOM(moving.tablePos) as HTMLElement | null)?.querySelector('table')\n if (!current || !host || !table || !element) return\n const map = TableMap.get(table)\n const copy = document.createElement('table')\n copy.className = 'dou-editor-table'\n const body = document.createElement('tbody')\n copy.append(body)\n let width = 0\n const [rows, cols] =\n moving.axis === 'row'\n ? [\n [moving.start, moving.end],\n [0, map.width],\n ]\n : [\n [0, map.height],\n [moving.start, moving.end],\n ]\n for (let row = rows[0]!; row < rows[1]!; row++) {\n const line = document.createElement('tr')\n let lineWidth = 0\n for (let col = cols[0]!; col < cols[1]!; col++) {\n const rect = map.findCell(map.map[row * map.width + col]!)\n if (rect.top !== row || rect.left !== col) continue\n const cell = cellElement(moving.tablePos, row, col)\n if (!cell) continue\n const clone = cell.cloneNode(true) as HTMLElement\n clone.classList.remove('selectedCell')\n clone.style.width = `${cell.getBoundingClientRect().width}px`\n lineWidth += cell.getBoundingClientRect().width\n line.append(clone)\n }\n width = Math.max(width, lineWidth)\n body.append(line)\n }\n ghost = document.createElement('div')\n ghost.className = 'dou-editor__surface dou-editor__ghost dou-editor-table__ghost'\n ghost.setAttribute('aria-hidden', 'true')\n ghost.style.width = `${Math.min(width, 360) + 2}px`\n ghost.append(copy)\n host.append(ghost)\n}\n\nfunction onDragMove(event: PointerEvent) {\n const moving = drag\n if (!moving) return\n if (!dragging.value) {\n if (Math.hypot(event.clientX - moving.x, event.clientY - moving.y) < 4) return\n dragging.value = true\n columnMenu.value = false\n rowMenu.value = false\n const current = view.value\n if (current)\n current.dispatch(\n selectLines(current.state.tr, moving.tablePos, moving.axis, moving.start, moving.end),\n )\n showGhost(moving)\n }\n if (ghost) ghost.style.transform = `translate(${event.clientX + 12}px, ${event.clientY + 12}px)`\n const host = root.value\n if (!host) return\n const box = host.getBoundingClientRect()\n const pointer = moving.axis === 'row' ? event.clientY - box.top : event.clientX - box.left\n let best: { cut: number; at: number } | null = null\n for (const place of cutPlaces(moving))\n if (!best || Math.abs(place.at - pointer) < Math.abs(best.at - pointer)) best = place\n // a boundary of the run itself leaves it where it is\n if (!best || (best.cut >= moving.start && best.cut <= moving.end)) {\n moving.to = null\n drop.value = null\n return\n }\n moving.to = best.cut\n drop.value = { axis: moving.axis, at: best.at }\n}\n\nfunction onDragUp() {\n endDrag(true)\n}\n\nfunction onDragCancel() {\n endDrag(false)\n}\n\nfunction endDrag(apply: boolean) {\n window.removeEventListener('pointermove', onDragMove)\n window.removeEventListener('pointerup', onDragUp)\n window.removeEventListener('pointercancel', onDragCancel)\n const moving = drag\n drag = null\n ghost?.remove()\n ghost = null\n drop.value = null\n if (!dragging.value) {\n // a press without a drag opens the menu; on release rather than on\n // click, as the press may close another menu and move the handles\n if (apply && moving) openMenu(moving.axis, moving)\n return\n }\n dragging.value = false\n if (apply && moving?.to !== null && moving)\n run(moveLinesTo(moving.tablePos, moving.axis, moving.start, moving.end, moving.to))\n collapseLines()\n schedule()\n}\n\nconst hasCellSelection = computed(() => {\n const selection = state.value?.selection\n return selection instanceof CellSelection && selection.$anchorCell.pos !== selection.$headCell.pos\n})\n\nconst visible = computed(() => !!layout.value && !!target.value)\n</script>\n\n<template>\n <div v-if=\"visible && layout\" class=\"dou-editor-table-controls\" @mousedown.prevent>\n <!-- column handle, above the column -->\n <DouDropdown\n v-model:open=\"columnMenu\"\n trigger=\"manual\"\n placement=\"bottom-start\"\n class=\"dou-editor-menu\"\n >\n <button\n type=\"button\"\n tabindex=\"-1\"\n v-show=\"!handlesHidden\"\n class=\"dou-editor-table__handle is-column\"\n :class=\"{ 'is-active': columnMenu }\"\n :style=\"{\n top: `${layout.table.top}px`,\n left: `${Math.min(Math.max(layout.column.left + layout.column.width / 2, layout.frame.left + 12), layout.frame.right - 12)}px`,\n }\"\n :aria-label=\"messages.table.column\"\n :title=\"messages.table.column\"\n @pointerdown=\"onHandleDown('column', $event)\"\n >\n <GripHorizontalIcon />\n </button>\n <template #menu>\n <DouDropdownItem @click=\"run(insertColumn('before'))\">\n <template #prefix><ArrowLeftToLineIcon /></template>\n {{ messages.table.insertLeft }}\n </DouDropdownItem>\n <DouDropdownItem @click=\"run(insertColumn('after'))\">\n <template #prefix><ArrowRightToLineIcon /></template>\n {{ messages.table.insertRight }}\n </DouDropdownItem>\n <DouDropdownItem\n divided\n :disabled=\"!can(moveLines('column', -1))\"\n @click=\"run(moveLines('column', -1))\"\n >\n <template #prefix><ArrowLeftIcon /></template>\n {{ messages.table.moveLeft }}\n </DouDropdownItem>\n <DouDropdownItem\n :disabled=\"!can(moveLines('column', 1))\"\n @click=\"run(moveLines('column', 1))\"\n >\n <template #prefix><ArrowRightIcon /></template>\n {{ messages.table.moveRight }}\n </DouDropdownItem>\n <DouDropdownSub divided :title=\"aligns.find((item) => item.value === columnAlign)!.label()\">\n <template #prefix>\n <component :is=\"aligns.find((item) => item.value === columnAlign)!.icon\" />\n </template>\n <DouDropdownItem\n v-for=\"item in aligns\"\n :key=\"item.value\"\n @click=\"run(alignColumns(item.value))\"\n >\n <template #prefix><component :is=\"item.icon\" /></template>\n {{ item.label() }}\n <template v-if=\"item.value === columnAlign\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n </DouDropdownSub>\n <DouDropdownItem v-if=\"target?.rect.left === 0\" @click=\"run(toggleHeader('headerColumn'))\">\n <template #prefix><LayoutColumnsIcon /></template>\n {{ messages.table.headerColumn }}\n <template v-if=\"tableNode?.attrs.headerColumn\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n <DouDropdownItem divided @click=\"run(clearCells)\">\n <template #prefix><EraserIcon /></template>\n {{ messages.table.clear }}\n </DouDropdownItem>\n <DouDropdownItem tone=\"danger\" :disabled=\"!can(deleteColumns)\" @click=\"run(deleteColumns)\">\n <template #prefix><TrashIcon /></template>\n {{ messages.table.deleteColumn }}\n </DouDropdownItem>\n </template>\n </DouDropdown>\n\n <!-- row handle, left of the row -->\n <DouDropdown\n v-model:open=\"rowMenu\"\n trigger=\"manual\"\n placement=\"right-start\"\n class=\"dou-editor-menu\"\n >\n <button\n type=\"button\"\n tabindex=\"-1\"\n v-show=\"!handlesHidden\"\n class=\"dou-editor-table__handle is-row\"\n :class=\"{ 'is-active': rowMenu }\"\n :style=\"{\n top: `${layout.row.top + layout.row.height / 2}px`,\n left: `${layout.frame.left}px`,\n }\"\n :aria-label=\"messages.table.row\"\n :title=\"messages.table.row\"\n @pointerdown=\"onHandleDown('row', $event)\"\n >\n <GripVerticalIcon />\n </button>\n <template #menu>\n <DouDropdownItem @click=\"run(insertRow('before'))\">\n <template #prefix><ArrowUpToLineIcon /></template>\n {{ messages.table.insertAbove }}\n </DouDropdownItem>\n <DouDropdownItem @click=\"run(insertRow('after'))\">\n <template #prefix><ArrowDownFromLineIcon /></template>\n {{ messages.table.insertBelow }}\n </DouDropdownItem>\n <DouDropdownItem\n divided\n :disabled=\"!can(moveLines('row', -1))\"\n @click=\"run(moveLines('row', -1))\"\n >\n <template #prefix><ArrowUpIcon /></template>\n {{ messages.table.moveUp }}\n </DouDropdownItem>\n <DouDropdownItem :disabled=\"!can(moveLines('row', 1))\" @click=\"run(moveLines('row', 1))\">\n <template #prefix><ArrowDownIcon /></template>\n {{ messages.table.moveDown }}\n </DouDropdownItem>\n <DouDropdownItem\n v-if=\"target?.rect.top === 0\"\n divided\n @click=\"run(toggleHeader('headerRow'))\"\n >\n <template #prefix><LayoutRowsIcon /></template>\n {{ messages.table.headerRow }}\n <template v-if=\"tableNode?.attrs.headerRow\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n <DouDropdownItem divided @click=\"run(clearCells)\">\n <template #prefix><EraserIcon /></template>\n {{ messages.table.clear }}\n </DouDropdownItem>\n <DouDropdownItem tone=\"danger\" :disabled=\"!can(deleteRows)\" @click=\"run(deleteRows)\">\n <template #prefix><TrashIcon /></template>\n {{ messages.table.deleteRow }}\n </DouDropdownItem>\n </template>\n </DouDropdown>\n\n <!-- + bars -->\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__add is-column\"\n :style=\"{\n top: `${layout.table.top}px`,\n left: `${Math.min(layout.table.left + layout.table.width, layout.frame.right)}px`,\n height: `${layout.table.height}px`,\n }\"\n :aria-label=\"messages.table.addColumn\"\n :title=\"messages.table.addColumn\"\n @click=\"addAtEnd('column')\"\n >\n <PlusIcon />\n </button>\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__add is-row\"\n :style=\"{\n top: `${layout.table.top + layout.table.height}px`,\n left: `${layout.frame.left}px`,\n width: `${Math.min(layout.table.left + layout.table.width, layout.frame.right) - layout.frame.left}px`,\n }\"\n :aria-label=\"messages.table.addRow\"\n :title=\"messages.table.addRow\"\n @click=\"addAtEnd('row')\"\n >\n <PlusIcon />\n </button>\n\n <!-- where dragged lines go -->\n <div\n v-if=\"drop\"\n class=\"dou-editor__drop\"\n :class=\"{ 'is-vertical': drop.axis === 'column' }\"\n :style=\"\n drop.axis === 'row'\n ? {\n top: `${drop.at}px`,\n left: `${layout.frame.left}px`,\n width: `${Math.min(layout.table.left + layout.table.width, layout.frame.right) - layout.frame.left}px`,\n }\n : {\n top: `${layout.table.top}px`,\n left: `${drop.at}px`,\n height: `${layout.table.height}px`,\n }\n \"\n />\n\n <!-- cells: merge, unmerge, clear -->\n <div\n v-if=\"barShown && layout.bar && !dragging\"\n class=\"dou-editor-table__cells\"\n :class=\"{ 'is-below': layout.bar.below }\"\n :style=\"{ top: `${layout.bar.top}px`, left: `${layout.bar.left}px` }\"\n >\n <button\n v-if=\"hasCellSelection\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__cells-button\"\n :disabled=\"!can(mergeCells)\"\n @click=\"run(mergeCells)\"\n >\n <MergeIcon />{{ messages.table.merge }}\n </button>\n <button\n v-if=\"can(splitMergedCell)\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__cells-button\"\n @click=\"run(splitMergedCell)\"\n >\n <SplitIcon />{{ messages.table.split }}\n </button>\n <button\n v-if=\"hasCellSelection\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__cells-button\"\n :aria-label=\"messages.table.clear\"\n :title=\"messages.table.clear\"\n @click=\"run(clearCells)\"\n >\n <EraserIcon />\n </button>\n </div>\n </div>\n</template>\n"],"mappings":""}
@@ -115,7 +115,7 @@ var table_controls_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
115
115
  height: tableBox.height
116
116
  },
117
117
  frame: {
118
- left: frameBox.left - box.left,
118
+ left: Math.max(frameBox.left, tableBox.left) - box.left,
119
119
  right: frameBox.right - box.left
120
120
  },
121
121
  column: {
@@ -1 +1 @@
1
- {"version":3,"file":"table-controls.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_withModifiers","_createVNode","_unref","_withCtx","_createTextVNode","_toDisplayString","_createBlock","_resolveDynamicComponent","_Fragment","_renderList","_createSlots","_createCommentVNode","_withDirectives","_createElementVNode","_normalizeClass","_normalizeStyle","_vShow"],"sources":["../../../src/extensions/table/table-controls.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n ArrowDownFromLineIcon,\n ArrowDownIcon,\n ArrowLeftIcon,\n ArrowLeftToLineIcon,\n ArrowRightIcon,\n ArrowRightToLineIcon,\n ArrowUpIcon,\n ArrowUpToLineIcon,\n CheckIcon,\n EraserIcon,\n GripHorizontalIcon,\n GripVerticalIcon,\n LayoutColumnsIcon,\n LayoutRowsIcon,\n MergeIcon,\n PlusIcon,\n SplitIcon,\n TextAlignCenterIcon,\n TextAlignLeftIcon,\n TextAlignRightIcon,\n TrashIcon,\n} from '@dou-ui/icons'\nimport { DouDropdown, DouDropdownItem, DouDropdownSub } from 'dou-ui'\nimport { TextSelection, type Command } from 'prosemirror-state'\nimport { CellSelection, TableMap, addColumn, addRow, type Rect } from 'prosemirror-tables'\nimport { computed, onBeforeUnmount, onMounted, shallowRef, watch } from 'vue'\nimport { createId } from '../../core/model'\nimport { useMenuEscape } from '../../components/menu-escape'\nimport { useEditor } from '../../editor'\nimport {\n alignColumns,\n band,\n boundaries,\n clearCells,\n deleteColumns,\n deleteRows,\n inMergedCell,\n insertColumn,\n insertRow,\n mergeCells,\n moveLines,\n moveLinesTo,\n selectLines,\n splitMergedCell,\n tableAt,\n toggleHeader,\n} from './commands'\nimport { fitColumns, type TableAlign } from './schema'\n\nconst { view, state, root, messages } = useEditor()\n\n/** The table and the cell the controls are about: the hovered one, or the selection's. */\ninterface Target {\n /** Position right before the table node. */\n pos: number\n /** The cell's place in the grid. */\n rect: Rect\n}\n\nconst hovered = shallowRef<Target | null>(null)\nconst columnMenu = shallowRef(false)\nconst rowMenu = shallowRef(false)\nconst menuOpen = computed(() => columnMenu.value || rowMenu.value)\nuseMenuEscape(menuOpen, () => {\n columnMenu.value = false\n rowMenu.value = false\n})\nconst barShown = computed(() => !!layout.value?.bar && !menuOpen.value && !dragging.value)\n// the toolbar over selected cells stands in for the handles; a merged cell's goes below it\nconst handlesHidden = computed(() => barShown.value && hasCellSelection.value)\n\nfunction targetOf(cell: HTMLElement): Target | null {\n const current = view.value\n if (!current || !current.dom.contains(cell)) return null\n const $pos = current.state.doc.resolve(current.posAtDOM(cell, 0))\n const found = tableAt($pos)\n if (!found) return null\n // the cell node starts right before its content\n for (let depth = $pos.depth; depth > 0; depth--) {\n const role = $pos.node(depth).type.spec.tableRole\n if (role === 'cell' || role === 'header_cell') {\n const cellPos = $pos.before(depth) - found.pos - 1\n return { pos: found.pos, rect: found.map.findCell(cellPos) }\n }\n }\n return null\n}\n\n/** The selection's cell when the pointer is elsewhere. */\nconst selected = computed<Target | null>(() => {\n const current = state.value\n if (!current) return null\n const selection = current.selection\n const $cell = selection instanceof CellSelection ? selection.$headCell : null\n const found = tableAt(selection.$head)\n if (!found) return null\n const start = found.pos + 1\n if ($cell) return { pos: found.pos, rect: found.map.findCell($cell.pos - start) }\n for (let depth = selection.$head.depth; depth > 0; depth--) {\n const role = selection.$head.node(depth).type.spec.tableRole\n if (role === 'cell' || role === 'header_cell')\n return { pos: found.pos, rect: found.map.findCell(selection.$head.before(depth) - start) }\n }\n return null\n})\n\nconst target = computed(() => hovered.value ?? selected.value)\n\n/* where things go */\n\ninterface Layout {\n /** The table, relative to the editor. */\n table: { top: number; left: number; width: number; height: number }\n /** The visible part of the table, when it scrolls sideways. */\n frame: { left: number; right: number }\n column: { left: number; width: number }\n row: { top: number; height: number }\n /**\n * Where the cell toolbar goes (its centre): above selected cells, or below\n * the merged cell with the cursor.\n */\n bar: { top: number; left: number; below: boolean } | null\n}\n\nconst layout = shallowRef<Layout | null>(null)\n\nfunction cellElement(tablePos: number, row: number, col: number): HTMLElement | null {\n const current = view.value\n const table = current?.state.doc.nodeAt(tablePos)\n if (!current || !table) return null\n const map = TableMap.get(table)\n if (row >= map.height || col >= map.width) return null\n const pos = tablePos + 1 + map.map[row * map.width + col]!\n return current.nodeDOM(pos) as HTMLElement | null\n}\n\nfunction measure() {\n const current = view.value\n const host = root.value\n const at = target.value\n if (!current || !host || !at) return (layout.value = null)\n const tableNode = current.state.doc.nodeAt(at.pos)\n const frameElement = current.nodeDOM(at.pos) as HTMLElement | null\n const tableElement = frameElement?.querySelector('table')\n if (!tableNode || !frameElement || !tableElement) return (layout.value = null)\n const box = host.getBoundingClientRect()\n const tableBox = tableElement.getBoundingClientRect()\n const frameBox = frameElement.getBoundingClientRect()\n const first = cellElement(at.pos, at.rect.top, at.rect.left)?.getBoundingClientRect()\n if (!first) return (layout.value = null)\n let bar: Layout['bar'] = null\n const boxes = barCells(current).map((pos) =>\n (current.nodeDOM(pos) as HTMLElement).getBoundingClientRect(),\n )\n if (boxes.length) {\n const left = Math.max(Math.min(...boxes.map((item) => item.left)), frameBox.left)\n const right = Math.min(Math.max(...boxes.map((item) => item.right)), frameBox.right)\n const below = !(current.state.selection instanceof CellSelection)\n bar = {\n top: below\n ? Math.max(...boxes.map((item) => item.bottom)) - box.top\n : Math.min(...boxes.map((item) => item.top)) - box.top,\n left: (left + right) / 2 - box.left,\n below,\n }\n }\n layout.value = {\n table: {\n top: tableBox.top - box.top,\n left: tableBox.left - box.left,\n width: tableBox.width,\n height: tableBox.height,\n },\n frame: { left: frameBox.left - box.left, right: frameBox.right - box.left },\n column: { left: first.left - box.left, width: first.width },\n row: { top: first.top - box.top, height: first.height },\n bar,\n }\n}\n\n/** The cells the toolbar is about: a cell selection's corners, or the merged cell with the cursor. */\nfunction barCells(current: NonNullable<typeof view.value>): number[] {\n const selection = current.state.selection\n if (selection instanceof CellSelection)\n return selection.$anchorCell.pos === selection.$headCell.pos\n ? []\n : [selection.$anchorCell.pos, selection.$headCell.pos]\n if (!inMergedCell(current.state)) return []\n const $head = selection.$head\n for (let depth = $head.depth; depth > 0; depth--) {\n const role = $head.node(depth).type.spec.tableRole\n if (role === 'cell' || role === 'header_cell') return [$head.before(depth)]\n }\n return []\n}\n\nlet frame = 0\nlet lastTarget: EventTarget | null = null\n\nfunction schedule() {\n if (frame) return\n frame = requestAnimationFrame(() => {\n frame = 0\n if (!menuOpen.value && !dragging.value) {\n const element = lastTarget instanceof Element ? lastTarget : null\n const cell = element?.closest<HTMLElement>('.dou-editor-table td, .dou-editor-table th')\n const inControls = element?.closest('.dou-editor-table-controls')\n if (cell) hovered.value = targetOf(cell)\n else if (!inControls) hovered.value = null\n }\n measure()\n })\n}\n\nfunction track(event: PointerEvent) {\n if (event.pointerType === 'touch') return\n lastTarget = event.target\n schedule()\n}\n\nfunction leave() {\n if (menuOpen.value || dragging.value) return\n lastTarget = null\n hovered.value = null\n schedule()\n}\n\nconst onScroll = () => schedule()\n\nonMounted(() => {\n root.value?.addEventListener('pointermove', track)\n root.value?.addEventListener('pointerleave', leave)\n // the table frame scrolls sideways; the page scrolls too\n window.addEventListener('scroll', onScroll, true)\n window.addEventListener('resize', onScroll)\n})\nonBeforeUnmount(() => {\n root.value?.removeEventListener('pointermove', track)\n root.value?.removeEventListener('pointerleave', leave)\n window.removeEventListener('scroll', onScroll, true)\n window.removeEventListener('resize', onScroll)\n if (frame) cancelAnimationFrame(frame)\n endDrag(false)\n})\n\nwatch([state, target], () => schedule())\n\n/* actions */\n\nfunction run(command: Command) {\n const current = view.value\n if (!current) return\n command(current.state, current.dispatch)\n current.focus()\n}\n\nfunction openMenu(axis: 'row' | 'column', pressed: Drag) {\n // the lines pressed on, even if the handles moved since\n const current = view.value\n if (!current) return\n current.dispatch(\n selectLines(current.state.tr, pressed.tablePos, axis, pressed.start, pressed.end),\n )\n // one menu at a time\n rowMenu.value = axis === 'row'\n columnMenu.value = axis === 'column'\n}\n\n/**\n * Whole lines are selected to show what a menu or a drag is about; after\n * it, the cursor goes into their first cell so the handles come back.\n */\nfunction collapseLines() {\n const current = view.value\n const selection = current?.state.selection\n if (!current || !(selection instanceof CellSelection)) return\n if (!selection.isRowSelection() && !selection.isColSelection()) return\n const $cell = current.state.doc.resolve(selection.$anchorCell.pos + 1)\n current.dispatch(current.state.tr.setSelection(TextSelection.near($cell)))\n}\n\nwatch(menuOpen, (open) => {\n if (open) return\n collapseLines()\n schedule()\n})\n\nconst can = (command: Command) => {\n const current = state.value\n return !!current && command(current)\n}\n\nconst tableNode = computed(() => {\n const at = target.value\n return at ? (state.value?.doc.nodeAt(at.pos) ?? null) : null\n})\n\nconst columnAlign = computed<TableAlign>(() => {\n const node = tableNode.value\n const at = target.value\n if (!node || !at) return 'left'\n return (fitColumns(node.attrs.columns, TableMap.get(node).width)[at.rect.left]?.align ??\n 'left') as TableAlign\n})\n\nconst aligns: { value: TableAlign; icon: unknown; label: () => string }[] = [\n { value: 'left', icon: TextAlignLeftIcon, label: () => messages.value.table.alignLeft },\n { value: 'center', icon: TextAlignCenterIcon, label: () => messages.value.table.alignCenter },\n { value: 'right', icon: TextAlignRightIcon, label: () => messages.value.table.alignRight },\n]\n\n/** The + bars: a column at the right end, a row at the bottom. */\nfunction addAtEnd(axis: 'row' | 'column') {\n const current = view.value\n const at = target.value\n if (!current || !at) return\n const table = current.state.doc.nodeAt(at.pos)!\n const map = TableMap.get(table)\n const rect = {\n left: 0,\n top: 0,\n right: map.width,\n bottom: map.height,\n map,\n table,\n tableStart: at.pos + 1,\n }\n let tr = current.state.tr\n if (axis === 'row') tr = addRow(tr, rect, map.height)\n else {\n const columns = fitColumns(table.attrs.columns, map.width)\n columns.push({ id: createId() })\n tr = addColumn(tr, rect, map.width).setNodeAttribute(at.pos, 'columns', columns)\n }\n current.dispatch(tr)\n}\n\n/* dragging rows and columns by their handle */\n\ninterface Drag {\n axis: 'row' | 'column'\n tablePos: number\n /** The lines that move: the target's, with any merged cells they belong to. */\n start: number\n end: number\n x: number\n y: number\n /** Where they go: the line they go before, or `null` for where they are. */\n to: number | null\n}\n\nlet drag: Drag | null = null\nconst dragging = shallowRef(false)\nconst drop = shallowRef<{ axis: 'row' | 'column'; at: number } | null>(null)\n/** A copy of the dragged lines that follows the pointer. */\nlet ghost: HTMLElement | null = null\n\nfunction onHandleDown(axis: 'row' | 'column', event: PointerEvent) {\n const current = view.value\n const at = target.value\n if (event.button !== 0 || !current || !at || !current.editable) return\n const map = TableMap.get(current.state.doc.nodeAt(at.pos)!)\n const [from, to] = axis === 'row' ? [at.rect.top, at.rect.bottom] : [at.rect.left, at.rect.right]\n const lines = band(map, axis, from, to)\n drag = { axis, tablePos: at.pos, ...lines, x: event.clientX, y: event.clientY, to: null }\n window.addEventListener('pointermove', onDragMove)\n window.addEventListener('pointerup', onDragUp)\n window.addEventListener('pointercancel', onDragCancel)\n}\n\n/** Each boundary a run can go to, and where it is (relative to the editor). */\nfunction cutPlaces(moving: Drag): { cut: number; at: number }[] {\n const current = view.value\n const host = root.value\n const table = current?.state.doc.nodeAt(moving.tablePos)\n const element = (current?.nodeDOM(moving.tablePos) as HTMLElement | null)?.querySelector('table')\n if (!current || !host || !table || !element) return []\n const box = host.getBoundingClientRect()\n const tableBox = element.getBoundingClientRect()\n const map = TableMap.get(table)\n const places: { cut: number; at: number }[] = []\n if (moving.axis === 'row') {\n const tops: number[] = []\n table.forEach((_row, offset) => {\n const row = current.nodeDOM(moving.tablePos + 1 + offset) as HTMLElement | null\n tops.push((row?.getBoundingClientRect().top ?? tableBox.top) - box.top)\n })\n for (const cut of boundaries(map, 'row'))\n places.push({ cut, at: cut < map.height ? tops[cut]! : tableBox.bottom - box.top })\n return places\n }\n for (const cut of boundaries(map, 'column')) {\n if (cut === map.width) {\n places.push({ cut, at: tableBox.right - box.left })\n continue\n }\n // no merged cell crosses a boundary, so the first row has a cell starting there\n let row = 0\n while (row < map.height && map.findCell(map.map[row * map.width + cut]!).left !== cut) row++\n const cell = cellElement(moving.tablePos, row, cut)\n if (cell) places.push({ cut, at: cell.getBoundingClientRect().left - box.left })\n }\n return places\n}\n\nfunction showGhost(moving: Drag) {\n const current = view.value\n const host = root.value\n const table = current?.state.doc.nodeAt(moving.tablePos)\n const element = (current?.nodeDOM(moving.tablePos) as HTMLElement | null)?.querySelector('table')\n if (!current || !host || !table || !element) return\n const map = TableMap.get(table)\n const copy = document.createElement('table')\n copy.className = 'dou-editor-table'\n const body = document.createElement('tbody')\n copy.append(body)\n let width = 0\n const [rows, cols] =\n moving.axis === 'row'\n ? [\n [moving.start, moving.end],\n [0, map.width],\n ]\n : [\n [0, map.height],\n [moving.start, moving.end],\n ]\n for (let row = rows[0]!; row < rows[1]!; row++) {\n const line = document.createElement('tr')\n let lineWidth = 0\n for (let col = cols[0]!; col < cols[1]!; col++) {\n const rect = map.findCell(map.map[row * map.width + col]!)\n if (rect.top !== row || rect.left !== col) continue\n const cell = cellElement(moving.tablePos, row, col)\n if (!cell) continue\n const clone = cell.cloneNode(true) as HTMLElement\n clone.classList.remove('selectedCell')\n clone.style.width = `${cell.getBoundingClientRect().width}px`\n lineWidth += cell.getBoundingClientRect().width\n line.append(clone)\n }\n width = Math.max(width, lineWidth)\n body.append(line)\n }\n ghost = document.createElement('div')\n ghost.className = 'dou-editor__surface dou-editor__ghost dou-editor-table__ghost'\n ghost.setAttribute('aria-hidden', 'true')\n ghost.style.width = `${Math.min(width, 360) + 2}px`\n ghost.append(copy)\n host.append(ghost)\n}\n\nfunction onDragMove(event: PointerEvent) {\n const moving = drag\n if (!moving) return\n if (!dragging.value) {\n if (Math.hypot(event.clientX - moving.x, event.clientY - moving.y) < 4) return\n dragging.value = true\n columnMenu.value = false\n rowMenu.value = false\n const current = view.value\n if (current)\n current.dispatch(\n selectLines(current.state.tr, moving.tablePos, moving.axis, moving.start, moving.end),\n )\n showGhost(moving)\n }\n if (ghost) ghost.style.transform = `translate(${event.clientX + 12}px, ${event.clientY + 12}px)`\n const host = root.value\n if (!host) return\n const box = host.getBoundingClientRect()\n const pointer = moving.axis === 'row' ? event.clientY - box.top : event.clientX - box.left\n let best: { cut: number; at: number } | null = null\n for (const place of cutPlaces(moving))\n if (!best || Math.abs(place.at - pointer) < Math.abs(best.at - pointer)) best = place\n // a boundary of the run itself leaves it where it is\n if (!best || (best.cut >= moving.start && best.cut <= moving.end)) {\n moving.to = null\n drop.value = null\n return\n }\n moving.to = best.cut\n drop.value = { axis: moving.axis, at: best.at }\n}\n\nfunction onDragUp() {\n endDrag(true)\n}\n\nfunction onDragCancel() {\n endDrag(false)\n}\n\nfunction endDrag(apply: boolean) {\n window.removeEventListener('pointermove', onDragMove)\n window.removeEventListener('pointerup', onDragUp)\n window.removeEventListener('pointercancel', onDragCancel)\n const moving = drag\n drag = null\n ghost?.remove()\n ghost = null\n drop.value = null\n if (!dragging.value) {\n // a press without a drag opens the menu; on release rather than on\n // click, as the press may close another menu and move the handles\n if (apply && moving) openMenu(moving.axis, moving)\n return\n }\n dragging.value = false\n if (apply && moving?.to !== null && moving)\n run(moveLinesTo(moving.tablePos, moving.axis, moving.start, moving.end, moving.to))\n collapseLines()\n schedule()\n}\n\nconst hasCellSelection = computed(() => {\n const selection = state.value?.selection\n return selection instanceof CellSelection && selection.$anchorCell.pos !== selection.$headCell.pos\n})\n\nconst visible = computed(() => !!layout.value && !!target.value)\n</script>\n\n<template>\n <div v-if=\"visible && layout\" class=\"dou-editor-table-controls\" @mousedown.prevent>\n <!-- column handle, above the column -->\n <DouDropdown\n v-model:open=\"columnMenu\"\n trigger=\"manual\"\n placement=\"bottom-start\"\n class=\"dou-editor-menu\"\n >\n <button\n type=\"button\"\n tabindex=\"-1\"\n v-show=\"!handlesHidden\"\n class=\"dou-editor-table__handle is-column\"\n :class=\"{ 'is-active': columnMenu }\"\n :style=\"{\n top: `${layout.table.top}px`,\n left: `${Math.min(Math.max(layout.column.left + layout.column.width / 2, layout.frame.left + 12), layout.frame.right - 12)}px`,\n }\"\n :aria-label=\"messages.table.column\"\n :title=\"messages.table.column\"\n @pointerdown=\"onHandleDown('column', $event)\"\n >\n <GripHorizontalIcon />\n </button>\n <template #menu>\n <DouDropdownItem @click=\"run(insertColumn('before'))\">\n <template #prefix><ArrowLeftToLineIcon /></template>\n {{ messages.table.insertLeft }}\n </DouDropdownItem>\n <DouDropdownItem @click=\"run(insertColumn('after'))\">\n <template #prefix><ArrowRightToLineIcon /></template>\n {{ messages.table.insertRight }}\n </DouDropdownItem>\n <DouDropdownItem\n divided\n :disabled=\"!can(moveLines('column', -1))\"\n @click=\"run(moveLines('column', -1))\"\n >\n <template #prefix><ArrowLeftIcon /></template>\n {{ messages.table.moveLeft }}\n </DouDropdownItem>\n <DouDropdownItem\n :disabled=\"!can(moveLines('column', 1))\"\n @click=\"run(moveLines('column', 1))\"\n >\n <template #prefix><ArrowRightIcon /></template>\n {{ messages.table.moveRight }}\n </DouDropdownItem>\n <DouDropdownSub divided :title=\"aligns.find((item) => item.value === columnAlign)!.label()\">\n <template #prefix>\n <component :is=\"aligns.find((item) => item.value === columnAlign)!.icon\" />\n </template>\n <DouDropdownItem\n v-for=\"item in aligns\"\n :key=\"item.value\"\n @click=\"run(alignColumns(item.value))\"\n >\n <template #prefix><component :is=\"item.icon\" /></template>\n {{ item.label() }}\n <template v-if=\"item.value === columnAlign\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n </DouDropdownSub>\n <DouDropdownItem v-if=\"target?.rect.left === 0\" @click=\"run(toggleHeader('headerColumn'))\">\n <template #prefix><LayoutColumnsIcon /></template>\n {{ messages.table.headerColumn }}\n <template v-if=\"tableNode?.attrs.headerColumn\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n <DouDropdownItem divided @click=\"run(clearCells)\">\n <template #prefix><EraserIcon /></template>\n {{ messages.table.clear }}\n </DouDropdownItem>\n <DouDropdownItem tone=\"danger\" :disabled=\"!can(deleteColumns)\" @click=\"run(deleteColumns)\">\n <template #prefix><TrashIcon /></template>\n {{ messages.table.deleteColumn }}\n </DouDropdownItem>\n </template>\n </DouDropdown>\n\n <!-- row handle, left of the row -->\n <DouDropdown\n v-model:open=\"rowMenu\"\n trigger=\"manual\"\n placement=\"right-start\"\n class=\"dou-editor-menu\"\n >\n <button\n type=\"button\"\n tabindex=\"-1\"\n v-show=\"!handlesHidden\"\n class=\"dou-editor-table__handle is-row\"\n :class=\"{ 'is-active': rowMenu }\"\n :style=\"{\n top: `${layout.row.top + layout.row.height / 2}px`,\n left: `${layout.frame.left}px`,\n }\"\n :aria-label=\"messages.table.row\"\n :title=\"messages.table.row\"\n @pointerdown=\"onHandleDown('row', $event)\"\n >\n <GripVerticalIcon />\n </button>\n <template #menu>\n <DouDropdownItem @click=\"run(insertRow('before'))\">\n <template #prefix><ArrowUpToLineIcon /></template>\n {{ messages.table.insertAbove }}\n </DouDropdownItem>\n <DouDropdownItem @click=\"run(insertRow('after'))\">\n <template #prefix><ArrowDownFromLineIcon /></template>\n {{ messages.table.insertBelow }}\n </DouDropdownItem>\n <DouDropdownItem\n divided\n :disabled=\"!can(moveLines('row', -1))\"\n @click=\"run(moveLines('row', -1))\"\n >\n <template #prefix><ArrowUpIcon /></template>\n {{ messages.table.moveUp }}\n </DouDropdownItem>\n <DouDropdownItem :disabled=\"!can(moveLines('row', 1))\" @click=\"run(moveLines('row', 1))\">\n <template #prefix><ArrowDownIcon /></template>\n {{ messages.table.moveDown }}\n </DouDropdownItem>\n <DouDropdownItem\n v-if=\"target?.rect.top === 0\"\n divided\n @click=\"run(toggleHeader('headerRow'))\"\n >\n <template #prefix><LayoutRowsIcon /></template>\n {{ messages.table.headerRow }}\n <template v-if=\"tableNode?.attrs.headerRow\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n <DouDropdownItem divided @click=\"run(clearCells)\">\n <template #prefix><EraserIcon /></template>\n {{ messages.table.clear }}\n </DouDropdownItem>\n <DouDropdownItem tone=\"danger\" :disabled=\"!can(deleteRows)\" @click=\"run(deleteRows)\">\n <template #prefix><TrashIcon /></template>\n {{ messages.table.deleteRow }}\n </DouDropdownItem>\n </template>\n </DouDropdown>\n\n <!-- + bars -->\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__add is-column\"\n :style=\"{\n top: `${layout.table.top}px`,\n left: `${Math.min(layout.table.left + layout.table.width, layout.frame.right)}px`,\n height: `${layout.table.height}px`,\n }\"\n :aria-label=\"messages.table.addColumn\"\n :title=\"messages.table.addColumn\"\n @click=\"addAtEnd('column')\"\n >\n <PlusIcon />\n </button>\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__add is-row\"\n :style=\"{\n top: `${layout.table.top + layout.table.height}px`,\n left: `${layout.frame.left}px`,\n width: `${Math.min(layout.table.left + layout.table.width, layout.frame.right) - layout.frame.left}px`,\n }\"\n :aria-label=\"messages.table.addRow\"\n :title=\"messages.table.addRow\"\n @click=\"addAtEnd('row')\"\n >\n <PlusIcon />\n </button>\n\n <!-- where dragged lines go -->\n <div\n v-if=\"drop\"\n class=\"dou-editor__drop\"\n :class=\"{ 'is-vertical': drop.axis === 'column' }\"\n :style=\"\n drop.axis === 'row'\n ? {\n top: `${drop.at}px`,\n left: `${layout.frame.left}px`,\n width: `${Math.min(layout.table.left + layout.table.width, layout.frame.right) - layout.frame.left}px`,\n }\n : {\n top: `${layout.table.top}px`,\n left: `${drop.at}px`,\n height: `${layout.table.height}px`,\n }\n \"\n />\n\n <!-- cells: merge, unmerge, clear -->\n <div\n v-if=\"barShown && layout.bar && !dragging\"\n class=\"dou-editor-table__cells\"\n :class=\"{ 'is-below': layout.bar.below }\"\n :style=\"{ top: `${layout.bar.top}px`, left: `${layout.bar.left}px` }\"\n >\n <button\n v-if=\"hasCellSelection\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__cells-button\"\n :disabled=\"!can(mergeCells)\"\n @click=\"run(mergeCells)\"\n >\n <MergeIcon />{{ messages.table.merge }}\n </button>\n <button\n v-if=\"can(splitMergedCell)\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__cells-button\"\n @click=\"run(splitMergedCell)\"\n >\n <SplitIcon />{{ messages.table.split }}\n </button>\n <button\n v-if=\"hasCellSelection\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__cells-button\"\n :aria-label=\"messages.table.clear\"\n :title=\"messages.table.clear\"\n @click=\"run(clearCells)\"\n >\n <EraserIcon />\n </button>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAmDA,MAAM,EAAE,MAAM,OAAO,MAAM,aAAa,UAAU;;EAUlD,MAAM,UAAU,WAA0B,IAAI;EAC9C,MAAM,aAAa,WAAW,KAAK;EACnC,MAAM,UAAU,WAAW,KAAK;EAChC,MAAM,WAAW,eAAe,WAAW,SAAS,QAAQ,KAAK;EACjE,cAAc,gBAAgB;GAC5B,WAAW,QAAQ;GACnB,QAAQ,QAAQ;EAClB,CAAC;EACD,MAAM,WAAW,eAAe,CAAC,CAAC,OAAO,OAAO,OAAO,CAAC,SAAS,SAAS,CAAC,SAAS,KAAK;EAEzF,MAAM,gBAAgB,eAAe,SAAS,SAAS,iBAAiB,KAAK;EAE7E,SAAS,SAAS,MAAkC;GAClD,MAAM,UAAU,KAAK;GACrB,IAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,SAAS,IAAI,GAAG,OAAO;GACpD,MAAM,OAAO,QAAQ,MAAM,IAAI,QAAQ,QAAQ,SAAS,MAAM,CAAC,CAAC;GAChE,MAAM,QAAQ,QAAQ,IAAI;GAC1B,IAAI,CAAC,OAAO,OAAO;GAEnB,KAAK,IAAI,QAAQ,KAAK,OAAO,QAAQ,GAAG,SAAS;IAC/C,MAAM,OAAO,KAAK,KAAK,KAAK,CAAC,CAAC,KAAK,KAAK;IACxC,IAAI,SAAS,UAAU,SAAS,eAAe;KAC7C,MAAM,UAAU,KAAK,OAAO,KAAK,IAAI,MAAM,MAAM;KACjD,OAAO;MAAE,KAAK,MAAM;MAAK,MAAM,MAAM,IAAI,SAAS,OAAO;KAAE;IAC7D;GACF;GACA,OAAO;EACT;;EAGA,MAAM,WAAW,eAA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US,UAAA;;MARP,MAAK;MACL,UAAS;MACT,OAAM;MACL,cAAYG,MAAA,QAAA,CAAQ,CAAC,MAAM;MAC3B,OAAOA,MAAA,QAAA,CAAQ,CAAC,MAAM;MACtB,SAAK,OAAA,QAAA,OAAA,OAAA,WAAE,IAAIA,MAAA,UAAA,CAAU;K,IAEtBD,YAAcC,MAAA,UAAA,CAAA,C"}
1
+ {"version":3,"file":"table-controls.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_withModifiers","_createVNode","_unref","_withCtx","_createTextVNode","_toDisplayString","_createBlock","_resolveDynamicComponent","_Fragment","_renderList","_createSlots","_createCommentVNode","_withDirectives","_createElementVNode","_normalizeClass","_normalizeStyle","_vShow"],"sources":["../../../src/extensions/table/table-controls.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n ArrowDownFromLineIcon,\n ArrowDownIcon,\n ArrowLeftIcon,\n ArrowLeftToLineIcon,\n ArrowRightIcon,\n ArrowRightToLineIcon,\n ArrowUpIcon,\n ArrowUpToLineIcon,\n CheckIcon,\n EraserIcon,\n GripHorizontalIcon,\n GripVerticalIcon,\n LayoutColumnsIcon,\n LayoutRowsIcon,\n MergeIcon,\n PlusIcon,\n SplitIcon,\n TextAlignCenterIcon,\n TextAlignLeftIcon,\n TextAlignRightIcon,\n TrashIcon,\n} from '@dou-ui/icons'\nimport { DouDropdown, DouDropdownItem, DouDropdownSub } from 'dou-ui'\nimport { TextSelection, type Command } from 'prosemirror-state'\nimport { CellSelection, TableMap, addColumn, addRow, type Rect } from 'prosemirror-tables'\nimport { computed, onBeforeUnmount, onMounted, shallowRef, watch } from 'vue'\nimport { createId } from '../../core/model'\nimport { useMenuEscape } from '../../components/menu-escape'\nimport { useEditor } from '../../editor'\nimport {\n alignColumns,\n band,\n boundaries,\n clearCells,\n deleteColumns,\n deleteRows,\n inMergedCell,\n insertColumn,\n insertRow,\n mergeCells,\n moveLines,\n moveLinesTo,\n selectLines,\n splitMergedCell,\n tableAt,\n toggleHeader,\n} from './commands'\nimport { fitColumns, type TableAlign } from './schema'\n\nconst { view, state, root, messages } = useEditor()\n\n/** The table and the cell the controls are about: the hovered one, or the selection's. */\ninterface Target {\n /** Position right before the table node. */\n pos: number\n /** The cell's place in the grid. */\n rect: Rect\n}\n\nconst hovered = shallowRef<Target | null>(null)\nconst columnMenu = shallowRef(false)\nconst rowMenu = shallowRef(false)\nconst menuOpen = computed(() => columnMenu.value || rowMenu.value)\nuseMenuEscape(menuOpen, () => {\n columnMenu.value = false\n rowMenu.value = false\n})\nconst barShown = computed(() => !!layout.value?.bar && !menuOpen.value && !dragging.value)\n// the toolbar over selected cells stands in for the handles; a merged cell's goes below it\nconst handlesHidden = computed(() => barShown.value && hasCellSelection.value)\n\nfunction targetOf(cell: HTMLElement): Target | null {\n const current = view.value\n if (!current || !current.dom.contains(cell)) return null\n const $pos = current.state.doc.resolve(current.posAtDOM(cell, 0))\n const found = tableAt($pos)\n if (!found) return null\n // the cell node starts right before its content\n for (let depth = $pos.depth; depth > 0; depth--) {\n const role = $pos.node(depth).type.spec.tableRole\n if (role === 'cell' || role === 'header_cell') {\n const cellPos = $pos.before(depth) - found.pos - 1\n return { pos: found.pos, rect: found.map.findCell(cellPos) }\n }\n }\n return null\n}\n\n/** The selection's cell when the pointer is elsewhere. */\nconst selected = computed<Target | null>(() => {\n const current = state.value\n if (!current) return null\n const selection = current.selection\n const $cell = selection instanceof CellSelection ? selection.$headCell : null\n const found = tableAt(selection.$head)\n if (!found) return null\n const start = found.pos + 1\n if ($cell) return { pos: found.pos, rect: found.map.findCell($cell.pos - start) }\n for (let depth = selection.$head.depth; depth > 0; depth--) {\n const role = selection.$head.node(depth).type.spec.tableRole\n if (role === 'cell' || role === 'header_cell')\n return { pos: found.pos, rect: found.map.findCell(selection.$head.before(depth) - start) }\n }\n return null\n})\n\nconst target = computed(() => hovered.value ?? selected.value)\n\n/* where things go */\n\ninterface Layout {\n /** The table, relative to the editor. */\n table: { top: number; left: number; width: number; height: number }\n /** The visible part of the table, when it scrolls sideways. */\n frame: { left: number; right: number }\n column: { left: number; width: number }\n row: { top: number; height: number }\n /**\n * Where the cell toolbar goes (its centre): above selected cells, or below\n * the merged cell with the cursor.\n */\n bar: { top: number; left: number; below: boolean } | null\n}\n\nconst layout = shallowRef<Layout | null>(null)\n\nfunction cellElement(tablePos: number, row: number, col: number): HTMLElement | null {\n const current = view.value\n const table = current?.state.doc.nodeAt(tablePos)\n if (!current || !table) return null\n const map = TableMap.get(table)\n if (row >= map.height || col >= map.width) return null\n const pos = tablePos + 1 + map.map[row * map.width + col]!\n return current.nodeDOM(pos) as HTMLElement | null\n}\n\nfunction measure() {\n const current = view.value\n const host = root.value\n const at = target.value\n if (!current || !host || !at) return (layout.value = null)\n const tableNode = current.state.doc.nodeAt(at.pos)\n const frameElement = current.nodeDOM(at.pos) as HTMLElement | null\n const tableElement = frameElement?.querySelector('table')\n if (!tableNode || !frameElement || !tableElement) return (layout.value = null)\n const box = host.getBoundingClientRect()\n const tableBox = tableElement.getBoundingClientRect()\n const frameBox = frameElement.getBoundingClientRect()\n const first = cellElement(at.pos, at.rect.top, at.rect.left)?.getBoundingClientRect()\n if (!first) return (layout.value = null)\n let bar: Layout['bar'] = null\n const boxes = barCells(current).map((pos) =>\n (current.nodeDOM(pos) as HTMLElement).getBoundingClientRect(),\n )\n if (boxes.length) {\n const left = Math.max(Math.min(...boxes.map((item) => item.left)), frameBox.left)\n const right = Math.min(Math.max(...boxes.map((item) => item.right)), frameBox.right)\n const below = !(current.state.selection instanceof CellSelection)\n bar = {\n top: below\n ? Math.max(...boxes.map((item) => item.bottom)) - box.top\n : Math.min(...boxes.map((item) => item.top)) - box.top,\n left: (left + right) / 2 - box.left,\n below,\n }\n }\n layout.value = {\n table: {\n top: tableBox.top - box.top,\n left: tableBox.left - box.left,\n width: tableBox.width,\n height: tableBox.height,\n },\n // a top-level table's frame reaches into the margins, the table starting\n // after its padding: what shows of it starts at whichever is further in\n frame: {\n left: Math.max(frameBox.left, tableBox.left) - box.left,\n right: frameBox.right - box.left,\n },\n column: { left: first.left - box.left, width: first.width },\n row: { top: first.top - box.top, height: first.height },\n bar,\n }\n}\n\n/** The cells the toolbar is about: a cell selection's corners, or the merged cell with the cursor. */\nfunction barCells(current: NonNullable<typeof view.value>): number[] {\n const selection = current.state.selection\n if (selection instanceof CellSelection)\n return selection.$anchorCell.pos === selection.$headCell.pos\n ? []\n : [selection.$anchorCell.pos, selection.$headCell.pos]\n if (!inMergedCell(current.state)) return []\n const $head = selection.$head\n for (let depth = $head.depth; depth > 0; depth--) {\n const role = $head.node(depth).type.spec.tableRole\n if (role === 'cell' || role === 'header_cell') return [$head.before(depth)]\n }\n return []\n}\n\nlet frame = 0\nlet lastTarget: EventTarget | null = null\n\nfunction schedule() {\n if (frame) return\n frame = requestAnimationFrame(() => {\n frame = 0\n if (!menuOpen.value && !dragging.value) {\n const element = lastTarget instanceof Element ? lastTarget : null\n const cell = element?.closest<HTMLElement>('.dou-editor-table td, .dou-editor-table th')\n const inControls = element?.closest('.dou-editor-table-controls')\n if (cell) hovered.value = targetOf(cell)\n else if (!inControls) hovered.value = null\n }\n measure()\n })\n}\n\nfunction track(event: PointerEvent) {\n if (event.pointerType === 'touch') return\n lastTarget = event.target\n schedule()\n}\n\nfunction leave() {\n if (menuOpen.value || dragging.value) return\n lastTarget = null\n hovered.value = null\n schedule()\n}\n\nconst onScroll = () => schedule()\n\nonMounted(() => {\n root.value?.addEventListener('pointermove', track)\n root.value?.addEventListener('pointerleave', leave)\n // the table frame scrolls sideways; the page scrolls too\n window.addEventListener('scroll', onScroll, true)\n window.addEventListener('resize', onScroll)\n})\nonBeforeUnmount(() => {\n root.value?.removeEventListener('pointermove', track)\n root.value?.removeEventListener('pointerleave', leave)\n window.removeEventListener('scroll', onScroll, true)\n window.removeEventListener('resize', onScroll)\n if (frame) cancelAnimationFrame(frame)\n endDrag(false)\n})\n\nwatch([state, target], () => schedule())\n\n/* actions */\n\nfunction run(command: Command) {\n const current = view.value\n if (!current) return\n command(current.state, current.dispatch)\n current.focus()\n}\n\nfunction openMenu(axis: 'row' | 'column', pressed: Drag) {\n // the lines pressed on, even if the handles moved since\n const current = view.value\n if (!current) return\n current.dispatch(\n selectLines(current.state.tr, pressed.tablePos, axis, pressed.start, pressed.end),\n )\n // one menu at a time\n rowMenu.value = axis === 'row'\n columnMenu.value = axis === 'column'\n}\n\n/**\n * Whole lines are selected to show what a menu or a drag is about; after\n * it, the cursor goes into their first cell so the handles come back.\n */\nfunction collapseLines() {\n const current = view.value\n const selection = current?.state.selection\n if (!current || !(selection instanceof CellSelection)) return\n if (!selection.isRowSelection() && !selection.isColSelection()) return\n const $cell = current.state.doc.resolve(selection.$anchorCell.pos + 1)\n current.dispatch(current.state.tr.setSelection(TextSelection.near($cell)))\n}\n\nwatch(menuOpen, (open) => {\n if (open) return\n collapseLines()\n schedule()\n})\n\nconst can = (command: Command) => {\n const current = state.value\n return !!current && command(current)\n}\n\nconst tableNode = computed(() => {\n const at = target.value\n return at ? (state.value?.doc.nodeAt(at.pos) ?? null) : null\n})\n\nconst columnAlign = computed<TableAlign>(() => {\n const node = tableNode.value\n const at = target.value\n if (!node || !at) return 'left'\n return (fitColumns(node.attrs.columns, TableMap.get(node).width)[at.rect.left]?.align ??\n 'left') as TableAlign\n})\n\nconst aligns: { value: TableAlign; icon: unknown; label: () => string }[] = [\n { value: 'left', icon: TextAlignLeftIcon, label: () => messages.value.table.alignLeft },\n { value: 'center', icon: TextAlignCenterIcon, label: () => messages.value.table.alignCenter },\n { value: 'right', icon: TextAlignRightIcon, label: () => messages.value.table.alignRight },\n]\n\n/** The + bars: a column at the right end, a row at the bottom. */\nfunction addAtEnd(axis: 'row' | 'column') {\n const current = view.value\n const at = target.value\n if (!current || !at) return\n const table = current.state.doc.nodeAt(at.pos)!\n const map = TableMap.get(table)\n const rect = {\n left: 0,\n top: 0,\n right: map.width,\n bottom: map.height,\n map,\n table,\n tableStart: at.pos + 1,\n }\n let tr = current.state.tr\n if (axis === 'row') tr = addRow(tr, rect, map.height)\n else {\n const columns = fitColumns(table.attrs.columns, map.width)\n columns.push({ id: createId() })\n tr = addColumn(tr, rect, map.width).setNodeAttribute(at.pos, 'columns', columns)\n }\n current.dispatch(tr)\n}\n\n/* dragging rows and columns by their handle */\n\ninterface Drag {\n axis: 'row' | 'column'\n tablePos: number\n /** The lines that move: the target's, with any merged cells they belong to. */\n start: number\n end: number\n x: number\n y: number\n /** Where they go: the line they go before, or `null` for where they are. */\n to: number | null\n}\n\nlet drag: Drag | null = null\nconst dragging = shallowRef(false)\nconst drop = shallowRef<{ axis: 'row' | 'column'; at: number } | null>(null)\n/** A copy of the dragged lines that follows the pointer. */\nlet ghost: HTMLElement | null = null\n\nfunction onHandleDown(axis: 'row' | 'column', event: PointerEvent) {\n const current = view.value\n const at = target.value\n if (event.button !== 0 || !current || !at || !current.editable) return\n const map = TableMap.get(current.state.doc.nodeAt(at.pos)!)\n const [from, to] = axis === 'row' ? [at.rect.top, at.rect.bottom] : [at.rect.left, at.rect.right]\n const lines = band(map, axis, from, to)\n drag = { axis, tablePos: at.pos, ...lines, x: event.clientX, y: event.clientY, to: null }\n window.addEventListener('pointermove', onDragMove)\n window.addEventListener('pointerup', onDragUp)\n window.addEventListener('pointercancel', onDragCancel)\n}\n\n/** Each boundary a run can go to, and where it is (relative to the editor). */\nfunction cutPlaces(moving: Drag): { cut: number; at: number }[] {\n const current = view.value\n const host = root.value\n const table = current?.state.doc.nodeAt(moving.tablePos)\n const element = (current?.nodeDOM(moving.tablePos) as HTMLElement | null)?.querySelector('table')\n if (!current || !host || !table || !element) return []\n const box = host.getBoundingClientRect()\n const tableBox = element.getBoundingClientRect()\n const map = TableMap.get(table)\n const places: { cut: number; at: number }[] = []\n if (moving.axis === 'row') {\n const tops: number[] = []\n table.forEach((_row, offset) => {\n const row = current.nodeDOM(moving.tablePos + 1 + offset) as HTMLElement | null\n tops.push((row?.getBoundingClientRect().top ?? tableBox.top) - box.top)\n })\n for (const cut of boundaries(map, 'row'))\n places.push({ cut, at: cut < map.height ? tops[cut]! : tableBox.bottom - box.top })\n return places\n }\n for (const cut of boundaries(map, 'column')) {\n if (cut === map.width) {\n places.push({ cut, at: tableBox.right - box.left })\n continue\n }\n // no merged cell crosses a boundary, so the first row has a cell starting there\n let row = 0\n while (row < map.height && map.findCell(map.map[row * map.width + cut]!).left !== cut) row++\n const cell = cellElement(moving.tablePos, row, cut)\n if (cell) places.push({ cut, at: cell.getBoundingClientRect().left - box.left })\n }\n return places\n}\n\nfunction showGhost(moving: Drag) {\n const current = view.value\n const host = root.value\n const table = current?.state.doc.nodeAt(moving.tablePos)\n const element = (current?.nodeDOM(moving.tablePos) as HTMLElement | null)?.querySelector('table')\n if (!current || !host || !table || !element) return\n const map = TableMap.get(table)\n const copy = document.createElement('table')\n copy.className = 'dou-editor-table'\n const body = document.createElement('tbody')\n copy.append(body)\n let width = 0\n const [rows, cols] =\n moving.axis === 'row'\n ? [\n [moving.start, moving.end],\n [0, map.width],\n ]\n : [\n [0, map.height],\n [moving.start, moving.end],\n ]\n for (let row = rows[0]!; row < rows[1]!; row++) {\n const line = document.createElement('tr')\n let lineWidth = 0\n for (let col = cols[0]!; col < cols[1]!; col++) {\n const rect = map.findCell(map.map[row * map.width + col]!)\n if (rect.top !== row || rect.left !== col) continue\n const cell = cellElement(moving.tablePos, row, col)\n if (!cell) continue\n const clone = cell.cloneNode(true) as HTMLElement\n clone.classList.remove('selectedCell')\n clone.style.width = `${cell.getBoundingClientRect().width}px`\n lineWidth += cell.getBoundingClientRect().width\n line.append(clone)\n }\n width = Math.max(width, lineWidth)\n body.append(line)\n }\n ghost = document.createElement('div')\n ghost.className = 'dou-editor__surface dou-editor__ghost dou-editor-table__ghost'\n ghost.setAttribute('aria-hidden', 'true')\n ghost.style.width = `${Math.min(width, 360) + 2}px`\n ghost.append(copy)\n host.append(ghost)\n}\n\nfunction onDragMove(event: PointerEvent) {\n const moving = drag\n if (!moving) return\n if (!dragging.value) {\n if (Math.hypot(event.clientX - moving.x, event.clientY - moving.y) < 4) return\n dragging.value = true\n columnMenu.value = false\n rowMenu.value = false\n const current = view.value\n if (current)\n current.dispatch(\n selectLines(current.state.tr, moving.tablePos, moving.axis, moving.start, moving.end),\n )\n showGhost(moving)\n }\n if (ghost) ghost.style.transform = `translate(${event.clientX + 12}px, ${event.clientY + 12}px)`\n const host = root.value\n if (!host) return\n const box = host.getBoundingClientRect()\n const pointer = moving.axis === 'row' ? event.clientY - box.top : event.clientX - box.left\n let best: { cut: number; at: number } | null = null\n for (const place of cutPlaces(moving))\n if (!best || Math.abs(place.at - pointer) < Math.abs(best.at - pointer)) best = place\n // a boundary of the run itself leaves it where it is\n if (!best || (best.cut >= moving.start && best.cut <= moving.end)) {\n moving.to = null\n drop.value = null\n return\n }\n moving.to = best.cut\n drop.value = { axis: moving.axis, at: best.at }\n}\n\nfunction onDragUp() {\n endDrag(true)\n}\n\nfunction onDragCancel() {\n endDrag(false)\n}\n\nfunction endDrag(apply: boolean) {\n window.removeEventListener('pointermove', onDragMove)\n window.removeEventListener('pointerup', onDragUp)\n window.removeEventListener('pointercancel', onDragCancel)\n const moving = drag\n drag = null\n ghost?.remove()\n ghost = null\n drop.value = null\n if (!dragging.value) {\n // a press without a drag opens the menu; on release rather than on\n // click, as the press may close another menu and move the handles\n if (apply && moving) openMenu(moving.axis, moving)\n return\n }\n dragging.value = false\n if (apply && moving?.to !== null && moving)\n run(moveLinesTo(moving.tablePos, moving.axis, moving.start, moving.end, moving.to))\n collapseLines()\n schedule()\n}\n\nconst hasCellSelection = computed(() => {\n const selection = state.value?.selection\n return selection instanceof CellSelection && selection.$anchorCell.pos !== selection.$headCell.pos\n})\n\nconst visible = computed(() => !!layout.value && !!target.value)\n</script>\n\n<template>\n <div v-if=\"visible && layout\" class=\"dou-editor-table-controls\" @mousedown.prevent>\n <!-- column handle, above the column -->\n <DouDropdown\n v-model:open=\"columnMenu\"\n trigger=\"manual\"\n placement=\"bottom-start\"\n class=\"dou-editor-menu\"\n >\n <button\n type=\"button\"\n tabindex=\"-1\"\n v-show=\"!handlesHidden\"\n class=\"dou-editor-table__handle is-column\"\n :class=\"{ 'is-active': columnMenu }\"\n :style=\"{\n top: `${layout.table.top}px`,\n left: `${Math.min(Math.max(layout.column.left + layout.column.width / 2, layout.frame.left + 12), layout.frame.right - 12)}px`,\n }\"\n :aria-label=\"messages.table.column\"\n :title=\"messages.table.column\"\n @pointerdown=\"onHandleDown('column', $event)\"\n >\n <GripHorizontalIcon />\n </button>\n <template #menu>\n <DouDropdownItem @click=\"run(insertColumn('before'))\">\n <template #prefix><ArrowLeftToLineIcon /></template>\n {{ messages.table.insertLeft }}\n </DouDropdownItem>\n <DouDropdownItem @click=\"run(insertColumn('after'))\">\n <template #prefix><ArrowRightToLineIcon /></template>\n {{ messages.table.insertRight }}\n </DouDropdownItem>\n <DouDropdownItem\n divided\n :disabled=\"!can(moveLines('column', -1))\"\n @click=\"run(moveLines('column', -1))\"\n >\n <template #prefix><ArrowLeftIcon /></template>\n {{ messages.table.moveLeft }}\n </DouDropdownItem>\n <DouDropdownItem\n :disabled=\"!can(moveLines('column', 1))\"\n @click=\"run(moveLines('column', 1))\"\n >\n <template #prefix><ArrowRightIcon /></template>\n {{ messages.table.moveRight }}\n </DouDropdownItem>\n <DouDropdownSub divided :title=\"aligns.find((item) => item.value === columnAlign)!.label()\">\n <template #prefix>\n <component :is=\"aligns.find((item) => item.value === columnAlign)!.icon\" />\n </template>\n <DouDropdownItem\n v-for=\"item in aligns\"\n :key=\"item.value\"\n @click=\"run(alignColumns(item.value))\"\n >\n <template #prefix><component :is=\"item.icon\" /></template>\n {{ item.label() }}\n <template v-if=\"item.value === columnAlign\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n </DouDropdownSub>\n <DouDropdownItem v-if=\"target?.rect.left === 0\" @click=\"run(toggleHeader('headerColumn'))\">\n <template #prefix><LayoutColumnsIcon /></template>\n {{ messages.table.headerColumn }}\n <template v-if=\"tableNode?.attrs.headerColumn\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n <DouDropdownItem divided @click=\"run(clearCells)\">\n <template #prefix><EraserIcon /></template>\n {{ messages.table.clear }}\n </DouDropdownItem>\n <DouDropdownItem tone=\"danger\" :disabled=\"!can(deleteColumns)\" @click=\"run(deleteColumns)\">\n <template #prefix><TrashIcon /></template>\n {{ messages.table.deleteColumn }}\n </DouDropdownItem>\n </template>\n </DouDropdown>\n\n <!-- row handle, left of the row -->\n <DouDropdown\n v-model:open=\"rowMenu\"\n trigger=\"manual\"\n placement=\"right-start\"\n class=\"dou-editor-menu\"\n >\n <button\n type=\"button\"\n tabindex=\"-1\"\n v-show=\"!handlesHidden\"\n class=\"dou-editor-table__handle is-row\"\n :class=\"{ 'is-active': rowMenu }\"\n :style=\"{\n top: `${layout.row.top + layout.row.height / 2}px`,\n left: `${layout.frame.left}px`,\n }\"\n :aria-label=\"messages.table.row\"\n :title=\"messages.table.row\"\n @pointerdown=\"onHandleDown('row', $event)\"\n >\n <GripVerticalIcon />\n </button>\n <template #menu>\n <DouDropdownItem @click=\"run(insertRow('before'))\">\n <template #prefix><ArrowUpToLineIcon /></template>\n {{ messages.table.insertAbove }}\n </DouDropdownItem>\n <DouDropdownItem @click=\"run(insertRow('after'))\">\n <template #prefix><ArrowDownFromLineIcon /></template>\n {{ messages.table.insertBelow }}\n </DouDropdownItem>\n <DouDropdownItem\n divided\n :disabled=\"!can(moveLines('row', -1))\"\n @click=\"run(moveLines('row', -1))\"\n >\n <template #prefix><ArrowUpIcon /></template>\n {{ messages.table.moveUp }}\n </DouDropdownItem>\n <DouDropdownItem :disabled=\"!can(moveLines('row', 1))\" @click=\"run(moveLines('row', 1))\">\n <template #prefix><ArrowDownIcon /></template>\n {{ messages.table.moveDown }}\n </DouDropdownItem>\n <DouDropdownItem\n v-if=\"target?.rect.top === 0\"\n divided\n @click=\"run(toggleHeader('headerRow'))\"\n >\n <template #prefix><LayoutRowsIcon /></template>\n {{ messages.table.headerRow }}\n <template v-if=\"tableNode?.attrs.headerRow\" #suffix><CheckIcon /></template>\n </DouDropdownItem>\n <DouDropdownItem divided @click=\"run(clearCells)\">\n <template #prefix><EraserIcon /></template>\n {{ messages.table.clear }}\n </DouDropdownItem>\n <DouDropdownItem tone=\"danger\" :disabled=\"!can(deleteRows)\" @click=\"run(deleteRows)\">\n <template #prefix><TrashIcon /></template>\n {{ messages.table.deleteRow }}\n </DouDropdownItem>\n </template>\n </DouDropdown>\n\n <!-- + bars -->\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__add is-column\"\n :style=\"{\n top: `${layout.table.top}px`,\n left: `${Math.min(layout.table.left + layout.table.width, layout.frame.right)}px`,\n height: `${layout.table.height}px`,\n }\"\n :aria-label=\"messages.table.addColumn\"\n :title=\"messages.table.addColumn\"\n @click=\"addAtEnd('column')\"\n >\n <PlusIcon />\n </button>\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__add is-row\"\n :style=\"{\n top: `${layout.table.top + layout.table.height}px`,\n left: `${layout.frame.left}px`,\n width: `${Math.min(layout.table.left + layout.table.width, layout.frame.right) - layout.frame.left}px`,\n }\"\n :aria-label=\"messages.table.addRow\"\n :title=\"messages.table.addRow\"\n @click=\"addAtEnd('row')\"\n >\n <PlusIcon />\n </button>\n\n <!-- where dragged lines go -->\n <div\n v-if=\"drop\"\n class=\"dou-editor__drop\"\n :class=\"{ 'is-vertical': drop.axis === 'column' }\"\n :style=\"\n drop.axis === 'row'\n ? {\n top: `${drop.at}px`,\n left: `${layout.frame.left}px`,\n width: `${Math.min(layout.table.left + layout.table.width, layout.frame.right) - layout.frame.left}px`,\n }\n : {\n top: `${layout.table.top}px`,\n left: `${drop.at}px`,\n height: `${layout.table.height}px`,\n }\n \"\n />\n\n <!-- cells: merge, unmerge, clear -->\n <div\n v-if=\"barShown && layout.bar && !dragging\"\n class=\"dou-editor-table__cells\"\n :class=\"{ 'is-below': layout.bar.below }\"\n :style=\"{ top: `${layout.bar.top}px`, left: `${layout.bar.left}px` }\"\n >\n <button\n v-if=\"hasCellSelection\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__cells-button\"\n :disabled=\"!can(mergeCells)\"\n @click=\"run(mergeCells)\"\n >\n <MergeIcon />{{ messages.table.merge }}\n </button>\n <button\n v-if=\"can(splitMergedCell)\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__cells-button\"\n @click=\"run(splitMergedCell)\"\n >\n <SplitIcon />{{ messages.table.split }}\n </button>\n <button\n v-if=\"hasCellSelection\"\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor-table__cells-button\"\n :aria-label=\"messages.table.clear\"\n :title=\"messages.table.clear\"\n @click=\"run(clearCells)\"\n >\n <EraserIcon />\n </button>\n </div>\n </div>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EAmDA,MAAM,EAAE,MAAM,OAAO,MAAM,aAAa,UAAU;;EAUlD,MAAM,UAAU,WAA0B,IAAI;EAC9C,MAAM,aAAa,WAAW,KAAK;EACnC,MAAM,UAAU,WAAW,KAAK;EAChC,MAAM,WAAW,eAAe,WAAW,SAAS,QAAQ,KAAK;EACjE,cAAc,gBAAgB;GAC5B,WAAW,QAAQ;GACnB,QAAQ,QAAQ;EAClB,CAAC;EACD,MAAM,WAAW,eAAe,CAAC,CAAC,OAAO,OAAO,OAAO,CAAC,SAAS,SAAS,CAAC,SAAS,KAAK;EAEzF,MAAM,gBAAgB,eAAe,SAAS,SAAS,iBAAiB,KAAK;EAE7E,SAAS,SAAS,MAAkC;GAClD,MAAM,UAAU,KAAK;GACrB,IAAI,CAAC,WAAW,CAAC,QAAQ,IAAI,SAAS,IAAI,GAAG,OAAO;GACpD,MAAM,OAAO,QAAQ,MAAM,IAAI,QAAQ,QAAQ,SAAS,MAAM,CAAC,CAAC;GAChE,MAAM,QAAQ,QAAQ,IAAI;GAC1B,IAAI,CAAC,OAAO,OAAO;GAE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CAAQ,CAAC,MAAM,KAAK,GAAA,CAAA,C;KAG9B,IAAIA,MAAA,eAAA,CAAe,KAD3BJ,UAAA,GAAAC,mBAQS,UAAA;;MANP,MAAK;MACL,UAAS;MACT,OAAM;MACL,SAAK,OAAA,QAAA,OAAA,OAAA,WAAE,IAAIG,MAAA,eAAA,CAAe;K,IAE3BD,YAAaC,MAAA,SAAA,CAAA,GAAGE,gBAAAC,gBAAAH,MAAA,QAAA,CAAQ,CAAC,MAAM,KAAK,GAAA,CAAA,C;KAG9B,iBAAA,SADRJ,UAAA,GAAAC,mBAUS,UAAA;;MARP,MAAK;MACL,UAAS;MACT,OAAM;MACL,cAAYG,MAAA,QAAA,CAAQ,CAAC,MAAM;MAC3B,OAAOA,MAAA,QAAA,CAAQ,CAAC,MAAM;MACtB,SAAK,OAAA,QAAA,OAAA,OAAA,WAAE,IAAIA,MAAA,UAAA,CAAU;K,IAEtBD,YAAcC,MAAA,UAAA,CAAA,C"}
@@ -1,18 +1,42 @@
1
1
  import { TableView } from "prosemirror-tables";
2
2
  /**
3
3
  * A table in the editor: a scrolling frame (the block's content element)
4
- * around the table, with a `<colgroup>` that holds the column widths.
4
+ * around the table, with a `<colgroup>` that holds the column widths. When
5
+ * columns are cut off at either side of the frame, that side has a shadow:
6
+ * `is-cut-start` / `is-cut-end` on the frame.
5
7
  */
6
8
  var TableBlockView = class extends TableView {
9
+ observer = null;
10
+ onScroll = () => this.edges();
7
11
  constructor(node) {
8
12
  super(node, 96);
9
13
  this.dom.className = "dou-editor__content dou-editor__content--table";
10
14
  this.dom.dataset.contentType = "table";
11
15
  this.table.className = "dou-editor-table";
16
+ this.dom.addEventListener("scroll", this.onScroll, { passive: true });
17
+ if (typeof ResizeObserver !== "undefined") {
18
+ this.observer = new ResizeObserver(this.onScroll);
19
+ this.observer.observe(this.dom);
20
+ this.observer.observe(this.table);
21
+ }
22
+ }
23
+ /** Which sides cut columns off: the table's edges against the frame's, padding left out. */
24
+ edges() {
25
+ const frame = this.dom;
26
+ const style = getComputedStyle(frame);
27
+ const start = Number.parseFloat(style.paddingInlineStart) || 0;
28
+ const end = Number.parseFloat(style.paddingInlineEnd) || 0;
29
+ const hidden = frame.scrollWidth - frame.clientWidth;
30
+ frame.classList.toggle("is-cut-start", frame.scrollLeft > start + .5);
31
+ frame.classList.toggle("is-cut-end", frame.scrollLeft < hidden - end - .5);
12
32
  }
13
33
  ignoreMutation(record) {
14
34
  return record.type === "attributes" && record.target === this.dom ? true : super.ignoreMutation(record);
15
35
  }
36
+ destroy() {
37
+ this.dom.removeEventListener("scroll", this.onScroll);
38
+ this.observer?.disconnect();
39
+ }
16
40
  };
17
41
  export { TableBlockView };
18
42
 
@@ -1 +1 @@
1
- {"version":3,"file":"view.js","names":[],"sources":["../../../src/extensions/table/view.ts"],"sourcesContent":["import type { Node as PMNode } from 'prosemirror-model'\nimport { TableView } from 'prosemirror-tables'\nimport type { NodeView, ViewMutationRecord } from 'prosemirror-view'\n\n/** The narrowest a column gets, without a width of its own and when resized. */\nexport const CELL_MIN_WIDTH = 96\n\n/**\n * A table in the editor: a scrolling frame (the block's content element)\n * around the table, with a `<colgroup>` that holds the column widths.\n */\nexport class TableBlockView extends TableView implements NodeView {\n constructor(node: PMNode) {\n super(node, CELL_MIN_WIDTH)\n this.dom.className = 'dou-editor__content dou-editor__content--table'\n this.dom.dataset.contentType = 'table'\n this.table.className = 'dou-editor-table'\n }\n\n override ignoreMutation(record: ViewMutationRecord) {\n // the frame's scroll position and classes are ours\n return record.type === 'attributes' && record.target === this.dom\n ? true\n : super.ignoreMutation(record)\n }\n}\n"],"mappings":";;;;;AAWA,IAAa,iBAAb,cAAoC,UAA8B;CAChE,YAAY,MAAc;EACxB,MAAM,MAAA,EAAoB;EAC1B,KAAK,IAAI,YAAY;EACrB,KAAK,IAAI,QAAQ,cAAc;EAC/B,KAAK,MAAM,YAAY;CACzB;CAEA,eAAwB,QAA4B;EAElD,OAAO,OAAO,SAAS,gBAAgB,OAAO,WAAW,KAAK,MAC1D,OACA,MAAM,eAAe,MAAM;CACjC;AACF"}
1
+ {"version":3,"file":"view.js","names":[],"sources":["../../../src/extensions/table/view.ts"],"sourcesContent":["import type { Node as PMNode } from 'prosemirror-model'\nimport { TableView } from 'prosemirror-tables'\nimport type { NodeView, ViewMutationRecord } from 'prosemirror-view'\n\n/** The narrowest a column gets, without a width of its own and when resized. */\nexport const CELL_MIN_WIDTH = 96\n\n/**\n * A table in the editor: a scrolling frame (the block's content element)\n * around the table, with a `<colgroup>` that holds the column widths. When\n * columns are cut off at either side of the frame, that side has a shadow:\n * `is-cut-start` / `is-cut-end` on the frame.\n */\nexport class TableBlockView extends TableView implements NodeView {\n private readonly observer: ResizeObserver | null = null\n private readonly onScroll = () => this.edges()\n\n constructor(node: PMNode) {\n super(node, CELL_MIN_WIDTH)\n this.dom.className = 'dou-editor__content dou-editor__content--table'\n this.dom.dataset.contentType = 'table'\n this.table.className = 'dou-editor-table'\n this.dom.addEventListener('scroll', this.onScroll, { passive: true })\n if (typeof ResizeObserver !== 'undefined') {\n // the frame's width, and the table's (columns added, removed, resized)\n this.observer = new ResizeObserver(this.onScroll)\n this.observer.observe(this.dom)\n this.observer.observe(this.table)\n }\n }\n\n /** Which sides cut columns off: the table's edges against the frame's, padding left out. */\n private edges() {\n const frame = this.dom\n const style = getComputedStyle(frame)\n const start = Number.parseFloat(style.paddingInlineStart) || 0\n const end = Number.parseFloat(style.paddingInlineEnd) || 0\n const hidden = frame.scrollWidth - frame.clientWidth\n frame.classList.toggle('is-cut-start', frame.scrollLeft > start + 0.5)\n frame.classList.toggle('is-cut-end', frame.scrollLeft < hidden - end - 0.5)\n }\n\n override ignoreMutation(record: ViewMutationRecord) {\n // the frame's scroll position and classes are ours\n return record.type === 'attributes' && record.target === this.dom\n ? true\n : super.ignoreMutation(record)\n }\n\n destroy() {\n this.dom.removeEventListener('scroll', this.onScroll)\n this.observer?.disconnect()\n }\n}\n"],"mappings":";;;;;;;AAaA,IAAa,iBAAb,cAAoC,UAA8B;CAChE,WAAmD;CACnD,iBAAkC,KAAK,MAAM;CAE7C,YAAY,MAAc;EACxB,MAAM,MAAA,EAAoB;EAC1B,KAAK,IAAI,YAAY;EACrB,KAAK,IAAI,QAAQ,cAAc;EAC/B,KAAK,MAAM,YAAY;EACvB,KAAK,IAAI,iBAAiB,UAAU,KAAK,UAAU,EAAE,SAAS,KAAK,CAAC;EACpE,IAAI,OAAO,mBAAmB,aAAa;GAEzC,KAAK,WAAW,IAAI,eAAe,KAAK,QAAQ;GAChD,KAAK,SAAS,QAAQ,KAAK,GAAG;GAC9B,KAAK,SAAS,QAAQ,KAAK,KAAK;EAClC;CACF;;CAGA,QAAgB;EACd,MAAM,QAAQ,KAAK;EACnB,MAAM,QAAQ,iBAAiB,KAAK;EACpC,MAAM,QAAQ,OAAO,WAAW,MAAM,kBAAkB,KAAK;EAC7D,MAAM,MAAM,OAAO,WAAW,MAAM,gBAAgB,KAAK;EACzD,MAAM,SAAS,MAAM,cAAc,MAAM;EACzC,MAAM,UAAU,OAAO,gBAAgB,MAAM,aAAa,QAAQ,EAAG;EACrE,MAAM,UAAU,OAAO,cAAc,MAAM,aAAa,SAAS,MAAM,EAAG;CAC5E;CAEA,eAAwB,QAA4B;EAElD,OAAO,OAAO,SAAS,gBAAgB,OAAO,WAAW,KAAK,MAC1D,OACA,MAAM,eAAe,MAAM;CACjC;CAEA,UAAU;EACR,KAAK,IAAI,oBAAoB,UAAU,KAAK,QAAQ;EACpD,KAAK,UAAU,WAAW;CAC5B;AACF"}
package/dist/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { editorLocales, useEditorMessages } from "./locale.js";
1
2
  import { textColors } from "./core/colors.js";
2
3
  import { blocksToDoc, createId, docToBlocks } from "./core/model.js";
3
4
  import { alignable } from "./core/align.js";
@@ -24,6 +25,7 @@ import { setHighlight, setTextColor } from "./extensions/colors/palette.js";
24
25
  import { colors } from "./extensions/colors/index.js";
25
26
  import { defaultLanguages } from "./extensions/code-block/languages.js";
26
27
  import { codeBlock } from "./extensions/code-block/index.js";
28
+ import { columns } from "./extensions/columns/index.js";
27
29
  import { formatting, link } from "./extensions/formatting.js";
28
30
  import { lists } from "./extensions/lists.js";
29
31
  import { alignColumns, clearCells, deleteColumns, deleteRows, insertColumn, insertRow, mergeCells, moveLines, moveLinesTo, splitMergedCell, toggleHeader } from "./extensions/table/commands.js";
@@ -32,7 +34,6 @@ import { toggle } from "./extensions/toggle/index.js";
32
34
  import { editorKit } from "./extensions/editor-kit.js";
33
35
  import { blocksToHTML, htmlToBlocks } from "./core/convert.js";
34
36
  import { checkDocument, emptyDocument, migrateDocument } from "./document.js";
35
- import { editorLocales, useEditorMessages } from "./locale.js";
36
37
  import editor_default from "./editor2.js";
37
38
  import { isSafeImageSrc, readAsDataUrl } from "./extensions/image/uploads.js";
38
39
  import { formatFileSize, isSafeFileSrc } from "./extensions/attachment/files.js";
@@ -44,6 +45,6 @@ import { mention } from "./extensions/mention/index.js";
44
45
  import { withInstall } from "dou-ui";
45
46
  // src/index.ts
46
47
  var DouEditor = withInstall(editor_default);
47
- export { DouEditor, DouEditor as default, EditorContent, EditorTransaction, align, alignColumns, alignable, atomInputRule, attachment, blockElement, blockInputRule, blocksToDoc, blocksToHTML, callout, checkDocument, clearBlockSelection, clearCells, codeBlock, colors, componentMounter, contentDOM, createId, createSchema, currentAlign, defaultLanguages, defineBlock, defineEditorExtension, deleteColumns, deleteRows, diffBlocks, diffText, divider, docToBlocks, duplicateBlocks, editorKit, editorLocales, embed, emptyDocument, escapeHTML, escapeMarkdown, filterOptions, formatFileSize, formatting, getBlockSelection, heading, historyCommands, htmlToBlocks, image, indentLines, inlineText, insertBlockAfter, insertColumn, insertRow, isRemote, isSafeFileSrc, isSafeHref, isSafeImageSrc, labelOf, liftBlocks, link, lists, markInputRule, mention, mergeCells, migrateDocument, moveLines, moveLinesTo, moveRangeTo, paragraph, quote, readAsDataUrl, resolveEmbed, searchDoc, selectBlocks, setAlign, setBlockType, setHighlight, setTextColor, sinkBlocks, splitContainer, splitMergedCell, swapBlocks, table, textBlock, textColors, toggle, toggleHeader, useEditor, useEditorMessages, useToolbarMenu, vueNodeView };
48
+ export { DouEditor, DouEditor as default, EditorContent, EditorTransaction, align, alignColumns, alignable, atomInputRule, attachment, blockElement, blockInputRule, blocksToDoc, blocksToHTML, callout, checkDocument, clearBlockSelection, clearCells, codeBlock, colors, columns, componentMounter, contentDOM, createId, createSchema, currentAlign, defaultLanguages, defineBlock, defineEditorExtension, deleteColumns, deleteRows, diffBlocks, diffText, divider, docToBlocks, duplicateBlocks, editorKit, editorLocales, embed, emptyDocument, escapeHTML, escapeMarkdown, filterOptions, formatFileSize, formatting, getBlockSelection, heading, historyCommands, htmlToBlocks, image, indentLines, inlineText, insertBlockAfter, insertColumn, insertRow, isRemote, isSafeFileSrc, isSafeHref, isSafeImageSrc, labelOf, liftBlocks, link, lists, markInputRule, mention, mergeCells, migrateDocument, moveLines, moveLinesTo, moveRangeTo, paragraph, quote, readAsDataUrl, resolveEmbed, searchDoc, selectBlocks, setAlign, setBlockType, setHighlight, setTextColor, sinkBlocks, splitContainer, splitMergedCell, swapBlocks, table, textBlock, textColors, toggle, toggleHeader, useEditor, useEditorMessages, useToolbarMenu, vueNodeView };
48
49
 
49
50
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["Editor"],"sources":["../src/index.ts"],"sourcesContent":["import { withInstall } from 'dou-ui'\nimport Editor from './editor.vue'\nimport type { EditorContent } from './define-block'\n\nexport const DouEditor = withInstall(Editor)\nexport default DouEditor\n\nexport { useEditor, useToolbarMenu } from './editor'\nexport type {\n EditorComments,\n EditorContext,\n EditorEmits,\n EditorExpose,\n EditorLinkOpenEvent,\n EditorProps,\n EditorOrigin,\n EditorSelection,\n EditorTransactionResult,\n} from './editor'\nexport { EditorTransaction } from './core/transaction'\nexport type {\n BlockEdge,\n BlockPatch,\n BlockPlacement,\n EditorTransactionMeta,\n} from './core/transaction'\nexport type { BlockChanges } from './core/changes'\nexport type { CommentAnchor, CommentRange } from './core/comments'\nexport { editorLocales, useEditorMessages } from './locale'\nexport type { EditorMessages, EditorMessagesOverride } from './locale'\nexport { filterOptions } from './catalog'\nexport { defineEditorExtension, labelOf } from './core/extension'\nexport type {\n BlockOption,\n CommentsProvider,\n EditorExtension,\n EditorExtensionContext,\n FormatOption,\n HistoryProvider,\n Label,\n MountComponent,\n ResolvedEditorExtensions,\n} from './core/extension'\nexport {\n align,\n callout,\n codeBlock,\n colors,\n divider,\n formatting,\n heading,\n link,\n lists,\n paragraph,\n quote,\n editorKit,\n table,\n toggle,\n} from './extensions/editor-kit'\nexport type { CalloutTone } from './extensions/callout'\nexport { setHighlight, setTextColor, textColors } from './extensions/colors'\nexport type { TextColor } from './extensions/colors'\nexport { currentAlign, setAlign } from './extensions/align'\nexport { alignable } from './core/align'\nexport type { BlockAlign } from './core/align'\nexport { attachment, formatFileSize, isSafeFileSrc } from './extensions/attachment'\nexport type { AttachmentOptions } from './extensions/attachment'\nexport { embed, resolveEmbed } from './extensions/embed'\nexport type { EmbedOptions, EmbedResolver, EmbedTarget } from './extensions/embed'\nexport {\n alignColumns,\n clearCells,\n deleteColumns,\n deleteRows,\n insertColumn,\n insertRow,\n mergeCells,\n moveLines,\n moveLinesTo,\n splitMergedCell,\n toggleHeader,\n} from './extensions/table'\nexport type { TableAlign, TableColumn } from './extensions/table'\nexport type { EditorKitOptions } from './extensions/editor-kit'\nexport { componentMounter, defineBlock, EditorContent, vueNodeView } from './define-block'\nexport { historyCommands } from './core/editor'\nexport { defaultLanguages } from './extensions/code-block'\nexport type { CodeBlockOptions, CodeHighlighter, CodeLanguage } from './extensions/code-block'\nexport { image, isSafeImageSrc, readAsDataUrl } from './extensions/image'\nexport { mention } from './extensions/mention'\nexport type { MentionItem, MentionOptions } from './extensions/mention'\nexport type { FileUploader, ImageOptions } from './extensions/image'\nexport type { BlockViewProps, DefineBlockOptions } from './define-block'\nexport { atomInputRule, blockInputRule, markInputRule } from './core/input-rules'\nexport type {\n Block,\n BlockProps,\n BreakContent,\n EditorDocument,\n InlineContent,\n InlineNodeContent,\n PartialBlock,\n PartialTableCell,\n PartialTableRow,\n RowsSpec,\n TableCell,\n TableRow,\n TextContent,\n} from './core/model'\nexport { blocksToDoc, createId, docToBlocks } from './core/model'\nexport { diffBlocks, diffText, inlineText } from './core/diff'\nexport type { BlockVersionChange, BlocksDiff, TextPart } from './core/diff'\nexport { searchDoc } from './core/search'\nexport type { EditorMatch, EditorSearchQuery } from './core/search'\nexport { checkDocument, emptyDocument, migrateDocument } from './document'\nexport type { CheckDocumentOptions, DocumentProblem } from './document'\nexport type { BuiltinContentType, ContentType, MarkType } from './core/schema'\nexport { contentDOM, createSchema, isSafeHref, textBlock } from './core/schema'\nexport {\n duplicateBlocks,\n insertBlockAfter,\n liftBlocks,\n swapBlocks,\n moveRangeTo,\n setBlockType,\n sinkBlocks,\n} from './core/commands'\nexport { clearBlockSelection, getBlockSelection, selectBlocks } from './core/block-selection'\nexport { isRemote } from './core/plugins'\nexport { blocksToHTML, htmlToBlocks, type HTMLToBlocksOptions } from './core/convert'\nexport type { DOMParserLike } from './core/prepare'\nexport type { EditorExtensionList } from './core/convert'\nexport { escapeHTML, escapeMarkdown, indentLines } from './core/output'\nexport type {\n BlockOutput,\n BlockOutputContext,\n EditorExtensionOutput,\n InlineOutput,\n MarkdownBlockContext,\n MarkOutput,\n} from './core/output'\nexport { blockElement, splitContainer } from './core/prepare'\n\ndeclare module 'vue' {\n export interface GlobalComponents {\n DouEditor: typeof DouEditor\n DouEditorContent: typeof EditorContent\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAa,YAAY,YAAYA,cAAM"}
1
+ {"version":3,"file":"index.js","names":["Editor"],"sources":["../src/index.ts"],"sourcesContent":["import { withInstall } from 'dou-ui'\nimport Editor from './editor.vue'\nimport type { EditorContent } from './define-block'\n\nexport const DouEditor = withInstall(Editor)\nexport default DouEditor\n\nexport { useEditor, useToolbarMenu } from './editor'\nexport type {\n EditorComments,\n EditorContext,\n EditorEmits,\n EditorExpose,\n EditorLinkOpenEvent,\n EditorProps,\n EditorOrigin,\n EditorSelection,\n EditorTransactionResult,\n} from './editor'\nexport { EditorTransaction } from './core/transaction'\nexport type {\n BlockEdge,\n BlockPatch,\n BlockPlacement,\n EditorTransactionMeta,\n} from './core/transaction'\nexport type { BlockChanges } from './core/changes'\nexport type { CommentAnchor, CommentRange } from './core/comments'\nexport { editorLocales, useEditorMessages } from './locale'\nexport type { EditorMessages, EditorMessagesOverride } from './locale'\nexport { filterOptions } from './catalog'\nexport { defineEditorExtension, labelOf } from './core/extension'\nexport type {\n BlockOption,\n BlockOptionChoice,\n BlockOptionChoices,\n BlockOptionChoicesEmits,\n BlockOptionChoicesProps,\n CommentsProvider,\n EditorExtension,\n EditorExtensionContext,\n FormatOption,\n HistoryProvider,\n Label,\n MountComponent,\n ResolvedEditorExtensions,\n} from './core/extension'\nexport {\n align,\n callout,\n codeBlock,\n colors,\n columns,\n divider,\n formatting,\n heading,\n link,\n lists,\n paragraph,\n quote,\n editorKit,\n table,\n toggle,\n} from './extensions/editor-kit'\nexport type { CalloutTone } from './extensions/callout'\nexport { setHighlight, setTextColor, textColors } from './extensions/colors'\nexport type { TextColor } from './extensions/colors'\nexport { currentAlign, setAlign } from './extensions/align'\nexport { alignable } from './core/align'\nexport type { BlockAlign } from './core/align'\nexport { attachment, formatFileSize, isSafeFileSrc } from './extensions/attachment'\nexport type { AttachmentOptions } from './extensions/attachment'\nexport { embed, resolveEmbed } from './extensions/embed'\nexport type { EmbedOptions, EmbedResolver, EmbedTarget } from './extensions/embed'\nexport {\n alignColumns,\n clearCells,\n deleteColumns,\n deleteRows,\n insertColumn,\n insertRow,\n mergeCells,\n moveLines,\n moveLinesTo,\n splitMergedCell,\n toggleHeader,\n} from './extensions/table'\nexport type { TableAlign, TableColumn } from './extensions/table'\nexport type { EditorKitOptions } from './extensions/editor-kit'\nexport { componentMounter, defineBlock, EditorContent, vueNodeView } from './define-block'\nexport { historyCommands } from './core/editor'\nexport { defaultLanguages } from './extensions/code-block'\nexport type { CodeBlockOptions, CodeHighlighter, CodeLanguage } from './extensions/code-block'\nexport { image, isSafeImageSrc, readAsDataUrl } from './extensions/image'\nexport { mention } from './extensions/mention'\nexport type { MentionItem, MentionOptions } from './extensions/mention'\nexport type { FileUploader, ImageOptions } from './extensions/image'\nexport type { BlockViewProps, DefineBlockOptions } from './define-block'\nexport { atomInputRule, blockInputRule, markInputRule } from './core/input-rules'\nexport type {\n Block,\n BlockProps,\n BreakContent,\n EditorDocument,\n InlineContent,\n InlineNodeContent,\n PartialBlock,\n PartialTableCell,\n PartialTableRow,\n RowsSpec,\n TableCell,\n TableRow,\n TextContent,\n} from './core/model'\nexport { blocksToDoc, createId, docToBlocks } from './core/model'\nexport { diffBlocks, diffText, inlineText } from './core/diff'\nexport type { BlockVersionChange, BlocksDiff, TextPart } from './core/diff'\nexport { searchDoc } from './core/search'\nexport type { EditorMatch, EditorSearchQuery } from './core/search'\nexport { checkDocument, emptyDocument, migrateDocument } from './document'\nexport type { CheckDocumentOptions, DocumentProblem } from './document'\nexport type { BuiltinContentType, ContentType, MarkType } from './core/schema'\nexport { contentDOM, createSchema, isSafeHref, textBlock } from './core/schema'\nexport {\n duplicateBlocks,\n insertBlockAfter,\n liftBlocks,\n swapBlocks,\n moveRangeTo,\n setBlockType,\n sinkBlocks,\n} from './core/commands'\nexport { clearBlockSelection, getBlockSelection, selectBlocks } from './core/block-selection'\nexport { isRemote } from './core/plugins'\nexport { blocksToHTML, htmlToBlocks, type HTMLToBlocksOptions } from './core/convert'\nexport type { DOMParserLike } from './core/prepare'\nexport type { EditorExtensionList } from './core/convert'\nexport { escapeHTML, escapeMarkdown, indentLines } from './core/output'\nexport type {\n BlockOutput,\n BlockOutputContext,\n EditorExtensionOutput,\n InlineOutput,\n MarkdownBlockContext,\n MarkOutput,\n} from './core/output'\nexport { blockElement, splitContainer } from './core/prepare'\n\ndeclare module 'vue' {\n export interface GlobalComponents {\n DouEditor: typeof DouEditor\n DouEditorContent: typeof EditorContent\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,IAAa,YAAY,YAAYA,cAAM"}
package/dist/locale.js CHANGED
@@ -20,6 +20,7 @@ var zhCN = {
20
20
  toggle: "折叠块",
21
21
  callout: "提示块",
22
22
  table: "表格",
23
+ columns: "分栏",
23
24
  attachment: "附件",
24
25
  embed: "嵌入"
25
26
  },
@@ -38,6 +39,7 @@ var zhCN = {
38
39
  toggle: "可以展开和收起的内容",
39
40
  callout: "带图标的醒目说明",
40
41
  table: "插入一个表格",
42
+ columns: "把内容并排分成几栏",
41
43
  attachment: "上传一个文件",
42
44
  embed: "视频、音频或网页"
43
45
  },
@@ -98,6 +100,14 @@ var zhCN = {
98
100
  danger: "警告"
99
101
  }
100
102
  },
103
+ columns: {
104
+ pick: "选择栏数",
105
+ count: "{count} 栏",
106
+ select: "选中整个分栏",
107
+ resize: "调整栏宽",
108
+ even: "平分栏宽",
109
+ column: "第 {index} 栏,共 {count} 栏"
110
+ },
101
111
  colors: {
102
112
  label: "颜色",
103
113
  text: "文字颜色",
@@ -184,6 +194,7 @@ var zhTW = {
184
194
  toggle: "摺疊區塊",
185
195
  callout: "提示區塊",
186
196
  table: "表格",
197
+ columns: "分欄",
187
198
  attachment: "附件",
188
199
  embed: "嵌入"
189
200
  },
@@ -202,6 +213,7 @@ var zhTW = {
202
213
  toggle: "可以展開和收合的內容",
203
214
  callout: "帶圖示的醒目說明",
204
215
  table: "插入一個表格",
216
+ columns: "把內容並排分成幾欄",
205
217
  attachment: "上傳一個檔案",
206
218
  embed: "影片、音訊或網頁"
207
219
  },
@@ -262,6 +274,14 @@ var zhTW = {
262
274
  danger: "警告"
263
275
  }
264
276
  },
277
+ columns: {
278
+ pick: "選擇欄數",
279
+ count: "{count} 欄",
280
+ select: "選取整個分欄",
281
+ resize: "調整欄寬",
282
+ even: "平分欄寬",
283
+ column: "第 {index} 欄,共 {count} 欄"
284
+ },
265
285
  colors: {
266
286
  label: "顏色",
267
287
  text: "文字顏色",
@@ -348,6 +368,7 @@ var en = {
348
368
  toggle: "Toggle",
349
369
  callout: "Callout",
350
370
  table: "Table",
371
+ columns: "Columns",
351
372
  attachment: "File",
352
373
  embed: "Embed"
353
374
  },
@@ -366,6 +387,7 @@ var en = {
366
387
  toggle: "Content that can be shown or hidden",
367
388
  callout: "A note that stands out, with an icon",
368
389
  table: "A grid of rows and columns",
390
+ columns: "Put content side by side",
369
391
  attachment: "Upload a file",
370
392
  embed: "Video, audio or a web page"
371
393
  },
@@ -426,6 +448,14 @@ var en = {
426
448
  danger: "Danger"
427
449
  }
428
450
  },
451
+ columns: {
452
+ pick: "Number of columns",
453
+ count: "{count} columns",
454
+ select: "Select all columns",
455
+ resize: "Resize columns",
456
+ even: "Even out columns",
457
+ column: "Column {index} of {count}"
458
+ },
429
459
  colors: {
430
460
  label: "Color",
431
461
  text: "Text color",