documint 0.0.9 → 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 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 <70 KB gzipped.
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[];
@@ -109,6 +111,7 @@ export type Anchor = {
109
111
  export type DocumintStorage = {
110
112
  readFile(path: string): Promise<Blob | null>;
111
113
  writeFile(file: File): Promise<string>;
114
+ openFile?(path: string): void;
112
115
  };
113
116
  type EditorCommand = "dedent" | "deleteBackward" | "indent" | "insertLineBreak" | "insertSoftLineBreak" | "moveListItemDown" | "moveListItemUp" | "moveToDocumentEnd" | "moveToDocumentStart" | "moveToLineEnd" | "moveToLineStart" | "redo" | "selectAll" | "toggleBold" | "toggleCode" | "toggleItalic" | "toggleStrikethrough" | "toggleUnderline" | "undo";
114
117
  export type EditorTheme = {
@@ -201,15 +204,23 @@ export declare const defaultKeybindings: EditorKeybinding[];
201
204
  export type DocumintProps = {
202
205
  content: string;
203
206
  className?: string;
207
+ actions?: DocumintActions;
204
208
  theme?: DocumintTheme;
205
209
  keybindings?: EditorKeybinding[];
206
210
  presence?: DocumentPresence[];
207
211
  storage?: DocumintStorage;
208
212
  users?: DocumentUser[];
209
213
  onContentChanged?: (content: string, document: Document$1) => void;
210
- onStateChanged?: (state: DocumintState) => 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,19 +244,7 @@ export type DocumintTheme = EditorTheme | {
233
244
  dark: EditorTheme;
234
245
  light: EditorTheme;
235
246
  };
236
- export type DocumintState = {
237
- activeBlockType: string | null;
238
- activeCommentThreadIndex: number | null;
239
- activeSpanKind: string | null;
240
- canonicalContent: string;
241
- characterCount: number;
242
- commentThreadCount: number;
243
- layoutWidth: number;
244
- resolvedCommentCount: number;
245
- selectionFrom: number;
246
- selectionTo: number;
247
- };
248
- export declare function Documint({ className, content, keybindings, onCommentChanged, onContentChanged, onStateChanged, presence, storage, theme, users, }: DocumintProps): import("react/jsx-runtime").JSX.Element;
247
+ export declare function Documint({ content, ...props }: DocumintProps): import("react/jsx-runtime").JSX.Element;
249
248
  export declare const lightTheme: EditorTheme;
250
249
  export declare const darkTheme: EditorTheme;
251
250
  export declare const mintTheme: EditorTheme;