documint 0.0.3 → 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/README.md CHANGED
@@ -40,11 +40,13 @@ This editor takes markdown in and gives markdown back out.
40
40
  export function App() {
41
41
  const [content, setContent] = useState(initialMarkdown);
42
42
 
43
- return <Documint content={content} onContentChange={setContent} />;
43
+ return <Documint content={content} onContentChanged={setContent} />;
44
44
  }
45
45
  ```
46
46
 
47
- You can also start from one of the built-in themes and tweak just the values you care about.
47
+ ## Custom Themes
48
+
49
+ 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.
48
50
 
49
51
  ```tsx
50
52
  import { useState } from "react";
@@ -60,6 +62,37 @@ const customTheme = {
60
62
  export function App() {
61
63
  const [content, setContent] = useState("# Themed Documint");
62
64
 
63
- return <Documint content={content} onContentChange={setContent} theme={customTheme} />;
65
+ return <Documint content={content} onContentChanged={setContent} theme={customTheme} />;
64
66
  }
65
67
  ```
68
+
69
+ ## Custom Storage
70
+
71
+ If the document includes http-based images, then the editor will automatically load and render them. However, if you want to support pasting images from the clipboard or uploading images from the user's device, you'll need to provide a `storage` prop that implements the `DocumintStorage` interface.
72
+
73
+ ```tsx
74
+ import { useState } from "react";
75
+ import { Documint, DocumintStorage } from "documint";
76
+
77
+ function createInMemoryStorage(): DocumintStorage {
78
+ const files = new Map<string, Blob>();
79
+
80
+ return {
81
+ async readFile(path) {
82
+ return files.get(path) ?? null;
83
+ },
84
+ async writeFile(file) {
85
+ files.set(file.name, file);
86
+ return file.name;
87
+ },
88
+ };
89
+ }
90
+
91
+ const storage = createInMemoryStorage();
92
+
93
+ export function App() {
94
+ const [content, setContent] = useState("# Documint with Custom Storage");
95
+
96
+ return <Documint content={content} onContentChanged={setContent} storage={storage} />;
97
+ }
98
+ ```
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ type Comment$1 = {
11
11
  type Document$1 = {
12
12
  blocks: Block[];
13
13
  comments: CommentThread[];
14
+ frontMatter?: string;
14
15
  };
15
16
  export type Block = ParagraphBlock | HeadingBlock | ListBlock | ListItemBlock | BlockquoteBlock | TableBlock | DividerBlock | CodeBlock | DirectiveBlock | RawBlock;
16
17
  export type Inline = Text$1 | Link | Image$1 | Code | LineBreak | Raw;
@@ -199,8 +200,28 @@ export type DocumintProps = {
199
200
  keybindings?: EditorKeybinding[];
200
201
  presence?: DocumentPresence[];
201
202
  users?: DocumentUser[];
202
- onContentChange?: (content: string, document: Document$1) => void;
203
- onStateChange?: (state: DocumintState) => void;
203
+ onContentChanged?: (content: string, document: Document$1) => void;
204
+ onStateChanged?: (state: DocumintState) => void;
205
+ onCommentChanged?: (event: CommentChangedEvent) => void;
206
+ };
207
+ export type CommentChangedEvent = {
208
+ kind: "added";
209
+ comment: Comment$1;
210
+ mentionedUserIds: string[];
211
+ thread: CommentThread;
212
+ threadIndex: number;
213
+ } | {
214
+ kind: "edited";
215
+ comment: Comment$1;
216
+ previousBody: string;
217
+ mentionedUserIds: string[];
218
+ thread: CommentThread;
219
+ threadIndex: number;
220
+ } | {
221
+ kind: "deleted";
222
+ comment: Comment$1;
223
+ thread: CommentThread;
224
+ threadIndex: number;
204
225
  };
205
226
  export type DocumintTheme = EditorTheme | {
206
227
  dark: EditorTheme;
@@ -218,7 +239,7 @@ export type DocumintState = {
218
239
  selectionFrom: number;
219
240
  selectionTo: number;
220
241
  };
221
- export declare function Documint({ className, content, keybindings, onContentChange, onStateChange, presence, theme, users, }: DocumintProps): import("react/jsx-runtime").JSX.Element;
242
+ export declare function Documint({ className, content, keybindings, onCommentChanged, onContentChanged, onStateChanged, presence, theme, users, }: DocumintProps): import("react/jsx-runtime").JSX.Element;
222
243
  export declare const lightTheme: EditorTheme;
223
244
  export declare const darkTheme: EditorTheme;
224
245
  export declare const mintTheme: EditorTheme;