@dou-ui/editor 0.1.0-alpha.11 → 0.1.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/dist/collaboration/cursors.js +42 -10
  2. package/dist/collaboration/cursors.js.map +1 -1
  3. package/dist/collaboration/index.js +30 -3
  4. package/dist/collaboration/index.js.map +1 -1
  5. package/dist/components/block-handle.js.map +1 -1
  6. package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js +73 -15
  7. package/dist/components/block-handle.vue_vue_type_script_setup_true_lang.js.map +1 -1
  8. package/dist/components/slash-choices.js +6 -0
  9. package/dist/components/slash-choices.js.map +1 -0
  10. package/dist/components/slash-choices.vue_vue_type_script_setup_true_lang.js +56 -0
  11. package/dist/components/slash-choices.vue_vue_type_script_setup_true_lang.js.map +1 -0
  12. package/dist/components/slash-menu.js.map +1 -1
  13. package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js +185 -20
  14. package/dist/components/slash-menu.vue_vue_type_script_setup_true_lang.js.map +1 -1
  15. package/dist/core/block-selection.js +32 -4
  16. package/dist/core/block-selection.js.map +1 -1
  17. package/dist/core/blocks.js +21 -3
  18. package/dist/core/blocks.js.map +1 -1
  19. package/dist/core/commands.js +125 -13
  20. package/dist/core/commands.js.map +1 -1
  21. package/dist/core/extension.js +6 -2
  22. package/dist/core/extension.js.map +1 -1
  23. package/dist/core/model.js +8 -2
  24. package/dist/core/model.js.map +1 -1
  25. package/dist/core/schema.js.map +1 -1
  26. package/dist/core/transaction.js +12 -3
  27. package/dist/core/transaction.js.map +1 -1
  28. package/dist/document.js +40 -4
  29. package/dist/document.js.map +1 -1
  30. package/dist/dom.js +96 -13
  31. package/dist/dom.js.map +1 -1
  32. package/dist/editor.vue_vue_type_script_setup_true_lang.js +3 -3
  33. package/dist/editor.vue_vue_type_script_setup_true_lang.js.map +1 -1
  34. package/dist/editor2.js.map +1 -1
  35. package/dist/extensions/columns/column-picker.js +6 -0
  36. package/dist/extensions/columns/column-picker.js.map +1 -0
  37. package/dist/extensions/columns/column-picker.vue_vue_type_script_setup_true_lang.js +57 -0
  38. package/dist/extensions/columns/column-picker.vue_vue_type_script_setup_true_lang.js.map +1 -0
  39. package/dist/extensions/columns/columns-controls.js +6 -0
  40. package/dist/extensions/columns/columns-controls.js.map +1 -0
  41. package/dist/extensions/columns/columns-controls.vue_vue_type_script_setup_true_lang.js +341 -0
  42. package/dist/extensions/columns/columns-controls.vue_vue_type_script_setup_true_lang.js.map +1 -0
  43. package/dist/extensions/columns/html.js +34 -0
  44. package/dist/extensions/columns/html.js.map +1 -0
  45. package/dist/extensions/columns/index.js +57 -0
  46. package/dist/extensions/columns/index.js.map +1 -0
  47. package/dist/extensions/columns/keys.js +53 -0
  48. package/dist/extensions/columns/keys.js.map +1 -0
  49. package/dist/extensions/columns/plugin.js +213 -0
  50. package/dist/extensions/columns/plugin.js.map +1 -0
  51. package/dist/extensions/columns/schema.js +58 -0
  52. package/dist/extensions/columns/schema.js.map +1 -0
  53. package/dist/extensions/columns/select-columns.js +6 -0
  54. package/dist/extensions/columns/select-columns.js.map +1 -0
  55. package/dist/extensions/columns/select-columns.vue_vue_type_script_setup_true_lang.js +71 -0
  56. package/dist/extensions/columns/select-columns.vue_vue_type_script_setup_true_lang.js.map +1 -0
  57. package/dist/extensions/editor-kit.js +3 -1
  58. package/dist/extensions/editor-kit.js.map +1 -1
  59. package/dist/extensions/table/plugin.js +33 -1
  60. package/dist/extensions/table/plugin.js.map +1 -1
  61. package/dist/extensions/table/table-controls.js.map +1 -1
  62. package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js +1 -1
  63. package/dist/extensions/table/table-controls.vue_vue_type_script_setup_true_lang.js.map +1 -1
  64. package/dist/extensions/table/view.js +25 -1
  65. package/dist/extensions/table/view.js.map +1 -1
  66. package/dist/index.js +3 -2
  67. package/dist/index.js.map +1 -1
  68. package/dist/locale.js +30 -0
  69. package/dist/locale.js.map +1 -1
  70. package/dist/style.css +1 -1
  71. package/dist/types/collaboration/cursors.d.ts +29 -1
  72. package/dist/types/collaboration/index.d.ts +17 -2
  73. package/dist/types/components/slash-choices.vue.d.ts +18 -0
  74. package/dist/types/core/blocks.d.ts +10 -0
  75. package/dist/types/core/commands.d.ts +17 -2
  76. package/dist/types/core/extension.d.ts +53 -2
  77. package/dist/types/core/model.d.ts +6 -1
  78. package/dist/types/core/schema.d.ts +1 -1
  79. package/dist/types/document.d.ts +4 -2
  80. package/dist/types/dom.d.ts +34 -4
  81. package/dist/types/editor.vue.d.ts +10 -0
  82. package/dist/types/extensions/columns/column-picker.vue.d.ts +10 -0
  83. package/dist/types/extensions/columns/columns-controls.vue.d.ts +3 -0
  84. package/dist/types/extensions/columns/html.d.ts +10 -0
  85. package/dist/types/extensions/columns/index.d.ts +9 -0
  86. package/dist/types/extensions/columns/keys.d.ts +6 -0
  87. package/dist/types/extensions/columns/plugin.d.ts +28 -0
  88. package/dist/types/extensions/columns/schema.d.ts +17 -0
  89. package/dist/types/extensions/columns/select-columns.vue.d.ts +13 -0
  90. package/dist/types/extensions/editor-kit.d.ts +4 -1
  91. package/dist/types/extensions/table/view.d.ts +8 -1
  92. package/dist/types/index.d.ts +12 -2
  93. package/dist/types/locale.d.ts +17 -0
  94. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"block-handle.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_withDirectives","_createElementVNode","_normalizeStyle","_withModifiers","_unref","_createVNode","_withCtx","_renderList","_createBlock","_createSlots","_resolveDynamicComponent","_createTextVNode","_toDisplayString","_createCommentVNode","_vShow"],"sources":["../../src/components/block-handle.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n ArrowDownIcon,\n ArrowUpIcon,\n CheckIcon,\n CopyIcon,\n GripVerticalIcon,\n PlusIcon,\n TrashIcon,\n} from '@dou-ui/icons'\nimport { DouDropdown, DouDropdownItem, DouDropdownSub } from 'dou-ui'\nimport { TextSelection } from 'prosemirror-state'\nimport { computed, inject, onBeforeUnmount, onMounted, shallowRef, watch } from 'vue'\nimport { isCurrent } from '../catalog'\nimport { labelOf, type BlockOption } from '../core/extension'\nimport {\n blockSelectionKey,\n blockSelectionRange,\n getBlockSelection,\n selectBlocks,\n} from '../core/block-selection'\nimport {\n blockAround,\n blocksIn,\n findBlockById,\n siblingRangeBetween,\n type SiblingRange,\n} from '../core/blocks'\nimport {\n duplicateBlocks,\n insertBlockAfter,\n swapBlocks,\n moveRangeTo,\n deleteBlocks,\n setBlockType,\n} from '../core/commands'\nimport { blockFromNode } from '../core/model'\nimport { slashKey } from '../core/slash'\nimport { blockElementOf, contentAt, firstLine, scrollParent } from '../dom'\nimport { editorKey } from '../editor'\nimport { useMenuEscape } from './menu-escape'\n\nconst { view, state, focused, messages, root, dragging, kit } = inject(editorKey)!\n\n/**\n * Touch screens have no hover: there the handle shows only the grip, next\n * to the block with the cursor (or the selected blocks) while the editor\n * has focus. A tap on it opens the menu, a press and drag moves the block.\n */\nconst touch = shallowRef(false)\nlet media: MediaQueryList | null = null\nconst onMedia = () => (touch.value = !!media?.matches)\n\n/** The block the handle is next to, by id. */\nconst hovered = shallowRef<string | null>(null)\nconst position = shallowRef<{ top: number; left: number; height: number } | null>(null)\nconst menuOpen = shallowRef(false)\nuseMenuEscape(menuOpen, () => (menuOpen.value = false))\n\nconst drop = shallowRef<{ pos: number; top: number; left: number; width: number } | null>(null)\n// typing hides the handle until the pointer moves again\nconst resting = shallowRef(false)\n\nconst visible = computed(() => {\n if (!position.value) return false\n if (menuOpen.value || dragging.value) return true\n if (touch.value) return focused.value || (!!state.value && !!getBlockSelection(state.value))\n return !resting.value\n})\n\nfunction place(content: HTMLElement) {\n const block = blockElementOf(content)\n const id = block?.dataset.blockId\n const host = root.value\n if (!id || !host) return\n const box = host.getBoundingClientRect()\n const line = firstLine(content)\n hovered.value = id\n position.value = {\n top: line.top - box.top,\n left: content.getBoundingClientRect().left - box.left,\n height: line.height,\n }\n}\n\nlet frame = 0\nlet lastY = 0\nlet lastX = 0\n\nfunction track(event: PointerEvent) {\n // a finger only moves the handle by moving the cursor; a drag reports itself\n if (event.pointerType === 'touch') return\n lastY = event.clientY\n lastX = event.clientX\n resting.value = false\n if (menuOpen.value || frame) return\n frame = requestAnimationFrame(() => {\n frame = 0\n if (dragging.value) return updateDrop()\n const current = view.value\n if (!current || menuOpen.value) return\n const content = contentAt(current, lastY)\n if (content) place(content)\n })\n}\n\nfunction leave(event: PointerEvent) {\n if (menuOpen.value || dragging.value || event.pointerType === 'touch') return\n position.value = null\n hovered.value = null\n}\n\n/** On touch screens: put the handle next to the block with the cursor. */\nfunction follow() {\n const current = view.value\n if (!current || dragging.value) return\n const selected = blockSelectionRange(current.state)\n const info = selected ? blocksIn(selected)[0] : blockAround(current.state.selection.$from)\n const element = info\n ? (current.nodeDOM(info.pos) as HTMLElement | null)?.querySelector<HTMLElement>(\n ':scope > .dou-editor__content',\n )\n : null\n if (element) place(element)\n else {\n position.value = null\n hovered.value = null\n }\n}\n\nlet followFrame = 0\nfunction scheduleFollow() {\n if (!touch.value || followFrame) return\n followFrame = requestAnimationFrame(() => {\n followFrame = 0\n if (touch.value && !menuOpen.value) follow()\n })\n}\n\nwatch([state, focused, touch], scheduleFollow)\n\nonMounted(() => {\n media = window.matchMedia('(pointer: coarse)')\n onMedia()\n media.addEventListener('change', onMedia)\n window.addEventListener('resize', scheduleFollow)\n root.value?.addEventListener('pointermove', track)\n root.value?.addEventListener('pointerleave', leave)\n})\nonBeforeUnmount(() => {\n media?.removeEventListener('change', onMedia)\n window.removeEventListener('resize', scheduleFollow)\n if (followFrame) cancelAnimationFrame(followFrame)\n root.value?.removeEventListener('pointermove', track)\n root.value?.removeEventListener('pointerleave', leave)\n if (frame) cancelAnimationFrame(frame)\n stopDrag()\n})\n\n// follow edits: keep the handle on its block, or hide it while typing\nwatch(state, (next, previous) => {\n if (touch.value || !next || !previous || next.doc === previous.doc || dragging.value) return\n if (!menuOpen.value) resting.value = true\n requestAnimationFrame(() => {\n const current = view.value\n if (!current || !hovered.value) return\n const element = current.dom.querySelector<HTMLElement>(\n `[data-block-id=\"${CSS.escape(hovered.value)}\"] > .dou-editor__content`,\n )\n if (element) place(element)\n else position.value = null\n })\n})\n\nconst target = computed(() => {\n const doc = state.value?.doc\n return doc && hovered.value ? findBlockById(doc, hovered.value) : null\n})\n\n/** The hovered block, or every selected block when it is one of them. */\nfunction rangeForHovered(): SiblingRange | null {\n const current = view.value\n const info = target.value\n if (!current || !info) return null\n const selected = blockSelectionRange(current.state)\n if (selected && info.pos >= selected.start && info.pos < selected.end) return selected\n return siblingRangeBetween(current.state.doc, info.pos + 1, info.pos + 1)\n}\n\n/** Select the blocks the menu or a drag acts on. */\nfunction selectTarget(): SiblingRange | null {\n const current = view.value\n const range = rangeForHovered()\n if (!current || !range) return null\n const blocks = blocksIn(range)\n selectBlocks(blocks[0]!.node.attrs.id, blocks.at(-1)!.node.attrs.id)(\n current.state,\n current.dispatch,\n )\n return blockSelectionRange(current.state)\n}\n\n/* the + button */\n\nfunction add(event: MouseEvent) {\n const current = view.value\n const info = target.value\n if (!current || !info) return\n const empty = info.content.isTextblock && info.content.content.size === 0\n if (!empty || info.content.type.name !== 'paragraph') {\n insertBlockAfter(info.pos)(current.state, current.dispatch)\n // Alt+click adds the block above instead\n if (event.altKey) swapBlocks(-1)(current.state, current.dispatch)\n } else {\n const tr = current.state.tr.setSelection(\n TextSelection.create(current.state.doc, info.contentPos + 1),\n )\n current.dispatch(tr)\n }\n const from = current.state.selection.from\n current.dispatch(current.state.tr.insertText('/').setMeta(slashKey, { from, query: '' }))\n current.focus()\n}\n\n/* the block menu */\n\nconst turnOptions = kit.blockOptions.filter(\n (option) => !!kit.schema.nodes[option.type]?.isTextblock,\n)\nconst current = computed(() => {\n const info = target.value\n return info ? blockFromNode(info.node) : null\n})\n\nfunction after(action: () => void) {\n action()\n // the menu gives focus back to the handle; the editor takes it after\n requestAnimationFrame(() => view.value?.focus())\n}\n\nfunction keep(run: (current: NonNullable<typeof view.value>) => void) {\n after(() => {\n const instance = view.value\n if (!instance) return\n const selection = getBlockSelection(instance.state)\n run(instance)\n if (selection) selectBlocks(selection.anchor, selection.head)(instance.state, instance.dispatch)\n })\n}\n\nconst turnInto = (option: BlockOption) =>\n keep((instance) => setBlockType(option.type, option.props)(instance.state, instance.dispatch))\nconst duplicate = () => keep((instance) => duplicateBlocks(instance.state, instance.dispatch))\nconst move = (direction: -1 | 1) =>\n keep((instance) => swapBlocks(direction)(instance.state, instance.dispatch))\n\nfunction remove() {\n after(() => {\n const instance = view.value\n const range = instance && blockSelectionRange(instance.state)\n if (!instance || !range) return\n const tr = deleteBlocks(instance.state.tr, blocksIn(range)).setMeta(blockSelectionKey, null)\n instance.dispatch(tr.scrollIntoView())\n position.value = null\n })\n}\n\nconst canMove = (direction: -1 | 1) => {\n const instance = view.value\n return !!instance && !!state.value && swapBlocks(direction)(instance.state)\n}\n\n/* dragging */\n\nlet start: { x: number; y: number; pointer: number; touch: boolean } | null = null\nlet range: SiblingRange | null = null\nlet scroller: HTMLElement | null = null\nlet scrollFrame = 0\n/** A copy of the dragged blocks that follows the pointer. */\nlet ghost: HTMLElement | null = null\n\nfunction showGhost(moving: SiblingRange) {\n const instance = view.value\n const host = root.value\n if (!instance || !host) return\n ghost = document.createElement('div')\n ghost.className = 'dou-editor__surface dou-editor__ghost'\n ghost.setAttribute('aria-hidden', 'true')\n let width = 0\n for (const block of blocksIn(moving)) {\n const element = instance.nodeDOM(block.pos) as HTMLElement | null\n if (!element) continue\n width = Math.max(width, element.getBoundingClientRect().width)\n const copy = element.cloneNode(true) as HTMLElement\n copy.classList.remove('is-selected')\n for (const node of [copy, ...copy.querySelectorAll('[id], .is-selected')]) {\n node.removeAttribute('id')\n node.classList.remove('is-selected')\n }\n ghost.append(copy)\n }\n ghost.style.width = `${Math.min(width, 360)}px`\n host.append(ghost)\n moveGhost()\n}\n\nfunction moveGhost() {\n if (!ghost) return\n // above a finger, which would hide it; below and right of a mouse pointer\n const y = start?.touch ? lastY - ghost.offsetHeight - 24 : lastY + 12\n ghost.style.transform = `translate(${lastX + 12}px, ${y}px)`\n}\n\nfunction onGripDown(event: PointerEvent) {\n if (event.button !== 0) return\n start = {\n x: event.clientX,\n y: event.clientY,\n pointer: event.pointerId,\n touch: event.pointerType === 'touch',\n }\n ;(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId)\n}\n\nfunction onGripMove(event: PointerEvent) {\n if (!start || event.pointerId !== start.pointer) return\n lastX = event.clientX\n lastY = event.clientY\n if (!dragging.value) {\n // a finger wobbles more than a mouse while tapping\n const slop = start.touch ? 8 : 4\n if (Math.hypot(event.clientX - start.x, event.clientY - start.y) < slop) return\n range = selectTarget()\n if (!range) return stopDrag()\n dragging.value = true\n scroller = root.value && scrollParent(root.value)\n window.addEventListener('keydown', onDragKey, true)\n showGhost(range)\n autoScroll()\n }\n moveGhost()\n updateDrop()\n}\n\nfunction onGripUp(event: PointerEvent) {\n if (!start || event.pointerId !== start.pointer) return\n if (dragging.value) finishDrag()\n else if (menuOpen.value) menuOpen.value = false\n else {\n selectTarget()\n menuOpen.value = true\n }\n start = null\n}\n\nfunction onDragKey(event: KeyboardEvent) {\n if (event.key !== 'Escape') return\n event.preventDefault()\n event.stopPropagation()\n stopDrag()\n}\n\nfunction updateDrop() {\n const instance = view.value\n const host = root.value\n if (!instance || !host || !range) return\n const content = contentAt(instance, lastY)\n const id = content && blockElementOf(content)?.dataset.blockId\n const info = id ? findBlockById(instance.state.doc, id) : null\n if (!content || !info) return (drop.value = null)\n const box = host.getBoundingClientRect()\n const rect = content.getBoundingClientRect()\n const below = lastY > rect.top + rect.height / 2\n let pos: number\n let y: number\n let left = rect.left\n if (!below) {\n pos = info.pos\n y = rect.top\n } else if (info.group) {\n // the lower half of a block with children: in front of its first child\n pos = info.contentPos + info.content.nodeSize + 1\n y = rect.bottom\n const child = blockElementOf(content)?.querySelector<HTMLElement>(\n ':scope > .dou-editor__group > .dou-editor__block > .dou-editor__content',\n )\n left = child?.getBoundingClientRect().left ?? rect.left\n } else {\n pos = info.pos + info.node.nodeSize\n y = blockElementOf(content)!.getBoundingClientRect().bottom\n }\n if (!moveRangeTo(range, pos)(instance.state)) return (drop.value = null)\n // to the end of the text column, which a reading width can end before the editor\n drop.value = { pos, top: y - box.top, left: left - box.left, width: rect.right - left }\n}\n\nfunction autoScroll() {\n scrollFrame = requestAnimationFrame(() => {\n if (!dragging.value) return\n const edge = 48\n const top = scroller ? scroller.getBoundingClientRect().top : 0\n const bottom = scroller ? scroller.getBoundingClientRect().bottom : window.innerHeight\n let speed = 0\n if (lastY < top + edge) speed = -Math.ceil(((top + edge - lastY) / edge) * 16)\n else if (lastY > bottom - edge) speed = Math.ceil(((lastY - bottom + edge) / edge) * 16)\n if (speed) {\n if (scroller) scroller.scrollTop += speed\n else window.scrollBy(0, speed)\n updateDrop()\n }\n autoScroll()\n })\n}\n\nfunction finishDrag() {\n const instance = view.value\n const spot = drop.value\n const moving = range\n stopDrag()\n if (!instance || !spot || !moving) return\n const ids = blocksIn(moving).map((block) => block.node.attrs.id as string)\n if (!moveRangeTo(moving, spot.pos)(instance.state, instance.dispatch)) return\n selectBlocks(ids[0]!, ids.at(-1)!)(instance.state, instance.dispatch)\n instance.focus()\n}\n\nfunction stopDrag() {\n dragging.value = false\n drop.value = null\n range = null\n start = null\n ghost?.remove()\n ghost = null\n if (scrollFrame) cancelAnimationFrame(scrollFrame)\n scrollFrame = 0\n window.removeEventListener('keydown', onDragKey, true)\n}\n\nwatch(menuOpen, (value) => {\n if (value) return\n if (touch.value) scheduleFollow()\n else if (!root.value?.matches(':hover')) position.value = null\n})\n</script>\n\n<template>\n <div\n v-show=\"visible\"\n class=\"dou-editor__handle\"\n :style=\"\n position\n ? {\n top: `${position.top}px`,\n left: `${position.left}px`,\n '--dou-editor-line': `${position.height}px`,\n }\n : undefined\n \"\n @mousedown.prevent\n >\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor__handle-button dou-editor__add\"\n :aria-label=\"messages.addBlock\"\n :title=\"messages.addBlock\"\n @click=\"add\"\n >\n <PlusIcon />\n </button>\n <DouDropdown\n v-model:open=\"menuOpen\"\n trigger=\"manual\"\n placement=\"bottom-start\"\n class=\"dou-editor-menu\"\n >\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor__handle-button dou-editor__grip\"\n :aria-label=\"messages.dragHandle\"\n :title=\"messages.dragHandle\"\n @pointerdown=\"onGripDown\"\n @pointermove=\"onGripMove\"\n @pointerup=\"onGripUp\"\n @pointercancel=\"stopDrag\"\n >\n <GripVerticalIcon />\n </button>\n <template #menu>\n <DouDropdownSub :title=\"messages.turnInto\">\n <DouDropdownItem\n v-for=\"option in turnOptions\"\n :key=\"option.key\"\n @click=\"turnInto(option)\"\n >\n <template #prefix><component :is=\"option.icon\" /></template>\n {{ labelOf(option.label, messages) }}\n <template v-if=\"current && isCurrent(option, current.type, current.props)\" #suffix>\n <CheckIcon />\n </template>\n </DouDropdownItem>\n </DouDropdownSub>\n <template v-if=\"current\">\n <component\n :is=\"entry\"\n v-for=\"(entry, index) in kit.blockMenu\"\n :key=\"index\"\n :block=\"current\"\n />\n </template>\n <DouDropdownItem :shortcut=\"touch ? undefined : 'mod+d'\" @click=\"duplicate\">\n <template #prefix><CopyIcon /></template>\n {{ messages.duplicate }}\n </DouDropdownItem>\n <DouDropdownItem\n :disabled=\"!canMove(-1)\"\n :shortcut=\"touch ? undefined : 'mod+shift+up'\"\n @click=\"move(-1)\"\n >\n <template #prefix><ArrowUpIcon /></template>\n {{ messages.moveUp }}\n </DouDropdownItem>\n <DouDropdownItem\n :disabled=\"!canMove(1)\"\n :shortcut=\"touch ? undefined : 'mod+shift+down'\"\n @click=\"move(1)\"\n >\n <template #prefix><ArrowDownIcon /></template>\n {{ messages.moveDown }}\n </DouDropdownItem>\n <DouDropdownItem\n divided\n tone=\"danger\"\n :shortcut=\"touch ? undefined : 'delete'\"\n @click=\"remove\"\n >\n <template #prefix><TrashIcon /></template>\n {{ messages.delete }}\n </DouDropdownItem>\n </template>\n </DouDropdown>\n </div>\n <div\n v-if=\"drop\"\n class=\"dou-editor__drop\"\n :style=\"{ top: `${drop.top}px`, left: `${drop.left}px`, width: `${drop.width}px` }\"\n />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;EA0CA,MAAM,EAAE,MAAM,OAAO,SAAS,UAAU,MAAM,UAAU,QAAQ,OAAO,SAAS;;;;;;EAOhF,MAAM,QAAQ,WAAW,KAAK;EAC9B,IAAI,QAA+B;EACnC,MAAM,gBAAiB,MAAM,QAAQ,CAAC,CAAC,OAAO;;EAG9C,MAAM,UAAU,WAA0B,IAAI;EAC9C,MAAM,WAAW,WAAiE,IAAI;EACtF,MAAM,WAAW,WAAW,KAAK;EACjC,cAAc,gBAAiB,SAAS,QAAQ,KAAM;EAEtD,MAAM,OAAO,WAA6E,IAAI;EAE9F,MAAM,UAAU,WAAW,KAAK;EAEhC,MAAM,UAAU,eAAe;GAC7B,IAAI,CAAC,SAAS,OAAO,OAAO;GAC5B,IAAI,SAAS,SAAS,SAAS,OAAO,OAAO;GAC7C,IAAI,MAAM,OAAO,OAAO,QAAQ,SAAU,CAAC,CAAC,MAAM,SAAS,CAAC,CAAC,kBAAkB,MAAM,KAAK;GAC1F,OAAO,CAAC,QAAQ;EAClB,CAAC;EAED,SAAS,MAAM,SAAsB;GAEnC,MAAM,KADQ,eAAe,OAClB,CAAA,EAAO,QAAQ;GAC1B,MAAM,OAAO,KAAK;GAClB,IAAI,CAAC,MAAM,CAAC,MAAM;GAClB,MAAM,MAAM,KAAK,sBAAsB;GACvC,MAAM,OAAO,UAAU,OAAO;GAC9B,QAAQ,QAAQ;GAChB,SAAS,QAAQ;IACf,KAAK,KAAK,MAAM,IAAI;IACpB,MAAM,QAAQ,sBAAsB,CAAC,CAAC,OAAO,IAAI;IACjD,QAAQ,KAAK;GACf;EACF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A;MANf,UAAQ,CAAG,QAAO,CAAA;MAClB,UAAU,MAAA,QAAQ,KAAA,IAAS;MAC3B,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,CAAA;;MAED,QAAME,cAAkB,CAAjBD,YAAiBD,MAAA,aAAA,CAAA,C;MAAW,SAAAE,cAC9C,CAD8CK,gBAAA,MAC9CC,gBAAGR,MAAA,QAAA,CAAQ,CAAC,QAAQ,GAAA,CAAA,C;;;KAEtBC,YAQkBD,MAAA,eAAA,GAAA;MAPhB,SAAA;MACA,MAAK;MACJ,UAAU,MAAA,QAAQ,KAAA,IAAS;MAC3B,SAAO;;MAEG,QAAME,cAAc,CAAbD,YAAaD,MAAA,SAAA,CAAA,C;MAAW,SAAAE,cAC1C,CAD0CK,gBAAA,MAC1CC,gBAAGR,MAAA,QAAA,CAAQ,CAAC,MAAM,GAAA,CAAA,C;;;;IA9DtB,SAAAE,cAYS,CAZTL,mBAYS,UAAA;KAXP,MAAK;KACL,UAAS;KACT,OAAM;KACL,cAAYG,MAAA,QAAA,CAAQ,CAAC;KACrB,OAAOA,MAAA,QAAA,CAAQ,CAAC;KAChB,eAAa;KACb,eAAa;KACb,aAAW;KACX,iBAAe;I,IAEhBC,YAAoBD,MAAA,gBAAA,CAAA,C;;G,wBAxChB,CAAAU,OAAA,QAAA,KAAO,C,IAiGT,KAAA,SADRjB,UAAA,GAAAC,mBAIE,OAAA;;IAFA,OAAM;IACL,OAAKI,eAAA;KAAA,KAAA,GAAY,KAAA,MAAK,IAAG;KAAA,MAAA,GAAe,KAAA,MAAK,KAAI;KAAA,OAAA,GAAgB,KAAA,MAAK,MAAK;IAAA,CAAA"}
1
+ {"version":3,"file":"block-handle.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_withDirectives","_createElementVNode","_normalizeClass","_normalizeStyle","_withModifiers","_unref","_createVNode","_withCtx","_renderList","_createBlock","_createSlots","_resolveDynamicComponent","_createTextVNode","_toDisplayString","_createCommentVNode","_vShow"],"sources":["../../src/components/block-handle.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport {\n ArrowDownIcon,\n ArrowUpIcon,\n CheckIcon,\n CopyIcon,\n GripVerticalIcon,\n PlusIcon,\n TrashIcon,\n} from '@dou-ui/icons'\nimport { DouDropdown, DouDropdownItem, DouDropdownSub } from 'dou-ui'\nimport { TextSelection } from 'prosemirror-state'\nimport { computed, inject, onBeforeUnmount, onMounted, shallowRef, watch } from 'vue'\nimport { isCurrent } from '../catalog'\nimport { labelOf, type BlockOption } from '../core/extension'\nimport {\n blockSelectionKey,\n blockSelectionRange,\n getBlockSelection,\n selectBlocks,\n} from '../core/block-selection'\nimport {\n blockAround,\n blocksIn,\n findBlockById,\n siblingRangeBetween,\n type SiblingRange,\n} from '../core/blocks'\nimport {\n duplicateBlocks,\n insertBlockAfter,\n swapBlocks,\n moveRangeTo,\n moveRangeToNewColumn,\n deleteBlocks,\n setBlockType,\n} from '../core/commands'\nimport { blockFromNode } from '../core/model'\nimport { slashKey } from '../core/slash'\nimport {\n blockElementOf,\n childBlocks,\n COLUMN_GROUP,\n contentAt,\n contentSpan,\n firstLine,\n handleLeft,\n scrollParent,\n sideBySide,\n} from '../dom'\nimport { editorKey } from '../editor'\nimport { useMenuEscape } from './menu-escape'\n\nconst { view, state, focused, messages, root, dragging, kit } = inject(editorKey)!\n\n/**\n * Touch screens have no hover: there the handle shows only the grip, next\n * to the block with the cursor (or the selected blocks) while the editor\n * has focus. A tap on it opens the menu, a press and drag moves the block.\n */\nconst touch = shallowRef(false)\nlet media: MediaQueryList | null = null\nconst onMedia = () => (touch.value = !!media?.matches)\n\n/** The block the handle is next to, by id. */\nconst hovered = shallowRef<string | null>(null)\nconst position = shallowRef<{ top: number; left: number; height: number } | null>(null)\n/** In a column the handle is only the grip, in the gap before it, leaving room for the resize bar. */\nconst compact = shallowRef(false)\nconst menuOpen = shallowRef(false)\nuseMenuEscape(menuOpen, () => (menuOpen.value = false))\n\n/**\n * Where a drag would drop: before or after a block (a line across), or\n * beside a column, into a new column (a line down, `column` set).\n */\ninterface Drop {\n pos: number\n top: number\n left: number\n width: number\n height?: number\n column?: { row: string; index: number }\n}\nconst drop = shallowRef<Drop | null>(null)\n// typing hides the handle until the pointer moves again\nconst resting = shallowRef(false)\n\nconst visible = computed(() => {\n if (!position.value) return false\n if (menuOpen.value || dragging.value) return true\n if (touch.value) return focused.value || (!!state.value && !!getBlockSelection(state.value))\n return !resting.value\n})\n\nfunction place(content: HTMLElement) {\n const block = blockElementOf(content)\n const id = block?.dataset.blockId\n const host = root.value\n if (!id || !host) return\n const box = host.getBoundingClientRect()\n const line = firstLine(content)\n hovered.value = id\n compact.value = !!content.closest(COLUMN_GROUP)\n position.value = {\n top: line.top - box.top,\n left: handleLeft(content) - box.left,\n height: line.height,\n }\n}\n\nlet frame = 0\nlet lastY = 0\nlet lastX = 0\n\nfunction track(event: PointerEvent) {\n // a finger only moves the handle by moving the cursor; a drag reports itself\n if (event.pointerType === 'touch') return\n lastY = event.clientY\n lastX = event.clientX\n resting.value = false\n if (menuOpen.value || frame) return\n frame = requestAnimationFrame(() => {\n frame = 0\n if (dragging.value) return updateDrop()\n const current = view.value\n if (!current || menuOpen.value) return\n const content = contentAt(current, lastY, lastX)\n if (content) place(content)\n })\n}\n\n/** A wide table scrolled sideways: the handle next to it follows its left edge. */\nfunction onScroll(event: Event) {\n const content = event.target\n if (\n !(content instanceof HTMLElement) ||\n !content.classList.contains('dou-editor__content--table')\n )\n return\n if (position.value && hovered.value && blockElementOf(content)?.dataset.blockId === hovered.value)\n place(content)\n}\n\nfunction leave(event: PointerEvent) {\n if (menuOpen.value || dragging.value || event.pointerType === 'touch') return\n position.value = null\n hovered.value = null\n}\n\n/** On touch screens: put the handle next to the block with the cursor. */\nfunction follow() {\n const current = view.value\n if (!current || dragging.value) return\n const selected = blockSelectionRange(current.state)\n const info = selected ? blocksIn(selected)[0] : blockAround(current.state.selection.$from)\n const element = info\n ? (current.nodeDOM(info.pos) as HTMLElement | null)?.querySelector<HTMLElement>(\n ':scope > .dou-editor__content',\n )\n : null\n if (element) place(element)\n else {\n position.value = null\n hovered.value = null\n }\n}\n\nlet followFrame = 0\nfunction scheduleFollow() {\n if (!touch.value || followFrame) return\n followFrame = requestAnimationFrame(() => {\n followFrame = 0\n if (touch.value && !menuOpen.value) follow()\n })\n}\n\nwatch([state, focused, touch], scheduleFollow)\n\nonMounted(() => {\n media = window.matchMedia('(pointer: coarse)')\n onMedia()\n media.addEventListener('change', onMedia)\n window.addEventListener('resize', scheduleFollow)\n root.value?.addEventListener('pointermove', track)\n root.value?.addEventListener('pointerleave', leave)\n root.value?.addEventListener('scroll', onScroll, true)\n})\nonBeforeUnmount(() => {\n media?.removeEventListener('change', onMedia)\n window.removeEventListener('resize', scheduleFollow)\n if (followFrame) cancelAnimationFrame(followFrame)\n root.value?.removeEventListener('pointermove', track)\n root.value?.removeEventListener('pointerleave', leave)\n root.value?.removeEventListener('scroll', onScroll, true)\n if (frame) cancelAnimationFrame(frame)\n stopDrag()\n})\n\n// follow edits: keep the handle on its block, or hide it while typing\nwatch(state, (next, previous) => {\n if (touch.value || !next || !previous || next.doc === previous.doc || dragging.value) return\n if (!menuOpen.value) resting.value = true\n requestAnimationFrame(() => {\n const current = view.value\n if (!current || !hovered.value) return\n const element = current.dom.querySelector<HTMLElement>(\n `[data-block-id=\"${CSS.escape(hovered.value)}\"] > .dou-editor__content`,\n )\n if (element) place(element)\n else position.value = null\n })\n})\n\nconst target = computed(() => {\n const doc = state.value?.doc\n return doc && hovered.value ? findBlockById(doc, hovered.value) : null\n})\n\n/** The hovered block, or every selected block when it is one of them. */\nfunction rangeForHovered(): SiblingRange | null {\n const current = view.value\n const info = target.value\n if (!current || !info) return null\n const selected = blockSelectionRange(current.state)\n if (selected && info.pos >= selected.start && info.pos < selected.end) return selected\n return siblingRangeBetween(current.state.doc, info.pos + 1, info.pos + 1)\n}\n\n/** Select the blocks the menu or a drag acts on. */\nfunction selectTarget(): SiblingRange | null {\n const current = view.value\n const range = rangeForHovered()\n if (!current || !range) return null\n const blocks = blocksIn(range)\n selectBlocks(blocks[0]!.node.attrs.id, blocks.at(-1)!.node.attrs.id)(\n current.state,\n current.dispatch,\n )\n return blockSelectionRange(current.state)\n}\n\n/* the + button */\n\nfunction add(event: MouseEvent) {\n const current = view.value\n const info = target.value\n if (!current || !info) return\n const empty = info.content.isTextblock && info.content.content.size === 0\n if (!empty || info.content.type.name !== 'paragraph') {\n insertBlockAfter(info.pos)(current.state, current.dispatch)\n // Alt+click adds the block above instead\n if (event.altKey) swapBlocks(-1)(current.state, current.dispatch)\n } else {\n const tr = current.state.tr.setSelection(\n TextSelection.create(current.state.doc, info.contentPos + 1),\n )\n current.dispatch(tr)\n }\n const from = current.state.selection.from\n current.dispatch(current.state.tr.insertText('/').setMeta(slashKey, { from, query: '' }))\n current.focus()\n}\n\n/* the block menu */\n\nconst turnOptions = kit.blockOptions.filter(\n (option) => !!kit.schema.nodes[option.type]?.isTextblock,\n)\nconst current = computed(() => {\n const info = target.value\n return info ? blockFromNode(info.node) : null\n})\n\nfunction after(action: () => void) {\n action()\n // the menu gives focus back to the handle; the editor takes it after\n requestAnimationFrame(() => view.value?.focus())\n}\n\nfunction keep(run: (current: NonNullable<typeof view.value>) => void) {\n after(() => {\n const instance = view.value\n if (!instance) return\n const selection = getBlockSelection(instance.state)\n run(instance)\n if (selection) selectBlocks(selection.anchor, selection.head)(instance.state, instance.dispatch)\n })\n}\n\nconst turnInto = (option: BlockOption) =>\n keep((instance) => setBlockType(option.type, option.props)(instance.state, instance.dispatch))\nconst duplicate = () => keep((instance) => duplicateBlocks(instance.state, instance.dispatch))\nconst move = (direction: -1 | 1) =>\n keep((instance) => swapBlocks(direction)(instance.state, instance.dispatch))\n\nfunction remove() {\n after(() => {\n const instance = view.value\n const range = instance && blockSelectionRange(instance.state)\n if (!instance || !range) return\n const tr = deleteBlocks(instance.state.tr, blocksIn(range)).setMeta(blockSelectionKey, null)\n instance.dispatch(tr.scrollIntoView())\n position.value = null\n })\n}\n\nconst canMove = (direction: -1 | 1) => {\n const instance = view.value\n return !!instance && !!state.value && swapBlocks(direction)(instance.state)\n}\n\n/* dragging */\n\nlet start: { x: number; y: number; pointer: number; touch: boolean } | null = null\nlet range: SiblingRange | null = null\nlet scroller: HTMLElement | null = null\nlet scrollFrame = 0\n/** A copy of the dragged blocks that follows the pointer. */\nlet ghost: HTMLElement | null = null\n\nfunction showGhost(moving: SiblingRange) {\n const instance = view.value\n const host = root.value\n if (!instance || !host) return\n ghost = document.createElement('div')\n ghost.className = 'dou-editor__surface dou-editor__ghost'\n ghost.setAttribute('aria-hidden', 'true')\n let width = 0\n for (const block of blocksIn(moving)) {\n const element = instance.nodeDOM(block.pos) as HTMLElement | null\n if (!element) continue\n width = Math.max(width, element.getBoundingClientRect().width)\n const copy = element.cloneNode(true) as HTMLElement\n copy.classList.remove('is-selected')\n for (const node of [copy, ...copy.querySelectorAll('[id], .is-selected')]) {\n node.removeAttribute('id')\n node.classList.remove('is-selected')\n }\n ghost.append(copy)\n }\n ghost.style.width = `${Math.min(width, 360)}px`\n host.append(ghost)\n moveGhost()\n}\n\nfunction moveGhost() {\n if (!ghost) return\n // above a finger, which would hide it; below and right of a mouse pointer\n const y = start?.touch ? lastY - ghost.offsetHeight - 24 : lastY + 12\n ghost.style.transform = `translate(${lastX + 12}px, ${y}px)`\n}\n\nfunction onGripDown(event: PointerEvent) {\n if (event.button !== 0) return\n start = {\n x: event.clientX,\n y: event.clientY,\n pointer: event.pointerId,\n touch: event.pointerType === 'touch',\n }\n ;(event.currentTarget as HTMLElement).setPointerCapture(event.pointerId)\n}\n\nfunction onGripMove(event: PointerEvent) {\n if (!start || event.pointerId !== start.pointer) return\n lastX = event.clientX\n lastY = event.clientY\n if (!dragging.value) {\n // a finger wobbles more than a mouse while tapping\n const slop = start.touch ? 8 : 4\n if (Math.hypot(event.clientX - start.x, event.clientY - start.y) < slop) return\n range = selectTarget()\n if (!range) return stopDrag()\n dragging.value = true\n scroller = root.value && scrollParent(root.value)\n window.addEventListener('keydown', onDragKey, true)\n showGhost(range)\n autoScroll()\n }\n moveGhost()\n updateDrop()\n}\n\nfunction onGripUp(event: PointerEvent) {\n if (!start || event.pointerId !== start.pointer) return\n if (dragging.value) finishDrag()\n else if (menuOpen.value) menuOpen.value = false\n else {\n selectTarget()\n menuOpen.value = true\n }\n start = null\n}\n\nfunction onDragKey(event: KeyboardEvent) {\n if (event.key !== 'Escape') return\n event.preventDefault()\n event.stopPropagation()\n stopDrag()\n}\n\n/** Beside a column, past its edge: a new column there, when the set takes one more. */\n/** How far into the last column a drop still makes a new column after it. */\nconst LAST_COLUMN_EDGE = 16\n\nfunction columnDrop(content: HTMLElement, moving: SiblingRange, box: DOMRect): Drop | null {\n const instance = view.value\n const group = content.closest<HTMLElement>(COLUMN_GROUP)\n const column = group?.parentElement\n const rowGroup = column?.parentElement\n const rowId = rowGroup?.parentElement?.dataset.blockId\n if (!instance || !column || !rowGroup || !rowId) return null\n const columns = childBlocks(rowGroup)\n const index = columns.indexOf(column)\n if (index < 0 || !sideBySide(columns)) return null\n const rect = column.getBoundingClientRect()\n // right of the last column there may be no room (the editor's edge): its last strip counts\n const right = index === columns.length - 1 ? rect.right - LAST_COLUMN_EDGE : rect.right\n const at = lastX < rect.left ? index : lastX > right ? index + 1 : -1\n if (at < 0) return null\n const row = findBlockById(instance.state.doc, rowId)\n if (!row || !moveRangeToNewColumn(moving, row.pos, at)(instance.state)) return null\n const gap =\n columns.length > 1\n ? columns[1]!.getBoundingClientRect().left - columns[0]!.getBoundingClientRect().right\n : 0\n const x =\n at === 0\n ? columns[0]!.getBoundingClientRect().left - gap / 2\n : at === columns.length\n ? columns.at(-1)!.getBoundingClientRect().right - 1\n : (columns[at - 1]!.getBoundingClientRect().right +\n columns[at]!.getBoundingClientRect().left) /\n 2\n const rowRect = rowGroup.getBoundingClientRect()\n return {\n pos: row.pos,\n top: rowRect.top - box.top,\n left: x - box.left,\n width: 0,\n height: rowRect.height,\n column: { row: rowId, index: at },\n }\n}\n\nfunction updateDrop() {\n const instance = view.value\n const host = root.value\n if (!instance || !host || !range) return\n const content = contentAt(instance, lastY, lastX)\n const id = content && blockElementOf(content)?.dataset.blockId\n const info = id ? findBlockById(instance.state.doc, id) : null\n if (!content || !info) return (drop.value = null)\n const box = host.getBoundingClientRect()\n const beside = columnDrop(content, range, box)\n if (beside) return (drop.value = beside)\n const rect = content.getBoundingClientRect()\n const span = contentSpan(content)\n const below = lastY > rect.top + rect.height / 2\n let pos: number\n let y: number\n let left = span.left\n if (!below) {\n pos = info.pos\n y = rect.top\n } else if (info.group) {\n // the lower half of a block with children: in front of its first child\n pos = info.contentPos + info.content.nodeSize + 1\n y = rect.bottom\n const child = blockElementOf(content)?.querySelector<HTMLElement>(\n ':scope > .dou-editor__group > .dou-editor__block > .dou-editor__content',\n )\n left = child ? contentSpan(child).left : span.left\n } else {\n pos = info.pos + info.node.nodeSize\n y = blockElementOf(content)!.getBoundingClientRect().bottom\n }\n if (!moveRangeTo(range, pos)(instance.state)) return (drop.value = null)\n // to the end of the text column, which a reading width can end before the editor\n drop.value = { pos, top: y - box.top, left: left - box.left, width: span.right - left }\n}\n\nfunction autoScroll() {\n scrollFrame = requestAnimationFrame(() => {\n if (!dragging.value) return\n const edge = 48\n const top = scroller ? scroller.getBoundingClientRect().top : 0\n const bottom = scroller ? scroller.getBoundingClientRect().bottom : window.innerHeight\n let speed = 0\n if (lastY < top + edge) speed = -Math.ceil(((top + edge - lastY) / edge) * 16)\n else if (lastY > bottom - edge) speed = Math.ceil(((lastY - bottom + edge) / edge) * 16)\n if (speed) {\n if (scroller) scroller.scrollTop += speed\n else window.scrollBy(0, speed)\n updateDrop()\n }\n autoScroll()\n })\n}\n\nfunction finishDrag() {\n const instance = view.value\n const spot = drop.value\n const moving = range\n stopDrag()\n if (!instance || !spot || !moving) return\n const ids = blocksIn(moving).map((block) => block.node.attrs.id as string)\n const row = spot.column && findBlockById(instance.state.doc, spot.column.row)\n const command = spot.column\n ? row && moveRangeToNewColumn(moving, row.pos, spot.column.index)\n : moveRangeTo(moving, spot.pos)\n if (!command || !command(instance.state, instance.dispatch)) return\n selectBlocks(ids[0]!, ids.at(-1)!)(instance.state, instance.dispatch)\n instance.focus()\n}\n\nfunction stopDrag() {\n dragging.value = false\n drop.value = null\n range = null\n start = null\n ghost?.remove()\n ghost = null\n if (scrollFrame) cancelAnimationFrame(scrollFrame)\n scrollFrame = 0\n window.removeEventListener('keydown', onDragKey, true)\n}\n\nwatch(menuOpen, (value) => {\n if (value) return\n if (touch.value) scheduleFollow()\n else if (!root.value?.matches(':hover')) position.value = null\n})\n</script>\n\n<template>\n <div\n v-show=\"visible\"\n :class=\"['dou-editor__handle', { 'is-compact': compact }]\"\n :style=\"\n position\n ? {\n top: `${position.top}px`,\n left: `${position.left}px`,\n '--dou-editor-line': `${position.height}px`,\n }\n : undefined\n \"\n @mousedown.prevent\n >\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor__handle-button dou-editor__add\"\n :aria-label=\"messages.addBlock\"\n :title=\"messages.addBlock\"\n @click=\"add\"\n >\n <PlusIcon />\n </button>\n <DouDropdown\n v-model:open=\"menuOpen\"\n trigger=\"manual\"\n placement=\"bottom-start\"\n class=\"dou-editor-menu\"\n >\n <button\n type=\"button\"\n tabindex=\"-1\"\n class=\"dou-editor__handle-button dou-editor__grip\"\n :aria-label=\"messages.dragHandle\"\n :title=\"messages.dragHandle\"\n @pointerdown=\"onGripDown\"\n @pointermove=\"onGripMove\"\n @pointerup=\"onGripUp\"\n @pointercancel=\"stopDrag\"\n >\n <GripVerticalIcon />\n </button>\n <template #menu>\n <DouDropdownSub :title=\"messages.turnInto\">\n <DouDropdownItem\n v-for=\"option in turnOptions\"\n :key=\"option.key\"\n @click=\"turnInto(option)\"\n >\n <template #prefix><component :is=\"option.icon\" /></template>\n {{ labelOf(option.label, messages) }}\n <template v-if=\"current && isCurrent(option, current.type, current.props)\" #suffix>\n <CheckIcon />\n </template>\n </DouDropdownItem>\n </DouDropdownSub>\n <template v-if=\"current\">\n <component\n :is=\"entry\"\n v-for=\"(entry, index) in kit.blockMenu\"\n :key=\"index\"\n :block=\"current\"\n />\n </template>\n <DouDropdownItem :shortcut=\"touch ? undefined : 'mod+d'\" @click=\"duplicate\">\n <template #prefix><CopyIcon /></template>\n {{ messages.duplicate }}\n </DouDropdownItem>\n <DouDropdownItem\n :disabled=\"!canMove(-1)\"\n :shortcut=\"touch ? undefined : 'mod+shift+up'\"\n @click=\"move(-1)\"\n >\n <template #prefix><ArrowUpIcon /></template>\n {{ messages.moveUp }}\n </DouDropdownItem>\n <DouDropdownItem\n :disabled=\"!canMove(1)\"\n :shortcut=\"touch ? undefined : 'mod+shift+down'\"\n @click=\"move(1)\"\n >\n <template #prefix><ArrowDownIcon /></template>\n {{ messages.moveDown }}\n </DouDropdownItem>\n <DouDropdownItem\n divided\n tone=\"danger\"\n :shortcut=\"touch ? undefined : 'delete'\"\n @click=\"remove\"\n >\n <template #prefix><TrashIcon /></template>\n {{ messages.delete }}\n </DouDropdownItem>\n </template>\n </DouDropdown>\n </div>\n <div\n v-if=\"drop\"\n :class=\"['dou-editor__drop', { 'is-vertical': drop.column }]\"\n :style=\"\n drop.column\n ? { top: `${drop.top}px`, left: `${drop.left}px`, height: `${drop.height}px` }\n : { top: `${drop.top}px`, left: `${drop.left}px`, width: `${drop.width}px` }\n \"\n />\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;AAoZA,IAAM,mBAAmB;;;;EA/VzB,MAAM,EAAE,MAAM,OAAO,SAAS,UAAU,MAAM,UAAU,QAAQ,OAAO,SAAS;;;;;;EAOhF,MAAM,QAAQ,WAAW,KAAK;EAC9B,IAAI,QAA+B;EACnC,MAAM,gBAAiB,MAAM,QAAQ,CAAC,CAAC,OAAO;;EAG9C,MAAM,UAAU,WAA0B,IAAI;EAC9C,MAAM,WAAW,WAAiE,IAAI;;EAEtF,MAAM,UAAU,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oBAAA,EAAA,eAAwC,KAAA,MAAK,OAAM,CAAA,CAAA;IACxD,OAAKC,eAAS,KAAA,MAAK,SAA2B;KAAA,KAAA,GAAA,KAAA,MAAK,IAAG;KAAA,MAAA,GAAe,KAAA,MAAK,KAAI;KAAA,QAAA,GAAiB,KAAA,MAAK,OAAM;IAAA,IAA2B;KAAA,KAAA,GAAA,KAAA,MAAK,IAAG;KAAA,MAAA,GAAe,KAAA,MAAK,KAAI;KAAA,OAAA,GAAgB,KAAA,MAAK,MAAK;IAAA,C"}
@@ -0,0 +1,6 @@
1
+ import slash_choices_vue_vue_type_script_setup_true_lang_default from "./slash-choices.vue_vue_type_script_setup_true_lang.js";
2
+ // src/components/slash-choices.vue
3
+ var slash_choices_default = slash_choices_vue_vue_type_script_setup_true_lang_default;
4
+ export { slash_choices_default as default };
5
+
6
+ //# sourceMappingURL=slash-choices.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slash-choices.js","names":["_sfc_main"],"sources":["../../src/components/slash-choices.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { labelOf, type BlockOptionChoices } from '../core/extension'\nimport type { EditorMessages } from '../locale'\n\n/** The variants of a slash menu option: its title, then the option's own panel or a list. */\ndefineProps<{\n choices: BlockOptionChoices\n active: number\n messages: EditorMessages\n idPrefix: string\n}>()\nconst emit = defineEmits<{ hover: [index: number]; choose: [index: number] }>()\n</script>\n\n<template>\n <div class=\"dou-editor-slash__choices-title\" aria-hidden=\"true\">\n {{ labelOf(choices.title, messages) }}\n </div>\n <component\n :is=\"choices.component\"\n v-if=\"choices.component\"\n :id-prefix=\"idPrefix\"\n :items=\"choices.items\"\n :active=\"active\"\n :messages=\"messages\"\n @hover=\"emit('hover', $event)\"\n @choose=\"emit('choose', $event)\"\n />\n <template v-else>\n <div\n v-for=\"(item, index) in choices.items\"\n :id=\"`${idPrefix}-${index}`\"\n :key=\"index\"\n role=\"option\"\n :aria-selected=\"index === active\"\n :class=\"['dou-dropdown__item', { 'is-active': index === active }]\"\n @pointermove=\"emit('hover', index)\"\n @click=\"emit('choose', index)\"\n >\n {{ labelOf(item.label, messages) }}\n </div>\n </template>\n</template>\n"],"mappings":""}
@@ -0,0 +1,56 @@
1
+ import { labelOf } from "../core/extension.js";
2
+ import { Fragment, createBlock, createElementBlock, createElementVNode, defineComponent, normalizeClass, openBlock, renderList, resolveDynamicComponent, toDisplayString, unref } from "vue";
3
+ // src/components/slash-choices.vue?vue&type=script&setup=true&lang.ts
4
+ var _hoisted_1 = {
5
+ class: "dou-editor-slash__choices-title",
6
+ "aria-hidden": "true"
7
+ };
8
+ var _hoisted_2 = [
9
+ "id",
10
+ "aria-selected",
11
+ "onPointermove",
12
+ "onClick"
13
+ ];
14
+ /** The variants of a slash menu option: its title, then the option's own panel or a list. */
15
+ var slash_choices_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
16
+ __name: "slash-choices",
17
+ props: {
18
+ choices: {},
19
+ active: {},
20
+ messages: {},
21
+ idPrefix: {}
22
+ },
23
+ emits: ["hover", "choose"],
24
+ setup(__props, { emit: __emit }) {
25
+ const emit = __emit;
26
+ return (_ctx, _cache) => {
27
+ return openBlock(), createElementBlock(Fragment, null, [createElementVNode("div", _hoisted_1, toDisplayString(unref(labelOf)(__props.choices.title, __props.messages)), 1), __props.choices.component ? (openBlock(), createBlock(resolveDynamicComponent(__props.choices.component), {
28
+ key: 0,
29
+ "id-prefix": __props.idPrefix,
30
+ items: __props.choices.items,
31
+ active: __props.active,
32
+ messages: __props.messages,
33
+ onHover: _cache[0] || (_cache[0] = ($event) => emit("hover", $event)),
34
+ onChoose: _cache[1] || (_cache[1] = ($event) => emit("choose", $event))
35
+ }, null, 40, [
36
+ "id-prefix",
37
+ "items",
38
+ "active",
39
+ "messages"
40
+ ])) : (openBlock(true), createElementBlock(Fragment, { key: 1 }, renderList(__props.choices.items, (item, index) => {
41
+ return openBlock(), createElementBlock("div", {
42
+ id: `${__props.idPrefix}-${index}`,
43
+ key: index,
44
+ role: "option",
45
+ "aria-selected": index === __props.active,
46
+ class: normalizeClass(["dou-dropdown__item", { "is-active": index === __props.active }]),
47
+ onPointermove: ($event) => emit("hover", index),
48
+ onClick: ($event) => emit("choose", index)
49
+ }, toDisplayString(unref(labelOf)(item.label, __props.messages)), 43, _hoisted_2);
50
+ }), 128))], 64);
51
+ };
52
+ }
53
+ });
54
+ export { slash_choices_vue_vue_type_script_setup_true_lang_default as default };
55
+
56
+ //# sourceMappingURL=slash-choices.vue_vue_type_script_setup_true_lang.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slash-choices.vue_vue_type_script_setup_true_lang.js","names":["_openBlock","_createElementBlock","_Fragment","_createElementVNode","_toDisplayString","_unref","_createBlock","_resolveDynamicComponent","_renderList","_normalizeClass"],"sources":["../../src/components/slash-choices.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { labelOf, type BlockOptionChoices } from '../core/extension'\nimport type { EditorMessages } from '../locale'\n\n/** The variants of a slash menu option: its title, then the option's own panel or a list. */\ndefineProps<{\n choices: BlockOptionChoices\n active: number\n messages: EditorMessages\n idPrefix: string\n}>()\nconst emit = defineEmits<{ hover: [index: number]; choose: [index: number] }>()\n</script>\n\n<template>\n <div class=\"dou-editor-slash__choices-title\" aria-hidden=\"true\">\n {{ labelOf(choices.title, messages) }}\n </div>\n <component\n :is=\"choices.component\"\n v-if=\"choices.component\"\n :id-prefix=\"idPrefix\"\n :items=\"choices.items\"\n :active=\"active\"\n :messages=\"messages\"\n @hover=\"emit('hover', $event)\"\n @choose=\"emit('choose', $event)\"\n />\n <template v-else>\n <div\n v-for=\"(item, index) in choices.items\"\n :id=\"`${idPrefix}-${index}`\"\n :key=\"index\"\n role=\"option\"\n :aria-selected=\"index === active\"\n :class=\"['dou-dropdown__item', { 'is-active': index === active }]\"\n @pointermove=\"emit('hover', index)\"\n @click=\"emit('choose', index)\"\n >\n {{ labelOf(item.label, messages) }}\n </div>\n </template>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;EAWA,MAAM,OAAO;;G,wDAIXG,mBAEM,OAFN,YAEMC,gBADDC,MAAA,OAAA,CAAO,CAAC,QAAA,QAAQ,OAAO,QAAA,QAAQ,CAAA,GAAA,CAAA,GAI5B,QAAA,QAAQ,aAFhBL,UAAA,GAAAM,YASEC,wBARK,QAAA,QAAQ,SAAS,GAAA;;IAErB,aAAW,QAAA;IACX,OAAO,QAAA,QAAQ;IACf,QAAQ,QAAA;IACR,UAAU,QAAA;IACV,SAAK,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,SAAU,MAAM;IAC3B,UAAM,OAAA,OAAA,OAAA,MAAA,WAAE,KAAI,UAAW,MAAM;;;;;;G,OAG9BP,UAAA,IAAA,GAAAC,mBAWMC,UAAA,EAAA,KAAA,EAAA,GAAAM,WAVoB,QAAA,QAAQ,QAAxB,MAAM,UAAK;IADrB,OAAAR,UAAA,GAAAC,mBAWM,OAAA;KATH,IAAE,GAAK,QAAA,SAAQ,GAAI;KACnB,KAAK;KACN,MAAK;KACJ,iBAAe,UAAU,QAAA;KACzB,OAAKQ,eAAA,CAAA,sBAAA,EAAA,aAAwC,UAAU,QAAA,OAAM,CAAA,CAAA;KAC7D,gBAAW,WAAE,KAAI,SAAU,KAAK;KAChC,UAAK,WAAE,KAAI,UAAW,KAAK;IAEzB,GAAAL,gBAAAC,MAAA,OAAA,CAAO,CAAC,KAAK,OAAO,QAAA,QAAQ,CAAA,GAAA,IAAA,UAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"slash-menu.js","names":["_sfc_main"],"sources":["../../src/components/slash-menu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { isComposing, useFloating, useLayer, useZIndex, type VirtualElement } from 'dou-ui'\nimport { computed, inject, nextTick, shallowRef, useId, useTemplateRef, watch } from 'vue'\nimport { filterOptions } from '../catalog'\nimport { labelOf, type BlockOption } from '../core/extension'\nimport { insertBlockAfter, setBlockType } from '../core/commands'\nimport { slashKey, type SlashState } from '../core/slash'\nimport { editorKey } from '../editor'\n\nconst props = defineProps<{ slash: SlashState | null }>()\n\nconst { view, messages, kit } = inject(editorKey)!\nconst id = `dou-editor-slash-${useId()}`\nconst panel = useTemplateRef<HTMLElement>('panel')\nconst active = shallowRef(0)\n\nconst options = computed(() =>\n props.slash ? filterOptions(kit.blockOptions, props.slash.query, messages.value) : [],\n)\nconst open = computed(() => !!props.slash)\n\n// the menu hangs below the `/` that opened it\nconst anchor: VirtualElement = {\n getBoundingClientRect() {\n const current = view.value\n const from = props.slash?.from\n if (!current || from === undefined) return new DOMRect()\n const { left, top, bottom } = current.coordsAtPos(from)\n return new DOMRect(left, top, 0, bottom - top)\n },\n}\nconst { style, placement, update } = useFloating(() => (open.value ? anchor : null), panel, {\n open,\n placement: 'bottom-start',\n offset: 6,\n})\n// stacked like DouUI's own popups, above whatever opened before\nconst { next } = useZIndex()\nconst zIndex = shallowRef(0)\nwatch(open, (value) => value && (zIndex.value = next()), { immediate: true })\n// a press outside the editor and the menu closes it; inside, the cursor move does\nuseLayer({\n open,\n elements: () => [panel.value, view.value?.dom],\n onOutside: () => close(),\n onEscape: () => close(),\n})\n\nwatch(\n () => props.slash?.query,\n () => {\n active.value = 0\n void nextTick(update)\n },\n)\n\n// the editor keeps focus; the active option is announced through it\nwatch(\n [open, active, options],\n () => {\n const dom = view.value?.dom\n if (!dom) return\n const option = open.value && options.value.length ? `${id}-${active.value}` : null\n if (open.value) {\n dom.setAttribute('aria-controls', id)\n dom.setAttribute('aria-expanded', 'true')\n } else {\n dom.removeAttribute('aria-controls')\n dom.removeAttribute('aria-expanded')\n }\n if (option) dom.setAttribute('aria-activedescendant', option)\n else dom.removeAttribute('aria-activedescendant')\n if (option) document.getElementById(option)?.scrollIntoView({ block: 'nearest' })\n },\n { flush: 'post' },\n)\n\nfunction choose(option: BlockOption) {\n const current = view.value\n const slash = props.slash\n if (!current || !slash) return\n // remove the `/query`, then turn the block, or add one below when it has text\n const removed = current.state.tr.delete(slash.from, current.state.selection.from)\n current.dispatch(removed.setMeta(slashKey, null))\n const { $from } = current.state.selection\n if ($from.parent.content.size > 0) insertBlockAfter($from.pos)(current.state, current.dispatch)\n if (option.type !== 'paragraph' || $from.parent.content.size === 0)\n setBlockType(option.type, option.props)(current.state, current.dispatch)\n current.focus()\n}\n\nfunction close() {\n const current = view.value\n if (current) current.dispatch(current.state.tr.setMeta(slashKey, null))\n}\n\n/** Keys the editor passes on while the menu is open. */\nfunction onKey(event: KeyboardEvent): boolean {\n if (isComposing(event)) return false\n const count = options.value.length\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n if (!count) return false\n active.value = (active.value + (event.key === 'ArrowDown' ? 1 : -1) + count) % count\n return true\n case 'Enter':\n case 'Tab': {\n const option = options.value[active.value]\n if (!option) {\n close()\n return false\n }\n choose(option)\n return true\n }\n default:\n return false\n }\n}\n\ndefineExpose({ onKey })\n</script>\n\n<template>\n <Transition name=\"dou-floating\">\n <div\n v-if=\"open\"\n :id=\"id\"\n ref=\"panel\"\n role=\"listbox\"\n :aria-label=\"messages.blockTypes\"\n class=\"dou-dropdown dou-floating dou-editor-slash\"\n :style=\"[style, { zIndex }]\"\n :data-placement=\"placement\"\n @mousedown.prevent\n >\n <div\n v-for=\"(option, index) in options\"\n :id=\"`${id}-${index}`\"\n :key=\"option.key\"\n role=\"option\"\n :aria-selected=\"index === active\"\n :class=\"['dou-dropdown__item', 'dou-editor-slash__item', { 'is-active': index === active }]\"\n @pointermove=\"active = index\"\n @click=\"choose(option)\"\n >\n <span class=\"dou-editor-slash__icon\"><component :is=\"option.icon\" /></span>\n <span class=\"dou-editor-slash__text\">\n <span class=\"dou-editor-slash__label\">{{ labelOf(option.label, messages) }}</span>\n <span v-if=\"option.hint\" class=\"dou-editor-slash__hint\">{{\n labelOf(option.hint, messages)\n }}</span>\n </span>\n <kbd v-if=\"option.shortcut\" class=\"dou-editor-slash__shortcut\">{{ option.shortcut }}</kbd>\n </div>\n <div v-if=\"!options.length\" class=\"dou-editor-slash__empty\">{{ messages.noResults }}</div>\n </div>\n </Transition>\n</template>\n"],"mappings":""}
1
+ {"version":3,"file":"slash-menu.js","names":["_sfc_main"],"sources":["../../src/components/slash-menu.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ChevronRightIcon } from '@dou-ui/icons'\nimport { isComposing, useFloating, useLayer, useZIndex, type VirtualElement } from 'dou-ui'\nimport { computed, inject, nextTick, shallowRef, useId, useTemplateRef, watch } from 'vue'\nimport { filterOptions } from '../catalog'\nimport { labelOf, type BlockOption } from '../core/extension'\nimport SlashChoices from './slash-choices.vue'\nimport { insertBlockAfter, setBlockType } from '../core/commands'\nimport { slashKey, type SlashState } from '../core/slash'\nimport { scrollParent } from '../dom'\nimport { editorKey } from '../editor'\n\nconst props = defineProps<{ slash: SlashState | null }>()\n\nconst { view, state, messages, kit } = inject(editorKey)!\nconst id = `dou-editor-slash-${useId()}`\nconst panel = useTemplateRef<HTMLElement>('panel')\nconst choicePanel = useTemplateRef<HTMLElement>('choicePanel')\nconst active = shallowRef(0)\n/**\n * The highlighted variant of the active option, when it has some (e.g. how\n * many columns); -1 while the option itself is highlighted, which inserts\n * the first variant.\n */\nconst choice = shallowRef(-1)\n/**\n * With a coarse pointer (a phone), the variants unfold in the menu under\n * their option, once it is tapped, instead of in a panel beside it that\n * would cover the menu on a narrow screen. Read when the menu opens.\n */\nconst coarse = shallowRef(false)\n/** The option whose variants are unfolded in the menu, or -1. */\nconst unfolded = shallowRef(-1)\n\nconst options = computed(() => {\n if (!props.slash) return []\n const current = state.value\n // only what can go here, e.g. no columns in a column\n const usable = current\n ? kit.blockOptions.filter((option) => setBlockType(option.type, option.props)(current))\n : kit.blockOptions\n return filterOptions(usable, props.slash.query, messages.value)\n})\nconst open = computed(() => !!props.slash)\nconst activeOption = computed(() => options.value[active.value])\nconst activeChoices = computed(() => (open.value ? activeOption.value?.choices : undefined))\n/** The variants in the panel beside the menu. */\nconst choices = computed(() => (coarse.value ? undefined : activeChoices.value))\n/** The variants unfolded in the menu, or shown beside it: where the keys pick from. */\nconst shownChoices = computed(() =>\n coarse.value\n ? unfolded.value === active.value\n ? activeChoices.value\n : undefined\n : choices.value,\n)\nwatch(activeOption, () => {\n // an option just unfolded keeps its variants\n if (unfolded.value === active.value) return\n choice.value = -1\n unfolded.value = -1\n})\nwatch(open, (value) => {\n if (value) coarse.value = window.matchMedia?.('(pointer: coarse)').matches ?? false\n})\n\n// the menu hangs below the `/` that opened it\nconst anchor: VirtualElement = {\n getBoundingClientRect() {\n const current = view.value\n const from = props.slash?.from\n if (!current || from === undefined) return new DOMRect()\n const { left, top, bottom } = current.coordsAtPos(from)\n return new DOMRect(left, top, 0, bottom - top)\n },\n}\nconst { style, placement, update } = useFloating(() => (open.value ? anchor : null), panel, {\n open,\n placement: 'bottom-start',\n offset: 6,\n})\n// the variants of the active option, in a panel beside it\nconst activeItem = () => (choices.value ? document.getElementById(`${id}-${active.value}`) : null)\nconst {\n style: choiceStyle,\n placement: choicePlacement,\n update: updateChoices,\n} = useFloating(activeItem, choicePanel, {\n open: () => !!choices.value,\n placement: 'right-start',\n offset: 4,\n})\nwatch([choices, active], () => void nextTick(updateChoices), { flush: 'post' })\n\n// stacked like DouUI's own popups, above whatever opened before\nconst { next } = useZIndex()\nconst zIndex = shallowRef(0)\nwatch(open, (value) => value && (zIndex.value = next()), { immediate: true })\n// a press outside the editor and the menu closes it; inside, the cursor move does\nuseLayer({\n open,\n elements: () => [panel.value, choicePanel.value, view.value?.dom],\n onOutside: () => close(),\n onEscape: () => close(),\n})\n\nwatch(\n () => props.slash?.query,\n () => {\n active.value = 0\n void nextTick(update)\n },\n)\n\n// the editor keeps focus; the active option, or variant, is announced through it\nwatch(\n [open, active, options, choice, shownChoices],\n () => {\n const dom = view.value?.dom\n if (!dom) return\n const option =\n open.value && options.value.length\n ? shownChoices.value && choice.value >= 0\n ? `${id}-choice-${choice.value}`\n : `${id}-${active.value}`\n : null\n if (open.value) {\n dom.setAttribute('aria-controls', choices.value ? `${id} ${id}-choices` : id)\n dom.setAttribute('aria-expanded', 'true')\n } else {\n dom.removeAttribute('aria-controls')\n dom.removeAttribute('aria-expanded')\n }\n if (option) dom.setAttribute('aria-activedescendant', option)\n else dom.removeAttribute('aria-activedescendant')\n if (option) document.getElementById(option)?.scrollIntoView({ block: 'nearest' })\n },\n { flush: 'post' },\n)\n\n/** On a touch screen, the first tap on an option with variants only shows them. */\nlet touched = false\nconst onItemPointer = (event: PointerEvent) => (touched = event.pointerType !== 'mouse')\n\nfunction onItemMove(event: PointerEvent, index: number) {\n if (event.pointerType === 'touch') return\n active.value = index\n // back on the option: clicking it inserts the first variant again\n choice.value = -1\n}\n\n/**\n * On a phone: the variants under option `index`, the first one lit (what\n * a tap on the option inserts), and in sight, the page scrolled up when\n * the menu has no room left below.\n */\nfunction unfold(index: number) {\n active.value = index\n unfolded.value = index\n choice.value = 0\n void nextTick(() => {\n const menu = panel.value\n const group = menu?.querySelector<HTMLElement>('.dou-editor-slash__unfolded')\n const dom = view.value?.dom\n if (!menu || !group || !dom) return\n const hidden = menu.scrollHeight - menu.clientHeight\n if (hidden > 0) {\n const scroller = scrollParent(dom)\n if (scroller) scroller.scrollBy({ top: hidden })\n else window.scrollBy({ top: hidden })\n }\n requestAnimationFrame(() => {\n update()\n requestAnimationFrame(() => group.scrollIntoView({ block: 'nearest' }))\n })\n })\n}\n\nfunction onItemClick(option: BlockOption, index: number) {\n if (option.choices && (coarse.value || touched) && unfolded.value !== index) {\n unfold(index)\n return\n }\n choose(option)\n}\n\nfunction choose(option: BlockOption, variant = option.choices ? Math.max(0, choice.value) : -1) {\n const current = view.value\n const slash = props.slash\n if (!current || !slash) return\n const chosen = { ...option.props, ...option.choices?.items[variant]?.props }\n // remove the `/query`, then turn the block, or add one below when it has text\n const removed = current.state.tr.delete(slash.from, current.state.selection.from)\n current.dispatch(removed.setMeta(slashKey, null))\n const { $from } = current.state.selection\n if ($from.parent.content.size > 0) insertBlockAfter($from.pos)(current.state, current.dispatch)\n if (option.type !== 'paragraph' || $from.parent.content.size === 0)\n setBlockType(option.type, chosen)(current.state, current.dispatch)\n current.focus()\n}\n\nfunction close() {\n const current = view.value\n if (current) current.dispatch(current.state.tr.setMeta(slashKey, null))\n}\n\n/** Keys the editor passes on while the menu is open. */\nfunction onKey(event: KeyboardEvent): boolean {\n if (isComposing(event)) return false\n const count = options.value.length\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n if (!count) return false\n active.value = (active.value + (event.key === 'ArrowDown' ? 1 : -1) + count) % count\n return true\n case 'ArrowRight': {\n const items = activeChoices.value?.items\n if (!items) return false\n if (coarse.value && unfolded.value !== active.value) {\n unfold(active.value)\n return true\n }\n // past the last variant the key moves the cursor again\n if (choice.value >= items.length - 1) return false\n choice.value++\n return true\n }\n case 'ArrowLeft':\n // from the first variant back to the option; on the option the key moves the cursor\n if (!activeChoices.value || choice.value < 0) return false\n choice.value--\n return true\n case 'Enter':\n case 'Tab': {\n const option = options.value[active.value]\n if (!option) {\n close()\n return false\n }\n choose(option)\n return true\n }\n default:\n return false\n }\n}\n\ndefineExpose({ onKey })\n</script>\n\n<template>\n <Transition name=\"dou-floating\">\n <div\n v-if=\"open\"\n :id=\"id\"\n ref=\"panel\"\n role=\"listbox\"\n :aria-label=\"messages.blockTypes\"\n class=\"dou-dropdown dou-floating dou-editor-slash\"\n :style=\"[style, { zIndex }]\"\n :data-placement=\"placement\"\n @mousedown.prevent\n >\n <template v-for=\"(option, index) in options\" :key=\"option.key\">\n <div\n :id=\"`${id}-${index}`\"\n role=\"option\"\n :aria-selected=\"index === active\"\n :class=\"[\n 'dou-dropdown__item',\n 'dou-editor-slash__item',\n { 'is-active': index === active },\n ]\"\n @pointerdown=\"onItemPointer\"\n @pointermove=\"onItemMove($event, index)\"\n @click=\"onItemClick(option, index)\"\n >\n <span class=\"dou-editor-slash__icon\"><component :is=\"option.icon\" /></span>\n <span class=\"dou-editor-slash__text\">\n <span class=\"dou-editor-slash__label\">{{ labelOf(option.label, messages) }}</span>\n <span v-if=\"option.hint\" class=\"dou-editor-slash__hint\">{{\n labelOf(option.hint, messages)\n }}</span>\n </span>\n <kbd v-if=\"option.shortcut\" class=\"dou-editor-slash__shortcut\">{{ option.shortcut }}</kbd>\n <ChevronRightIcon\n v-if=\"option.choices\"\n :class=\"['dou-editor-slash__more', { 'is-unfolded': coarse && unfolded === index }]\"\n aria-hidden=\"true\"\n />\n </div>\n <!-- on a phone: the variants under their option -->\n <div\n v-if=\"option.choices && coarse && unfolded === index\"\n role=\"group\"\n :aria-label=\"labelOf(option.choices.title, messages)\"\n class=\"dou-editor-slash__unfolded\"\n >\n <SlashChoices\n :choices=\"option.choices\"\n :active=\"choice\"\n :messages=\"messages\"\n :id-prefix=\"`${id}-choice`\"\n @hover=\"choice = $event\"\n @choose=\"choose(option, $event)\"\n />\n </div>\n </template>\n <div v-if=\"!options.length\" class=\"dou-editor-slash__empty\">{{ messages.noResults }}</div>\n </div>\n </Transition>\n <Transition name=\"dou-floating\">\n <div\n v-if=\"choices && activeOption\"\n :id=\"`${id}-choices`\"\n ref=\"choicePanel\"\n role=\"listbox\"\n :aria-label=\"labelOf(choices.title, messages)\"\n class=\"dou-dropdown dou-floating dou-editor-slash__choices\"\n :style=\"[choiceStyle, { zIndex }]\"\n :data-placement=\"choicePlacement\"\n @mousedown.prevent\n >\n <SlashChoices\n :choices=\"choices\"\n :active=\"choice\"\n :messages=\"messages\"\n :id-prefix=\"`${id}-choice`\"\n @hover=\"choice = $event\"\n @choose=\"choose(activeOption!, $event)\"\n />\n </div>\n </Transition>\n</template>\n"],"mappings":""}
@@ -2,9 +2,12 @@ import { labelOf } from "../core/extension.js";
2
2
  import { filterOptions } from "../catalog.js";
3
3
  import { insertBlockAfter, setBlockType } from "../core/commands.js";
4
4
  import { slashKey } from "../core/slash.js";
5
+ import { scrollParent } from "../dom.js";
5
6
  import { editorKey } from "../editor.js";
7
+ import slash_choices_default from "./slash-choices.js";
6
8
  import { isComposing, useFloating, useLayer, useZIndex } from "dou-ui";
7
- import { Fragment, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, inject, nextTick, normalizeClass, normalizeStyle, openBlock, renderList, resolveDynamicComponent, shallowRef, toDisplayString, unref, useId, useTemplateRef, watch, withCtx, withModifiers } from "vue";
9
+ import { Fragment, Transition, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createVNode, defineComponent, inject, nextTick, normalizeClass, normalizeStyle, openBlock, renderList, resolveDynamicComponent, shallowRef, toDisplayString, unref, useId, useTemplateRef, watch, withCtx, withModifiers } from "vue";
10
+ import { ChevronRightIcon } from "@dou-ui/icons";
8
11
  // src/components/slash-menu.vue?vue&type=script&setup=true&lang.ts
9
12
  var _hoisted_1 = ["aria-label", "data-placement"];
10
13
  var _hoisted_2 = [
@@ -24,21 +27,61 @@ var _hoisted_7 = {
24
27
  key: 0,
25
28
  class: "dou-editor-slash__shortcut"
26
29
  };
27
- var _hoisted_8 = {
30
+ var _hoisted_8 = ["aria-label"];
31
+ var _hoisted_9 = {
28
32
  key: 0,
29
33
  class: "dou-editor-slash__empty"
30
34
  };
35
+ var _hoisted_10 = [
36
+ "id",
37
+ "aria-label",
38
+ "data-placement"
39
+ ];
31
40
  var slash_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
32
41
  __name: "slash-menu",
33
42
  props: { slash: {} },
34
43
  setup(__props, { expose: __expose }) {
35
44
  const props = __props;
36
- const { view, messages, kit } = inject(editorKey);
45
+ const { view, state, messages, kit } = inject(editorKey);
37
46
  const id = `dou-editor-slash-${useId()}`;
38
47
  const panel = useTemplateRef("panel");
48
+ const choicePanel = useTemplateRef("choicePanel");
39
49
  const active = shallowRef(0);
40
- const options = computed(() => props.slash ? filterOptions(kit.blockOptions, props.slash.query, messages.value) : []);
50
+ /**
51
+ * The highlighted variant of the active option, when it has some (e.g. how
52
+ * many columns); -1 while the option itself is highlighted, which inserts
53
+ * the first variant.
54
+ */
55
+ const choice = shallowRef(-1);
56
+ /**
57
+ * With a coarse pointer (a phone), the variants unfold in the menu under
58
+ * their option, once it is tapped, instead of in a panel beside it that
59
+ * would cover the menu on a narrow screen. Read when the menu opens.
60
+ */
61
+ const coarse = shallowRef(false);
62
+ /** The option whose variants are unfolded in the menu, or -1. */
63
+ const unfolded = shallowRef(-1);
64
+ const options = computed(() => {
65
+ if (!props.slash) return [];
66
+ const current = state.value;
67
+ const usable = current ? kit.blockOptions.filter((option) => setBlockType(option.type, option.props)(current)) : kit.blockOptions;
68
+ return filterOptions(usable, props.slash.query, messages.value);
69
+ });
41
70
  const open = computed(() => !!props.slash);
71
+ const activeOption = computed(() => options.value[active.value]);
72
+ const activeChoices = computed(() => open.value ? activeOption.value?.choices : void 0);
73
+ /** The variants in the panel beside the menu. */
74
+ const choices = computed(() => coarse.value ? void 0 : activeChoices.value);
75
+ /** The variants unfolded in the menu, or shown beside it: where the keys pick from. */
76
+ const shownChoices = computed(() => coarse.value ? unfolded.value === active.value ? activeChoices.value : void 0 : choices.value);
77
+ watch(activeOption, () => {
78
+ if (unfolded.value === active.value) return;
79
+ choice.value = -1;
80
+ unfolded.value = -1;
81
+ });
82
+ watch(open, (value) => {
83
+ if (value) coarse.value = window.matchMedia?.("(pointer: coarse)").matches ?? false;
84
+ });
42
85
  const anchor = { getBoundingClientRect() {
43
86
  const current = view.value;
44
87
  const from = props.slash?.from;
@@ -51,12 +94,23 @@ var slash_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
51
94
  placement: "bottom-start",
52
95
  offset: 6
53
96
  });
97
+ const activeItem = () => choices.value ? document.getElementById(`${id}-${active.value}`) : null;
98
+ const { style: choiceStyle, placement: choicePlacement, update: updateChoices } = useFloating(activeItem, choicePanel, {
99
+ open: () => !!choices.value,
100
+ placement: "right-start",
101
+ offset: 4
102
+ });
103
+ watch([choices, active], () => void nextTick(updateChoices), { flush: "post" });
54
104
  const { next } = useZIndex();
55
105
  const zIndex = shallowRef(0);
56
106
  watch(open, (value) => value && (zIndex.value = next()), { immediate: true });
57
107
  useLayer({
58
108
  open,
59
- elements: () => [panel.value, view.value?.dom],
109
+ elements: () => [
110
+ panel.value,
111
+ choicePanel.value,
112
+ view.value?.dom
113
+ ],
60
114
  onOutside: () => close(),
61
115
  onEscape: () => close()
62
116
  });
@@ -67,13 +121,15 @@ var slash_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
67
121
  watch([
68
122
  open,
69
123
  active,
70
- options
124
+ options,
125
+ choice,
126
+ shownChoices
71
127
  ], () => {
72
128
  const dom = view.value?.dom;
73
129
  if (!dom) return;
74
- const option = open.value && options.value.length ? `${id}-${active.value}` : null;
130
+ const option = open.value && options.value.length ? shownChoices.value && choice.value >= 0 ? `${id}-choice-${choice.value}` : `${id}-${active.value}` : null;
75
131
  if (open.value) {
76
- dom.setAttribute("aria-controls", id);
132
+ dom.setAttribute("aria-controls", choices.value ? `${id} ${id}-choices` : id);
77
133
  dom.setAttribute("aria-expanded", "true");
78
134
  } else {
79
135
  dom.removeAttribute("aria-controls");
@@ -83,15 +139,60 @@ var slash_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
83
139
  else dom.removeAttribute("aria-activedescendant");
84
140
  if (option) document.getElementById(option)?.scrollIntoView({ block: "nearest" });
85
141
  }, { flush: "post" });
86
- function choose(option) {
142
+ /** On a touch screen, the first tap on an option with variants only shows them. */
143
+ let touched = false;
144
+ const onItemPointer = (event) => touched = event.pointerType !== "mouse";
145
+ function onItemMove(event, index) {
146
+ if (event.pointerType === "touch") return;
147
+ active.value = index;
148
+ choice.value = -1;
149
+ }
150
+ /**
151
+ * On a phone: the variants under option `index`, the first one lit (what
152
+ * a tap on the option inserts), and in sight, the page scrolled up when
153
+ * the menu has no room left below.
154
+ */
155
+ function unfold(index) {
156
+ active.value = index;
157
+ unfolded.value = index;
158
+ choice.value = 0;
159
+ nextTick(() => {
160
+ const menu = panel.value;
161
+ const group = menu?.querySelector(".dou-editor-slash__unfolded");
162
+ const dom = view.value?.dom;
163
+ if (!menu || !group || !dom) return;
164
+ const hidden = menu.scrollHeight - menu.clientHeight;
165
+ if (hidden > 0) {
166
+ const scroller = scrollParent(dom);
167
+ if (scroller) scroller.scrollBy({ top: hidden });
168
+ else window.scrollBy({ top: hidden });
169
+ }
170
+ requestAnimationFrame(() => {
171
+ update();
172
+ requestAnimationFrame(() => group.scrollIntoView({ block: "nearest" }));
173
+ });
174
+ });
175
+ }
176
+ function onItemClick(option, index) {
177
+ if (option.choices && (coarse.value || touched) && unfolded.value !== index) {
178
+ unfold(index);
179
+ return;
180
+ }
181
+ choose(option);
182
+ }
183
+ function choose(option, variant = option.choices ? Math.max(0, choice.value) : -1) {
87
184
  const current = view.value;
88
185
  const slash = props.slash;
89
186
  if (!current || !slash) return;
187
+ const chosen = {
188
+ ...option.props,
189
+ ...option.choices?.items[variant]?.props
190
+ };
90
191
  const removed = current.state.tr.delete(slash.from, current.state.selection.from);
91
192
  current.dispatch(removed.setMeta(slashKey, null));
92
193
  const { $from } = current.state.selection;
93
194
  if ($from.parent.content.size > 0) insertBlockAfter($from.pos)(current.state, current.dispatch);
94
- if (option.type !== "paragraph" || $from.parent.content.size === 0) setBlockType(option.type, option.props)(current.state, current.dispatch);
195
+ if (option.type !== "paragraph" || $from.parent.content.size === 0) setBlockType(option.type, chosen)(current.state, current.dispatch);
95
196
  current.focus();
96
197
  }
97
198
  function close() {
@@ -108,6 +209,21 @@ var slash_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
108
209
  if (!count) return false;
109
210
  active.value = (active.value + (event.key === "ArrowDown" ? 1 : -1) + count) % count;
110
211
  return true;
212
+ case "ArrowRight": {
213
+ const items = activeChoices.value?.items;
214
+ if (!items) return false;
215
+ if (coarse.value && unfolded.value !== active.value) {
216
+ unfold(active.value);
217
+ return true;
218
+ }
219
+ if (choice.value >= items.length - 1) return false;
220
+ choice.value++;
221
+ return true;
222
+ }
223
+ case "ArrowLeft":
224
+ if (!activeChoices.value || choice.value < 0) return false;
225
+ choice.value--;
226
+ return true;
111
227
  case "Enter":
112
228
  case "Tab": {
113
229
  const option = options.value[active.value];
@@ -123,7 +239,7 @@ var slash_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
123
239
  }
124
240
  __expose({ onKey });
125
241
  return (_ctx, _cache) => {
126
- return openBlock(), createBlock(Transition, { name: "dou-floating" }, {
242
+ return openBlock(), createElementBlock(Fragment, null, [createVNode(Transition, { name: "dou-floating" }, {
127
243
  default: withCtx(() => [open.value ? (openBlock(), createElementBlock("div", {
128
244
  key: 0,
129
245
  id,
@@ -134,11 +250,10 @@ var slash_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
134
250
  class: "dou-dropdown dou-floating dou-editor-slash",
135
251
  style: normalizeStyle([unref(style), { zIndex: zIndex.value }]),
136
252
  "data-placement": unref(placement),
137
- onMousedown: _cache[0] || (_cache[0] = withModifiers(() => {}, ["prevent"]))
253
+ onMousedown: _cache[1] || (_cache[1] = withModifiers(() => {}, ["prevent"]))
138
254
  }, [(openBlock(true), createElementBlock(Fragment, null, renderList(options.value, (option, index) => {
139
- return openBlock(), createElementBlock("div", {
255
+ return openBlock(), createElementBlock(Fragment, { key: option.key }, [createElementVNode("div", {
140
256
  id: `${id}-${index}`,
141
- key: option.key,
142
257
  role: "option",
143
258
  "aria-selected": index === active.value,
144
259
  class: normalizeClass([
@@ -146,16 +261,66 @@ var slash_menu_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defin
146
261
  "dou-editor-slash__item",
147
262
  { "is-active": index === active.value }
148
263
  ]),
149
- onPointermove: ($event) => active.value = index,
150
- onClick: ($event) => choose(option)
264
+ onPointerdown: onItemPointer,
265
+ onPointermove: ($event) => onItemMove($event, index),
266
+ onClick: ($event) => onItemClick(option, index)
151
267
  }, [
152
268
  createElementVNode("span", _hoisted_3, [(openBlock(), createBlock(resolveDynamicComponent(option.icon)))]),
153
269
  createElementVNode("span", _hoisted_4, [createElementVNode("span", _hoisted_5, toDisplayString(unref(labelOf)(option.label, unref(messages))), 1), option.hint ? (openBlock(), createElementBlock("span", _hoisted_6, toDisplayString(unref(labelOf)(option.hint, unref(messages))), 1)) : createCommentVNode("", true)]),
154
- option.shortcut ? (openBlock(), createElementBlock("kbd", _hoisted_7, toDisplayString(option.shortcut), 1)) : createCommentVNode("", true)
155
- ], 42, _hoisted_2);
156
- }), 128)), !options.value.length ? (openBlock(), createElementBlock("div", _hoisted_8, toDisplayString(unref(messages).noResults), 1)) : createCommentVNode("", true)], 44, _hoisted_1)) : createCommentVNode("", true)]),
270
+ option.shortcut ? (openBlock(), createElementBlock("kbd", _hoisted_7, toDisplayString(option.shortcut), 1)) : createCommentVNode("", true),
271
+ option.choices ? (openBlock(), createBlock(unref(ChevronRightIcon), {
272
+ key: 1,
273
+ class: normalizeClass(["dou-editor-slash__more", { "is-unfolded": coarse.value && unfolded.value === index }]),
274
+ "aria-hidden": "true"
275
+ }, null, 8, ["class"])) : createCommentVNode("", true)
276
+ ], 42, _hoisted_2), option.choices && coarse.value && unfolded.value === index ? (openBlock(), createElementBlock("div", {
277
+ key: 0,
278
+ role: "group",
279
+ "aria-label": unref(labelOf)(option.choices.title, unref(messages)),
280
+ class: "dou-editor-slash__unfolded"
281
+ }, [createVNode(slash_choices_default, {
282
+ choices: option.choices,
283
+ active: choice.value,
284
+ messages: unref(messages),
285
+ "id-prefix": `${id}-choice`,
286
+ onHover: _cache[0] || (_cache[0] = ($event) => choice.value = $event),
287
+ onChoose: ($event) => choose(option, $event)
288
+ }, null, 8, [
289
+ "choices",
290
+ "active",
291
+ "messages",
292
+ "id-prefix",
293
+ "onChoose"
294
+ ])], 8, _hoisted_8)) : createCommentVNode("", true)], 64);
295
+ }), 128)), !options.value.length ? (openBlock(), createElementBlock("div", _hoisted_9, toDisplayString(unref(messages).noResults), 1)) : createCommentVNode("", true)], 44, _hoisted_1)) : createCommentVNode("", true)]),
157
296
  _: 1
158
- });
297
+ }), createVNode(Transition, { name: "dou-floating" }, {
298
+ default: withCtx(() => [choices.value && activeOption.value ? (openBlock(), createElementBlock("div", {
299
+ key: 0,
300
+ id: `${id}-choices`,
301
+ ref_key: "choicePanel",
302
+ ref: choicePanel,
303
+ role: "listbox",
304
+ "aria-label": unref(labelOf)(choices.value.title, unref(messages)),
305
+ class: "dou-dropdown dou-floating dou-editor-slash__choices",
306
+ style: normalizeStyle([unref(choiceStyle), { zIndex: zIndex.value }]),
307
+ "data-placement": unref(choicePlacement),
308
+ onMousedown: _cache[4] || (_cache[4] = withModifiers(() => {}, ["prevent"]))
309
+ }, [createVNode(slash_choices_default, {
310
+ choices: choices.value,
311
+ active: choice.value,
312
+ messages: unref(messages),
313
+ "id-prefix": `${id}-choice`,
314
+ onHover: _cache[2] || (_cache[2] = ($event) => choice.value = $event),
315
+ onChoose: _cache[3] || (_cache[3] = ($event) => choose(activeOption.value, $event))
316
+ }, null, 8, [
317
+ "choices",
318
+ "active",
319
+ "messages",
320
+ "id-prefix"
321
+ ])], 44, _hoisted_10)) : createCommentVNode("", true)]),
322
+ _: 1
323
+ })], 64);
159
324
  };
160
325
  }
161
326
  });