@dou-ui/editor 0.1.0-alpha.3 → 0.1.0-alpha.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/collaboration/binding.js +371 -57
- package/dist/collaboration/binding.js.map +1 -1
- package/dist/collaboration/cursors.js +42 -10
- package/dist/collaboration/cursors.js.map +1 -1
- package/dist/collaboration/index.js +61 -11
- package/dist/collaboration/index.js.map +1 -1
- package/dist/collaboration/inline-diff.js +138 -0
- package/dist/collaboration/inline-diff.js.map +1 -0
- package/dist/collaboration/merged-props.js +152 -0
- package/dist/collaboration/merged-props.js.map +1 -0
- package/dist/collaboration/order.js +41 -1
- package/dist/collaboration/order.js.map +1 -1
- package/dist/collaboration/table.js +64 -25
- package/dist/collaboration/table.js.map +1 -1
- package/dist/collaboration/text.js +213 -1
- package/dist/collaboration/text.js.map +1 -1
- package/dist/components/block-handle.js.map +1 -1
- package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js +127 -17
- package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/components/slash-choices.js +6 -0
- package/dist/components/slash-choices.js.map +1 -0
- package/dist/components/slash-choices.vue_vue_type_script_setup_true_lang.js +56 -0
- package/dist/components/slash-choices.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/components/slash-menu.js.map +1 -1
- package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js +185 -20
- package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/core/block-selection.js +32 -4
- package/dist/core/block-selection.js.map +1 -1
- package/dist/core/blocks.js +21 -3
- package/dist/core/blocks.js.map +1 -1
- package/dist/core/cjk.js +54 -0
- package/dist/core/cjk.js.map +1 -0
- package/dist/core/commands.js +125 -13
- package/dist/core/commands.js.map +1 -1
- package/dist/core/comments.js +85 -3
- package/dist/core/comments.js.map +1 -1
- package/dist/core/convert.js +3 -3
- package/dist/core/convert.js.map +1 -1
- package/dist/core/extension.js +6 -2
- package/dist/core/extension.js.map +1 -1
- package/dist/core/model.js +10 -3
- package/dist/core/model.js.map +1 -1
- package/dist/core/output.js +26 -10
- package/dist/core/output.js.map +1 -1
- package/dist/core/prepare.js +12 -5
- package/dist/core/prepare.js.map +1 -1
- package/dist/core/schema.js.map +1 -1
- package/dist/core/transaction.js +19 -4
- package/dist/core/transaction.js.map +1 -1
- package/dist/define-block.js +8 -4
- package/dist/define-block.js.map +1 -1
- package/dist/document.js +59 -4
- package/dist/document.js.map +1 -1
- package/dist/dom.js +109 -13
- package/dist/dom.js.map +1 -1
- package/dist/editor.js.map +1 -1
- package/dist/editor.vue_vue_type_script_setup_true_lang.js +6 -5
- package/dist/editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/editor2.js.map +1 -1
- package/dist/extensions/callout/html.js +5 -4
- package/dist/extensions/callout/html.js.map +1 -1
- package/dist/extensions/columns/column-picker.js +6 -0
- package/dist/extensions/columns/column-picker.js.map +1 -0
- package/dist/extensions/columns/column-picker.vue_vue_type_script_setup_true_lang.js +57 -0
- package/dist/extensions/columns/column-picker.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/columns/columns-controls.js +6 -0
- package/dist/extensions/columns/columns-controls.js.map +1 -0
- package/dist/extensions/columns/columns-controls.vue_vue_type_script_setup_true_lang.js +341 -0
- package/dist/extensions/columns/columns-controls.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/columns/html.js +34 -0
- package/dist/extensions/columns/html.js.map +1 -0
- package/dist/extensions/columns/index.js +57 -0
- package/dist/extensions/columns/index.js.map +1 -0
- package/dist/extensions/columns/keys.js +53 -0
- package/dist/extensions/columns/keys.js.map +1 -0
- package/dist/extensions/columns/plugin.js +213 -0
- package/dist/extensions/columns/plugin.js.map +1 -0
- package/dist/extensions/columns/schema.js +58 -0
- package/dist/extensions/columns/schema.js.map +1 -0
- package/dist/extensions/columns/select-columns.js +6 -0
- package/dist/extensions/columns/select-columns.js.map +1 -0
- package/dist/extensions/columns/select-columns.vue_vue_type_script_setup_true_lang.js +71 -0
- package/dist/extensions/columns/select-columns.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/extensions/editor-kit.js +3 -1
- package/dist/extensions/editor-kit.js.map +1 -1
- package/dist/extensions/list-html.js +1 -1
- package/dist/extensions/list-html.js.map +1 -1
- package/dist/extensions/table/plugin.js +33 -1
- package/dist/extensions/table/plugin.js.map +1 -1
- package/dist/extensions/table/schema.js +5 -1
- package/dist/extensions/table/schema.js.map +1 -1
- package/dist/extensions/table/table-controls.js.map +1 -1
- package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js +80 -9
- package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js.map +1 -1
- package/dist/extensions/table/view.js +181 -3
- package/dist/extensions/table/view.js.map +1 -1
- package/dist/flow/board-block.js +6 -0
- package/dist/flow/board-block.js.map +1 -0
- package/dist/flow/board-block.vue_vue_type_script_setup_true_lang.js +659 -0
- package/dist/flow/board-block.vue_vue_type_script_setup_true_lang.js.map +1 -0
- package/dist/flow/board.js +221 -0
- package/dist/flow/board.js.map +1 -0
- package/dist/flow/index.js +173 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/dist/locale.js +78 -6
- package/dist/locale.js.map +1 -1
- package/dist/markdown/cjk-friendly.js +62 -0
- package/dist/markdown/cjk-friendly.js.map +1 -0
- package/dist/markdown/index.js +4 -3
- package/dist/markdown/index.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/style.js +2 -0
- package/dist/types/collaboration/binding.d.ts +12 -0
- package/dist/types/collaboration/cursors.d.ts +29 -1
- package/dist/types/collaboration/index.d.ts +53 -6
- package/dist/types/collaboration/inline-diff.d.ts +9 -0
- package/dist/types/collaboration/merged-props.d.ts +20 -0
- package/dist/types/collaboration/order.d.ts +5 -0
- package/dist/types/collaboration/table.d.ts +5 -1
- package/dist/types/collaboration/text.d.ts +20 -0
- package/dist/types/components/slash-choices.vue.d.ts +18 -0
- package/dist/types/core/blocks.d.ts +10 -0
- package/dist/types/core/cjk.d.ts +23 -0
- package/dist/types/core/commands.d.ts +17 -2
- package/dist/types/core/comments.d.ts +39 -3
- package/dist/types/core/convert.d.ts +10 -2
- package/dist/types/core/extension.d.ts +58 -4
- package/dist/types/core/model.d.ts +6 -1
- package/dist/types/core/prepare.d.ts +16 -2
- package/dist/types/core/schema.d.ts +1 -1
- package/dist/types/core/transaction.d.ts +6 -0
- package/dist/types/define-block.d.ts +16 -4
- package/dist/types/document.d.ts +5 -2
- package/dist/types/dom.d.ts +41 -4
- package/dist/types/editor.d.ts +15 -1
- package/dist/types/editor.vue.d.ts +24 -0
- package/dist/types/extensions/columns/column-picker.vue.d.ts +10 -0
- package/dist/types/extensions/columns/columns-controls.vue.d.ts +3 -0
- package/dist/types/extensions/columns/html.d.ts +10 -0
- package/dist/types/extensions/columns/index.d.ts +9 -0
- package/dist/types/extensions/columns/keys.d.ts +6 -0
- package/dist/types/extensions/columns/plugin.d.ts +28 -0
- package/dist/types/extensions/columns/schema.d.ts +17 -0
- package/dist/types/extensions/columns/select-columns.vue.d.ts +13 -0
- package/dist/types/extensions/editor-kit.d.ts +4 -1
- package/dist/types/extensions/table/view.d.ts +36 -2
- package/dist/types/flow/board-block.vue.d.ts +16 -0
- package/dist/types/flow/board.d.ts +53 -0
- package/dist/types/flow/index.d.ts +65 -0
- package/dist/types/index.d.ts +29 -4
- package/dist/types/locale.d.ts +34 -0
- package/dist/types/markdown/cjk-friendly.d.ts +6 -0
- package/dist/types/markdown/index.d.ts +11 -4
- package/dist/types/use-comments.d.ts +1 -0
- package/dist/use-comments.js +63 -9
- package/dist/use-comments.js.map +1 -1
- package/package.json +14 -5
|
@@ -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__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AC3B,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 /** Where the \"+\" row button starts: under the table, or flush under its scrollbar track. */\n rowAddTop: number\n rowAddAfterScrollbar: boolean\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) {\n observeFrame(null)\n return (layout.value = null)\n }\n const tableNode = current.state.doc.nodeAt(at.pos)\n const frameElement = current.nodeDOM(at.pos) as HTMLElement | null\n const viewportElement =\n frameElement?.querySelector<HTMLElement>(':scope > .dou-editor-table__viewport') ?? frameElement\n const tableElement = viewportElement?.querySelector('table')\n if (!tableNode || !frameElement || !viewportElement || !tableElement) {\n observeFrame(null)\n return (layout.value = null)\n }\n observeFrame(frameElement)\n const box = host.getBoundingClientRect()\n const tableBox = tableElement.getBoundingClientRect()\n const frameBox = viewportElement.getBoundingClientRect()\n const outerBox = frameElement.getBoundingClientRect()\n const scrollable = frameElement.classList.contains('is-scrollable')\n observedScrollable = scrollable\n const barElement = scrollable\n ? frameElement.querySelector<HTMLElement>(':scope > .dou-editor-table__scrollbar')\n : null\n const barBox = barElement?.getBoundingClientRect()\n const rowAddBottom = barBox && barBox.height > 0 ? barBox.bottom : outerBox.bottom\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 rowAddTop: (scrollable ? rowAddBottom : tableBox.bottom) - box.top,\n rowAddAfterScrollbar: scrollable,\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\nlet lastPoint: { x: number; y: number } | null = null\n\nlet observedFrame: HTMLElement | null = null\nlet observedScrollable = false\nconst frameResize =\n typeof ResizeObserver !== 'undefined' ? new ResizeObserver(() => schedule()) : null\nconst frameClasses =\n typeof MutationObserver !== 'undefined'\n ? new MutationObserver(() => {\n if (!observedFrame) return\n const scrollable = observedFrame.classList.contains('is-scrollable')\n if (scrollable === observedScrollable) return\n observedScrollable = scrollable\n schedule()\n })\n : null\n\n/** Watch the active table frame so container resizes and `is-scrollable` toggles re-place the \"+\" bar. */\nfunction observeFrame(element: HTMLElement | null) {\n if (element === observedFrame) return\n frameResize?.disconnect()\n frameClasses?.disconnect()\n observedFrame = element\n observedScrollable = !!element?.classList.contains('is-scrollable')\n if (!element) return\n frameResize?.observe(element)\n frameClasses?.observe(element, { attributes: true, attributeFilter: ['class'] })\n}\n\n/**\n * True while the pointer crosses the strip between a scrollable table's bottom\n * edge and its row \"+\" button — over the custom scrollbar or the open lane\n * beside it when a scrolled wide table reaches into the start margin.\n */\nfunction inBottomBridge(element: Element | null, point: { x: number; y: number } | null): boolean {\n const active = hovered.value\n const current = view.value\n if (!active || !current) return false\n const frameElement = current.nodeDOM(active.pos) as HTMLElement | null\n if (!frameElement) return false\n if (element?.closest('.dou-editor-table__scrollbar')?.parentElement === frameElement) return true\n if (!point || !frameElement.classList.contains('is-scrollable')) return false\n const viewportElement =\n frameElement.querySelector<HTMLElement>(':scope > .dou-editor-table__viewport') ?? frameElement\n const tableElement = viewportElement.querySelector('table')\n if (!tableElement) return false\n const tableBox = tableElement.getBoundingClientRect()\n const frameBox = viewportElement.getBoundingClientRect()\n const barBox = frameElement\n .querySelector<HTMLElement>(':scope > .dou-editor-table__scrollbar')\n ?.getBoundingClientRect()\n const left = Math.max(frameBox.left, tableBox.left)\n const right = Math.min(tableBox.right, frameBox.right)\n const top = tableBox.bottom - 1\n const bottom =\n (barBox && barBox.height > 0 ? barBox.bottom : frameElement.getBoundingClientRect().bottom) + 1\n return point.x >= left && point.x <= right && point.y >= top && point.y <= bottom\n}\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 && !inBottomBridge(element, lastPoint)) hovered.value = null\n }\n measure()\n })\n}\n\nfunction track(event: PointerEvent) {\n if (event.pointerType === 'touch') return\n lastTarget = event.target\n lastPoint = { x: event.clientX, y: event.clientY }\n schedule()\n}\n\nfunction leave() {\n if (menuOpen.value || dragging.value) return\n lastTarget = null\n lastPoint = 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 observeFrame(null)\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 :class=\"{ 'is-after-scrollbar': layout.rowAddAfterScrollbar }\"\n :style=\"{\n top: `${layout.rowAddTop}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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L,UAAQ,CAAG,IAAIG,MAAA,UAAA,CAAU;MACzB,SAAK,OAAA,QAAA,OAAA,OAAA,WAAE,IAAIA,MAAA,UAAA,CAAU;K,IAEtBD,YAAaC,MAAA,SAAA,CAAA,GAAGE,gBAAAC,gBAAAH,MAAA,QAAA,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,17 +1,195 @@
|
|
|
1
1
|
import { TableView } from "prosemirror-tables";
|
|
2
|
+
/** The least length of the horizontal scrollbar thumb, so wide tables stay easy to grab. */
|
|
3
|
+
var MIN_THUMB = 24;
|
|
4
|
+
/** How long the scrollbar stays visible after scrolling stops, in ms. */
|
|
5
|
+
var SCROLL_IDLE_MS = 900;
|
|
2
6
|
/**
|
|
3
|
-
* A table in the editor:
|
|
4
|
-
* around the table,
|
|
7
|
+
* A table in the editor: an outer frame (`this.dom`, the block's content
|
|
8
|
+
* element), an inner scrolling viewport around the table, and a lightweight
|
|
9
|
+
* custom horizontal scrollbar aligned to the text column's start edge.
|
|
10
|
+
*
|
|
11
|
+
* Keeping the viewport inside the frame lets top-level wide tables scroll into
|
|
12
|
+
* the left reading-width margin while the scrollbar starts flush with the
|
|
13
|
+
* text column, and prevents the edge-fade mask (`is-cut-start` / `is-cut-end`)
|
|
14
|
+
* from fading the ends of the scrollbar itself.
|
|
5
15
|
*/
|
|
6
16
|
var TableBlockView = class extends TableView {
|
|
17
|
+
viewport;
|
|
18
|
+
bar;
|
|
19
|
+
thumb;
|
|
20
|
+
observer = null;
|
|
21
|
+
thumbSize = 0;
|
|
22
|
+
dragging = false;
|
|
23
|
+
dragStartX = 0;
|
|
24
|
+
dragStartScroll = 0;
|
|
25
|
+
idleTimer;
|
|
26
|
+
rafId = 0;
|
|
27
|
+
onScroll = () => {
|
|
28
|
+
this.sync();
|
|
29
|
+
this.dom.classList.add("is-scrolling");
|
|
30
|
+
clearTimeout(this.idleTimer);
|
|
31
|
+
this.idleTimer = setTimeout(() => {
|
|
32
|
+
this.dom.classList.remove("is-scrolling");
|
|
33
|
+
}, SCROLL_IDLE_MS);
|
|
34
|
+
};
|
|
35
|
+
onResize = () => this.scheduleSync();
|
|
36
|
+
onBarMouseDown = (event) => {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
};
|
|
39
|
+
onTrackDown = (event) => {
|
|
40
|
+
if (event.button !== 0) return;
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
event.stopPropagation();
|
|
43
|
+
if (!this.thumbSize) this.updateScrollbar();
|
|
44
|
+
const room = this.viewport.scrollWidth - this.viewport.clientWidth;
|
|
45
|
+
const box = this.bar.getBoundingClientRect();
|
|
46
|
+
const free = box.width - this.thumbSize;
|
|
47
|
+
if (room <= 1 || free <= 0) return;
|
|
48
|
+
const rtl = this.isRtl();
|
|
49
|
+
const at = (rtl ? box.right - event.clientX : event.clientX - box.left) - this.thumbSize / 2;
|
|
50
|
+
const ratio = Math.min(1, Math.max(0, at / free));
|
|
51
|
+
this.viewport.scrollLeft = rtl ? -ratio * room : ratio * room;
|
|
52
|
+
this.sync();
|
|
53
|
+
};
|
|
54
|
+
onThumbDown = (event) => {
|
|
55
|
+
if (event.button !== 0) return;
|
|
56
|
+
event.preventDefault();
|
|
57
|
+
event.stopPropagation();
|
|
58
|
+
if (!this.thumbSize) this.updateScrollbar();
|
|
59
|
+
this.thumb.setPointerCapture?.(event.pointerId);
|
|
60
|
+
this.dragging = true;
|
|
61
|
+
this.dragStartX = event.clientX;
|
|
62
|
+
this.dragStartScroll = this.viewport.scrollLeft;
|
|
63
|
+
this.dom.classList.add("is-dragging");
|
|
64
|
+
window.addEventListener("pointermove", this.onThumbMove);
|
|
65
|
+
window.addEventListener("pointerup", this.onThumbUp);
|
|
66
|
+
window.addEventListener("pointercancel", this.onThumbUp);
|
|
67
|
+
};
|
|
68
|
+
onThumbMove = (event) => {
|
|
69
|
+
if (!this.dragging) return;
|
|
70
|
+
const room = this.viewport.scrollWidth - this.viewport.clientWidth;
|
|
71
|
+
const free = (this.bar.clientWidth || this.bar.getBoundingClientRect().width) - this.thumbSize;
|
|
72
|
+
if (room <= 1 || free <= 0) return;
|
|
73
|
+
const moved = event.clientX - this.dragStartX;
|
|
74
|
+
const next = this.dragStartScroll + moved / free * room;
|
|
75
|
+
this.viewport.scrollLeft = this.isRtl() ? Math.min(0, Math.max(-room, next)) : Math.max(0, Math.min(room, next));
|
|
76
|
+
this.sync();
|
|
77
|
+
};
|
|
78
|
+
onThumbUp = () => {
|
|
79
|
+
if (!this.dragging) return;
|
|
80
|
+
this.dragging = false;
|
|
81
|
+
this.dom.classList.remove("is-dragging");
|
|
82
|
+
window.removeEventListener("pointermove", this.onThumbMove);
|
|
83
|
+
window.removeEventListener("pointerup", this.onThumbUp);
|
|
84
|
+
window.removeEventListener("pointercancel", this.onThumbUp);
|
|
85
|
+
};
|
|
7
86
|
constructor(node) {
|
|
8
87
|
super(node, 96);
|
|
9
88
|
this.dom.className = "dou-editor__content dou-editor__content--table";
|
|
10
89
|
this.dom.dataset.contentType = "table";
|
|
11
90
|
this.table.className = "dou-editor-table";
|
|
91
|
+
this.viewport = document.createElement("div");
|
|
92
|
+
this.viewport.className = "dou-editor-table__viewport";
|
|
93
|
+
this.viewport.appendChild(this.table);
|
|
94
|
+
this.dom.appendChild(this.viewport);
|
|
95
|
+
this.bar = document.createElement("div");
|
|
96
|
+
this.bar.className = "dou-editor-table__scrollbar";
|
|
97
|
+
this.bar.contentEditable = "false";
|
|
98
|
+
this.bar.setAttribute("aria-hidden", "true");
|
|
99
|
+
this.thumb = document.createElement("div");
|
|
100
|
+
this.thumb.className = "dou-editor-table__scrollbar-thumb";
|
|
101
|
+
this.bar.appendChild(this.thumb);
|
|
102
|
+
this.dom.appendChild(this.bar);
|
|
103
|
+
this.viewport.addEventListener("scroll", this.onScroll, { passive: true });
|
|
104
|
+
this.bar.addEventListener("mousedown", this.onBarMouseDown);
|
|
105
|
+
this.bar.addEventListener("pointerdown", this.onTrackDown);
|
|
106
|
+
this.thumb.addEventListener("pointerdown", this.onThumbDown);
|
|
107
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
108
|
+
this.observer = new ResizeObserver(this.onResize);
|
|
109
|
+
this.observer.observe(this.dom);
|
|
110
|
+
this.observer.observe(this.viewport);
|
|
111
|
+
this.observer.observe(this.table);
|
|
112
|
+
this.observer.observe(this.bar);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
isRtl() {
|
|
116
|
+
return getComputedStyle(this.viewport).direction === "rtl";
|
|
117
|
+
}
|
|
118
|
+
scheduleSync() {
|
|
119
|
+
if (this.rafId || typeof requestAnimationFrame === "undefined") {
|
|
120
|
+
if (typeof requestAnimationFrame === "undefined") this.sync();
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
this.rafId = requestAnimationFrame(() => {
|
|
124
|
+
this.rafId = 0;
|
|
125
|
+
this.sync();
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/** Sync edge-fade classes and the custom scrollbar thumb geometry. */
|
|
129
|
+
sync() {
|
|
130
|
+
this.edges();
|
|
131
|
+
this.updateScrollbar();
|
|
132
|
+
}
|
|
133
|
+
/** Which sides cut columns off: the table's edges against the viewport's, padding left out. */
|
|
134
|
+
edges() {
|
|
135
|
+
const viewport = this.viewport;
|
|
136
|
+
const style = getComputedStyle(viewport);
|
|
137
|
+
const start = Number.parseFloat(style.paddingInlineStart) || 0;
|
|
138
|
+
const end = Number.parseFloat(style.paddingInlineEnd) || 0;
|
|
139
|
+
const hidden = viewport.scrollWidth - viewport.clientWidth;
|
|
140
|
+
const left = Math.abs(viewport.scrollLeft);
|
|
141
|
+
viewport.classList.toggle("is-cut-start", left > start + .5);
|
|
142
|
+
viewport.classList.toggle("is-cut-end", left < hidden - end - .5);
|
|
143
|
+
}
|
|
144
|
+
/** Size and position the custom scrollbar thumb along its track. */
|
|
145
|
+
updateScrollbar() {
|
|
146
|
+
const viewport = this.viewport;
|
|
147
|
+
const client = viewport.clientWidth;
|
|
148
|
+
const total = viewport.scrollWidth;
|
|
149
|
+
const room = total - client;
|
|
150
|
+
const active = room > 1;
|
|
151
|
+
this.dom.classList.toggle("is-scrollable", active);
|
|
152
|
+
this.bar.classList.toggle("is-active", active);
|
|
153
|
+
if (!active) {
|
|
154
|
+
this.thumbSize = 0;
|
|
155
|
+
return;
|
|
156
|
+
}
|
|
157
|
+
const track = this.bar.clientWidth || this.bar.getBoundingClientRect().width;
|
|
158
|
+
if (track <= 0) return;
|
|
159
|
+
const size = Math.min(track, Math.max(MIN_THUMB, Math.round(client / total * track)));
|
|
160
|
+
const free = track - size;
|
|
161
|
+
const ratio = Math.min(1, Math.max(0, Math.abs(viewport.scrollLeft) / room));
|
|
162
|
+
const offset = Math.round(ratio * free);
|
|
163
|
+
const rtl = this.isRtl();
|
|
164
|
+
this.thumbSize = size;
|
|
165
|
+
this.thumb.style.width = `${size}px`;
|
|
166
|
+
this.thumb.style.transform = `translateX(${rtl ? -offset : offset}px)`;
|
|
167
|
+
}
|
|
168
|
+
update(node) {
|
|
169
|
+
const ok = super.update(node);
|
|
170
|
+
if (ok) this.scheduleSync();
|
|
171
|
+
return ok;
|
|
172
|
+
}
|
|
173
|
+
stopEvent(event) {
|
|
174
|
+
return event.target instanceof Node && this.bar.contains(event.target);
|
|
12
175
|
}
|
|
13
176
|
ignoreMutation(record) {
|
|
14
|
-
|
|
177
|
+
const target = record.target;
|
|
178
|
+
if (target instanceof Node && this.bar.contains(target)) return true;
|
|
179
|
+
if (record.type === "attributes" && (target === this.dom || target === this.viewport)) return true;
|
|
180
|
+
return super.ignoreMutation(record);
|
|
181
|
+
}
|
|
182
|
+
destroy() {
|
|
183
|
+
this.viewport.removeEventListener("scroll", this.onScroll);
|
|
184
|
+
this.bar.removeEventListener("mousedown", this.onBarMouseDown);
|
|
185
|
+
this.bar.removeEventListener("pointerdown", this.onTrackDown);
|
|
186
|
+
this.thumb.removeEventListener("pointerdown", this.onThumbDown);
|
|
187
|
+
window.removeEventListener("pointermove", this.onThumbMove);
|
|
188
|
+
window.removeEventListener("pointerup", this.onThumbUp);
|
|
189
|
+
window.removeEventListener("pointercancel", this.onThumbUp);
|
|
190
|
+
this.observer?.disconnect();
|
|
191
|
+
clearTimeout(this.idleTimer);
|
|
192
|
+
if (this.rafId && typeof cancelAnimationFrame !== "undefined") cancelAnimationFrame(this.rafId);
|
|
15
193
|
}
|
|
16
194
|
};
|
|
17
195
|
export { TableBlockView };
|
|
@@ -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/** The least length of the horizontal scrollbar thumb, so wide tables stay easy to grab. */\nconst MIN_THUMB = 24\n\n/** How long the scrollbar stays visible after scrolling stops, in ms. */\nconst SCROLL_IDLE_MS = 900\n\n/**\n * A table in the editor: an outer frame (`this.dom`, the block's content\n * element), an inner scrolling viewport around the table, and a lightweight\n * custom horizontal scrollbar aligned to the text column's start edge.\n *\n * Keeping the viewport inside the frame lets top-level wide tables scroll into\n * the left reading-width margin while the scrollbar starts flush with the\n * text column, and prevents the edge-fade mask (`is-cut-start` / `is-cut-end`)\n * from fading the ends of the scrollbar itself.\n */\nexport class TableBlockView extends TableView implements NodeView {\n readonly viewport: HTMLDivElement\n readonly bar: HTMLDivElement\n readonly thumb: HTMLDivElement\n\n private readonly observer: ResizeObserver | null = null\n private thumbSize = 0\n private dragging = false\n private dragStartX = 0\n private dragStartScroll = 0\n private idleTimer: ReturnType<typeof setTimeout> | undefined\n private rafId = 0\n\n private readonly onScroll = () => {\n this.sync()\n this.dom.classList.add('is-scrolling')\n clearTimeout(this.idleTimer)\n this.idleTimer = setTimeout(() => {\n this.dom.classList.remove('is-scrolling')\n }, SCROLL_IDLE_MS)\n }\n\n private readonly onResize = () => this.scheduleSync()\n\n private readonly onBarMouseDown = (event: MouseEvent) => {\n // Keep ProseMirror from moving the text selection or blurring the editor.\n event.preventDefault()\n }\n\n private readonly onTrackDown = (event: PointerEvent) => {\n if (event.button !== 0) return\n event.preventDefault()\n event.stopPropagation()\n if (!this.thumbSize) this.updateScrollbar()\n const room = this.viewport.scrollWidth - this.viewport.clientWidth\n const box = this.bar.getBoundingClientRect()\n const free = box.width - this.thumbSize\n if (room <= 1 || free <= 0) return\n const rtl = this.isRtl()\n const at = (rtl ? box.right - event.clientX : event.clientX - box.left) - this.thumbSize / 2\n const ratio = Math.min(1, Math.max(0, at / free))\n this.viewport.scrollLeft = rtl ? -ratio * room : ratio * room\n this.sync()\n }\n\n private readonly onThumbDown = (event: PointerEvent) => {\n if (event.button !== 0) return\n event.preventDefault()\n event.stopPropagation()\n if (!this.thumbSize) this.updateScrollbar()\n this.thumb.setPointerCapture?.(event.pointerId)\n this.dragging = true\n this.dragStartX = event.clientX\n this.dragStartScroll = this.viewport.scrollLeft\n this.dom.classList.add('is-dragging')\n window.addEventListener('pointermove', this.onThumbMove)\n window.addEventListener('pointerup', this.onThumbUp)\n window.addEventListener('pointercancel', this.onThumbUp)\n }\n\n private readonly onThumbMove = (event: PointerEvent) => {\n if (!this.dragging) return\n const room = this.viewport.scrollWidth - this.viewport.clientWidth\n const track = this.bar.clientWidth || this.bar.getBoundingClientRect().width\n const free = track - this.thumbSize\n if (room <= 1 || free <= 0) return\n const moved = event.clientX - this.dragStartX\n const next = this.dragStartScroll + (moved / free) * room\n this.viewport.scrollLeft = this.isRtl()\n ? Math.min(0, Math.max(-room, next))\n : Math.max(0, Math.min(room, next))\n this.sync()\n }\n\n private readonly onThumbUp = () => {\n if (!this.dragging) return\n this.dragging = false\n this.dom.classList.remove('is-dragging')\n window.removeEventListener('pointermove', this.onThumbMove)\n window.removeEventListener('pointerup', this.onThumbUp)\n window.removeEventListener('pointercancel', this.onThumbUp)\n }\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\n this.viewport = document.createElement('div')\n this.viewport.className = 'dou-editor-table__viewport'\n this.viewport.appendChild(this.table)\n this.dom.appendChild(this.viewport)\n\n this.bar = document.createElement('div')\n this.bar.className = 'dou-editor-table__scrollbar'\n this.bar.contentEditable = 'false'\n this.bar.setAttribute('aria-hidden', 'true')\n\n this.thumb = document.createElement('div')\n this.thumb.className = 'dou-editor-table__scrollbar-thumb'\n this.bar.appendChild(this.thumb)\n this.dom.appendChild(this.bar)\n\n this.viewport.addEventListener('scroll', this.onScroll, { passive: true })\n this.bar.addEventListener('mousedown', this.onBarMouseDown)\n this.bar.addEventListener('pointerdown', this.onTrackDown)\n this.thumb.addEventListener('pointerdown', this.onThumbDown)\n\n if (typeof ResizeObserver !== 'undefined') {\n // the frame, viewport, table (columns added/removed/resized), and track width (reading margin changes)\n this.observer = new ResizeObserver(this.onResize)\n this.observer.observe(this.dom)\n this.observer.observe(this.viewport)\n this.observer.observe(this.table)\n this.observer.observe(this.bar)\n }\n }\n\n private isRtl() {\n return getComputedStyle(this.viewport).direction === 'rtl'\n }\n\n private scheduleSync() {\n if (this.rafId || typeof requestAnimationFrame === 'undefined') {\n if (typeof requestAnimationFrame === 'undefined') this.sync()\n return\n }\n this.rafId = requestAnimationFrame(() => {\n this.rafId = 0\n this.sync()\n })\n }\n\n /** Sync edge-fade classes and the custom scrollbar thumb geometry. */\n private sync() {\n this.edges()\n this.updateScrollbar()\n }\n\n /** Which sides cut columns off: the table's edges against the viewport's, padding left out. */\n private edges() {\n const viewport = this.viewport\n const style = getComputedStyle(viewport)\n const start = Number.parseFloat(style.paddingInlineStart) || 0\n const end = Number.parseFloat(style.paddingInlineEnd) || 0\n const hidden = viewport.scrollWidth - viewport.clientWidth\n // `scrollLeft` is negative in right-to-left pages.\n const left = Math.abs(viewport.scrollLeft)\n viewport.classList.toggle('is-cut-start', left > start + 0.5)\n viewport.classList.toggle('is-cut-end', left < hidden - end - 0.5)\n }\n\n /** Size and position the custom scrollbar thumb along its track. */\n private updateScrollbar() {\n const viewport = this.viewport\n const client = viewport.clientWidth\n const total = viewport.scrollWidth\n const room = total - client\n const active = room > 1\n this.dom.classList.toggle('is-scrollable', active)\n this.bar.classList.toggle('is-active', active)\n if (!active) {\n this.thumbSize = 0\n return\n }\n const track = this.bar.clientWidth || this.bar.getBoundingClientRect().width\n if (track <= 0) return\n const size = Math.min(track, Math.max(MIN_THUMB, Math.round((client / total) * track)))\n const free = track - size\n const ratio = Math.min(1, Math.max(0, Math.abs(viewport.scrollLeft) / room))\n const offset = Math.round(ratio * free)\n const rtl = this.isRtl()\n this.thumbSize = size\n this.thumb.style.width = `${size}px`\n this.thumb.style.transform = `translateX(${rtl ? -offset : offset}px)`\n }\n\n override update(node: PMNode) {\n const ok = super.update(node)\n if (ok) this.scheduleSync()\n return ok\n }\n\n stopEvent(event: Event) {\n return event.target instanceof Node && this.bar.contains(event.target)\n }\n\n override ignoreMutation(record: ViewMutationRecord) {\n // the frame's and viewport's attributes are ours; the custom scrollbar is non-editable chrome\n const target = record.target\n if (target instanceof Node && this.bar.contains(target)) return true\n if (record.type === 'attributes' && (target === this.dom || target === this.viewport))\n return true\n return super.ignoreMutation(record)\n }\n\n destroy() {\n this.viewport.removeEventListener('scroll', this.onScroll)\n this.bar.removeEventListener('mousedown', this.onBarMouseDown)\n this.bar.removeEventListener('pointerdown', this.onTrackDown)\n this.thumb.removeEventListener('pointerdown', this.onThumbDown)\n window.removeEventListener('pointermove', this.onThumbMove)\n window.removeEventListener('pointerup', this.onThumbUp)\n window.removeEventListener('pointercancel', this.onThumbUp)\n this.observer?.disconnect()\n clearTimeout(this.idleTimer)\n if (this.rafId && typeof cancelAnimationFrame !== 'undefined') cancelAnimationFrame(this.rafId)\n }\n}\n"],"mappings":";;AAQA,IAAM,YAAY;;AAGlB,IAAM,iBAAiB;;;;;;;;;;;AAYvB,IAAa,iBAAb,cAAoC,UAA8B;CAChE;CACA;CACA;CAEA,WAAmD;CACnD,YAAoB;CACpB,WAAmB;CACnB,aAAqB;CACrB,kBAA0B;CAC1B;CACA,QAAgB;CAEhB,iBAAkC;EAChC,KAAK,KAAK;EACV,KAAK,IAAI,UAAU,IAAI,cAAc;EACrC,aAAa,KAAK,SAAS;EAC3B,KAAK,YAAY,iBAAiB;GAChC,KAAK,IAAI,UAAU,OAAO,cAAc;EAC1C,GAAG,cAAc;CACnB;CAEA,iBAAkC,KAAK,aAAa;CAEpD,kBAAmC,UAAsB;EAEvD,MAAM,eAAe;CACvB;CAEA,eAAgC,UAAwB;EACtD,IAAI,MAAM,WAAW,GAAG;EACxB,MAAM,eAAe;EACrB,MAAM,gBAAgB;EACtB,IAAI,CAAC,KAAK,WAAW,KAAK,gBAAgB;EAC1C,MAAM,OAAO,KAAK,SAAS,cAAc,KAAK,SAAS;EACvD,MAAM,MAAM,KAAK,IAAI,sBAAsB;EAC3C,MAAM,OAAO,IAAI,QAAQ,KAAK;EAC9B,IAAI,QAAQ,KAAK,QAAQ,GAAG;EAC5B,MAAM,MAAM,KAAK,MAAM;EACvB,MAAM,MAAM,MAAM,IAAI,QAAQ,MAAM,UAAU,MAAM,UAAU,IAAI,QAAQ,KAAK,YAAY;EAC3F,MAAM,QAAQ,KAAK,IAAI,GAAG,KAAK,IAAI,GAAG,KAAK,IAAI,CAAC;EAChD,KAAK,SAAS,aAAa,MAAM,CAAC,QAAQ,OAAO,QAAQ;EACzD,KAAK,KAAK;CACZ;CAEA,eAAgC,UAAwB;EACtD,IAAI,MAAM,WAAW,GAAG;EACxB,MAAM,eAAe;EACrB,MAAM,gBAA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,MAAM,SAAS,OAAO;EACtB,IAAI,kBAAkB,QAAQ,KAAK,IAAI,SAAS,MAAM,GAAG,OAAO;EAChE,IAAI,OAAO,SAAS,iBAAiB,WAAW,KAAK,OAAO,WAAW,KAAK,WAC1E,OAAO;EACT,OAAO,MAAM,eAAe,MAAM;CACpC;CAEA,UAAU;EACR,KAAK,SAAS,oBAAoB,UAAU,KAAK,QAAQ;EACzD,KAAK,IAAI,oBAAoB,aAAa,KAAK,cAAc;EAC7D,KAAK,IAAI,oBAAoB,eAAe,KAAK,WAAW;EAC5D,KAAK,MAAM,oBAAoB,eAAe,KAAK,WAAW;EAC9D,OAAO,oBAAoB,eAAe,KAAK,WAAW;EAC1D,OAAO,oBAAoB,aAAa,KAAK,SAAS;EACtD,OAAO,oBAAoB,iBAAiB,KAAK,SAAS;EAC1D,KAAK,UAAU,WAAW;EAC1B,aAAa,KAAK,SAAS;EAC3B,IAAI,KAAK,SAAS,OAAO,yBAAyB,aAAa,qBAAqB,KAAK,KAAK;CAChG;AACF"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import board_block_vue_vue_type_script_setup_true_lang_default from "./board-block.vue_vue_type_script_setup_true_lang.js";
|
|
2
|
+
// src/flow/board-block.vue
|
|
3
|
+
var board_block_default = board_block_vue_vue_type_script_setup_true_lang_default;
|
|
4
|
+
export { board_block_default as default };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=board-block.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"board-block.js","names":["_sfc_main"],"sources":["../../src/flow/board-block.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n defaultNode,\n defineNodeType,\n DouFlowControls,\n DouFlowEditor,\n defineFlowExtension,\n type NodeTypeSpec,\n type FlowDocument,\n type FlowExtension,\n type FlowHistoryHandler,\n type FlowNode,\n type FlowTransaction,\n} from '@dou-ui/flow'\nimport type { CommentAction, CommentThread } from 'dou-ui'\nimport { EyeIcon, PencilIcon, PlusIcon, SquareIcon } from '@dou-ui/icons'\nimport { DouButton, DouCommand, DouDialog, DouPopover, type CommandItem } from 'dou-ui'\nimport { NodeSelection } from 'prosemirror-state'\nimport {\n computed,\n nextTick,\n onBeforeUnmount,\n onMounted,\n shallowRef,\n useTemplateRef,\n watch,\n} from 'vue'\nimport { findBlockById } from '../core/blocks'\nimport { historyCommands } from '../core/editor'\nimport { labelOf } from '../core/extension'\nimport type { BlockProps } from '../core/model'\nimport { joinStepKey, ownStepKey } from '../core/transaction'\nimport { useEditor } from '../editor'\nimport {\n BOARD_HEIGHT,\n BOARD_OPEN_EVENT,\n boardComments,\n boardOf,\n clampHeight,\n onlyBoardChanged,\n type BoardBlockSettings,\n} from './board'\n\n/** The board with the groups this reader folded or unfolded. */\nfunction withFolded(board: FlowDocument, folded: Map<string, boolean>): FlowDocument {\n if (!folded.size) return board\n const nodes = board.nodes.map((node) => {\n if (!folded.has(node.id)) return node\n const { collapsed: _, ...data } = node.data ?? {}\n return { ...node, data: folded.get(node.id) ? { ...data, collapsed: true } : data }\n })\n return { ...board, nodes }\n}\n\nconst props = defineProps<{\n block: { id: string; type: string; props: BlockProps }\n updateProps: (props: BlockProps) => void\n selected: boolean\n editable: boolean\n settings: BoardBlockSettings\n}>()\n\nconst { view, messages, comments } = useEditor()\nconst text = computed(() => messages.value.board)\nconst label = computed(() => labelOf(props.settings.label, messages.value))\nconst stored = computed(() => boardOf(props.block.props.board))\n/*\n * Whether a group is folded is each reader's own view, as with toggles: it\n * stays out of the document (what it holds there is kept), and is shown\n * from here.\n */\nconst folded = shallowRef(new Map<string, boolean>())\nconst board = computed(() => withFolded(stored.value, folded.value))\nconst empty = computed(() => !board.value.nodes.length)\n\n/* the fullscreen editor */\nconst open = shallowRef(false)\n/** The fullscreen editor is in place (its dialog done opening). */\nconst opened = shallowRef(false)\nwatch(open, (value) => {\n if (!value) shown.value = board.value\n})\n\n/*\n * Comment threads on the nodes and edges: the document's threads, author\n * and open thread, shown by the flow editors. The ids are kept on the nodes\n * and edges (see `boardComments`); a thread opened from outside, e.g. a\n * list of the document's comments, opens the fullscreen editor at it.\n */\nconst flowComments = computed(() =>\n props.settings.commentable && comments.enabled.value\n ? (comments.threads.value as CommentThread[])\n : undefined,\n)\nconst threadsHere = computed(\n () =>\n new Set(\n props.settings.commentable ? Object.keys(boardComments.anchors(props.block.props)) : [],\n ),\n)\nconst here = (id: string | null): id is string => !!id && threadsHere.value.has(id)\n/** The open thread, when it is on this board and the fullscreen editor shows it. */\nconst boardActive = computed(() =>\n opened.value && here(comments.active.value) ? comments.active.value : null,\n)\nwatch(\n () => comments.active.value,\n (id) => {\n if (here(id) && !open.value) openEditor()\n },\n)\n/*\n * The preview can't be pressed (it is inert and lets the pointer through to\n * the block), but its comment markers look like buttons: a click or tap on\n * one opens the board at its thread.\n */\nconst markerCursor = shallowRef(false)\nfunction markerAt(event: MouseEvent): string | null {\n if (!flowComments.value) return null\n const markers = root.value?.querySelectorAll<HTMLElement>(\n '.dou-editor-board__preview [data-thread]',\n )\n for (const marker of markers ?? []) {\n const box = marker.getBoundingClientRect()\n if (\n event.clientX >= box.left &&\n event.clientX <= box.right &&\n event.clientY >= box.top &&\n event.clientY <= box.bottom\n )\n return marker.dataset.thread ?? null\n }\n return null\n}\nfunction onPreviewClick(event: MouseEvent) {\n const id = markerAt(event)\n if (id) comments.open(id)\n}\nfunction onPreviewMove(event: PointerEvent) {\n if (event.pointerType === 'mouse') markerCursor.value = !!markerAt(event)\n}\n\nfunction onActive(id: string | null) {\n if (id !== boardActive.value) comments.open(id)\n}\nfunction onCommentAction(action: CommentAction) {\n comments.apply(action, { anchored: true })\n}\nfunction onClose() {\n settle()\n opened.value = false\n if (here(comments.active.value)) comments.open(null)\n}\n\nconst root = useTemplateRef<HTMLElement>('root')\nconst canvas = useTemplateRef<HTMLElement>('canvas')\nconst preview = useTemplateRef<InstanceType<typeof DouFlowEditor>>('preview')\n\n/* the height, followed live while the bar is dragged */\nconst dragged = shallowRef<number | null>(null)\nconst height = computed(\n () => dragged.value ?? clampHeight(Number(props.block.props.height) || props.settings.height),\n)\n\n/* the preview is drawn once the block comes near the screen */\nconst seen = shallowRef(typeof IntersectionObserver === 'undefined')\nlet observer: IntersectionObserver | null = null\nlet resized: ResizeObserver | null = null\nlet frame = 0\n/** Fits the preview to its box again, once the nodes have been laid out. */\nfunction refit() {\n cancelAnimationFrame(frame)\n frame = requestAnimationFrame(() => preview.value?.fit())\n}\nonMounted(() => {\n const element = root.value!\n element.addEventListener(BOARD_OPEN_EVENT, openEditor)\n if (!seen.value) {\n observer = new IntersectionObserver(\n (entries) => {\n if (!entries.some((entry) => entry.isIntersecting)) return\n seen.value = true\n observer?.disconnect()\n observer = null\n },\n { rootMargin: '200px' },\n )\n observer.observe(element)\n }\n if (typeof ResizeObserver !== 'undefined') {\n let width = element.clientWidth\n resized = new ResizeObserver(() => {\n if (element.clientWidth === width) return\n width = element.clientWidth\n refit()\n })\n resized.observe(element)\n }\n})\nonBeforeUnmount(() => {\n settle()\n root.value?.removeEventListener(BOARD_OPEN_EVENT, openEditor)\n observer?.disconnect()\n resized?.disconnect()\n cancelAnimationFrame(frame)\n})\n/* what the preview shows: held while the fullscreen editor covers it, so it isn't redrawn each frame */\nconst shown = shallowRef(board.value)\nwatch(board, (value) => {\n if (!open.value) shown.value = value\n})\nwatch(shown, () => void nextTick(refit))\nwatch(height, () => void nextTick(refit))\n\nfunction openEditor() {\n if (!props.editable && empty.value) return\n steps.undo = 0\n steps.redo = 0\n pending = null\n open.value = true\n}\n\nconst contentPos = () => {\n const state = view.value?.state\n return state ? (findBlockById(state.doc, props.block.id)?.contentPos ?? null) : null\n}\n\n/** The keys go to the canvas from the start: a tool's letter, `Esc` letting go of a selection. */\nfunction onOpened() {\n opened.value = true\n canvas.value?.querySelector<HTMLElement>('.dou-flow-editor')?.focus({ preventScroll: true })\n}\n\n/** Back in the document: the block selected, the editor focused. */\nfunction onClosed() {\n const editor = view.value\n const pos = contentPos()\n if (!editor || pos === null) return\n if (props.editable)\n editor.dispatch(editor.state.tr.setSelection(NodeSelection.create(editor.state.doc, pos)))\n editor.focus()\n}\n\n/*\n * Changes on the board go into the document as they are made, so `v-model`,\n * collaboration and the other blocks see them, and into the editor's undo\n * history: undo in the fullscreen editor is the document's, one step per\n * change on the board. The frames of a drag (or nudges with the arrow keys,\n * or typing in one node) join the step of the first one; only the fields\n * they change are written, so what others change meanwhile stays theirs. A\n * cancelled drag takes its step back.\n */\nconst GROUP_WINDOW = 1000\n/** A drag going on: its group, and when its last frame came. */\nlet pending: { group: string; time: number } | null = null\n/** The steps taken on the board since it was opened, and those undone. */\nconst steps = { undo: 0, redo: 0 }\n\n/** The board as the document keeps it: groups folded as they are there; and what this reader folded. */\nfunction toDocument(next: FlowDocument): FlowDocument {\n const before = new Map(stored.value.nodes.map((node) => [node.id, node]))\n let changed: Map<string, boolean> | null = null\n const nodes = next.nodes.map((node) => {\n const mine = !!node.data?.collapsed\n const theirs = before.get(node.id)?.data?.collapsed\n if (mine === !!theirs) {\n if (folded.value.has(node.id)) (changed ??= new Map(folded.value)).delete(node.id)\n return node\n }\n if (folded.value.get(node.id) !== mine) (changed ??= new Map(folded.value)).set(node.id, mine)\n const { collapsed: _, ...data } = node.data ?? {}\n if (theirs !== undefined) return { ...node, data: { ...data, collapsed: theirs } }\n // a node with no data before has none after\n if (Object.keys(data).length || before.get(node.id)?.data) return { ...node, data }\n const { data: __, ...rest } = node\n return rest as FlowNode\n })\n if (changed) folded.value = changed\n warnDataImages(next, before)\n return { ...next, nodes }\n}\n\nlet warned = false\n/** Pictures kept in the document as data URLs make it large: say so once, while developing. */\nfunction warnDataImages(next: FlowDocument, before: Map<string, FlowNode>) {\n if (warned || process.env.NODE_ENV === 'production') return\n const added = next.nodes.find(\n (node) =>\n typeof node.data?.src === 'string' &&\n node.data.src.startsWith('data:') &&\n before.get(node.id)?.data?.src !== node.data.src,\n )\n if (!added) return\n warned = true\n console.warn(\n `[@dou-ui/editor] a picture on the \"${props.block.type}\" block is kept in the document as a data URL; pass \\`upload\\` to whiteboardBlock() to keep only its address`,\n )\n}\n\nconst currentBoard = () => {\n const pos = contentPos()\n return pos === null ? null : (view.value?.state.doc.nodeAt(pos)?.attrs.board ?? null)\n}\n\n/** Writes the board as one undo step of its own. */\nfunction record(next: unknown) {\n const editor = view.value\n const pos = contentPos()\n if (!editor || pos === null) return\n editor.dispatch(editor.state.tr.setNodeAttribute(pos, 'board', next).setMeta(ownStepKey, true))\n steps.undo++\n steps.redo = 0\n}\n\n/** Writes the board into the undo step before, the drag's. */\nfunction join(next: unknown) {\n const editor = view.value\n const pos = contentPos()\n if (!editor || pos === null) return\n const tr = editor.state.tr.setNodeAttribute(pos, 'board', next).setMeta(joinStepKey, true)\n // for the built-in history: part of the step before, however long after\n editor.dispatch(tr.setMeta('appendedTransaction', editor.state.tr))\n}\n\n/** Ends the drag going on: the next change is a step of its own. */\nfunction settle() {\n pending = null\n}\n\nfunction forward(tr: FlowTransaction) {\n const editor = view.value\n const pos = contentPos()\n // a thread put on or taken off a node is written in a read-only document too, as on text\n const comment = tr.meta.origin === 'comment'\n if (!editor || pos === null || (!props.editable && !comment)) return\n const group = tr.meta.group\n const next = toDocument(tr.doc)\n // only folded or unfolded: nothing for the document\n if (JSON.stringify(next) === JSON.stringify(currentBoard())) return\n // not a step of the undo history, nor part of a drag going on\n if (comment) {\n editor.dispatch(\n editor.state.tr.setNodeAttribute(pos, 'board', next).setMeta('addToHistory', false),\n )\n return\n }\n const now = Date.now()\n if (pending && (pending.group !== group || now - pending.time >= GROUP_WINDOW)) {\n // a cancelled drag putting the board back: part of its step\n if (tr.meta.history === false) return join(next)\n settle()\n }\n if (tr.meta.history === false) {\n editor.dispatch(\n editor.state.tr.setNodeAttribute(pos, 'board', next).setMeta('addToHistory', false),\n )\n return\n }\n if (!group) return record(next)\n if (pending) {\n pending.time = now\n return join(next)\n }\n pending = { group, time: now }\n record(next)\n}\n\n/** Undo or redo in the document; refused when it would change something besides this board. */\nfunction travel(kind: 'undo' | 'redo') {\n settle()\n const editor = view.value\n if (!editor || !steps[kind]) return false\n const before = editor.state.doc\n const commands = historyCommands(editor.state)\n if (!commands[kind](editor.state, editor.dispatch, editor)) return false\n if (!onlyBoardChanged(before, editor.state.doc, props.block.id)) {\n // the board's own steps are used up: put back what was taken\n historyCommands(editor.state)[kind === 'undo' ? 'redo' : 'undo'](\n editor.state,\n editor.dispatch,\n editor,\n )\n steps[kind] = 0\n return false\n }\n steps[kind]--\n steps[kind === 'undo' ? 'redo' : 'undo']++\n return true\n}\n\n/** A cancelled drag: the board is back where it started, and its step is taken back. */\nfunction drop(group: string) {\n if (pending?.group !== group) return\n pending = null\n const editor = view.value\n if (!editor || !steps.undo) return\n if (historyCommands(editor.state).undo(editor.state, editor.dispatch, editor)) steps.undo--\n}\n\nconst history: FlowHistoryHandler = {\n undo: () => travel('undo'),\n redo: () => travel('redo'),\n canUndo: () => steps.undo > 0,\n canRedo: () => steps.redo > 0 && !pending,\n drop,\n close: settle,\n}\nconst bridge: FlowExtension = defineFlowExtension({\n name: 'editor-board-history',\n history: () => history,\n})\nconst extensions = [...props.settings.extensions, bridge]\n\n/*\n * Adding nodes: the types the extensions offer (`palette`), from a button\n * at the top left. When none is offered (`flowKit()` alone), a node of its\n * own with an input and an output, so what is added can be connected right\n * away.\n */\nconst offered = [\n ...props.settings.extensions.flat(),\n { nodeTypes: props.settings.editorProps.nodeTypes ?? [] },\n].some((extension) => extension.nodeTypes?.some((spec) => spec.palette))\nconst nodeTypes = computed(() => {\n const given = (props.settings.editorProps.nodeTypes ?? []) as NodeTypeSpec[]\n if (offered || !props.settings.fallbackNode) return given\n const name = text.value.node\n const step = defineNodeType({\n ...defaultNode,\n defaults: () => ({ label: name, inputs: [{ id: 'in' }], outputs: [{ id: 'out' }] }),\n palette: { label: name, icon: SquareIcon },\n }) as unknown as NodeTypeSpec\n return [step, ...given]\n})\nconst full = useTemplateRef<InstanceType<typeof DouFlowEditor>>('full')\nconst palette = computed(() => (props.editable ? (full.value?.paletteTypes ?? []) : []))\n/* several types: the same searchable list as when an edge is dropped on the canvas */\nconst adding = shallowRef(false)\nconst query = shallowRef('')\nconst addTrigger = useTemplateRef<InstanceType<typeof DouButton>>('addTrigger')\nconst command = useTemplateRef<InstanceType<typeof DouCommand>>('command')\nconst items = computed<CommandItem[]>(() =>\n palette.value.map((spec) => ({\n value: spec.type,\n label: spec.palette!.label,\n group: spec.palette!.group,\n description: spec.palette!.description,\n keywords: spec.palette!.keywords,\n icon: spec.palette!.icon,\n })),\n)\nwatch(adding, (value) => {\n if (!value) return\n query.value = ''\n // a phone's keyboard would cover the list: search only with a mouse\n if (!matchMedia('(pointer: coarse)').matches) void nextTick(() => command.value?.focus())\n})\n\nfunction addNode(type: string) {\n adding.value = false\n full.value?.insertNode(type)\n}\nfunction dragNode(type: string, event: PointerEvent) {\n if (event.button !== 0) return\n full.value?.startInsertDrag(type, event)\n // the list goes once the node is dropped, or the drag ends otherwise\n window.addEventListener(\n 'pointerup',\n () => {\n if (!adding.value) return\n adding.value = false\n // a drag let go of (or cancelled) off the canvas: back to the button\n void nextTick(() => {\n // the list may not be hidden yet: focus still in its search field\n const active = document.activeElement\n const list = command.value?.$el as HTMLElement | undefined\n if (!active || active === document.body || list?.contains(active))\n (addTrigger.value?.$el as HTMLElement | undefined)?.focus({ preventScroll: true })\n })\n },\n { once: true },\n )\n}\n\n/** A label cut into the letters the search matched and the rest. */\nfunction parts(name: string, indices: number[]) {\n const hit = new Set(indices)\n const out: { text: string; match: boolean }[] = []\n for (let i = 0; i < name.length; i++) {\n const match = hit.has(i)\n const last = out[out.length - 1]\n if (last && last.match === match) last.text += name[i]\n else out.push({ text: name[i]!, match })\n }\n return out\n}\n\n/* changing the height: drag the bar under the block, or the arrow keys on it */\nfunction onResizeStart(event: PointerEvent) {\n if (event.button !== 0) return\n event.preventDefault()\n const bar = event.currentTarget as HTMLElement\n bar.setPointerCapture(event.pointerId)\n const startY = event.clientY\n const start = height.value\n const move = (e: PointerEvent) => (dragged.value = clampHeight(start + e.clientY - startY))\n const finish = (commit: boolean) => {\n bar.removeEventListener('pointermove', move)\n bar.removeEventListener('pointerup', up)\n bar.removeEventListener('pointercancel', cancel)\n window.removeEventListener('keydown', escape, true)\n const value = dragged.value\n dragged.value = null\n if (commit && value !== null && value !== start) props.updateProps({ height: value })\n }\n const up = () => finish(true)\n const cancel = () => finish(false)\n const escape = (e: KeyboardEvent) => {\n if (e.key !== 'Escape') return\n e.preventDefault()\n e.stopPropagation()\n finish(false)\n }\n bar.addEventListener('pointermove', move)\n bar.addEventListener('pointerup', up)\n bar.addEventListener('pointercancel', cancel)\n window.addEventListener('keydown', escape, true)\n}\n\nfunction onResizeKey(event: KeyboardEvent) {\n const by = { ArrowUp: -BOARD_HEIGHT.step, ArrowDown: BOARD_HEIGHT.step }[event.key]\n if (by) {\n event.preventDefault()\n props.updateProps({ height: clampHeight(height.value + by) })\n } else if (event.key === 'Escape') {\n event.preventDefault()\n onClosed()\n }\n}\n\nfunction resetHeight() {\n props.updateProps({ height: props.settings.height })\n}\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"dou-editor-board\"\n :class=\"{ 'is-selected': selected, 'is-empty': empty }\"\n :style=\"{ height: `${height}px`, cursor: markerCursor ? 'pointer' : undefined }\"\n @dblclick=\"openEditor\"\n @click=\"onPreviewClick\"\n @pointermove=\"onPreviewMove\"\n @pointerleave=\"markerCursor = false\"\n >\n <div v-if=\"!empty\" class=\"dou-editor-board__preview\" role=\"img\" :aria-label=\"label\">\n <DouFlowEditor\n class=\"dou-editor-board__canvas\"\n inert\n v-if=\"seen\"\n ref=\"preview\"\n :model-value=\"shown\"\n v-bind=\"settings.editorProps\"\n :extensions=\"settings.extensions\"\n :node-types=\"nodeTypes\"\n readonly\n fit-view\n :fit-min-zoom=\"0.05\"\n :simple-zoom=\"0\"\n :min-zoom=\"0.05\"\n :max-zoom=\"1\"\n :bordered=\"false\"\n :searchable=\"false\"\n :comments=\"flowComments\"\n :commentable=\"false\"\n :pan-on-scroll=\"false\"\n />\n </div>\n <div v-else class=\"dou-editor-board__empty\">\n <span class=\"dou-editor-board__empty-text\">{{ text.empty }}</span>\n <DouButton v-if=\"editable\" size=\"sm\" variant=\"outline\" @click=\"openEditor\">\n <template #leading><PencilIcon /></template>\n {{ text.start }}\n </DouButton>\n </div>\n\n <div v-if=\"!empty\" class=\"dou-editor-board__actions\">\n <DouButton size=\"sm\" variant=\"outline\" class=\"dou-editor-board__open\" @click=\"openEditor\">\n <template #leading><PencilIcon v-if=\"editable\" /><EyeIcon v-else /></template>\n {{ editable ? text.edit : text.view }}\n </DouButton>\n </div>\n\n <div\n v-if=\"editable\"\n class=\"dou-editor-board__resize\"\n role=\"separator\"\n aria-orientation=\"horizontal\"\n tabindex=\"0\"\n :aria-label=\"text.resize\"\n :aria-valuemin=\"BOARD_HEIGHT.min\"\n :aria-valuemax=\"BOARD_HEIGHT.max\"\n :aria-valuenow=\"height\"\n data-editor-control\n @pointerdown=\"onResizeStart\"\n @keydown=\"onResizeKey\"\n @dblclick.stop=\"resetHeight\"\n />\n\n <DouDialog\n v-model:open=\"open\"\n :title=\"label\"\n fullscreen\n destroy-on-close\n @opened=\"onOpened\"\n @close=\"onClose\"\n @closed=\"onClosed\"\n >\n <div ref=\"canvas\" class=\"dou-editor-board__editor\" data-editor-control>\n <DouFlowEditor\n ref=\"full\"\n :model-value=\"board\"\n v-bind=\"settings.editorProps\"\n :extensions=\"extensions\"\n :node-types=\"nodeTypes\"\n :readonly=\"!editable\"\n fit-view\n :fit-min-zoom=\"0.1\"\n :simple-zoom=\"0.1\"\n :comments=\"flowComments\"\n :author=\"comments.author.value\"\n :commentable=\"comments.writable.value\"\n :active-comment=\"boardActive\"\n :aria-label=\"label\"\n @transaction=\"forward\"\n @update:active-comment=\"onActive\"\n @comment-action=\"onCommentAction\"\n >\n <DouFlowControls />\n <div v-if=\"palette.length\" class=\"dou-editor-board__add\">\n <DouButton\n v-if=\"palette.length === 1\"\n size=\"sm\"\n variant=\"outline\"\n @pointerdown=\"dragNode(palette[0]!.type, $event)\"\n @click=\"addNode(palette[0]!.type)\"\n >\n <template #leading><PlusIcon /></template>\n {{ text.addNode }}\n </DouButton>\n <DouPopover v-else v-model:open=\"adding\" placement=\"bottom-start\">\n <DouButton ref=\"addTrigger\" size=\"sm\" variant=\"outline\">\n <template #leading><PlusIcon /></template>\n {{ text.addNode }}\n </DouButton>\n <template #content>\n <DouCommand\n ref=\"command\"\n v-model:query=\"query\"\n class=\"dou-editor-board__types\"\n :items=\"items\"\n :placeholder=\"text.searchNodes\"\n :aria-label=\"text.addNode\"\n :empty-text=\"text.noNodes\"\n :max-height=\"280\"\n @select=\"addNode(String($event.value))\"\n >\n <template #item=\"{ item, indices }\">\n <span\n class=\"dou-editor-board__type\"\n @pointerdown=\"dragNode(String(item.value), $event)\"\n >\n <span class=\"dou-editor-board__type-icon\">\n <component :is=\"item.icon\" v-if=\"item.icon\" />\n </span>\n <span class=\"dou-command__label\">\n <template v-for=\"(part, at) in parts(item.label, indices)\" :key=\"at\">\n <mark v-if=\"part.match\" class=\"dou-command__match\">{{ part.text }}</mark>\n <template v-else>{{ part.text }}</template>\n </template>\n </span>\n <span v-if=\"item.description\" class=\"dou-command__description\">\n {{ item.description }}\n </span>\n </span>\n </template>\n </DouCommand>\n </template>\n </DouPopover>\n </div>\n <p v-if=\"palette.length && !board.nodes.length\" class=\"dou-editor-board__hint\">\n {{ text.emptyFlow }}\n </p>\n </DouFlowEditor>\n </div>\n </DouDialog>\n </div>\n</template>\n"],"mappings":""}
|