@ecsplico/editor 3.2.0 → 3.4.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 +17 -0
- package/dist/code/CodeSurface.vue.d.ts +3 -3
- package/dist/document/DocumentSurface.vue.d.ts +3 -3
- 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/components/CompositeView.js +5 -1
- package/dist/features/composites/components/CompositeView.js.map +1 -1
- package/dist/features/composites/feature.js +12 -1
- package/dist/features/composites/feature.js.map +1 -1
- package/dist/features/composites/index.d.ts +2 -1
- package/dist/features/composites/index.js +2 -1
- package/dist/features/composites/kinds.d.ts +10 -1
- package/dist/features/composites/kinds.js.map +1 -1
- package/dist/features/composites/merge.d.ts +24 -0
- package/dist/features/composites/merge.js +50 -0
- package/dist/features/composites/merge.js.map +1 -0
- package/dist/features/composites/nodes.d.ts +1 -0
- package/dist/features/composites/nodes.js +1 -1
- 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/react/CompositeView.js +4 -1
- package/dist/features/composites/react/CompositeView.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/i18n/de/composites.js +1 -0
- package/dist/i18n/de/composites.js.map +1 -1
- package/dist/i18n/de/tree.js +1 -0
- package/dist/i18n/de/tree.js.map +1 -1
- package/dist/i18n/de.d.ts +2 -0
- package/dist/i18n/en/composites.js +1 -0
- package/dist/i18n/en/composites.js.map +1 -1
- package/dist/i18n/en/tree.js +1 -0
- package/dist/i18n/en/tree.js.map +1 -1
- package/dist/markdown/MarkdownSurface.vue.d.ts +5 -5
- package/dist/nuxt/module.d.ts +4 -0
- package/dist/server/handlers/ai.d.ts +1 -1
- package/dist/styles/composites.css +10 -1
- package/dist/tree/DocumentTree.js +25 -9
- package/dist/tree/DocumentTree.js.map +1 -1
- package/dist/tree/react/DocumentTree.js +14 -2
- package/dist/tree/react/DocumentTree.js.map +1 -1
- package/dist/tree/tree-host.js +11 -1
- package/dist/tree/tree-host.js.map +1 -1
- package/dist/tree/tree-items.js +3 -1
- package/dist/tree/tree-items.js.map +1 -1
- package/dist/tree/tree-model.js +9 -0
- package/dist/tree/tree-model.js.map +1 -1
- package/dist/vue/AdvancedEditor.vue.d.ts +4 -4
- package/dist/vue/SimpleEditor.vue.d.ts +4 -4
- package/dist/vue/components/EditorSurface.vue.d.ts +4 -4
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tree-model.js","names":[],"sources":["../../src/tree/tree-model.ts"],"sourcesContent":["import type { BlockTransfer } from '../core/block-transfer'\nimport { createStore, type ReadonlyStore } from '../core/store'\nimport { type Basket, basketById, type CompositeKind, kindAccepts } from '../features/composites'\nimport type { Translate } from '../i18n'\nimport { type DropEnv, dropVerdict, type DropVerdict } from './drop-rules'\nimport { remapFolderPath } from './folder-paths'\nimport type { DocumentStore } from './store'\nimport {\n ancestorKeys,\n collectFolderPaths,\n creatableBelow,\n type DragPayload,\n dragPayloadOf,\n EMPTY_OUTLINE,\n filterKinds,\n folderNamesIn,\n isDraggable,\n joinPath,\n type Outline,\n parentPath,\n type TreeItem,\n VIRTUAL_ROOT,\n} from './tree-items'\nimport { deriveTree, filterQuery, type TreeRow, type TreeView } from './tree-rows'\nimport type { NodeFilters, TreeViewModel } from './tree-view-model'\nimport type { DocumentSummary, TreeFolder } from './types'\n\n// One framework-free model per `DocumentTree`, rendered by the Vue and the React component alike. It owns what the\n// tree remembers (open rows, kind filters, the title filter, the selection, a drag, a folder being renamed or created)\n// and checks all of it against the tree after every change of the store, the outline or the view state, so a key of\n// something that moved or vanished never lingers. It never calls the store or the editor to change something: it emits\n// `TreeCommand`s to the `execute` it was given and follows their result.\n\n/** What the model asks its host to do; the host reports whether it happened. */\nexport type TreeCommand\n = | { type: 'openDocument', id: string }\n | { type: 'createDocument', folder: string }\n | { type: 'moveDocument', id: string, folder: string }\n | { type: 'removeDocument', id: string, folder: string }\n | { type: 'createFolder', path: string }\n | { type: 'moveFolder', from: string, to: string }\n | { type: 'removeFolder', path: string }\n /** Moves the block into the Baustein `targetId` (`null` = the end of the document). */\n | { type: 'moveBlock', id: string, targetId: string | null }\n | { type: 'revealBlock', id: string | null, pos: number }\n /** Adds an Ordner-Baustein to the Baustein `targetId` (`null` = the end of the document). */\n | { type: 'createBausteinFolder', targetId: string | null }\n /** Lets the user pick files and imports them into the Baustein `targetId` (`null` = the end of the document); `false` when none were imported. */\n | { type: 'importFiles', targetId: string | null }\n | { type: 'warn', title: string, description: string }\n /** Inserts a Baustein dragged in from another surface or tree at the end of the Baustein `targetId` (`null` = the end of the document); `menu`: offer the transforms at `x`, `y` first. */\n | { type: 'transferBlock', payload: BlockTransfer, targetId: string | null, menu: boolean, x: number, y: number }\n /** Puts the editor into focus mode on the Baustein `id` (`null` = leaves focus mode); sent after the tree's own focus changed. */\n | { type: 'focusBlock', id: string | null }\n\n/** Runs a command and resolves whether it happened. Never rejects: the host reports its own failures. */\nexport type TreeExecutor = (command: TreeCommand) => boolean | Promise<boolean>\n\n/** What the model needs from the open document's editor. */\nexport interface TreeEditor {\n kinds: readonly CompositeKind[]\n /** The baskets a Baustein can be put into (colour dots on the rows). */\n baskets: readonly Basket[]\n /** The outline in `structure`: Bausteine in `'composite'` structure, else the headings. Empty once the editor is gone. */\n outline: (structure: string) => Outline\n /** Whether a block may move into a Baustein, judged on the live document. */\n moveVerdict: NonNullable<DropEnv['moveVerdict']>\n /** Whether the editor takes blocks from outside: it has the transfer feature's drop target and its `transferBlock` command. */\n canTransfer: () => boolean\n /** The block id of the Baustein the editor is focused on (focus mode), `null` without focus. The model mirrors it into the tree. */\n focusedId: () => string | null\n /** `listener` runs after the document or the editor's focus changed; returns the unsubscribe function. */\n onChange: (listener: () => void) => () => void\n}\n\n/** What the surrounding app decides: the open editor and the `blocks.structure` / `blocks.treeRoot` settings. */\nexport interface TreeContext {\n editor: TreeEditor | undefined\n structure: string\n treeRoot: string\n}\n\nexport interface TreeModelOptions {\n /** Words the menus, the drop refusals and the label of an untitled open document; the framework layer passes the context's `t`. */\n t: Translate\n store: DocumentStore\n /** The view state shared by the trees of one app: open store items and kind filters (persisted). */\n view: TreeViewModel\n execute: TreeExecutor\n context: TreeContext\n /** The folder new documents and folders go to; default the root. */\n selectedFolder?: string\n /** How long the outline waits for the document to settle before it is read again; default 150 ms. */\n outlineDebounceMs?: number\n}\n\n/** A drag in progress. */\nexport interface TreeDrag {\n source: DragPayload\n /** Key of the dragged row (`''` for a `foreign-block`, which has no row here) */\n sourceKey: string\n /** Key of the row under the pointer */\n hover: string | null\n /** What dropping on `hover` would do; `null` without a `hover` */\n verdict: DropVerdict | null\n}\n\n/** A folder being renamed. */\nexport interface TreeRename {\n /** Key of the folder's row */\n key: string\n path: string\n /** Its name when renaming started */\n base: string\n draft: string\n error: string | null\n}\n\n/** A folder being named. */\nexport interface TreeCreateFolder {\n /** Folder path the folder is created in */\n parent: string\n draft: string\n error: string | null\n}\n\n/** Everything a renderer needs. Fields below `view` are what the derived `view` was computed from and what `rowOf` reads. */\nexport interface TreeState {\n /** The loaded folder tree: `undefined` = not loaded yet, `null` = loading failed. */\n tree: TreeFolder | null | undefined\n documents: readonly DocumentSummary[]\n activeId: string | undefined\n /** The open document is the root (virtual mode) instead of the store's folders. */\n virtual: boolean\n structure: string\n kinds: readonly CompositeKind[]\n /** The open editor's baskets (colours of the row dots). */\n baskets: readonly Basket[]\n hasEditor: boolean\n outline: Outline\n nodeFilters: NodeFilters\n /** The basket ids the tree shows (`[]` = all). */\n basketFilter: readonly string[]\n /** Key of the focused row: the tree lists only its children. `null` = no focus. */\n focusKey: string | null\n expanded: readonly string[]\n collapsedOutline: readonly string[]\n /** What the title filter input holds. */\n filterText: string\n filterOverrides: Readonly<Record<string, boolean>>\n /** The folder new documents, folders and host imports go to. */\n selectedFolder: string\n /** Virtual mode: block ID of the selected Baustein that takes Bausteine; `null` = the document itself. */\n virtualTarget: string | null\n drag: TreeDrag | null\n renaming: TreeRename | null\n creatingFolder: TreeCreateFolder | null\n /** Key of the row whose deletion is running. */\n removing: string | null\n view: TreeView\n /** The unfiltered items from the top down to the focused one (the breadcrumb); empty without a focus. Derived with `view`. */\n focusPath: readonly TreeItem[]\n}\n\n/** One row of a row's menu. */\nexport interface TreeMenuEntry {\n label: string\n icon: string\n run: () => void\n}\n\n/** How a renderer draws one row. */\nexport interface TreeRowState extends TreeRow {\n /** The row's document is the open one. */\n active: boolean\n /** The row is the selected folder, or (virtual mode) the selected Baustein. */\n selected: boolean\n /** What dropping the drag on this row would do, while the pointer is over it. */\n drop: DropVerdict | null\n renaming: TreeRename | null\n removing: boolean\n /** The kinds the row's kind filter can hide below it, and the ones it hides. */\n filterKinds: readonly CompositeKind[]\n hiddenKinds: readonly string[]\n /** The row offers a kind filter. */\n showFilter: boolean\n}\n\nexport interface TreeModel {\n readonly state: ReadonlyStore<TreeState>\n /** The open editor or a setting changed. */\n setContext: (context: TreeContext) => void\n /** The host selected another folder (it controls the value). */\n setSelectedFolder: (path: string) => void\n\n // --- what is open, filtered, typed\n /** Opens or closes a row; while the title filter is set the choice is discarded when it is cleared. */\n setOpen: (key: string, open: boolean) => void\n toggle: (key: string) => void\n /** Opens the rows (also during a title filter); closed rows are left alone otherwise. */\n expand: (keys: readonly string[]) => void\n /** Filters the rows by title (case-insensitive substring); `''` clears it and restores the opened rows from before. */\n setFilterText: (text: string) => void\n setKindHidden: (key: string, kind: string, hidden: boolean) => void\n clearFilter: (key: string) => void\n clearAllFilters: () => void\n /** Shows (`shown`) or stops showing the Bausteine of the basket; no basket shown = no filter. */\n setBasketShown: (id: string, shown: boolean) => void\n clearBasketFilter: () => void\n /** Focuses a Baustein row: the tree lists only its children and the editor hides everything else. */\n focus: (key: string) => void\n /** Leaves focus mode (tree and editor). */\n defocus: () => void\n\n // --- rows\n /** A row was chosen (click, Enter). */\n select: (item: TreeItem) => void\n /** `select`, and a folder or the root toggles. */\n activate: (item: TreeItem) => void\n addMenu: (item: TreeItem) => TreeMenuEntry[][]\n remove: (item: TreeItem) => Promise<void>\n\n // --- drag and drop\n isDraggable: (item: TreeItem) => boolean\n /** Starts dragging `item`; returns what the drag carries, `null` when `item` cannot be dragged. */\n dragStart: (item: TreeItem) => DragPayload | null\n /** The pointer is over `item`; returns the verdict (`null` without a drag). Only an `ok` one is a drop target. */\n dragOver: (item: TreeItem) => DropVerdict | null\n /** The pointer left `item` for good (not into one of its parts). */\n dragLeave: (item: TreeItem) => void\n dragEnd: () => void\n drop: (item: TreeItem) => Promise<void>\n /**\n * A Baustein from another surface or tree (`BLOCK_MIME`) is over `item`; returns the verdict, `null` while this\n * tree's own drag is running. Only an `ok` one is a drop target.\n */\n foreignDragOver: (item: TreeItem) => DropVerdict | null\n /** Drops the foreign Baustein `payload` on `item`: inserts a copy at the end of that Baustein (`menu`: offers the transforms at `x`, `y` instead). */\n dropForeign: (item: TreeItem, payload: BlockTransfer, menu: boolean, x: number, y: number) => Promise<void>\n\n // --- renaming and creating folders\n startRename: (item: TreeItem) => void\n setRenameDraft: (text: string) => void\n cancelRename: () => void\n commitRename: () => Promise<void>\n /** The rename field lost focus: commit, or give up with a warning when the name is invalid. */\n blurRename: () => Promise<void>\n startCreateFolder: (parent: string) => void\n setFolderDraft: (text: string) => void\n cancelCreateFolder: () => void\n commitCreateFolder: () => Promise<void>\n\n dispose: () => void\n}\n\nconst NO_DOCUMENTS: readonly DocumentSummary[] = []\nconst NO_KINDS: readonly CompositeKind[] = []\nconst NO_BASKETS: readonly Basket[] = []\nconst NO_FILTERS: Readonly<Record<string, boolean>> = {}\nconst UNSET = Symbol('unset')\n\nconst isOutlineKey = (key: string) => key.startsWith('outline:')\n\n/** The state `core` holds: everything of `TreeState` but what is derived from the view. */\ntype TreeCore = Omit<TreeState, 'view' | 'focusPath'>\n\nconst withView = (c: TreeCore, view: TreeView): TreeState => ({ ...c, view, focusPath: view.focusPath })\n\nfunction sameVerdict(a: DropVerdict | null, b: DropVerdict | null): boolean {\n if (a === b) return true\n if (!a || !b) return false\n return a.ok ? b.ok : !b.ok && a.reason === b.reason\n}\n\n/** A row's state in `state` (`item` is one of `state.view.items`). */\nexport function rowOf(state: TreeState, item: TreeItem, t: Translate): TreeRowState {\n const hidden = state.nodeFilters[item.key] ?? []\n const kinds = filterKinds(item, { structure: state.structure, activeId: state.activeId, kinds: state.kinds, t })\n const virtualTarget = state.virtual && (item.key === VIRTUAL_ROOT ? state.virtualTarget === null : !!item.blockId && item.blockId === state.virtualTarget)\n return {\n ...state.view.rows.get(item.key)!,\n active: item.id !== undefined && item.id === state.activeId,\n selected: (item.type !== 'document' && item.path === state.selectedFolder) || virtualTarget,\n drop: state.drag?.hover === item.key ? state.drag.verdict : null,\n renaming: state.renaming?.key === item.key ? state.renaming : null,\n removing: state.removing === item.key,\n filterKinds: kinds,\n hiddenKinds: hidden,\n showFilter: kinds.length > 0 && (item.type === 'root' || item.type === 'folder' || !!item.children?.length || hidden.length > 0),\n }\n}\n\n/** A tree model over `options.store`; call `dispose` when its tree goes away. */\nexport function createTreeModel(options: TreeModelOptions): TreeModel {\n const { store, view: shared, execute, t } = options\n const debounceMs = options.outlineDebounceMs ?? 150\n\n let editor = options.context.editor\n let structure = options.context.structure\n let treeRoot = options.context.treeRoot\n let unwatchEditor = editor?.onChange(onEditorChange)\n /** The focus the editor last showed that the tree took over (or already had); a change of the editor's focus is told apart from the tree's own by comparing against it. */\n let seenFocus: string | null = null\n let outlineTimer: ReturnType<typeof setTimeout> | undefined\n /** A folder move the host is running: until it is done, a selected folder at the old path follows to the new one. */\n let pendingMove: { from: string, to: string } | undefined\n let disposed = false\n\n const isVirtual = () => treeRoot === 'file' && structure === 'composite' && !!editor\n\n let core: TreeCore = {\n tree: store.tree.get(),\n documents: store.documents.get() ?? NO_DOCUMENTS,\n activeId: store.activeId.get(),\n virtual: isVirtual(),\n structure,\n kinds: editor?.kinds ?? NO_KINDS,\n baskets: editor?.baskets ?? NO_BASKETS,\n hasEditor: !!editor,\n outline: editor ? editor.outline(structure) : EMPTY_OUTLINE,\n nodeFilters: shared.nodeFilters.get(),\n basketFilter: shared.basketFilter.get(),\n focusKey: null,\n expanded: shared.expanded.get(),\n collapsedOutline: [],\n filterText: '',\n filterOverrides: NO_FILTERS,\n selectedFolder: options.selectedFolder ?? '',\n virtualTarget: null,\n drag: null,\n renaming: null,\n creatingFolder: null,\n removing: null,\n }\n let lastView: { deps: readonly unknown[], view: TreeView } | undefined\n let lastTree: TreeFolder | null | undefined | typeof UNSET = UNSET\n let folderPaths = new Set<string>()\n let lastActiveFolder: string | undefined | typeof UNSET = UNSET\n let lastActiveId: string | undefined | typeof UNSET = UNSET\n\n const dropEnv = (): DropEnv => ({ virtual: core.virtual, moveVerdict: editor?.moveVerdict, canTransfer: editor?.canTransfer() ?? false, t })\n\n function viewOf(c: TreeCore): TreeView {\n const deps = [c.tree, c.documents, c.activeId, c.virtual, c.outline, c.kinds, c.nodeFilters, c.basketFilter, c.baskets, c.focusKey, c.expanded, c.collapsedOutline, c.filterText, c.filterOverrides]\n if (lastView && deps.every((dep, i) => Object.is(dep, lastView!.deps[i]))) return lastView.view\n // A basket the open editor does not offer cannot be unchecked in the filter menu, so it never filters.\n const basketFilter = c.basketFilter.filter(id => basketById(c.baskets, id) !== undefined)\n const view = deriveTree({ ...c, basketFilter, t, select: selectItem })\n lastView = { deps, view }\n return view\n }\n\n const renameError = (draft: string, path: string, base: string, tree: TreeFolder | null | undefined) =>\n draft.trim() === base ? null : store.validateName(draft, folderNamesIn(tree, parentPath(path), path))\n const folderError = (draft: string, parent: string, tree: TreeFolder | null | undefined) =>\n draft.trim() ? store.validateName(draft, folderNamesIn(tree, parent)) : null\n\n /** Measures everything the tree remembers against the current tree: what is gone is dropped, what depends on the tree is recomputed. */\n function reconcile(c: TreeCore, view: TreeView): TreeCore {\n let next = c\n if (c.tree !== lastTree) {\n lastTree = c.tree\n folderPaths = new Set<string>()\n if (c.tree) collectFolderPaths(c.tree, folderPaths)\n if (c.tree && !folderPaths.has(next.selectedFolder)) {\n const followed = pendingMove ? remapFolderPath(next.selectedFolder, pendingMove.from, pendingMove.to) : ''\n next = { ...next, selectedFolder: folderPaths.has(followed) ? followed : '' }\n }\n }\n if (next.virtualTarget !== null && (!next.virtual || !view.keys.has(`outline:${next.virtualTarget}`))) next = { ...next, virtualTarget: null }\n if (next.focusKey !== null && !view.keys.has(next.focusKey)) next = { ...next, focusKey: null }\n if (next.renaming) {\n const r = next.renaming\n if (!view.keys.has(r.key)) next = { ...next, renaming: null }\n else {\n const error = renameError(r.draft, r.path, r.base, next.tree)\n if (error !== r.error) next = { ...next, renaming: { ...r, error } }\n }\n }\n if (next.creatingFolder) {\n const f = next.creatingFolder\n if (next.tree && !folderPaths.has(f.parent)) next = { ...next, creatingFolder: null }\n else {\n const error = folderError(f.draft, f.parent, next.tree)\n if (error !== f.error) next = { ...next, creatingFolder: { ...f, error } }\n }\n }\n if (next.drag) {\n const d = next.drag\n if ((d.source.type !== 'foreign-block' && !view.keys.has(d.sourceKey)) || (d.hover !== null && !view.keys.has(d.hover))) next = { ...next, drag: null }\n else if (d.hover !== null) {\n const target = view.rows.get(d.hover)?.item\n const verdict = target ? dropVerdict(d.source, target, dropEnv()) : d.verdict\n if (!sameVerdict(verdict, d.verdict)) next = { ...next, drag: { ...d, verdict } }\n }\n }\n return next\n }\n\n const state = createStore<TreeState>(withView(core, viewOf(core)))\n\n function publish(c: TreeCore) {\n if (disposed) return\n const view = viewOf(c)\n core = reconcile(c, view)\n const next = withView(core, view)\n const current = state.get()\n if ((Object.keys(next) as (keyof TreeState)[]).every(key => Object.is(next[key], current[key]))) return\n state.set(next)\n }\n\n const patch = (changes: Partial<TreeCore>) => publish({ ...core, ...changes })\n\n // --- sources ---------------------------------------------------------------------------------------------------\n\n /** Reads the store and the shared view state; what opening a document shows is opened. */\n function sync() {\n if (disposed) return\n const documents = store.documents.get() ?? NO_DOCUMENTS\n const activeId = store.activeId.get()\n publish({ ...core, tree: store.tree.get(), documents, activeId, nodeFilters: shared.nodeFilters.get(), basketFilter: shared.basketFilter.get(), expanded: shared.expanded.get() })\n // Opening a document (also by URL, or after a move) shows it: its folders open and its folder becomes the selected one.\n const activeFolder = documents.find(d => d.id === activeId)?.folder\n if (activeFolder !== lastActiveFolder) {\n lastActiveFolder = activeFolder\n expand(ancestorKeys(activeFolder ?? ''))\n if (activeFolder !== undefined) setSelectedFolder(activeFolder)\n }\n if (activeId !== lastActiveId) {\n lastActiveId = activeId\n if (activeId) expand([`doc:${activeId}`])\n }\n }\n\n const unsubscribe = [\n store.tree.subscribe(sync),\n store.documents.subscribe(sync),\n store.activeId.subscribe(sync),\n shared.nodeFilters.subscribe(sync),\n shared.basketFilter.subscribe(sync),\n shared.expanded.subscribe(sync),\n ]\n\n function readOutline() {\n patch({ outline: editor ? editor.outline(structure) : EMPTY_OUTLINE })\n mirrorFocus()\n }\n\n /**\n * The editor's focus mode changed on its own (the focus chip, a block's „Fokussieren“, the focused Baustein vanished):\n * the tree follows without a command. A Baustein the outline does not know yet is retried after the next outline read.\n */\n function mirrorFocus() {\n const id = editor?.focusedId() ?? null\n if (id === seenFocus) return\n if (id === null) {\n seenFocus = null\n if (core.focusKey !== null) patch({ focusKey: null })\n return\n }\n const key = `outline:${id}`\n if (core.focusKey !== key) {\n const item = state.get().view.index.get(key)?.item\n if (item?.type !== 'composite') return\n patch({ focusKey: key })\n }\n seenFocus = id\n }\n\n // The outline is read when the document changed and has been quiet for a moment; a drag in progress is checked at once, and so is the editor's focus.\n function onEditorChange() {\n clearTimeout(outlineTimer)\n outlineTimer = setTimeout(readOutline, debounceMs)\n if (core.drag) publish(core)\n mirrorFocus()\n }\n\n function setContext(context: TreeContext) {\n if (context.editor === editor && context.structure === structure && context.treeRoot === treeRoot) return\n const editorChanged = context.editor !== editor\n const wasVirtual = core.virtual\n editor = context.editor\n structure = context.structure\n treeRoot = context.treeRoot\n clearTimeout(outlineTimer)\n if (editorChanged) {\n seenFocus = null\n unwatchEditor?.()\n unwatchEditor = editor?.onChange(onEditorChange)\n }\n patch({\n virtual: isVirtual(),\n structure,\n kinds: editor?.kinds ?? NO_KINDS,\n baskets: editor?.baskets ?? NO_BASKETS,\n ...(editorChanged ? { focusKey: null } : {}),\n hasEditor: !!editor,\n outline: editor ? editor.outline(structure) : EMPTY_OUTLINE,\n })\n if (core.virtual && !wasVirtual) expand([VIRTUAL_ROOT])\n mirrorFocus()\n }\n\n // --- open, filtered, typed -------------------------------------------------------------------------------------\n\n const filtering = () => filterQuery(core.filterText) !== ''\n\n function setOpen(key: string, open: boolean) {\n if (filtering()) patch({ filterOverrides: { ...core.filterOverrides, [key]: open } })\n else if (isOutlineKey(key)) patch({ collapsedOutline: open ? core.collapsedOutline.filter(k => k !== key) : [...core.collapsedOutline.filter(k => k !== key), key] })\n else if (open) shared.expand([key])\n else shared.expanded.set(shared.expanded.get().filter(k => k !== key))\n }\n\n function expand(keys: readonly string[]) {\n const outlineKeys = keys.filter(isOutlineKey)\n const { filterOverrides } = core\n const overridden = keys.some(key => key in filterOverrides)\n if (overridden || outlineKeys.some(key => core.collapsedOutline.includes(key))) {\n patch({\n collapsedOutline: core.collapsedOutline.filter(key => !outlineKeys.includes(key)),\n filterOverrides: overridden ? Object.fromEntries(Object.entries(filterOverrides).filter(([key]) => !keys.includes(key))) : filterOverrides,\n })\n }\n shared.expand(keys.filter(key => !isOutlineKey(key)))\n }\n\n function setFilterText(text: string) {\n patch({ filterText: text, filterOverrides: filterQuery(text) ? core.filterOverrides : NO_FILTERS })\n }\n\n // --- focus -----------------------------------------------------------------------------------------------------\n\n /** Only a Baustein the editor can address (it has a block ID) can be focused. */\n function focus(key: string) {\n const item = state.get().view.index.get(key)?.item\n if (item?.type !== 'composite' || !item.blockId) return\n patch({ focusKey: key })\n void execute({ type: 'focusBlock', id: item.blockId })\n }\n\n function defocus() {\n if (core.focusKey === null) return\n patch({ focusKey: null })\n void execute({ type: 'focusBlock', id: null })\n }\n\n // --- selection -------------------------------------------------------------------------------------------------\n\n function setSelectedFolder(path: string) {\n patch({ selectedFolder: path })\n }\n\n function selectItem(item: TreeItem) {\n if (core.renaming?.key === item.key) return\n if (item.key === VIRTUAL_ROOT) return patch({ virtualTarget: null })\n if (item.type === 'document') {\n setSelectedFolder(item.folder ?? '')\n void execute({ type: 'openDocument', id: item.id! })\n }\n else if (item.type === 'composite' || item.type === 'heading') {\n void execute({ type: 'revealBlock', id: item.blockId ?? null, pos: item.pos! })\n const takesBausteine = !!item.kind && core.kinds.some(kind => kindAccepts(core.kinds, item.kind!, kind.id))\n if (core.virtual && item.blockId && takesBausteine) patch({ virtualTarget: item.blockId })\n }\n else {\n setSelectedFolder(item.path ?? '')\n }\n }\n\n function toggle(key: string) {\n setOpen(key, !state.get().view.rows.get(key)?.open)\n }\n\n /** A folder moved from `from` to `to`: its open/selected state follows it. */\n function followFolderMove(from: string, to: string) {\n shared.followFolderMove(from, to)\n patch({\n selectedFolder: remapFolderPath(core.selectedFolder, from, to),\n filterOverrides: Object.fromEntries(Object.entries(core.filterOverrides).map(([key, open]) => [key.startsWith('folder:') ? `folder:${remapFolderPath(key.slice(7), from, to)}` : key, open])),\n })\n expand(ancestorKeys(parentPath(to)))\n }\n\n async function moveFolder(from: string, to: string) {\n pendingMove = { from, to }\n const moved = await execute({ type: 'moveFolder', from, to })\n pendingMove = undefined\n if (moved) followFolderMove(from, to)\n }\n\n // --- drag and drop ---------------------------------------------------------------------------------------------\n\n function dragStart(item: TreeItem) {\n if (core.renaming?.key === item.key || !isDraggable(item, core.virtual)) return null\n const source = dragPayloadOf(item)\n patch({ drag: { source, sourceKey: item.key, hover: null, verdict: null } })\n return source\n }\n\n function dragOver(item: TreeItem) {\n const drag = core.drag\n if (!drag) return null\n const verdict = dropVerdict(drag.source, item, dropEnv())\n if (drag.hover !== item.key || !sameVerdict(drag.verdict, verdict)) patch({ drag: { ...drag, hover: item.key, verdict } })\n return verdict\n }\n\n function foreignDragOver(item: TreeItem) {\n const drag = core.drag\n if (drag && drag.source.type !== 'foreign-block') return null\n const source: DragPayload = { type: 'foreign-block' }\n const verdict = dropVerdict(source, item, dropEnv())\n if (!drag || drag.hover !== item.key || !sameVerdict(drag.verdict, verdict)) patch({ drag: { source, sourceKey: '', hover: item.key, verdict } })\n return verdict\n }\n\n async function dropForeign(item: TreeItem, payload: BlockTransfer, menu: boolean, x: number, y: number) {\n // This tree's own drag (a row also writes the block payload) is a move, not a transfer.\n if (core.drag && core.drag.source.type !== 'foreign-block') return\n patch({ drag: null })\n if (!dropVerdict({ type: 'foreign-block' }, item, dropEnv()).ok) return\n const targetId = item.key === VIRTUAL_ROOT ? null : item.blockId!\n // A throwing executor (the contract says it never does) must not leave the drop handler with an unhandled rejection.\n let done = false\n try {\n done = await execute({ type: 'transferBlock', payload, targetId, menu, x, y })\n }\n catch {\n return\n }\n if (done && targetId && !menu) expand([`outline:${targetId}`])\n }\n\n async function drop(item: TreeItem) {\n const drag = core.drag\n patch({ drag: null })\n if (!drag || !dropVerdict(drag.source, item, dropEnv()).ok) return\n const { source } = drag\n if (source.type === 'composite') {\n const targetId = item.key === VIRTUAL_ROOT ? null : item.blockId!\n if (await execute({ type: 'moveBlock', id: source.blockId, targetId }) && targetId) expand([`outline:${targetId}`])\n return\n }\n // A foreign Baustein is dropped through `dropForeign`, which reads its payload; it is no move of this tree.\n if (source.type === 'foreign-block') return\n const targetPath = item.path!\n if (source.type === 'document') {\n if (await execute({ type: 'moveDocument', id: source.id!, folder: targetPath })) expand(ancestorKeys(targetPath))\n return\n }\n await moveFolder(source.path, joinPath(targetPath, source.path.slice(source.path.lastIndexOf('/') + 1)))\n }\n\n // --- renaming, creating ----------------------------------------------------------------------------------------\n\n function startRename(item: TreeItem) {\n if (item.type !== 'folder') return\n patch({ renaming: { key: item.key, path: item.path!, base: item.label, draft: item.label, error: null } })\n }\n\n async function commitRename() {\n const r = core.renaming\n // An invalid name keeps the field open with its inline error.\n if (!r || r.error) return\n const name = r.draft.trim()\n patch({ renaming: null })\n if (name !== r.base) await moveFolder(r.path, joinPath(parentPath(r.path), name))\n }\n\n async function blurRename() {\n const r = core.renaming\n if (!r) return\n if (r.error) {\n void execute({ type: 'warn', title: t('tree.folder.renameFailed'), description: r.error })\n patch({ renaming: null })\n return\n }\n await commitRename()\n }\n\n function startCreateFolder(parent: string) {\n patch({ selectedFolder: parent, creatingFolder: { parent, draft: '', error: null } })\n }\n\n async function commitCreateFolder() {\n const f = core.creatingFolder\n if (!f) return\n if (!f.draft.trim()) return patch({ creatingFolder: null })\n if (f.error) return\n patch({ creatingFolder: null })\n if (await execute({ type: 'createFolder', path: joinPath(f.parent, f.draft.trim()) })) expand(ancestorKeys(f.parent))\n }\n\n // --- menus, deleting -------------------------------------------------------------------------------------------\n\n async function createDocumentIn(folder: string) {\n setSelectedFolder(folder)\n if (await execute({ type: 'createDocument', folder })) expand(ancestorKeys(folder))\n }\n\n /** Runs `command` for the Baustein of `item` (the file itself when it has none) and shows the result. */\n async function inComposite(item: TreeItem, command: TreeCommand) {\n if (await execute(command)) expand([item.blockId ? `outline:${item.blockId}` : item.key])\n }\n\n /**\n * What can be created below `item`: folders of the store take documents and sub-folders, the open file (as the root or\n * as a document row) and its Bausteine take what their kind accepts. Other rows take nothing. Folders also list\n * „Umbenennen“ here: renaming a document happens in the editor's title field.\n */\n function addMenu(item: TreeItem): TreeMenuEntry[][] {\n const groups: TreeMenuEntry[][] = []\n if (item.key !== VIRTUAL_ROOT && (item.type === 'root' || item.type === 'folder')) {\n const path = item.path!\n groups.push([\n { label: t('tree.menu.newDocument'), icon: 'i-lucide-file-plus', run: () => void createDocumentIn(path) },\n { label: item.type === 'root' ? t('tree.menu.newFolder') : t('tree.menu.newSubfolder'), icon: 'i-lucide-folder-plus', run: () => startCreateFolder(path) },\n ])\n }\n else {\n const can = creatableBelow(item, { structure: core.structure, hasEditor: core.hasEditor, activeId: core.activeId, kinds: core.kinds })\n const targetId = item.blockId ?? null\n const entries: TreeMenuEntry[] = []\n if (can.folder) entries.push({ label: t('tree.menu.newCompositeFolder'), icon: 'i-lucide-folder-plus', run: () => void inComposite(item, { type: 'createBausteinFolder', targetId }) })\n if (can.document) entries.push({ label: t('tree.menu.importFile'), icon: 'i-lucide-file-up', run: () => void inComposite(item, { type: 'importFiles', targetId }) })\n if (entries.length) groups.push(entries)\n }\n if (item.type === 'folder') groups.push([{ label: t('tree.menu.rename'), icon: 'i-lucide-pencil', run: () => startRename(item) }])\n return groups\n }\n\n async function remove(item: TreeItem) {\n patch({ removing: item.key })\n try {\n await execute(item.type === 'document' ? { type: 'removeDocument', id: item.id!, folder: item.folder ?? '' } : { type: 'removeFolder', path: item.path! })\n }\n finally {\n patch({ removing: null })\n }\n }\n\n sync()\n mirrorFocus()\n\n return {\n state,\n setContext,\n setSelectedFolder,\n setOpen,\n toggle,\n expand,\n setFilterText,\n setKindHidden: (key, kind, hidden) => shared.setKindHidden(key, kind, hidden),\n clearFilter: key => shared.clearFilter(key),\n clearAllFilters: () => shared.clearAllFilters(),\n setBasketShown: (id, shown) => shared.setBasketShown(id, shown),\n clearBasketFilter: () => shared.clearBasketFilter(),\n focus,\n defocus,\n select: selectItem,\n activate(item) {\n selectItem(item)\n if (item.type === 'root' || item.type === 'folder') toggle(item.key)\n },\n addMenu,\n remove,\n isDraggable: item => core.renaming?.key !== item.key && isDraggable(item, core.virtual),\n dragStart,\n dragOver,\n dragLeave(item) {\n // A foreign drag only exists while it is over this tree (no `dragend` reaches here), so leaving a row ends it; the next row's `foreignDragOver` starts it again.\n if (core.drag?.source.type === 'foreign-block') patch({ drag: null })\n else if (core.drag?.hover === item.key) patch({ drag: { ...core.drag, hover: null, verdict: null } })\n },\n dragEnd: () => patch({ drag: null }),\n drop,\n foreignDragOver,\n dropForeign,\n startRename,\n setRenameDraft(text) {\n const r = core.renaming\n if (r) patch({ renaming: { ...r, draft: text, error: renameError(text, r.path, r.base, core.tree) } })\n },\n cancelRename: () => patch({ renaming: null }),\n commitRename,\n blurRename,\n startCreateFolder,\n setFolderDraft(text) {\n const f = core.creatingFolder\n if (f) patch({ creatingFolder: { ...f, draft: text, error: folderError(text, f.parent, core.tree) } })\n },\n cancelCreateFolder: () => patch({ creatingFolder: null }),\n commitCreateFolder,\n dispose() {\n disposed = true\n clearTimeout(outlineTimer)\n unwatchEditor?.()\n for (const stop of unsubscribe) stop()\n },\n }\n}\n"],"mappings":";;;;;;;;AA+PA,MAAM,eAA2C,CAAC;AAClD,MAAM,WAAqC,CAAC;AAC5C,MAAM,aAAgC,CAAC;AACvC,MAAM,aAAgD,CAAC;AACvD,MAAM,QAAQ,OAAO,OAAO;AAE5B,MAAM,gBAAgB,QAAgB,IAAI,WAAW,UAAU;AAK/D,MAAM,YAAY,GAAa,UAA+B;CAAE,GAAG;CAAG;CAAM,WAAW,KAAK;AAAU;AAEtG,SAAS,YAAY,GAAuB,GAAgC;CAC1E,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO;CACrB,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE;AAC/C;;AAGA,SAAgB,MAAM,OAAkB,MAAgB,GAA4B;CAClF,MAAM,SAAS,MAAM,YAAY,KAAK,QAAQ,CAAC;CAC/C,MAAM,QAAQ,YAAY,MAAM;EAAE,WAAW,MAAM;EAAW,UAAU,MAAM;EAAU,OAAO,MAAM;EAAO;CAAE,CAAC;CAC/G,MAAM,gBAAgB,MAAM,YAAY,KAAK,QAAA,UAAuB,MAAM,kBAAkB,OAAO,CAAC,CAAC,KAAK,WAAW,KAA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I;GACf,IAAI,KAAK,SAAS,UAAU,KAAK,SAAS,UAAU,OAAO,KAAK,GAAG;EACrE;EACA;EACA;EACA,cAAa,SAAQ,KAAK,UAAU,QAAQ,KAAK,OAAO,YAAY,MAAM,KAAK,OAAO;EACtF;EACA;EACA,UAAU,MAAM;GAEd,IAAI,KAAK,MAAM,OAAO,SAAS,iBAAiB,MAAM,EAAE,MAAM,KAAK,CAAC;QAC/D,IAAI,KAAK,MAAM,UAAU,KAAK,KAAK,MAAM,EAAE,MAAM;IAAE,GAAG,KAAK;IAAM,OAAO;IAAM,SAAS;GAAK,EAAE,CAAC;EACtG;EACA,eAAe,MAAM,EAAE,MAAM,KAAK,CAAC;EACnC;EACA;EACA;EACA;EACA,eAAe,MAAM;GACnB,MAAM,IAAI,KAAK;GACf,IAAI,GAAG,MAAM,EAAE,UAAU;IAAE,GAAG;IAAG,OAAO;IAAM,OAAO,YAAY,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI;GAAE,EAAE,CAAC;EACvG;EACA,oBAAoB,MAAM,EAAE,UAAU,KAAK,CAAC;EAC5C;EACA;EACA;EACA,eAAe,MAAM;GACnB,MAAM,IAAI,KAAK;GACf,IAAI,GAAG,MAAM,EAAE,gBAAgB;IAAE,GAAG;IAAG,OAAO;IAAM,OAAO,YAAY,MAAM,EAAE,QAAQ,KAAK,IAAI;GAAE,EAAE,CAAC;EACvG;EACA,0BAA0B,MAAM,EAAE,gBAAgB,KAAK,CAAC;EACxD;EACA,UAAU;GACR,WAAW;GACX,aAAa,YAAY;GACzB,gBAAgB;GAChB,KAAK,MAAM,QAAQ,aAAa,KAAK;EACvC;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"tree-model.js","names":[],"sources":["../../src/tree/tree-model.ts"],"sourcesContent":["import type { BlockTransfer } from '../core/block-transfer'\nimport { createStore, type ReadonlyStore } from '../core/store'\nimport { type Basket, basketById, type CompositeKind, kindAccepts } from '../features/composites'\nimport type { Translate } from '../i18n'\nimport { type DropEnv, dropVerdict, type DropVerdict } from './drop-rules'\nimport { remapFolderPath } from './folder-paths'\nimport type { DocumentStore } from './store'\nimport {\n ancestorKeys,\n collectFolderPaths,\n creatableBelow,\n type DragPayload,\n dragPayloadOf,\n EMPTY_OUTLINE,\n filterKinds,\n folderNamesIn,\n isDraggable,\n joinPath,\n type Outline,\n parentPath,\n type TreeItem,\n VIRTUAL_ROOT,\n} from './tree-items'\nimport { deriveTree, filterQuery, type TreeRow, type TreeView } from './tree-rows'\nimport type { NodeFilters, TreeViewModel } from './tree-view-model'\nimport type { DocumentSummary, TreeFolder } from './types'\n\n// One framework-free model per `DocumentTree`, rendered by the Vue and the React component alike. It owns what the\n// tree remembers (open rows, kind filters, the title filter, the selection, a drag, a folder being renamed or created)\n// and checks all of it against the tree after every change of the store, the outline or the view state, so a key of\n// something that moved or vanished never lingers. It never calls the store or the editor to change something: it emits\n// `TreeCommand`s to the `execute` it was given and follows their result.\n\n/** What the model asks its host to do; the host reports whether it happened. */\nexport type TreeCommand\n = | { type: 'openDocument', id: string }\n | { type: 'createDocument', folder: string }\n | { type: 'moveDocument', id: string, folder: string }\n | { type: 'removeDocument', id: string, folder: string }\n | { type: 'createFolder', path: string }\n | { type: 'moveFolder', from: string, to: string }\n | { type: 'removeFolder', path: string }\n /** Moves the block into the Baustein `targetId` (`null` = the end of the document). */\n | { type: 'moveBlock', id: string, targetId: string | null }\n | { type: 'revealBlock', id: string | null, pos: number }\n /** Adds an Ordner-Baustein to the Baustein `targetId` (`null` = the end of the document). */\n | { type: 'createBausteinFolder', targetId: string | null }\n /** Lets the user pick files and imports them into the Baustein `targetId` (`null` = the end of the document); `false` when none were imported. */\n | { type: 'importFiles', targetId: string | null }\n | { type: 'warn', title: string, description: string }\n /** Inserts a Baustein dragged in from another surface or tree at the end of the Baustein `targetId` (`null` = the end of the document); `menu`: offer the transforms at `x`, `y` first. */\n | { type: 'transferBlock', payload: BlockTransfer, targetId: string | null, menu: boolean, x: number, y: number }\n /** Puts the editor into focus mode on the Baustein `id` (`null` = leaves focus mode); sent after the tree's own focus changed. */\n | { type: 'focusBlock', id: string | null }\n /** The Baustein `id` absorbs the Baustein that follows it (`mergeCompositeWithNext`); `false` when the editor refuses. */\n | { type: 'mergeBlock', id: string }\n\n/** Runs a command and resolves whether it happened. Never rejects: the host reports its own failures. */\nexport type TreeExecutor = (command: TreeCommand) => boolean | Promise<boolean>\n\n/** What the model needs from the open document's editor. */\nexport interface TreeEditor {\n kinds: readonly CompositeKind[]\n /** The baskets a Baustein can be put into (colour dots on the rows). */\n baskets: readonly Basket[]\n /** The outline in `structure`: Bausteine in `'composite'` structure, else the headings. Empty once the editor is gone. */\n outline: (structure: string) => Outline\n /** Whether a block may move into a Baustein, judged on the live document. */\n moveVerdict: NonNullable<DropEnv['moveVerdict']>\n /** Whether the editor takes blocks from outside: it has the transfer feature's drop target and its `transferBlock` command. */\n canTransfer: () => boolean\n /** The block id of the Baustein the editor is focused on (focus mode), `null` without focus. The model mirrors it into the tree. */\n focusedId: () => string | null\n /** Whether the Baustein `id` can absorb the Baustein that follows it, judged on the live document. */\n canMerge: (id: string) => boolean\n /** `listener` runs after the document or the editor's focus changed; returns the unsubscribe function. */\n onChange: (listener: () => void) => () => void\n}\n\n/** What the surrounding app decides: the open editor and the `blocks.structure` / `blocks.treeRoot` settings. */\nexport interface TreeContext {\n editor: TreeEditor | undefined\n structure: string\n treeRoot: string\n}\n\nexport interface TreeModelOptions {\n /** Words the menus, the drop refusals and the label of an untitled open document; the framework layer passes the context's `t`. */\n t: Translate\n store: DocumentStore\n /** The view state shared by the trees of one app: open store items and kind filters (persisted). */\n view: TreeViewModel\n execute: TreeExecutor\n context: TreeContext\n /** The folder new documents and folders go to; default the root. */\n selectedFolder?: string\n /** How long the outline waits for the document to settle before it is read again; default 150 ms. */\n outlineDebounceMs?: number\n}\n\n/** A drag in progress. */\nexport interface TreeDrag {\n source: DragPayload\n /** Key of the dragged row (`''` for a `foreign-block`, which has no row here) */\n sourceKey: string\n /** Key of the row under the pointer */\n hover: string | null\n /** What dropping on `hover` would do; `null` without a `hover` */\n verdict: DropVerdict | null\n}\n\n/** A folder being renamed. */\nexport interface TreeRename {\n /** Key of the folder's row */\n key: string\n path: string\n /** Its name when renaming started */\n base: string\n draft: string\n error: string | null\n}\n\n/** A folder being named. */\nexport interface TreeCreateFolder {\n /** Folder path the folder is created in */\n parent: string\n draft: string\n error: string | null\n}\n\n/** Everything a renderer needs. Fields below `view` are what the derived `view` was computed from and what `rowOf` reads. */\nexport interface TreeState {\n /** The loaded folder tree: `undefined` = not loaded yet, `null` = loading failed. */\n tree: TreeFolder | null | undefined\n documents: readonly DocumentSummary[]\n activeId: string | undefined\n /** The open document is the root (virtual mode) instead of the store's folders. */\n virtual: boolean\n structure: string\n kinds: readonly CompositeKind[]\n /** The open editor's baskets (colours of the row dots). */\n baskets: readonly Basket[]\n hasEditor: boolean\n outline: Outline\n nodeFilters: NodeFilters\n /** The basket ids the tree shows (`[]` = all). */\n basketFilter: readonly string[]\n /** Key of the focused row: the tree lists only its children. `null` = no focus. */\n focusKey: string | null\n expanded: readonly string[]\n collapsedOutline: readonly string[]\n /** What the title filter input holds. */\n filterText: string\n filterOverrides: Readonly<Record<string, boolean>>\n /** The folder new documents, folders and host imports go to. */\n selectedFolder: string\n /** Virtual mode: block ID of the selected Baustein that takes Bausteine; `null` = the document itself. */\n virtualTarget: string | null\n drag: TreeDrag | null\n renaming: TreeRename | null\n creatingFolder: TreeCreateFolder | null\n /** Key of the row whose deletion is running. */\n removing: string | null\n view: TreeView\n /** The unfiltered items from the top down to the focused one (the breadcrumb); empty without a focus. Derived with `view`. */\n focusPath: readonly TreeItem[]\n}\n\n/** One row of a row's menu. */\nexport interface TreeMenuEntry {\n label: string\n icon: string\n run: () => void\n}\n\n/** How a renderer draws one row. */\nexport interface TreeRowState extends TreeRow {\n /** The row's document is the open one. */\n active: boolean\n /** The row is the selected folder, or (virtual mode) the selected Baustein. */\n selected: boolean\n /** What dropping the drag on this row would do, while the pointer is over it. */\n drop: DropVerdict | null\n renaming: TreeRename | null\n removing: boolean\n /** The kinds the row's kind filter can hide below it, and the ones it hides. */\n filterKinds: readonly CompositeKind[]\n hiddenKinds: readonly string[]\n /** The row offers a kind filter. */\n showFilter: boolean\n}\n\nexport interface TreeModel {\n readonly state: ReadonlyStore<TreeState>\n /** The open editor or a setting changed. */\n setContext: (context: TreeContext) => void\n /** The host selected another folder (it controls the value). */\n setSelectedFolder: (path: string) => void\n\n // --- what is open, filtered, typed\n /** Opens or closes a row; while the title filter is set the choice is discarded when it is cleared. */\n setOpen: (key: string, open: boolean) => void\n toggle: (key: string) => void\n /** Opens the rows (also during a title filter); closed rows are left alone otherwise. */\n expand: (keys: readonly string[]) => void\n /** Filters the rows by title (case-insensitive substring); `''` clears it and restores the opened rows from before. */\n setFilterText: (text: string) => void\n setKindHidden: (key: string, kind: string, hidden: boolean) => void\n clearFilter: (key: string) => void\n clearAllFilters: () => void\n /** Shows (`shown`) or stops showing the Bausteine of the basket; no basket shown = no filter. */\n setBasketShown: (id: string, shown: boolean) => void\n clearBasketFilter: () => void\n /** Focuses a Baustein row: the tree lists only its children and the editor hides everything else. */\n focus: (key: string) => void\n /** Leaves focus mode (tree and editor). */\n defocus: () => void\n /** Whether the Baustein row can be merged with the Baustein after it (it has a block ID and the editor accepts the merge). */\n canMerge: (item: TreeItem) => boolean\n /** Merges the Baustein row with the Baustein after it: the row keeps its title, id and meta and takes over the other one's body and sub-Bausteine. */\n merge: (item: TreeItem) => void\n\n // --- rows\n /** A row was chosen (click, Enter). */\n select: (item: TreeItem) => void\n /** `select`, and a folder or the root toggles. */\n activate: (item: TreeItem) => void\n addMenu: (item: TreeItem) => TreeMenuEntry[][]\n remove: (item: TreeItem) => Promise<void>\n\n // --- drag and drop\n isDraggable: (item: TreeItem) => boolean\n /** Starts dragging `item`; returns what the drag carries, `null` when `item` cannot be dragged. */\n dragStart: (item: TreeItem) => DragPayload | null\n /** The pointer is over `item`; returns the verdict (`null` without a drag). Only an `ok` one is a drop target. */\n dragOver: (item: TreeItem) => DropVerdict | null\n /** The pointer left `item` for good (not into one of its parts). */\n dragLeave: (item: TreeItem) => void\n dragEnd: () => void\n drop: (item: TreeItem) => Promise<void>\n /**\n * A Baustein from another surface or tree (`BLOCK_MIME`) is over `item`; returns the verdict, `null` while this\n * tree's own drag is running. Only an `ok` one is a drop target.\n */\n foreignDragOver: (item: TreeItem) => DropVerdict | null\n /** Drops the foreign Baustein `payload` on `item`: inserts a copy at the end of that Baustein (`menu`: offers the transforms at `x`, `y` instead). */\n dropForeign: (item: TreeItem, payload: BlockTransfer, menu: boolean, x: number, y: number) => Promise<void>\n\n // --- renaming and creating folders\n startRename: (item: TreeItem) => void\n setRenameDraft: (text: string) => void\n cancelRename: () => void\n commitRename: () => Promise<void>\n /** The rename field lost focus: commit, or give up with a warning when the name is invalid. */\n blurRename: () => Promise<void>\n startCreateFolder: (parent: string) => void\n setFolderDraft: (text: string) => void\n cancelCreateFolder: () => void\n commitCreateFolder: () => Promise<void>\n\n dispose: () => void\n}\n\nconst NO_DOCUMENTS: readonly DocumentSummary[] = []\nconst NO_KINDS: readonly CompositeKind[] = []\nconst NO_BASKETS: readonly Basket[] = []\nconst NO_FILTERS: Readonly<Record<string, boolean>> = {}\nconst UNSET = Symbol('unset')\n\nconst isOutlineKey = (key: string) => key.startsWith('outline:')\n\n/** The state `core` holds: everything of `TreeState` but what is derived from the view. */\ntype TreeCore = Omit<TreeState, 'view' | 'focusPath'>\n\nconst withView = (c: TreeCore, view: TreeView): TreeState => ({ ...c, view, focusPath: view.focusPath })\n\nfunction sameVerdict(a: DropVerdict | null, b: DropVerdict | null): boolean {\n if (a === b) return true\n if (!a || !b) return false\n return a.ok ? b.ok : !b.ok && a.reason === b.reason\n}\n\n/** A row's state in `state` (`item` is one of `state.view.items`). */\nexport function rowOf(state: TreeState, item: TreeItem, t: Translate): TreeRowState {\n const hidden = state.nodeFilters[item.key] ?? []\n const kinds = filterKinds(item, { structure: state.structure, activeId: state.activeId, kinds: state.kinds, t })\n const virtualTarget = state.virtual && (item.key === VIRTUAL_ROOT ? state.virtualTarget === null : !!item.blockId && item.blockId === state.virtualTarget)\n return {\n ...state.view.rows.get(item.key)!,\n active: item.id !== undefined && item.id === state.activeId,\n selected: (item.type !== 'document' && item.path === state.selectedFolder) || virtualTarget,\n drop: state.drag?.hover === item.key ? state.drag.verdict : null,\n renaming: state.renaming?.key === item.key ? state.renaming : null,\n removing: state.removing === item.key,\n filterKinds: kinds,\n hiddenKinds: hidden,\n showFilter: kinds.length > 0 && (item.type === 'root' || item.type === 'folder' || !!item.children?.length || hidden.length > 0),\n }\n}\n\n/** A tree model over `options.store`; call `dispose` when its tree goes away. */\nexport function createTreeModel(options: TreeModelOptions): TreeModel {\n const { store, view: shared, execute, t } = options\n const debounceMs = options.outlineDebounceMs ?? 150\n\n let editor = options.context.editor\n let structure = options.context.structure\n let treeRoot = options.context.treeRoot\n let unwatchEditor = editor?.onChange(onEditorChange)\n /** The focus the editor last showed that the tree took over (or already had); a change of the editor's focus is told apart from the tree's own by comparing against it. */\n let seenFocus: string | null = null\n let outlineTimer: ReturnType<typeof setTimeout> | undefined\n /** A folder move the host is running: until it is done, a selected folder at the old path follows to the new one. */\n let pendingMove: { from: string, to: string } | undefined\n let disposed = false\n\n const isVirtual = () => treeRoot === 'file' && structure === 'composite' && !!editor\n\n let core: TreeCore = {\n tree: store.tree.get(),\n documents: store.documents.get() ?? NO_DOCUMENTS,\n activeId: store.activeId.get(),\n virtual: isVirtual(),\n structure,\n kinds: editor?.kinds ?? NO_KINDS,\n baskets: editor?.baskets ?? NO_BASKETS,\n hasEditor: !!editor,\n outline: editor ? editor.outline(structure) : EMPTY_OUTLINE,\n nodeFilters: shared.nodeFilters.get(),\n basketFilter: shared.basketFilter.get(),\n focusKey: null,\n expanded: shared.expanded.get(),\n collapsedOutline: [],\n filterText: '',\n filterOverrides: NO_FILTERS,\n selectedFolder: options.selectedFolder ?? '',\n virtualTarget: null,\n drag: null,\n renaming: null,\n creatingFolder: null,\n removing: null,\n }\n let lastView: { deps: readonly unknown[], view: TreeView } | undefined\n let lastTree: TreeFolder | null | undefined | typeof UNSET = UNSET\n let folderPaths = new Set<string>()\n let lastActiveFolder: string | undefined | typeof UNSET = UNSET\n let lastActiveId: string | undefined | typeof UNSET = UNSET\n\n const dropEnv = (): DropEnv => ({ virtual: core.virtual, moveVerdict: editor?.moveVerdict, canTransfer: editor?.canTransfer() ?? false, t })\n\n function viewOf(c: TreeCore): TreeView {\n const deps = [c.tree, c.documents, c.activeId, c.virtual, c.outline, c.kinds, c.nodeFilters, c.basketFilter, c.baskets, c.focusKey, c.expanded, c.collapsedOutline, c.filterText, c.filterOverrides]\n if (lastView && deps.every((dep, i) => Object.is(dep, lastView!.deps[i]))) return lastView.view\n // A basket the open editor does not offer cannot be unchecked in the filter menu, so it never filters.\n const basketFilter = c.basketFilter.filter(id => basketById(c.baskets, id) !== undefined)\n const view = deriveTree({ ...c, basketFilter, t, select: selectItem })\n lastView = { deps, view }\n return view\n }\n\n const renameError = (draft: string, path: string, base: string, tree: TreeFolder | null | undefined) =>\n draft.trim() === base ? null : store.validateName(draft, folderNamesIn(tree, parentPath(path), path))\n const folderError = (draft: string, parent: string, tree: TreeFolder | null | undefined) =>\n draft.trim() ? store.validateName(draft, folderNamesIn(tree, parent)) : null\n\n /** Measures everything the tree remembers against the current tree: what is gone is dropped, what depends on the tree is recomputed. */\n function reconcile(c: TreeCore, view: TreeView): TreeCore {\n let next = c\n if (c.tree !== lastTree) {\n lastTree = c.tree\n folderPaths = new Set<string>()\n if (c.tree) collectFolderPaths(c.tree, folderPaths)\n if (c.tree && !folderPaths.has(next.selectedFolder)) {\n const followed = pendingMove ? remapFolderPath(next.selectedFolder, pendingMove.from, pendingMove.to) : ''\n next = { ...next, selectedFolder: folderPaths.has(followed) ? followed : '' }\n }\n }\n if (next.virtualTarget !== null && (!next.virtual || !view.keys.has(`outline:${next.virtualTarget}`))) next = { ...next, virtualTarget: null }\n if (next.focusKey !== null && !view.keys.has(next.focusKey)) next = { ...next, focusKey: null }\n if (next.renaming) {\n const r = next.renaming\n if (!view.keys.has(r.key)) next = { ...next, renaming: null }\n else {\n const error = renameError(r.draft, r.path, r.base, next.tree)\n if (error !== r.error) next = { ...next, renaming: { ...r, error } }\n }\n }\n if (next.creatingFolder) {\n const f = next.creatingFolder\n if (next.tree && !folderPaths.has(f.parent)) next = { ...next, creatingFolder: null }\n else {\n const error = folderError(f.draft, f.parent, next.tree)\n if (error !== f.error) next = { ...next, creatingFolder: { ...f, error } }\n }\n }\n if (next.drag) {\n const d = next.drag\n if ((d.source.type !== 'foreign-block' && !view.keys.has(d.sourceKey)) || (d.hover !== null && !view.keys.has(d.hover))) next = { ...next, drag: null }\n else if (d.hover !== null) {\n const target = view.rows.get(d.hover)?.item\n const verdict = target ? dropVerdict(d.source, target, dropEnv()) : d.verdict\n if (!sameVerdict(verdict, d.verdict)) next = { ...next, drag: { ...d, verdict } }\n }\n }\n return next\n }\n\n const state = createStore<TreeState>(withView(core, viewOf(core)))\n\n function publish(c: TreeCore) {\n if (disposed) return\n const view = viewOf(c)\n core = reconcile(c, view)\n const next = withView(core, view)\n const current = state.get()\n if ((Object.keys(next) as (keyof TreeState)[]).every(key => Object.is(next[key], current[key]))) return\n state.set(next)\n }\n\n const patch = (changes: Partial<TreeCore>) => publish({ ...core, ...changes })\n\n // --- sources ---------------------------------------------------------------------------------------------------\n\n /** Reads the store and the shared view state; what opening a document shows is opened. */\n function sync() {\n if (disposed) return\n const documents = store.documents.get() ?? NO_DOCUMENTS\n const activeId = store.activeId.get()\n publish({ ...core, tree: store.tree.get(), documents, activeId, nodeFilters: shared.nodeFilters.get(), basketFilter: shared.basketFilter.get(), expanded: shared.expanded.get() })\n // Opening a document (also by URL, or after a move) shows it: its folders open and its folder becomes the selected one.\n const activeFolder = documents.find(d => d.id === activeId)?.folder\n if (activeFolder !== lastActiveFolder) {\n lastActiveFolder = activeFolder\n expand(ancestorKeys(activeFolder ?? ''))\n if (activeFolder !== undefined) setSelectedFolder(activeFolder)\n }\n if (activeId !== lastActiveId) {\n lastActiveId = activeId\n if (activeId) expand([`doc:${activeId}`])\n }\n }\n\n const unsubscribe = [\n store.tree.subscribe(sync),\n store.documents.subscribe(sync),\n store.activeId.subscribe(sync),\n shared.nodeFilters.subscribe(sync),\n shared.basketFilter.subscribe(sync),\n shared.expanded.subscribe(sync),\n ]\n\n function readOutline() {\n patch({ outline: editor ? editor.outline(structure) : EMPTY_OUTLINE })\n mirrorFocus()\n }\n\n /**\n * The editor's focus mode changed on its own (the focus chip, a block's „Fokussieren“, the focused Baustein vanished):\n * the tree follows without a command. A Baustein the outline does not know yet is retried after the next outline read.\n */\n function mirrorFocus() {\n const id = editor?.focusedId() ?? null\n if (id === seenFocus) return\n if (id === null) {\n seenFocus = null\n if (core.focusKey !== null) patch({ focusKey: null })\n return\n }\n const key = `outline:${id}`\n if (core.focusKey !== key) {\n const item = state.get().view.index.get(key)?.item\n if (item?.type !== 'composite') return\n patch({ focusKey: key })\n }\n seenFocus = id\n }\n\n // The outline is read when the document changed and has been quiet for a moment; a drag in progress is checked at once, and so is the editor's focus.\n function onEditorChange() {\n clearTimeout(outlineTimer)\n outlineTimer = setTimeout(readOutline, debounceMs)\n if (core.drag) publish(core)\n mirrorFocus()\n }\n\n function setContext(context: TreeContext) {\n if (context.editor === editor && context.structure === structure && context.treeRoot === treeRoot) return\n const editorChanged = context.editor !== editor\n const wasVirtual = core.virtual\n editor = context.editor\n structure = context.structure\n treeRoot = context.treeRoot\n clearTimeout(outlineTimer)\n if (editorChanged) {\n seenFocus = null\n unwatchEditor?.()\n unwatchEditor = editor?.onChange(onEditorChange)\n }\n patch({\n virtual: isVirtual(),\n structure,\n kinds: editor?.kinds ?? NO_KINDS,\n baskets: editor?.baskets ?? NO_BASKETS,\n ...(editorChanged ? { focusKey: null } : {}),\n hasEditor: !!editor,\n outline: editor ? editor.outline(structure) : EMPTY_OUTLINE,\n })\n if (core.virtual && !wasVirtual) expand([VIRTUAL_ROOT])\n mirrorFocus()\n }\n\n // --- open, filtered, typed -------------------------------------------------------------------------------------\n\n const filtering = () => filterQuery(core.filterText) !== ''\n\n function setOpen(key: string, open: boolean) {\n if (filtering()) patch({ filterOverrides: { ...core.filterOverrides, [key]: open } })\n else if (isOutlineKey(key)) patch({ collapsedOutline: open ? core.collapsedOutline.filter(k => k !== key) : [...core.collapsedOutline.filter(k => k !== key), key] })\n else if (open) shared.expand([key])\n else shared.expanded.set(shared.expanded.get().filter(k => k !== key))\n }\n\n function expand(keys: readonly string[]) {\n const outlineKeys = keys.filter(isOutlineKey)\n const { filterOverrides } = core\n const overridden = keys.some(key => key in filterOverrides)\n if (overridden || outlineKeys.some(key => core.collapsedOutline.includes(key))) {\n patch({\n collapsedOutline: core.collapsedOutline.filter(key => !outlineKeys.includes(key)),\n filterOverrides: overridden ? Object.fromEntries(Object.entries(filterOverrides).filter(([key]) => !keys.includes(key))) : filterOverrides,\n })\n }\n shared.expand(keys.filter(key => !isOutlineKey(key)))\n }\n\n function setFilterText(text: string) {\n patch({ filterText: text, filterOverrides: filterQuery(text) ? core.filterOverrides : NO_FILTERS })\n }\n\n // --- focus -----------------------------------------------------------------------------------------------------\n\n /** Only a Baustein the editor can address (it has a block ID) can be focused. */\n function focus(key: string) {\n const item = state.get().view.index.get(key)?.item\n if (item?.type !== 'composite' || !item.blockId) return\n patch({ focusKey: key })\n void execute({ type: 'focusBlock', id: item.blockId })\n }\n\n function defocus() {\n if (core.focusKey === null) return\n patch({ focusKey: null })\n void execute({ type: 'focusBlock', id: null })\n }\n\n // --- merge -----------------------------------------------------------------------------------------------------\n\n const canMerge = (item: TreeItem) => item.type === 'composite' && !!item.blockId && !!editor?.canMerge(item.blockId)\n\n function merge(item: TreeItem) {\n if (canMerge(item)) void execute({ type: 'mergeBlock', id: item.blockId! })\n }\n\n // --- selection -------------------------------------------------------------------------------------------------\n\n function setSelectedFolder(path: string) {\n patch({ selectedFolder: path })\n }\n\n function selectItem(item: TreeItem) {\n if (core.renaming?.key === item.key) return\n if (item.key === VIRTUAL_ROOT) return patch({ virtualTarget: null })\n if (item.type === 'document') {\n setSelectedFolder(item.folder ?? '')\n void execute({ type: 'openDocument', id: item.id! })\n }\n else if (item.type === 'composite' || item.type === 'heading') {\n void execute({ type: 'revealBlock', id: item.blockId ?? null, pos: item.pos! })\n const takesBausteine = !!item.kind && core.kinds.some(kind => kindAccepts(core.kinds, item.kind!, kind.id))\n if (core.virtual && item.blockId && takesBausteine) patch({ virtualTarget: item.blockId })\n }\n else {\n setSelectedFolder(item.path ?? '')\n }\n }\n\n function toggle(key: string) {\n setOpen(key, !state.get().view.rows.get(key)?.open)\n }\n\n /** A folder moved from `from` to `to`: its open/selected state follows it. */\n function followFolderMove(from: string, to: string) {\n shared.followFolderMove(from, to)\n patch({\n selectedFolder: remapFolderPath(core.selectedFolder, from, to),\n filterOverrides: Object.fromEntries(Object.entries(core.filterOverrides).map(([key, open]) => [key.startsWith('folder:') ? `folder:${remapFolderPath(key.slice(7), from, to)}` : key, open])),\n })\n expand(ancestorKeys(parentPath(to)))\n }\n\n async function moveFolder(from: string, to: string) {\n pendingMove = { from, to }\n const moved = await execute({ type: 'moveFolder', from, to })\n pendingMove = undefined\n if (moved) followFolderMove(from, to)\n }\n\n // --- drag and drop ---------------------------------------------------------------------------------------------\n\n function dragStart(item: TreeItem) {\n if (core.renaming?.key === item.key || !isDraggable(item, core.virtual)) return null\n const source = dragPayloadOf(item)\n patch({ drag: { source, sourceKey: item.key, hover: null, verdict: null } })\n return source\n }\n\n function dragOver(item: TreeItem) {\n const drag = core.drag\n if (!drag) return null\n const verdict = dropVerdict(drag.source, item, dropEnv())\n if (drag.hover !== item.key || !sameVerdict(drag.verdict, verdict)) patch({ drag: { ...drag, hover: item.key, verdict } })\n return verdict\n }\n\n function foreignDragOver(item: TreeItem) {\n const drag = core.drag\n if (drag && drag.source.type !== 'foreign-block') return null\n const source: DragPayload = { type: 'foreign-block' }\n const verdict = dropVerdict(source, item, dropEnv())\n if (!drag || drag.hover !== item.key || !sameVerdict(drag.verdict, verdict)) patch({ drag: { source, sourceKey: '', hover: item.key, verdict } })\n return verdict\n }\n\n async function dropForeign(item: TreeItem, payload: BlockTransfer, menu: boolean, x: number, y: number) {\n // This tree's own drag (a row also writes the block payload) is a move, not a transfer.\n if (core.drag && core.drag.source.type !== 'foreign-block') return\n patch({ drag: null })\n if (!dropVerdict({ type: 'foreign-block' }, item, dropEnv()).ok) return\n const targetId = item.key === VIRTUAL_ROOT ? null : item.blockId!\n // A throwing executor (the contract says it never does) must not leave the drop handler with an unhandled rejection.\n let done = false\n try {\n done = await execute({ type: 'transferBlock', payload, targetId, menu, x, y })\n }\n catch {\n return\n }\n if (done && targetId && !menu) expand([`outline:${targetId}`])\n }\n\n async function drop(item: TreeItem) {\n const drag = core.drag\n patch({ drag: null })\n if (!drag || !dropVerdict(drag.source, item, dropEnv()).ok) return\n const { source } = drag\n if (source.type === 'composite') {\n const targetId = item.key === VIRTUAL_ROOT ? null : item.blockId!\n if (await execute({ type: 'moveBlock', id: source.blockId, targetId }) && targetId) expand([`outline:${targetId}`])\n return\n }\n // A foreign Baustein is dropped through `dropForeign`, which reads its payload; it is no move of this tree.\n if (source.type === 'foreign-block') return\n const targetPath = item.path!\n if (source.type === 'document') {\n if (await execute({ type: 'moveDocument', id: source.id!, folder: targetPath })) expand(ancestorKeys(targetPath))\n return\n }\n await moveFolder(source.path, joinPath(targetPath, source.path.slice(source.path.lastIndexOf('/') + 1)))\n }\n\n // --- renaming, creating ----------------------------------------------------------------------------------------\n\n function startRename(item: TreeItem) {\n if (item.type !== 'folder') return\n patch({ renaming: { key: item.key, path: item.path!, base: item.label, draft: item.label, error: null } })\n }\n\n async function commitRename() {\n const r = core.renaming\n // An invalid name keeps the field open with its inline error.\n if (!r || r.error) return\n const name = r.draft.trim()\n patch({ renaming: null })\n if (name !== r.base) await moveFolder(r.path, joinPath(parentPath(r.path), name))\n }\n\n async function blurRename() {\n const r = core.renaming\n if (!r) return\n if (r.error) {\n void execute({ type: 'warn', title: t('tree.folder.renameFailed'), description: r.error })\n patch({ renaming: null })\n return\n }\n await commitRename()\n }\n\n function startCreateFolder(parent: string) {\n patch({ selectedFolder: parent, creatingFolder: { parent, draft: '', error: null } })\n }\n\n async function commitCreateFolder() {\n const f = core.creatingFolder\n if (!f) return\n if (!f.draft.trim()) return patch({ creatingFolder: null })\n if (f.error) return\n patch({ creatingFolder: null })\n if (await execute({ type: 'createFolder', path: joinPath(f.parent, f.draft.trim()) })) expand(ancestorKeys(f.parent))\n }\n\n // --- menus, deleting -------------------------------------------------------------------------------------------\n\n async function createDocumentIn(folder: string) {\n setSelectedFolder(folder)\n if (await execute({ type: 'createDocument', folder })) expand(ancestorKeys(folder))\n }\n\n /** Runs `command` for the Baustein of `item` (the file itself when it has none) and shows the result. */\n async function inComposite(item: TreeItem, command: TreeCommand) {\n if (await execute(command)) expand([item.blockId ? `outline:${item.blockId}` : item.key])\n }\n\n /**\n * What can be created below `item`: folders of the store take documents and sub-folders, the open file (as the root or\n * as a document row) and its Bausteine take what their kind accepts. Other rows take nothing. Folders also list\n * „Umbenennen“ here: renaming a document happens in the editor's title field.\n */\n function addMenu(item: TreeItem): TreeMenuEntry[][] {\n const groups: TreeMenuEntry[][] = []\n if (item.key !== VIRTUAL_ROOT && (item.type === 'root' || item.type === 'folder')) {\n const path = item.path!\n groups.push([\n { label: t('tree.menu.newDocument'), icon: 'i-lucide-file-plus', run: () => void createDocumentIn(path) },\n { label: item.type === 'root' ? t('tree.menu.newFolder') : t('tree.menu.newSubfolder'), icon: 'i-lucide-folder-plus', run: () => startCreateFolder(path) },\n ])\n }\n else {\n const can = creatableBelow(item, { structure: core.structure, hasEditor: core.hasEditor, activeId: core.activeId, kinds: core.kinds })\n const targetId = item.blockId ?? null\n const entries: TreeMenuEntry[] = []\n if (can.folder) entries.push({ label: t('tree.menu.newCompositeFolder'), icon: 'i-lucide-folder-plus', run: () => void inComposite(item, { type: 'createBausteinFolder', targetId }) })\n if (can.document) entries.push({ label: t('tree.menu.importFile'), icon: 'i-lucide-file-up', run: () => void inComposite(item, { type: 'importFiles', targetId }) })\n if (entries.length) groups.push(entries)\n }\n if (item.type === 'folder') groups.push([{ label: t('tree.menu.rename'), icon: 'i-lucide-pencil', run: () => startRename(item) }])\n return groups\n }\n\n async function remove(item: TreeItem) {\n patch({ removing: item.key })\n try {\n await execute(item.type === 'document' ? { type: 'removeDocument', id: item.id!, folder: item.folder ?? '' } : { type: 'removeFolder', path: item.path! })\n }\n finally {\n patch({ removing: null })\n }\n }\n\n sync()\n mirrorFocus()\n\n return {\n state,\n setContext,\n setSelectedFolder,\n setOpen,\n toggle,\n expand,\n setFilterText,\n setKindHidden: (key, kind, hidden) => shared.setKindHidden(key, kind, hidden),\n clearFilter: key => shared.clearFilter(key),\n clearAllFilters: () => shared.clearAllFilters(),\n setBasketShown: (id, shown) => shared.setBasketShown(id, shown),\n clearBasketFilter: () => shared.clearBasketFilter(),\n focus,\n defocus,\n canMerge,\n merge,\n select: selectItem,\n activate(item) {\n selectItem(item)\n if (item.type === 'root' || item.type === 'folder') toggle(item.key)\n },\n addMenu,\n remove,\n isDraggable: item => core.renaming?.key !== item.key && isDraggable(item, core.virtual),\n dragStart,\n dragOver,\n dragLeave(item) {\n // A foreign drag only exists while it is over this tree (no `dragend` reaches here), so leaving a row ends it; the next row's `foreignDragOver` starts it again.\n if (core.drag?.source.type === 'foreign-block') patch({ drag: null })\n else if (core.drag?.hover === item.key) patch({ drag: { ...core.drag, hover: null, verdict: null } })\n },\n dragEnd: () => patch({ drag: null }),\n drop,\n foreignDragOver,\n dropForeign,\n startRename,\n setRenameDraft(text) {\n const r = core.renaming\n if (r) patch({ renaming: { ...r, draft: text, error: renameError(text, r.path, r.base, core.tree) } })\n },\n cancelRename: () => patch({ renaming: null }),\n commitRename,\n blurRename,\n startCreateFolder,\n setFolderDraft(text) {\n const f = core.creatingFolder\n if (f) patch({ creatingFolder: { ...f, draft: text, error: folderError(text, f.parent, core.tree) } })\n },\n cancelCreateFolder: () => patch({ creatingFolder: null }),\n commitCreateFolder,\n dispose() {\n disposed = true\n clearTimeout(outlineTimer)\n unwatchEditor?.()\n for (const stop of unsubscribe) stop()\n },\n }\n}\n"],"mappings":";;;;;;;;AAuQA,MAAM,eAA2C,CAAC;AAClD,MAAM,WAAqC,CAAC;AAC5C,MAAM,aAAgC,CAAC;AACvC,MAAM,aAAgD,CAAC;AACvD,MAAM,QAAQ,OAAO,OAAO;AAE5B,MAAM,gBAAgB,QAAgB,IAAI,WAAW,UAAU;AAK/D,MAAM,YAAY,GAAa,UAA+B;CAAE,GAAG;CAAG;CAAM,WAAW,KAAK;AAAU;AAEtG,SAAS,YAAY,GAAuB,GAAgC;CAC1E,IAAI,MAAM,GAAG,OAAO;CACpB,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO;CACrB,OAAO,EAAE,KAAK,EAAE,KAAK,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE;AAC/C;;AAGA,SAAgB,MAAM,OAAkB,MAAgB,GAA4B;CAClF,MAAM,SAAS,MAAM,YAAY,KAAK,QAAQ,CAAC;CAC/C,MAAM,QAAQ,YAAY,MAAM;EAAE,WAAW,MAAM;EAAW,UAAU,MAAM;EAAU,OAAO,MAAM;EAAO;CAAE,CAAC;CAC/G,MAAM,gBAAgB,MAAM,YAAY,KAAK,QAAA,UAAuB,MAAM,kBAAkB,OAAO,CAAC,CAAC,KAAK,WAAW,KAAK,YAAY,MAAM;CAC5I,OAAO;EACL,GAAG,MAAM,KAAK,KAAK,IAAI,KAAK,GAAG;EAC/B,QAAQ,KAAK,OAAO,KAAA,KAAa,KAAK,OAAO,MAAM;EACnD,UAAW,KAAK,SAAS,cAAc,KAAK,SAAS,MAAM,kBAAmB;EAC9E,MAAM,MAAM,MAAM,UAAU,KAAK,MAAM,MAAM,KAAK,UAAU;EAC5D,UAAU,MAAM,UA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UAAU,OAAO,KAAK,GAAG;EACrE;EACA;EACA;EACA,cAAa,SAAQ,KAAK,UAAU,QAAQ,KAAK,OAAO,YAAY,MAAM,KAAK,OAAO;EACtF;EACA;EACA,UAAU,MAAM;GAEd,IAAI,KAAK,MAAM,OAAO,SAAS,iBAAiB,MAAM,EAAE,MAAM,KAAK,CAAC;QAC/D,IAAI,KAAK,MAAM,UAAU,KAAK,KAAK,MAAM,EAAE,MAAM;IAAE,GAAG,KAAK;IAAM,OAAO;IAAM,SAAS;GAAK,EAAE,CAAC;EACtG;EACA,eAAe,MAAM,EAAE,MAAM,KAAK,CAAC;EACnC;EACA;EACA;EACA;EACA,eAAe,MAAM;GACnB,MAAM,IAAI,KAAK;GACf,IAAI,GAAG,MAAM,EAAE,UAAU;IAAE,GAAG;IAAG,OAAO;IAAM,OAAO,YAAY,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI;GAAE,EAAE,CAAC;EACvG;EACA,oBAAoB,MAAM,EAAE,UAAU,KAAK,CAAC;EAC5C;EACA;EACA;EACA,eAAe,MAAM;GACnB,MAAM,IAAI,KAAK;GACf,IAAI,GAAG,MAAM,EAAE,gBAAgB;IAAE,GAAG;IAAG,OAAO;IAAM,OAAO,YAAY,MAAM,EAAE,QAAQ,KAAK,IAAI;GAAE,EAAE,CAAC;EACvG;EACA,0BAA0B,MAAM,EAAE,gBAAgB,KAAK,CAAC;EACxD;EACA,UAAU;GACR,WAAW;GACX,aAAa,YAAY;GACzB,gBAAgB;GAChB,KAAK,MAAM,QAAQ,aAAa,KAAK;EACvC;CACF;AACF"}
|
|
@@ -71,19 +71,19 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
71
71
|
editor: import("vue").ComputedRef<Editor | undefined>;
|
|
72
72
|
preset: ComposedEditor<Component>;
|
|
73
73
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
74
|
+
"update:modelValue": (content: JSONContent) => any;
|
|
75
|
+
ready: (editor: Editor) => any;
|
|
74
76
|
settingsOpen: (tab?: string | undefined) => any;
|
|
75
77
|
"update:sidebarOpen": (value: boolean) => any;
|
|
76
78
|
"update:commentsOpen": (value: boolean) => any;
|
|
77
|
-
"update:modelValue": (content: JSONContent) => any;
|
|
78
|
-
ready: (editor: Editor) => any;
|
|
79
79
|
metadataCreate: (list: string, item: MetadataItem) => any;
|
|
80
80
|
contentError: (error: Error) => any;
|
|
81
81
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
82
|
+
"onUpdate:modelValue"?: ((content: JSONContent) => any) | undefined;
|
|
83
|
+
onReady?: ((editor: Editor) => any) | undefined;
|
|
82
84
|
onSettingsOpen?: ((tab?: string | undefined) => any) | undefined;
|
|
83
85
|
"onUpdate:sidebarOpen"?: ((value: boolean) => any) | undefined;
|
|
84
86
|
"onUpdate:commentsOpen"?: ((value: boolean) => any) | undefined;
|
|
85
|
-
"onUpdate:modelValue"?: ((content: JSONContent) => any) | undefined;
|
|
86
|
-
onReady?: ((editor: Editor) => any) | undefined;
|
|
87
87
|
onMetadataCreate?: ((list: string, item: MetadataItem) => any) | undefined;
|
|
88
88
|
onContentError?: ((error: Error) => any) | undefined;
|
|
89
89
|
}>, {
|
|
@@ -41,19 +41,19 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
41
41
|
editor: import("vue").ComputedRef<Editor | undefined>;
|
|
42
42
|
preset: EditorPreset<Component>;
|
|
43
43
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
44
|
+
"update:modelValue": (content: JSONContent) => any;
|
|
45
|
+
ready: (editor: Editor) => any;
|
|
44
46
|
settingsOpen: (tab?: string | undefined) => any;
|
|
45
47
|
"update:sidebarOpen": (value: boolean) => any;
|
|
46
48
|
"update:commentsOpen": (value: boolean) => any;
|
|
47
|
-
"update:modelValue": (content: JSONContent) => any;
|
|
48
|
-
ready: (editor: Editor) => any;
|
|
49
49
|
metadataCreate: (list: string, item: MetadataItem) => any;
|
|
50
50
|
contentError: (error: Error) => any;
|
|
51
51
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
52
|
+
"onUpdate:modelValue"?: ((content: JSONContent) => any) | undefined;
|
|
53
|
+
onReady?: ((editor: Editor) => any) | undefined;
|
|
52
54
|
onSettingsOpen?: ((tab?: string | undefined) => any) | undefined;
|
|
53
55
|
"onUpdate:sidebarOpen"?: ((value: boolean) => any) | undefined;
|
|
54
56
|
"onUpdate:commentsOpen"?: ((value: boolean) => any) | undefined;
|
|
55
|
-
"onUpdate:modelValue"?: ((content: JSONContent) => any) | undefined;
|
|
56
|
-
onReady?: ((editor: Editor) => any) | undefined;
|
|
57
57
|
onMetadataCreate?: ((list: string, item: MetadataItem) => any) | undefined;
|
|
58
58
|
onContentError?: ((error: Error) => any) | undefined;
|
|
59
59
|
}>, {
|
|
@@ -43,19 +43,19 @@ declare const __VLS_export: import("vue").DefineComponent<__VLS_PublicProps, {
|
|
|
43
43
|
settingsOpen: import("vue").Ref<boolean, boolean>;
|
|
44
44
|
settingsTab: import("vue").Ref<string | undefined, string | undefined>;
|
|
45
45
|
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
46
|
+
"update:modelValue": (content: JSONContent) => any;
|
|
47
|
+
ready: (editor: Editor) => any;
|
|
46
48
|
settingsOpen: (tab?: string | undefined) => any;
|
|
47
49
|
"update:sidebarOpen": (value: boolean) => any;
|
|
48
50
|
"update:commentsOpen": (value: boolean) => any;
|
|
49
|
-
"update:modelValue": (content: JSONContent) => any;
|
|
50
|
-
ready: (editor: Editor) => any;
|
|
51
51
|
metadataCreate: (list: string, item: MetadataItem) => any;
|
|
52
52
|
contentError: (error: Error) => any;
|
|
53
53
|
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
54
|
+
"onUpdate:modelValue"?: ((content: JSONContent) => any) | undefined;
|
|
55
|
+
onReady?: ((editor: Editor) => any) | undefined;
|
|
54
56
|
onSettingsOpen?: ((tab?: string | undefined) => any) | undefined;
|
|
55
57
|
"onUpdate:sidebarOpen"?: ((value: boolean) => any) | undefined;
|
|
56
58
|
"onUpdate:commentsOpen"?: ((value: boolean) => any) | undefined;
|
|
57
|
-
"onUpdate:modelValue"?: ((content: JSONContent) => any) | undefined;
|
|
58
|
-
onReady?: ((editor: Editor) => any) | undefined;
|
|
59
59
|
onMetadataCreate?: ((list: string, item: MetadataItem) => any) | undefined;
|
|
60
60
|
onContentError?: ((error: Error) => any) | undefined;
|
|
61
61
|
}>, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ecsplico/editor",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.4.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vue and React editor library on TipTap v3 (Vue: Nuxt UI; React: shadcn/ui): framework-free features with Vue and React bindings, simple and advanced presets, tree-shakeable entries. Built ESM with type declarations.",
|
|
6
6
|
"license": "MIT",
|