@kedataindo/docflow-plugins 0.0.4 → 0.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunk-CLCSH4NX.js +1078 -0
- package/dist/chunk-MZZTJIFJ.js +1417 -0
- package/dist/citations.cjs +1458 -0
- package/dist/citations.d.cts +132 -0
- package/dist/citations.d.ts +132 -0
- package/dist/citations.js +18 -0
- package/dist/index.cjs +2553 -21
- package/dist/index.d.cts +215 -2
- package/dist/index.d.ts +215 -2
- package/dist/index.js +1127 -18
- package/package.json +26 -9
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import * as _kedata_indonesia_docflow_core from '@kedataindo/docflow-core';
|
|
2
|
+
import { AIAction, DocsEditorPlugin } from '@kedataindo/docflow-core';
|
|
2
3
|
export { DocsEditorPlugin, FontSizeExtension, SlashCommand, ToolbarItem } from '@kedataindo/docflow-core';
|
|
3
|
-
import { Node } from '@tiptap/core';
|
|
4
|
+
import { Extension, Node, Editor, Mark } from '@tiptap/core';
|
|
5
|
+
import { CiteEngine } from './citations.cjs';
|
|
6
|
+
export { CSL_LOCALE_EN_US, CSL_STYLES, CitationAttrs, CitationCluster, CitationMode, CiteEngineOptions, CslStyleInfo, DEFAULT_CSL_STYLE, buildCitationNodes, nextCitationId, sanitizeCiteprocHtml } from './citations.cjs';
|
|
7
|
+
import { PluginKey } from '@tiptap/pm/state';
|
|
8
|
+
|
|
9
|
+
declare function getCitationEngine(editor: Editor): CiteEngine | null;
|
|
10
|
+
/**
|
|
11
|
+
* Carries the document-scoped CiteEngine in editor storage. The engine is
|
|
12
|
+
* created by citationPlugin.hooks.onInit (from the injected CitationPort) and
|
|
13
|
+
* disposed on destroy — one instance per editor, never per node.
|
|
14
|
+
*/
|
|
15
|
+
declare const CitationEngineExtension: Extension<any, any>;
|
|
16
|
+
/**
|
|
17
|
+
* Inline citation — `{ sourceId, locator, … }` only. The visible text is
|
|
18
|
+
* derived by the CiteEngine at render time and is NEVER stored in the
|
|
19
|
+
* document (the #1 correctness invariant of the phase-6 design: two clients
|
|
20
|
+
* with the same sources + style derive identical output through Yjs).
|
|
21
|
+
*/
|
|
22
|
+
declare const CitationNode: Node<any, any>;
|
|
23
|
+
declare const citationPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
4
24
|
|
|
5
25
|
declare const formattingPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
6
26
|
|
|
@@ -32,6 +52,54 @@ declare const pageBreakPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
|
32
52
|
declare const FootnoteNode: Node<any, any>;
|
|
33
53
|
declare const footnotePlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
34
54
|
|
|
55
|
+
interface TocHeading {
|
|
56
|
+
level: number;
|
|
57
|
+
text: string;
|
|
58
|
+
pos: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Walk the doc and collect H1–H3 headings in document order. Same algorithm
|
|
62
|
+
* as the outline sidebar (TOCSidebar.vue) — positions are captured now and go
|
|
63
|
+
* stale as the doc is edited; refresh to recapture.
|
|
64
|
+
*/
|
|
65
|
+
declare function collectHeadings(editor: Editor): TocHeading[];
|
|
66
|
+
/** Standalone refresh (refresh button, plugin action): builds and dispatches its own transaction. */
|
|
67
|
+
declare function regenerateToc(editor: Editor): boolean;
|
|
68
|
+
declare module '@tiptap/core' {
|
|
69
|
+
interface Commands<ReturnType> {
|
|
70
|
+
toc: {
|
|
71
|
+
/** Insert a table-of-contents block prefilled with the current H1–H3 headings. */
|
|
72
|
+
insertToc: () => ReturnType;
|
|
73
|
+
/** Regenerate the entries of every toc block from the current headings. */
|
|
74
|
+
refreshToc: () => ReturnType;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A page number inside a TOC entry — an inline atom holding the page captured
|
|
80
|
+
* at generation time (GDocs "with page numbers": stale until refresh). Being
|
|
81
|
+
* real node content, it serializes to JSON (attrs.page) and to HTML as an
|
|
82
|
+
* actual `<span>` with the number as text, so exports show it even without
|
|
83
|
+
* the editor stylesheet.
|
|
84
|
+
*/
|
|
85
|
+
declare const TocPageNumNode: Node<any, any>;
|
|
86
|
+
/**
|
|
87
|
+
* One TOC entry — a paragraph variant carrying the heading level (CSS indents
|
|
88
|
+
* by it) and the heading's doc position at generation time (click-to-jump).
|
|
89
|
+
* Only valid inside a `toc` block (no group), so regular paragraphs never
|
|
90
|
+
* turn into entries and entries never leak into the doc body.
|
|
91
|
+
*/
|
|
92
|
+
declare const TocEntryNode: Node<any, any>;
|
|
93
|
+
/**
|
|
94
|
+
* Table of contents — a container block holding real generated entry
|
|
95
|
+
* paragraphs (one per H1–H3). The entries are real document content, so
|
|
96
|
+
* export/print/Yjs/undo all work without special-casing; the `0` hole in
|
|
97
|
+
* renderHTML is what keeps them in the serialized output. The NodeView adds
|
|
98
|
+
* only the chrome (caption + refresh button) around the contentDOM.
|
|
99
|
+
*/
|
|
100
|
+
declare const TocNode: Node<any, any>;
|
|
101
|
+
declare const tocPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
102
|
+
|
|
35
103
|
/**
|
|
36
104
|
* fontSizePlugin — provides the `setFontSize` command action for toolbar use.
|
|
37
105
|
*
|
|
@@ -42,6 +110,151 @@ declare const footnotePlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
|
42
110
|
*/
|
|
43
111
|
declare const fontSizePlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
44
112
|
|
|
113
|
+
declare const textColorPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
114
|
+
|
|
115
|
+
declare const highlightPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* AI writing assistance (Phase 7B inline transforms + 7C generation at cursor).
|
|
119
|
+
*
|
|
120
|
+
* The two non-negotiables from the phase-7 design:
|
|
121
|
+
*
|
|
122
|
+
* 1. Streaming NEVER mutates the document. Tokens accumulate in plugin state
|
|
123
|
+
* and render as decorations (highlight + ghost preview). Meta-only
|
|
124
|
+
* transactions carry no steps, so a collaborative Yjs doc sees zero churn
|
|
125
|
+
* while a preview streams.
|
|
126
|
+
* 2. Accept is ONE ProseMirror transaction replacing the selection range
|
|
127
|
+
* (transform) or inserting at the cursor (generate), so y-prosemirror
|
|
128
|
+
* propagates it exactly like a human edit.
|
|
129
|
+
*
|
|
130
|
+
* The library never names a URL: the host injects `aiStream` through the
|
|
131
|
+
* editorContext port (mirroring onImageUpload). Without it, actions are inert.
|
|
132
|
+
*/
|
|
133
|
+
type AIMode = 'transform' | 'generate';
|
|
134
|
+
interface AIPreviewState {
|
|
135
|
+
mode: AIMode;
|
|
136
|
+
/** 'prompt' — waiting for the /ai instruction input (7C, generate only). */
|
|
137
|
+
status: 'prompt' | 'streaming' | 'done' | 'error';
|
|
138
|
+
/**
|
|
139
|
+
* Transform: range of the original selection. Generate: collapsed cursor
|
|
140
|
+
* position. Mapped through doc changes.
|
|
141
|
+
*/
|
|
142
|
+
from: number;
|
|
143
|
+
to: number;
|
|
144
|
+
/** Selection text at start (transform) — detects external edits; '' for generate. */
|
|
145
|
+
originalText: string;
|
|
146
|
+
/** Accumulated streamed text. */
|
|
147
|
+
text: string;
|
|
148
|
+
action: AIAction;
|
|
149
|
+
error?: string;
|
|
150
|
+
}
|
|
151
|
+
declare const aiPluginKey: PluginKey<AIPreviewState | null>;
|
|
152
|
+
declare function getAIPreview(editor: Editor): AIPreviewState | null;
|
|
153
|
+
declare module '@tiptap/core' {
|
|
154
|
+
interface Commands<ReturnType> {
|
|
155
|
+
ai: {
|
|
156
|
+
/** Start an AI transform over the current selection (streams a preview). */
|
|
157
|
+
aiTransform: (options: {
|
|
158
|
+
action: AIAction;
|
|
159
|
+
prompt?: string;
|
|
160
|
+
}) => ReturnType;
|
|
161
|
+
/** Open the /ai prompt input at the cursor (7C). */
|
|
162
|
+
aiGenerate: () => ReturnType;
|
|
163
|
+
/** Submit the /ai instruction and stream ghost text at the cursor (7C). */
|
|
164
|
+
aiPromptSubmit: (options: {
|
|
165
|
+
prompt: string;
|
|
166
|
+
}) => ReturnType;
|
|
167
|
+
/** Apply the streamed text in ONE transaction (replace or insert). */
|
|
168
|
+
aiAccept: () => ReturnType;
|
|
169
|
+
/** Discard the preview; the document stays untouched. */
|
|
170
|
+
aiReject: () => ReturnType;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
declare const AIExtension: Extension<any, any>;
|
|
175
|
+
declare const aiPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Phase 9 P9-4 — comment plugin.
|
|
179
|
+
*
|
|
180
|
+
* The mark carries ONLY \`threadId\` — never the anchored text. The
|
|
181
|
+
* anchored text + position live in the server-side CommentThread
|
|
182
|
+
* record; the mark is the in-doc pointer to that record. This is the
|
|
183
|
+
* same invariant the citation plugin uses (Phase 6), extended with
|
|
184
|
+
* thread id + position.
|
|
185
|
+
*
|
|
186
|
+
* ### Anchor survival (v1 — position-based)
|
|
187
|
+
*
|
|
188
|
+
* This v1 stores the absolute document position at the time the
|
|
189
|
+
* comment was created. It survives concurrent edits from OTHER
|
|
190
|
+
* users until someone deletes or restructures the surrounding text.
|
|
191
|
+
* For a docflow-style \"inline review comment\" workflow, drift is
|
|
192
|
+
* rare (commenters don't aggressively edit each other's paragraphs
|
|
193
|
+
* mid-review) and the rendered side panel shows the snippet + author
|
|
194
|
+
* so the reader can locate the anchor by content if needed.
|
|
195
|
+
*
|
|
196
|
+
* v2 (follow-up PR) replaces the position field with a Yjs
|
|
197
|
+
* RelativePosition — recommended in the Phase 9 plan §3 spec but
|
|
198
|
+
* deferred because it requires:
|
|
199
|
+
* 1. Yjs encode/decode logic over the mark range.
|
|
200
|
+
* 2. A tombstone strategy when the anchored text is deleted.
|
|
201
|
+
* 3. A migration path for v1 anchors.
|
|
202
|
+
* Phase 9 v1 is the user-visible win; v2 is the robustness upgrade.
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The mark carries only the threadId + the position-at-creation-time.
|
|
207
|
+
* The threadId is the link to the server-side CommentThread record
|
|
208
|
+
* (route: GET /api/documents/:id/comments/:threadId); the position is
|
|
209
|
+
* used by the UI to focus / scroll to the anchor when a thread is
|
|
210
|
+
* selected from the sidebar. Text-content is never stored on the
|
|
211
|
+
* mark — the server-side thread holds the snippet captured at
|
|
212
|
+
* creation time.
|
|
213
|
+
*/
|
|
214
|
+
interface CommentMarkAttrs {
|
|
215
|
+
threadId: string;
|
|
216
|
+
/** Document position at creation time (volatile — recomputed by the
|
|
217
|
+
* editor on each click). v2 will replace this with a Yjs
|
|
218
|
+
* RelativePosition. */
|
|
219
|
+
pos: number;
|
|
220
|
+
}
|
|
221
|
+
declare const CommentMark: Mark<any, any>;
|
|
222
|
+
/**
|
|
223
|
+
* The comment plugin (Phase 9 P9-4). Library-only — server-side
|
|
224
|
+
* persistence + role-gated API + UI live in apps/server + apps/web.
|
|
225
|
+
*/
|
|
226
|
+
declare const commentPlugin: DocsEditorPlugin;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Bibliography — a fully derived block. It stores NOTHING (no attrs): the
|
|
230
|
+
* node view renders the engine's citeproc-sorted entries and repaints on
|
|
231
|
+
* every engine change (source edit, style switch, citation add/remove).
|
|
232
|
+
*/
|
|
233
|
+
declare const BibliographyNode: Node<any, any>;
|
|
234
|
+
|
|
235
|
+
interface SlashState {
|
|
236
|
+
open: boolean;
|
|
237
|
+
query: string;
|
|
238
|
+
position: {
|
|
239
|
+
top: number;
|
|
240
|
+
left: number;
|
|
241
|
+
};
|
|
242
|
+
commands: Array<{
|
|
243
|
+
name: string;
|
|
244
|
+
command: string;
|
|
245
|
+
action: (() => boolean) | null;
|
|
246
|
+
}>;
|
|
247
|
+
selectedIndex: number;
|
|
248
|
+
}
|
|
249
|
+
declare let slashState: SlashState;
|
|
250
|
+
declare function onSlashStateChange(fn: () => void): () => void;
|
|
251
|
+
declare function registerSlashCommands(editorId: string, commands: Array<{
|
|
252
|
+
name: string;
|
|
253
|
+
command: string;
|
|
254
|
+
}>): void;
|
|
255
|
+
declare const SlashMenuExtension: Extension<any, any>;
|
|
256
|
+
declare const slashMenuPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
257
|
+
|
|
45
258
|
declare const defaultPlugins: _kedata_indonesia_docflow_core.DocsEditorPlugin[];
|
|
46
259
|
|
|
47
|
-
export { FootnoteNode, PageBreak, type PlaceholderPluginOptions, alignmentPlugin, blockquotePlugin, codeBlockPlugin, createPlaceholderPlugin, defaultPlugins, fontSizePlugin, footnotePlugin, formattingPlugin, headingsPlugin, imagePlugin, linkPlugin, listsPlugin, pageBreakPlugin, placeholderPlugin, tablePlugin };
|
|
260
|
+
export { AIExtension, type AIPreviewState, BibliographyNode, CitationEngineExtension, CitationNode, CiteEngine, type CommentMarkAttrs, CommentMark as CommentMarkExtension, FootnoteNode, PageBreak, type PlaceholderPluginOptions, SlashMenuExtension, TocEntryNode, TocNode, TocPageNumNode, aiPlugin, aiPluginKey, alignmentPlugin, blockquotePlugin, citationPlugin, codeBlockPlugin, collectHeadings, commentPlugin, createPlaceholderPlugin, defaultPlugins, fontSizePlugin, footnotePlugin, formattingPlugin, getAIPreview, getCitationEngine, headingsPlugin, highlightPlugin, imagePlugin, linkPlugin, listsPlugin, onSlashStateChange, pageBreakPlugin, placeholderPlugin, regenerateToc, registerSlashCommands, slashMenuPlugin, slashState, tablePlugin, textColorPlugin, tocPlugin };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,26 @@
|
|
|
1
1
|
import * as _kedata_indonesia_docflow_core from '@kedataindo/docflow-core';
|
|
2
|
+
import { AIAction, DocsEditorPlugin } from '@kedataindo/docflow-core';
|
|
2
3
|
export { DocsEditorPlugin, FontSizeExtension, SlashCommand, ToolbarItem } from '@kedataindo/docflow-core';
|
|
3
|
-
import { Node } from '@tiptap/core';
|
|
4
|
+
import { Extension, Node, Editor, Mark } from '@tiptap/core';
|
|
5
|
+
import { CiteEngine } from './citations.js';
|
|
6
|
+
export { CSL_LOCALE_EN_US, CSL_STYLES, CitationAttrs, CitationCluster, CitationMode, CiteEngineOptions, CslStyleInfo, DEFAULT_CSL_STYLE, buildCitationNodes, nextCitationId, sanitizeCiteprocHtml } from './citations.js';
|
|
7
|
+
import { PluginKey } from '@tiptap/pm/state';
|
|
8
|
+
|
|
9
|
+
declare function getCitationEngine(editor: Editor): CiteEngine | null;
|
|
10
|
+
/**
|
|
11
|
+
* Carries the document-scoped CiteEngine in editor storage. The engine is
|
|
12
|
+
* created by citationPlugin.hooks.onInit (from the injected CitationPort) and
|
|
13
|
+
* disposed on destroy — one instance per editor, never per node.
|
|
14
|
+
*/
|
|
15
|
+
declare const CitationEngineExtension: Extension<any, any>;
|
|
16
|
+
/**
|
|
17
|
+
* Inline citation — `{ sourceId, locator, … }` only. The visible text is
|
|
18
|
+
* derived by the CiteEngine at render time and is NEVER stored in the
|
|
19
|
+
* document (the #1 correctness invariant of the phase-6 design: two clients
|
|
20
|
+
* with the same sources + style derive identical output through Yjs).
|
|
21
|
+
*/
|
|
22
|
+
declare const CitationNode: Node<any, any>;
|
|
23
|
+
declare const citationPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
4
24
|
|
|
5
25
|
declare const formattingPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
6
26
|
|
|
@@ -32,6 +52,54 @@ declare const pageBreakPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
|
32
52
|
declare const FootnoteNode: Node<any, any>;
|
|
33
53
|
declare const footnotePlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
34
54
|
|
|
55
|
+
interface TocHeading {
|
|
56
|
+
level: number;
|
|
57
|
+
text: string;
|
|
58
|
+
pos: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Walk the doc and collect H1–H3 headings in document order. Same algorithm
|
|
62
|
+
* as the outline sidebar (TOCSidebar.vue) — positions are captured now and go
|
|
63
|
+
* stale as the doc is edited; refresh to recapture.
|
|
64
|
+
*/
|
|
65
|
+
declare function collectHeadings(editor: Editor): TocHeading[];
|
|
66
|
+
/** Standalone refresh (refresh button, plugin action): builds and dispatches its own transaction. */
|
|
67
|
+
declare function regenerateToc(editor: Editor): boolean;
|
|
68
|
+
declare module '@tiptap/core' {
|
|
69
|
+
interface Commands<ReturnType> {
|
|
70
|
+
toc: {
|
|
71
|
+
/** Insert a table-of-contents block prefilled with the current H1–H3 headings. */
|
|
72
|
+
insertToc: () => ReturnType;
|
|
73
|
+
/** Regenerate the entries of every toc block from the current headings. */
|
|
74
|
+
refreshToc: () => ReturnType;
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A page number inside a TOC entry — an inline atom holding the page captured
|
|
80
|
+
* at generation time (GDocs "with page numbers": stale until refresh). Being
|
|
81
|
+
* real node content, it serializes to JSON (attrs.page) and to HTML as an
|
|
82
|
+
* actual `<span>` with the number as text, so exports show it even without
|
|
83
|
+
* the editor stylesheet.
|
|
84
|
+
*/
|
|
85
|
+
declare const TocPageNumNode: Node<any, any>;
|
|
86
|
+
/**
|
|
87
|
+
* One TOC entry — a paragraph variant carrying the heading level (CSS indents
|
|
88
|
+
* by it) and the heading's doc position at generation time (click-to-jump).
|
|
89
|
+
* Only valid inside a `toc` block (no group), so regular paragraphs never
|
|
90
|
+
* turn into entries and entries never leak into the doc body.
|
|
91
|
+
*/
|
|
92
|
+
declare const TocEntryNode: Node<any, any>;
|
|
93
|
+
/**
|
|
94
|
+
* Table of contents — a container block holding real generated entry
|
|
95
|
+
* paragraphs (one per H1–H3). The entries are real document content, so
|
|
96
|
+
* export/print/Yjs/undo all work without special-casing; the `0` hole in
|
|
97
|
+
* renderHTML is what keeps them in the serialized output. The NodeView adds
|
|
98
|
+
* only the chrome (caption + refresh button) around the contentDOM.
|
|
99
|
+
*/
|
|
100
|
+
declare const TocNode: Node<any, any>;
|
|
101
|
+
declare const tocPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
102
|
+
|
|
35
103
|
/**
|
|
36
104
|
* fontSizePlugin — provides the `setFontSize` command action for toolbar use.
|
|
37
105
|
*
|
|
@@ -42,6 +110,151 @@ declare const footnotePlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
|
42
110
|
*/
|
|
43
111
|
declare const fontSizePlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
44
112
|
|
|
113
|
+
declare const textColorPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
114
|
+
|
|
115
|
+
declare const highlightPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* AI writing assistance (Phase 7B inline transforms + 7C generation at cursor).
|
|
119
|
+
*
|
|
120
|
+
* The two non-negotiables from the phase-7 design:
|
|
121
|
+
*
|
|
122
|
+
* 1. Streaming NEVER mutates the document. Tokens accumulate in plugin state
|
|
123
|
+
* and render as decorations (highlight + ghost preview). Meta-only
|
|
124
|
+
* transactions carry no steps, so a collaborative Yjs doc sees zero churn
|
|
125
|
+
* while a preview streams.
|
|
126
|
+
* 2. Accept is ONE ProseMirror transaction replacing the selection range
|
|
127
|
+
* (transform) or inserting at the cursor (generate), so y-prosemirror
|
|
128
|
+
* propagates it exactly like a human edit.
|
|
129
|
+
*
|
|
130
|
+
* The library never names a URL: the host injects `aiStream` through the
|
|
131
|
+
* editorContext port (mirroring onImageUpload). Without it, actions are inert.
|
|
132
|
+
*/
|
|
133
|
+
type AIMode = 'transform' | 'generate';
|
|
134
|
+
interface AIPreviewState {
|
|
135
|
+
mode: AIMode;
|
|
136
|
+
/** 'prompt' — waiting for the /ai instruction input (7C, generate only). */
|
|
137
|
+
status: 'prompt' | 'streaming' | 'done' | 'error';
|
|
138
|
+
/**
|
|
139
|
+
* Transform: range of the original selection. Generate: collapsed cursor
|
|
140
|
+
* position. Mapped through doc changes.
|
|
141
|
+
*/
|
|
142
|
+
from: number;
|
|
143
|
+
to: number;
|
|
144
|
+
/** Selection text at start (transform) — detects external edits; '' for generate. */
|
|
145
|
+
originalText: string;
|
|
146
|
+
/** Accumulated streamed text. */
|
|
147
|
+
text: string;
|
|
148
|
+
action: AIAction;
|
|
149
|
+
error?: string;
|
|
150
|
+
}
|
|
151
|
+
declare const aiPluginKey: PluginKey<AIPreviewState | null>;
|
|
152
|
+
declare function getAIPreview(editor: Editor): AIPreviewState | null;
|
|
153
|
+
declare module '@tiptap/core' {
|
|
154
|
+
interface Commands<ReturnType> {
|
|
155
|
+
ai: {
|
|
156
|
+
/** Start an AI transform over the current selection (streams a preview). */
|
|
157
|
+
aiTransform: (options: {
|
|
158
|
+
action: AIAction;
|
|
159
|
+
prompt?: string;
|
|
160
|
+
}) => ReturnType;
|
|
161
|
+
/** Open the /ai prompt input at the cursor (7C). */
|
|
162
|
+
aiGenerate: () => ReturnType;
|
|
163
|
+
/** Submit the /ai instruction and stream ghost text at the cursor (7C). */
|
|
164
|
+
aiPromptSubmit: (options: {
|
|
165
|
+
prompt: string;
|
|
166
|
+
}) => ReturnType;
|
|
167
|
+
/** Apply the streamed text in ONE transaction (replace or insert). */
|
|
168
|
+
aiAccept: () => ReturnType;
|
|
169
|
+
/** Discard the preview; the document stays untouched. */
|
|
170
|
+
aiReject: () => ReturnType;
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
declare const AIExtension: Extension<any, any>;
|
|
175
|
+
declare const aiPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Phase 9 P9-4 — comment plugin.
|
|
179
|
+
*
|
|
180
|
+
* The mark carries ONLY \`threadId\` — never the anchored text. The
|
|
181
|
+
* anchored text + position live in the server-side CommentThread
|
|
182
|
+
* record; the mark is the in-doc pointer to that record. This is the
|
|
183
|
+
* same invariant the citation plugin uses (Phase 6), extended with
|
|
184
|
+
* thread id + position.
|
|
185
|
+
*
|
|
186
|
+
* ### Anchor survival (v1 — position-based)
|
|
187
|
+
*
|
|
188
|
+
* This v1 stores the absolute document position at the time the
|
|
189
|
+
* comment was created. It survives concurrent edits from OTHER
|
|
190
|
+
* users until someone deletes or restructures the surrounding text.
|
|
191
|
+
* For a docflow-style \"inline review comment\" workflow, drift is
|
|
192
|
+
* rare (commenters don't aggressively edit each other's paragraphs
|
|
193
|
+
* mid-review) and the rendered side panel shows the snippet + author
|
|
194
|
+
* so the reader can locate the anchor by content if needed.
|
|
195
|
+
*
|
|
196
|
+
* v2 (follow-up PR) replaces the position field with a Yjs
|
|
197
|
+
* RelativePosition — recommended in the Phase 9 plan §3 spec but
|
|
198
|
+
* deferred because it requires:
|
|
199
|
+
* 1. Yjs encode/decode logic over the mark range.
|
|
200
|
+
* 2. A tombstone strategy when the anchored text is deleted.
|
|
201
|
+
* 3. A migration path for v1 anchors.
|
|
202
|
+
* Phase 9 v1 is the user-visible win; v2 is the robustness upgrade.
|
|
203
|
+
*/
|
|
204
|
+
|
|
205
|
+
/**
|
|
206
|
+
* The mark carries only the threadId + the position-at-creation-time.
|
|
207
|
+
* The threadId is the link to the server-side CommentThread record
|
|
208
|
+
* (route: GET /api/documents/:id/comments/:threadId); the position is
|
|
209
|
+
* used by the UI to focus / scroll to the anchor when a thread is
|
|
210
|
+
* selected from the sidebar. Text-content is never stored on the
|
|
211
|
+
* mark — the server-side thread holds the snippet captured at
|
|
212
|
+
* creation time.
|
|
213
|
+
*/
|
|
214
|
+
interface CommentMarkAttrs {
|
|
215
|
+
threadId: string;
|
|
216
|
+
/** Document position at creation time (volatile — recomputed by the
|
|
217
|
+
* editor on each click). v2 will replace this with a Yjs
|
|
218
|
+
* RelativePosition. */
|
|
219
|
+
pos: number;
|
|
220
|
+
}
|
|
221
|
+
declare const CommentMark: Mark<any, any>;
|
|
222
|
+
/**
|
|
223
|
+
* The comment plugin (Phase 9 P9-4). Library-only — server-side
|
|
224
|
+
* persistence + role-gated API + UI live in apps/server + apps/web.
|
|
225
|
+
*/
|
|
226
|
+
declare const commentPlugin: DocsEditorPlugin;
|
|
227
|
+
|
|
228
|
+
/**
|
|
229
|
+
* Bibliography — a fully derived block. It stores NOTHING (no attrs): the
|
|
230
|
+
* node view renders the engine's citeproc-sorted entries and repaints on
|
|
231
|
+
* every engine change (source edit, style switch, citation add/remove).
|
|
232
|
+
*/
|
|
233
|
+
declare const BibliographyNode: Node<any, any>;
|
|
234
|
+
|
|
235
|
+
interface SlashState {
|
|
236
|
+
open: boolean;
|
|
237
|
+
query: string;
|
|
238
|
+
position: {
|
|
239
|
+
top: number;
|
|
240
|
+
left: number;
|
|
241
|
+
};
|
|
242
|
+
commands: Array<{
|
|
243
|
+
name: string;
|
|
244
|
+
command: string;
|
|
245
|
+
action: (() => boolean) | null;
|
|
246
|
+
}>;
|
|
247
|
+
selectedIndex: number;
|
|
248
|
+
}
|
|
249
|
+
declare let slashState: SlashState;
|
|
250
|
+
declare function onSlashStateChange(fn: () => void): () => void;
|
|
251
|
+
declare function registerSlashCommands(editorId: string, commands: Array<{
|
|
252
|
+
name: string;
|
|
253
|
+
command: string;
|
|
254
|
+
}>): void;
|
|
255
|
+
declare const SlashMenuExtension: Extension<any, any>;
|
|
256
|
+
declare const slashMenuPlugin: _kedata_indonesia_docflow_core.DocsEditorPlugin;
|
|
257
|
+
|
|
45
258
|
declare const defaultPlugins: _kedata_indonesia_docflow_core.DocsEditorPlugin[];
|
|
46
259
|
|
|
47
|
-
export { FootnoteNode, PageBreak, type PlaceholderPluginOptions, alignmentPlugin, blockquotePlugin, codeBlockPlugin, createPlaceholderPlugin, defaultPlugins, fontSizePlugin, footnotePlugin, formattingPlugin, headingsPlugin, imagePlugin, linkPlugin, listsPlugin, pageBreakPlugin, placeholderPlugin, tablePlugin };
|
|
260
|
+
export { AIExtension, type AIPreviewState, BibliographyNode, CitationEngineExtension, CitationNode, CiteEngine, type CommentMarkAttrs, CommentMark as CommentMarkExtension, FootnoteNode, PageBreak, type PlaceholderPluginOptions, SlashMenuExtension, TocEntryNode, TocNode, TocPageNumNode, aiPlugin, aiPluginKey, alignmentPlugin, blockquotePlugin, citationPlugin, codeBlockPlugin, collectHeadings, commentPlugin, createPlaceholderPlugin, defaultPlugins, fontSizePlugin, footnotePlugin, formattingPlugin, getAIPreview, getCitationEngine, headingsPlugin, highlightPlugin, imagePlugin, linkPlugin, listsPlugin, onSlashStateChange, pageBreakPlugin, placeholderPlugin, regenerateToc, registerSlashCommands, slashMenuPlugin, slashState, tablePlugin, textColorPlugin, tocPlugin };
|