documint 0.0.10 → 0.0.12
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 +31 -2
- package/dist/index.d.ts +23 -2
- package/dist/index.js +120 -64
- package/package.json +4 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ A canvas-based, batteries-included markdown editor for React.
|
|
|
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 <80 KB gzipped.
|
|
24
24
|
|
|
25
25
|
## Getting Started
|
|
26
26
|
|
|
@@ -44,6 +44,35 @@ export function App() {
|
|
|
44
44
|
}
|
|
45
45
|
```
|
|
46
46
|
|
|
47
|
+
## Custom Actions
|
|
48
|
+
|
|
49
|
+
Use the `actions` prop to add custom buttons to contextual leaf menus. The first supported target is `selection`, which appears in the annotation toolbar when text is selected. Each action provides a Lucide icon name and receives the selected text when clicked.
|
|
50
|
+
|
|
51
|
+
```tsx
|
|
52
|
+
import { useState } from "react";
|
|
53
|
+
import { Documint } from "documint";
|
|
54
|
+
|
|
55
|
+
export function App() {
|
|
56
|
+
const [content, setContent] = useState("Select this text");
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<Documint
|
|
60
|
+
content={content}
|
|
61
|
+
onContentChanged={setContent}
|
|
62
|
+
actions={{
|
|
63
|
+
selection: {
|
|
64
|
+
icon: "copy",
|
|
65
|
+
label: "Copy selected text",
|
|
66
|
+
onClick: (selectedText) => {
|
|
67
|
+
navigator.clipboard.writeText(selectedText);
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
}}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
47
76
|
## Custom Themes
|
|
48
77
|
|
|
49
78
|
By default, Documint will detect the end-user's system theme and apply either the built-in light or dark theme. You can also specify a theme explicitly by passing `"light"` or `"dark"` to the `theme` prop, or provide a custom theme object with your own colors and styles.
|
|
@@ -95,4 +124,4 @@ export function App() {
|
|
|
95
124
|
|
|
96
125
|
return <Documint content={content} onContentChanged={setContent} storage={storage} />;
|
|
97
126
|
}
|
|
98
|
-
```
|
|
127
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { LucideIcon } from 'lucide-react';
|
|
2
|
+
|
|
1
3
|
export type CommentThread = {
|
|
2
4
|
quote: string;
|
|
3
5
|
comments: Comment$1[];
|
|
@@ -14,7 +16,7 @@ type Document$1 = {
|
|
|
14
16
|
frontMatter?: string;
|
|
15
17
|
};
|
|
16
18
|
export type Block = ParagraphBlock | HeadingBlock | ListBlock | ListItemBlock | BlockquoteBlock | TableBlock | DividerBlock | CodeBlock | DirectiveBlock | RawBlock;
|
|
17
|
-
export type Inline = Text$1 | Link | Image$1 | Code | LineBreak | Raw;
|
|
19
|
+
export type Inline = Text$1 | Link | Image$1 | Mention | Code | LineBreak | Raw;
|
|
18
20
|
type DocumentNode<K extends string, P = {}> = {
|
|
19
21
|
id: string;
|
|
20
22
|
type: K;
|
|
@@ -87,6 +89,10 @@ type Image$1 = DocumentNode<"image", {
|
|
|
87
89
|
url: string;
|
|
88
90
|
width: number | null;
|
|
89
91
|
}>;
|
|
92
|
+
type Mention = DocumentNode<"mention", {
|
|
93
|
+
name: string;
|
|
94
|
+
userId: string;
|
|
95
|
+
}>;
|
|
90
96
|
type LineBreak = DocumentNode<"lineBreak">;
|
|
91
97
|
type Code = DocumentNode<"code", {
|
|
92
98
|
code: string;
|
|
@@ -202,6 +208,7 @@ export declare const defaultKeybindings: EditorKeybinding[];
|
|
|
202
208
|
export type DocumintProps = {
|
|
203
209
|
content: string;
|
|
204
210
|
className?: string;
|
|
211
|
+
actions?: DocumintActions;
|
|
205
212
|
theme?: DocumintTheme;
|
|
206
213
|
keybindings?: EditorKeybinding[];
|
|
207
214
|
presence?: DocumentPresence[];
|
|
@@ -209,6 +216,15 @@ export type DocumintProps = {
|
|
|
209
216
|
users?: DocumentUser[];
|
|
210
217
|
onContentChanged?: (content: string, document: Document$1) => void;
|
|
211
218
|
onCommentChanged?: (change: CommentChange) => void;
|
|
219
|
+
onUserMentioned?: (event: UserMentionEvent) => void;
|
|
220
|
+
};
|
|
221
|
+
export type DocumintAction<T> = {
|
|
222
|
+
icon: LucideIcon;
|
|
223
|
+
label: string;
|
|
224
|
+
onClick: (arg: T) => void;
|
|
225
|
+
};
|
|
226
|
+
export type DocumintActions = {
|
|
227
|
+
selection?: DocumintAction<string> | readonly DocumintAction<string>[];
|
|
212
228
|
};
|
|
213
229
|
export type CommentChange = {
|
|
214
230
|
kind: "added";
|
|
@@ -229,11 +245,16 @@ export type CommentChange = {
|
|
|
229
245
|
thread: CommentThread;
|
|
230
246
|
threadIndex: number;
|
|
231
247
|
};
|
|
248
|
+
export type UserMentionEvent = {
|
|
249
|
+
lineMarkdown: string;
|
|
250
|
+
lineNumber: number;
|
|
251
|
+
userId: string;
|
|
252
|
+
};
|
|
232
253
|
export type DocumintTheme = EditorTheme | {
|
|
233
254
|
dark: EditorTheme;
|
|
234
255
|
light: EditorTheme;
|
|
235
256
|
};
|
|
236
|
-
export declare function Documint({
|
|
257
|
+
export declare function Documint({ content, ...props }: DocumintProps): import("react/jsx-runtime").JSX.Element;
|
|
237
258
|
export declare const lightTheme: EditorTheme;
|
|
238
259
|
export declare const darkTheme: EditorTheme;
|
|
239
260
|
export declare const mintTheme: EditorTheme;
|