@beyondwork/docx-react-component 1.0.18 → 1.0.19
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 +374 -4
- package/src/api/session-state.ts +58 -0
- package/src/core/commands/formatting-commands.ts +1 -0
- package/src/core/commands/image-commands.ts +147 -0
- package/src/core/commands/index.ts +5 -1
- 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 +329 -0
- package/src/core/selection/mapping.ts +41 -0
- package/src/core/state/editor-state.ts +1 -1
- package/src/index.ts +30 -0
- package/src/io/docx-session.ts +260 -39
- package/src/io/export/serialize-main-document.ts +202 -5
- package/src/io/export/serialize-numbering.ts +28 -7
- package/src/io/normalize/normalize-text.ts +63 -25
- package/src/io/ooxml/numbering-sentinels.ts +44 -0
- package/src/io/ooxml/parse-footnotes.ts +212 -20
- package/src/io/ooxml/parse-headers-footers.ts +229 -25
- package/src/io/ooxml/parse-inline-media.ts +16 -0
- package/src/io/ooxml/parse-main-document.ts +411 -6
- package/src/io/ooxml/parse-numbering.ts +7 -0
- 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/model/canonical-document.ts +133 -3
- package/src/model/cds-1.0.0.ts +13 -0
- package/src/model/snapshot.ts +2 -1
- package/src/runtime/document-layout.ts +332 -0
- package/src/runtime/document-navigation.ts +564 -0
- package/src/runtime/document-runtime.ts +265 -35
- 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 +1 -0
- package/src/runtime/session-capabilities.ts +2 -0
- package/src/runtime/story-context.ts +164 -0
- package/src/runtime/story-targeting.ts +162 -0
- package/src/runtime/surface-projection.ts +239 -12
- package/src/runtime/table-schema.ts +87 -5
- package/src/runtime/view-state.ts +459 -0
- package/src/ui/WordReviewEditor.tsx +1902 -312
- package/src/ui/browser-export.ts +52 -0
- package/src/ui/headless/preserve-editor-selection.ts +5 -0
- 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-tailwind/chrome/tw-page-ruler.tsx +386 -0
- package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +125 -14
- package/src/ui-tailwind/editor-surface/perf-probe.ts +107 -0
- package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +45 -6
- package/src/ui-tailwind/editor-surface/pm-contextual-ui.ts +31 -0
- package/src/ui-tailwind/editor-surface/pm-position-map.ts +2 -2
- package/src/ui-tailwind/editor-surface/pm-schema.ts +47 -5
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +95 -22
- package/src/ui-tailwind/editor-surface/search-plugin.ts +19 -68
- package/src/ui-tailwind/editor-surface/tw-inline-token.tsx +11 -0
- package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +394 -77
- 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/review/tw-comment-sidebar.tsx +277 -147
- package/src/ui-tailwind/review/tw-review-rail.tsx +6 -6
- package/src/ui-tailwind/theme/editor-theme.css +123 -0
- package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +4 -0
- package/src/ui-tailwind/toolbar/tw-toolbar.tsx +291 -12
- package/src/ui-tailwind/tw-review-workspace.tsx +926 -27
- package/src/validation/compatibility-engine.ts +92 -20
- package/src/validation/diagnostics.ts +1 -0
- package/src/validation/docx-comment-proof.ts +487 -0
|
@@ -15,7 +15,17 @@ import { Plugin, PluginKey } from "prosemirror-state";
|
|
|
15
15
|
import type { EditorState, Transaction } from "prosemirror-state";
|
|
16
16
|
import { Decoration, DecorationSet } from "prosemirror-view";
|
|
17
17
|
|
|
18
|
-
import type {
|
|
18
|
+
import type {
|
|
19
|
+
SearchOptions as PublicSearchOptions,
|
|
20
|
+
} from "../../api/public-types";
|
|
21
|
+
import {
|
|
22
|
+
buildSearchPattern,
|
|
23
|
+
createSearchExcerpt,
|
|
24
|
+
findSearchMatches,
|
|
25
|
+
searchSecondaryStories,
|
|
26
|
+
type SecondaryStorySearchResult,
|
|
27
|
+
type SearchTextOptions,
|
|
28
|
+
} from "../../core/search/search-text.ts";
|
|
19
29
|
|
|
20
30
|
// ---------------------------------------------------------------------------
|
|
21
31
|
// Public types
|
|
@@ -28,8 +38,7 @@ export interface SearchResult {
|
|
|
28
38
|
index: number;
|
|
29
39
|
}
|
|
30
40
|
|
|
31
|
-
export interface SearchOptions extends PublicSearchOptions {
|
|
32
|
-
caseSensitive?: boolean;
|
|
41
|
+
export interface SearchOptions extends PublicSearchOptions, SearchTextOptions {
|
|
33
42
|
regex?: boolean;
|
|
34
43
|
highlightColor?: string;
|
|
35
44
|
}
|
|
@@ -133,71 +142,6 @@ export function performSearch(
|
|
|
133
142
|
return results;
|
|
134
143
|
}
|
|
135
144
|
|
|
136
|
-
export function findSearchMatches(
|
|
137
|
-
text: string,
|
|
138
|
-
query: string,
|
|
139
|
-
options: SearchOptions = {},
|
|
140
|
-
): SearchResult[] {
|
|
141
|
-
const pattern = buildSearchPattern(query, options);
|
|
142
|
-
if (!pattern) return [];
|
|
143
|
-
|
|
144
|
-
const results: SearchResult[] = [];
|
|
145
|
-
let match: RegExpExecArray | null;
|
|
146
|
-
pattern.lastIndex = 0;
|
|
147
|
-
while ((match = pattern.exec(text)) !== null) {
|
|
148
|
-
results.push({
|
|
149
|
-
from: match.index,
|
|
150
|
-
to: match.index + match[0].length,
|
|
151
|
-
text: match[0],
|
|
152
|
-
index: results.length,
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
if (match[0].length === 0) {
|
|
156
|
-
pattern.lastIndex += 1;
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
return results;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
export function createSearchExcerpt(
|
|
164
|
-
text: string,
|
|
165
|
-
from: number,
|
|
166
|
-
to: number,
|
|
167
|
-
radius = 24,
|
|
168
|
-
): string {
|
|
169
|
-
const safeFrom = Math.max(0, Math.min(from, text.length));
|
|
170
|
-
const safeTo = Math.max(safeFrom, Math.min(to, text.length));
|
|
171
|
-
const start = Math.max(0, safeFrom - radius);
|
|
172
|
-
const end = Math.min(text.length, safeTo + radius);
|
|
173
|
-
const prefix = start > 0 ? "…" : "";
|
|
174
|
-
const suffix = end < text.length ? "…" : "";
|
|
175
|
-
return `${prefix}${text.slice(start, end)}${suffix}`;
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
function buildSearchPattern(
|
|
179
|
-
query: string,
|
|
180
|
-
options: SearchOptions,
|
|
181
|
-
): RegExp | null {
|
|
182
|
-
if (!query) {
|
|
183
|
-
return null;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const caseSensitive = options.matchCase ?? options.caseSensitive ?? false;
|
|
187
|
-
const regex = options.regex ?? false;
|
|
188
|
-
const wholeWord = options.wholeWord ?? false;
|
|
189
|
-
|
|
190
|
-
try {
|
|
191
|
-
const source = regex
|
|
192
|
-
? query
|
|
193
|
-
: query.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
194
|
-
const wrapped = wholeWord ? `\\b${source}\\b` : source;
|
|
195
|
-
return new RegExp(wrapped, caseSensitive ? "g" : "gi");
|
|
196
|
-
} catch {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
|
|
201
145
|
// ---------------------------------------------------------------------------
|
|
202
146
|
// Clear helper (ProseMirror Command signature)
|
|
203
147
|
// ---------------------------------------------------------------------------
|
|
@@ -215,3 +159,10 @@ export function clearSearch(
|
|
|
215
159
|
);
|
|
216
160
|
return true;
|
|
217
161
|
}
|
|
162
|
+
|
|
163
|
+
export {
|
|
164
|
+
createSearchExcerpt,
|
|
165
|
+
findSearchMatches,
|
|
166
|
+
searchSecondaryStories,
|
|
167
|
+
};
|
|
168
|
+
export type { SecondaryStorySearchResult };
|
|
@@ -95,6 +95,17 @@ export function TwInlineToken(props: TwInlineTokenProps) {
|
|
|
95
95
|
|
|
96
96
|
// opaque_inline
|
|
97
97
|
if (segment.kind === "opaque_inline") {
|
|
98
|
+
if (segment.presentation === "quiet-marker") {
|
|
99
|
+
return (
|
|
100
|
+
<span
|
|
101
|
+
aria-label={segment.label}
|
|
102
|
+
title={segment.detail}
|
|
103
|
+
className="inline-block h-0 w-0 overflow-hidden align-baseline"
|
|
104
|
+
data-inline-presentation="quiet-marker"
|
|
105
|
+
/>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
98
109
|
return (
|
|
99
110
|
<button
|
|
100
111
|
type="button"
|