@ecsplico/editor 3.3.0 → 3.5.0
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/CHANGELOG.md +24 -0
- package/dist/core/abilities.js +1 -0
- package/dist/core/abilities.js.map +1 -1
- package/dist/core/backend-capability.d.ts +1 -1
- package/dist/core/backend-capability.js +2 -1
- package/dist/core/backend-capability.js.map +1 -1
- package/dist/core/backend-types.d.ts +25 -0
- package/dist/core/backend-types.js.map +1 -1
- package/dist/core/backend.d.ts +9 -1
- package/dist/core/backend.js.map +1 -1
- package/dist/core/http-backend.js +17 -0
- package/dist/core/http-backend.js.map +1 -1
- package/dist/core/schema/abilities.d.ts +1 -0
- package/dist/core/schema/abilities.js +4 -0
- package/dist/core/schema/abilities.js.map +1 -1
- package/dist/features/ai/protocol/generate.d.ts +1 -1
- package/dist/features/composites/components/CompositeChrome.js +10 -9
- package/dist/features/composites/components/CompositeChrome.js.map +1 -1
- package/dist/features/composites/kinds.d.ts +4 -0
- package/dist/features/composites/kinds.js.map +1 -1
- package/dist/features/composites/merge.d.ts +1 -1
- package/dist/features/composites/merge.js +5 -2
- package/dist/features/composites/merge.js.map +1 -1
- package/dist/features/composites/nodes.js +1 -0
- package/dist/features/composites/nodes.js.map +1 -1
- package/dist/features/composites/outline.d.ts +9 -2
- package/dist/features/composites/outline.js +41 -3
- package/dist/features/composites/outline.js.map +1 -1
- package/dist/features/composites/react/CompositeChrome.js +11 -9
- package/dist/features/composites/react/CompositeChrome.js.map +1 -1
- package/dist/features/composites/rows.d.ts +2 -0
- package/dist/features/composites/rows.js +1 -0
- package/dist/features/composites/rows.js.map +1 -1
- package/dist/features/image-studio/components/ImageStudioChat.js +121 -0
- package/dist/features/image-studio/components/ImageStudioChat.js.map +1 -0
- package/dist/features/image-studio/components/ImageStudioDialog.js +371 -0
- package/dist/features/image-studio/components/ImageStudioDialog.js.map +1 -0
- package/dist/features/image-studio/components/ImageStudioDialog.vue.d.ts +25 -0
- package/dist/features/image-studio/components/ImageStudioTile.js +74 -0
- package/dist/features/image-studio/components/ImageStudioTile.js.map +1 -0
- package/dist/features/image-studio/components/ImageStudioView.js +117 -0
- package/dist/features/image-studio/components/ImageStudioView.js.map +1 -0
- package/dist/features/image-studio/feature.d.ts +24 -0
- package/dist/features/image-studio/feature.js +53 -0
- package/dist/features/image-studio/feature.js.map +1 -0
- package/dist/features/image-studio/index.d.ts +5 -0
- package/dist/features/image-studio/index.js +4 -0
- package/dist/features/image-studio/node-store.d.ts +27 -0
- package/dist/features/image-studio/node-store.js +64 -0
- package/dist/features/image-studio/node-store.js.map +1 -0
- package/dist/features/image-studio/schema.d.ts +29 -0
- package/dist/features/image-studio/schema.js +86 -0
- package/dist/features/image-studio/schema.js.map +1 -0
- package/dist/features/image-studio/state.d.ts +52 -0
- package/dist/features/image-studio/state.js +147 -0
- package/dist/features/image-studio/state.js.map +1 -0
- package/dist/features/image-studio/store.d.ts +29 -0
- package/dist/features/image-studio/vue.d.ts +17 -0
- package/dist/features/image-studio/vue.js +20 -0
- package/dist/features/image-studio/vue.js.map +1 -0
- package/dist/features/media/schema.d.ts +5 -1
- package/dist/features/media/schema.js +3 -3
- package/dist/features/media/schema.js.map +1 -1
- package/dist/features/transcript/segment-node.js +1 -0
- package/dist/features/transcript/segment-node.js.map +1 -1
- package/dist/i18n/de/image-studio.js +39 -0
- package/dist/i18n/de/image-studio.js.map +1 -0
- package/dist/i18n/de.d.ts +32 -0
- package/dist/i18n/de.js +13 -11
- package/dist/i18n/de.js.map +1 -1
- package/dist/i18n/en/image-studio.js +39 -0
- package/dist/i18n/en/image-studio.js.map +1 -0
- package/dist/i18n/en.js +13 -11
- package/dist/i18n/en.js.map +1 -1
- package/dist/nuxt/module.d.ts +64 -0
- package/dist/server/handlers/images.d.ts +22 -0
- package/dist/server/handlers/images.js +46 -0
- package/dist/server/handlers/images.js.map +1 -0
- package/dist/server/handlers/index.d.ts +2 -1
- package/dist/server/handlers/index.js +2 -1
- package/dist/server/index.d.ts +2 -2
- package/dist/server/ports.d.ts +11 -1
- package/dist/server/ports.js +2 -1
- package/dist/server/ports.js.map +1 -1
- package/dist/server/routes.js +19 -0
- package/dist/server/routes.js.map +1 -1
- package/dist/tree/DocumentTree.js +5 -4
- package/dist/tree/DocumentTree.js.map +1 -1
- package/dist/tree/react/DocumentTree.js +2 -1
- package/dist/tree/react/DocumentTree.js.map +1 -1
- package/dist/tree/tree-items.js +1 -0
- package/dist/tree/tree-items.js.map +1 -1
- package/dist/vue/AdvancedEditor.vue.d.ts +1 -1
- package/package.json +16 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CompositeChrome.js","names":["_unref","_openBlock","_createBlock","_Teleport","_createElementVNode","_createElementBlock","_Fragment","_renderList","_withCtx","_createVNode","CompositeDetails","_normalizeClass","_normalizeStyle","_withKeys","_withModifiers","_createCommentVNode","CompositeBasketMenu","_createTextVNode","_toDisplayString","CompositeStatusMenu","CompositeTagsEditor"],"sources":["../../../../src/features/composites/components/CompositeChrome.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Editor } from '@tiptap/vue-3'\nimport { computed, shallowRef, watch } from 'vue'\nimport { startBlockDrag } from '../../../core'\nimport { useUiKit } from '../../../vue/kit/use-ui-kit'\nimport { useEditorI18n } from '../../../vue/use-editor-i18n'\nimport { useStoreRef } from '../../../vue/store-ref'\nimport { useEditorSettings } from '../../../vue/settings'\nimport { compositeSectionOf } from '../anchors'\nimport { derivedChromeOf } from '../derived-chrome'\nimport { rowStatus } from '../meta-display'\nimport { basketById, basketOf, titleHiddenOf } from '../baskets'\nimport { compositeBasketsOf } from '../nodes'\nimport { compositeOfRow, type CompositeRow, setCompositeTags } from '../rows'\nimport { useCompositeAnchors } from '../use-composite-anchors'\nimport { useCompositeRows } from '../use-composite-rows'\nimport CompositeBasketMenu from './CompositeBasketMenu.vue'\nimport CompositeDetails from './CompositeDetails.vue'\nimport CompositeStatusMenu from './CompositeStatusMenu.vue'\nimport CompositeTagsEditor from './CompositeTagsEditor.vue'\n\n/**\n * Chrome of every composite, laid over the editor (mounted by the composites feature): on the title line the status\n * chip and one chip per tag (with a `+` chip to add tags), and on the front the kind icon. The icon is a button that\n * opens the details popover (kind with a confirmation before it changes, the kind's fields and the summary;\n * `CompositeDetails`) and, in an editable editor, the composite's drag handle: dragging it moves the composite\n * (`startBlockDrag`). A kind with `chrome.tags: false` shows no tag chips and no `+` chip. With `blocks.kindIcon: 'hover'` it shows only while the composite is hovered, its popover is\n * open or the icon has keyboard focus. Chips and popover also render in read-only editors, without edit affordances.\n * The node view's own description and tags rows are hidden by CSS; this overlay shows and edits them.\n */\nconst props = defineProps<{ editor: Editor }>()\n\nconst { Icon: UIcon, Popover: UPopover } = useUiKit()\nconst { t } = useEditorI18n()\n\nconst { rows } = useCompositeRows(() => props.editor)\nconst { host, anchors, frame } = useCompositeAnchors(() => props.editor, rows)\n\n// `isEditable` is not reactive: follow it on every transaction (`EditorSurface` dispatches one after `setEditable`).\nconst editable = shallowRef(false)\nwatch(() => props.editor, (instance, _previous, onCleanup) => {\n editable.value = !instance.isDestroyed && instance.isEditable\n const sync = () => {\n editable.value = !instance.isDestroyed && instance.isEditable\n }\n instance.on('transaction', sync)\n onCleanup(() => instance.off('transaction', sync))\n}, { immediate: true })\n\nconst { settings } = useEditorSettings()\nconst iconOnHover = computed(() => settings.value.blocks.kindIcon === 'hover')\n\n// Hover state of `kindIcon: 'hover'`: the keys of the rows whose composite is under the pointer (that one and every\n// composite around it), plus the row whose chips the pointer is on (they sit outside the editor's DOM).\nconst hoveredKeys = shallowRef<ReadonlySet<string>>(new Set())\nconst chipsHoveredKey = shallowRef<string | null>(null)\nlet hoveredSection: Element | null = null\n\nfunction onEditorMouseover(event: MouseEvent) {\n const section = event.target instanceof Element ? event.target.closest('.composite') : null\n if (section === hoveredSection) return\n hoveredSection = section\n const chain = new Set<Element>()\n for (let el = section; el; el = el.parentElement?.closest('.composite') ?? null) chain.add(el)\n const { view, state } = props.editor\n hoveredKeys.value = new Set(rows.value.filter((row) => {\n const found = compositeOfRow(state.doc, row)\n const dom = found ? view.nodeDOM(found.pos) : null\n const section = dom instanceof Element ? compositeSectionOf(dom) : null\n return section !== null && chain.has(section)\n }).map(row => row.key))\n}\n\nfunction onEditorMouseleave() {\n hoveredSection = null\n hoveredKeys.value = new Set()\n}\n\nwatch([() => props.editor, iconOnHover], ([instance, hover], _previous, onCleanup) => {\n onEditorMouseleave()\n if (!hover || instance.isDestroyed) return\n const { dom } = instance.view\n dom.addEventListener('mouseover', onEditorMouseover)\n dom.addEventListener('mouseleave', onEditorMouseleave)\n onCleanup(() => {\n dom.removeEventListener('mouseover', onEditorMouseover)\n dom.removeEventListener('mouseleave', onEditorMouseleave)\n })\n}, { immediate: true })\n\nfunction onIconDragStart(event: DragEvent, row: CompositeRow) {\n const found = compositeOfRow(props.editor.state.doc, row)\n if (!found || !startBlockDrag(props.editor, event, found.pos)) event.preventDefault()\n}\n\n/** Chips start right after the title's last character and run on to the editor's right edge. */\nconst ROW_HEIGHT = 24\n\nconst expanded = useStoreRef(() => props.editor.storage.composite.expanded)\nconst revealedTitles = useStoreRef(() => props.editor.storage.composite.revealedTitles)\n\nconst placed = computed(() => {\n const baskets = compositeBasketsOf(props.editor)\n // End of the collapsed derived Baustein the rows being walked sit in: its clipped content shows no chrome.\n let hiddenUntil = -1\n return rows.value.flatMap((row) => {\n if (row.pos < hiddenUntil) return []\n const derived = derivedChromeOf(props.editor, row)\n const open = !derived || !row.id || expanded.value.has(row.id)\n if (!open) hiddenUntil = row.end\n const anchor = anchors.value.get(row.key)\n if (!anchor) return []\n const titleHidden = titleHiddenOf(row)\n // A hidden title leaves nothing to measure: the chips sit in the strip beside the kind icon (`composites.css`).\n const inStrip = titleHidden && !(row.id && revealedTitles.value.has(row.id)) && anchor.toggleSize > 0\n // An empty title shows a placeholder the anchor cannot measure: keep clear of it.\n const left = inStrip ? anchor.toggleLeft + anchor.toggleSize + 6 : anchor.lineEnd + (anchor.titleEmpty ? 116 : 12)\n return [{\n row,\n anchor,\n left,\n top: (inStrip ? anchor.toggleTop + anchor.toggleSize / 2 : anchor.lastCenter) - ROW_HEIGHT / 2,\n width: Math.max((frame.value?.right ?? anchor.right) - left, 120),\n status: rowStatus(row, t),\n derived: derived && { stale: derived.stale, open, toggleable: !!row.id },\n basket: basketById(baskets, basketOf(row)) ?? null,\n titleHidden,\n }]\n })\n})\n\nfunction toggleExpanded(row: CompositeRow) {\n if (row.id) props.editor.commands.toggleCompositeExpanded(row.id)\n}\n\nfunction removeTag(row: CompositeRow, tag: string) {\n setCompositeTags(props.editor, row, row.tags.filter(candidate => candidate !== tag))\n}\n\nfunction toggleTitleHidden(row: CompositeRow) {\n const found = compositeOfRow(props.editor.state.doc, row)\n if (found) props.editor.commands.setCompositeTitleHidden(!titleHiddenOf(row), found.pos)\n}\n\nconst chip = 'inline-flex h-5 shrink-0 items-center gap-1 rounded-sm px-1.5 text-xs leading-none whitespace-nowrap text-[var(--sk-muted)]'\nconst chipButton = `${chip} transition-colors duration-150 hover:bg-[var(--sk-bg-elevated)] hover:text-[var(--sk-fg-highlighted)] focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[var(--sk-primary)]`\n\n/** Scale and fade in from the icon (`transform-origin` is Reka's), a bit longer than Nuxt UI's default; `composites.css` defines the keyframes and the reduced-motion override. */\nconst detailsPopoverUi = {\n content: 'composite-popover data-[state=open]:animate-[composite-pop-in_160ms_var(--ease-out)] data-[state=closed]:animate-[composite-pop-out_120ms_var(--ease-out)]',\n}\n</script>\n\n<template>\n <Teleport v-if=\"host\" :to=\"host\">\n <div class=\"absolute left-0 top-0 h-0 w-0\">\n <template v-for=\"item in placed\" :key=\"item.row.key\">\n <UPopover\n v-if=\"item.anchor.toggleSize\"\n :content=\"{ side: 'bottom', align: 'start', sideOffset: 4 }\"\n :ui=\"detailsPopoverUi\"\n >\n <!-- A span, not a `button`: Firefox does not start drags from buttons. -->\n <span\n role=\"button\"\n tabindex=\"0\"\n :draggable=\"editable\"\n :class=\"[\n 'absolute z-10 flex items-center justify-center rounded-sm bg-[var(--sk-bg)] text-[var(--sk-muted)] transition-[color,background-color,opacity] duration-120 motion-reduce:transition-none hover:bg-[var(--sk-bg-elevated)] hover:text-[var(--sk-fg-highlighted)] focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[var(--sk-primary)]',\n editable ? 'cursor-grab active:cursor-grabbing' : 'cursor-pointer',\n iconOnHover && !hoveredKeys.has(item.row.key) && chipsHoveredKey !== item.row.key && 'opacity-0 hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100',\n ]\"\n :style=\"{ top: `${item.anchor.toggleTop}px`, left: `${item.anchor.toggleLeft}px`, width: `${item.anchor.toggleSize}px`, height: `${item.anchor.toggleSize}px` }\"\n :aria-label=\"t('composites.chrome.details', { kind: item.row.kindLabel })\"\n :title=\"editable ? t('composites.chrome.detailsDrag', { kind: item.row.kindLabel }) : t('composites.chrome.details', { kind: item.row.kindLabel })\"\n @keydown.enter.space.prevent=\"($event.currentTarget as HTMLElement).click()\"\n @dragstart=\"onIconDragStart($event, item.row)\"\n >\n <UIcon :key=\"item.row.icon\" :name=\"item.row.icon\" class=\"size-3.5\" />\n </span>\n <template #content>\n <CompositeDetails :editor=\"editor\" :row=\"item.row\" :editable=\"editable\" />\n </template>\n </UPopover>\n\n <div\n v-if=\"editable || item.basket || item.status || item.derived || (item.row.tagsVisible && item.row.tags.length)\"\n class=\"absolute z-10 flex items-center gap-px overflow-hidden rounded-md bg-[var(--sk-bg)]\"\n :style=\"{ top: `${item.top}px`, left: `${item.left}px`, maxWidth: `${item.width}px`, height: `${ROW_HEIGHT}px` }\"\n @mouseenter=\"chipsHoveredKey = item.row.key\"\n @mouseleave=\"chipsHoveredKey = null\"\n >\n <template v-if=\"editable\">\n <CompositeBasketMenu :editor=\"editor\" :row=\"item.row\">\n <button type=\"button\" :class=\"chipButton\" :aria-label=\"t('composites.basket.label')\" :title=\"item.basket ? `${t('composites.basket.label')}: ${item.basket.label}` : t('composites.basket.label')\">\n <span v-if=\"item.basket\" class=\"size-2.5 rounded-full\" :style=\"{ backgroundColor: item.basket.color }\" />\n <UIcon v-else name=\"i-lucide-circle-dashed\" class=\"size-3.5\" />\n </button>\n </CompositeBasketMenu>\n <button\n type=\"button\"\n :class=\"chipButton\"\n :aria-label=\"t(item.titleHidden ? 'composites.titleHidden.show' : 'composites.titleHidden.hide')\"\n :title=\"t(item.titleHidden ? 'composites.titleHidden.show' : 'composites.titleHidden.hide')\"\n @click=\"toggleTitleHidden(item.row)\"\n >\n <UIcon :name=\"item.titleHidden ? 'i-lucide-eye' : 'i-lucide-eye-off'\" class=\"size-3.5\" />\n </button>\n </template>\n <span v-else-if=\"item.basket\" :class=\"chip\" :title=\"item.basket.label\">\n <span class=\"size-2.5 rounded-full\" :style=\"{ backgroundColor: item.basket.color }\" />\n </span>\n\n <template v-if=\"item.derived\">\n <button\n v-if=\"item.derived.toggleable\"\n type=\"button\"\n :class=\"chipButton\"\n :aria-expanded=\"item.derived.open\"\n :aria-label=\"t(item.derived.open ? 'composites.derivation.collapse' : 'composites.derivation.expand')\"\n :title=\"t(item.derived.open ? 'composites.derivation.collapse' : 'composites.derivation.expand')\"\n @click=\"toggleExpanded(item.row)\"\n >\n <UIcon :name=\"item.derived.open ? 'i-lucide-chevron-down' : 'i-lucide-chevron-right'\" class=\"size-3.5\" />\n </button>\n <span :class=\"chip\">\n <UIcon name=\"i-lucide-git-branch\" class=\"size-3.5\" />{{ t('composites.derivation.badge') }}\n </span>\n <span v-if=\"item.derived.stale\" :class=\"[chip, 'text-[var(--sk-warning)]']\">\n <UIcon name=\"i-lucide-triangle-alert\" class=\"size-3.5\" />{{ t('composites.derivation.stale') }}\n </span>\n </template>\n\n <template v-if=\"item.status\">\n <CompositeStatusMenu v-if=\"editable\" :editor=\"editor\" :row=\"item.row\">\n <button type=\"button\" :class=\"chipButton\" :aria-label=\"t('composites.status.label', { status: item.status.label })\">\n <UIcon :name=\"item.status.icon\" :class=\"['size-3.5', item.status.color]\" />{{ item.status.label }}\n </button>\n </CompositeStatusMenu>\n <span v-else :class=\"chip\">\n <UIcon :name=\"item.status.icon\" :class=\"['size-3.5', item.status.color]\" />{{ item.status.label }}\n </span>\n </template>\n\n <span v-for=\"tag in item.row.tagsVisible ? item.row.tags : []\" :key=\"tag\" :class=\"[chip, 'group max-w-40 gap-0']\">\n <span class=\"truncate\">#{{ tag }}</span>\n <button\n v-if=\"editable\"\n type=\"button\"\n class=\"flex h-4 w-0 shrink-0 items-center justify-center overflow-hidden rounded-sm opacity-0 transition-all duration-150 group-hover:ml-1 group-hover:w-4 group-hover:opacity-100 hover:bg-[var(--sk-bg-elevated)] hover:text-[var(--sk-fg-highlighted)] focus-visible:ml-1 focus-visible:w-4 focus-visible:opacity-100 focus-visible:outline-2 focus-visible:outline-[var(--sk-primary)]\"\n :aria-label=\"t('composites.tag.remove', { tag })\"\n @click=\"removeTag(item.row, tag)\"\n >\n <UIcon name=\"i-lucide-x\" class=\"size-3\" />\n </button>\n </span>\n\n <UPopover\n v-if=\"editable && item.row.tagsVisible\"\n :content=\"{ side: 'bottom', align: 'start', sideOffset: 6, onCloseAutoFocus: (event: Event) => event.preventDefault() }\"\n >\n <button type=\"button\" :class=\"chipButton\" :aria-label=\"t('composites.tag.add')\" :title=\"t('composites.tag.add')\">\n <UIcon name=\"i-lucide-plus\" class=\"size-3.5\" />\n </button>\n <template #content>\n <div class=\"w-64 p-3\">\n <CompositeTagsEditor :editor=\"editor\" :row=\"item.row\" />\n </div>\n </template>\n </UPopover>\n </div>\n </template>\n </div>\n </Teleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA,MAAM,aAAa;AAgDnB,MAAM,OAAO;;;;;EAlHb,MAAM,QAAQ;EAEd,MAAM,EAAE,MAAM,OAAO,SAAS,aAAa,SAAS;EACpD,M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BAWOC,UAAA,MAAAC,WAXa,KAAK,IAAI,cAAc,KAAK,IAAI,OAAI,CAAA,IAA3C,QAAG;MAAhB,OAAAN,UAAA,GAAAI,mBAWO,QAAA;OAXyD,KAAK;OAAM,OAAKM,eAAA,CAAG,MAAI,sBAAA,CAAA;MACrF,GAAA,CAAAP,mBAAwC,QAAxC,YAAuB,MAACc,gBAAG,GAAG,GAAA,CAAA,GAEtB,SAAA,SADRjB,UAAA,GAAAI,mBAQS,UAAA;;OANP,MAAK;OACL,OAAM;OACL,cAAYL,MAAA,CAAA,CAAC,CAAA,yBAAA,EAA4B,IAAG,CAAA;OAC5C,UAAK,WAAE,UAAU,KAAK,KAAK,GAAG;MAE/B,GAAA,CAAAS,YAA0CT,MAAA,KAAA,GAAA;OAAnC,MAAK;OAAa,OAAM;;;KAK3B,SAAA,SAAY,KAAK,IAAI,eAD7BC,UAAA,GAAAC,YAYWF,MAAA,QAAA,GAAA;;MAVR,SAAO;OAAA,MAAA;OAAA,OAAA;OAAA,YAAA;OAAA,mBAAsE,UAAiB,MAAM,eAAc;MAAA;;MAKxG,SAAOQ,cAGV,CAFNJ,mBAEM,OAFN,aAEM,CADJK,YAAwDW,aAAA;OAAlC,QAAQ,QAAA;OAAS,KAAK,KAAK;;MALrD,SAAAZ,cAES,CAFTJ,mBAES,UAAA;OAFD,MAAK;OAAU,OAAKO,eAAE,UAAU;OAAG,cAAYX,MAAA,CAAA,CAAC,CAAA,oBAAA;OAAyB,OAAOA,MAAA,CAAA,CAAC,CAAA,oBAAA;MACvF,GAAA,CAAAS,YAA+CT,MAAA,KAAA,GAAA;OAAxC,MAAK;OAAgB,OAAM"}
|
|
1
|
+
{"version":3,"file":"CompositeChrome.js","names":["_unref","_openBlock","_createBlock","_Teleport","_createElementVNode","_createElementBlock","_Fragment","_renderList","_withCtx","_createVNode","CompositeDetails","_normalizeClass","_normalizeStyle","_withKeys","_withModifiers","_createCommentVNode","CompositeBasketMenu","_createTextVNode","_toDisplayString","CompositeStatusMenu","CompositeTagsEditor"],"sources":["../../../../src/features/composites/components/CompositeChrome.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { Editor } from '@tiptap/vue-3'\nimport { computed, shallowRef, watch } from 'vue'\nimport { startBlockDrag } from '../../../core'\nimport { useUiKit } from '../../../vue/kit/use-ui-kit'\nimport { useEditorI18n } from '../../../vue/use-editor-i18n'\nimport { useStoreRef } from '../../../vue/store-ref'\nimport { useEditorSettings } from '../../../vue/settings'\nimport { compositeSectionOf } from '../anchors'\nimport { derivedChromeOf } from '../derived-chrome'\nimport { rowStatus } from '../meta-display'\nimport { basketById, basketOf, titleHiddenOf } from '../baskets'\nimport { compositeBasketsOf } from '../nodes'\nimport { compositeOfRow, type CompositeRow, setCompositeTags } from '../rows'\nimport { useCompositeAnchors } from '../use-composite-anchors'\nimport { useCompositeRows } from '../use-composite-rows'\nimport CompositeBasketMenu from './CompositeBasketMenu.vue'\nimport CompositeDetails from './CompositeDetails.vue'\nimport CompositeStatusMenu from './CompositeStatusMenu.vue'\nimport CompositeTagsEditor from './CompositeTagsEditor.vue'\n\n/**\n * Chrome of every composite, laid over the editor (mounted by the composites feature): on the title line the status\n * chip and one chip per tag (with a `+` chip to add tags), and on the front the kind icon. The icon is a button that\n * opens the details popover (kind with a confirmation before it changes, the kind's fields and the summary;\n * `CompositeDetails`) and, in an editable editor, the composite's drag handle: dragging it moves the composite\n * (`startBlockDrag`). A kind with `chrome.tags: false` shows no tag chips and no `+` chip. With `blocks.kindIcon: 'hover'` it shows only while the composite is hovered, its popover is\n * open or the icon has keyboard focus. Chips and popover also render in read-only editors, without edit affordances.\n * The node view's own description and tags rows are hidden by CSS; this overlay shows and edits them.\n */\nconst props = defineProps<{ editor: Editor }>()\n\nconst { Icon: UIcon, Popover: UPopover } = useUiKit()\nconst { t } = useEditorI18n()\n\nconst { rows } = useCompositeRows(() => props.editor)\nconst { host, anchors, frame } = useCompositeAnchors(() => props.editor, rows)\n\n// `isEditable` is not reactive: follow it on every transaction (`EditorSurface` dispatches one after `setEditable`).\nconst editable = shallowRef(false)\nwatch(() => props.editor, (instance, _previous, onCleanup) => {\n editable.value = !instance.isDestroyed && instance.isEditable\n const sync = () => {\n editable.value = !instance.isDestroyed && instance.isEditable\n }\n instance.on('transaction', sync)\n onCleanup(() => instance.off('transaction', sync))\n}, { immediate: true })\n\nconst { settings } = useEditorSettings()\nconst iconOnHover = computed(() => settings.value.blocks.kindIcon === 'hover')\n\n// Hover state of `kindIcon: 'hover'`: the keys of the rows whose composite is under the pointer (that one and every\n// composite around it), plus the row whose chips the pointer is on (they sit outside the editor's DOM).\nconst hoveredKeys = shallowRef<ReadonlySet<string>>(new Set())\nconst chipsHoveredKey = shallowRef<string | null>(null)\nlet hoveredSection: Element | null = null\n\nfunction onEditorMouseover(event: MouseEvent) {\n const section = event.target instanceof Element ? event.target.closest('.composite') : null\n if (section === hoveredSection) return\n hoveredSection = section\n const chain = new Set<Element>()\n for (let el = section; el; el = el.parentElement?.closest('.composite') ?? null) chain.add(el)\n const { view, state } = props.editor\n hoveredKeys.value = new Set(rows.value.filter((row) => {\n const found = compositeOfRow(state.doc, row)\n const dom = found ? view.nodeDOM(found.pos) : null\n const section = dom instanceof Element ? compositeSectionOf(dom) : null\n return section !== null && chain.has(section)\n }).map(row => row.key))\n}\n\nfunction onEditorMouseleave() {\n hoveredSection = null\n hoveredKeys.value = new Set()\n}\n\nwatch([() => props.editor, iconOnHover], ([instance, hover], _previous, onCleanup) => {\n onEditorMouseleave()\n if (!hover || instance.isDestroyed) return\n const { dom } = instance.view\n dom.addEventListener('mouseover', onEditorMouseover)\n dom.addEventListener('mouseleave', onEditorMouseleave)\n onCleanup(() => {\n dom.removeEventListener('mouseover', onEditorMouseover)\n dom.removeEventListener('mouseleave', onEditorMouseleave)\n })\n}, { immediate: true })\n\nfunction onIconDragStart(event: DragEvent, row: CompositeRow) {\n const found = compositeOfRow(props.editor.state.doc, row)\n if (!found || !startBlockDrag(props.editor, event, found.pos)) event.preventDefault()\n}\n\n/** Chips start right after the title's last character and run on to the editor's right edge. */\nconst ROW_HEIGHT = 24\n\nconst expanded = useStoreRef(() => props.editor.storage.composite.expanded)\nconst revealedTitles = useStoreRef(() => props.editor.storage.composite.revealedTitles)\n\nconst placed = computed(() => {\n const baskets = compositeBasketsOf(props.editor)\n // End of the collapsed derived Baustein the rows being walked sit in: its clipped content shows no chrome.\n let hiddenUntil = -1\n return rows.value.flatMap((row) => {\n if (row.pos < hiddenUntil) return []\n const derived = derivedChromeOf(props.editor, row)\n const open = !derived || !row.id || expanded.value.has(row.id)\n if (!open) hiddenUntil = row.end\n const anchor = anchors.value.get(row.key)\n if (!anchor) return []\n const titleHidden = titleHiddenOf(row)\n // A hidden title leaves nothing to measure: the chips sit in the strip beside the kind icon (`composites.css`).\n const inStrip = titleHidden && !(row.id && revealedTitles.value.has(row.id)) && anchor.toggleSize > 0\n // An empty title shows a placeholder the anchor cannot measure: keep clear of it.\n const left = inStrip ? anchor.toggleLeft + anchor.toggleSize + 6 : anchor.lineEnd + (anchor.titleEmpty ? 116 : 12)\n return [{\n row,\n anchor,\n // A kind without `chrome.controls` renders as in a read-only editor.\n editable: editable.value && row.controls,\n left,\n top: (inStrip ? anchor.toggleTop + anchor.toggleSize / 2 : anchor.lastCenter) - ROW_HEIGHT / 2,\n width: Math.max((frame.value?.right ?? anchor.right) - left, 120),\n status: rowStatus(row, t),\n derived: derived && { stale: derived.stale, open, toggleable: !!row.id },\n basket: basketById(baskets, basketOf(row)) ?? null,\n titleHidden,\n }]\n })\n})\n\nfunction toggleExpanded(row: CompositeRow) {\n if (row.id) props.editor.commands.toggleCompositeExpanded(row.id)\n}\n\nfunction removeTag(row: CompositeRow, tag: string) {\n setCompositeTags(props.editor, row, row.tags.filter(candidate => candidate !== tag))\n}\n\nfunction toggleTitleHidden(row: CompositeRow) {\n const found = compositeOfRow(props.editor.state.doc, row)\n if (found) props.editor.commands.setCompositeTitleHidden(!titleHiddenOf(row), found.pos)\n}\n\nconst chip = 'inline-flex h-5 shrink-0 items-center gap-1 rounded-sm px-1.5 text-xs leading-none whitespace-nowrap text-[var(--sk-muted)]'\nconst chipButton = `${chip} transition-colors duration-150 hover:bg-[var(--sk-bg-elevated)] hover:text-[var(--sk-fg-highlighted)] focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[var(--sk-primary)]`\n\n/** Scale and fade in from the icon (`transform-origin` is Reka's), a bit longer than Nuxt UI's default; `composites.css` defines the keyframes and the reduced-motion override. */\nconst detailsPopoverUi = {\n content: 'composite-popover data-[state=open]:animate-[composite-pop-in_160ms_var(--ease-out)] data-[state=closed]:animate-[composite-pop-out_120ms_var(--ease-out)]',\n}\n</script>\n\n<template>\n <Teleport v-if=\"host\" :to=\"host\">\n <div class=\"absolute left-0 top-0 h-0 w-0\">\n <template v-for=\"item in placed\" :key=\"item.row.key\">\n <UPopover\n v-if=\"item.anchor.toggleSize\"\n :content=\"{ side: 'bottom', align: 'start', sideOffset: 4 }\"\n :ui=\"detailsPopoverUi\"\n >\n <!-- A span, not a `button`: Firefox does not start drags from buttons. -->\n <span\n role=\"button\"\n tabindex=\"0\"\n :draggable=\"item.editable\"\n :class=\"[\n 'absolute z-10 flex items-center justify-center rounded-sm bg-[var(--sk-bg)] text-[var(--sk-muted)] transition-[color,background-color,opacity] duration-120 motion-reduce:transition-none hover:bg-[var(--sk-bg-elevated)] hover:text-[var(--sk-fg-highlighted)] focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-[var(--sk-primary)]',\n item.editable ? 'cursor-grab active:cursor-grabbing' : 'cursor-pointer',\n iconOnHover && !hoveredKeys.has(item.row.key) && chipsHoveredKey !== item.row.key && 'opacity-0 hover:opacity-100 focus-visible:opacity-100 data-[state=open]:opacity-100',\n ]\"\n :style=\"{ top: `${item.anchor.toggleTop}px`, left: `${item.anchor.toggleLeft}px`, width: `${item.anchor.toggleSize}px`, height: `${item.anchor.toggleSize}px` }\"\n :aria-label=\"t('composites.chrome.details', { kind: item.row.kindLabel })\"\n :title=\"item.editable ? t('composites.chrome.detailsDrag', { kind: item.row.kindLabel }) : t('composites.chrome.details', { kind: item.row.kindLabel })\"\n @keydown.enter.space.prevent=\"($event.currentTarget as HTMLElement).click()\"\n @dragstart=\"onIconDragStart($event, item.row)\"\n >\n <UIcon :key=\"item.row.icon\" :name=\"item.row.icon\" class=\"size-3.5\" />\n </span>\n <template #content>\n <CompositeDetails :editor=\"editor\" :row=\"item.row\" :editable=\"item.editable\" />\n </template>\n </UPopover>\n\n <div\n v-if=\"item.editable || item.basket || item.status || item.derived || (item.row.tagsVisible && item.row.tags.length)\"\n class=\"absolute z-10 flex items-center gap-px overflow-hidden rounded-md bg-[var(--sk-bg)]\"\n :style=\"{ top: `${item.top}px`, left: `${item.left}px`, maxWidth: `${item.width}px`, height: `${ROW_HEIGHT}px` }\"\n @mouseenter=\"chipsHoveredKey = item.row.key\"\n @mouseleave=\"chipsHoveredKey = null\"\n >\n <template v-if=\"item.editable\">\n <CompositeBasketMenu :editor=\"editor\" :row=\"item.row\">\n <button type=\"button\" :class=\"chipButton\" :aria-label=\"t('composites.basket.label')\" :title=\"item.basket ? `${t('composites.basket.label')}: ${item.basket.label}` : t('composites.basket.label')\">\n <span v-if=\"item.basket\" class=\"size-2.5 rounded-full\" :style=\"{ backgroundColor: item.basket.color }\" />\n <UIcon v-else name=\"i-lucide-circle-dashed\" class=\"size-3.5\" />\n </button>\n </CompositeBasketMenu>\n <button\n type=\"button\"\n :class=\"chipButton\"\n :aria-label=\"t(item.titleHidden ? 'composites.titleHidden.show' : 'composites.titleHidden.hide')\"\n :title=\"t(item.titleHidden ? 'composites.titleHidden.show' : 'composites.titleHidden.hide')\"\n @click=\"toggleTitleHidden(item.row)\"\n >\n <UIcon :name=\"item.titleHidden ? 'i-lucide-eye' : 'i-lucide-eye-off'\" class=\"size-3.5\" />\n </button>\n </template>\n <span v-else-if=\"item.basket\" :class=\"chip\" :title=\"item.basket.label\">\n <span class=\"size-2.5 rounded-full\" :style=\"{ backgroundColor: item.basket.color }\" />\n </span>\n\n <template v-if=\"item.derived\">\n <button\n v-if=\"item.derived.toggleable\"\n type=\"button\"\n :class=\"chipButton\"\n :aria-expanded=\"item.derived.open\"\n :aria-label=\"t(item.derived.open ? 'composites.derivation.collapse' : 'composites.derivation.expand')\"\n :title=\"t(item.derived.open ? 'composites.derivation.collapse' : 'composites.derivation.expand')\"\n @click=\"toggleExpanded(item.row)\"\n >\n <UIcon :name=\"item.derived.open ? 'i-lucide-chevron-down' : 'i-lucide-chevron-right'\" class=\"size-3.5\" />\n </button>\n <span :class=\"chip\">\n <UIcon name=\"i-lucide-git-branch\" class=\"size-3.5\" />{{ t('composites.derivation.badge') }}\n </span>\n <span v-if=\"item.derived.stale\" :class=\"[chip, 'text-[var(--sk-warning)]']\">\n <UIcon name=\"i-lucide-triangle-alert\" class=\"size-3.5\" />{{ t('composites.derivation.stale') }}\n </span>\n </template>\n\n <template v-if=\"item.status\">\n <CompositeStatusMenu v-if=\"item.editable\" :editor=\"editor\" :row=\"item.row\">\n <button type=\"button\" :class=\"chipButton\" :aria-label=\"t('composites.status.label', { status: item.status.label })\">\n <UIcon :name=\"item.status.icon\" :class=\"['size-3.5', item.status.color]\" />{{ item.status.label }}\n </button>\n </CompositeStatusMenu>\n <span v-else :class=\"chip\">\n <UIcon :name=\"item.status.icon\" :class=\"['size-3.5', item.status.color]\" />{{ item.status.label }}\n </span>\n </template>\n\n <span v-for=\"tag in item.row.tagsVisible ? item.row.tags : []\" :key=\"tag\" :class=\"[chip, 'group max-w-40 gap-0']\">\n <span class=\"truncate\">#{{ tag }}</span>\n <button\n v-if=\"item.editable\"\n type=\"button\"\n class=\"flex h-4 w-0 shrink-0 items-center justify-center overflow-hidden rounded-sm opacity-0 transition-all duration-150 group-hover:ml-1 group-hover:w-4 group-hover:opacity-100 hover:bg-[var(--sk-bg-elevated)] hover:text-[var(--sk-fg-highlighted)] focus-visible:ml-1 focus-visible:w-4 focus-visible:opacity-100 focus-visible:outline-2 focus-visible:outline-[var(--sk-primary)]\"\n :aria-label=\"t('composites.tag.remove', { tag })\"\n @click=\"removeTag(item.row, tag)\"\n >\n <UIcon name=\"i-lucide-x\" class=\"size-3\" />\n </button>\n </span>\n\n <UPopover\n v-if=\"item.editable && item.row.tagsVisible\"\n :content=\"{ side: 'bottom', align: 'start', sideOffset: 6, onCloseAutoFocus: (event: Event) => event.preventDefault() }\"\n >\n <button type=\"button\" :class=\"chipButton\" :aria-label=\"t('composites.tag.add')\" :title=\"t('composites.tag.add')\">\n <UIcon name=\"i-lucide-plus\" class=\"size-3.5\" />\n </button>\n <template #content>\n <div class=\"w-64 p-3\">\n <CompositeTagsEditor :editor=\"editor\" :row=\"item.row\" />\n </div>\n </template>\n </UPopover>\n </div>\n </template>\n </div>\n </Teleport>\n</template>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgGA,MAAM,aAAa;AAkDnB,MAAM,OAAO;;;;;EApHb,MAAM,QAAQ;EAEd,MAAM,EAAE,MAAM,OAAO,SAAS,aAAa,SAAS;EACpD,MAAM,EAAE,MAAM,cAAc;EAE5B,MAAM,EAAE,SAAS,uBAAuB,MAAM,MAAM;EACpD,MAAM,EAAE,MAAM,SAAS,UAAU,0BAA0B,MAAM,QAAQ,IAAI;EAG7E,MAAM,WAAW,WAAW,KAAK;EACjC,YAAY,MAAM,SAAS,UAAU,WAAW,cAAc;GAC5D,SAAS,QAAQ,CAAC,SAAS,eAAe,SAAS;GACnD,MAAM,aAAa;IACjB,SAAS,QAAQ,CAAC,SAAS,eAAe,SAAS;GACrD;GACA,SAAS,GAAG,eAAe,IAAI;GAC/B,gBAAgB,SAAS,IAAI,eAAe,IAAI,CAAC;EACnD,GAAG,EAAE,WAAW,KAAK,CAAC;EAEtB,MAAM,EAAE,aAAa,kBAAkB;EACvC,MAAM,cAAc,eAAe,SAAS,MAAM,OAAO,aAAa,OAAO;EAI7E,MA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a,OAAM;;;KAK3B,KAAK,YAAY,KAAK,IAAI,eADlCC,UAAA,GAAAC,YAYWF,MAAA,QAAA,GAAA;;MAVR,SAAO;OAAA,MAAA;OAAA,OAAA;OAAA,YAAA;OAAA,mBAAsE,UAAiB,MAAM,eAAc;MAAA;;MAKxG,SAAOQ,cAGV,CAFNJ,mBAEM,OAFN,aAEM,CADJK,YAAwDW,aAAA;OAAlC,QAAQ,QAAA;OAAS,KAAK,KAAK;;MALrD,SAAAZ,cAES,CAFTJ,mBAES,UAAA;OAFD,MAAK;OAAU,OAAKO,eAAE,UAAU;OAAG,cAAYX,MAAA,CAAA,CAAC,CAAA,oBAAA;OAAyB,OAAOA,MAAA,CAAA,CAAC,CAAA,oBAAA;MACvF,GAAA,CAAAS,YAA+CT,MAAA,KAAA,GAAA;OAAxC,MAAK;OAAgB,OAAM"}
|
|
@@ -45,10 +45,14 @@ export interface CompositeKind {
|
|
|
45
45
|
* How much of the chrome the kind shows. Absent: all of it. `tags: false` hides the tag row of this kind (the node stays in the schema, empty).
|
|
46
46
|
* `tone`: a CSS colour or `var(...)` that sets the kind apart: a Baustein of this kind gets `data-kind-tone` and `--sk-kind-tone` on its wrapper
|
|
47
47
|
* (a tinted surface and a left border in the tone) and its tree rows tint the kind icon with it. Absent: the kind looks as before.
|
|
48
|
+
* `controls: false` makes the chrome of a Baustein of this kind read-only although the editor is editable (for a kind whose attributes a host
|
|
49
|
+
* guard refuses to change): no basket menu, status menu, title-visibility toggle, tag editing or drag handle on the kind icon, and a read-only
|
|
50
|
+
* details popover; an existing basket, status and tags still show as chips. Default `true`.
|
|
48
51
|
*/
|
|
49
52
|
chrome?: {
|
|
50
53
|
tags?: boolean;
|
|
51
54
|
tone?: string;
|
|
55
|
+
controls?: boolean;
|
|
52
56
|
};
|
|
53
57
|
/** Absent: the kind has no AI brief; „Baustein füllen (KI)“ is not offered for it. */
|
|
54
58
|
ai?: CompositeKindAi;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kinds.js","names":[],"sources":["../../../src/features/composites/kinds.ts"],"sourcesContent":["// Vue-free and server-importable: the kind registry of the composite block family („Bausteine“).\nimport { createTranslator, type Translate } from '../../i18n'\n\n/** Media block types a source-holding kind's source may be (`CompositeKind.source`). */\nexport const SOURCE_MEDIA_TYPES = ['image', 'audio', 'video', 'file'] as const\n\n/** One metadata field of a composite kind, stored under `key` in the composite's `meta` attribute. */\nexport interface CompositeMetaField {\n key: string\n label: string\n /**\n * `bibliography`: CSL-JSON item under `meta.bib`; `derivation`: read-only provenance of a derived Baustein; `reference`: block id of another Baustein;\n * `multiselect`: several of `options`, stored as `string[]` (the key is removed when none is chosen).\n */\n type: 'text' | 'textarea' | 'date' | 'number' | 'select' | 'multiselect' | 'reference' | 'bibliography' | 'derivation'\n /** Choices of a `select` or `multiselect` field (required for `multiselect`). */\n options?: { value: string, label: string }[]\n /** `reference`: kind ids the field may point to; absent = any Baustein. */\n targets?: readonly string[]\n}\n\n/**\n * What a kind tells the model beyond its fields. `purpose` goes into every AI request's block model (chat, generate\n * tasks); `instructions`, `instructionsField` and `skeleton` are read only by „Baustein füllen (KI)“ (`fillComposite`).\n */\nexport interface CompositeKindAi {\n /** One or two German sentences: what a Baustein of this kind is for and what its body holds. */\n purpose: string\n /** Default instruction for filling the body of a Baustein of this kind (what to write, structure, tone). */\n instructions?: string\n /** Key of a `textarea` field of this kind; a Baustein whose value is non-empty replaces `instructions` with it. */\n instructionsField?: string\n /** Target text (Vorlage) as Markdown; `{key}` placeholders are replaced by the Baustein's `meta[key]` before it goes to the model, unknown ones stay. */\n skeleton?: string\n}\n\n/** A composite kind: what its `kind` attribute selects (label, icon, chrome placeholders, meta fields). */\nexport interface CompositeKind {\n id: string\n label: string\n icon: string\n titlePlaceholder: string\n descriptionPlaceholder: string\n fields: CompositeMetaField[]\n /**\n * How much of the chrome the kind shows. Absent: all of it. `tags: false` hides the tag row of this kind (the node stays in the schema, empty).\n * `tone`: a CSS colour or `var(...)` that sets the kind apart: a Baustein of this kind gets `data-kind-tone` and `--sk-kind-tone` on its wrapper\n * (a tinted surface and a left border in the tone) and its tree rows tint the kind icon with it. Absent: the kind looks as before.\n */\n chrome?: { tags?: boolean, tone?: string }\n /** Absent: the kind has no AI brief; „Baustein füllen (KI)“ is not offered for it. */\n ai?: CompositeKindAi\n /**\n * Baustein kinds this kind accepts as nested Bausteine: a list of kind ids, or `'all'`. Absent: `folder` and `document`\n * accept `'all'`, every other kind accepts none. Non-Baustein content (paragraphs, lists, ...) is always allowed.\n * Only new moves are checked; documents that already nest against it stay as they are.\n */\n accepts?: readonly string[] | 'all'\n /** Present on source-holding kinds: the media block types the kind's source may be; `sourceOf` returns the first body child of one of these. */\n source?: readonly (typeof SOURCE_MEDIA_TYPES)[number][]\n}\n\n/**\n * The built-in kinds in the language of `t`. The default set is produced from the translator (labels, placeholders, field\n * labels and status choices are catalog messages), so it is built per translator and memoized; hosts that pass their own\n * kinds (`compositeFeature({ kinds })`, `Composite.configure({ kinds })`) keep their labels untouched. Ids, field keys and\n * stored values (`open`, `doing`, `done`) do not depend on the language.\n */\nexport function defaultCompositeKinds(t: Translate): readonly CompositeKind[] {\n let kinds = DEFAULT_KINDS.get(t)\n if (!kinds) DEFAULT_KINDS.set(t, kinds = buildDefaultKinds(t))\n return kinds\n}\n\nconst DEFAULT_KINDS = new WeakMap<Translate, readonly CompositeKind[]>()\n\nfunction buildDefaultKinds(t: Translate): readonly CompositeKind[] {\n return [\n { id: 'section', label: t('composites.kind.section.label'), icon: 'i-lucide-layers', titlePlaceholder: t('composites.kind.section.title'), descriptionPlaceholder: t('composites.kind.section.description'), fields: [], accepts: 'all' },\n { id: 'task', label: t('composites.kind.task.label'), icon: 'i-lucide-square-check', titlePlaceholder: t('composites.kind.task.title'), descriptionPlaceholder: t('composites.kind.task.description'), fields: [\n { key: 'status', label: t('composites.kind.task.field.status'), type: 'select', options: [\n { value: 'open', label: t('composites.kind.task.status.open') },\n { value: 'doing', label: t('composites.kind.task.status.doing') },\n { value: 'done', label: t('composites.kind.task.status.done') },\n ] },\n { key: 'due', label: t('composites.kind.task.field.due'), type: 'date' },\n { key: 'assignee', label: t('composites.kind.task.field.assignee'), type: 'text' },\n ] },\n // i18n-ignore: model-facing kind purpose (German prompt text, not UI)\n { id: 'note', label: t('composites.kind.note.label'), icon: 'i-lucide-sticky-note', titlePlaceholder: t('composites.kind.note.title'), descriptionPlaceholder: t('composites.kind.note.description'), fields: [], ai: { purpose: 'Eigene Notiz zu einer Quelle oder einem Thema: Zusammenfassung, Gedanken, offene Fragen.' } },\n { id: 'document', label: t('composites.kind.document.label'), icon: 'i-lucide-file-text', titlePlaceholder: t('composites.kind.document.title'), descriptionPlaceholder: t('composites.kind.document.description'), source: [...SOURCE_MEDIA_TYPES], fields: [\n { key: 'filename', label: t('composites.kind.document.field.filename'), type: 'text' },\n { key: 'mimeType', label: t('composites.kind.document.field.mimeType'), type: 'text' },\n { key: 'size', label: t('composites.kind.document.field.size'), type: 'number' },\n { key: 'importedAt', label: t('composites.kind.document.field.importedAt'), type: 'date' },\n ] },\n // i18n-ignore-start: model-facing kind purposes and instructions (German prompt text, not UI)\n { id: 'recording', label: t('composites.kind.recording.label'), icon: 'i-lucide-mic', titlePlaceholder: t('composites.kind.recording.title'), descriptionPlaceholder: t('composites.kind.recording.description'), accepts: 'all', source: ['audio', 'video'], fields: [\n ...importFields(t, 'recording'),\n { key: 'recordedAt', label: t('composites.kind.recording.field.recordedAt'), type: 'date' },\n { key: 'participants', label: t('composites.kind.recording.field.participants'), type: 'text' },\n { key: 'durationSeconds', label: t('composites.kind.recording.field.durationSeconds'), type: 'number' },\n ], ai: { purpose: 'Aufnahme (Audio oder Video) als Quelle; der Inhalt hält Lesefassungen wie das Transkript und eigene Notizen.' } },\n { id: 'paper', label: t('composites.kind.paper.label'), icon: 'i-lucide-scroll-text', titlePlaceholder: t('composites.kind.paper.title'), descriptionPlaceholder: t('composites.kind.paper.description'), accepts: 'all', source: ['file'], fields: [\n ...importFields(t, 'paper'),\n { key: 'bib', label: t('composites.kind.paper.field.bib'), type: 'bibliography' },\n { key: 'doi', label: t('composites.kind.paper.field.doi'), type: 'text' },\n ], ai: { purpose: 'Wissenschaftliche Arbeit als Quelle (PDF) mit Literaturangabe; der Inhalt hält Volltext, Zusammenfassungen und Notizen.' } },\n { id: 'book', label: t('composites.kind.book.label'), icon: 'i-lucide-book', titlePlaceholder: t('composites.kind.book.title'), descriptionPlaceholder: t('composites.kind.book.description'), accepts: 'all', source: ['file'], fields: [\n ...importFields(t, 'book'),\n { key: 'bib', label: t('composites.kind.book.field.bib'), type: 'bibliography' },\n { key: 'isbn', label: t('composites.kind.book.field.isbn'), type: 'text' },\n ], ai: { purpose: 'Buch als Quelle (PDF) mit Literaturangabe; der Inhalt hält den Volltext, gegliedert in Kapitel, und Notizen.' } },\n { id: 'figure', label: t('composites.kind.figure.label'), icon: 'i-lucide-image', titlePlaceholder: t('composites.kind.figure.title'), descriptionPlaceholder: t('composites.kind.figure.description'), accepts: 'all', source: ['image'], fields: [\n ...importFields(t, 'figure'),\n { key: 'credit', label: t('composites.kind.figure.field.credit'), type: 'text' },\n ], ai: { purpose: 'Bild als Quelle; der Inhalt hält die Bildbeschreibung und eigene Notizen.' } },\n { id: 'rendition', label: t('composites.kind.rendition.label'), icon: 'i-lucide-captions', titlePlaceholder: t('composites.kind.rendition.title'), descriptionPlaceholder: t('composites.kind.rendition.description'), accepts: 'all', fields: [\n { key: 'derivation', label: t('composites.kind.rendition.field.derivation'), type: 'derivation' },\n { key: 'language', label: t('composites.kind.rendition.field.language'), type: 'text' },\n ], ai: {\n purpose: 'Lesbare Fassung einer Quelle (Transkript, Volltext, Beschreibung, Übersetzung)',\n instructions: 'Übertrage den Inhalt vollständig und gut lesbar; nichts weglassen, nichts hinzuerfinden.',\n } },\n // i18n-ignore-end\n { id: 'folder', label: t('composites.kind.folder.label'), icon: 'i-lucide-folder', titlePlaceholder: t('composites.kind.folder.title'), descriptionPlaceholder: t('composites.kind.folder.description'), fields: [] },\n ]\n}\n\n/** The four fields the import of a file fills in (`wrapImport` of `composite-media`), shared by every source-holding kind. */\nfunction importFields(t: Translate, kind: 'recording' | 'paper' | 'book' | 'figure'): CompositeMetaField[] {\n return [\n { key: 'filename', label: t(`composites.kind.${kind}.field.filename`), type: 'text' },\n { key: 'mimeType', label: t(`composites.kind.${kind}.field.mimeType`), type: 'text' },\n { key: 'size', label: t(`composites.kind.${kind}.field.size`), type: 'number' },\n { key: 'importedAt', label: t(`composites.kind.${kind}.field.importedAt`), type: 'date' },\n ]\n}\n\n/** The built-in kinds in the default language, for server-side and context-free code (`Composite`'s default option, an editor without a context). */\nexport const fallbackCompositeKinds = (): readonly CompositeKind[] => defaultCompositeKinds(DEFAULT_TRANSLATE)\n\nconst DEFAULT_TRANSLATE = createTranslator()\n\n/** Kind `id` from `kinds`; an unknown id gets the `section` kind's presentation (else the first kind's) under its own id and label. */\nexport function compositeKind(kinds: readonly CompositeKind[], id: string): CompositeKind {\n const known = kinds.find(kind => kind.id === id)\n if (known) return known\n const base = kinds.find(kind => kind.id === 'section') ?? kinds[0] ?? fallbackCompositeKinds()[0]!\n return { ...base, id, label: id }\n}\n\n/** Kinds that accept every Baustein kind when their definition sets no `accepts`. */\nconst ACCEPTS_ALL_BY_DEFAULT: Record<string, true> = { folder: true, document: true }\n\n/**\n * Whether a Baustein of kind `parentKind` accepts one of kind `childKind` as nested Baustein. The `accepts` of the kind\n * in `kinds` decides; without one (or for a kind `kinds` does not list) only `folder` and `document` accept all.\n */\nexport function kindAccepts(kinds: readonly CompositeKind[], parentKind: string, childKind: string): boolean {\n const accepts = kinds.find(kind => kind.id === parentKind)?.accepts\n if (accepts === undefined) return Object.hasOwn(ACCEPTS_ALL_BY_DEFAULT, parentKind)\n return accepts === 'all' || accepts.includes(childKind)\n}\n"],"mappings":";;;AAIA,MAAa,qBAAqB;CAAC;CAAS;CAAS;CAAS;AAAM;;;;;;;AAgEpE,SAAgB,sBAAsB,GAAwC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C9E;GAAE,KAAK;GAAc,OAAO,EAAE,mBAAmB,KAAK,kBAAkB;GAAG,MAAM;EAAO;CAC1F;AACF;;AAGA,MAAa,+BAAyD,sBAAsB,iBAAiB;AAE7G,MAAM,oBAAoB,iBAAiB;;AAG3C,SAAgB,cAAc,OAAiC,IAA2B;CACxF,MAAM,QAAQ,MAAM,MAAK,SAAQ,KAAK,OAAO,EAAE;CAC/C,IAAI,OAAO,OAAO;CAElB,OAAO;EAAE,GADI,MAAM,MAAK,SAAQ,KAAK,OAAO,SAAS,KAAK,MAAM,MAAM,uBAAuB,CAAC,CAAC;EAC7E;EAAI,OAAO;CAAG;AAClC;;AAGA,MAAM,yBAA+C;CAAE,QAAQ;CAAM,UAAU;AAAK;;;;;AAMpF,SAAgB,YAAY,OAAiC,YAAoB,WAA4B;CAC3G,MAAM,UAAU,MAAM,MAAK,SAAQ,KAAK,OAAO,UAAU,CAAC,EAAE;CAC5D,IAAI,YAAY,KAAA,GAAW,OAAO,OAAO,OAAO,wBAAwB,UAAU;CAClF,OAAO,YAAY,SAAS,QAAQ,SAAS,SAAS;AACxD"}
|
|
1
|
+
{"version":3,"file":"kinds.js","names":[],"sources":["../../../src/features/composites/kinds.ts"],"sourcesContent":["// Vue-free and server-importable: the kind registry of the composite block family („Bausteine“).\nimport { createTranslator, type Translate } from '../../i18n'\n\n/** Media block types a source-holding kind's source may be (`CompositeKind.source`). */\nexport const SOURCE_MEDIA_TYPES = ['image', 'audio', 'video', 'file'] as const\n\n/** One metadata field of a composite kind, stored under `key` in the composite's `meta` attribute. */\nexport interface CompositeMetaField {\n key: string\n label: string\n /**\n * `bibliography`: CSL-JSON item under `meta.bib`; `derivation`: read-only provenance of a derived Baustein; `reference`: block id of another Baustein;\n * `multiselect`: several of `options`, stored as `string[]` (the key is removed when none is chosen).\n */\n type: 'text' | 'textarea' | 'date' | 'number' | 'select' | 'multiselect' | 'reference' | 'bibliography' | 'derivation'\n /** Choices of a `select` or `multiselect` field (required for `multiselect`). */\n options?: { value: string, label: string }[]\n /** `reference`: kind ids the field may point to; absent = any Baustein. */\n targets?: readonly string[]\n}\n\n/**\n * What a kind tells the model beyond its fields. `purpose` goes into every AI request's block model (chat, generate\n * tasks); `instructions`, `instructionsField` and `skeleton` are read only by „Baustein füllen (KI)“ (`fillComposite`).\n */\nexport interface CompositeKindAi {\n /** One or two German sentences: what a Baustein of this kind is for and what its body holds. */\n purpose: string\n /** Default instruction for filling the body of a Baustein of this kind (what to write, structure, tone). */\n instructions?: string\n /** Key of a `textarea` field of this kind; a Baustein whose value is non-empty replaces `instructions` with it. */\n instructionsField?: string\n /** Target text (Vorlage) as Markdown; `{key}` placeholders are replaced by the Baustein's `meta[key]` before it goes to the model, unknown ones stay. */\n skeleton?: string\n}\n\n/** A composite kind: what its `kind` attribute selects (label, icon, chrome placeholders, meta fields). */\nexport interface CompositeKind {\n id: string\n label: string\n icon: string\n titlePlaceholder: string\n descriptionPlaceholder: string\n fields: CompositeMetaField[]\n /**\n * How much of the chrome the kind shows. Absent: all of it. `tags: false` hides the tag row of this kind (the node stays in the schema, empty).\n * `tone`: a CSS colour or `var(...)` that sets the kind apart: a Baustein of this kind gets `data-kind-tone` and `--sk-kind-tone` on its wrapper\n * (a tinted surface and a left border in the tone) and its tree rows tint the kind icon with it. Absent: the kind looks as before.\n * `controls: false` makes the chrome of a Baustein of this kind read-only although the editor is editable (for a kind whose attributes a host\n * guard refuses to change): no basket menu, status menu, title-visibility toggle, tag editing or drag handle on the kind icon, and a read-only\n * details popover; an existing basket, status and tags still show as chips. Default `true`.\n */\n chrome?: { tags?: boolean, tone?: string, controls?: boolean }\n /** Absent: the kind has no AI brief; „Baustein füllen (KI)“ is not offered for it. */\n ai?: CompositeKindAi\n /**\n * Baustein kinds this kind accepts as nested Bausteine: a list of kind ids, or `'all'`. Absent: `folder` and `document`\n * accept `'all'`, every other kind accepts none. Non-Baustein content (paragraphs, lists, ...) is always allowed.\n * Only new moves are checked; documents that already nest against it stay as they are.\n */\n accepts?: readonly string[] | 'all'\n /** Present on source-holding kinds: the media block types the kind's source may be; `sourceOf` returns the first body child of one of these. */\n source?: readonly (typeof SOURCE_MEDIA_TYPES)[number][]\n}\n\n/**\n * The built-in kinds in the language of `t`. The default set is produced from the translator (labels, placeholders, field\n * labels and status choices are catalog messages), so it is built per translator and memoized; hosts that pass their own\n * kinds (`compositeFeature({ kinds })`, `Composite.configure({ kinds })`) keep their labels untouched. Ids, field keys and\n * stored values (`open`, `doing`, `done`) do not depend on the language.\n */\nexport function defaultCompositeKinds(t: Translate): readonly CompositeKind[] {\n let kinds = DEFAULT_KINDS.get(t)\n if (!kinds) DEFAULT_KINDS.set(t, kinds = buildDefaultKinds(t))\n return kinds\n}\n\nconst DEFAULT_KINDS = new WeakMap<Translate, readonly CompositeKind[]>()\n\nfunction buildDefaultKinds(t: Translate): readonly CompositeKind[] {\n return [\n { id: 'section', label: t('composites.kind.section.label'), icon: 'i-lucide-layers', titlePlaceholder: t('composites.kind.section.title'), descriptionPlaceholder: t('composites.kind.section.description'), fields: [], accepts: 'all' },\n { id: 'task', label: t('composites.kind.task.label'), icon: 'i-lucide-square-check', titlePlaceholder: t('composites.kind.task.title'), descriptionPlaceholder: t('composites.kind.task.description'), fields: [\n { key: 'status', label: t('composites.kind.task.field.status'), type: 'select', options: [\n { value: 'open', label: t('composites.kind.task.status.open') },\n { value: 'doing', label: t('composites.kind.task.status.doing') },\n { value: 'done', label: t('composites.kind.task.status.done') },\n ] },\n { key: 'due', label: t('composites.kind.task.field.due'), type: 'date' },\n { key: 'assignee', label: t('composites.kind.task.field.assignee'), type: 'text' },\n ] },\n // i18n-ignore: model-facing kind purpose (German prompt text, not UI)\n { id: 'note', label: t('composites.kind.note.label'), icon: 'i-lucide-sticky-note', titlePlaceholder: t('composites.kind.note.title'), descriptionPlaceholder: t('composites.kind.note.description'), fields: [], ai: { purpose: 'Eigene Notiz zu einer Quelle oder einem Thema: Zusammenfassung, Gedanken, offene Fragen.' } },\n { id: 'document', label: t('composites.kind.document.label'), icon: 'i-lucide-file-text', titlePlaceholder: t('composites.kind.document.title'), descriptionPlaceholder: t('composites.kind.document.description'), source: [...SOURCE_MEDIA_TYPES], fields: [\n { key: 'filename', label: t('composites.kind.document.field.filename'), type: 'text' },\n { key: 'mimeType', label: t('composites.kind.document.field.mimeType'), type: 'text' },\n { key: 'size', label: t('composites.kind.document.field.size'), type: 'number' },\n { key: 'importedAt', label: t('composites.kind.document.field.importedAt'), type: 'date' },\n ] },\n // i18n-ignore-start: model-facing kind purposes and instructions (German prompt text, not UI)\n { id: 'recording', label: t('composites.kind.recording.label'), icon: 'i-lucide-mic', titlePlaceholder: t('composites.kind.recording.title'), descriptionPlaceholder: t('composites.kind.recording.description'), accepts: 'all', source: ['audio', 'video'], fields: [\n ...importFields(t, 'recording'),\n { key: 'recordedAt', label: t('composites.kind.recording.field.recordedAt'), type: 'date' },\n { key: 'participants', label: t('composites.kind.recording.field.participants'), type: 'text' },\n { key: 'durationSeconds', label: t('composites.kind.recording.field.durationSeconds'), type: 'number' },\n ], ai: { purpose: 'Aufnahme (Audio oder Video) als Quelle; der Inhalt hält Lesefassungen wie das Transkript und eigene Notizen.' } },\n { id: 'paper', label: t('composites.kind.paper.label'), icon: 'i-lucide-scroll-text', titlePlaceholder: t('composites.kind.paper.title'), descriptionPlaceholder: t('composites.kind.paper.description'), accepts: 'all', source: ['file'], fields: [\n ...importFields(t, 'paper'),\n { key: 'bib', label: t('composites.kind.paper.field.bib'), type: 'bibliography' },\n { key: 'doi', label: t('composites.kind.paper.field.doi'), type: 'text' },\n ], ai: { purpose: 'Wissenschaftliche Arbeit als Quelle (PDF) mit Literaturangabe; der Inhalt hält Volltext, Zusammenfassungen und Notizen.' } },\n { id: 'book', label: t('composites.kind.book.label'), icon: 'i-lucide-book', titlePlaceholder: t('composites.kind.book.title'), descriptionPlaceholder: t('composites.kind.book.description'), accepts: 'all', source: ['file'], fields: [\n ...importFields(t, 'book'),\n { key: 'bib', label: t('composites.kind.book.field.bib'), type: 'bibliography' },\n { key: 'isbn', label: t('composites.kind.book.field.isbn'), type: 'text' },\n ], ai: { purpose: 'Buch als Quelle (PDF) mit Literaturangabe; der Inhalt hält den Volltext, gegliedert in Kapitel, und Notizen.' } },\n { id: 'figure', label: t('composites.kind.figure.label'), icon: 'i-lucide-image', titlePlaceholder: t('composites.kind.figure.title'), descriptionPlaceholder: t('composites.kind.figure.description'), accepts: 'all', source: ['image'], fields: [\n ...importFields(t, 'figure'),\n { key: 'credit', label: t('composites.kind.figure.field.credit'), type: 'text' },\n ], ai: { purpose: 'Bild als Quelle; der Inhalt hält die Bildbeschreibung und eigene Notizen.' } },\n { id: 'rendition', label: t('composites.kind.rendition.label'), icon: 'i-lucide-captions', titlePlaceholder: t('composites.kind.rendition.title'), descriptionPlaceholder: t('composites.kind.rendition.description'), accepts: 'all', fields: [\n { key: 'derivation', label: t('composites.kind.rendition.field.derivation'), type: 'derivation' },\n { key: 'language', label: t('composites.kind.rendition.field.language'), type: 'text' },\n ], ai: {\n purpose: 'Lesbare Fassung einer Quelle (Transkript, Volltext, Beschreibung, Übersetzung)',\n instructions: 'Übertrage den Inhalt vollständig und gut lesbar; nichts weglassen, nichts hinzuerfinden.',\n } },\n // i18n-ignore-end\n { id: 'folder', label: t('composites.kind.folder.label'), icon: 'i-lucide-folder', titlePlaceholder: t('composites.kind.folder.title'), descriptionPlaceholder: t('composites.kind.folder.description'), fields: [] },\n ]\n}\n\n/** The four fields the import of a file fills in (`wrapImport` of `composite-media`), shared by every source-holding kind. */\nfunction importFields(t: Translate, kind: 'recording' | 'paper' | 'book' | 'figure'): CompositeMetaField[] {\n return [\n { key: 'filename', label: t(`composites.kind.${kind}.field.filename`), type: 'text' },\n { key: 'mimeType', label: t(`composites.kind.${kind}.field.mimeType`), type: 'text' },\n { key: 'size', label: t(`composites.kind.${kind}.field.size`), type: 'number' },\n { key: 'importedAt', label: t(`composites.kind.${kind}.field.importedAt`), type: 'date' },\n ]\n}\n\n/** The built-in kinds in the default language, for server-side and context-free code (`Composite`'s default option, an editor without a context). */\nexport const fallbackCompositeKinds = (): readonly CompositeKind[] => defaultCompositeKinds(DEFAULT_TRANSLATE)\n\nconst DEFAULT_TRANSLATE = createTranslator()\n\n/** Kind `id` from `kinds`; an unknown id gets the `section` kind's presentation (else the first kind's) under its own id and label. */\nexport function compositeKind(kinds: readonly CompositeKind[], id: string): CompositeKind {\n const known = kinds.find(kind => kind.id === id)\n if (known) return known\n const base = kinds.find(kind => kind.id === 'section') ?? kinds[0] ?? fallbackCompositeKinds()[0]!\n return { ...base, id, label: id }\n}\n\n/** Kinds that accept every Baustein kind when their definition sets no `accepts`. */\nconst ACCEPTS_ALL_BY_DEFAULT: Record<string, true> = { folder: true, document: true }\n\n/**\n * Whether a Baustein of kind `parentKind` accepts one of kind `childKind` as nested Baustein. The `accepts` of the kind\n * in `kinds` decides; without one (or for a kind `kinds` does not list) only `folder` and `document` accept all.\n */\nexport function kindAccepts(kinds: readonly CompositeKind[], parentKind: string, childKind: string): boolean {\n const accepts = kinds.find(kind => kind.id === parentKind)?.accepts\n if (accepts === undefined) return Object.hasOwn(ACCEPTS_ALL_BY_DEFAULT, parentKind)\n return accepts === 'all' || accepts.includes(childKind)\n}\n"],"mappings":";;;AAIA,MAAa,qBAAqB;CAAC;CAAS;CAAS;CAAS;AAAM;;;;;;;AAmEpE,SAAgB,sBAAsB,GAAwC;CAC5E,IAAI,QAAQ,cAAc,IAAI,CAAC;CAC/B,IAAI,CAAC,OAAO,cAAc,IAAI,GAAG,QAAQ,kBAAkB,CAAC,CAAC;CAC7D,OAAO;AACT;AAEA,MAAM,gCAAgB,IAAI,QAA6C;AAEvE,SAAS,kBAAkB,GAAwC;CACjE,OAAO;EACL;GAAE,IAAI;GAAW,OAAO,EAAE,+BAA+B;GAAG,MAAM;GAAmB,kBAAkB,EAAE,+BAA+B;GAAG,wBAAwB,EAAE,qCAAqC;GAAG,QAAQ,CAAC;GAAG,SAAS;EAAM;EACxO;GAA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C,CAAC;EAC7E;EAAI,OAAO;CAAG;AAClC;;AAGA,MAAM,yBAA+C;CAAE,QAAQ;CAAM,UAAU;AAAK;;;;;AAMpF,SAAgB,YAAY,OAAiC,YAAoB,WAA4B;CAC3G,MAAM,UAAU,MAAM,MAAK,SAAQ,KAAK,OAAO,UAAU,CAAC,EAAE;CAC5D,IAAI,YAAY,KAAA,GAAW,OAAO,OAAO,OAAO,wBAAwB,UAAU;CAClF,OAAO,YAAY,SAAS,QAAQ,SAAS,SAAS;AACxD"}
|
|
@@ -12,7 +12,7 @@ declare module '@tiptap/core' {
|
|
|
12
12
|
interface Commands<ReturnType> {
|
|
13
13
|
compositeMerge: {
|
|
14
14
|
/**
|
|
15
|
-
* The Baustein at `pos` (default: the caret's innermost one) absorbs the Baustein that directly follows it in the same parent: that one's body, with its sub-Bausteine, is appended to the end of this one's body and the following Baustein is gone. Title, description, tags, id, kind and meta stay those of the first. One transaction. Refused when no Baustein follows, when the first kind does not accept a Baustein nested in the following one, or when the editor is not editable.
|
|
15
|
+
* The Baustein at `pos` (default: the caret's innermost one) absorbs the Baustein that directly follows it in the same parent: that one's body, with its sub-Bausteine, is appended to the end of this one's body and the following Baustein is gone. Title, description, tags, id, kind and meta stay those of the first. One transaction. Refused when no Baustein follows, when the first kind does not accept a Baustein nested in the following one, when either Baustein has a kind with `chrome.controls === false` (host-managed), or when the editor is not editable.
|
|
16
16
|
*/
|
|
17
17
|
mergeCompositeWithNext: (pos?: number) => ReturnType;
|
|
18
18
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { kindAccepts } from "./kinds.js";
|
|
1
|
+
import { compositeKind, kindAccepts } from "./kinds.js";
|
|
2
2
|
import { compositeAt, compositeKindsOf } from "./nodes.js";
|
|
3
3
|
import { outermostComposites } from "./accepted-children.js";
|
|
4
4
|
import { Extension } from "@tiptap/core";
|
|
@@ -29,7 +29,10 @@ const CompositeMerge = Extension.create({
|
|
|
29
29
|
const $pos = state.doc.resolve(found.pos);
|
|
30
30
|
const next = $pos.parent.maybeChild($pos.index() + 1);
|
|
31
31
|
if (next?.type.name !== "composite") return false;
|
|
32
|
-
const
|
|
32
|
+
const kinds = compositeKindsOf(this.editor);
|
|
33
|
+
const hostManaged = (node) => compositeKind(kinds, String(node.attrs.kind)).chrome?.controls === false;
|
|
34
|
+
if (hostManaged(found.node) || hostManaged(next)) return false;
|
|
35
|
+
const appended = mergeBody(kinds, found.node, next);
|
|
33
36
|
if (!appended) return false;
|
|
34
37
|
if (dispatch) {
|
|
35
38
|
const nextPos = found.pos + found.node.nodeSize;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"merge.js","names":[],"sources":["../../../src/features/composites/merge.ts"],"sourcesContent":["// Merging a Baustein with its next sibling: the counterpart of the split. The pure part (`mergeBody`) knows nothing about\n// the editor; the `CompositeMerge` extension wraps it into the command `mergeCompositeWithNext`.\nimport { Extension } from '@tiptap/core'\nimport { Fragment, type Node as PMNode } from '@tiptap/pm/model'\nimport { outermostComposites } from './accepted-children'\nimport { type CompositeKind, kindAccepts } from './kinds'\nimport { COMPOSITE_CHROME_COUNT, compositeAt, compositeKindsOf } from './nodes'\n\n/**\n * What a merge appends to the end of the first Baustein's body: the whole body of `next`, its own sub-Bausteine\n * included, in document order. A body that is one empty paragraph (a Baustein nothing was written in) adds nothing.\n * Null when `first`'s kind does not accept the kind of a Baustein nested in that body (the merge is refused).\n */\nexport function mergeBody(kinds: readonly CompositeKind[], first: PMNode, next: PMNode): Fragment | null {\n let chrome = 0\n for (let i = 0; i < COMPOSITE_CHROME_COUNT; i++) chrome += next.child(i).nodeSize\n const body = next.content.cut(chrome)\n const firstKind = String(first.attrs.kind)\n for (let i = 0; i < body.childCount; i++) {\n for (const child of outermostComposites(body.child(i))) {\n if (!kindAccepts(kinds, firstKind, String(child.attrs.kind))) return null\n }\n }\n const only = body.childCount === 1 ? body.firstChild! : null\n return only?.type.name === 'paragraph' && only.content.size === 0 ? Fragment.empty : body\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n compositeMerge: {\n /**\n * The Baustein at `pos` (default: the caret's innermost one) absorbs the Baustein that directly follows it in the same parent: that one's body, with its sub-Bausteine, is appended to the end of this one's body and the following Baustein is gone. Title, description, tags, id, kind and meta stay those of the first. One transaction. Refused when no Baustein follows, when the first kind does not accept a Baustein nested in the following one, or when the editor is not editable.\n */\n mergeCompositeWithNext: (pos?: number) => ReturnType\n }\n }\n}\n\n/** Client-only, no schema: the merge command of Bausteine. */\nexport const CompositeMerge = Extension.create({\n name: 'compositeMerge',\n addCommands() {\n return {\n mergeCompositeWithNext: pos => ({ state, tr, dispatch }) => {\n if (!this.editor.isEditable) return false\n const found = compositeAt(state, pos)\n if (!found) return false\n const $pos = state.doc.resolve(found.pos)\n const next = $pos.parent.maybeChild($pos.index() + 1)\n if (next?.type.name !== 'composite') return false\n const
|
|
1
|
+
{"version":3,"file":"merge.js","names":[],"sources":["../../../src/features/composites/merge.ts"],"sourcesContent":["// Merging a Baustein with its next sibling: the counterpart of the split. The pure part (`mergeBody`) knows nothing about\n// the editor; the `CompositeMerge` extension wraps it into the command `mergeCompositeWithNext`.\nimport { Extension } from '@tiptap/core'\nimport { Fragment, type Node as PMNode } from '@tiptap/pm/model'\nimport { outermostComposites } from './accepted-children'\nimport { type CompositeKind, compositeKind, kindAccepts } from './kinds'\nimport { COMPOSITE_CHROME_COUNT, compositeAt, compositeKindsOf } from './nodes'\n\n/**\n * What a merge appends to the end of the first Baustein's body: the whole body of `next`, its own sub-Bausteine\n * included, in document order. A body that is one empty paragraph (a Baustein nothing was written in) adds nothing.\n * Null when `first`'s kind does not accept the kind of a Baustein nested in that body (the merge is refused).\n */\nexport function mergeBody(kinds: readonly CompositeKind[], first: PMNode, next: PMNode): Fragment | null {\n let chrome = 0\n for (let i = 0; i < COMPOSITE_CHROME_COUNT; i++) chrome += next.child(i).nodeSize\n const body = next.content.cut(chrome)\n const firstKind = String(first.attrs.kind)\n for (let i = 0; i < body.childCount; i++) {\n for (const child of outermostComposites(body.child(i))) {\n if (!kindAccepts(kinds, firstKind, String(child.attrs.kind))) return null\n }\n }\n const only = body.childCount === 1 ? body.firstChild! : null\n return only?.type.name === 'paragraph' && only.content.size === 0 ? Fragment.empty : body\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n compositeMerge: {\n /**\n * The Baustein at `pos` (default: the caret's innermost one) absorbs the Baustein that directly follows it in the same parent: that one's body, with its sub-Bausteine, is appended to the end of this one's body and the following Baustein is gone. Title, description, tags, id, kind and meta stay those of the first. One transaction. Refused when no Baustein follows, when the first kind does not accept a Baustein nested in the following one, when either Baustein has a kind with `chrome.controls === false` (host-managed), or when the editor is not editable.\n */\n mergeCompositeWithNext: (pos?: number) => ReturnType\n }\n }\n}\n\n/** Client-only, no schema: the merge command of Bausteine. */\nexport const CompositeMerge = Extension.create({\n name: 'compositeMerge',\n addCommands() {\n return {\n mergeCompositeWithNext: pos => ({ state, tr, dispatch }) => {\n if (!this.editor.isEditable) return false\n const found = compositeAt(state, pos)\n if (!found) return false\n const $pos = state.doc.resolve(found.pos)\n const next = $pos.parent.maybeChild($pos.index() + 1)\n if (next?.type.name !== 'composite') return false\n const kinds = compositeKindsOf(this.editor)\n // A kind with `chrome.controls === false` is host-managed: neither absorbing nor being absorbed is the editor's call.\n const hostManaged = (node: PMNode) => compositeKind(kinds, String(node.attrs.kind)).chrome?.controls === false\n if (hostManaged(found.node) || hostManaged(next)) return false\n const appended = mergeBody(kinds, found.node, next)\n if (!appended) return false\n if (dispatch) {\n const nextPos = found.pos + found.node.nodeSize\n // The body goes in at the end of the first Baustein, then the second one is cut out behind it.\n tr.insert(nextPos - 1, appended)\n const shifted = nextPos + appended.size\n tr.delete(shifted, shifted + next.nodeSize)\n }\n return true\n },\n }\n },\n})\n"],"mappings":";;;;;;;;;;;AAaA,SAAgB,UAAU,OAAiC,OAAe,MAA+B;CACvG,IAAI,SAAS;CACb,KAAK,IAAI,IAAI,GAAG,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;IACnC,GAAG,OAAO,SAAS,UAAU,KAAK,QAAQ;GAC5C;GACA,OAAO;EACT,EACF;CACF;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","names":[],"sources":["../../../src/features/composites/nodes.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport { type JSONContent, mergeAttributes, Node } from '@tiptap/core'\nimport type { Node as PMNode, ResolvedPos } from '@tiptap/pm/model'\nimport { type EditorState, Selection, TextSelection } from '@tiptap/pm/state'\nimport { editorEntryOf } from '../../core/editor-ui'\nimport { createStore, type Store } from '../../core/store'\nimport { ABILITY, isChromeNode, TEXT_ABILITIES } from '../../core/schema'\nimport type { HeadingConversionScope } from '../../settings'\nimport { compositeFence, withReferencedFenceIds } from './fences'\nimport { type Basket, basketById, defaultBaskets, fallbackBaskets, titleHiddenOf } from './baskets'\nimport { derivationOf } from './derivation'\nimport { flattenCompositesToHeadings, groupHeadingsIntoComposites, headingGroupRange } from './heading-composites'\nimport { type CompositeKind, compositeKind, defaultCompositeKinds, fallbackCompositeKinds } from './kinds'\nimport { BASKET_KEY, keptMeta, TITLE_HIDDEN_KEY } from './meta-keys'\n\n/** Options of the `composite` node: the kinds its `kind` attribute selects from and the baskets its `meta.basket` selects from. */\nexport interface CompositeOptions {\n kinds: readonly CompositeKind[]\n baskets: readonly Basket[]\n}\n\n/** Storage of the `composite` node: mirrors `options.kinds` and `options.baskets` for code that only has the editor. */\nexport interface CompositeStorage {\n kinds: readonly CompositeKind[]\n baskets: readonly Basket[]\n /** Ids of the Bausteine with a hidden title (`meta.titleHidden`) whose title the caret entered; they show it for the rest of the editor session. */\n revealedTitles: Store<ReadonlySet<string>>\n /** Ids of the derived Bausteine (those with a `meta.derivation`) the user opened; every other derived Baustein shows collapsed. */\n expanded: Store<ReadonlySet<string>>\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n composite: {\n /** Insert an empty composite of `kind` after the caret's block (replacing an empty paragraph; at the body start from the composite chrome), caret in its title. */\n insertComposite: (kind?: string) => ReturnType\n /** Wrap the selected blocks into a new composite of `kind`, caret in its title. */\n wrapInComposite: (kind?: string) => ReturnType\n /** Leave the caret's innermost composite: new paragraph right after it (a trailing empty body paragraph is moved there). */\n exitComposite: () => ReturnType\n /** Group headings in the selected blocks (or, without a selection, in `scope`) into composites of `kind`; `recursive` nests every heading level. False when the range holds no heading. */\n convertHeadingsToComposites: (options: { recursive: boolean, scope: HeadingConversionScope, kind?: string }) => ReturnType\n /** Turn composites among the selected blocks (or, without a selection, in `scope`) into headings of their nesting level, with description, tags and meta as text lines; `recursive` flattens every level. False when the range holds no composite. */\n convertCompositesToHeadings: (options: { recursive: boolean, scope: HeadingConversionScope }) => ReturnType\n /** Switch the composite at `pos` (default: the caret's innermost composite) to `kind`; `meta` keeps the target kind's fields plus `derivation` and `bib`. */\n setCompositeKind: (kind: string, pos?: number) => ReturnType\n /** Open the derived Baustein with block id `id` if it is collapsed, collapse it if it is open. */\n toggleCompositeExpanded: (id: string) => ReturnType\n /** Put the composite at `pos` (default: the caret's innermost composite) into the basket `basket` (an id of the editor's baskets; false for an unknown id), or take it out with `null`. */\n setCompositeBasket: (basket: string | null, pos?: number) => ReturnType\n /** Hide (`true`) or show (`false`) the title of the composite at `pos` (default: the caret's innermost composite); showing also ends the caret reveal of its title. */\n setCompositeTitleHidden: (hidden: boolean, pos?: number) => ReturnType\n }\n }\n\n interface Storage {\n composite: CompositeStorage\n }\n}\n\nconst COMPOSITE = 'composite'\nconst TITLE = 'compositeTitle'\nconst DESCRIPTION = 'compositeDescription'\nconst TAGS = 'compositeTags'\n/** Kind of a composite created without an explicit one (also the attribute default). */\nconst DEFAULT_KIND = 'section'\n/** Title, description and tags: the fixed children in front of a composite's body. */\nexport const COMPOSITE_CHROME_COUNT = 3\nconst CHROME_COUNT = COMPOSITE_CHROME_COUNT\n\n/**\n * Composite kinds `editor` was configured with. An editor without the composite node gets the built-in kinds in the\n * language of its surface (the default language without one).\n */\nexport function compositeKindsOf(editor: Editor): readonly CompositeKind[] {\n const configured: readonly CompositeKind[] | undefined = editor.storage.composite?.kinds\n if (configured) return configured\n const entry = editorEntryOf(editor)\n return entry ? defaultCompositeKinds(entry.ctx.t) : fallbackCompositeKinds()\n}\n\n/** Baskets `editor` was configured with (the built-in ones in the default language for an editor without the composite node). */\nexport function compositeBasketsOf(editor: Editor): readonly Basket[] {\n const configured: readonly Basket[] | undefined = editor.storage.composite?.baskets\n if (configured) return configured\n const entry = editorEntryOf(editor)\n return entry ? defaultBaskets(entry.ctx.t) : fallbackBaskets()\n}\n\n/** JSON of a fresh composite of `kind` (empty title/description/tags, hidden meta) with `body`. */\nexport function compositeJSON(kind: string, body: JSONContent[] = [{ type: 'paragraph' }]): JSONContent {\n return { type: COMPOSITE, attrs: { kind }, content: [{ type: TITLE }, { type: DESCRIPTION }, { type: TAGS }, ...body] }\n}\n\n/** Innermost composite around `$pos`: its depth, position and node. */\nexport function compositeAround($pos: ResolvedPos): { depth: number, pos: number, node: PMNode } | null {\n for (let depth = $pos.depth; depth > 0; depth--) {\n const node = $pos.node(depth)\n if (node.type.name === COMPOSITE) return { depth, pos: $pos.before(depth), node }\n }\n return null\n}\n\n/** The composite starting at `pos`, or without `pos` the caret's innermost composite. */\nexport function compositeAt(state: EditorState, pos: number | undefined): { pos: number, node: PMNode } | null {\n if (pos === undefined) return compositeAround(state.selection.$head)\n const node = state.doc.nodeAt(pos)\n return node?.type.name === COMPOSITE ? { pos, node } : null\n}\n\n/** Position right in front of the body (= after the tags row) of the composite whose content starts at `start`. */\nfunction bodyStart(composite: PMNode, start: number): number {\n let pos = start\n for (let i = 0; i < CHROME_COUNT; i++) pos += composite.child(i).nodeSize\n return pos\n}\n\nconst isEmptyParagraph = (node: PMNode) => node.type.name === 'paragraph' && node.content.size === 0\n\n/** The caret's block is an empty paragraph, the last child of a composite whose body has more than this one block. */\nfunction inTrailingEmptyParagraph($head: ResolvedPos): boolean {\n if ($head.depth < 2 || !isEmptyParagraph($head.parent)) return false\n const composite = $head.node($head.depth - 1)\n return composite.type.name === COMPOSITE\n && $head.index($head.depth - 1) === composite.childCount - 1\n && composite.childCount > CHROME_COUNT + 1\n}\n\n/** Nothing typed yet: empty title and description, no tags, body is one empty paragraph. */\nfunction isEmptyComposite(composite: PMNode): boolean {\n const tags: unknown = composite.child(2).attrs.tags\n return composite.child(0).content.size === 0\n && composite.child(1).content.size === 0\n && (!Array.isArray(tags) || tags.length === 0)\n && composite.childCount === CHROME_COUNT + 1\n && isEmptyParagraph(composite.child(CHROME_COUNT))\n}\n\n/** Child range of `parent` a structure conversion works on: the selected blocks (composite chrome excluded), or without a selection the `scope` — for `'heading'` the caret's heading group (`'group'`) or innermost composite (`'flatten'`). */\nfunction structureRange(state: EditorState, scope: HeadingConversionScope, direction: 'group' | 'flatten'): { parent: PMNode, parentDepth: number, parentStart: number, fromIndex: number, toIndex: number } | null {\n const { $from, $to, $head, empty } = state.selection\n if (!empty) {\n const range = $from.blockRange($to, node => node.type.name === 'doc' || node.type.name === COMPOSITE)\n if (!range) return null\n const parent = range.parent\n // The composite chrome (title, description, tags) is never part of the converted blocks.\n const fromIndex = Math.max(range.startIndex, parent.type.name === COMPOSITE ? CHROME_COUNT : 0)\n const toIndex = range.endIndex\n if (fromIndex >= toIndex) return null\n return { parent, parentDepth: range.depth, parentStart: range.$from.start(range.depth), fromIndex, toIndex }\n }\n if (scope === 'container') {\n const found = compositeAround($head)\n if (found) return { parent: found.node, parentDepth: found.depth, parentStart: $head.start(found.depth), fromIndex: CHROME_COUNT, toIndex: found.node.childCount }\n return { parent: state.doc, parentDepth: 0, parentStart: 0, fromIndex: 0, toIndex: state.doc.childCount }\n }\n if (scope === 'heading') {\n if (direction === 'flatten') {\n const found = compositeAround($head)\n if (!found) return null\n const depth = found.depth - 1\n const fromIndex = $head.index(depth)\n return { parent: $head.node(depth), parentDepth: depth, parentStart: $head.start(depth), fromIndex, toIndex: fromIndex + 1 }\n }\n let depth = $head.depth\n while (depth > 0 && !['doc', COMPOSITE].includes($head.node(depth - 1).type.name)) depth--\n if (depth === 0) return null\n const parent = $head.node(depth - 1)\n const minIndex = parent.type.name === COMPOSITE ? CHROME_COUNT : 0\n let index = $head.index(depth - 1)\n while (index >= minIndex && parent.child(index).type.name !== 'heading') index--\n if (index < minIndex) return null\n const group = headingGroupRange(parent, index)\n return { parent, parentDepth: depth - 1, parentStart: $head.start(depth - 1), fromIndex: group.from, toIndex: group.to }\n }\n return { parent: state.doc, parentDepth: 0, parentStart: 0, fromIndex: 0, toIndex: state.doc.childCount }\n}\n\n/** Children `fromIndex..toIndex` of `parent` (content starting at `parentStart`) and their document range. */\nfunction rangeBlocks(parent: PMNode, parentStart: number, fromIndex: number, toIndex: number): { blocks: PMNode[], from: number, to: number } {\n const blocks: PMNode[] = []\n let from = parentStart\n let to = parentStart\n parent.forEach((child, _offset, index) => {\n if (index < fromIndex) from += child.nodeSize\n else if (index < toIndex) blocks.push(child)\n if (index < toIndex) to += child.nodeSize\n })\n return { blocks, from, to }\n}\n\n// Revoked inside title and description: they are single lines of text, not containers for blocks.\nconst CHROME_REVOKES = [\n ABILITY.headings, ABILITY.lists, ABILITY.blockquote, ABILITY.codeBlock, ABILITY.rule, ABILITY.composite, ABILITY.transcript,\n ABILITY.media, ABILITY.record, ABILITY.aiGenerate, ABILITY.blockDuplicate,\n]\n\n// Schema-only nodes (no node views): shared by the client editor and the server-side Yjs schema.\n// The client adds the node view of `composite` in `node-views.ts`; `compositeTags` needs none (a hidden data row).\nexport const CompositeNode = Node.create<CompositeOptions, CompositeStorage>({\n name: COMPOSITE,\n // Above StarterKit's default (100) so this Enter / Backspace / Delete keymap runs first,\n // below Paragraph (1000) so the paragraph stays the schema's default block.\n priority: 101,\n group: 'block',\n content: `${TITLE} ${DESCRIPTION} ${TAGS} block+`,\n isolating: true,\n defining: true,\n editorBlockContainer: true,\n abilities: { own: [ABILITY.compositeMeta, ABILITY.compositeSummarize, ABILITY.compositeExport, ABILITY.compositeDerive] },\n addOptions: () => ({ kinds: fallbackCompositeKinds(), baskets: fallbackBaskets() }),\n addStorage() {\n return {\n kinds: this.options.kinds,\n baskets: this.options.baskets,\n expanded: createStore<ReadonlySet<string>>(new Set()),\n revealedTitles: createStore<ReadonlySet<string>>(new Set()),\n }\n },\n // A caret inside the body of a collapsed derived Baustein (also inside nested ones) opens it: typing into hidden text would be blind.\n // A caret inside the title of a Baustein with a hidden title reveals that title for the rest of the session.\n onSelectionUpdate() {\n const { expanded, revealedTitles } = this.storage\n const { $head } = this.editor.state.selection\n let open: Set<string> | null = null\n for (let depth = $head.depth; depth > 0; depth--) {\n const node = $head.node(depth)\n const id: unknown = node.attrs.id\n if (node.type.name !== COMPOSITE || typeof id !== 'string' || !id || $head.index(depth) < CHROME_COUNT) continue\n if (derivationOf(node) && !expanded.get().has(id)) (open ??= new Set(expanded.get())).add(id)\n }\n if (open) expanded.set(open)\n if ($head.parent.type.name === TITLE && $head.depth > 0) {\n const composite = $head.node($head.depth - 1)\n const id: unknown = composite.attrs.id\n if (composite.type.name === COMPOSITE && typeof id === 'string' && id && titleHiddenOf(composite) && !revealedTitles.get().has(id)) {\n revealedTitles.set(new Set(revealedTitles.get()).add(id))\n }\n }\n },\n // Block ids reach the Markdown only for referenced Bausteine (see `fences.ts`): `DocumentMarkdown` runs this on the\n // document JSON before serializing, it drops the ids of unreferenced composites, `renderMarkdown` writes the ones left.\n markdownPrepare: (json, editor) => withReferencedFenceIds(json, compositeKindsOf(editor)),\n addAttributes: () => ({\n kind: {\n default: DEFAULT_KIND,\n // `null` (no `data-kind`, e.g. legacy markup) falls back to the default kind.\n parseHTML: el => el.getAttribute('data-kind') || null,\n renderHTML: attrs => ({ 'data-kind': attrs.kind }),\n },\n meta: {\n default: {},\n parseHTML: (el) => {\n try {\n const value: unknown = JSON.parse(el.getAttribute('data-meta') ?? '{}')\n return value && typeof value === 'object' && !Array.isArray(value) ? value : {}\n }\n catch {\n return {}\n }\n },\n renderHTML: attrs => ({ 'data-meta': JSON.stringify(attrs.meta) }),\n },\n }),\n parseHTML: () => [\n { tag: 'section[data-type=\"composite\"]' },\n // Legacy markup of the block the composite family replaced: no `data-kind`, so it parses as kind `section`.\n { tag: 'section[data-type=\"section\"]' },\n ],\n renderHTML: ({ HTMLAttributes }) => ['section', mergeAttributes(HTMLAttributes, { 'data-type': COMPOSITE }), 0],\n // Fenced: `::: <kind> {meta JSON, only when non-empty}`, then title, description, tags and body blocks as separate\n // Markdown blocks (empty description/tags render nothing), then `:::`. Same child iteration as the blockquote's\n // renderMarkdown (keeps list numbering etc. per sibling index).\n renderMarkdown: (node, h) => {\n const kind = typeof node.attrs?.kind === 'string' && node.attrs.kind ? node.attrs.kind : DEFAULT_KIND\n const meta: unknown = node.attrs?.meta\n const body = (node.content ?? [])\n .map((child, index) => h.renderChild?.(child, index) ?? h.renderChildren([child]))\n .filter(Boolean)\n .join('\\n\\n')\n const id: unknown = node.attrs?.id\n return compositeFence(kind, meta && typeof meta === 'object' ? meta as Record<string, unknown> : {}, body, typeof id === 'string' && id ? id : undefined)\n },\n\n addCommands() {\n return {\n toggleCompositeExpanded: id => () => {\n const { expanded } = this.storage\n const next = new Set(expanded.get())\n if (!next.delete(id)) next.add(id)\n expanded.set(next)\n return true\n },\n\n setCompositeBasket: (basket, pos) => ({ state, tr, dispatch }) => {\n const found = compositeAt(state, pos)\n if (!found) return false\n if (basket !== null && !basketById(this.options.baskets, basket)) return false\n if (dispatch) {\n const { [BASKET_KEY]: _previous, ...meta } = found.node.attrs.meta as Record<string, unknown>\n tr.setNodeMarkup(found.pos, undefined, { ...found.node.attrs, meta: basket === null ? meta : { ...meta, [BASKET_KEY]: basket } })\n }\n return true\n },\n\n setCompositeTitleHidden: (hidden, pos) => ({ state, tr, dispatch }) => {\n const found = compositeAt(state, pos)\n if (!found) return false\n if (dispatch) {\n const { [TITLE_HIDDEN_KEY]: _previous, ...meta } = found.node.attrs.meta as Record<string, unknown>\n tr.setNodeMarkup(found.pos, undefined, { ...found.node.attrs, meta: hidden ? { ...meta, [TITLE_HIDDEN_KEY]: true } : meta })\n const id: unknown = found.node.attrs.id\n const { revealedTitles } = this.storage\n if (!hidden && typeof id === 'string' && revealedTitles.get().has(id)) {\n const next = new Set(revealedTitles.get())\n next.delete(id)\n revealedTitles.set(next)\n }\n }\n return true\n },\n\n insertComposite: (kind = DEFAULT_KIND) => ({ state, tr, dispatch }) => {\n const { $head } = state.selection\n let depth = $head.depth\n while (depth > 0 && !['doc', COMPOSITE].includes($head.node(depth - 1).type.name)) depth--\n let from = $head.pos\n let to = from\n if (depth > 0) {\n const block = $head.node(depth)\n if (isChromeNode(block)) from = to = bodyStart($head.node(depth - 1), $head.start(depth - 1))\n else if (isEmptyParagraph(block)) {\n from = $head.before(depth)\n to = $head.after(depth)\n }\n else from = to = $head.after(depth)\n }\n const $from = state.doc.resolve(from)\n if (!$from.parent.canReplaceWith($from.index(), state.doc.resolve(to).index(), this.type)) return false\n if (dispatch) {\n const json = compositeJSON(kind)\n tr.replaceWith(from, to, state.schema.nodeFromJSON(json))\n tr.setSelection(TextSelection.create(tr.doc, from + 2)).scrollIntoView()\n }\n return true\n },\n\n wrapInComposite: (kind = DEFAULT_KIND) => ({ state, tr, dispatch }) => {\n const { $from, $to } = state.selection\n const range = $from.blockRange($to, node => node.type.name === 'doc' || node.type.name === COMPOSITE)\n if (!range) return false\n if (range.parent.type.name === COMPOSITE && range.startIndex < CHROME_COUNT) return false\n if (!range.parent.canReplaceWith(range.startIndex, range.endIndex, this.type)) return false\n if (dispatch) {\n const { nodes } = state.schema\n const composite = this.type.create({ kind }, [\n nodes[TITLE]!.create(), nodes[DESCRIPTION]!.create(), nodes[TAGS]!.create(),\n ...state.doc.slice(range.start, range.end).content.content,\n ])\n tr.replaceWith(range.start, range.end, composite)\n tr.setSelection(TextSelection.create(tr.doc, range.start + 2)).scrollIntoView()\n }\n return true\n },\n\n setCompositeKind: (kind, pos) => ({ state, tr, dispatch }) => {\n const found = compositeAt(state, pos)\n if (!found) return false\n if (dispatch) {\n const meta = keptMeta(compositeKind(this.options.kinds, kind), found.node.attrs.meta as Record<string, unknown>)\n tr.setNodeMarkup(found.pos, undefined, { ...found.node.attrs, kind, meta })\n }\n return true\n },\n\n exitComposite: () => ({ state, tr, dispatch }) => {\n const { $head } = state.selection\n const composite = compositeAround($head)\n if (!composite) return false\n if (dispatch) {\n // Leaving from a trailing empty paragraph moves it out instead of leaving an empty line behind.\n if ($head.depth === composite.depth + 1 && inTrailingEmptyParagraph($head)) tr.delete($head.before(), $head.after())\n const after = tr.mapping.map($head.after(composite.depth))\n tr.insert(after, state.schema.nodes.paragraph!.create())\n tr.setSelection(TextSelection.create(tr.doc, after + 1)).scrollIntoView()\n }\n return true\n },\n\n convertHeadingsToComposites: ({ recursive, scope, kind = DEFAULT_KIND }) => ({ state, tr, dispatch }) => {\n const range = structureRange(state, scope, 'group')\n if (!range) return false\n const { blocks, from, to } = rangeBlocks(range.parent, range.parentStart, range.fromIndex, range.toIndex)\n const result = groupHeadingsIntoComposites(state.schema, blocks, recursive, kind)\n if (!result) return false\n if (dispatch) {\n tr.replaceWith(from, to, result)\n tr.setSelection(Selection.near(tr.doc.resolve(from), 1)).scrollIntoView()\n }\n return true\n },\n\n convertCompositesToHeadings: ({ recursive, scope }) => ({ state, tr, dispatch }) => {\n const range = structureRange(state, scope, 'flatten')\n if (!range) return false\n const $pos = state.selection.empty ? state.selection.$head : state.selection.$from\n let level = 1\n for (let depth = 1; depth <= range.parentDepth; depth++) {\n if ($pos.node(depth).type.name === COMPOSITE) level++\n }\n const { blocks, from, to } = rangeBlocks(range.parent, range.parentStart, range.fromIndex, range.toIndex)\n const result = flattenCompositesToHeadings(state.schema, blocks, recursive, level, this.options.kinds)\n if (!result) return false\n if (dispatch) {\n tr.replaceWith(from, to, result)\n tr.setSelection(Selection.near(tr.doc.resolve(from), 1)).scrollIntoView()\n }\n return true\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n Enter: () => {\n const { $head } = this.editor.state.selection\n const type = $head.parent.type.name\n if (type === TITLE || type === DESCRIPTION) {\n const depth = $head.depth - 1\n const composite = $head.node(depth)\n const start = $head.start(depth)\n return this.editor.commands.command(({ tr }) => {\n const selection = Selection.findFrom(tr.doc.resolve(bodyStart(composite, start)), 1)\n if (!selection) return false\n tr.setSelection(selection).scrollIntoView()\n return true\n })\n }\n if (this.editor.state.selection.empty && inTrailingEmptyParagraph($head)) return this.editor.commands.exitComposite()\n return false\n },\n\n Backspace: () => {\n const { selection } = this.editor.state\n const { $head } = selection\n if (!selection.empty || !$head.parent.isTextblock || $head.parentOffset !== 0 || $head.depth < 2) return false\n const depth = $head.depth - 1\n const composite = $head.node(depth)\n if (composite.type.name !== COMPOSITE) return false\n const start = $head.start(depth)\n const titleEnd = start + composite.child(0).nodeSize - 1\n const type = $head.parent.type.name\n\n if (type === DESCRIPTION) {\n return this.editor.commands.command(({ tr }) => {\n tr.setSelection(TextSelection.create(tr.doc, titleEnd))\n return true\n })\n }\n if (type === TITLE) {\n // Never joins anything into the title; an untouched composite turns back into a paragraph.\n if (!isEmptyComposite(composite)) return true\n return this.editor.commands.command(({ tr, state }) => {\n const from = $head.before(depth)\n tr.replaceWith(from, $head.after(depth), state.schema.nodes.paragraph!.create())\n tr.setSelection(TextSelection.create(tr.doc, from + 1))\n return true\n })\n }\n // First body block: ProseMirror's joinBackward would delete the tags row (an atom) — move into the chrome instead.\n if ($head.index(depth) !== CHROME_COUNT) return false\n return this.editor.commands.command(({ tr }) => {\n if (isEmptyParagraph($head.parent) && composite.childCount > CHROME_COUNT + 1) tr.delete($head.before(), $head.after())\n tr.setSelection(TextSelection.create(tr.doc, titleEnd))\n return true\n })\n },\n\n // No join of the following block into title or description.\n Delete: () => {\n const { selection } = this.editor.state\n const { $head } = selection\n const type = $head.parent.type.name\n return selection.empty && (type === TITLE || type === DESCRIPTION) && $head.parentOffset === $head.parent.content.size\n },\n\n 'Mod-Shift-a': () => this.editor.commands.insertComposite(DEFAULT_KIND),\n }\n },\n})\n\nexport const CompositeTitleNode = Node.create({\n name: TITLE,\n // Above StarterKit's hard break (100), which also binds Mod-Enter.\n priority: 101,\n content: 'inline*',\n defining: true,\n editorChrome: true,\n abilities: { revokes: CHROME_REVOKES },\n // Above the heading's `h2` rule; the second rule reads legacy markup.\n parseHTML: () => [\n { tag: 'h2[data-type=\"composite-title\"]', priority: 60 },\n { tag: 'h2[data-type=\"section-title\"]', priority: 60 },\n ],\n renderHTML: ({ HTMLAttributes }) => ['h2', mergeAttributes(HTMLAttributes, { 'data-type': 'composite-title', class: 'composite-title' }), 0],\n renderMarkdown: (node, h) => `## ${h.renderChildren(node.content ?? [])}`,\n addKeyboardShortcuts() {\n return {\n // Here rather than on CompositeNode: the ability gate swallows every Mod-/Alt- key of the `composite` type where\n // `format.composite` is missing (title, code blocks, speaker segments), but leaving a composite must work everywhere.\n 'Mod-Enter': () => this.editor.commands.exitComposite(),\n }\n },\n})\n\nexport const CompositeDescriptionNode = Node.create({\n name: DESCRIPTION,\n content: 'inline*',\n defining: true,\n editorChrome: true,\n abilities: { revokes: CHROME_REVOKES },\n // Above the paragraph's `p` rule; the second rule reads legacy markup.\n parseHTML: () => [\n { tag: 'p[data-type=\"composite-description\"]', priority: 60 },\n { tag: 'p[data-type=\"section-summary\"]', priority: 60 },\n ],\n renderHTML: ({ HTMLAttributes }) => ['p', mergeAttributes(HTMLAttributes, { 'data-type': 'composite-description', class: 'composite-description' }), 0],\n renderMarkdown: (node, h) => {\n const text = h.renderChildren(node.content ?? [])\n return text ? `> ${text}` : ''\n },\n})\n\nexport const CompositeTagsNode = Node.create({\n name: TAGS,\n atom: true,\n selectable: false,\n draggable: false,\n allowGapCursor: false,\n editorChrome: true,\n abilities: { revokes: [...TEXT_ABILITIES, ABILITY.blockDelete, ABILITY.blockDuplicate] },\n addAttributes: () => ({\n tags: {\n default: [],\n parseHTML: (el) => {\n try {\n const value: unknown = JSON.parse(el.getAttribute('data-tags') ?? '[]')\n return Array.isArray(value) ? value.filter(tag => typeof tag === 'string') : []\n }\n catch {\n return []\n }\n },\n renderHTML: attrs => ({ 'data-tags': JSON.stringify(attrs.tags) }),\n },\n }),\n // The second rule reads legacy markup.\n parseHTML: () => [{ tag: 'div[data-type=\"composite-tags\"]' }, { tag: 'div[data-type=\"section-tags\"]' }],\n renderHTML: ({ HTMLAttributes }) => ['div', mergeAttributes(HTMLAttributes, { 'data-type': 'composite-tags', class: 'composite-tags' })],\n renderMarkdown: (node) => {\n const tags: unknown = node.attrs?.tags\n return Array.isArray(tags) && tags.length ? `Tags: ${tags.map(tag => `#${tag}`).join(' ')}` : ''\n },\n})\n\nexport const CompositeNodes = [CompositeNode, CompositeTitleNode, CompositeDescriptionNode, CompositeTagsNode]\n"],"mappings":";;;;;;;;;;;;;AA4DA,MAAM,YAAY;AAClB,MAAM,QAAQ;AACd,MAAM,cAAc;AACpB,MAAM,OAAO;;AAEb,MAAM,eAAe;;AAErB,MAAa,yBAAyB;AACtC,MAAM,eAAA;;;;;AAMN,SAAgB,iBAAiB,QAA0C;CACzE,MAAM,aAAmD,OAAO,QAAQ,WAAW;CACnF,IAAI,YAAY,OAAO;CACvB,MAAM,QAAQ,cAAc,MAAM;CAClC,OAAO,QAAQ,sBAAsB,MAAM,IAAI,CAAC,IAAI,uBAAuB;AAC7E;;AAGA,SAAgB,mBAAmB,QAAmC;CACpE,MAAM,aAA4C,OAAO,QAAQ,WAAW;CAC5E,IAAI,YAAY,OAAO;CACvB,MAAM,QAAQ,cAAc,MAAM;CAClC,OAAO,QAAQ,eAAe,MAAM,IAAI,CAAC,IAAI,gBAAgB;AAC/D;;AAGA,SAAgB,cAAc,MAAc,OAAsB,CAAC,EAAE,MAAM,YAAY,CAAC,GAAgB;CACtG,OAAO;EAAE,MAAM;EAAW,OAAO,EAAE,KAAK;EAAG,SAAS;GAAC,EAAE,MAAM,MAAM;GAAG,EAAE,MAAM,YAAY;GAAG,EAAE,MAAM,KAAK;GAAG,GAAG;E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O,MAAM,QAAQ,IAAI,KAAK,KAAK,SAAS,SAAS,KAAK,KAAI,QAAO,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG,MAAM;CAChG;AACF,CAAC"}
|
|
1
|
+
{"version":3,"file":"nodes.js","names":[],"sources":["../../../src/features/composites/nodes.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport { type JSONContent, mergeAttributes, Node } from '@tiptap/core'\nimport type { Node as PMNode, ResolvedPos } from '@tiptap/pm/model'\nimport { type EditorState, Selection, TextSelection } from '@tiptap/pm/state'\nimport { editorEntryOf } from '../../core/editor-ui'\nimport { createStore, type Store } from '../../core/store'\nimport { ABILITY, isChromeNode, TEXT_ABILITIES } from '../../core/schema'\nimport type { HeadingConversionScope } from '../../settings'\nimport { compositeFence, withReferencedFenceIds } from './fences'\nimport { type Basket, basketById, defaultBaskets, fallbackBaskets, titleHiddenOf } from './baskets'\nimport { derivationOf } from './derivation'\nimport { flattenCompositesToHeadings, groupHeadingsIntoComposites, headingGroupRange } from './heading-composites'\nimport { type CompositeKind, compositeKind, defaultCompositeKinds, fallbackCompositeKinds } from './kinds'\nimport { BASKET_KEY, keptMeta, TITLE_HIDDEN_KEY } from './meta-keys'\n\n/** Options of the `composite` node: the kinds its `kind` attribute selects from and the baskets its `meta.basket` selects from. */\nexport interface CompositeOptions {\n kinds: readonly CompositeKind[]\n baskets: readonly Basket[]\n}\n\n/** Storage of the `composite` node: mirrors `options.kinds` and `options.baskets` for code that only has the editor. */\nexport interface CompositeStorage {\n kinds: readonly CompositeKind[]\n baskets: readonly Basket[]\n /** Ids of the Bausteine with a hidden title (`meta.titleHidden`) whose title the caret entered; they show it for the rest of the editor session. */\n revealedTitles: Store<ReadonlySet<string>>\n /** Ids of the derived Bausteine (those with a `meta.derivation`) the user opened; every other derived Baustein shows collapsed. */\n expanded: Store<ReadonlySet<string>>\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n composite: {\n /** Insert an empty composite of `kind` after the caret's block (replacing an empty paragraph; at the body start from the composite chrome), caret in its title. */\n insertComposite: (kind?: string) => ReturnType\n /** Wrap the selected blocks into a new composite of `kind`, caret in its title. */\n wrapInComposite: (kind?: string) => ReturnType\n /** Leave the caret's innermost composite: new paragraph right after it (a trailing empty body paragraph is moved there). */\n exitComposite: () => ReturnType\n /** Group headings in the selected blocks (or, without a selection, in `scope`) into composites of `kind`; `recursive` nests every heading level. False when the range holds no heading. */\n convertHeadingsToComposites: (options: { recursive: boolean, scope: HeadingConversionScope, kind?: string }) => ReturnType\n /** Turn composites among the selected blocks (or, without a selection, in `scope`) into headings of their nesting level, with description, tags and meta as text lines; `recursive` flattens every level. False when the range holds no composite. */\n convertCompositesToHeadings: (options: { recursive: boolean, scope: HeadingConversionScope }) => ReturnType\n /** Switch the composite at `pos` (default: the caret's innermost composite) to `kind`; `meta` keeps the target kind's fields plus `derivation` and `bib`. */\n setCompositeKind: (kind: string, pos?: number) => ReturnType\n /** Open the derived Baustein with block id `id` if it is collapsed, collapse it if it is open. */\n toggleCompositeExpanded: (id: string) => ReturnType\n /** Put the composite at `pos` (default: the caret's innermost composite) into the basket `basket` (an id of the editor's baskets; false for an unknown id), or take it out with `null`. */\n setCompositeBasket: (basket: string | null, pos?: number) => ReturnType\n /** Hide (`true`) or show (`false`) the title of the composite at `pos` (default: the caret's innermost composite); showing also ends the caret reveal of its title. */\n setCompositeTitleHidden: (hidden: boolean, pos?: number) => ReturnType\n }\n }\n\n interface Storage {\n composite: CompositeStorage\n }\n}\n\nconst COMPOSITE = 'composite'\nconst TITLE = 'compositeTitle'\nconst DESCRIPTION = 'compositeDescription'\nconst TAGS = 'compositeTags'\n/** Kind of a composite created without an explicit one (also the attribute default). */\nconst DEFAULT_KIND = 'section'\n/** Title, description and tags: the fixed children in front of a composite's body. */\nexport const COMPOSITE_CHROME_COUNT = 3\nconst CHROME_COUNT = COMPOSITE_CHROME_COUNT\n\n/**\n * Composite kinds `editor` was configured with. An editor without the composite node gets the built-in kinds in the\n * language of its surface (the default language without one).\n */\nexport function compositeKindsOf(editor: Editor): readonly CompositeKind[] {\n const configured: readonly CompositeKind[] | undefined = editor.storage.composite?.kinds\n if (configured) return configured\n const entry = editorEntryOf(editor)\n return entry ? defaultCompositeKinds(entry.ctx.t) : fallbackCompositeKinds()\n}\n\n/** Baskets `editor` was configured with (the built-in ones in the default language for an editor without the composite node). */\nexport function compositeBasketsOf(editor: Editor): readonly Basket[] {\n const configured: readonly Basket[] | undefined = editor.storage.composite?.baskets\n if (configured) return configured\n const entry = editorEntryOf(editor)\n return entry ? defaultBaskets(entry.ctx.t) : fallbackBaskets()\n}\n\n/** JSON of a fresh composite of `kind` (empty title/description/tags, hidden meta) with `body`. */\nexport function compositeJSON(kind: string, body: JSONContent[] = [{ type: 'paragraph' }]): JSONContent {\n return { type: COMPOSITE, attrs: { kind }, content: [{ type: TITLE }, { type: DESCRIPTION }, { type: TAGS }, ...body] }\n}\n\n/** Innermost composite around `$pos`: its depth, position and node. */\nexport function compositeAround($pos: ResolvedPos): { depth: number, pos: number, node: PMNode } | null {\n for (let depth = $pos.depth; depth > 0; depth--) {\n const node = $pos.node(depth)\n if (node.type.name === COMPOSITE) return { depth, pos: $pos.before(depth), node }\n }\n return null\n}\n\n/** The composite starting at `pos`, or without `pos` the caret's innermost composite. */\nexport function compositeAt(state: EditorState, pos: number | undefined): { pos: number, node: PMNode } | null {\n if (pos === undefined) return compositeAround(state.selection.$head)\n const node = state.doc.nodeAt(pos)\n return node?.type.name === COMPOSITE ? { pos, node } : null\n}\n\n/** Position right in front of the body (= after the tags row) of the composite whose content starts at `start`. */\nfunction bodyStart(composite: PMNode, start: number): number {\n let pos = start\n for (let i = 0; i < CHROME_COUNT; i++) pos += composite.child(i).nodeSize\n return pos\n}\n\nconst isEmptyParagraph = (node: PMNode) => node.type.name === 'paragraph' && node.content.size === 0\n\n/** The caret's block is an empty paragraph, the last child of a composite whose body has more than this one block. */\nfunction inTrailingEmptyParagraph($head: ResolvedPos): boolean {\n if ($head.depth < 2 || !isEmptyParagraph($head.parent)) return false\n const composite = $head.node($head.depth - 1)\n return composite.type.name === COMPOSITE\n && $head.index($head.depth - 1) === composite.childCount - 1\n && composite.childCount > CHROME_COUNT + 1\n}\n\n/** Nothing typed yet: empty title and description, no tags, body is one empty paragraph. */\nfunction isEmptyComposite(composite: PMNode): boolean {\n const tags: unknown = composite.child(2).attrs.tags\n return composite.child(0).content.size === 0\n && composite.child(1).content.size === 0\n && (!Array.isArray(tags) || tags.length === 0)\n && composite.childCount === CHROME_COUNT + 1\n && isEmptyParagraph(composite.child(CHROME_COUNT))\n}\n\n/** Child range of `parent` a structure conversion works on: the selected blocks (composite chrome excluded), or without a selection the `scope` — for `'heading'` the caret's heading group (`'group'`) or innermost composite (`'flatten'`). */\nfunction structureRange(state: EditorState, scope: HeadingConversionScope, direction: 'group' | 'flatten'): { parent: PMNode, parentDepth: number, parentStart: number, fromIndex: number, toIndex: number } | null {\n const { $from, $to, $head, empty } = state.selection\n if (!empty) {\n const range = $from.blockRange($to, node => node.type.name === 'doc' || node.type.name === COMPOSITE)\n if (!range) return null\n const parent = range.parent\n // The composite chrome (title, description, tags) is never part of the converted blocks.\n const fromIndex = Math.max(range.startIndex, parent.type.name === COMPOSITE ? CHROME_COUNT : 0)\n const toIndex = range.endIndex\n if (fromIndex >= toIndex) return null\n return { parent, parentDepth: range.depth, parentStart: range.$from.start(range.depth), fromIndex, toIndex }\n }\n if (scope === 'container') {\n const found = compositeAround($head)\n if (found) return { parent: found.node, parentDepth: found.depth, parentStart: $head.start(found.depth), fromIndex: CHROME_COUNT, toIndex: found.node.childCount }\n return { parent: state.doc, parentDepth: 0, parentStart: 0, fromIndex: 0, toIndex: state.doc.childCount }\n }\n if (scope === 'heading') {\n if (direction === 'flatten') {\n const found = compositeAround($head)\n if (!found) return null\n const depth = found.depth - 1\n const fromIndex = $head.index(depth)\n return { parent: $head.node(depth), parentDepth: depth, parentStart: $head.start(depth), fromIndex, toIndex: fromIndex + 1 }\n }\n let depth = $head.depth\n while (depth > 0 && !['doc', COMPOSITE].includes($head.node(depth - 1).type.name)) depth--\n if (depth === 0) return null\n const parent = $head.node(depth - 1)\n const minIndex = parent.type.name === COMPOSITE ? CHROME_COUNT : 0\n let index = $head.index(depth - 1)\n while (index >= minIndex && parent.child(index).type.name !== 'heading') index--\n if (index < minIndex) return null\n const group = headingGroupRange(parent, index)\n return { parent, parentDepth: depth - 1, parentStart: $head.start(depth - 1), fromIndex: group.from, toIndex: group.to }\n }\n return { parent: state.doc, parentDepth: 0, parentStart: 0, fromIndex: 0, toIndex: state.doc.childCount }\n}\n\n/** Children `fromIndex..toIndex` of `parent` (content starting at `parentStart`) and their document range. */\nfunction rangeBlocks(parent: PMNode, parentStart: number, fromIndex: number, toIndex: number): { blocks: PMNode[], from: number, to: number } {\n const blocks: PMNode[] = []\n let from = parentStart\n let to = parentStart\n parent.forEach((child, _offset, index) => {\n if (index < fromIndex) from += child.nodeSize\n else if (index < toIndex) blocks.push(child)\n if (index < toIndex) to += child.nodeSize\n })\n return { blocks, from, to }\n}\n\n// Revoked inside title and description: they are single lines of text, not containers for blocks.\nconst CHROME_REVOKES = [\n ABILITY.headings, ABILITY.lists, ABILITY.blockquote, ABILITY.codeBlock, ABILITY.rule, ABILITY.composite, ABILITY.transcript,\n ABILITY.media, ABILITY.imageStudio, ABILITY.record, ABILITY.aiGenerate, ABILITY.blockDuplicate,\n]\n\n// Schema-only nodes (no node views): shared by the client editor and the server-side Yjs schema.\n// The client adds the node view of `composite` in `node-views.ts`; `compositeTags` needs none (a hidden data row).\nexport const CompositeNode = Node.create<CompositeOptions, CompositeStorage>({\n name: COMPOSITE,\n // Above StarterKit's default (100) so this Enter / Backspace / Delete keymap runs first,\n // below Paragraph (1000) so the paragraph stays the schema's default block.\n priority: 101,\n group: 'block',\n content: `${TITLE} ${DESCRIPTION} ${TAGS} block+`,\n isolating: true,\n defining: true,\n editorBlockContainer: true,\n abilities: { own: [ABILITY.compositeMeta, ABILITY.compositeSummarize, ABILITY.compositeExport, ABILITY.compositeDerive] },\n addOptions: () => ({ kinds: fallbackCompositeKinds(), baskets: fallbackBaskets() }),\n addStorage() {\n return {\n kinds: this.options.kinds,\n baskets: this.options.baskets,\n expanded: createStore<ReadonlySet<string>>(new Set()),\n revealedTitles: createStore<ReadonlySet<string>>(new Set()),\n }\n },\n // A caret inside the body of a collapsed derived Baustein (also inside nested ones) opens it: typing into hidden text would be blind.\n // A caret inside the title of a Baustein with a hidden title reveals that title for the rest of the session.\n onSelectionUpdate() {\n const { expanded, revealedTitles } = this.storage\n const { $head } = this.editor.state.selection\n let open: Set<string> | null = null\n for (let depth = $head.depth; depth > 0; depth--) {\n const node = $head.node(depth)\n const id: unknown = node.attrs.id\n if (node.type.name !== COMPOSITE || typeof id !== 'string' || !id || $head.index(depth) < CHROME_COUNT) continue\n if (derivationOf(node) && !expanded.get().has(id)) (open ??= new Set(expanded.get())).add(id)\n }\n if (open) expanded.set(open)\n if ($head.parent.type.name === TITLE && $head.depth > 0) {\n const composite = $head.node($head.depth - 1)\n const id: unknown = composite.attrs.id\n if (composite.type.name === COMPOSITE && typeof id === 'string' && id && titleHiddenOf(composite) && !revealedTitles.get().has(id)) {\n revealedTitles.set(new Set(revealedTitles.get()).add(id))\n }\n }\n },\n // Block ids reach the Markdown only for referenced Bausteine (see `fences.ts`): `DocumentMarkdown` runs this on the\n // document JSON before serializing, it drops the ids of unreferenced composites, `renderMarkdown` writes the ones left.\n markdownPrepare: (json, editor) => withReferencedFenceIds(json, compositeKindsOf(editor)),\n addAttributes: () => ({\n kind: {\n default: DEFAULT_KIND,\n // `null` (no `data-kind`, e.g. legacy markup) falls back to the default kind.\n parseHTML: el => el.getAttribute('data-kind') || null,\n renderHTML: attrs => ({ 'data-kind': attrs.kind }),\n },\n meta: {\n default: {},\n parseHTML: (el) => {\n try {\n const value: unknown = JSON.parse(el.getAttribute('data-meta') ?? '{}')\n return value && typeof value === 'object' && !Array.isArray(value) ? value : {}\n }\n catch {\n return {}\n }\n },\n renderHTML: attrs => ({ 'data-meta': JSON.stringify(attrs.meta) }),\n },\n }),\n parseHTML: () => [\n { tag: 'section[data-type=\"composite\"]' },\n // Legacy markup of the block the composite family replaced: no `data-kind`, so it parses as kind `section`.\n { tag: 'section[data-type=\"section\"]' },\n ],\n renderHTML: ({ HTMLAttributes }) => ['section', mergeAttributes(HTMLAttributes, { 'data-type': COMPOSITE }), 0],\n // Fenced: `::: <kind> {meta JSON, only when non-empty}`, then title, description, tags and body blocks as separate\n // Markdown blocks (empty description/tags render nothing), then `:::`. Same child iteration as the blockquote's\n // renderMarkdown (keeps list numbering etc. per sibling index).\n renderMarkdown: (node, h) => {\n const kind = typeof node.attrs?.kind === 'string' && node.attrs.kind ? node.attrs.kind : DEFAULT_KIND\n const meta: unknown = node.attrs?.meta\n const body = (node.content ?? [])\n .map((child, index) => h.renderChild?.(child, index) ?? h.renderChildren([child]))\n .filter(Boolean)\n .join('\\n\\n')\n const id: unknown = node.attrs?.id\n return compositeFence(kind, meta && typeof meta === 'object' ? meta as Record<string, unknown> : {}, body, typeof id === 'string' && id ? id : undefined)\n },\n\n addCommands() {\n return {\n toggleCompositeExpanded: id => () => {\n const { expanded } = this.storage\n const next = new Set(expanded.get())\n if (!next.delete(id)) next.add(id)\n expanded.set(next)\n return true\n },\n\n setCompositeBasket: (basket, pos) => ({ state, tr, dispatch }) => {\n const found = compositeAt(state, pos)\n if (!found) return false\n if (basket !== null && !basketById(this.options.baskets, basket)) return false\n if (dispatch) {\n const { [BASKET_KEY]: _previous, ...meta } = found.node.attrs.meta as Record<string, unknown>\n tr.setNodeMarkup(found.pos, undefined, { ...found.node.attrs, meta: basket === null ? meta : { ...meta, [BASKET_KEY]: basket } })\n }\n return true\n },\n\n setCompositeTitleHidden: (hidden, pos) => ({ state, tr, dispatch }) => {\n const found = compositeAt(state, pos)\n if (!found) return false\n if (dispatch) {\n const { [TITLE_HIDDEN_KEY]: _previous, ...meta } = found.node.attrs.meta as Record<string, unknown>\n tr.setNodeMarkup(found.pos, undefined, { ...found.node.attrs, meta: hidden ? { ...meta, [TITLE_HIDDEN_KEY]: true } : meta })\n const id: unknown = found.node.attrs.id\n const { revealedTitles } = this.storage\n if (!hidden && typeof id === 'string' && revealedTitles.get().has(id)) {\n const next = new Set(revealedTitles.get())\n next.delete(id)\n revealedTitles.set(next)\n }\n }\n return true\n },\n\n insertComposite: (kind = DEFAULT_KIND) => ({ state, tr, dispatch }) => {\n const { $head } = state.selection\n let depth = $head.depth\n while (depth > 0 && !['doc', COMPOSITE].includes($head.node(depth - 1).type.name)) depth--\n let from = $head.pos\n let to = from\n if (depth > 0) {\n const block = $head.node(depth)\n if (isChromeNode(block)) from = to = bodyStart($head.node(depth - 1), $head.start(depth - 1))\n else if (isEmptyParagraph(block)) {\n from = $head.before(depth)\n to = $head.after(depth)\n }\n else from = to = $head.after(depth)\n }\n const $from = state.doc.resolve(from)\n if (!$from.parent.canReplaceWith($from.index(), state.doc.resolve(to).index(), this.type)) return false\n if (dispatch) {\n const json = compositeJSON(kind)\n tr.replaceWith(from, to, state.schema.nodeFromJSON(json))\n tr.setSelection(TextSelection.create(tr.doc, from + 2)).scrollIntoView()\n }\n return true\n },\n\n wrapInComposite: (kind = DEFAULT_KIND) => ({ state, tr, dispatch }) => {\n const { $from, $to } = state.selection\n const range = $from.blockRange($to, node => node.type.name === 'doc' || node.type.name === COMPOSITE)\n if (!range) return false\n if (range.parent.type.name === COMPOSITE && range.startIndex < CHROME_COUNT) return false\n if (!range.parent.canReplaceWith(range.startIndex, range.endIndex, this.type)) return false\n if (dispatch) {\n const { nodes } = state.schema\n const composite = this.type.create({ kind }, [\n nodes[TITLE]!.create(), nodes[DESCRIPTION]!.create(), nodes[TAGS]!.create(),\n ...state.doc.slice(range.start, range.end).content.content,\n ])\n tr.replaceWith(range.start, range.end, composite)\n tr.setSelection(TextSelection.create(tr.doc, range.start + 2)).scrollIntoView()\n }\n return true\n },\n\n setCompositeKind: (kind, pos) => ({ state, tr, dispatch }) => {\n const found = compositeAt(state, pos)\n if (!found) return false\n if (dispatch) {\n const meta = keptMeta(compositeKind(this.options.kinds, kind), found.node.attrs.meta as Record<string, unknown>)\n tr.setNodeMarkup(found.pos, undefined, { ...found.node.attrs, kind, meta })\n }\n return true\n },\n\n exitComposite: () => ({ state, tr, dispatch }) => {\n const { $head } = state.selection\n const composite = compositeAround($head)\n if (!composite) return false\n if (dispatch) {\n // Leaving from a trailing empty paragraph moves it out instead of leaving an empty line behind.\n if ($head.depth === composite.depth + 1 && inTrailingEmptyParagraph($head)) tr.delete($head.before(), $head.after())\n const after = tr.mapping.map($head.after(composite.depth))\n tr.insert(after, state.schema.nodes.paragraph!.create())\n tr.setSelection(TextSelection.create(tr.doc, after + 1)).scrollIntoView()\n }\n return true\n },\n\n convertHeadingsToComposites: ({ recursive, scope, kind = DEFAULT_KIND }) => ({ state, tr, dispatch }) => {\n const range = structureRange(state, scope, 'group')\n if (!range) return false\n const { blocks, from, to } = rangeBlocks(range.parent, range.parentStart, range.fromIndex, range.toIndex)\n const result = groupHeadingsIntoComposites(state.schema, blocks, recursive, kind)\n if (!result) return false\n if (dispatch) {\n tr.replaceWith(from, to, result)\n tr.setSelection(Selection.near(tr.doc.resolve(from), 1)).scrollIntoView()\n }\n return true\n },\n\n convertCompositesToHeadings: ({ recursive, scope }) => ({ state, tr, dispatch }) => {\n const range = structureRange(state, scope, 'flatten')\n if (!range) return false\n const $pos = state.selection.empty ? state.selection.$head : state.selection.$from\n let level = 1\n for (let depth = 1; depth <= range.parentDepth; depth++) {\n if ($pos.node(depth).type.name === COMPOSITE) level++\n }\n const { blocks, from, to } = rangeBlocks(range.parent, range.parentStart, range.fromIndex, range.toIndex)\n const result = flattenCompositesToHeadings(state.schema, blocks, recursive, level, this.options.kinds)\n if (!result) return false\n if (dispatch) {\n tr.replaceWith(from, to, result)\n tr.setSelection(Selection.near(tr.doc.resolve(from), 1)).scrollIntoView()\n }\n return true\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n Enter: () => {\n const { $head } = this.editor.state.selection\n const type = $head.parent.type.name\n if (type === TITLE || type === DESCRIPTION) {\n const depth = $head.depth - 1\n const composite = $head.node(depth)\n const start = $head.start(depth)\n return this.editor.commands.command(({ tr }) => {\n const selection = Selection.findFrom(tr.doc.resolve(bodyStart(composite, start)), 1)\n if (!selection) return false\n tr.setSelection(selection).scrollIntoView()\n return true\n })\n }\n if (this.editor.state.selection.empty && inTrailingEmptyParagraph($head)) return this.editor.commands.exitComposite()\n return false\n },\n\n Backspace: () => {\n const { selection } = this.editor.state\n const { $head } = selection\n if (!selection.empty || !$head.parent.isTextblock || $head.parentOffset !== 0 || $head.depth < 2) return false\n const depth = $head.depth - 1\n const composite = $head.node(depth)\n if (composite.type.name !== COMPOSITE) return false\n const start = $head.start(depth)\n const titleEnd = start + composite.child(0).nodeSize - 1\n const type = $head.parent.type.name\n\n if (type === DESCRIPTION) {\n return this.editor.commands.command(({ tr }) => {\n tr.setSelection(TextSelection.create(tr.doc, titleEnd))\n return true\n })\n }\n if (type === TITLE) {\n // Never joins anything into the title; an untouched composite turns back into a paragraph.\n if (!isEmptyComposite(composite)) return true\n return this.editor.commands.command(({ tr, state }) => {\n const from = $head.before(depth)\n tr.replaceWith(from, $head.after(depth), state.schema.nodes.paragraph!.create())\n tr.setSelection(TextSelection.create(tr.doc, from + 1))\n return true\n })\n }\n // First body block: ProseMirror's joinBackward would delete the tags row (an atom) — move into the chrome instead.\n if ($head.index(depth) !== CHROME_COUNT) return false\n return this.editor.commands.command(({ tr }) => {\n if (isEmptyParagraph($head.parent) && composite.childCount > CHROME_COUNT + 1) tr.delete($head.before(), $head.after())\n tr.setSelection(TextSelection.create(tr.doc, titleEnd))\n return true\n })\n },\n\n // No join of the following block into title or description.\n Delete: () => {\n const { selection } = this.editor.state\n const { $head } = selection\n const type = $head.parent.type.name\n return selection.empty && (type === TITLE || type === DESCRIPTION) && $head.parentOffset === $head.parent.content.size\n },\n\n 'Mod-Shift-a': () => this.editor.commands.insertComposite(DEFAULT_KIND),\n }\n },\n})\n\nexport const CompositeTitleNode = Node.create({\n name: TITLE,\n // Above StarterKit's hard break (100), which also binds Mod-Enter.\n priority: 101,\n content: 'inline*',\n defining: true,\n editorChrome: true,\n abilities: { revokes: CHROME_REVOKES },\n // Above the heading's `h2` rule; the second rule reads legacy markup.\n parseHTML: () => [\n { tag: 'h2[data-type=\"composite-title\"]', priority: 60 },\n { tag: 'h2[data-type=\"section-title\"]', priority: 60 },\n ],\n renderHTML: ({ HTMLAttributes }) => ['h2', mergeAttributes(HTMLAttributes, { 'data-type': 'composite-title', class: 'composite-title' }), 0],\n renderMarkdown: (node, h) => `## ${h.renderChildren(node.content ?? [])}`,\n addKeyboardShortcuts() {\n return {\n // Here rather than on CompositeNode: the ability gate swallows every Mod-/Alt- key of the `composite` type where\n // `format.composite` is missing (title, code blocks, speaker segments), but leaving a composite must work everywhere.\n 'Mod-Enter': () => this.editor.commands.exitComposite(),\n }\n },\n})\n\nexport const CompositeDescriptionNode = Node.create({\n name: DESCRIPTION,\n content: 'inline*',\n defining: true,\n editorChrome: true,\n abilities: { revokes: CHROME_REVOKES },\n // Above the paragraph's `p` rule; the second rule reads legacy markup.\n parseHTML: () => [\n { tag: 'p[data-type=\"composite-description\"]', priority: 60 },\n { tag: 'p[data-type=\"section-summary\"]', priority: 60 },\n ],\n renderHTML: ({ HTMLAttributes }) => ['p', mergeAttributes(HTMLAttributes, { 'data-type': 'composite-description', class: 'composite-description' }), 0],\n renderMarkdown: (node, h) => {\n const text = h.renderChildren(node.content ?? [])\n return text ? `> ${text}` : ''\n },\n})\n\nexport const CompositeTagsNode = Node.create({\n name: TAGS,\n atom: true,\n selectable: false,\n draggable: false,\n allowGapCursor: false,\n editorChrome: true,\n abilities: { revokes: [...TEXT_ABILITIES, ABILITY.blockDelete, ABILITY.blockDuplicate] },\n addAttributes: () => ({\n tags: {\n default: [],\n parseHTML: (el) => {\n try {\n const value: unknown = JSON.parse(el.getAttribute('data-tags') ?? '[]')\n return Array.isArray(value) ? value.filter(tag => typeof tag === 'string') : []\n }\n catch {\n return []\n }\n },\n renderHTML: attrs => ({ 'data-tags': JSON.stringify(attrs.tags) }),\n },\n }),\n // The second rule reads legacy markup.\n parseHTML: () => [{ tag: 'div[data-type=\"composite-tags\"]' }, { tag: 'div[data-type=\"section-tags\"]' }],\n renderHTML: ({ HTMLAttributes }) => ['div', mergeAttributes(HTMLAttributes, { 'data-type': 'composite-tags', class: 'composite-tags' })],\n renderMarkdown: (node) => {\n const tags: unknown = node.attrs?.tags\n return Array.isArray(tags) && tags.length ? `Tags: ${tags.map(tag => `#${tag}`).join(' ')}` : ''\n },\n})\n\nexport const CompositeNodes = [CompositeNode, CompositeTitleNode, CompositeDescriptionNode, CompositeTagsNode]\n"],"mappings":";;;;;;;;;;;;;AA4DA,MAAM,YAAY;AAClB,MAAM,QAAQ;AACd,MAAM,cAAc;AACpB,MAAM,OAAO;;AAEb,MAAM,eAAe;;AAErB,MAAa,yBAAyB;AACtC,MAAM,eAAA;;;;;AAMN,SAAgB,iBAAiB,QAA0C;CACzE,MAAM,aAAmD,OAAO,QAAQ,WAAW;CACnF,IAAI,YAAY,OAAO;CACvB,MAAM,QAAQ,cAAc,MAAM;CAClC,OAAO,QAAQ,sBAAsB,MAAM,IAAI,CAAC,IAAI,uBAAuB;AAC7E;;AAGA,SAAgB,mBAAmB,QAAmC;CACpE,MAAM,aAA4C,OAAO,QAAQ,WAAW;CAC5E,IAAI,YAAY,OAAO;CACvB,MAAM,QAAQ,cAAc,MAAM;CAClC,OAAO,QAAQ,eAAe,MAAM,IAAI,CAAC,IAAI,gBAAgB;AAC/D;;AAGA,SAAgB,cAAc,MAAc,OAAsB,CAAC,EAAE,MAAM,YAAY,CAAC,GAAgB;CACtG,OAAO;EAAE,MAAM;EAAW,OAAO,EAAE,KAAK;EAAG,SAAS;GAAC,EAAE,MAAM,MAAM;GAAG,EAAE,MAAM,YAAY;GAAG,EAA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ACxB,MAAM,OAAgB,KAAK,OAAO;EAClC,OAAO,MAAM,QAAQ,IAAI,KAAK,KAAK,SAAS,SAAS,KAAK,KAAI,QAAO,IAAI,KAAK,CAAC,CAAC,KAAK,GAAG,MAAM;CAChG;AACF,CAAC"}
|
|
@@ -10,7 +10,13 @@ export interface OutlineNode {
|
|
|
10
10
|
/** Position of the composite in the document it was read from. */
|
|
11
11
|
pos: number;
|
|
12
12
|
kind: string;
|
|
13
|
+
/**
|
|
14
|
+
* The title; for a composite without one, the text of the first heading of its own body, else the start of the first
|
|
15
|
+
* text of its own body (`labelFromBody`), else the caller's `untitled`.
|
|
16
|
+
*/
|
|
13
17
|
title: string;
|
|
18
|
+
/** `title` is derived from the body, the Baustein itself has no title. */
|
|
19
|
+
labelFromBody: boolean;
|
|
14
20
|
/** The composite has a description (the summary). */
|
|
15
21
|
hasSummary: boolean;
|
|
16
22
|
/** Basket id (`meta.basket`), `null` without one. */
|
|
@@ -20,8 +26,9 @@ export interface OutlineNode {
|
|
|
20
26
|
children: OutlineNode[];
|
|
21
27
|
}
|
|
22
28
|
/**
|
|
23
|
-
* The composites of `doc` as a tree (title, kind, summary flag). A composite without a title
|
|
24
|
-
*
|
|
29
|
+
* The composites of `doc` as a tree (title, kind, summary flag). A composite without a title is labelled by its body
|
|
30
|
+
* (`labelFromBody`: first heading, else the start of the first text; nested composites do not count) and only an empty
|
|
31
|
+
* one gets `untitled` (the caller's translated „(ohne Titel)“). Composites of a kind in `hiddenKinds` are omitted and their visible descendants
|
|
25
32
|
* take their place in the parent's list.
|
|
26
33
|
*/
|
|
27
34
|
export declare function compositeOutline(doc: Node$1, hiddenKinds: ReadonlySet<string>, untitled: string): OutlineNode[];
|
|
@@ -4,9 +4,44 @@ import { basketOf, titleHiddenOf } from "./baskets.js";
|
|
|
4
4
|
import { compositeKindsOf } from "./nodes.js";
|
|
5
5
|
import { nestingReason, outermostComposites } from "./accepted-children.js";
|
|
6
6
|
//#region src/features/composites/outline.ts
|
|
7
|
+
/** Longest label taken from a paragraph; longer text is cut and ends in an ellipsis. */
|
|
8
|
+
const BODY_LABEL_CHARS = 60;
|
|
9
|
+
const clipLabel = (text) => {
|
|
10
|
+
if (text.length <= BODY_LABEL_CHARS) return text;
|
|
11
|
+
let end = BODY_LABEL_CHARS;
|
|
12
|
+
const last = text.charCodeAt(end - 1);
|
|
13
|
+
if (last >= 55296 && last <= 56319) end--;
|
|
14
|
+
return `${text.slice(0, end).trimEnd()}…`;
|
|
15
|
+
};
|
|
7
16
|
/**
|
|
8
|
-
*
|
|
9
|
-
*
|
|
17
|
+
* Walks the blocks of a composite's own body (not the ones inside a nested composite) in order. The text of the first
|
|
18
|
+
* heading ends the walk; `found.text` collects the first non-empty text block as the fallback.
|
|
19
|
+
*/
|
|
20
|
+
function scanBody(parent, from, found) {
|
|
21
|
+
for (let i = from; i < parent.childCount && found.heading === null; i++) {
|
|
22
|
+
const node = parent.child(i);
|
|
23
|
+
if (node.type.name === "composite") continue;
|
|
24
|
+
if (node.isTextblock) {
|
|
25
|
+
const text = node.textContent.trim();
|
|
26
|
+
if (!text) continue;
|
|
27
|
+
if (node.type.name === "heading") found.heading = text;
|
|
28
|
+
else found.text ??= text.replace(/\s+/g, " ");
|
|
29
|
+
} else if (!node.isLeaf) scanBody(node, 0, found);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/** The label of a composite without a title: its first heading, else the start of its first text; `null` for an empty body. */
|
|
33
|
+
function bodyLabel(composite) {
|
|
34
|
+
const found = {
|
|
35
|
+
heading: null,
|
|
36
|
+
text: null
|
|
37
|
+
};
|
|
38
|
+
scanBody(composite, 3, found);
|
|
39
|
+
return found.heading ?? (found.text === null ? null : clipLabel(found.text));
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* The composites of `doc` as a tree (title, kind, summary flag). A composite without a title is labelled by its body
|
|
43
|
+
* (`labelFromBody`: first heading, else the start of the first text; nested composites do not count) and only an empty
|
|
44
|
+
* one gets `untitled` (the caller's translated „(ohne Titel)“). Composites of a kind in `hiddenKinds` are omitted and their visible descendants
|
|
10
45
|
* take their place in the parent's list.
|
|
11
46
|
*/
|
|
12
47
|
function compositeOutline(doc, hiddenKinds, untitled) {
|
|
@@ -22,12 +57,15 @@ function compositeOutline(doc, hiddenKinds, untitled) {
|
|
|
22
57
|
return;
|
|
23
58
|
}
|
|
24
59
|
const id = blockIdOf(node);
|
|
60
|
+
const ownTitle = node.firstChild?.textContent.trim() ?? "";
|
|
61
|
+
const derived = ownTitle ? null : bodyLabel(node);
|
|
25
62
|
into.push({
|
|
26
63
|
key: id ?? `pos:${pos}`,
|
|
27
64
|
id,
|
|
28
65
|
pos,
|
|
29
66
|
kind,
|
|
30
|
-
title:
|
|
67
|
+
title: ownTitle || derived || untitled,
|
|
68
|
+
labelFromBody: derived !== null,
|
|
31
69
|
hasSummary: (node.maybeChild(1)?.content.size ?? 0) > 0,
|
|
32
70
|
basket: basketOf(node),
|
|
33
71
|
titleHidden: titleHiddenOf(node),
|