@beyondwork/docx-react-component 1.0.41 → 1.0.43
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 +38 -37
- package/src/api/awareness-identity-types.ts +35 -0
- package/src/api/comment-negotiation-types.ts +130 -0
- package/src/api/comment-presentation-types.ts +106 -0
- package/src/api/editor-state-types.ts +110 -0
- package/src/api/external-custody-types.ts +74 -0
- package/src/api/participants-types.ts +18 -0
- package/src/api/public-types.ts +541 -5
- package/src/api/scope-metadata-resolver-types.ts +88 -0
- package/src/core/commands/formatting-commands.ts +1 -1
- package/src/core/commands/index.ts +601 -9
- package/src/core/search/search-text.ts +15 -2
- package/src/index.ts +131 -1
- package/src/io/docx-session.ts +672 -2
- package/src/io/export/escape-xml-attribute.ts +26 -0
- package/src/io/export/external-send.ts +188 -0
- package/src/io/export/serialize-comments.ts +13 -16
- package/src/io/export/serialize-footnotes.ts +17 -24
- package/src/io/export/serialize-headers-footers.ts +17 -24
- package/src/io/export/serialize-main-document.ts +59 -62
- package/src/io/export/serialize-numbering.ts +20 -27
- package/src/io/export/serialize-runtime-revisions.ts +2 -9
- package/src/io/export/serialize-tables.ts +8 -15
- package/src/io/export/table-properties-xml.ts +25 -32
- package/src/io/import/external-reimport.ts +40 -0
- package/src/io/load-scheduler.ts +230 -0
- package/src/io/normalize/normalize-text.ts +83 -0
- package/src/io/ooxml/bw-xml.ts +244 -0
- package/src/io/ooxml/canonicalize-payload.ts +301 -0
- package/src/io/ooxml/comment-negotiation-payload.ts +288 -0
- package/src/io/ooxml/comment-presentation-payload.ts +311 -0
- package/src/io/ooxml/external-custody-payload.ts +102 -0
- package/src/io/ooxml/participants-payload.ts +97 -0
- package/src/io/ooxml/payload-signature.ts +112 -0
- package/src/io/ooxml/workflow-payload-validator.ts +367 -0
- package/src/io/ooxml/workflow-payload.ts +317 -7
- package/src/runtime/awareness-identity.ts +173 -0
- package/src/runtime/collab/event-types.ts +27 -0
- package/src/runtime/collab-session-bridge.ts +157 -0
- package/src/runtime/collab-session-facet.ts +193 -0
- package/src/runtime/collab-session.ts +273 -0
- package/src/runtime/comment-negotiation-sync.ts +91 -0
- package/src/runtime/comment-negotiation.ts +158 -0
- package/src/runtime/comment-presentation.ts +223 -0
- package/src/runtime/document-runtime.ts +639 -124
- package/src/runtime/editor-state-channel.ts +544 -0
- package/src/runtime/editor-state-integration.ts +217 -0
- package/src/runtime/external-send-runtime.ts +117 -0
- package/src/runtime/layout/docx-font-loader.ts +11 -30
- package/src/runtime/layout/index.ts +2 -0
- package/src/runtime/layout/inert-layout-facet.ts +4 -0
- package/src/runtime/layout/layout-engine-instance.ts +139 -14
- package/src/runtime/layout/page-graph.ts +79 -7
- package/src/runtime/layout/paginated-layout-engine.ts +441 -48
- package/src/runtime/layout/public-facet.ts +585 -14
- package/src/runtime/layout/table-row-split.ts +316 -0
- package/src/runtime/markdown-sanitizer.ts +132 -0
- package/src/runtime/participants.ts +134 -0
- package/src/runtime/perf-counters.ts +28 -0
- package/src/runtime/render/render-frame-types.ts +17 -0
- package/src/runtime/render/render-kernel.ts +172 -29
- package/src/runtime/resign-payload.ts +120 -0
- package/src/runtime/surface-projection.ts +10 -5
- package/src/runtime/tamper-gate.ts +157 -0
- package/src/runtime/workflow-markup.ts +80 -16
- package/src/runtime/workflow-rail-segments.ts +244 -5
- package/src/ui/WordReviewEditor.tsx +654 -45
- package/src/ui/editor-command-bag.ts +14 -0
- package/src/ui/editor-runtime-boundary.ts +111 -11
- package/src/ui/editor-shell-view.tsx +21 -0
- package/src/ui/editor-surface-controller.tsx +5 -0
- package/src/ui/headless/selection-helpers.ts +10 -0
- package/src/ui-tailwind/chrome/chrome-preset-model.ts +28 -0
- package/src/ui-tailwind/chrome/chrome-preset-toolbar.tsx +62 -2
- package/src/ui-tailwind/chrome/collab-audience-chip.tsx +73 -0
- package/src/ui-tailwind/chrome/collab-negotiation-action-bar.tsx +244 -0
- package/src/ui-tailwind/chrome/collab-presence-strip.tsx +150 -0
- package/src/ui-tailwind/chrome/collab-role-chip.tsx +62 -0
- package/src/ui-tailwind/chrome/collab-send-to-supplier-button.tsx +68 -0
- package/src/ui-tailwind/chrome/collab-send-to-supplier-modal.tsx +149 -0
- package/src/ui-tailwind/chrome/collab-tamper-banner.tsx +68 -0
- package/src/ui-tailwind/chrome/collab-top-nav-container.tsx +281 -0
- package/src/ui-tailwind/chrome/forward-non-drag-click.ts +104 -0
- package/src/ui-tailwind/chrome/tw-mode-dock.tsx +1 -0
- package/src/ui-tailwind/chrome/tw-selection-tool-host.tsx +7 -1
- package/src/ui-tailwind/chrome/tw-table-grip-layer.tsx +1 -38
- package/src/ui-tailwind/chrome-overlay/index.ts +6 -0
- package/src/ui-tailwind/chrome-overlay/scope-card-role-model.ts +78 -0
- package/src/ui-tailwind/chrome-overlay/scope-keyboard-cycle.ts +49 -0
- package/src/ui-tailwind/chrome-overlay/tw-chrome-overlay.tsx +106 -0
- package/src/ui-tailwind/chrome-overlay/tw-page-stack-overlay-layer.tsx +527 -0
- package/src/ui-tailwind/chrome-overlay/tw-scope-card-layer.tsx +120 -22
- package/src/ui-tailwind/chrome-overlay/tw-scope-card.tsx +310 -32
- package/src/ui-tailwind/chrome-overlay/tw-scope-rail-layer.tsx +93 -14
- package/src/ui-tailwind/editor-surface/paste-plain-text.ts +72 -0
- package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +118 -8
- package/src/ui-tailwind/editor-surface/pm-decorations.ts +35 -1
- package/src/ui-tailwind/editor-surface/pm-page-break-decorations.ts +86 -3
- package/src/ui-tailwind/editor-surface/pm-schema.ts +167 -17
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +35 -7
- package/src/ui-tailwind/editor-surface/remote-cursor-plugin.ts +20 -3
- package/src/ui-tailwind/editor-surface/tw-page-block-view.helpers.ts +265 -0
- package/src/ui-tailwind/editor-surface/tw-page-block-view.tsx +10 -256
- package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +9 -0
- package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +66 -0
- package/src/ui-tailwind/index.ts +37 -1
- package/src/ui-tailwind/page-stack/tw-endnote-area.tsx +57 -0
- package/src/ui-tailwind/page-stack/tw-footnote-area.tsx +71 -0
- package/src/ui-tailwind/page-stack/tw-page-footer-band.tsx +73 -0
- package/src/ui-tailwind/page-stack/tw-page-header-band.tsx +74 -0
- package/src/ui-tailwind/page-stack/tw-page-stack-chrome-layer.tsx +477 -0
- package/src/ui-tailwind/page-stack/tw-region-block-renderer.tsx +374 -0
- package/src/ui-tailwind/review/comment-markdown-renderer.tsx +155 -0
- package/src/ui-tailwind/review/tw-comment-sidebar.tsx +77 -16
- package/src/ui-tailwind/review/tw-review-rail-footer.tsx +29 -3
- package/src/ui-tailwind/status/tw-status-bar.tsx +52 -1
- package/src/ui-tailwind/theme/editor-theme.css +25 -0
- package/src/ui-tailwind/tw-review-workspace.tsx +455 -118
|
@@ -2,6 +2,7 @@ import { useMemo, useRef } from "react";
|
|
|
2
2
|
|
|
3
3
|
import type {
|
|
4
4
|
CommentSidebarThreadSnapshot,
|
|
5
|
+
EditorStoryTarget,
|
|
5
6
|
FormattingAlignment,
|
|
6
7
|
HeaderFooterLinkPatch,
|
|
7
8
|
InsertImageOptions,
|
|
@@ -87,12 +88,25 @@ export interface EditorCommandBag {
|
|
|
87
88
|
onAcceptAllChanges(): void;
|
|
88
89
|
onRejectAllChanges(): void;
|
|
89
90
|
onCloseStory?(): void;
|
|
91
|
+
/**
|
|
92
|
+
* @deprecated P8.11 — see the matching prop on `TwReviewWorkspaceProps`.
|
|
93
|
+
* Kept optional for back-compat; per-page bands use `onOpenStory`.
|
|
94
|
+
*/
|
|
90
95
|
onOpenHeaderStory?(): void;
|
|
96
|
+
/**
|
|
97
|
+
* @deprecated P8.11 — see `onOpenHeaderStory`.
|
|
98
|
+
*/
|
|
91
99
|
onOpenFooterStory?(): void;
|
|
92
100
|
/** Open the header story for a specific page (double-click on its band). */
|
|
93
101
|
onOpenHeaderStoryForPage?(pageIndex: number): void;
|
|
94
102
|
/** Open the footer story for a specific page (double-click on its band). */
|
|
95
103
|
onOpenFooterStoryForPage?(pageIndex: number): void;
|
|
104
|
+
/**
|
|
105
|
+
* P8.11 — per-page header/footer band click handler. Receives the
|
|
106
|
+
* exact `EditorStoryTarget` the band represents; the command bag wires
|
|
107
|
+
* this to `runtime.openStory(target)`.
|
|
108
|
+
*/
|
|
109
|
+
onOpenStory?(target: EditorStoryTarget): void;
|
|
96
110
|
onSetParagraphIndentation?(indentation: {
|
|
97
111
|
left?: number;
|
|
98
112
|
right?: number;
|
|
@@ -34,12 +34,20 @@ import {
|
|
|
34
34
|
type DocumentRuntimeEvent,
|
|
35
35
|
type DocumentRuntime,
|
|
36
36
|
} from "../runtime/document-runtime.ts";
|
|
37
|
+
import { createEditorStateChannel } from "../runtime/editor-state-channel.ts";
|
|
37
38
|
import {
|
|
38
39
|
createRuntimeCommandAppliedBridge,
|
|
39
40
|
type RuntimeCommandAppliedBridge,
|
|
40
41
|
} from "../runtime/collab/runtime-collab-sync.ts";
|
|
41
42
|
import { createInertLayoutFacet } from "../runtime/layout/index.ts";
|
|
42
|
-
import {
|
|
43
|
+
import {
|
|
44
|
+
loadDocxEditorSession,
|
|
45
|
+
loadDocxEditorSessionAsync,
|
|
46
|
+
} from "../io/docx-session.ts";
|
|
47
|
+
import {
|
|
48
|
+
createLoadScheduler,
|
|
49
|
+
type LoadScheduler,
|
|
50
|
+
} from "../io/load-scheduler.ts";
|
|
43
51
|
import {
|
|
44
52
|
decodePersistedSourcePackageBytes,
|
|
45
53
|
hasValidPersistedSourcePackageDigest,
|
|
@@ -48,6 +56,7 @@ import {
|
|
|
48
56
|
createEditorViewStateSnapshot,
|
|
49
57
|
createViewState,
|
|
50
58
|
} from "../runtime/view-state.ts";
|
|
59
|
+
import { hydrateEditorStateFromEnvelope } from "../runtime/editor-state-integration.ts";
|
|
51
60
|
import {
|
|
52
61
|
recordPerfSample,
|
|
53
62
|
} from "../ui-tailwind/editor-surface/perf-probe.ts";
|
|
@@ -62,6 +71,14 @@ export interface ResolvedSource {
|
|
|
62
71
|
initialDocx?: Uint8Array | ArrayBuffer;
|
|
63
72
|
initialSessionState?: EditorSessionState;
|
|
64
73
|
initialSnapshot?: PersistedEditorSnapshot;
|
|
74
|
+
/**
|
|
75
|
+
* Fastload P6: when the boundary hook pre-loads the docx via the
|
|
76
|
+
* async loader (DOM environments only), it stashes the session here
|
|
77
|
+
* so `createRuntime` reuses it instead of running another synchronous
|
|
78
|
+
* load. Undefined in SSR / Node test fallback — `createRuntime` then
|
|
79
|
+
* does the classic synchronous load.
|
|
80
|
+
*/
|
|
81
|
+
preloadedDocxSession?: ReturnType<typeof loadDocxEditorSession>;
|
|
65
82
|
}
|
|
66
83
|
|
|
67
84
|
export interface CreateRuntimeArgs {
|
|
@@ -280,6 +297,9 @@ export function useEditorRuntimeBoundary(
|
|
|
280
297
|
const pendingReadySourceRef = useRef<"docx" | "session" | "snapshot" | null>(null);
|
|
281
298
|
const autosaveTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
282
299
|
const lastSavedRevisionTokenRef = useRef<string | null>(null);
|
|
300
|
+
// Fastload P6: scheduler used by the DOM-side async docx loader. Held
|
|
301
|
+
// here so it can be disposed on unmount / source change.
|
|
302
|
+
const loadSchedulerRef = useRef<LoadScheduler | null>(null);
|
|
283
303
|
const hostAdapterRef = useRef(hostAdapter);
|
|
284
304
|
const datastoreRef = useRef(datastore);
|
|
285
305
|
const onEventRef = useRef(onEvent);
|
|
@@ -355,6 +375,10 @@ export function useEditorRuntimeBoundary(
|
|
|
355
375
|
lastSavedRevisionTokenRef.current = null;
|
|
356
376
|
runtimeRef.current?.dispose?.();
|
|
357
377
|
runtimeRef.current = null;
|
|
378
|
+
// Fastload P6: dispose any scheduler held from a previous mount /
|
|
379
|
+
// source cycle before allocating a fresh one for this load.
|
|
380
|
+
loadSchedulerRef.current?.dispose();
|
|
381
|
+
loadSchedulerRef.current = null;
|
|
358
382
|
setRuntime(null);
|
|
359
383
|
|
|
360
384
|
try {
|
|
@@ -375,6 +399,33 @@ export function useEditorRuntimeBoundary(
|
|
|
375
399
|
return;
|
|
376
400
|
}
|
|
377
401
|
|
|
402
|
+
// Fastload P6: in a DOM environment, preload the docx via the
|
|
403
|
+
// async loader so normalize-body yields mid-walk and the browser
|
|
404
|
+
// can paint the skeleton while the rest of the parse finishes.
|
|
405
|
+
// SSR / Node tests fall through to the synchronous load inside
|
|
406
|
+
// `createRuntime`.
|
|
407
|
+
if (
|
|
408
|
+
source.initialDocx !== undefined &&
|
|
409
|
+
source.preloadedDocxSession === undefined &&
|
|
410
|
+
typeof document !== "undefined"
|
|
411
|
+
) {
|
|
412
|
+
const scheduler = createLoadScheduler();
|
|
413
|
+
loadSchedulerRef.current = scheduler;
|
|
414
|
+
const preloaded = await loadDocxEditorSessionAsync({
|
|
415
|
+
documentId,
|
|
416
|
+
sourceLabel: source.sourceLabel,
|
|
417
|
+
bytes: source.initialDocx,
|
|
418
|
+
editorBuild: "dev",
|
|
419
|
+
scheduler,
|
|
420
|
+
});
|
|
421
|
+
if (cancelled) {
|
|
422
|
+
scheduler.dispose();
|
|
423
|
+
loadSchedulerRef.current = null;
|
|
424
|
+
return;
|
|
425
|
+
}
|
|
426
|
+
source.preloadedDocxSession = preloaded;
|
|
427
|
+
}
|
|
428
|
+
|
|
378
429
|
const nextRuntime = createRuntime(
|
|
379
430
|
{
|
|
380
431
|
documentId,
|
|
@@ -480,6 +531,11 @@ export function useEditorRuntimeBoundary(
|
|
|
480
531
|
}
|
|
481
532
|
runtimeRef.current?.dispose?.();
|
|
482
533
|
runtimeRef.current = null;
|
|
534
|
+
// Fastload P6: release any pending idle callbacks the load scheduler
|
|
535
|
+
// registered so React unmount doesn't leak setTimeout/IdleCallback
|
|
536
|
+
// handles.
|
|
537
|
+
loadSchedulerRef.current?.dispose();
|
|
538
|
+
loadSchedulerRef.current = null;
|
|
483
539
|
};
|
|
484
540
|
}, []);
|
|
485
541
|
|
|
@@ -568,14 +624,16 @@ function createRuntime(
|
|
|
568
624
|
handlers: RuntimeLifecycleHandlers = {},
|
|
569
625
|
): WordReviewEditorRuntime {
|
|
570
626
|
const bootstrapEvents: DocumentRuntimeEvent[] = [];
|
|
571
|
-
const docxSession =
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
627
|
+
const docxSession =
|
|
628
|
+
args.source.preloadedDocxSession ??
|
|
629
|
+
(args.source.initialDocx
|
|
630
|
+
? loadDocxEditorSession({
|
|
631
|
+
documentId: args.documentId,
|
|
632
|
+
sourceLabel: args.source.sourceLabel,
|
|
633
|
+
bytes: args.source.initialDocx,
|
|
634
|
+
editorBuild: "dev",
|
|
635
|
+
})
|
|
636
|
+
: undefined);
|
|
579
637
|
const snapshotExportResolution = !args.source.initialDocx
|
|
580
638
|
? resolvePackageBackedExportSession(args)
|
|
581
639
|
: undefined;
|
|
@@ -594,7 +652,7 @@ function createRuntime(
|
|
|
594
652
|
? applySessionExportBarrier(initialSessionState, snapshotExportResolution.barrier)
|
|
595
653
|
: initialSessionState;
|
|
596
654
|
|
|
597
|
-
const
|
|
655
|
+
const baseRuntime = createDocumentRuntime({
|
|
598
656
|
documentId: args.documentId,
|
|
599
657
|
initialSessionState: runtimeSessionState,
|
|
600
658
|
sourceKind: args.source.source,
|
|
@@ -629,7 +687,39 @@ function createRuntime(
|
|
|
629
687
|
},
|
|
630
688
|
defaultAuthorId: args.currentUserId,
|
|
631
689
|
onCommandApplied: args.commandAppliedBridge?.onCommandApplied,
|
|
632
|
-
})
|
|
690
|
+
});
|
|
691
|
+
|
|
692
|
+
// Schema 1.2: drive load-path hydration from the parsed envelope.
|
|
693
|
+
if (docxSession?.initialEditorStatePayload) {
|
|
694
|
+
void hydrateEditorStateFromEnvelope({
|
|
695
|
+
editorState: docxSession.initialEditorStatePayload,
|
|
696
|
+
channel: baseRuntime.editorStateChannel,
|
|
697
|
+
applyBlob: (ns, data) => {
|
|
698
|
+
switch (ns) {
|
|
699
|
+
case "hostAnnotations":
|
|
700
|
+
baseRuntime.setHostAnnotationOverlay(data as import("../api/public-types.ts").HostAnnotationOverlay);
|
|
701
|
+
break;
|
|
702
|
+
case "workflowOverlay":
|
|
703
|
+
baseRuntime.setWorkflowOverlay(data as import("../api/public-types.ts").WorkflowOverlay);
|
|
704
|
+
break;
|
|
705
|
+
case "workflowMetadata":
|
|
706
|
+
// Metadata is split across definitions + entries in the runtime;
|
|
707
|
+
// inline payload carries the full snapshot so we apply entries.
|
|
708
|
+
if (data && typeof data === "object" && "entries" in (data as object)) {
|
|
709
|
+
baseRuntime.setWorkflowMetadataEntries(
|
|
710
|
+
(data as { entries: import("../api/public-types.ts").WorkflowMetadataEntry[] }).entries,
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
break;
|
|
714
|
+
case "workItems":
|
|
715
|
+
// workItems namespace is reserved; no runtime setter yet.
|
|
716
|
+
break;
|
|
717
|
+
}
|
|
718
|
+
},
|
|
719
|
+
});
|
|
720
|
+
}
|
|
721
|
+
|
|
722
|
+
const runtime: WordReviewEditorRuntime = Object.assign(baseRuntime, {
|
|
633
723
|
drainBootstrapEvents: () => bootstrapEvents.splice(0, bootstrapEvents.length),
|
|
634
724
|
emitBlockedCommand: (
|
|
635
725
|
command: string,
|
|
@@ -868,6 +958,7 @@ function createLoadingRuntimeBridge(input: {
|
|
|
868
958
|
Promise.reject(createLoadingBoundaryError(input.snapshot.documentId, "export")),
|
|
869
959
|
setWorkflowOverlay: () => undefined,
|
|
870
960
|
clearWorkflowOverlay: () => undefined,
|
|
961
|
+
getWorkflowOverlay: () => null,
|
|
871
962
|
getWorkflowScopeSnapshot: () => null,
|
|
872
963
|
getInteractionGuardSnapshot: () => ({ effectiveMode: "edit", blockedReasons: [] }),
|
|
873
964
|
getWorkflowMarkupSnapshot: () => ({
|
|
@@ -907,6 +998,15 @@ function createLoadingRuntimeBridge(input: {
|
|
|
907
998
|
items: [],
|
|
908
999
|
}),
|
|
909
1000
|
getRuntimeContextAnalytics: () => null,
|
|
1001
|
+
// Schema 1.2 — no-op stubs for loading boundary (SSR / headless path).
|
|
1002
|
+
configureEditorStatePolicy: () => undefined,
|
|
1003
|
+
registerEditorStateResolver: () => undefined,
|
|
1004
|
+
registerEditorStatePersister: () => undefined,
|
|
1005
|
+
getEditorStateKey: () => undefined,
|
|
1006
|
+
retryPendingPersist: async () => undefined,
|
|
1007
|
+
editorStateChannel: createEditorStateChannel(),
|
|
1008
|
+
getPerfCountersSnapshot: () => ({}),
|
|
1009
|
+
resetPerfCounters: () => undefined,
|
|
910
1010
|
};
|
|
911
1011
|
}
|
|
912
1012
|
|
|
@@ -64,6 +64,16 @@ export interface EditorShellViewProps {
|
|
|
64
64
|
interactionGuardSnapshot?: InteractionGuardSnapshot;
|
|
65
65
|
chromePreset?: WordReviewEditorChromePreset;
|
|
66
66
|
chromeOptions?: Partial<WordReviewEditorChromeOptions>;
|
|
67
|
+
/** P9g — live collab session for the `"collab"` chrome preset's top nav. */
|
|
68
|
+
collabSession?: import("../runtime/collab-session.ts").CollabSession;
|
|
69
|
+
collabTransportStatus?: import("../api/awareness-identity-types.ts").TransportStatus;
|
|
70
|
+
collabActorId?: string;
|
|
71
|
+
collabSendBaseline?: {
|
|
72
|
+
originDocumentId: string;
|
|
73
|
+
originPayloadId: string;
|
|
74
|
+
originContentHash: string;
|
|
75
|
+
payloadXml: string;
|
|
76
|
+
};
|
|
67
77
|
reviewQueue?: ReviewQueueSnapshot;
|
|
68
78
|
documentContextAnalytics?: RuntimeContextAnalyticsSnapshot | null;
|
|
69
79
|
selectionContextAnalytics?: RuntimeContextAnalyticsSnapshot | null;
|
|
@@ -105,6 +115,17 @@ export interface EditorShellViewProps {
|
|
|
105
115
|
issueId: string;
|
|
106
116
|
action: import("../api/public-types.ts").ScopeIssueAction;
|
|
107
117
|
}) => void;
|
|
118
|
+
/** R3 — forwarded from workspace to WordReviewEditor. */
|
|
119
|
+
onScopeAcceptSuggestionGroup?: (payload: {
|
|
120
|
+
scopeId: string;
|
|
121
|
+
groupId: string;
|
|
122
|
+
}) => void;
|
|
123
|
+
onScopeRejectSuggestionGroup?: (payload: {
|
|
124
|
+
scopeId: string;
|
|
125
|
+
groupId: string;
|
|
126
|
+
}) => void;
|
|
127
|
+
/** K2 — forwarded from workspace to WordReviewEditor. */
|
|
128
|
+
onScopeAskAgent?: (payload: { scopeId: string }) => void;
|
|
108
129
|
}
|
|
109
130
|
|
|
110
131
|
export function EditorShellView(props: EditorShellViewProps) {
|
|
@@ -52,6 +52,11 @@ export interface EditorSurfaceControllerProps {
|
|
|
52
52
|
onUndo?: () => void;
|
|
53
53
|
onRedo?: () => void;
|
|
54
54
|
onBlockedInput?: (command: "paste" | "drop", message: string) => void;
|
|
55
|
+
onPasteApplied?: (meta: {
|
|
56
|
+
segmentCount: number;
|
|
57
|
+
charCount: number;
|
|
58
|
+
source: "paste" | "drop";
|
|
59
|
+
}) => void;
|
|
55
60
|
onCommentActivated?: (commentId: string) => void;
|
|
56
61
|
onRevisionActivated?: (revisionId: string) => void;
|
|
57
62
|
workflowScopes?: readonly WorkflowScope[];
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
import type { SelectionSnapshot } from "../../api/public-types";
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Headless-UI-side `createSelectionSnapshot` that produces the **public**
|
|
5
|
+
* `EditorAnchorProjection` shape (top-level `from`/`to`). The runtime-facing
|
|
6
|
+
* twin at `src/core/state/editor-state.ts` produces the internal
|
|
7
|
+
* `RangeAnchor` shape (`range: { from, to }`). The two are *not*
|
|
8
|
+
* interchangeable — they serve different type contracts. See the
|
|
9
|
+
* `EditorAnchorProjection` definitions in `src/api/public-types.ts` vs
|
|
10
|
+
* `src/core/selection/mapping.ts`. Do not merge without first unifying
|
|
11
|
+
* those two definitions.
|
|
12
|
+
*/
|
|
3
13
|
export function createSelectionSnapshot(anchor: number, head = anchor): SelectionSnapshot {
|
|
4
14
|
const from = Math.min(anchor, head);
|
|
5
15
|
const to = Math.max(anchor, head);
|
|
@@ -51,6 +51,24 @@ export function resolveChromePresetOptions(
|
|
|
51
51
|
showSectionTagAction: false,
|
|
52
52
|
showReviewRail: true,
|
|
53
53
|
},
|
|
54
|
+
collab: {
|
|
55
|
+
// Collab preset composes on top of "review" — same review rail,
|
|
56
|
+
// plus the collab top nav (presence, role + audience chips,
|
|
57
|
+
// tamper banner, negotiation action bar, send-to-supplier).
|
|
58
|
+
// Each sub-surface has its own flag so hosts can selectively
|
|
59
|
+
// disable parts (e.g. single-user demo, or a presenter-only view)
|
|
60
|
+
// without forking the preset.
|
|
61
|
+
showReviewQueueBar: false,
|
|
62
|
+
showSectionTagAction: false,
|
|
63
|
+
showReviewRail: true,
|
|
64
|
+
showCollabTopNav: true,
|
|
65
|
+
showCollabPresenceStrip: true,
|
|
66
|
+
showCollabRoleChip: true,
|
|
67
|
+
showCollabAudienceChip: true,
|
|
68
|
+
showCollabTamperBanner: true,
|
|
69
|
+
showCollabNegotiationActionBar: true,
|
|
70
|
+
showCollabSendToSupplier: true,
|
|
71
|
+
},
|
|
54
72
|
};
|
|
55
73
|
|
|
56
74
|
return {
|
|
@@ -116,6 +134,16 @@ export function resolveChromeVisibilityForPreset(input: {
|
|
|
116
134
|
statusBar: true,
|
|
117
135
|
reviewRail: options.showReviewRail,
|
|
118
136
|
},
|
|
137
|
+
collab: {
|
|
138
|
+
toolbar: true,
|
|
139
|
+
alerts: true,
|
|
140
|
+
selectionOverlay: true,
|
|
141
|
+
contextToolbars: true,
|
|
142
|
+
contextAnalytics: true,
|
|
143
|
+
pageChrome: true,
|
|
144
|
+
statusBar: true,
|
|
145
|
+
reviewRail: options.showReviewRail,
|
|
146
|
+
},
|
|
119
147
|
};
|
|
120
148
|
|
|
121
149
|
return {
|
|
@@ -1,15 +1,75 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
WordReviewEditorChromeOptions,
|
|
5
|
+
WordReviewEditorChromePreset,
|
|
6
|
+
} from "../../api/public-types";
|
|
7
|
+
import type { CollabSession } from "../../runtime/collab-session.ts";
|
|
8
|
+
import type { TransportStatus } from "../../api/awareness-identity-types.ts";
|
|
4
9
|
import {
|
|
5
10
|
TwToolbar,
|
|
6
11
|
type TwToolbarProps,
|
|
7
12
|
} from "../toolbar/tw-toolbar";
|
|
13
|
+
import { CollabTopNavContainer } from "./collab-top-nav-container";
|
|
8
14
|
|
|
9
15
|
export interface ChromePresetToolbarProps extends TwToolbarProps {
|
|
10
16
|
chromePreset: WordReviewEditorChromePreset;
|
|
17
|
+
/** P9g — optional collab session. Rendered above the toolbar when the `"collab"` preset is active. */
|
|
18
|
+
collabSession?: CollabSession;
|
|
19
|
+
collabTransportStatus?: TransportStatus;
|
|
20
|
+
activeCommentId?: string;
|
|
21
|
+
collabActorId?: string;
|
|
22
|
+
collabSendBaseline?: {
|
|
23
|
+
originDocumentId: string;
|
|
24
|
+
originPayloadId: string;
|
|
25
|
+
originContentHash: string;
|
|
26
|
+
payloadXml: string;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Sub-surface visibility toggles from `resolveChromePresetOptions`.
|
|
30
|
+
* When omitted the container defaults match the `"collab"` preset.
|
|
31
|
+
*/
|
|
32
|
+
chromeOptionsResolved?: Pick<
|
|
33
|
+
WordReviewEditorChromeOptions,
|
|
34
|
+
| "showCollabTopNav"
|
|
35
|
+
| "showCollabPresenceStrip"
|
|
36
|
+
| "showCollabRoleChip"
|
|
37
|
+
| "showCollabAudienceChip"
|
|
38
|
+
| "showCollabTamperBanner"
|
|
39
|
+
| "showCollabNegotiationActionBar"
|
|
40
|
+
| "showCollabSendToSupplier"
|
|
41
|
+
>;
|
|
11
42
|
}
|
|
12
43
|
|
|
13
44
|
export function ChromePresetToolbar(props: ChromePresetToolbarProps) {
|
|
14
|
-
|
|
45
|
+
const {
|
|
46
|
+
collabSession,
|
|
47
|
+
collabTransportStatus,
|
|
48
|
+
activeCommentId,
|
|
49
|
+
collabActorId,
|
|
50
|
+
collabSendBaseline,
|
|
51
|
+
chromeOptionsResolved,
|
|
52
|
+
...toolbarProps
|
|
53
|
+
} = props;
|
|
54
|
+
|
|
55
|
+
const collabActive =
|
|
56
|
+
props.chromePreset === "collab" && collabSession !== undefined;
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<>
|
|
60
|
+
{collabActive ? (
|
|
61
|
+
<CollabTopNavContainer
|
|
62
|
+
session={collabSession}
|
|
63
|
+
{...(activeCommentId !== undefined ? { activeCommentId } : {})}
|
|
64
|
+
actorId={collabActorId ?? "local"}
|
|
65
|
+
{...(collabTransportStatus
|
|
66
|
+
? { transportStatus: collabTransportStatus }
|
|
67
|
+
: {})}
|
|
68
|
+
{...(chromeOptionsResolved ? { visibility: chromeOptionsResolved } : {})}
|
|
69
|
+
{...(collabSendBaseline ? { sendBaseline: collabSendBaseline } : {})}
|
|
70
|
+
/>
|
|
71
|
+
) : null}
|
|
72
|
+
<TwToolbar {...toolbarProps} preset={props.chromePreset} />
|
|
73
|
+
</>
|
|
74
|
+
);
|
|
15
75
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
|
|
3
|
+
import type { CommentAudience } from "../../api/comment-presentation-types.ts";
|
|
4
|
+
|
|
5
|
+
export interface CollabAudienceChipProps {
|
|
6
|
+
/** `undefined` when there is no active comment. */
|
|
7
|
+
audience: CommentAudience | undefined;
|
|
8
|
+
/** `true` when the local user is allowed to change audience. */
|
|
9
|
+
canEdit: boolean;
|
|
10
|
+
/** Invoked when the user cycles the chip. Caller dispatches set-audience. */
|
|
11
|
+
onCycle?: (next: CommentAudience) => void;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const CYCLE: readonly CommentAudience[] = ["internal", "external", "shared"];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Audience chip for the active comment in the collab top nav (P9c).
|
|
19
|
+
*
|
|
20
|
+
* Renders the current `audience` of the active comment. Clicking
|
|
21
|
+
* cycles `internal → external → shared → internal` and invokes
|
|
22
|
+
* `onCycle(next)` — the caller is responsible for dispatching
|
|
23
|
+
* `set-audience` through `session.dispatchCommentPresentation`.
|
|
24
|
+
*
|
|
25
|
+
* Fail-safe rendering:
|
|
26
|
+
* - Renders a disabled "no comment" placeholder when `audience` is
|
|
27
|
+
* undefined (no active comment selected).
|
|
28
|
+
* - Respects `canEdit`: when false, renders a disabled chip with the
|
|
29
|
+
* current audience but no click handler — useful for observer /
|
|
30
|
+
* reviewer who cannot change the audience.
|
|
31
|
+
*/
|
|
32
|
+
export function CollabAudienceChip({
|
|
33
|
+
audience,
|
|
34
|
+
canEdit,
|
|
35
|
+
onCycle,
|
|
36
|
+
className,
|
|
37
|
+
}: CollabAudienceChipProps): React.ReactElement {
|
|
38
|
+
const empty = audience === undefined;
|
|
39
|
+
const disabled = empty || !canEdit;
|
|
40
|
+
const rootClass = [
|
|
41
|
+
"tw-collab-audience-chip",
|
|
42
|
+
audience ? `tw-collab-audience-chip--${audience}` : "tw-collab-audience-chip--empty",
|
|
43
|
+
disabled ? "tw-collab-audience-chip--disabled" : null,
|
|
44
|
+
className ?? null,
|
|
45
|
+
]
|
|
46
|
+
.filter((v): v is string => v !== null)
|
|
47
|
+
.join(" ");
|
|
48
|
+
|
|
49
|
+
const label = empty ? "no comment" : audience;
|
|
50
|
+
|
|
51
|
+
const handleClick = (): void => {
|
|
52
|
+
if (disabled || !audience) return;
|
|
53
|
+
const idx = CYCLE.indexOf(audience);
|
|
54
|
+
const next = CYCLE[(idx + 1) % CYCLE.length]!;
|
|
55
|
+
onCycle?.(next);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
return (
|
|
59
|
+
<button
|
|
60
|
+
type="button"
|
|
61
|
+
className={rootClass}
|
|
62
|
+
data-testid="collab-audience-chip"
|
|
63
|
+
data-audience={audience ?? "none"}
|
|
64
|
+
data-can-edit={canEdit ? "true" : "false"}
|
|
65
|
+
aria-label={empty ? "No active comment" : `Audience: ${audience}`}
|
|
66
|
+
aria-disabled={disabled ? "true" : undefined}
|
|
67
|
+
disabled={disabled}
|
|
68
|
+
onClick={handleClick}
|
|
69
|
+
>
|
|
70
|
+
{label}
|
|
71
|
+
</button>
|
|
72
|
+
);
|
|
73
|
+
}
|