documint 0.0.13 → 0.0.16

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
@@ -125,3 +125,22 @@ export function App() {
125
125
  return <Documint content={content} onContentChanged={setContent} storage={storage} />;
126
126
  }
127
127
  ```
128
+
129
+ ## Text Decorations
130
+
131
+ Use the `decorations` prop to style text that matches host-provided regular expressions. Decorations are worker-derived presentation ranges, update asynchronously as content changes, and are not serialized back to markdown. Link text keeps the theme link color when it overlaps a text-color decoration.
132
+
133
+ ```tsx
134
+ import { useState } from "react";
135
+ import { Documint, type DocumintDecoration } from "documint";
136
+
137
+ const decorations: readonly DocumintDecoration[] = [
138
+ { pattern: /\blist\b/gi, color: "red", backgroundColor: "rgba(255, 0, 0, 0.12)" },
139
+ ];
140
+
141
+ export function App() {
142
+ const [content, setContent] = useState("A list of things");
143
+
144
+ return <Documint content={content} onContentChanged={setContent} decorations={decorations} />;
145
+ }
146
+ ```
package/dist/index.d.ts CHANGED
@@ -1,9 +1,10 @@
1
1
  import { LucideIcon } from 'lucide-react';
2
2
 
3
3
  export type CommentThread = {
4
+ id: string;
4
5
  quote: string;
5
6
  comments: Comment$1[];
6
- anchor: Anchor;
7
+ anchor: TextAnchor;
7
8
  resolvedAt?: string;
8
9
  };
9
10
  type Comment$1 = {
@@ -107,11 +108,15 @@ declare const ANCHOR_KINDS: readonly [
107
108
  "tableCell"
108
109
  ];
109
110
  type AnchorKind = (typeof ANCHOR_KINDS)[number];
110
- export type Anchor = {
111
+ type TextAnchor = {
111
112
  kind?: AnchorKind;
112
113
  prefix?: string;
113
114
  suffix?: string;
114
115
  };
116
+ type CommentThreadAnchor = {
117
+ threadId: string;
118
+ };
119
+ export type Anchor = TextAnchor | CommentThreadAnchor;
115
120
  export type DocumintStorage = {
116
121
  readFile(path: string): Promise<Blob | null>;
117
122
  writeFile(file: File): Promise<string>;
@@ -160,7 +165,7 @@ export type EditorTheme = {
160
165
  leafShadow?: string;
161
166
  leafText: string;
162
167
  linkText: string;
163
- listMarkerText: string;
168
+ listMarkerText?: string;
164
169
  mentionBackground?: string;
165
170
  mentionText?: string;
166
171
  paddingX: number;
@@ -184,13 +189,12 @@ export type DocumentUser = {
184
189
  avatarUrl?: string;
185
190
  };
186
191
  /**
187
- * One user's live cursor in the document. `userId` foreign-keys into the
188
- * `users` roster; entries without a matching user are silently dropped.
192
+ * One user's live document presence. `userId` foreign-keys into the `users`
193
+ * roster; entries without a matching user are silently dropped.
189
194
  *
190
- * `cursor` is a content-addressable anchor (prefix/suffix). The editor
191
- * resolves it against the current document; if the anchor matches zero or
192
- * more than one place, the cursor is treated as unresolved and rendered as
193
- * an "unknown location" indicator rather than guessed.
195
+ * `cursor` is either a content-addressable text anchor (prefix/suffix) or a
196
+ * comment-thread anchor (`{ threadId }`). The editor resolves comment-thread
197
+ * anchors to a presence-active comment rule instead of a remote caret.
194
198
  */
195
199
  export type DocumentPresence = {
196
200
  userId: string;
@@ -205,12 +209,19 @@ export type EditorKeybinding = {
205
209
  shiftKey?: boolean | "any";
206
210
  };
207
211
  export declare const defaultKeybindings: EditorKeybinding[];
212
+ export type DocumintDecoration = {
213
+ backgroundColor?: string;
214
+ pulse?: boolean;
215
+ color?: string;
216
+ pattern: RegExp;
217
+ };
208
218
  export type DocumintProps = {
209
219
  content: string;
210
220
  className?: string;
211
221
  actions?: DocumintActions;
212
222
  theme?: DocumintTheme;
213
223
  keybindings?: EditorKeybinding[];
224
+ decorations?: readonly DocumintDecoration[];
214
225
  presence?: DocumentPresence[];
215
226
  storage?: DocumintStorage;
216
227
  users?: DocumentUser[];
@@ -231,19 +242,19 @@ export type CommentChange = {
231
242
  comment: Comment$1;
232
243
  mentionedUserIds: string[];
233
244
  thread: CommentThread;
234
- threadIndex: number;
245
+ threadId: string;
235
246
  } | {
236
247
  kind: "edited";
237
248
  comment: Comment$1;
238
249
  previousBody: string;
239
250
  mentionedUserIds: string[];
240
251
  thread: CommentThread;
241
- threadIndex: number;
252
+ threadId: string;
242
253
  } | {
243
254
  kind: "deleted";
244
255
  comment: Comment$1;
245
256
  thread: CommentThread;
246
- threadIndex: number;
257
+ threadId: string;
247
258
  };
248
259
  export type UserMentionEvent = {
249
260
  lineMarkdown: string;