@veltdev/types-dev 6.0.34 → 6.0.36

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.
@@ -212,6 +212,11 @@ export interface DeleteCommentAnnotationEvent {
212
212
  commentAnnotation: CommentAnnotation;
213
213
  metadata: VeltEventMetadata;
214
214
  }
215
+ /**
216
+ * `suggestionAccepted` on the comment element. Also fires when the target could not be resolved; then
217
+ * `commentAnnotation.suggestion.status` is `'stale'` (the suggestion element fires `suggestionStale` instead of
218
+ * `suggestionApproved`). Fires only in the tab where the action ran.
219
+ */
215
220
  export interface SuggestionAcceptEvent {
216
221
  annotationId: string;
217
222
  commentAnnotation: CommentAnnotation;
@@ -118,7 +118,7 @@ export interface PartialCommentAnnotation {
118
118
  resolvedByUserId?: string | null;
119
119
  /**
120
120
  * The suggestion (comment-resolver iteration-3) — present when the annotation carries one. Its
121
- * content keys (`oldValue`, `newValue`, `summary`, `rejectReason`) are PII: they live only here,
121
+ * content keys (`oldValue`, `newValue`, `summary`, `rejectReason`, `metadata`, `textChange`) are PII: they live only here,
122
122
  * never in Velt. When sent it is always COMPLETE (the content your store already holds plus this
123
123
  * write), so a backend may replace the stored value wholesale. `resolvedBy` may be `{ userId }`
124
124
  * under a user resolver. On `get`, only the content keys are read back — Velt stays authoritative
@@ -94,4 +94,16 @@ export declare class CommentSidebarData {
94
94
  export declare class CommentSidebarDataOptions {
95
95
  grouping?: boolean;
96
96
  }
97
+ /**
98
+ * Optional config for `openCommentSidebar(config?)`.
99
+ */
100
+ export interface OpenCommentSidebarConfig {
101
+ /**
102
+ * Open the sidebar on this comment annotation. With `focusedThreadMode` and `openAnnotationInFocusMode` on, the
103
+ * thread opens in focused view (even if the list's filters hide it); otherwise its card is scrolled into view.
104
+ * Applied once the sidebar has loaded the annotation (up to 10 s); an unknown id logs one warning. Does not
105
+ * select the annotation (no pin dialog opens) and does not move keyboard focus. Sidebar V2 only.
106
+ */
107
+ annotationId?: string;
108
+ }
97
109
  export {};
@@ -47,6 +47,21 @@ export interface TargetEditCommitEvent {
47
47
  commitSuggestion: TargetEditCommitBuilder;
48
48
  timestamp: number;
49
49
  }
50
+ /**
51
+ * Suggestion events, as fired from the suggestion element (`getSuggestionElement().on(...)`).
52
+ *
53
+ * Which event fires for a suggestion's outcome, on which element:
54
+ *
55
+ * | Outcome | Suggestion element | Comment element (`getCommentElement().on(...)`) |
56
+ * |----------------------------------|-----------------------|---------------------------------------------------------|
57
+ * | Accept (target resolves) | `suggestionApproved` | `suggestionAccepted` |
58
+ * | Accept, target unresolvable | `suggestionStale` | `suggestionAccepted` (its annotation's `suggestion.status` is `'stale'`) |
59
+ * | Reject | `suggestionRejected` | `suggestionRejected` |
60
+ *
61
+ * A target resolves through its element on the page OR a getter registered with `registerTarget`; it is
62
+ * unresolvable only with neither. Events fire in the browser tab where Accept/Reject ran (from the sidebar card,
63
+ * an embedded thread or the API); other tabs see the change through the annotation itself.
64
+ */
50
65
  export type SuggestionEventTypesMap = {
51
66
  [SuggestionEventTypes.SUGGESTION_CREATED]: SuggestionCreatedEvent;
52
67
  [SuggestionEventTypes.SUGGESTION_APPROVED]: SuggestionApprovedEvent;
@@ -40,6 +40,36 @@ export type SuggestionTargetType = 'custom';
40
40
  export interface RegisterTargetConfig<T = unknown> {
41
41
  targetId: string;
42
42
  getter: TargetGetter<T>;
43
+ /**
44
+ * Writes a value into the target — the app's own write path (form state, store, save). With a setter the SDK
45
+ * puts the target back once an edit's suggestion is committed (see `restoreOnCommit`) and applies an accepted
46
+ * suggestion's value on the client that accepted it. Without one the SDK never writes to the target.
47
+ */
48
+ setter?: TargetSetter<T>;
49
+ /**
50
+ * With a `setter`: once the suggestion made from an edit is committed, call `setter(valueOnFocus, { reason:
51
+ * 'restore' })` so the target shows its saved value again. Default true. Accept applies through the setter
52
+ * either way.
53
+ */
54
+ restoreOnCommit?: boolean;
55
+ }
56
+ /**
57
+ * Registered with `registerTarget({ targetId, getter, setter })`. The SDK calls it:
58
+ * - `reason: 'restore'` — the suggestion made from an edit was committed; `value` is the target's value when the
59
+ * edit started (put the field back; there is nothing new to save while suggesting).
60
+ * - `reason: 'accept'` — a suggestion on this target was accepted on THIS client; `value` is the accepted value
61
+ * (save it). Called once, after the accepted status is saved and before `suggestionApproved` fires. Other
62
+ * clients don't call their setter: they get the value through the app's own data.
63
+ *
64
+ * While suggestion mode is on, don't save a registered target's edits yourself — save in the 'accept' call.
65
+ * A setter that throws (or rejects) is caught and logged; it never blocks the suggestion.
66
+ */
67
+ export type TargetSetter<T = unknown> = (value: T, context: TargetSetterContext<T>) => void | Promise<void>;
68
+ export interface TargetSetterContext<T = unknown> {
69
+ targetId: string;
70
+ reason: 'restore' | 'accept';
71
+ /** `reason: 'accept'` only: the accepted suggestion, as `suggestionApproved` carries it. */
72
+ suggestion?: Suggestion<T>;
43
73
  }
44
74
  /**
45
75
  * Function the customer registers via SuggestionElement.registerTarget(config).
@@ -118,6 +148,34 @@ export interface TargetEditCommitResult {
118
148
  summaryHtml?: string;
119
149
  /** Customer metadata persisted on the resulting suggestion (`Suggestion.metadata`). */
120
150
  metadata?: Record<string, unknown>;
151
+ /** Where the change sits in a text target (`Suggestion.textChange`). Overrides the one the SDK works out. */
152
+ textChange?: SuggestionTextChange;
153
+ }
154
+ /**
155
+ * Where a suggestion on TEXT sits: what it removes and adds, the unchanged text around it, and which
156
+ * occurrence of that text it is. Stored as `annotation.suggestion.textChange` and returned as
157
+ * `Suggestion.textChange`, the same for every kind of text target (contenteditable fields, rich-text
158
+ * editors), so any screen can find the change again and draw it in place.
159
+ *
160
+ * - Passed by an integration on `commitSuggestion`, or worked out by the SDK for a contenteditable
161
+ * target with no registered getter.
162
+ * - Never re-written after commit: readers find the spot again from the context each time.
163
+ * - Self-hosting: suggestion content — with a comment resolver it is stored by the resolver only,
164
+ * like `oldValue` / `newValue`.
165
+ * - The SDK may add optional keys later; unknown keys passed in are dropped (use `metadata` for your
166
+ * own data).
167
+ */
168
+ export interface SuggestionTextChange {
169
+ /** Text the suggestion removes ('' for a pure insertion). */
170
+ removed: string;
171
+ /** Text the suggestion adds ('' for a pure deletion). */
172
+ added: string;
173
+ /** Up to 32 characters of unchanged text right before the change. */
174
+ contextBefore: string;
175
+ /** Up to 32 characters of unchanged text right after the change. */
176
+ contextAfter: string;
177
+ /** Which non-overlapping match (1-based) of `contextBefore + removed + contextAfter` in the old text it is. */
178
+ occurrence: number;
121
179
  }
122
180
  /**
123
181
  * Return type of `onTargetEditStart`. Reserved for future fields; v1 has
@@ -209,6 +267,11 @@ export interface SuggestionData {
209
267
  * Self-hosting: content — with a comment resolver it is stored by the resolver only.
210
268
  */
211
269
  metadata?: Record<string, unknown>;
270
+ /**
271
+ * Where the change sits in a text target (absent when unknown). Self-hosting: content — with a
272
+ * comment resolver it is stored by the resolver only.
273
+ */
274
+ textChange?: SuggestionTextChange;
212
275
  }
213
276
  /**
214
277
  * Fields shared across every Suggestion regardless of status.
@@ -232,6 +295,11 @@ interface SuggestionBase<T = unknown> {
232
295
  * `{}` when none was given). Contains only the customer's keys.
233
296
  */
234
297
  metadata: Record<string, any>;
298
+ /**
299
+ * Where the change sits in a text target; null (or absent) when unknown — non-text targets such as plain fields
300
+ * and objects, and older suggestions. Optional so code that builds `Suggestion` values needs no change.
301
+ */
302
+ textChange?: SuggestionTextChange | null;
235
303
  /** True iff the live value at approve time differed from oldValue. */
236
304
  driftDetected: boolean;
237
305
  /**
@@ -311,6 +379,13 @@ export interface CommitSuggestionConfig<T = unknown> {
311
379
  * resolver (self-hosting) it is stored by the resolver only.
312
380
  */
313
381
  metadata?: Record<string, unknown>;
382
+ /**
383
+ * Optional: where the change sits in a text target. Integrations that know it (a rich-text editor)
384
+ * pass it; for a contenteditable target with no registered getter the SDK works it out when it is
385
+ * omitted. An invalid value is not saved (dev warning); the commit still succeeds. With a comment
386
+ * resolver (self-hosting) it is stored by the resolver only.
387
+ */
388
+ textChange?: SuggestionTextChange;
314
389
  }
315
390
  /**
316
391
  * Pre-bound builder attached to `targetEditCommit` payloads. Calling it
@@ -7,7 +7,7 @@ import { AutocompleteData } from "../data/autocomplete.data.model";
7
7
  import { AcceptSuggestionRequest, RejectSuggestionRequest, AcceptCommentAnnotationRequest, AddAttachmentRequest, AddAttachmentResponse, AddCommentAnnotationRequest, AddCommentRequest, AddReactionRequest, ApproveCommentAnnotationRequest, AssignUserRequest, CommentRequestQuery, CommentVisibilityConfig, ClearComposerRequest, CopyLinkRequest, DeleteAttachmentRequest, DeleteCommentAnnotationRequest, DeleteCommentRequest, DeleteReactionRequest, DeleteRecordingRequest, FetchCommentAnnotationsRequest, FormatConfig, GetAttachmentRequest, GetCommentRequest, GetComposerDataRequest, GetLinkRequest, GetRecordingRequest, PrivateModeConfig, RejectCommentAnnotationRequest, ResolveCommentAnnotationRequest, SubmitCommentRequest, SubscribeCommentAnnotationRequest, ToggleReactionRequest, UnsubscribeCommentAnnotationRequest, UpdateAccessRequest, UpdateCommentRequest, UpdatePriorityRequest, UpdateStatusRequest } from "../data/comment-actions.data.model";
8
8
  import { CommentAnnotation, CommentOnElementConfig, CommentSelectionChangeData, ManualCommentAnnotationConfig, UpdateContextConfig } from "../data/comment-annotation.data.model";
9
9
  import { SuggestionAcceptEvent, SuggestionRejectEvent, AcceptCommentAnnotationEvent, AddCommentAnnotationEvent, AddCommentEvent, AddReactionEvent, ApproveCommentAnnotationEvent, AssignToConfig, AssignUserEvent, CommentAddEventData, CommentEventTypesMap, CommentUpdateEventData, ComposerTextChangeEvent, CopyLinkEvent, DeleteAttachmentEvent, DeleteCommentAnnotationEvent, DeleteCommentEvent, DeleteReactionEvent, DeleteRecordingEvent, FetchCommentAnnotationsResponse, GetCommentAnnotationsCountResponse, GetCommentAnnotationsResponse, GetLinkResponse, PageModeComposerConfig, RejectCommentAnnotationEvent, SubscribeCommentAnnotationEvent, UnsubscribeCommentAnnotationEvent, ToggleReactionEvent, UpdateAccessEvent, UpdateCommentEvent, UpdatePriorityEvent, UpdateStatusEvent } from "../data/comment-events.data.model";
10
- import { CommentSidebarCustomActionEventData, CommentSidebarCustomActionsState, CommentSidebarData, CommentSidebarDataOptions } from "../data/comment-sidebar-config.model";
10
+ import { CommentSidebarCustomActionEventData, CommentSidebarCustomActionsState, CommentSidebarData, CommentSidebarDataOptions, OpenCommentSidebarConfig } from "../data/comment-sidebar-config.model";
11
11
  import { CommentContextProvider, IdScopedAnchoringConfig, TransformContext, UnreadCommentsCount } from "../data/comment-utils.data.model";
12
12
  import { CustomAnnotationDropdownData } from "../data/custom-chip-dropdown.data.model";
13
13
  import { CustomCategory, CustomPriority, CustomStatus } from "../data/custom-filter.data.model";
@@ -73,8 +73,10 @@ export declare class CommentElement {
73
73
 
74
74
  /**
75
75
  * To open comment sidebar
76
+ * @param config Optional. `{ annotationId }` opens the sidebar on that thread: focused view with
77
+ * `focusedThreadMode` + `openAnnotationInFocusMode`, otherwise its card is scrolled into view (sidebar V2).
76
78
  */
77
- openCommentSidebar: () => void;
79
+ openCommentSidebar: (config?: OpenCommentSidebarConfig) => void;
78
80
 
79
81
  /**
80
82
  * To close comment sidebar
@@ -29,6 +29,21 @@ export declare class SuggestionElement {
29
29
  */
30
30
  isSuggestionModeEnabled$: () => Observable<boolean>;
31
31
 
32
+ /**
33
+ * Draw pending suggestions inside contenteditable suggestion targets (the default): the removed text struck through,
34
+ * the added text in green, and a click on them opens the suggestion's thread. While suggesting, the change being
35
+ * typed in such a field is drawn as it is typed and separate edits become separate suggestions.
36
+ */
37
+ enableInlineSuggestions: () => void;
38
+
39
+ /**
40
+ * Never touch contenteditable suggestion targets: nothing is drawn inside them (what was drawn is taken out),
41
+ * typed changes are not tracked edit by edit (one suggestion per visit to a field), and their undo is left to the
42
+ * browser. Use when the field's DOM must stay the app's own (a framework-controlled field, an app that saves
43
+ * innerHTML). Suggestions still work and show in the sidebar and dialogs.
44
+ */
45
+ disableInlineSuggestions: () => void;
46
+
32
47
  /**
33
48
  * Register a getter that returns the current value of a tagged target.
34
49
  * Required for non-primitive (wrapper) targets — the SDK calls this on
@@ -36,6 +51,10 @@ export declare class SuggestionElement {
36
51
  *
37
52
  * The getter must reflect edit-time state (typically read from the DOM),
38
53
  * not the persisted customer state. See `RegisterTargetConfig`.
54
+ *
55
+ * Optional `setter`: the app's write path for the target. The SDK puts the target back once an edit's
56
+ * suggestion is committed (`restoreOnCommit`, default true) and applies an accepted suggestion's value on the
57
+ * client that accepted it. See `TargetSetter`.
39
58
  */
40
59
  registerTarget: <T = unknown>(config: RegisterTargetConfig<T>) => void;
41
60
 
@@ -115,6 +134,8 @@ export declare class SuggestionElement {
115
134
  * Reactive enable-flag stream; deduplicated.
116
135
  */
117
136
  private _isSuggestionModeEnabled$;
137
+ private _enableInlineSuggestions;
138
+ private _disableInlineSuggestions;
118
139
 
119
140
  /**
120
141
  * Register a getter that returns the current value of a tagged target.
@@ -123,6 +144,10 @@ export declare class SuggestionElement {
123
144
  *
124
145
  * The getter must reflect edit-time state (typically read from the DOM),
125
146
  * not the persisted customer state. See `RegisterTargetConfig`.
147
+ *
148
+ * Optional `setter`: the app's write path for the target. The SDK puts the target back once an edit's
149
+ * suggestion is committed (`restoreOnCommit`, default true) and applies an accepted suggestion's value on the
150
+ * client that accepted it. See `TargetSetter`.
126
151
  */
127
152
  private _registerTarget;
128
153
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veltdev/types-dev",
3
- "version": "6.0.34",
3
+ "version": "6.0.36",
4
4
  "description": "Velt is an SDK to add collaborative features to your product within minutes. Example: Comments like Figma, Frame.io, Google docs or sheets, Recording like Loom, Huddles like Slack and much more.",
5
5
  "homepage": "https://velt.dev",
6
6
  "keywords": [