documint 0.0.2 → 0.0.4
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 +2 -2
- package/dist/index.d.ts +50 -8
- package/dist/index.js +809 -736
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ 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}
|
|
43
|
+
return <Documint content={content} onContentChanged={setContent} />;
|
|
44
44
|
}
|
|
45
45
|
```
|
|
46
46
|
|
|
@@ -60,6 +60,6 @@ const customTheme = {
|
|
|
60
60
|
export function App() {
|
|
61
61
|
const [content, setContent] = useState("# Themed Documint");
|
|
62
62
|
|
|
63
|
-
return <Documint content={content}
|
|
63
|
+
return <Documint content={content} onContentChanged={setContent} theme={customTheme} />;
|
|
64
64
|
}
|
|
65
65
|
```
|
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;
|
|
@@ -148,6 +149,8 @@ export type EditorTheme = {
|
|
|
148
149
|
leafText: string;
|
|
149
150
|
linkText: string;
|
|
150
151
|
listMarkerText: string;
|
|
152
|
+
mentionBackground?: string;
|
|
153
|
+
mentionText?: string;
|
|
151
154
|
paddingX: number;
|
|
152
155
|
paddingY: number;
|
|
153
156
|
paragraphText: string;
|
|
@@ -158,11 +161,29 @@ export type EditorTheme = {
|
|
|
158
161
|
tableBorder: string;
|
|
159
162
|
tableHeaderBackground: string;
|
|
160
163
|
};
|
|
161
|
-
|
|
162
|
-
|
|
164
|
+
/**
|
|
165
|
+
* A user known to the host. The full set is the mention roster; the subset
|
|
166
|
+
* that also appears in `presence` shows a live cursor in the document.
|
|
167
|
+
*/
|
|
168
|
+
export type DocumentUser = {
|
|
169
|
+
id: string;
|
|
170
|
+
username: string;
|
|
171
|
+
fullName?: string;
|
|
172
|
+
avatarUrl?: string;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* One user's live cursor in the document. `userId` foreign-keys into the
|
|
176
|
+
* `users` roster; entries without a matching user are silently dropped.
|
|
177
|
+
*
|
|
178
|
+
* `cursor` is a content-addressable anchor (prefix/suffix). The editor
|
|
179
|
+
* resolves it against the current document; if the anchor matches zero or
|
|
180
|
+
* more than one place, the cursor is treated as unresolved and rendered as
|
|
181
|
+
* an "unknown location" indicator rather than guessed.
|
|
182
|
+
*/
|
|
183
|
+
export type DocumentPresence = {
|
|
184
|
+
userId: string;
|
|
163
185
|
cursor?: Anchor;
|
|
164
|
-
|
|
165
|
-
name: string;
|
|
186
|
+
color?: string;
|
|
166
187
|
};
|
|
167
188
|
export type EditorKeybinding = {
|
|
168
189
|
altKey?: boolean;
|
|
@@ -177,9 +198,30 @@ export type DocumintProps = {
|
|
|
177
198
|
className?: string;
|
|
178
199
|
theme?: DocumintTheme;
|
|
179
200
|
keybindings?: EditorKeybinding[];
|
|
180
|
-
presence?:
|
|
181
|
-
|
|
182
|
-
|
|
201
|
+
presence?: DocumentPresence[];
|
|
202
|
+
users?: DocumentUser[];
|
|
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;
|
|
183
225
|
};
|
|
184
226
|
export type DocumintTheme = EditorTheme | {
|
|
185
227
|
dark: EditorTheme;
|
|
@@ -197,7 +239,7 @@ export type DocumintState = {
|
|
|
197
239
|
selectionFrom: number;
|
|
198
240
|
selectionTo: number;
|
|
199
241
|
};
|
|
200
|
-
export declare function Documint({ className, content, keybindings,
|
|
242
|
+
export declare function Documint({ className, content, keybindings, onCommentChanged, onContentChanged, onStateChanged, presence, theme, users, }: DocumintProps): import("react/jsx-runtime").JSX.Element;
|
|
201
243
|
export declare const lightTheme: EditorTheme;
|
|
202
244
|
export declare const darkTheme: EditorTheme;
|
|
203
245
|
export declare const mintTheme: EditorTheme;
|