@beyondwork/docx-react-component 1.0.35 → 1.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.
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.
|
|
4
|
+
"version": "1.0.36",
|
|
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": [
|
package/src/api/public-types.ts
CHANGED
|
@@ -920,7 +920,7 @@ export type ViewMode = "editing" | "review" | "view";
|
|
|
920
920
|
* Distinct from `ViewMode` (editor posture) and `WorkspaceMode` (shell layout).
|
|
921
921
|
* `DocumentMode` reflects document-level editing authority, not presentation.
|
|
922
922
|
*/
|
|
923
|
-
export type DocumentMode = "editing" | "suggesting" | "viewing";
|
|
923
|
+
export type DocumentMode = "editing" | "suggesting" | "viewing" | "commenting";
|
|
924
924
|
|
|
925
925
|
/**
|
|
926
926
|
* A single permission range parsed from `w:permStart` / `w:permEnd` in the
|
|
@@ -195,7 +195,7 @@ export interface EditorTransaction {
|
|
|
195
195
|
|
|
196
196
|
export interface CommandExecutionContext {
|
|
197
197
|
timestamp: string;
|
|
198
|
-
documentMode?: "editing" | "suggesting" | "viewing";
|
|
198
|
+
documentMode?: "editing" | "suggesting" | "viewing" | "commenting";
|
|
199
199
|
defaultAuthorId?: string;
|
|
200
200
|
}
|
|
201
201
|
|
|
@@ -738,7 +738,7 @@ export function createDocumentRuntime(
|
|
|
738
738
|
});
|
|
739
739
|
}
|
|
740
740
|
|
|
741
|
-
if (viewState.documentMode === "viewing") {
|
|
741
|
+
if (viewState.documentMode === "viewing" || viewState.documentMode === "commenting") {
|
|
742
742
|
reasons.push({
|
|
743
743
|
code: "document_viewing_mode",
|
|
744
744
|
message: "Document is in viewing mode.",
|
|
@@ -822,8 +822,8 @@ export function createDocumentRuntime(
|
|
|
822
822
|
function getEffectiveDocumentMode(
|
|
823
823
|
selection: EditorState["selection"],
|
|
824
824
|
): DocumentMode {
|
|
825
|
-
if (viewState.documentMode === "viewing") {
|
|
826
|
-
return
|
|
825
|
+
if (viewState.documentMode === "viewing" || viewState.documentMode === "commenting") {
|
|
826
|
+
return viewState.documentMode;
|
|
827
827
|
}
|
|
828
828
|
const matchingScope = getMatchingWorkflowScope(selection);
|
|
829
829
|
if (matchingScope?.mode === "suggest") {
|
|
@@ -1529,13 +1529,13 @@ export function createDocumentRuntime(
|
|
|
1529
1529
|
}
|
|
1530
1530
|
|
|
1531
1531
|
if (command.type === "history.undo") {
|
|
1532
|
-
if (viewState.documentMode === "viewing") return;
|
|
1532
|
+
if (viewState.documentMode === "viewing" || viewState.documentMode === "commenting") return;
|
|
1533
1533
|
applyHistory("undo");
|
|
1534
1534
|
return;
|
|
1535
1535
|
}
|
|
1536
1536
|
|
|
1537
1537
|
if (command.type === "history.redo") {
|
|
1538
|
-
if (viewState.documentMode === "viewing") return;
|
|
1538
|
+
if (viewState.documentMode === "viewing" || viewState.documentMode === "commenting") return;
|
|
1539
1539
|
applyHistory("redo");
|
|
1540
1540
|
return;
|
|
1541
1541
|
}
|
|
@@ -23,7 +23,7 @@ export interface SessionCapabilities {
|
|
|
23
23
|
|
|
24
24
|
// ── Document mode ──
|
|
25
25
|
/** Runtime document mode — editing authority, distinct from view/workspace mode. */
|
|
26
|
-
documentMode: "editing" | "suggesting" | "viewing";
|
|
26
|
+
documentMode: "editing" | "suggesting" | "viewing" | "commenting";
|
|
27
27
|
|
|
28
28
|
// ── Command capabilities ──
|
|
29
29
|
canUndo: boolean;
|
|
@@ -101,12 +101,15 @@ export function deriveCapabilities(
|
|
|
101
101
|
? "read-only-diagnostics"
|
|
102
102
|
: reviewMode;
|
|
103
103
|
|
|
104
|
-
// Command capabilities —
|
|
105
|
-
|
|
104
|
+
// Command capabilities — "viewing" and "commenting" modes both disable editing;
|
|
105
|
+
// "commenting" additionally keeps comment creation enabled.
|
|
106
|
+
const canEdit = isReady && !isReadOnly && !hasFatalError
|
|
107
|
+
&& documentMode !== "viewing" && documentMode !== "commenting";
|
|
106
108
|
const canUndo = snapshot.commandState.canUndo && canEdit;
|
|
107
109
|
const canRedo = snapshot.commandState.canRedo && canEdit;
|
|
110
|
+
const canComment = isReady && !hasFatalError && documentMode !== "viewing";
|
|
108
111
|
const canAddComment =
|
|
109
|
-
|
|
112
|
+
canComment &&
|
|
110
113
|
activeStory.kind === "main" &&
|
|
111
114
|
!snapshot.selection.isCollapsed &&
|
|
112
115
|
Boolean(snapshot.surface) &&
|