documint 0.0.10 → 0.0.11
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 +12 -1
- package/dist/index.js +88 -63
- package/package.json +2 -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 { IconName } from 'lucide-react/dynamic';
|
|
2
|
+
|
|
1
3
|
export type CommentThread = {
|
|
2
4
|
quote: string;
|
|
3
5
|
comments: Comment$1[];
|
|
@@ -202,6 +204,7 @@ export declare const defaultKeybindings: EditorKeybinding[];
|
|
|
202
204
|
export type DocumintProps = {
|
|
203
205
|
content: string;
|
|
204
206
|
className?: string;
|
|
207
|
+
actions?: DocumintActions;
|
|
205
208
|
theme?: DocumintTheme;
|
|
206
209
|
keybindings?: EditorKeybinding[];
|
|
207
210
|
presence?: DocumentPresence[];
|
|
@@ -210,6 +213,14 @@ export type DocumintProps = {
|
|
|
210
213
|
onContentChanged?: (content: string, document: Document$1) => void;
|
|
211
214
|
onCommentChanged?: (change: CommentChange) => void;
|
|
212
215
|
};
|
|
216
|
+
export type DocumintAction<T> = {
|
|
217
|
+
icon: IconName;
|
|
218
|
+
label?: string;
|
|
219
|
+
onClick: (arg: T) => void;
|
|
220
|
+
};
|
|
221
|
+
export type DocumintActions = {
|
|
222
|
+
selection?: DocumintAction<string> | readonly DocumintAction<string>[];
|
|
223
|
+
};
|
|
213
224
|
export type CommentChange = {
|
|
214
225
|
kind: "added";
|
|
215
226
|
comment: Comment$1;
|
|
@@ -233,7 +244,7 @@ export type DocumintTheme = EditorTheme | {
|
|
|
233
244
|
dark: EditorTheme;
|
|
234
245
|
light: EditorTheme;
|
|
235
246
|
};
|
|
236
|
-
export declare function Documint({
|
|
247
|
+
export declare function Documint({ content, ...props }: DocumintProps): import("react/jsx-runtime").JSX.Element;
|
|
237
248
|
export declare const lightTheme: EditorTheme;
|
|
238
249
|
export declare const darkTheme: EditorTheme;
|
|
239
250
|
export declare const mintTheme: EditorTheme;
|