@beyondwork/docx-react-component 1.0.32 → 1.0.33

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@beyondwork/docx-react-component",
3
3
  "publisher": "beyondwork",
4
- "version": "1.0.32",
4
+ "version": "1.0.33",
5
5
  "description": "Embeddable React Word (docx) editor with review, comments, tracked changes, and round-trip OOXML fidelity.",
6
6
  "type": "module",
7
7
  "sideEffects": [
@@ -261,6 +261,7 @@ export function buildDecorations(
261
261
  revisionModel: RevisionDecorationModel | undefined,
262
262
  markupDisplay: MarkupDisplay,
263
263
  showTrackedChanges = true,
264
+ suggestionsEnabled = false,
264
265
  workflowScopes?: readonly WorkflowScope[],
265
266
  activeStory: EditorStoryTarget = MAIN_STORY_TARGET,
266
267
  workflowCandidates?: readonly WorkflowCandidateRange[],
@@ -324,6 +325,47 @@ export function buildDecorations(
324
325
  // Skip visual styling when tracked changes display is off
325
326
  if (!showTrackedChanges) continue;
326
327
 
328
+ const pmFrom = positionMap.runtimeToPm(rev.from);
329
+ const pmTo = positionMap.runtimeToPm(rev.to);
330
+ if (pmFrom >= pmTo) continue;
331
+
332
+ if (suggestionsEnabled) {
333
+ if (rev.kind === "insertion") {
334
+ decorations.push(
335
+ Decoration.inline(pmFrom, pmTo, {
336
+ class: "text-insert",
337
+ "data-revision-id": rev.revisionId,
338
+ }),
339
+ );
340
+ decorations.push(
341
+ Decoration.widget(pmFrom, () => {
342
+ const el = document.createElement("span");
343
+ el.textContent = "[";
344
+ el.className = "text-insert";
345
+ el.setAttribute("contenteditable", "false");
346
+ return el;
347
+ }, { side: -1, key: `${rev.revisionId}-open` }),
348
+ );
349
+ decorations.push(
350
+ Decoration.widget(pmTo, () => {
351
+ const el = document.createElement("span");
352
+ el.textContent = "]";
353
+ el.className = "text-insert";
354
+ el.setAttribute("contenteditable", "false");
355
+ return el;
356
+ }, { side: 1, key: `${rev.revisionId}-close` }),
357
+ );
358
+ } else if (rev.kind === "deletion") {
359
+ decorations.push(
360
+ Decoration.inline(pmFrom, pmTo, {
361
+ class: "text-danger line-through decoration-danger/80 decoration-1",
362
+ "data-revision-id": rev.revisionId,
363
+ }),
364
+ );
365
+ }
366
+ continue;
367
+ }
368
+
327
369
  const cls = getRevisionHighlightClass(
328
370
  revisionModel,
329
371
  rev.from,
@@ -332,16 +374,12 @@ export function buildDecorations(
332
374
  );
333
375
  if (!cls) continue;
334
376
 
335
- const pmFrom = positionMap.runtimeToPm(rev.from);
336
- const pmTo = positionMap.runtimeToPm(rev.to);
337
- if (pmFrom < pmTo) {
338
- decorations.push(
339
- Decoration.inline(pmFrom, pmTo, {
340
- class: cls,
341
- "data-revision-id": rev.revisionId,
342
- }),
343
- );
344
- }
377
+ decorations.push(
378
+ Decoration.inline(pmFrom, pmTo, {
379
+ class: cls,
380
+ "data-revision-id": rev.revisionId,
381
+ }),
382
+ );
345
383
  }
346
384
  }
347
385
 
@@ -80,6 +80,7 @@ export interface TwProseMirrorSurfaceProps {
80
80
  activeRevisionId?: string;
81
81
  activeSelectionToolKind?: ActiveSelectionToolModel["kind"] | null;
82
82
  showTrackedChanges?: boolean;
83
+ suggestionsEnabled?: boolean;
83
84
  /** When true, the surface renders inside the page workspace (vs canvas). */
84
85
  isPageWorkspace?: boolean;
85
86
  onFocus: FocusEventHandler<HTMLDivElement>;
@@ -196,6 +197,7 @@ export const TwProseMirrorSurface = forwardRef<
196
197
  [snapshot.comments],
197
198
  );
198
199
  const showTrackedChanges = props.showTrackedChanges !== false;
200
+ const suggestionsEnabled = props.suggestionsEnabled ?? false;
199
201
  // Always create the revision model — needed for deletion hiding in clean mode
200
202
  // even when the tracked changes display toggle is off.
201
203
  const revisionModel = useMemo(
@@ -280,6 +282,7 @@ export const TwProseMirrorSurface = forwardRef<
280
282
  revisionModel,
281
283
  markupDisplay,
282
284
  showTrackedChanges,
285
+ suggestionsEnabled,
283
286
  props.workflowScopes,
284
287
  snapshot.activeStory,
285
288
  props.workflowCandidates,
@@ -311,6 +314,7 @@ export const TwProseMirrorSurface = forwardRef<
311
314
  props.workflowScopes,
312
315
  revisionModel,
313
316
  showTrackedChanges,
317
+ suggestionsEnabled,
314
318
  ],
315
319
  );
316
320
 
@@ -337,6 +341,7 @@ export const TwProseMirrorSurface = forwardRef<
337
341
  revisionModel,
338
342
  markupDisplay,
339
343
  showTrackedChanges,
344
+ suggestionsEnabled,
340
345
  props.workflowScopes,
341
346
  snapshot.activeStory,
342
347
  props.workflowCandidates,