documint 0.0.4 → 0.0.6

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
@@ -44,7 +44,9 @@ export function App() {
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";
@@ -63,3 +65,34 @@ export function App() {
63
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
@@ -106,7 +106,11 @@ export type Anchor = {
106
106
  prefix?: string;
107
107
  suffix?: string;
108
108
  };
109
- type EditorCommand = "dedent" | "deleteBackward" | "indent" | "insertLineBreak" | "moveListItemDown" | "moveListItemUp" | "moveToDocumentEnd" | "moveToDocumentStart" | "moveToLineEnd" | "moveToLineStart" | "redo" | "selectAll" | "toggleBold" | "toggleInlineCode" | "toggleItalic" | "toggleStrikethrough" | "toggleUnderline" | "undo";
109
+ export type DocumintStorage = {
110
+ readFile(path: string): Promise<Blob | null>;
111
+ writeFile(file: File): Promise<string>;
112
+ };
113
+ type EditorCommand = "dedent" | "deleteBackward" | "indent" | "insertLineBreak" | "moveListItemDown" | "moveListItemUp" | "moveToDocumentEnd" | "moveToDocumentStart" | "moveToLineEnd" | "moveToLineStart" | "redo" | "selectAll" | "toggleBold" | "toggleCode" | "toggleItalic" | "toggleStrikethrough" | "toggleUnderline" | "undo";
110
114
  export type EditorTheme = {
111
115
  activeBlockBackground: string;
112
116
  activeBlockFlash: string;
@@ -199,12 +203,13 @@ export type DocumintProps = {
199
203
  theme?: DocumintTheme;
200
204
  keybindings?: EditorKeybinding[];
201
205
  presence?: DocumentPresence[];
206
+ storage?: DocumintStorage;
202
207
  users?: DocumentUser[];
203
208
  onContentChanged?: (content: string, document: Document$1) => void;
204
209
  onStateChanged?: (state: DocumintState) => void;
205
- onCommentChanged?: (event: CommentChangedEvent) => void;
210
+ onCommentChanged?: (change: CommentChange) => void;
206
211
  };
207
- export type CommentChangedEvent = {
212
+ export type CommentChange = {
208
213
  kind: "added";
209
214
  comment: Comment$1;
210
215
  mentionedUserIds: string[];
@@ -239,7 +244,7 @@ export type DocumintState = {
239
244
  selectionFrom: number;
240
245
  selectionTo: number;
241
246
  };
242
- export declare function Documint({ className, content, keybindings, onCommentChanged, onContentChanged, onStateChanged, presence, theme, users, }: DocumintProps): import("react/jsx-runtime").JSX.Element;
247
+ export declare function Documint({ className, content, keybindings, onCommentChanged, onContentChanged, onStateChanged, presence, storage, theme, users, }: DocumintProps): import("react/jsx-runtime").JSX.Element;
243
248
  export declare const lightTheme: EditorTheme;
244
249
  export declare const darkTheme: EditorTheme;
245
250
  export declare const mintTheme: EditorTheme;