documint 0.0.21 → 0.0.23
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 +2 -2
- package/dist/index.d.ts +53 -14
- package/dist/index.js +194 -91
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -16,11 +16,11 @@ A canvas-based, batteries-included markdown editor for React.
|
|
|
16
16
|
|
|
17
17
|
- **Context-aware toolbars ("leaves")** — Floating toolbars that appear based on what you're interacting with: text formatting options on selection, link editing on links, column/row controls on tables, and block insertion (headings, lists, quotes, tables) on empty lines.
|
|
18
18
|
|
|
19
|
-
- **Configurable themes and keybindings** — Ships with built-in light and dark themes, follows the system theme by default, and lets you customize every theme value
|
|
19
|
+
- **Configurable themes and keybindings** — Ships with built-in light and dark themes, follows the system theme by default, and lets you customize every theme value. Keybindings are configurable too — remap formatting shortcuts, navigation, and list operations to match your users' expectations.
|
|
20
20
|
|
|
21
21
|
- **Comments and presence for review workflows** — Anchor comments to any range of text, with full threading (replies, resolution, deletion) and self-repairing quote-based matching after edits. External user and AI agent presence can be projected into the document as live cursors and viewport indicators without becoming document content.
|
|
22
22
|
|
|
23
|
-
- **Fast and lightweight** — Canvas-based rendering optimized for hot-path performance even on large documents. A custom markdown parser, editor engine, and layout/rendering system all ship in a bundle
|
|
23
|
+
- **Fast and lightweight** — Canvas-based rendering optimized for hot-path performance even on large documents. A custom markdown parser, editor engine, and layout/rendering system all ship in a bundle ~100 KB gzipped.
|
|
24
24
|
|
|
25
25
|
## Getting Started
|
|
26
26
|
|
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,7 @@ type Document$1 = {
|
|
|
39
39
|
frontMatter?: string;
|
|
40
40
|
};
|
|
41
41
|
export type Block = ParagraphBlock | HeadingBlock | ListBlock | ListItemBlock | BlockquoteBlock | TableBlock | DividerBlock | CodeBlock | DirectiveBlock | RawBlock;
|
|
42
|
-
export type Inline = Text$1 | Link | Image$1 | Mention |
|
|
42
|
+
export type Inline = Text$1 | Link | Image$1 | Mention | Resource | LineBreak | Raw;
|
|
43
43
|
type DocumentNode<K extends string, P = {}> = {
|
|
44
44
|
id: string;
|
|
45
45
|
type: K;
|
|
@@ -96,7 +96,7 @@ export type RawBlock = BlockNode<"raw", {
|
|
|
96
96
|
originalType: string;
|
|
97
97
|
source: string;
|
|
98
98
|
}>;
|
|
99
|
-
export type Mark = "bold" | "italic" | "strikethrough" | "underline" | "superscript";
|
|
99
|
+
export type Mark = "code" | "bold" | "italic" | "strikethrough" | "underline" | "superscript";
|
|
100
100
|
type Text$1 = DocumentNode<"text", {
|
|
101
101
|
marks: Mark[];
|
|
102
102
|
text: string;
|
|
@@ -116,14 +116,34 @@ type Mention = DocumentNode<"mention", {
|
|
|
116
116
|
name: string;
|
|
117
117
|
userId: string;
|
|
118
118
|
}>;
|
|
119
|
-
type
|
|
120
|
-
|
|
121
|
-
|
|
119
|
+
export type Resource = DocumentNode<"resource", {
|
|
120
|
+
label: string;
|
|
121
|
+
protocol: string;
|
|
122
|
+
url: string;
|
|
122
123
|
}>;
|
|
124
|
+
type LineBreak = DocumentNode<"lineBreak">;
|
|
123
125
|
export type Raw = DocumentNode<"raw", {
|
|
124
126
|
originalType: string;
|
|
125
127
|
source: string;
|
|
126
128
|
}>;
|
|
129
|
+
export type DocumentResourceProtocol = {
|
|
130
|
+
icon?: DocumentResourceIcon;
|
|
131
|
+
label: string;
|
|
132
|
+
};
|
|
133
|
+
export type DocumentResourceIcon = string | DocumentResourceVectorIcon;
|
|
134
|
+
export type DocumentResourceVectorIcon = {
|
|
135
|
+
node: DocumentResourceIconNode;
|
|
136
|
+
type: "svg";
|
|
137
|
+
};
|
|
138
|
+
export type DocumentResourceIconNode = readonly DocumentResourceIconNodeElement[];
|
|
139
|
+
type DocumentResourceIconNodeElement = readonly [
|
|
140
|
+
elementName: string,
|
|
141
|
+
attrs: Readonly<Record<string, string>>
|
|
142
|
+
];
|
|
143
|
+
export type DocumentResourceReference = {
|
|
144
|
+
protocol: string;
|
|
145
|
+
url: string;
|
|
146
|
+
};
|
|
127
147
|
export type DocumintStorage = {
|
|
128
148
|
readFile(path: string): Promise<Blob | null>;
|
|
129
149
|
writeFile(file: File): Promise<string>;
|
|
@@ -161,7 +181,7 @@ export type EditorTheme = {
|
|
|
161
181
|
inlineCodeText?: string;
|
|
162
182
|
insertHighlightText?: string;
|
|
163
183
|
leafAccent: string;
|
|
164
|
-
leafBackground
|
|
184
|
+
leafBackground?: string;
|
|
165
185
|
leafBorder: string;
|
|
166
186
|
leafInputBackground: string;
|
|
167
187
|
leafButtonText?: string;
|
|
@@ -207,7 +227,10 @@ export type DocumentPresence = {
|
|
|
207
227
|
userId: string;
|
|
208
228
|
cursor?: Anchor;
|
|
209
229
|
color?: string;
|
|
230
|
+
status?: string;
|
|
210
231
|
};
|
|
232
|
+
export type ResourceProtocolRecord = ReadonlyMap<string, DocumentResourceProtocol> | Record<string, DocumentResourceProtocol>;
|
|
233
|
+
export type ActiveResourceSet = ReadonlySet<string> | readonly string[] | Record<string, boolean>;
|
|
211
234
|
export type EditorInputKeybinding = {
|
|
212
235
|
altKey?: boolean;
|
|
213
236
|
command: EditorInputCommand;
|
|
@@ -216,24 +239,44 @@ export type EditorInputKeybinding = {
|
|
|
216
239
|
shiftKey?: boolean | "any";
|
|
217
240
|
};
|
|
218
241
|
export declare const defaultKeybindings: EditorInputKeybinding[];
|
|
242
|
+
export type DocumintPatch = {
|
|
243
|
+
revision: string | null;
|
|
244
|
+
changes: DocumintPatchChange[];
|
|
245
|
+
};
|
|
246
|
+
export type DocumintPatchChange = {
|
|
247
|
+
startLine: number;
|
|
248
|
+
endLine: number;
|
|
249
|
+
text: string;
|
|
250
|
+
};
|
|
251
|
+
export declare function applyDocumintPatch(content: string, patch: DocumintPatch): string;
|
|
219
252
|
export type DocumintDecoration = {
|
|
220
253
|
backgroundColor?: string;
|
|
221
254
|
pulse?: boolean;
|
|
222
255
|
color?: string;
|
|
223
256
|
pattern: RegExp;
|
|
224
257
|
};
|
|
258
|
+
export type UserMentionEvent = {
|
|
259
|
+
lineMarkdown: string;
|
|
260
|
+
lineNumber: number;
|
|
261
|
+
userId: string;
|
|
262
|
+
};
|
|
225
263
|
export type DocumintProps = {
|
|
226
264
|
content: string;
|
|
227
265
|
className?: string;
|
|
266
|
+
revision?: string | null;
|
|
228
267
|
actions?: DocumintActions;
|
|
229
268
|
theme?: DocumintTheme;
|
|
230
269
|
keybindings?: EditorInputKeybinding[];
|
|
231
270
|
decorations?: readonly DocumintDecoration[];
|
|
232
271
|
presence?: DocumentPresence[];
|
|
272
|
+
protocols?: ResourceProtocolRecord;
|
|
273
|
+
resources?: ActiveResourceSet;
|
|
233
274
|
storage?: DocumintStorage;
|
|
234
275
|
users?: DocumentUser[];
|
|
235
|
-
onContentChanged?: (content: string, document: Document$1) => void;
|
|
276
|
+
onContentChanged?: (content: string, document: Document$1, patch: DocumintPatch | null) => void;
|
|
236
277
|
onCommentChanged?: (change: CommentChange) => void;
|
|
278
|
+
onResourceOpened?: (resource: DocumentResourceReference) => void;
|
|
279
|
+
onResourcesRequested?: (resources: readonly DocumentResourceReference[]) => void;
|
|
237
280
|
onUserMentioned?: (event: UserMentionEvent) => void;
|
|
238
281
|
};
|
|
239
282
|
export type DocumintAction<T> = {
|
|
@@ -263,11 +306,6 @@ export type CommentChange = {
|
|
|
263
306
|
thread: CommentThread;
|
|
264
307
|
threadId: string;
|
|
265
308
|
};
|
|
266
|
-
export type UserMentionEvent = {
|
|
267
|
-
lineMarkdown: string;
|
|
268
|
-
lineNumber: number;
|
|
269
|
-
userId: string;
|
|
270
|
-
};
|
|
271
309
|
export type DocumintTheme = EditorTheme | {
|
|
272
310
|
dark: EditorTheme;
|
|
273
311
|
light: EditorTheme;
|
|
@@ -275,8 +313,9 @@ export type DocumintTheme = EditorTheme | {
|
|
|
275
313
|
export declare function Documint({ content, ...props }: DocumintProps): import("react/jsx-runtime").JSX.Element;
|
|
276
314
|
export declare const lightTheme: EditorTheme;
|
|
277
315
|
export declare const darkTheme: EditorTheme;
|
|
278
|
-
export declare
|
|
279
|
-
export declare
|
|
316
|
+
export declare function lucideResourceIcon(node: DocumentResourceIconNode): DocumentResourceIcon;
|
|
317
|
+
export declare function normalizeResourceProtocol(protocol: string): string | null;
|
|
318
|
+
export declare function resolveResourceProtocol(url: string): string | null;
|
|
280
319
|
|
|
281
320
|
export {
|
|
282
321
|
Comment$1 as Comment,
|