documint 0.0.20 → 0.0.22

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
@@ -16,11 +16,11 @@ A canvas-based, batteries-included markdown editor for React.
16
16
 
17
17
  - **Context-aware toolbars ("leaves")** — Floating toolbars that appear based on what you're interacting with: text formatting options on selection, link editing on links, column/row controls on tables, and block insertion (headings, lists, quotes, tables) on empty lines.
18
18
 
19
- - **Configurable themes and keybindings** — Ships with built-in light and dark themes, follows the system theme by default, and lets you customize every theme value or start from presets like mint, midnight, and sunrise. Keybindings are configurable too — remap formatting shortcuts, navigation, and list operations to match your users' expectations.
19
+ - **Configurable themes and keybindings** — Ships with built-in light and dark themes, follows the system theme by default, and lets you customize every theme value. Keybindings are configurable too — remap formatting shortcuts, navigation, and list operations to match your users' expectations.
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 <80 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 ~100 KB gzipped.
24
24
 
25
25
  ## Getting Started
26
26
 
package/dist/index.d.ts CHANGED
@@ -39,7 +39,7 @@ type Document$1 = {
39
39
  frontMatter?: string;
40
40
  };
41
41
  export type Block = ParagraphBlock | HeadingBlock | ListBlock | ListItemBlock | BlockquoteBlock | TableBlock | DividerBlock | CodeBlock | DirectiveBlock | RawBlock;
42
- export type Inline = Text$1 | Link | Image$1 | Mention | Code | LineBreak | Raw;
42
+ export type Inline = Text$1 | Link | Image$1 | Mention | Resource | LineBreak | Raw;
43
43
  type DocumentNode<K extends string, P = {}> = {
44
44
  id: string;
45
45
  type: K;
@@ -96,7 +96,7 @@ export type RawBlock = BlockNode<"raw", {
96
96
  originalType: string;
97
97
  source: string;
98
98
  }>;
99
- export type Mark = "bold" | "italic" | "strikethrough" | "underline" | "superscript";
99
+ export type Mark = "code" | "bold" | "italic" | "strikethrough" | "underline" | "superscript";
100
100
  type Text$1 = DocumentNode<"text", {
101
101
  marks: Mark[];
102
102
  text: string;
@@ -116,14 +116,34 @@ type Mention = DocumentNode<"mention", {
116
116
  name: string;
117
117
  userId: string;
118
118
  }>;
119
- type LineBreak = DocumentNode<"lineBreak">;
120
- type Code = DocumentNode<"code", {
121
- code: string;
119
+ export type Resource = DocumentNode<"resource", {
120
+ label: string;
121
+ protocol: string;
122
+ url: string;
122
123
  }>;
124
+ type LineBreak = DocumentNode<"lineBreak">;
123
125
  export type Raw = DocumentNode<"raw", {
124
126
  originalType: string;
125
127
  source: string;
126
128
  }>;
129
+ export type DocumentResourceProtocol = {
130
+ icon?: DocumentResourceIcon;
131
+ label: string;
132
+ };
133
+ export type DocumentResourceIcon = string | DocumentResourceVectorIcon;
134
+ export type DocumentResourceVectorIcon = {
135
+ node: DocumentResourceIconNode;
136
+ type: "svg";
137
+ };
138
+ export type DocumentResourceIconNode = readonly DocumentResourceIconNodeElement[];
139
+ type DocumentResourceIconNodeElement = readonly [
140
+ elementName: string,
141
+ attrs: Readonly<Record<string, string>>
142
+ ];
143
+ export type DocumentResourceReference = {
144
+ protocol: string;
145
+ url: string;
146
+ };
127
147
  export type DocumintStorage = {
128
148
  readFile(path: string): Promise<Blob | null>;
129
149
  writeFile(file: File): Promise<string>;
@@ -161,7 +181,7 @@ export type EditorTheme = {
161
181
  inlineCodeText?: string;
162
182
  insertHighlightText?: string;
163
183
  leafAccent: string;
164
- leafBackground: string;
184
+ leafBackground?: string;
165
185
  leafBorder: string;
166
186
  leafInputBackground: string;
167
187
  leafButtonText?: string;
@@ -207,7 +227,10 @@ export type DocumentPresence = {
207
227
  userId: string;
208
228
  cursor?: Anchor;
209
229
  color?: string;
230
+ status?: string;
210
231
  };
232
+ export type ResourceProtocolRecord = ReadonlyMap<string, DocumentResourceProtocol> | Record<string, DocumentResourceProtocol>;
233
+ export type ActiveResourceSet = ReadonlySet<string> | readonly string[] | Record<string, boolean>;
211
234
  export type EditorInputKeybinding = {
212
235
  altKey?: boolean;
213
236
  command: EditorInputCommand;
@@ -230,10 +253,14 @@ export type DocumintProps = {
230
253
  keybindings?: EditorInputKeybinding[];
231
254
  decorations?: readonly DocumintDecoration[];
232
255
  presence?: DocumentPresence[];
256
+ protocols?: ResourceProtocolRecord;
257
+ resources?: ActiveResourceSet;
233
258
  storage?: DocumintStorage;
234
259
  users?: DocumentUser[];
235
260
  onContentChanged?: (content: string, document: Document$1) => void;
236
261
  onCommentChanged?: (change: CommentChange) => void;
262
+ onResourceOpened?: (resource: DocumentResourceReference) => void;
263
+ onResourcesRequested?: (resources: readonly DocumentResourceReference[]) => void;
237
264
  onUserMentioned?: (event: UserMentionEvent) => void;
238
265
  };
239
266
  export type DocumintAction<T> = {
@@ -275,8 +302,9 @@ export type DocumintTheme = EditorTheme | {
275
302
  export declare function Documint({ content, ...props }: DocumintProps): import("react/jsx-runtime").JSX.Element;
276
303
  export declare const lightTheme: EditorTheme;
277
304
  export declare const darkTheme: EditorTheme;
278
- export declare const mintTheme: EditorTheme;
279
- export declare const midnightTheme: EditorTheme;
305
+ export declare function lucideResourceIcon(node: DocumentResourceIconNode): DocumentResourceIcon;
306
+ export declare function normalizeResourceProtocol(protocol: string): string | null;
307
+ export declare function resolveResourceProtocol(url: string): string | null;
280
308
 
281
309
  export {
282
310
  Comment$1 as Comment,