@beyondwork/docx-react-component 1.0.18 → 1.0.20
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/README.md +8 -2
- package/package.json +24 -34
- package/src/api/README.md +5 -1
- package/src/api/public-types.ts +710 -4
- package/src/api/session-state.ts +60 -0
- package/src/core/commands/formatting-commands.ts +2 -1
- package/src/core/commands/image-commands.ts +147 -0
- package/src/core/commands/index.ts +19 -3
- package/src/core/commands/list-commands.ts +231 -36
- package/src/core/commands/paragraph-layout-commands.ts +339 -0
- package/src/core/commands/section-layout-commands.ts +680 -0
- package/src/core/commands/style-commands.ts +262 -0
- package/src/core/search/search-text.ts +357 -0
- package/src/core/selection/mapping.ts +41 -0
- package/src/core/state/editor-state.ts +4 -1
- package/src/index.ts +51 -0
- package/src/io/docx-session.ts +623 -56
- 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 +285 -8
- package/src/io/export/serialize-numbering.ts +28 -7
- package/src/io/export/split-review-boundaries.ts +181 -19
- package/src/io/normalize/normalize-text.ts +144 -32
- package/src/io/ooxml/highlight-colors.ts +39 -0
- package/src/io/ooxml/numbering-sentinels.ts +44 -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 +452 -22
- package/src/io/ooxml/parse-headers-footers.ts +657 -29
- package/src/io/ooxml/parse-inline-media.ts +30 -0
- package/src/io/ooxml/parse-main-document.ts +807 -20
- package/src/io/ooxml/parse-numbering.ts +7 -0
- package/src/io/ooxml/parse-revisions.ts +317 -38
- package/src/io/ooxml/parse-settings.ts +184 -0
- package/src/io/ooxml/parse-shapes.ts +25 -0
- package/src/io/ooxml/parse-styles.ts +463 -0
- package/src/io/ooxml/parse-theme.ts +32 -0
- package/src/legal/bookmarks.ts +44 -0
- package/src/legal/cross-references.ts +59 -1
- package/src/model/canonical-document.ts +250 -4
- package/src/model/cds-1.0.0.ts +13 -0
- package/src/model/snapshot.ts +87 -2
- package/src/review/store/revision-store.ts +6 -0
- package/src/review/store/revision-types.ts +1 -0
- package/src/runtime/document-layout.ts +332 -0
- package/src/runtime/document-navigation.ts +603 -0
- package/src/runtime/document-runtime.ts +1754 -78
- package/src/runtime/document-search.ts +145 -0
- package/src/runtime/numbering-prefix.ts +47 -26
- package/src/runtime/page-layout-estimation.ts +212 -0
- package/src/runtime/read-only-diagnostics-runtime.ts +9 -0
- package/src/runtime/session-capabilities.ts +35 -3
- package/src/runtime/story-context.ts +164 -0
- package/src/runtime/story-targeting.ts +162 -0
- package/src/runtime/surface-projection.ts +324 -36
- package/src/runtime/table-schema.ts +89 -7
- package/src/runtime/view-state.ts +477 -0
- package/src/runtime/workflow-markup.ts +349 -0
- package/src/ui/WordReviewEditor.tsx +2469 -1344
- package/src/ui/browser-export.ts +52 -0
- package/src/ui/editor-command-bag.ts +120 -0
- package/src/ui/editor-runtime-boundary.ts +1422 -0
- package/src/ui/editor-shell-view.tsx +134 -0
- package/src/ui/editor-surface-controller.tsx +51 -0
- package/src/ui/headless/preserve-editor-selection.ts +5 -0
- package/src/ui/headless/revision-decoration-model.ts +4 -4
- package/src/ui/headless/selection-helpers.ts +20 -0
- package/src/ui/headless/selection-toolbar-model.ts +22 -0
- package/src/ui/headless/use-editor-keyboard.ts +6 -1
- package/src/ui/runtime-snapshot-selectors.ts +197 -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-page-ruler.tsx +386 -0
- package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +150 -14
- package/src/ui-tailwind/chrome/tw-table-context-toolbar.tsx +128 -0
- package/src/ui-tailwind/editor-surface/perf-probe.ts +179 -0
- package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +46 -7
- package/src/ui-tailwind/editor-surface/pm-contextual-ui.ts +31 -0
- package/src/ui-tailwind/editor-surface/pm-decorations.ts +35 -0
- package/src/ui-tailwind/editor-surface/pm-position-map.ts +3 -3
- package/src/ui-tailwind/editor-surface/pm-schema.ts +186 -13
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +191 -68
- package/src/ui-tailwind/editor-surface/search-plugin.ts +19 -68
- package/src/ui-tailwind/editor-surface/surface-build-keys.ts +51 -0
- package/src/ui-tailwind/editor-surface/tw-inline-token.tsx +11 -0
- package/src/ui-tailwind/editor-surface/tw-opaque-block.tsx +7 -1
- package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +528 -85
- package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +0 -1
- package/src/ui-tailwind/index.ts +2 -1
- package/src/ui-tailwind/page-chrome-model.ts +27 -0
- package/src/ui-tailwind/review/tw-comment-sidebar.tsx +277 -147
- package/src/ui-tailwind/review/tw-health-panel.tsx +31 -2
- package/src/ui-tailwind/review/tw-review-rail.tsx +8 -8
- package/src/ui-tailwind/review/tw-revision-sidebar.tsx +15 -15
- package/src/ui-tailwind/theme/editor-theme.css +127 -0
- package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +4 -0
- package/src/ui-tailwind/toolbar/tw-toolbar.tsx +829 -12
- package/src/ui-tailwind/tw-review-workspace.tsx +1238 -42
- package/src/validation/compatibility-engine.ts +119 -24
- package/src/validation/compatibility-report.ts +1 -0
- package/src/validation/diagnostics.ts +1 -0
- package/src/validation/docx-comment-proof.ts +707 -0
|
@@ -14,6 +14,8 @@ export interface ParsedInlineMedia {
|
|
|
14
14
|
contentType?: string;
|
|
15
15
|
filename: string;
|
|
16
16
|
altText?: string;
|
|
17
|
+
widthEmu?: number;
|
|
18
|
+
heightEmu?: number;
|
|
17
19
|
display?: "inline" | "floating";
|
|
18
20
|
floating?: {
|
|
19
21
|
horizontalPosition?: {
|
|
@@ -85,6 +87,11 @@ export function parseInlineMediaXml(
|
|
|
85
87
|
const altText = readAltText(docProperties);
|
|
86
88
|
const floating = anchor ? readFloatingProperties(anchor) : undefined;
|
|
87
89
|
|
|
90
|
+
// Read extent dimensions (wp:extent cx/cy in EMUs)
|
|
91
|
+
const extent = findDrawingExtent(container);
|
|
92
|
+
const widthEmu = extent ? readEmuAttribute(extent, "cx") : undefined;
|
|
93
|
+
const heightEmu = extent ? readEmuAttribute(extent, "cy") : undefined;
|
|
94
|
+
|
|
88
95
|
media.push({
|
|
89
96
|
type: "image",
|
|
90
97
|
mediaId: `media:${packagePartName.slice(1)}`,
|
|
@@ -93,6 +100,8 @@ export function parseInlineMediaXml(
|
|
|
93
100
|
...(mediaPart ? { contentType: mediaPart.contentType } : {}),
|
|
94
101
|
filename: packagePartName.slice(packagePartName.lastIndexOf("/") + 1),
|
|
95
102
|
...(altText ? { altText } : {}),
|
|
103
|
+
...(widthEmu !== undefined ? { widthEmu } : {}),
|
|
104
|
+
...(heightEmu !== undefined ? { heightEmu } : {}),
|
|
96
105
|
...(anchor ? { display: "floating" as const } : {}),
|
|
97
106
|
...(floating ? { floating } : {}),
|
|
98
107
|
});
|
|
@@ -101,6 +110,20 @@ export function parseInlineMediaXml(
|
|
|
101
110
|
return media;
|
|
102
111
|
}
|
|
103
112
|
|
|
113
|
+
function findDrawingExtent(node: XmlElementNode): XmlElementNode | undefined {
|
|
114
|
+
const wordProcessingExtent = findFirstDescendant(node, "extent");
|
|
115
|
+
if (wordProcessingExtent) {
|
|
116
|
+
return wordProcessingExtent;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const transform = findFirstDescendant(node, "xfrm");
|
|
120
|
+
if (!transform) {
|
|
121
|
+
return undefined;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return findFirstDescendant(transform, "ext");
|
|
125
|
+
}
|
|
126
|
+
|
|
104
127
|
function readFloatingProperties(
|
|
105
128
|
node: XmlElementNode,
|
|
106
129
|
): NonNullable<ParsedInlineMedia["floating"]> | undefined {
|
|
@@ -238,6 +261,13 @@ function readOptionalAttribute(node: XmlElementNode, name: string): string | und
|
|
|
238
261
|
?? node.attributes[name];
|
|
239
262
|
}
|
|
240
263
|
|
|
264
|
+
function readEmuAttribute(node: XmlElementNode, name: string): number | undefined {
|
|
265
|
+
const value = node.attributes[name] ?? node.attributes[`wp:${name}`];
|
|
266
|
+
if (value === undefined) return undefined;
|
|
267
|
+
const parsed = Number.parseInt(value, 10);
|
|
268
|
+
return Number.isFinite(parsed) && parsed >= 0 ? parsed : undefined;
|
|
269
|
+
}
|
|
270
|
+
|
|
241
271
|
function readBooleanAttribute(node: XmlElementNode, name: string): boolean | undefined {
|
|
242
272
|
const value = readOptionalAttribute(node, name);
|
|
243
273
|
if (value === undefined) {
|