@malva-ui/editor 0.1.13 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -5
- package/fesm2022/malva-ui-editor-ai.mjs +17 -0
- package/fesm2022/malva-ui-editor-ai.mjs.map +1 -0
- package/fesm2022/malva-ui-editor.mjs +10227 -0
- package/fesm2022/malva-ui-editor.mjs.map +1 -0
- package/package.json +35 -26
- package/types/malva-ui-editor-ai.d.ts +1 -0
- package/types/malva-ui-editor.d.ts +2995 -0
- package/ai/index.d.ts +0 -12
- package/ai/malva-ui-editor-ai.d.ts +0 -5
- package/esm2022/ai/index.js +0 -12
- package/esm2022/ai/index.js.map +0 -1
- package/esm2022/ai/malva-ui-editor-ai.js +0 -5
- package/esm2022/ai/malva-ui-editor-ai.js.map +0 -1
- package/esm2022/index.js +0 -37
- package/esm2022/index.js.map +0 -1
- package/esm2022/lib/ai/editor-ai-actions.js +0 -69
- package/esm2022/lib/ai/editor-ai-actions.js.map +0 -1
- package/esm2022/lib/ai/editor-ai-context.js +0 -612
- package/esm2022/lib/ai/editor-ai-context.js.map +0 -1
- package/esm2022/lib/ai/editor-ai-menu.js +0 -288
- package/esm2022/lib/ai/editor-ai-menu.js.map +0 -1
- package/esm2022/lib/ai/editor-ai-review-bar.js +0 -223
- package/esm2022/lib/ai/editor-ai-review-bar.js.map +0 -1
- package/esm2022/lib/ai/editor-ai-stream.js +0 -677
- package/esm2022/lib/ai/editor-ai-stream.js.map +0 -1
- package/esm2022/lib/ai/editor-ai-suggestions.js +0 -751
- package/esm2022/lib/ai/editor-ai-suggestions.js.map +0 -1
- package/esm2022/lib/ai/editor-ai.tokens.js +0 -10
- package/esm2022/lib/ai/editor-ai.tokens.js.map +0 -1
- package/esm2022/lib/ai/editor-ai.types.js +0 -1
- package/esm2022/lib/ai/editor-ai.types.js.map +0 -1
- package/esm2022/lib/editor/editor.js +0 -985
- package/esm2022/lib/editor/editor.js.map +0 -1
- package/esm2022/lib/editor-extension-preflight.js +0 -83
- package/esm2022/lib/editor-extension-preflight.js.map +0 -1
- package/esm2022/lib/editor-serialization.js +0 -152
- package/esm2022/lib/editor-serialization.js.map +0 -1
- package/esm2022/lib/editor-toolbar-context.js +0 -259
- package/esm2022/lib/editor-toolbar-context.js.map +0 -1
- package/esm2022/lib/editor.tokens.js +0 -10
- package/esm2022/lib/editor.tokens.js.map +0 -1
- package/esm2022/lib/editor.types.js +0 -48
- package/esm2022/lib/editor.types.js.map +0 -1
- package/esm2022/lib/extensions/editor-block-handle.js +0 -760
- package/esm2022/lib/extensions/editor-block-handle.js.map +0 -1
- package/esm2022/lib/extensions/editor-extensions.js +0 -321
- package/esm2022/lib/extensions/editor-extensions.js.map +0 -1
- package/esm2022/lib/extensions/editor-markdown-compatibility.js +0 -162
- package/esm2022/lib/extensions/editor-markdown-compatibility.js.map +0 -1
- package/esm2022/lib/extensions/editor-upload-placeholder.js +0 -156
- package/esm2022/lib/extensions/editor-upload-placeholder.js.map +0 -1
- package/esm2022/lib/status/editor-status.js +0 -64
- package/esm2022/lib/status/editor-status.js.map +0 -1
- package/esm2022/lib/toolbar/editor-alignment.js +0 -203
- package/esm2022/lib/toolbar/editor-alignment.js.map +0 -1
- package/esm2022/lib/toolbar/editor-block-insert.js +0 -101
- package/esm2022/lib/toolbar/editor-block-insert.js.map +0 -1
- package/esm2022/lib/toolbar/editor-color-control.js +0 -71
- package/esm2022/lib/toolbar/editor-color-control.js.map +0 -1
- package/esm2022/lib/toolbar/editor-command-button.js +0 -115
- package/esm2022/lib/toolbar/editor-command-button.js.map +0 -1
- package/esm2022/lib/toolbar/editor-heading.js +0 -266
- package/esm2022/lib/toolbar/editor-heading.js.map +0 -1
- package/esm2022/lib/toolbar/editor-highlight.js +0 -84
- package/esm2022/lib/toolbar/editor-highlight.js.map +0 -1
- package/esm2022/lib/toolbar/editor-image-upload-dialog.js +0 -289
- package/esm2022/lib/toolbar/editor-image-upload-dialog.js.map +0 -1
- package/esm2022/lib/toolbar/editor-image-upload.js +0 -315
- package/esm2022/lib/toolbar/editor-image-upload.js.map +0 -1
- package/esm2022/lib/toolbar/editor-inline-marks.js +0 -124
- package/esm2022/lib/toolbar/editor-inline-marks.js.map +0 -1
- package/esm2022/lib/toolbar/editor-link.js +0 -265
- package/esm2022/lib/toolbar/editor-link.js.map +0 -1
- package/esm2022/lib/toolbar/editor-list.js +0 -249
- package/esm2022/lib/toolbar/editor-list.js.map +0 -1
- package/esm2022/lib/toolbar/editor-table.js +0 -292
- package/esm2022/lib/toolbar/editor-table.js.map +0 -1
- package/esm2022/lib/toolbar/editor-text-color.js +0 -82
- package/esm2022/lib/toolbar/editor-text-color.js.map +0 -1
- package/esm2022/lib/toolbar/editor-toolbar-widget.js +0 -41
- package/esm2022/lib/toolbar/editor-toolbar-widget.js.map +0 -1
- package/esm2022/lib/toolbar/editor-toolbar.defs.js +0 -60
- package/esm2022/lib/toolbar/editor-toolbar.defs.js.map +0 -1
- package/esm2022/lib/toolbar/editor-toolbar.js +0 -826
- package/esm2022/lib/toolbar/editor-toolbar.js.map +0 -1
- package/esm2022/lib/toolbar/editor-undo-redo.js +0 -72
- package/esm2022/lib/toolbar/editor-undo-redo.js.map +0 -1
- package/esm2022/lib/toolbar/editor-zoom.js +0 -330
- package/esm2022/lib/toolbar/editor-zoom.js.map +0 -1
- package/esm2022/lib/upload/editor-image-upload-coordinator.js +0 -480
- package/esm2022/lib/upload/editor-image-upload-coordinator.js.map +0 -1
- package/esm2022/malva-ui-editor.js +0 -5
- package/esm2022/malva-ui-editor.js.map +0 -1
- package/index.d.ts +0 -35
- package/lib/ai/editor-ai-actions.d.ts +0 -27
- package/lib/ai/editor-ai-context.d.ts +0 -307
- package/lib/ai/editor-ai-menu.d.ts +0 -142
- package/lib/ai/editor-ai-review-bar.d.ts +0 -116
- package/lib/ai/editor-ai-stream.d.ts +0 -207
- package/lib/ai/editor-ai-suggestions.d.ts +0 -219
- package/lib/ai/editor-ai.tokens.d.ts +0 -10
- package/lib/ai/editor-ai.types.d.ts +0 -176
- package/lib/editor/editor.d.ts +0 -243
- package/lib/editor-extension-preflight.d.ts +0 -23
- package/lib/editor-serialization.d.ts +0 -74
- package/lib/editor-toolbar-context.d.ts +0 -116
- package/lib/editor.tokens.d.ts +0 -6
- package/lib/editor.types.d.ts +0 -194
- package/lib/extensions/editor-block-handle.d.ts +0 -59
- package/lib/extensions/editor-extensions.d.ts +0 -165
- package/lib/extensions/editor-markdown-compatibility.d.ts +0 -11
- package/lib/extensions/editor-upload-placeholder.d.ts +0 -75
- package/lib/status/editor-status.d.ts +0 -24
- package/lib/toolbar/editor-alignment.d.ts +0 -61
- package/lib/toolbar/editor-block-insert.d.ts +0 -26
- package/lib/toolbar/editor-color-control.d.ts +0 -32
- package/lib/toolbar/editor-command-button.d.ts +0 -29
- package/lib/toolbar/editor-heading.d.ts +0 -68
- package/lib/toolbar/editor-highlight.d.ts +0 -21
- package/lib/toolbar/editor-image-upload-dialog.d.ts +0 -96
- package/lib/toolbar/editor-image-upload.d.ts +0 -71
- package/lib/toolbar/editor-inline-marks.d.ts +0 -30
- package/lib/toolbar/editor-link.d.ts +0 -78
- package/lib/toolbar/editor-list.d.ts +0 -67
- package/lib/toolbar/editor-table.d.ts +0 -133
- package/lib/toolbar/editor-text-color.d.ts +0 -21
- package/lib/toolbar/editor-toolbar-widget.d.ts +0 -19
- package/lib/toolbar/editor-toolbar.d.ts +0 -157
- package/lib/toolbar/editor-toolbar.defs.d.ts +0 -35
- package/lib/toolbar/editor-undo-redo.d.ts +0 -26
- package/lib/toolbar/editor-zoom.d.ts +0 -108
- package/lib/upload/editor-image-upload-coordinator.d.ts +0 -55
- package/malva-ui-editor.d.ts +0 -5
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editor-ai-suggestions.js","sourceRoot":"","sources":["../../../../../../libs/editor/src/lib/ai/editor-ai-suggestions.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAA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tiptap/core';\n// Type-only: augments `Editor` with the optional `markdown` manager the\n// replacement is parsed through. Erased at compile time, so the engine stays\n// free of any runtime dependency on the Markdown extension.\nimport type {} from '@tiptap/markdown';\nimport { closeHistory } from '@tiptap/pm/history';\nimport { Fragment, Slice } from '@tiptap/pm/model';\nimport type { Node as ProseMirrorNode } from '@tiptap/pm/model';\nimport { Plugin, PluginKey } from '@tiptap/pm/state';\nimport type { EditorState, Transaction } from '@tiptap/pm/state';\nimport type { Mapping } from '@tiptap/pm/transform';\nimport { Decoration, DecorationSet } from '@tiptap/pm/view';\n\n/**\n * CSS class of the inline decoration highlighting text a pending suggestion\n * inserted into the document.\n *\n * The class is applied through a ProseMirror decoration held in plugin state,\n * never through document content, so it can appear in no HTML, Markdown, or\n * JSON serialization.\n */\nexport const MLV_EDITOR_AI_SUGGESTION_INSERT_CLASS =\n 'mlv-editor__ai-suggestion-insert';\n\n/**\n * CSS class of the widget decoration rendering text a pending suggestion\n * removed from the document.\n *\n * The removed text lives only inside the widget element — a strikethrough,\n * `aria-hidden` affordance — so it is absent from the document and from every\n * serialization the moment the suggestion is applied.\n */\nexport const MLV_EDITOR_AI_SUGGESTION_DELETE_CLASS =\n 'mlv-editor__ai-suggestion-delete';\n\n/**\n * CSS class added on top of the insert and delete decorations of the one\n * suggestion a review surface currently navigates\n * ({@link MlvEditorAiSuggestionsSession.setCurrent}).\n *\n * A decoration-only outline affordance: it never enters document content or\n * any serialization, and marking a suggestion current dispatches no document\n * step, so it can never create a history entry.\n */\nexport const MLV_EDITOR_AI_SUGGESTION_CURRENT_CLASS =\n 'mlv-editor__ai-suggestion-current';\n\n/**\n * Shape of one reviewable change.\n *\n * `'insert'` — new text was added; reject removes it. `'delete'` — text was\n * removed; reject restores it. `'replace'` — text was swapped; reject\n * restores the original.\n */\nexport type MlvEditorAiSuggestionKind = 'insert' | 'delete' | 'replace';\n\n/** Document range a suggestion currently occupies. */\nexport interface MlvEditorAiSuggestionRange {\n /** Start position of the suggestion's inserted content. */\n readonly from: number;\n\n /**\n * End position of the suggestion's inserted content. Equals {@link from}\n * for `'delete'` suggestions, whose removed text exists only in the widget\n * decoration anchored at this collapsed position.\n */\n readonly to: number;\n}\n\n/** One pending, reviewable AI change. */\nexport interface MlvEditorAiSuggestion {\n /** Stable identifier, unique across sessions within this runtime. */\n readonly id: string;\n\n /** Shape of the change. */\n readonly kind: MlvEditorAiSuggestionKind;\n\n /**\n * Current document range of the inserted content, remapped through every\n * concurrent transaction. Collapsed for `'delete'` suggestions.\n */\n readonly range: MlvEditorAiSuggestionRange;\n\n /** Plain text the change removed; empty for `'insert'`. */\n readonly oldText: string;\n\n /** Plain text the change added; empty for `'delete'`. */\n readonly newText: string;\n}\n\n/** Options accepted by {@link applyMlvEditorAiSuggestions}. */\nexport interface MlvEditorAiSuggestionsOptions {\n /** Start of the document region the replacement rewrites. */\n readonly from: number;\n\n /** End of the document region the replacement rewrites. */\n readonly to: number;\n\n /**\n * AI-produced replacement for the region, as Markdown. Parsed through the\n * editor's Markdown manager when one is registered; treated as plain text\n * otherwise — the same fallback the streaming engine uses for its commit.\n */\n readonly replacementMarkdown: string;\n}\n\n/**\n * Handle over one review session created by {@link applyMlvEditorAiSuggestions}.\n *\n * Undo semantics — a deliberate refinement of the spec sentence \"each\n * accept/reject = one undo step\": in the applied-edits storage model the\n * document already carries every change, so **accepting changes no document\n * content**. Accept operations (including {@link acceptAll}) are pure\n * plugin-state updates that drop decorations and entries without dispatching\n * a single step, and therefore create **no** history entry — an \"accept undo\n * step\" would necessarily be an empty one. Rejects mutate the document:\n * {@link reject} is exactly one history-visible step per call, and\n * {@link rejectAll} is exactly one step total.\n *\n * Every method returns `false` once the session has ended — all suggestions\n * resolved, the application undone, a newer session started, or the editor\n * destroyed.\n */\nexport interface MlvEditorAiSuggestionsSession {\n /**\n * Current pending suggestions in document order, with ranges remapped\n * through every transaction dispatched since application. Empty once the\n * session has ended.\n */\n suggestions(): readonly MlvEditorAiSuggestion[];\n\n /**\n * Accepts one suggestion: the applied change stays in the document and its\n * decorations are dropped. A pure plugin-state update — no document step,\n * no history entry. Returns whether the suggestion existed.\n */\n accept(id: string): boolean;\n\n /**\n * Rejects one suggestion: the original content is restored over the\n * suggestion's current range in exactly one history-visible step, and the\n * suggestion's decorations are dropped. Returns whether the suggestion\n * existed and the restore succeeded.\n *\n * Restored is the reviewed region, not the editor's own schema-maintenance\n * reactions to the suggested state: for example, the default preset's\n * `trailingNode` paragraph appended while a structural suggestion was the\n * last block stays behind — the same residue an ordinary user edit leaves.\n */\n reject(id: string): boolean;\n\n /**\n * Accepts every pending suggestion in one plugin-state update. Like\n * {@link accept}, dispatches no document step and creates no history\n * entry. Returns whether any suggestion was pending.\n */\n acceptAll(): boolean;\n\n /**\n * Rejects every pending suggestion in exactly one history-visible step,\n * restoring the original content of the whole reviewed region. Returns\n * whether any suggestion was pending and the restore succeeded.\n */\n rejectAll(): boolean;\n\n /**\n * Marks one suggestion as the current one under review: its decorations\n * gain {@link MLV_EDITOR_AI_SUGGESTION_CURRENT_CLASS} and the previous\n * current suggestion loses it. `null` clears the marker. Like\n * {@link accept}, a pure plugin-state update — no document step, no\n * history entry. The marker clears itself when its suggestion resolves or\n * is dropped by a concurrent edit. Returns `false` once the session has\n * ended or for an unknown id.\n */\n setCurrent(id: string | null): boolean;\n}\n\n/** One contiguous change between two texts, produced by {@link mlvEditorAiWordDiff}. */\nexport interface MlvEditorAiWordDiffRun {\n /** Shape of the change at this position. */\n readonly kind: MlvEditorAiSuggestionKind;\n\n /** Inclusive character offset in the old text where the run starts. */\n readonly oldFrom: number;\n\n /**\n * Exclusive character offset in the old text where the run ends. Equals\n * {@link oldFrom} for `'insert'` runs.\n */\n readonly oldTo: number;\n\n /** Old text covered by the run; empty for `'insert'`. */\n readonly oldText: string;\n\n /** New text the run introduces; empty for `'delete'`. */\n readonly newText: string;\n}\n\n/**\n * @internal Cell budget for the LCS table. Two texts whose token counts\n * multiply past this bound (only reachable with degenerate, book-length\n * \"paragraphs\") skip the quadratic diff and collapse to one replace run.\n */\nconst MAX_DIFF_CELLS = 1_000_000;\n\n/** @internal Splits text into alternating whitespace and word tokens; the tokens partition the input exactly. */\nconst tokenize = (text: string): string[] => text.match(/\\s+|\\S+/g) ?? [];\n\n/**\n * Token-level word diff between two plain texts, computed over a\n * longest-common-subsequence of tokens. Tokens are maximal whitespace or\n * non-whitespace runs, so whitespace changes are diffed like words.\n * Consecutive non-equal tokens merge into one run; a run that both removes\n * and adds text is a `'replace'`.\n *\n * Pure and framework-free. Returns an empty array for identical inputs.\n *\n * @param oldText Text currently in the document.\n * @param newText Replacement text.\n * @returns Change runs in ascending old-text offset order.\n */\nexport function mlvEditorAiWordDiff(\n oldText: string,\n newText: string,\n): readonly MlvEditorAiWordDiffRun[] {\n if (oldText === newText) return [];\n const oldTokens = tokenize(oldText);\n const newTokens = tokenize(newText);\n\n let prefix = 0;\n while (\n prefix < oldTokens.length &&\n prefix < newTokens.length &&\n oldTokens[prefix] === newTokens[prefix]\n ) {\n prefix += 1;\n }\n let suffix = 0;\n while (\n suffix < oldTokens.length - prefix &&\n suffix < newTokens.length - prefix &&\n oldTokens[oldTokens.length - 1 - suffix] ===\n newTokens[newTokens.length - 1 - suffix]\n ) {\n suffix += 1;\n }\n const oldCore = oldTokens.slice(prefix, oldTokens.length - suffix);\n const newCore = newTokens.slice(prefix, newTokens.length - suffix);\n\n // Edit script over the cores as (op, token) pairs in document order.\n const ops: {\n readonly op: 'equal' | 'del' | 'ins';\n readonly token: string;\n }[] = [];\n if ((oldCore.length + 1) * (newCore.length + 1) > MAX_DIFF_CELLS) {\n // Degenerate size: one whole-core replacement instead of an LCS walk.\n oldCore.forEach((token) => ops.push({ op: 'del', token }));\n newCore.forEach((token) => ops.push({ op: 'ins', token }));\n } else {\n // dp[i][j] = LCS length of oldCore[i..] and newCore[j..].\n const width = newCore.length + 1;\n const dp = new Uint32Array((oldCore.length + 1) * width);\n for (let i = oldCore.length - 1; i >= 0; i--) {\n for (let j = newCore.length - 1; j >= 0; j--) {\n dp[i * width + j] =\n oldCore[i] === newCore[j]\n ? dp[(i + 1) * width + j + 1] + 1\n : Math.max(dp[(i + 1) * width + j], dp[i * width + j + 1]);\n }\n }\n let i = 0;\n let j = 0;\n while (i < oldCore.length && j < newCore.length) {\n if (oldCore[i] === newCore[j]) {\n ops.push({ op: 'equal', token: oldCore[i] });\n i += 1;\n j += 1;\n } else if (dp[(i + 1) * width + j] >= dp[i * width + j + 1]) {\n ops.push({ op: 'del', token: oldCore[i] });\n i += 1;\n } else {\n ops.push({ op: 'ins', token: newCore[j] });\n j += 1;\n }\n }\n while (i < oldCore.length) ops.push({ op: 'del', token: oldCore[i++] });\n while (j < newCore.length) ops.push({ op: 'ins', token: newCore[j++] });\n }\n\n const runs: MlvEditorAiWordDiffRun[] = [];\n let oldPos = oldTokens.slice(0, prefix).join('').length;\n let pendingStart = -1;\n let pendingOld = '';\n let pendingNew = '';\n const flush = () => {\n if (pendingStart < 0) return;\n if (pendingOld.length > 0 && pendingNew.length > 0) {\n runs.push({\n kind: 'replace',\n oldFrom: pendingStart,\n oldTo: pendingStart + pendingOld.length,\n oldText: pendingOld,\n newText: pendingNew,\n });\n } else if (pendingOld.length > 0) {\n runs.push({\n kind: 'delete',\n oldFrom: pendingStart,\n oldTo: pendingStart + pendingOld.length,\n oldText: pendingOld,\n newText: '',\n });\n } else {\n runs.push({\n kind: 'insert',\n oldFrom: pendingStart,\n oldTo: pendingStart,\n oldText: '',\n newText: pendingNew,\n });\n }\n pendingStart = -1;\n pendingOld = '';\n pendingNew = '';\n };\n for (const { op, token } of ops) {\n if (op === 'equal') {\n flush();\n oldPos += token.length;\n } else if (op === 'del') {\n if (pendingStart < 0) pendingStart = oldPos;\n pendingOld += token;\n oldPos += token.length;\n } else {\n if (pendingStart < 0) pendingStart = oldPos;\n pendingNew += token;\n }\n }\n flush();\n return runs;\n}\n\n/** @internal One pending change tracked by the suggestion plugin. */\ninterface MlvEditorAiSuggestionEntry {\n readonly id: string;\n readonly kind: MlvEditorAiSuggestionKind;\n /** Current start of the inserted content (widget anchor for `'delete'`). */\n readonly from: number;\n /** Current end of the inserted content; equals `from` for `'delete'`. */\n readonly to: number;\n readonly oldText: string;\n readonly newText: string;\n /** Original content a reject restores over `[from, to]`; empty for `'insert'`. */\n readonly inverted: Slice;\n}\n\n/** @internal State the per-session suggestion plugin holds. */\ninterface MlvEditorAiSuggestionsPluginState {\n readonly entries: readonly MlvEditorAiSuggestionEntry[];\n /** Entry currently outlined for review navigation, if any. */\n readonly currentId: string | null;\n readonly decorations: DecorationSet;\n}\n\n/** @internal Transaction metadata driving the suggestion plugin. */\ntype MlvEditorAiSuggestionsMetadata =\n | {\n readonly type: 'init';\n readonly entries: readonly MlvEditorAiSuggestionEntry[];\n }\n | { readonly type: 'drop'; readonly ids: readonly string[] }\n | { readonly type: 'clear' }\n | { readonly type: 'current'; readonly id: string | null };\n\n/**\n * @internal Key identifying the per-session suggestion plugin. Session\n * transactions carry metadata under this key; transactions without it are\n * foreign and subject to the remap-or-drop policy.\n */\nconst MLV_EDITOR_AI_SUGGESTIONS_KEY =\n new PluginKey<MlvEditorAiSuggestionsPluginState | null>(\n 'mlvEditorAiSuggestions',\n );\n\n/**\n * @internal One active review session per editor. Starting a new session\n * tears the previous one down first (its remaining suggestions stay applied —\n * the accepted-by-default rule), so the shared key never registers twice.\n */\nconst activeSessions = new WeakMap<Editor, () => void>();\n\n/** @internal Monotonic source of session-unique suggestion identifiers. */\nlet suggestionIdSequence = 0;\n\n/** @internal Allocates the next suggestion identifier. */\nconst nextSuggestionId = () => `mlv-ai-suggestion-${++suggestionIdSequence}`;\n\n/** @internal Renders the strikethrough widget carrying one removed text. */\nconst renderDeleteWidget = (oldText: string, current: boolean) => () => {\n const element = document.createElement('span');\n element.className = current\n ? `${MLV_EDITOR_AI_SUGGESTION_DELETE_CLASS} ${MLV_EDITOR_AI_SUGGESTION_CURRENT_CLASS}`\n : MLV_EDITOR_AI_SUGGESTION_DELETE_CLASS;\n element.textContent = oldText;\n // Purely visual affordance: the removed text must not be read as document\n // content. The review surface announces outcomes separately.\n element.setAttribute('aria-hidden', 'true');\n return element;\n};\n\n/** @internal Builds the decoration set for a fresh entry list. */\nconst buildDecorations = (\n doc: ProseMirrorNode,\n entries: readonly MlvEditorAiSuggestionEntry[],\n currentId: string | null,\n): DecorationSet => {\n const decorations: Decoration[] = [];\n for (const entry of entries) {\n const current = entry.id === currentId;\n if (entry.kind !== 'delete' && entry.from < entry.to) {\n decorations.push(\n Decoration.inline(\n entry.from,\n entry.to,\n {\n class: current\n ? `${MLV_EDITOR_AI_SUGGESTION_INSERT_CLASS} ${MLV_EDITOR_AI_SUGGESTION_CURRENT_CLASS}`\n : MLV_EDITOR_AI_SUGGESTION_INSERT_CLASS,\n },\n { id: entry.id },\n ),\n );\n }\n if (entry.kind !== 'insert' && entry.oldText.length > 0) {\n decorations.push(\n Decoration.widget(\n entry.from,\n renderDeleteWidget(entry.oldText, current),\n {\n id: entry.id,\n side: -1,\n },\n ),\n );\n }\n }\n return DecorationSet.create(doc, decorations);\n};\n\n/**\n * @internal Remaps one entry through a session-owned transaction. Session\n * edits (rejects) never overlap other entries, so positions map without the\n * drop policy. Collapsed entries map with the same association their widget\n * decoration uses (`side: -1`), keeping entry and decoration in lockstep.\n */\nconst remapEntryThroughOwn = (\n entry: MlvEditorAiSuggestionEntry,\n mapping: Mapping,\n): MlvEditorAiSuggestionEntry => {\n const collapsed = entry.kind === 'delete';\n const from = mapping.map(entry.from, collapsed ? -1 : 1);\n const to = collapsed ? from : mapping.map(entry.to, -1);\n if (from === entry.from && to === entry.to) return entry;\n return { ...entry, from, to };\n};\n\n/**\n * @internal Remaps one entry through a foreign transaction, or returns `null`\n * when a step touches it — the concurrent-edit drop policy.\n *\n * A non-collapsed entry is touched by any step whose replaced range strictly\n * overlaps `[from, to)`; a pure insertion strictly inside counts, insertions\n * and deletions that only meet a boundary do not. A collapsed (`'delete'`)\n * entry is touched by a replacement strictly spanning its anchor and by an\n * insertion at exactly the anchor — which is also what makes undoing the\n * original application (it re-inserts the removed text at the anchor) drop\n * the widget along with everything else.\n *\n * Boundary association mirrors the decorations: inline ranges exclude\n * content inserted at either edge (`inclusiveStart`/`inclusiveEnd` false),\n * widgets stay put with `side: -1`.\n */\nconst remapEntryThroughForeign = (\n entry: MlvEditorAiSuggestionEntry,\n mapping: Mapping,\n): MlvEditorAiSuggestionEntry | null => {\n const collapsed = entry.kind === 'delete';\n let from = entry.from;\n let to = entry.to;\n for (const stepMap of mapping.maps) {\n let touched = false;\n stepMap.forEach((oldStart: number, oldEnd: number) => {\n if (collapsed) {\n if (\n (oldStart < from && oldEnd > from) ||\n (oldStart === oldEnd && oldStart === from)\n ) {\n touched = true;\n }\n } else if (oldStart < to && oldEnd > from) {\n touched = true;\n }\n });\n if (touched) return null;\n from = stepMap.map(from, collapsed ? -1 : 1);\n to = collapsed ? from : stepMap.map(to, -1);\n }\n if (from === entry.from && to === entry.to) return entry;\n return { ...entry, from, to };\n};\n\n/** @internal Removes every decoration belonging to the given ids. */\nconst removeDecorationsFor = (\n decorations: DecorationSet,\n ids: ReadonlySet<string>,\n): DecorationSet =>\n decorations.remove(\n decorations.find(undefined, undefined, (spec: { id: string }) =>\n ids.has(spec.id),\n ),\n );\n\n/** @internal Creates the per-session suggestion plugin. */\nconst createSuggestionsPlugin =\n (): Plugin<MlvEditorAiSuggestionsPluginState | null> =>\n new Plugin<MlvEditorAiSuggestionsPluginState | null>({\n key: MLV_EDITOR_AI_SUGGESTIONS_KEY,\n state: {\n init: () => null,\n apply: (transaction, state) => {\n const metadata = transaction.getMeta(\n MLV_EDITOR_AI_SUGGESTIONS_KEY,\n ) as MlvEditorAiSuggestionsMetadata | undefined;\n if (metadata?.type === 'init') {\n // Entry positions were computed against the transaction's result\n // document, so the decorations build against it directly.\n return {\n entries: metadata.entries,\n currentId: null,\n decorations: buildDecorations(\n transaction.doc,\n metadata.entries,\n null,\n ),\n };\n }\n if (!state) return null;\n\n let entries = state.entries;\n let currentId = state.currentId;\n let decorations = state.decorations;\n if (transaction.docChanged) {\n if (metadata) {\n entries = entries.map((entry) =>\n remapEntryThroughOwn(entry, transaction.mapping),\n );\n decorations = decorations.map(\n transaction.mapping,\n transaction.doc,\n );\n } else {\n const survivors: MlvEditorAiSuggestionEntry[] = [];\n const dropped = new Set<string>();\n for (const entry of entries) {\n const mapped = remapEntryThroughForeign(\n entry,\n transaction.mapping,\n );\n if (mapped) survivors.push(mapped);\n else dropped.add(entry.id);\n }\n entries = survivors;\n decorations = decorations.map(\n transaction.mapping,\n transaction.doc,\n );\n if (dropped.size > 0) {\n decorations = removeDecorationsFor(decorations, dropped);\n if (currentId !== null && dropped.has(currentId)) {\n currentId = null;\n }\n }\n }\n }\n if (metadata?.type === 'drop') {\n const ids = new Set(metadata.ids);\n entries = entries.filter((entry) => !ids.has(entry.id));\n decorations = removeDecorationsFor(decorations, ids);\n if (currentId !== null && ids.has(currentId)) currentId = null;\n }\n if (metadata?.type === 'clear') {\n return {\n entries: [],\n currentId: null,\n decorations: DecorationSet.empty,\n };\n }\n if (metadata?.type === 'current') {\n // The outline moves by rebuilding from the (possibly remapped)\n // entries: entry and decoration positions stay in lockstep, so\n // the rebuild is equivalent to the incrementally mapped set plus\n // the new current marker.\n return {\n entries,\n currentId: metadata.id,\n decorations: buildDecorations(\n transaction.doc,\n entries,\n metadata.id,\n ),\n };\n }\n if (\n entries === state.entries &&\n currentId === state.currentId &&\n decorations === state.decorations\n ) {\n return state;\n }\n return { entries, currentId, decorations };\n },\n },\n props: {\n decorations: (state: EditorState) =>\n MLV_EDITOR_AI_SUGGESTIONS_KEY.getState(state)?.decorations ?? null,\n },\n });\n\n/**\n * @internal True when `[from, to]` lies inside one textblock and contains\n * only unmarked text nodes — the precondition for the token-level word diff,\n * where one character is exactly one document position and inserted plain\n * text can drop no formatting.\n */\nconst regionIsPlainInline = (\n doc: ProseMirrorNode,\n from: number,\n to: number,\n): boolean => {\n const $from = doc.resolve(from);\n const $to = doc.resolve(to);\n if (!$from.sameParent($to) || !$from.parent.isTextblock) return false;\n let plain = true;\n $from.parent.nodesBetween($from.parentOffset, $to.parentOffset, (node) => {\n if (!node.isText || node.marks.length > 0) plain = false;\n return false;\n });\n return plain;\n};\n\n/**\n * @internal Extracts the plain text of a parsed replacement that is exactly\n * one paragraph of unmarked text nodes; `null` for anything richer, which\n * routes the application through the whole-region fallback.\n */\nconst plainParagraphText = (blocks: readonly JSONContent[]): string | null => {\n if (blocks.length !== 1 || blocks[0].type !== 'paragraph') return null;\n const content = blocks[0].content ?? [];\n let text = '';\n for (const child of content) {\n if (\n child.type !== 'text' ||\n typeof child.text !== 'string' ||\n (child.marks?.length ?? 0) > 0\n ) {\n return null;\n }\n text += child.text;\n }\n return text;\n};\n\n/**\n * @internal Parses the replacement Markdown into top-level blocks through the\n * editor's Markdown manager; without a manager the raw text becomes one plain\n * paragraph — the same fallback the streaming engine's commit uses. Returns\n * `null` for unusable input.\n */\nconst parseReplacement = (\n editor: Editor,\n markdown: string,\n): readonly JSONContent[] | null => {\n const manager = editor.markdown;\n if (!manager) {\n return [{ type: 'paragraph', content: [{ type: 'text', text: markdown }] }];\n }\n try {\n const parsed = manager.parse(markdown);\n if (!Array.isArray(parsed.content) || parsed.content.length === 0) {\n return null;\n }\n return parsed.content;\n } catch {\n return null;\n }\n};\n\n/**\n * @internal Restores one entry's original content into the shared reject\n * transaction. Insert entries delete their exact inline range. Other kinds\n * try the precise `replace` with the stored slice first — exact for every\n * token-diff entry — and fall back to the fitting `replaceRange` for\n * whole-region entries whose paste-fitted boundaries no longer match the\n * slice's open depths. A throwing `replace` adds no step, so the fallback\n * runs against an unchanged transaction.\n */\nconst applyRestore = (\n tr: Transaction,\n entry: MlvEditorAiSuggestionEntry,\n): void => {\n if (entry.kind === 'insert') {\n tr.delete(entry.from, entry.to);\n return;\n }\n try {\n tr.replace(entry.from, entry.to, entry.inverted);\n } catch {\n tr.replaceRange(entry.from, entry.to, entry.inverted);\n }\n};\n\n/**\n * Applies an AI replacement for `[from, to]` as reviewable tracked changes —\n * the Phase 2 suggestion engine (storage option B of the design spec).\n *\n * Framework-free: only the editor instance and the replacement Markdown are\n * needed — no Angular, no provider token, no network.\n *\n * Diff granularity (pragmatic, documented rule): when the original region is\n * a single textblock of plain, unmarked text **and** the parsed replacement\n * is a single paragraph of plain text, the two are diffed token-by-token\n * (tokens are whitespace or word runs) over a longest common subsequence,\n * producing individual insert/delete/replace suggestions. Any structural or\n * formatted content on either side falls back to **one** whole-region\n * replace suggestion.\n *\n * Representation: inserted text enters the document immediately and is\n * highlighted by an inline decoration\n * ({@link MLV_EDITOR_AI_SUGGESTION_INSERT_CLASS}); deleted text is removed\n * from the document and re-rendered at its position by a strikethrough\n * `aria-hidden` widget decoration\n * ({@link MLV_EDITOR_AI_SUGGESTION_DELETE_CLASS}). Because both are\n * decorations, `getHTML`/`getMarkdown`/`getJSON` during review serialize the\n * document as-is — inserted text present, removed text absent — the spec's\n * accepted-by-default rule. Hosts gate saves on pending suggestions.\n *\n * The whole application is exactly **one** history-visible transaction:\n * one undo removes every suggested change at once — and, because the undo\n * intersects every suggestion range, it also drops the whole session.\n *\n * Concurrent edits: user transactions remap all suggestion ranges through\n * their step maps; an edit that intersects a suggestion's range drops that\n * one suggestion (decorations removed, the current document text stands,\n * nothing is restored). The session ends when every suggestion is resolved\n * or dropped, and editor destruction cleans up listeners and plugin state.\n * Starting a new session on an editor first ends the previous one, leaving\n * its remaining suggestions applied (accepted-by-default).\n *\n * Undo-step semantics of the returned session are documented on\n * {@link MlvEditorAiSuggestionsSession}.\n *\n * @param editor Live Tiptap editor the suggestions are applied to.\n * @param options Region to rewrite and the replacement Markdown.\n * @returns The review session, or `null` when nothing reviewable results —\n * destroyed editor, out-of-range positions, unusable replacement, or a\n * replacement identical to the region.\n */\nexport function applyMlvEditorAiSuggestions(\n editor: Editor,\n options: MlvEditorAiSuggestionsOptions,\n): MlvEditorAiSuggestionsSession | null {\n const { from, to, replacementMarkdown } = options;\n if (editor.isDestroyed) return null;\n if (\n !Number.isInteger(from) ||\n !Number.isInteger(to) ||\n from < 0 ||\n to < from ||\n to > editor.state.doc.content.size\n ) {\n return null;\n }\n if (replacementMarkdown.trim().length === 0) return null;\n\n const blocks = parseReplacement(editor, replacementMarkdown);\n if (!blocks) return null;\n\n const doc = editor.state.doc;\n const plainReplacement = plainParagraphText(blocks);\n const wordDiff =\n plainReplacement !== null && regionIsPlainInline(doc, from, to)\n ? mlvEditorAiWordDiff(doc.textBetween(from, to), plainReplacement)\n : null;\n // A word-diffable replacement identical to the region changes nothing.\n if (wordDiff !== null && wordDiff.length === 0) return null;\n\n // One session per editor: the shared plugin key must never register twice.\n activeSessions.get(editor)?.();\n\n let active = true;\n\n /** @internal Ends the session exactly once and detaches everything. */\n const teardown = () => {\n if (!active) return;\n active = false;\n editor.off('transaction', onTransaction);\n editor.off('destroy', onDestroy);\n if (!editor.isDestroyed) {\n try {\n editor.unregisterPlugin(MLV_EDITOR_AI_SUGGESTIONS_KEY);\n } catch {\n // A failing reconfigure must not break teardown; the listeners are\n // already detached and the session is inert either way.\n }\n }\n if (activeSessions.get(editor) === teardown) activeSessions.delete(editor);\n };\n\n /**\n * @internal Ends the session once every suggestion is resolved or dropped —\n * including the drop-all that undoing the original application causes.\n */\n const onTransaction = () => {\n if (!active) return;\n const state = MLV_EDITOR_AI_SUGGESTIONS_KEY.getState(editor.state);\n if (!state || state.entries.length === 0) teardown();\n };\n\n /** @internal A destroyed editor leaves nothing to unregister. */\n const onDestroy = () => teardown();\n\n editor.registerPlugin(createSuggestionsPlugin());\n editor.on('transaction', onTransaction);\n editor.on('destroy', onDestroy);\n activeSessions.set(editor, teardown);\n\n try {\n const tr = editor.state.tr;\n const entries: MlvEditorAiSuggestionEntry[] = [];\n if (wordDiff !== null) {\n // Token path: every run edits plain inline text of one textblock, so a\n // character offset is a document offset and a running delta keeps the\n // positions of later runs exact.\n let delta = 0;\n for (const run of wordDiff) {\n const runFrom = from + run.oldFrom + delta;\n const runTo = from + run.oldTo + delta;\n const inverted =\n run.kind === 'insert'\n ? Slice.empty\n : doc.slice(from + run.oldFrom, from + run.oldTo);\n if (run.kind === 'delete') {\n tr.delete(runFrom, runTo);\n } else {\n tr.replaceWith(runFrom, runTo, editor.schema.text(run.newText));\n }\n entries.push({\n id: nextSuggestionId(),\n kind: run.kind,\n from: runFrom,\n to: run.kind === 'delete' ? runFrom : runFrom + run.newText.length,\n oldText: run.oldText,\n newText: run.newText,\n inverted,\n });\n delta += run.newText.length - run.oldText.length;\n }\n } else {\n // Fallback: one whole-region replace. A single-paragraph replacement\n // lands as inline content so a one-line result never splits the\n // surrounding block (streaming-commit precedent); everything else lands\n // as the block structure the Markdown describes, paste-fitted.\n const inline =\n blocks.length === 1 && blocks[0].type === 'paragraph'\n ? (blocks[0].content ?? [])\n : null;\n const blockReplacement = !inline || inline.length === 0;\n const fragment = Fragment.fromJSON(\n editor.schema,\n blockReplacement ? blocks : inline,\n );\n // Block content replacing a region whose edge sits at a textblock edge\n // grows to that block's boundary; otherwise `replaceRange`'s fitting\n // strands the emptied source block as a shell next to the inserted\n // structure, and that shell would serialize (accepted-by-default) and\n // survive a reject.\n let replaceFrom = from;\n let replaceTo = to;\n if (blockReplacement && from < to) {\n const $from = doc.resolve(from);\n const $to = doc.resolve(to);\n if (\n $from.depth > 0 &&\n $from.parent.isTextblock &&\n $from.parentOffset === 0\n ) {\n replaceFrom = $from.before();\n }\n if (\n $to.depth > 0 &&\n $to.parent.isTextblock &&\n $to.parentOffset === $to.parent.content.size\n ) {\n replaceTo = $to.after();\n }\n }\n const inverted = doc.slice(replaceFrom, replaceTo);\n tr.replaceRange(replaceFrom, replaceTo, new Slice(fragment, 0, 0));\n // A replacement that reproduces the document is the no-changes case —\n // the whole-region counterpart of the empty word diff above. Without\n // this check an echoed formatted or structural region would land as one\n // bogus no-op replace suggestion (and a no-op undo step).\n if (tr.doc.eq(doc)) {\n teardown();\n return null;\n }\n const mappedFrom = tr.mapping.map(replaceFrom, -1);\n const mappedTo = Math.max(mappedFrom, tr.mapping.map(replaceTo, 1));\n entries.push({\n id: nextSuggestionId(),\n kind: 'replace',\n from: mappedFrom,\n to: mappedTo,\n oldText: doc.textBetween(replaceFrom, replaceTo, ' '),\n newText: tr.doc.textBetween(mappedFrom, mappedTo, ' '),\n inverted,\n });\n }\n tr.setMeta(MLV_EDITOR_AI_SUGGESTIONS_KEY, {\n type: 'init',\n entries,\n } satisfies MlvEditorAiSuggestionsMetadata);\n closeHistory(tr);\n editor.view.dispatch(tr);\n } catch {\n teardown();\n return null;\n }\n\n /** @internal Reads the current entries; empty once the session ended. */\n const currentEntries = (): readonly MlvEditorAiSuggestionEntry[] =>\n active\n ? (MLV_EDITOR_AI_SUGGESTIONS_KEY.getState(editor.state)?.entries ?? [])\n : [];\n\n return {\n suggestions: () =>\n currentEntries().map((entry) => ({\n id: entry.id,\n kind: entry.kind,\n range: { from: entry.from, to: entry.to },\n oldText: entry.oldText,\n newText: entry.newText,\n })),\n\n accept: (id) => {\n const entry = currentEntries().find((candidate) => candidate.id === id);\n if (!entry) return false;\n // No document step: the applied change already is the accepted state,\n // so this is a pure plugin-state update and creates no history entry.\n const tr = editor.state.tr;\n tr.setMeta(MLV_EDITOR_AI_SUGGESTIONS_KEY, {\n type: 'drop',\n ids: [id],\n } satisfies MlvEditorAiSuggestionsMetadata);\n editor.view.dispatch(tr);\n return true;\n },\n\n reject: (id) => {\n const entry = currentEntries().find((candidate) => candidate.id === id);\n if (!entry) return false;\n try {\n const tr = editor.state.tr;\n applyRestore(tr, entry);\n tr.setMeta(MLV_EDITOR_AI_SUGGESTIONS_KEY, {\n type: 'drop',\n ids: [id],\n } satisfies MlvEditorAiSuggestionsMetadata);\n closeHistory(tr);\n editor.view.dispatch(tr);\n return true;\n } catch {\n return false;\n }\n },\n\n acceptAll: () => {\n if (currentEntries().length === 0) return false;\n const tr = editor.state.tr;\n tr.setMeta(MLV_EDITOR_AI_SUGGESTIONS_KEY, {\n type: 'clear',\n } satisfies MlvEditorAiSuggestionsMetadata);\n editor.view.dispatch(tr);\n return true;\n },\n\n setCurrent: (id) => {\n if (!active) return false;\n const state = MLV_EDITOR_AI_SUGGESTIONS_KEY.getState(editor.state);\n if (!state) return false;\n if (id !== null && !state.entries.some((entry) => entry.id === id)) {\n return false;\n }\n if (state.currentId === id) return true;\n // No document step: the marker lives in plugin state and decorations\n // only, so this dispatch can never create a history entry.\n const tr = editor.state.tr;\n tr.setMeta(MLV_EDITOR_AI_SUGGESTIONS_KEY, {\n type: 'current',\n id,\n } satisfies MlvEditorAiSuggestionsMetadata);\n editor.view.dispatch(tr);\n return true;\n },\n\n rejectAll: () => {\n const entries = currentEntries();\n if (entries.length === 0) return false;\n try {\n const tr = editor.state.tr;\n // Descending order keeps every earlier entry's positions valid while\n // later ones are restored.\n for (const entry of [...entries].sort((a, b) => b.from - a.from)) {\n applyRestore(tr, entry);\n }\n tr.setMeta(MLV_EDITOR_AI_SUGGESTIONS_KEY, {\n type: 'clear',\n } satisfies MlvEditorAiSuggestionsMetadata);\n closeHistory(tr);\n editor.view.dispatch(tr);\n return true;\n } catch {\n return false;\n }\n },\n };\n}\n"]}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { InjectionToken } from '@angular/core';
|
|
2
|
-
/**
|
|
3
|
-
* Optional dependency-injection token for a host-provided AI transport.
|
|
4
|
-
*
|
|
5
|
-
* The per-editor `aiProvider` input wins over this token, mirroring
|
|
6
|
-
* `MLV_EDITOR_IMAGE_UPLOADER` precedence. Without either, AI UI modules hide
|
|
7
|
-
* and AI commands are unavailable.
|
|
8
|
-
*/
|
|
9
|
-
export const MLV_EDITOR_AI_PROVIDER = new InjectionToken('MLV_EDITOR_AI_PROVIDER');
|
|
10
|
-
//# sourceMappingURL=editor-ai.tokens.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editor-ai.tokens.js","sourceRoot":"","sources":["../../../../../../libs/editor/src/lib/ai/editor-ai.tokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAG/C;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,cAAc,CACtD,wBAAwB,CACzB,CAAC","sourcesContent":["import { InjectionToken } from '@angular/core';\nimport { type MlvEditorAiProvider } from './editor-ai.types';\n\n/**\n * Optional dependency-injection token for a host-provided AI transport.\n *\n * The per-editor `aiProvider` input wins over this token, mirroring\n * `MLV_EDITOR_IMAGE_UPLOADER` precedence. Without either, AI UI modules hide\n * and AI commands are unavailable.\n */\nexport const MLV_EDITOR_AI_PROVIDER = new InjectionToken<MlvEditorAiProvider>(\n 'MLV_EDITOR_AI_PROVIDER',\n);\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=editor-ai.types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"editor-ai.types.js","sourceRoot":"","sources":["../../../../../../libs/editor/src/lib/ai/editor-ai.types.ts"],"names":[],"mappings":"","sourcesContent":["// Type-only, and therefore erased: the context imports this module for its\n// request shapes, so a value import back would be a real module cycle.\nimport type { MlvEditorAiContext } from './editor-ai-context';\nimport type { MlvEditorAiSuggestionKind } from './editor-ai-suggestions';\n\n/**\n * The transform kinds the library itself ships menu entries and i18n copy for.\n *\n * `'improve'`, `'fix-grammar'`, `'shorten'`, `'extend'`, and `'summarize'`\n * rewrite the selection without further arguments. `'tone'` and `'translate'`\n * carry their target tone or language in\n * {@link MlvEditorAiRequest.instruction}. `'custom'` carries a free-form host\n * or user prompt in the same field.\n */\nexport type MlvEditorAiBuiltInTransformKind =\n | 'improve'\n | 'fix-grammar'\n | 'shorten'\n | 'extend'\n | 'summarize'\n | 'tone'\n | 'translate'\n | 'custom';\n\n/**\n * Selection transform requested from an AI provider: one of the\n * {@link MlvEditorAiBuiltInTransformKind} values, or any host-authored string.\n *\n * The provider owns prompting, so a kind is a name the *provider* understands\n * and is fully opaque to the editor: nothing in the library branches on it,\n * and it is forwarded verbatim on {@link MlvEditorAiRequest.kind}. A host that\n * supplies its own {@link MlvEditorAiAction} list can therefore name kinds the\n * library has never heard of (`'legal-review'`, `'to-bullets'`, …) and answer\n * them in its own provider.\n *\n * The union with `string` deliberately keeps the built-in literals in\n * autocomplete — `(string & {})` is not reduced to `string` by the compiler,\n * so editors still suggest `'improve'` while any other string remains\n * assignable. The corollary for providers: `request.kind` is not exhaustively\n * checkable, so a `switch` over it needs a `default` branch that tolerates\n * kinds it does not know.\n */\nexport type MlvEditorAiTransformKind =\n | MlvEditorAiBuiltInTransformKind\n | (string & {});\n\n/**\n * One entry of the AI menu's action list.\n *\n * Hosts pass an array of these to `MlvEditorAiMenu.actions` to replace the\n * built-in list literally — see `mlvEditorAiDefaultActions()` to start from\n * the built-ins instead of retyping them.\n */\nexport interface MlvEditorAiAction {\n /**\n * Transform kind forwarded verbatim to the provider through\n * {@link MlvEditorAiContext.runTransform}. Any string is valid; see\n * {@link MlvEditorAiTransformKind}. Ignored when {@link run} is present.\n *\n * Kinds are not required to be unique within one list: two entries may run\n * the same kind with different instructions.\n */\n readonly kind: MlvEditorAiTransformKind;\n\n /**\n * Display text of the menu item, already resolved. The menu renders it as\n * given and never translates it — a localized list is built by resolving\n * the copy before constructing the actions.\n */\n readonly label: string;\n\n /**\n * Free-form transform argument passed through as\n * {@link MlvEditorAiRequest.instruction}: a fixed tone for `'tone'`, a fixed\n * target language for `'translate'`, or a canned prompt for `'custom'`.\n * Omitted from the request when absent. Ignored when {@link run} is present.\n */\n readonly instruction?: string;\n\n /**\n * Where the result lands; defaults to `'replace-selection'`. Ignored when\n * {@link run} is present.\n */\n readonly output?: MlvEditorAiOutputMode;\n\n /**\n * Escape hatch replacing the menu's own behaviour for this entry.\n *\n * When present the menu calls this instead of `runTransform` and reads\n * neither {@link kind}, {@link instruction}, nor {@link output} — they stay\n * available to the callback itself, which owns the whole action. The\n * argument is the live per-editor {@link MlvEditorAiContext}, so the\n * callback can call `runTransform` with anything (including options this\n * shape cannot express), chain several calls, inspect `status()` /\n * `hasProvider()` / the review surface, or do something else entirely and\n * never touch the AI context at all.\n *\n * It runs only when the item is enabled, so the readonly, disabled, and\n * already-running guards still hold.\n *\n * @param context The AI context of the editor this menu belongs to.\n */\n readonly run?: (context: MlvEditorAiContext) => void;\n}\n\n/**\n * Where the streamed result of a transform lands in the document.\n *\n * `'replace-selection'` overwrites the selected fragment in place.\n * `'insert-below'` keeps the selection and streams the result into a new\n * block after it. `'review'` collects the complete result without touching\n * the document, then lands it as reviewable tracked suggestions the user\n * accepts or rejects through the context's suggestion surface.\n */\nexport type MlvEditorAiOutputMode =\n | 'replace-selection'\n | 'insert-below'\n | 'review';\n\n/**\n * One pending AI change as the Angular context exposes it to review UIs.\n *\n * A projection of the engine-level `MlvEditorAiSuggestion`: the live document\n * range stays internal to the context — positions remap on every transaction\n * and would be stale the moment a template read them. Review surfaces render\n * identity, shape, and the two texts; accept/reject go back through the\n * context by `id`.\n */\nexport interface MlvEditorAiReviewSuggestion {\n /** Stable identifier, unique across sessions within this runtime. */\n readonly id: string;\n\n /**\n * Shape of the change: `'insert'` added text, `'delete'` removed text,\n * `'replace'` swapped text.\n */\n readonly kind: MlvEditorAiSuggestionKind;\n\n /** Plain text the change removed; empty for `'insert'`. */\n readonly oldText: string;\n\n /** Plain text the change added; empty for `'delete'`. */\n readonly newText: string;\n}\n\n/**\n * One structured request handed to an {@link MlvEditorAiProvider}.\n *\n * The editor never builds a prompt: the provider receives the transform kind,\n * the optional instruction, and Markdown context, and owns prompting, model\n * choice, and server-side policy itself.\n */\nexport interface MlvEditorAiRequest {\n /**\n * Requested capability. Either a selection transform or `'autocomplete'`\n * for ghost-text completion at the caret.\n *\n * Not a closed union: a host-supplied action list can name any kind, so a\n * provider that branches on this field must tolerate kinds it does not\n * recognize rather than assume exhaustiveness.\n */\n readonly kind: MlvEditorAiTransformKind | 'autocomplete';\n\n /**\n * Free-form argument for the transform: the custom prompt for `'custom'`,\n * the target tone for `'tone'`, or the target language for `'translate'`.\n * Absent for transforms that need no argument.\n */\n readonly instruction?: string;\n\n /** Markdown context captured from the editor when the request started. */\n readonly context: {\n /** Selected fragment as Markdown, or `null` when nothing is selected. */\n readonly selection: string | null;\n\n /** Optional surrounding document window as Markdown, or `null`. */\n readonly document: string | null;\n };\n\n /**\n * Aborted when the user cancels, presses Escape, or edits the document\n * mid-stream. Providers should stop producing chunks once aborted.\n */\n readonly signal: AbortSignal;\n\n /** Host-defined passthrough metadata; the editor never reads it. */\n readonly meta?: Record<string, unknown>;\n}\n\n/**\n * Host-supplied transport for AI transforms.\n *\n * The library performs no network requests itself. Hosts provide an\n * implementation through the `aiProvider` input on `mlv-editor` or the\n * `MLV_EDITOR_AI_PROVIDER` injection token; the input wins, mirroring the\n * image-uploader precedence rule.\n */\nexport interface MlvEditorAiProvider {\n /**\n * Streams the result of one request as plain Markdown/text chunks.\n *\n * Non-streaming transports may return a single-chunk iterable. A thrown\n * error or rejected iteration surfaces as a recoverable `'ai-transport'`\n * editor error; unusable output surfaces as `'ai-result'`.\n *\n * @param request Structured transform or autocomplete request.\n * @returns Async iterable of Markdown/text chunks in document order.\n */\n stream(request: MlvEditorAiRequest): AsyncIterable<string>;\n}\n"]}
|