@beyondwork/docx-react-component 1.0.19 → 1.0.21
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 +44 -25
- package/src/api/public-types.ts +336 -0
- package/src/api/session-state.ts +2 -0
- package/src/core/commands/formatting-commands.ts +1 -1
- package/src/core/commands/index.ts +14 -2
- package/src/core/search/search-text.ts +28 -0
- package/src/core/state/editor-state.ts +3 -0
- package/src/index.ts +21 -0
- package/src/io/docx-session.ts +363 -17
- package/src/io/export/serialize-comments.ts +104 -34
- package/src/io/export/serialize-footnotes.ts +198 -1
- package/src/io/export/serialize-headers-footers.ts +203 -10
- package/src/io/export/serialize-main-document.ts +83 -3
- package/src/io/export/split-review-boundaries.ts +181 -19
- package/src/io/normalize/normalize-text.ts +82 -8
- package/src/io/ooxml/highlight-colors.ts +39 -0
- package/src/io/ooxml/parse-comments.ts +85 -19
- package/src/io/ooxml/parse-fields.ts +396 -0
- package/src/io/ooxml/parse-footnotes.ts +240 -2
- package/src/io/ooxml/parse-headers-footers.ts +431 -7
- package/src/io/ooxml/parse-inline-media.ts +15 -1
- package/src/io/ooxml/parse-main-document.ts +396 -14
- package/src/io/ooxml/parse-revisions.ts +317 -38
- package/src/legal/bookmarks.ts +44 -0
- package/src/legal/cross-references.ts +59 -1
- package/src/model/canonical-document.ts +117 -1
- package/src/model/snapshot.ts +85 -1
- package/src/review/store/revision-store.ts +6 -0
- package/src/review/store/revision-types.ts +1 -0
- package/src/runtime/document-navigation.ts +52 -13
- package/src/runtime/document-runtime.ts +1521 -75
- package/src/runtime/read-only-diagnostics-runtime.ts +8 -0
- package/src/runtime/session-capabilities.ts +33 -3
- package/src/runtime/surface-projection.ts +86 -25
- package/src/runtime/table-schema.ts +2 -2
- package/src/runtime/view-state.ts +24 -6
- package/src/runtime/workflow-markup.ts +349 -0
- package/src/ui/WordReviewEditor.tsx +915 -1314
- package/src/ui/editor-command-bag.ts +120 -0
- package/src/ui/editor-runtime-boundary.ts +1448 -0
- package/src/ui/editor-shell-view.tsx +134 -0
- package/src/ui/editor-surface-controller.tsx +55 -0
- package/src/ui/headless/revision-decoration-model.ts +4 -4
- package/src/ui/runtime-snapshot-selectors.ts +197 -0
- package/src/ui/workflow-surface-blocked-rails.ts +94 -0
- package/src/ui-tailwind/chrome/tw-alert-banner.tsx +18 -2
- package/src/ui-tailwind/chrome/tw-image-context-toolbar.tsx +129 -0
- package/src/ui-tailwind/chrome/tw-layout-panel.tsx +114 -0
- package/src/ui-tailwind/chrome/tw-object-context-toolbar.tsx +34 -0
- package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +27 -2
- package/src/ui-tailwind/chrome/tw-table-context-toolbar.tsx +128 -0
- package/src/ui-tailwind/editor-surface/perf-probe.ts +86 -14
- package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +2 -2
- package/src/ui-tailwind/editor-surface/pm-decorations.ts +237 -0
- package/src/ui-tailwind/editor-surface/pm-position-map.ts +1 -1
- package/src/ui-tailwind/editor-surface/pm-schema.ts +139 -8
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +98 -48
- package/src/ui-tailwind/editor-surface/surface-build-keys.ts +55 -0
- package/src/ui-tailwind/editor-surface/tw-opaque-block.tsx +7 -1
- package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +190 -48
- package/src/ui-tailwind/page-chrome-model.ts +27 -0
- package/src/ui-tailwind/review/tw-comment-sidebar.tsx +7 -7
- package/src/ui-tailwind/review/tw-health-panel.tsx +31 -2
- package/src/ui-tailwind/review/tw-review-rail.tsx +3 -3
- package/src/ui-tailwind/review/tw-revision-sidebar.tsx +15 -15
- package/src/ui-tailwind/theme/editor-theme.css +130 -0
- package/src/ui-tailwind/toolbar/tw-toolbar.tsx +543 -5
- package/src/ui-tailwind/tw-review-workspace.tsx +316 -19
- package/src/validation/compatibility-engine.ts +27 -4
- package/src/validation/compatibility-report.ts +1 -0
- package/src/validation/docx-comment-proof.ts +220 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { useMemo, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
import type {
|
|
4
|
+
CommentSidebarThreadSnapshot,
|
|
5
|
+
FormattingAlignment,
|
|
6
|
+
HeaderFooterLinkPatch,
|
|
7
|
+
InsertImageOptions,
|
|
8
|
+
SectionBreakType,
|
|
9
|
+
SectionLayoutPatch,
|
|
10
|
+
SectionPageNumberingPatch,
|
|
11
|
+
TrackedChangeEntrySnapshot,
|
|
12
|
+
ZoomLevel,
|
|
13
|
+
WorkspaceMode,
|
|
14
|
+
} from "../api/public-types.ts";
|
|
15
|
+
import type { ReviewRailTab } from "../ui-tailwind/review/tw-review-rail.tsx";
|
|
16
|
+
|
|
17
|
+
type CommandHandler = (...args: any[]) => unknown;
|
|
18
|
+
|
|
19
|
+
export interface EditorCommandBag {
|
|
20
|
+
onWorkspaceModeChange(value: WorkspaceMode): void;
|
|
21
|
+
onZoomChange?(level: ZoomLevel): void;
|
|
22
|
+
onActiveRailTabChange(value: ReviewRailTab): void;
|
|
23
|
+
onShowTrackedChangesChange(show: boolean): void;
|
|
24
|
+
onUndo(): void;
|
|
25
|
+
onRedo(): void;
|
|
26
|
+
onSetParagraphStyle?(styleId: string): void;
|
|
27
|
+
onToggleBold?(): void;
|
|
28
|
+
onToggleItalic?(): void;
|
|
29
|
+
onToggleUnderline?(): void;
|
|
30
|
+
onSetSelectionTextColor?(color: string): void;
|
|
31
|
+
onSetSelectionHighlightColor?(color: string | null): void;
|
|
32
|
+
onToggleStrikethrough?(): void;
|
|
33
|
+
onToggleSuperscript?(): void;
|
|
34
|
+
onToggleSubscript?(): void;
|
|
35
|
+
onSetFontFamily?(fontFamily: string): void;
|
|
36
|
+
onSetFontSize?(fontSize: number): void;
|
|
37
|
+
onSetTextColor?(color: string): void;
|
|
38
|
+
onSetHighlightColor?(color: string | null): void;
|
|
39
|
+
onSetAlignment?(alignment: FormattingAlignment): void;
|
|
40
|
+
onOutdent?(): void;
|
|
41
|
+
onIndent?(): void;
|
|
42
|
+
onAddComment(): void;
|
|
43
|
+
onInsertPageBreak?(): void;
|
|
44
|
+
onInsertTable?(): void;
|
|
45
|
+
onInsertSectionBreak?(type: SectionBreakType): void;
|
|
46
|
+
onInsertImage?(options: InsertImageOptions): void;
|
|
47
|
+
onSetTableStyle?(styleId: string): void;
|
|
48
|
+
onAddRowBefore?(): void;
|
|
49
|
+
onAddRowAfter?(): void;
|
|
50
|
+
onAddColumnBefore?(): void;
|
|
51
|
+
onAddColumnAfter?(): void;
|
|
52
|
+
onDeleteRow?(): void;
|
|
53
|
+
onDeleteColumn?(): void;
|
|
54
|
+
onDeleteTable?(): void;
|
|
55
|
+
onMergeCells?(): void;
|
|
56
|
+
onSplitCell?(): void;
|
|
57
|
+
onSetCellBackground?(color: string): void;
|
|
58
|
+
onSetImageLayout?(
|
|
59
|
+
mediaId: string,
|
|
60
|
+
dimensions: { widthEmu: number; heightEmu: number },
|
|
61
|
+
): void;
|
|
62
|
+
onSetImageFrame?(
|
|
63
|
+
mediaId: string,
|
|
64
|
+
offsets: { horizontalOffsetEmu?: number; verticalOffsetEmu?: number },
|
|
65
|
+
): void;
|
|
66
|
+
onDeleteSectionBreak?(sectionIndex: number): void;
|
|
67
|
+
onUpdateSectionLayout?(sectionIndex: number, patch: SectionLayoutPatch): void;
|
|
68
|
+
onSetSectionPageNumbering?(
|
|
69
|
+
sectionIndex: number,
|
|
70
|
+
patch: SectionPageNumberingPatch | null,
|
|
71
|
+
): void;
|
|
72
|
+
onSetHeaderFooterLink?(
|
|
73
|
+
sectionIndex: number,
|
|
74
|
+
patch: HeaderFooterLinkPatch,
|
|
75
|
+
): void;
|
|
76
|
+
onExport(): void;
|
|
77
|
+
onOpenComment(thread: CommentSidebarThreadSnapshot): void;
|
|
78
|
+
onResolveComment(commentId: string): void;
|
|
79
|
+
onReopenComment?(commentId: string): void;
|
|
80
|
+
onAddReply?(commentId: string, body: string): void;
|
|
81
|
+
onEditBody?(commentId: string, body: string): void;
|
|
82
|
+
onOpenRevision(revision: TrackedChangeEntrySnapshot): void;
|
|
83
|
+
onAcceptRevision(revisionId: string): void;
|
|
84
|
+
onRejectRevision(revisionId: string): void;
|
|
85
|
+
onAcceptAllChanges(): void;
|
|
86
|
+
onRejectAllChanges(): void;
|
|
87
|
+
onCloseStory?(): void;
|
|
88
|
+
onOpenHeaderStory?(): void;
|
|
89
|
+
onOpenFooterStory?(): void;
|
|
90
|
+
onSetParagraphIndentation?(indentation: {
|
|
91
|
+
left?: number;
|
|
92
|
+
right?: number;
|
|
93
|
+
firstLine?: number;
|
|
94
|
+
hanging?: number;
|
|
95
|
+
}): void;
|
|
96
|
+
onSetParagraphTabStops?(
|
|
97
|
+
tabStops: Array<{ pos: number; val?: string; leader?: string }>,
|
|
98
|
+
): void;
|
|
99
|
+
onRestartNumbering?(): void;
|
|
100
|
+
onContinueNumbering?(): void;
|
|
101
|
+
onNavigateHeading?(headingId: string): void;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function useCommandBag<T extends object>(commands: T): T {
|
|
105
|
+
const commandsRef = useRef(commands);
|
|
106
|
+
commandsRef.current = commands;
|
|
107
|
+
|
|
108
|
+
return useMemo(() => {
|
|
109
|
+
const stableBag: Partial<T> = {};
|
|
110
|
+
|
|
111
|
+
for (const key of Object.keys(commands) as Array<keyof T>) {
|
|
112
|
+
stableBag[key] = ((...args: unknown[]) => {
|
|
113
|
+
const handler = commandsRef.current[key] as CommandHandler | undefined;
|
|
114
|
+
return handler?.(...args);
|
|
115
|
+
}) as T[typeof key];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return stableBag as T;
|
|
119
|
+
}, []);
|
|
120
|
+
}
|