@beyondwork/docx-react-component 1.0.28 → 1.0.29
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/dist/canonical-document-BLEbzL2J.d.cts +844 -0
- package/dist/canonical-document-BLEbzL2J.d.ts +844 -0
- package/dist/chunk-2FJS5GZM.js +763 -0
- package/dist/chunk-2FJS5GZM.js.map +1 -0
- package/{src/core/commands/section-layout-commands.ts → dist/chunk-2OQBZS3F.js} +106 -340
- package/dist/chunk-2OQBZS3F.js.map +1 -0
- package/dist/chunk-2S7W4KFO.js +127 -0
- package/dist/chunk-2S7W4KFO.js.map +1 -0
- package/dist/chunk-2TG72QSW.js +3874 -0
- package/dist/chunk-2TG72QSW.js.map +1 -0
- package/{src/core/commands/table-structure-commands.ts → dist/chunk-36QNIZBO.js} +126 -315
- package/dist/chunk-36QNIZBO.js.map +1 -0
- package/dist/chunk-4AQOYAW4.js +3069 -0
- package/dist/chunk-4AQOYAW4.js.map +1 -0
- package/dist/chunk-4D5EWJ3P.js +77 -0
- package/dist/chunk-4D5EWJ3P.js.map +1 -0
- package/dist/chunk-5FN54NDH.js +2257 -0
- package/dist/chunk-5FN54NDH.js.map +1 -0
- package/dist/chunk-BOYGQYRQ.js +7306 -0
- package/dist/chunk-BOYGQYRQ.js.map +1 -0
- package/dist/chunk-CN3XMECL.js +212 -0
- package/dist/chunk-CN3XMECL.js.map +1 -0
- package/dist/chunk-EBI3BX6U.js +164 -0
- package/dist/chunk-EBI3BX6U.js.map +1 -0
- package/dist/chunk-EILUG3VB.js +1275 -0
- package/dist/chunk-EILUG3VB.js.map +1 -0
- package/dist/chunk-FUDY333O.js +70 -0
- package/dist/chunk-FUDY333O.js.map +1 -0
- package/dist/chunk-GBVOWFIK.js +1237 -0
- package/dist/chunk-GBVOWFIK.js.map +1 -0
- package/dist/chunk-H4TQ3H3Y.js +262 -0
- package/dist/chunk-H4TQ3H3Y.js.map +1 -0
- package/{src/core/commands/style-commands.ts → dist/chunk-JGB3IXZO.js} +40 -113
- package/dist/chunk-JGB3IXZO.js.map +1 -0
- package/dist/chunk-KD2QRQPY.js +4342 -0
- package/dist/chunk-KD2QRQPY.js.map +1 -0
- package/dist/chunk-KLMXQVYK.js +369 -0
- package/dist/chunk-KLMXQVYK.js.map +1 -0
- package/dist/chunk-KZUG5KFQ.js +214 -0
- package/dist/chunk-KZUG5KFQ.js.map +1 -0
- package/{src/core/state/text-transaction.ts → dist/chunk-QDAQ4CJU.js} +79 -236
- package/dist/chunk-QDAQ4CJU.js.map +1 -0
- package/{src/legal/bookmarks.ts → dist/chunk-RMH72RZI.js} +44 -130
- package/dist/chunk-RMH72RZI.js.map +1 -0
- package/dist/chunk-SWKWQZXM.js +117 -0
- package/dist/chunk-SWKWQZXM.js.map +1 -0
- package/{src/core/commands/formatting-commands.ts → dist/chunk-TJBP2K4T.js} +196 -536
- package/dist/chunk-TJBP2K4T.js.map +1 -0
- package/dist/chunk-TLCEAQDQ.js +542 -0
- package/dist/chunk-TLCEAQDQ.js.map +1 -0
- package/{src/core/commands/text-commands.ts → dist/chunk-UZXBISGO.js} +86 -142
- package/dist/chunk-UZXBISGO.js.map +1 -0
- package/dist/chunk-WGBAKP3Q.js +3220 -0
- package/dist/chunk-WGBAKP3Q.js.map +1 -0
- package/dist/compare/index.cjs +5475 -0
- package/dist/compare/index.cjs.map +1 -0
- package/dist/compare/index.d.cts +114 -0
- package/dist/compare/index.d.ts +114 -0
- package/dist/compare/index.js +731 -0
- package/dist/compare/index.js.map +1 -0
- package/dist/core/commands/formatting-commands.cjs +828 -0
- package/dist/core/commands/formatting-commands.cjs.map +1 -0
- package/dist/core/commands/formatting-commands.d.cts +63 -0
- package/dist/core/commands/formatting-commands.d.ts +63 -0
- package/dist/core/commands/formatting-commands.js +37 -0
- package/dist/core/commands/formatting-commands.js.map +1 -0
- package/dist/core/commands/image-commands.cjs +2023 -0
- package/dist/core/commands/image-commands.cjs.map +1 -0
- package/dist/core/commands/image-commands.d.cts +58 -0
- package/dist/core/commands/image-commands.d.ts +58 -0
- package/dist/core/commands/image-commands.js +18 -0
- package/dist/core/commands/image-commands.js.map +1 -0
- package/dist/core/commands/section-layout-commands.cjs +477 -0
- package/dist/core/commands/section-layout-commands.cjs.map +1 -0
- package/dist/core/commands/section-layout-commands.d.cts +62 -0
- package/dist/core/commands/section-layout-commands.d.ts +62 -0
- package/dist/core/commands/section-layout-commands.js +21 -0
- package/dist/core/commands/section-layout-commands.js.map +1 -0
- package/dist/core/commands/style-commands.cjs +214 -0
- package/dist/core/commands/style-commands.cjs.map +1 -0
- package/dist/core/commands/style-commands.d.cts +13 -0
- package/dist/core/commands/style-commands.d.ts +13 -0
- package/dist/core/commands/style-commands.js +9 -0
- package/dist/core/commands/style-commands.js.map +1 -0
- package/dist/core/commands/table-structure-commands.cjs +1883 -0
- package/dist/core/commands/table-structure-commands.cjs.map +1 -0
- package/dist/core/commands/table-structure-commands.d.cts +59 -0
- package/dist/core/commands/table-structure-commands.d.ts +59 -0
- package/dist/core/commands/table-structure-commands.js +12 -0
- package/dist/core/commands/table-structure-commands.js.map +1 -0
- package/dist/core/commands/text-commands.cjs +2391 -0
- package/dist/core/commands/text-commands.cjs.map +1 -0
- package/dist/core/commands/text-commands.d.cts +24 -0
- package/dist/core/commands/text-commands.d.ts +24 -0
- package/dist/core/commands/text-commands.js +28 -0
- package/dist/core/commands/text-commands.js.map +1 -0
- package/dist/core/selection/mapping.cjs +200 -0
- package/dist/core/selection/mapping.cjs.map +1 -0
- package/dist/core/selection/mapping.d.cts +2 -0
- package/dist/core/selection/mapping.d.ts +2 -0
- package/dist/core/selection/mapping.js +31 -0
- package/dist/core/selection/mapping.js.map +1 -0
- package/dist/core/state/editor-state.cjs +2278 -0
- package/dist/core/state/editor-state.cjs.map +1 -0
- package/dist/core/state/editor-state.d.cts +2 -0
- package/dist/core/state/editor-state.d.ts +2 -0
- package/dist/core/state/editor-state.js +26 -0
- package/dist/core/state/editor-state.js.map +1 -0
- package/dist/index.cjs +38553 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +7856 -0
- package/dist/index.js.map +1 -0
- package/dist/io/docx-session.cjs +16236 -0
- package/dist/io/docx-session.cjs.map +1 -0
- package/dist/io/docx-session.d.cts +21 -0
- package/dist/io/docx-session.d.ts +21 -0
- package/dist/io/docx-session.js +18 -0
- package/dist/io/docx-session.js.map +1 -0
- package/dist/legal/index.cjs +3900 -0
- package/dist/legal/index.cjs.map +1 -0
- package/dist/legal/index.d.cts +86 -0
- package/dist/legal/index.d.ts +86 -0
- package/dist/legal/index.js +616 -0
- package/dist/legal/index.js.map +1 -0
- package/dist/public-types-7ZL_94cz.d.ts +1573 -0
- package/dist/public-types-CeMaDueh.d.cts +1573 -0
- package/dist/public-types.cjs +19 -0
- package/dist/public-types.cjs.map +1 -0
- package/dist/public-types.d.cts +2 -0
- package/dist/public-types.d.ts +2 -0
- package/dist/public-types.js +1 -0
- package/dist/public-types.js.map +1 -0
- package/dist/runtime/document-runtime.cjs +11140 -0
- package/dist/runtime/document-runtime.cjs.map +1 -0
- package/dist/runtime/document-runtime.d.cts +231 -0
- package/dist/runtime/document-runtime.d.ts +231 -0
- package/dist/runtime/document-runtime.js +21 -0
- package/dist/runtime/document-runtime.js.map +1 -0
- package/dist/structural-helpers-CilgOVhh.d.cts +10 -0
- package/dist/structural-helpers-q0Gd-eBN.d.ts +10 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.cjs +313 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.cjs.map +1 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.d.cts +67 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.d.ts +67 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.js +23 -0
- package/dist/ui-tailwind/editor-surface/search-plugin.js.map +1 -0
- package/dist/ui-tailwind/index.cjs +4833 -0
- package/dist/ui-tailwind/index.cjs.map +1 -0
- package/dist/ui-tailwind/index.d.cts +617 -0
- package/dist/ui-tailwind/index.d.ts +617 -0
- package/dist/ui-tailwind/index.js +575 -0
- package/dist/ui-tailwind/index.js.map +1 -0
- package/package.json +61 -41
- package/src/README.md +0 -85
- package/src/api/README.md +0 -26
- package/src/api/public-types.ts +0 -1421
- package/src/api/session-state.ts +0 -60
- package/src/compare/diff-engine.ts +0 -623
- package/src/compare/export-redlines.ts +0 -280
- package/src/compare/index.ts +0 -25
- package/src/compare/snapshot.ts +0 -97
- package/src/component-inventory.md +0 -99
- package/src/core/README.md +0 -10
- package/src/core/commands/README.md +0 -3
- package/src/core/commands/image-commands.ts +0 -373
- package/src/core/commands/index.ts +0 -1757
- package/src/core/commands/list-commands.ts +0 -565
- package/src/core/commands/paragraph-layout-commands.ts +0 -339
- package/src/core/commands/review-commands.ts +0 -108
- package/src/core/commands/structural-helpers.ts +0 -309
- package/src/core/schema/README.md +0 -3
- package/src/core/schema/text-schema.ts +0 -516
- package/src/core/search/search-text.ts +0 -357
- package/src/core/selection/README.md +0 -3
- package/src/core/selection/mapping.ts +0 -289
- package/src/core/selection/review-anchors.ts +0 -183
- package/src/core/state/README.md +0 -3
- package/src/core/state/editor-state.ts +0 -892
- package/src/formats/xlsx/io/parse-shared-strings.ts +0 -41
- package/src/formats/xlsx/io/parse-sheet.ts +0 -459
- package/src/formats/xlsx/io/parse-styles.ts +0 -59
- package/src/formats/xlsx/io/parse-workbook.ts +0 -75
- package/src/formats/xlsx/io/serialize-shared-strings.ts +0 -72
- package/src/formats/xlsx/io/serialize-sheet.ts +0 -333
- package/src/formats/xlsx/io/serialize-styles.ts +0 -98
- package/src/formats/xlsx/io/serialize-workbook.ts +0 -429
- package/src/formats/xlsx/io/xlsx-session.ts +0 -314
- package/src/formats/xlsx/model/cell.ts +0 -189
- package/src/formats/xlsx/model/sheet.ts +0 -326
- package/src/formats/xlsx/model/styles.ts +0 -118
- package/src/formats/xlsx/model/workbook.ts +0 -453
- package/src/formats/xlsx/runtime/cell-commands.ts +0 -567
- package/src/formats/xlsx/runtime/sheet-commands.ts +0 -206
- package/src/formats/xlsx/runtime/workbook-runtime.ts +0 -177
- package/src/formats/xlsx/runtime/workbook-transaction.ts +0 -822
- package/src/index.ts +0 -101
- package/src/io/README.md +0 -10
- package/src/io/docx-session.ts +0 -2882
- package/src/io/export/README.md +0 -3
- package/src/io/export/export-session.ts +0 -220
- package/src/io/export/minimal-docx.ts +0 -115
- package/src/io/export/reattach-preserved-parts.ts +0 -54
- package/src/io/export/serialize-comments.ts +0 -947
- package/src/io/export/serialize-footnotes.ts +0 -399
- package/src/io/export/serialize-headers-footers.ts +0 -372
- package/src/io/export/serialize-main-document.ts +0 -1376
- package/src/io/export/serialize-numbering.ts +0 -118
- package/src/io/export/serialize-revisions.ts +0 -389
- package/src/io/export/serialize-runtime-revisions.ts +0 -269
- package/src/io/export/serialize-tables.ts +0 -174
- package/src/io/export/split-review-boundaries.ts +0 -356
- package/src/io/normalize/README.md +0 -3
- package/src/io/normalize/normalize-text.ts +0 -639
- package/src/io/ooxml/README.md +0 -3
- package/src/io/ooxml/highlight-colors.ts +0 -39
- package/src/io/ooxml/numbering-sentinels.ts +0 -44
- package/src/io/ooxml/parse-comments.ts +0 -846
- package/src/io/ooxml/parse-complex-content.ts +0 -287
- package/src/io/ooxml/parse-fields.ts +0 -834
- package/src/io/ooxml/parse-footnotes.ts +0 -896
- package/src/io/ooxml/parse-headers-footers.ts +0 -1169
- package/src/io/ooxml/parse-inline-media.ts +0 -461
- package/src/io/ooxml/parse-main-document.ts +0 -2877
- package/src/io/ooxml/parse-numbering.ts +0 -432
- package/src/io/ooxml/parse-revisions.ts +0 -931
- package/src/io/ooxml/parse-settings.ts +0 -184
- package/src/io/ooxml/parse-shapes.ts +0 -296
- package/src/io/ooxml/parse-styles.ts +0 -463
- package/src/io/ooxml/parse-tables.ts +0 -618
- package/src/io/ooxml/parse-theme.ts +0 -346
- package/src/io/ooxml/part-manifest.ts +0 -136
- package/src/io/ooxml/revision-boundaries.ts +0 -351
- package/src/io/opc/README.md +0 -3
- package/src/io/opc/corrupt-package.ts +0 -166
- package/src/io/opc/docx-package.ts +0 -74
- package/src/io/opc/package-reader.ts +0 -325
- package/src/io/opc/package-writer.ts +0 -273
- package/src/io/source-package-provenance.ts +0 -241
- package/src/legal/cross-references.ts +0 -414
- package/src/legal/defined-terms.ts +0 -203
- package/src/legal/index.ts +0 -32
- package/src/legal/signature-blocks.ts +0 -259
- package/src/model/README.md +0 -3
- package/src/model/canonical-document.ts +0 -2632
- package/src/model/cds-1.0.0.ts +0 -212
- package/src/model/snapshot.ts +0 -649
- package/src/preservation/README.md +0 -3
- package/src/preservation/markup-compatibility.ts +0 -48
- package/src/preservation/opaque-fragment-store.ts +0 -89
- package/src/preservation/opaque-region.ts +0 -233
- package/src/preservation/package-preservation.ts +0 -113
- package/src/preservation/preserved-part-manifest.ts +0 -56
- package/src/preservation/relationship-retention.ts +0 -57
- package/src/preservation/store.ts +0 -185
- package/src/review/README.md +0 -16
- package/src/review/store/README.md +0 -3
- package/src/review/store/comment-anchors.ts +0 -70
- package/src/review/store/comment-remapping.ts +0 -154
- package/src/review/store/comment-store.ts +0 -331
- package/src/review/store/comment-thread.ts +0 -109
- package/src/review/store/revision-actions.ts +0 -394
- package/src/review/store/revision-store.ts +0 -312
- package/src/review/store/revision-types.ts +0 -171
- package/src/review/store/runtime-comment-store.ts +0 -43
- package/src/runtime/README.md +0 -3
- package/src/runtime/ai-action-policy.ts +0 -764
- package/src/runtime/document-layout.ts +0 -332
- package/src/runtime/document-navigation.ts +0 -603
- package/src/runtime/document-runtime.ts +0 -3159
- package/src/runtime/document-search.ts +0 -145
- package/src/runtime/numbering-prefix.ts +0 -216
- package/src/runtime/page-layout-estimation.ts +0 -212
- package/src/runtime/read-only-diagnostics-runtime.ts +0 -241
- package/src/runtime/review-runtime.ts +0 -44
- package/src/runtime/revision-runtime.ts +0 -107
- package/src/runtime/session-capabilities.ts +0 -192
- package/src/runtime/story-context.ts +0 -164
- package/src/runtime/story-targeting.ts +0 -162
- package/src/runtime/surface-projection.ts +0 -1357
- package/src/runtime/table-commands.ts +0 -173
- package/src/runtime/table-schema.ts +0 -309
- package/src/runtime/view-state.ts +0 -477
- package/src/runtime/virtualized-rendering.ts +0 -258
- package/src/runtime/workflow-markup.ts +0 -353
- package/src/ui/README.md +0 -30
- package/src/ui/WordReviewEditor.tsx +0 -4086
- package/src/ui/browser-export.ts +0 -52
- package/src/ui/comments/README.md +0 -3
- package/src/ui/compatibility/README.md +0 -3
- package/src/ui/editor-command-bag.ts +0 -120
- package/src/ui/editor-runtime-boundary.ts +0 -1457
- package/src/ui/editor-shell-view.tsx +0 -142
- package/src/ui/editor-surface/README.md +0 -3
- package/src/ui/editor-surface-controller.tsx +0 -61
- package/src/ui/headless/comment-decoration-model.ts +0 -124
- package/src/ui/headless/preserve-editor-selection.ts +0 -5
- package/src/ui/headless/revision-decoration-model.ts +0 -128
- package/src/ui/headless/selection-helpers.ts +0 -54
- package/src/ui/headless/selection-toolbar-model.ts +0 -34
- package/src/ui/headless/use-editor-keyboard.ts +0 -103
- package/src/ui/review/README.md +0 -3
- package/src/ui/runtime-snapshot-selectors.ts +0 -197
- package/src/ui/shared/revision-filters.ts +0 -31
- package/src/ui/status/README.md +0 -3
- package/src/ui/theme/README.md +0 -3
- package/src/ui/toolbar/README.md +0 -3
- package/src/ui/workflow-surface-blocked-rails.ts +0 -94
- package/src/ui-tailwind/chrome/tw-alert-banner.tsx +0 -64
- package/src/ui-tailwind/chrome/tw-image-context-toolbar.tsx +0 -129
- package/src/ui-tailwind/chrome/tw-layout-panel.tsx +0 -114
- package/src/ui-tailwind/chrome/tw-object-context-toolbar.tsx +0 -34
- package/src/ui-tailwind/chrome/tw-page-ruler.tsx +0 -386
- package/src/ui-tailwind/chrome/tw-selection-toolbar.tsx +0 -186
- package/src/ui-tailwind/chrome/tw-suggestion-card.tsx +0 -139
- package/src/ui-tailwind/chrome/tw-table-context-toolbar.tsx +0 -128
- package/src/ui-tailwind/chrome/tw-unsaved-modal.tsx +0 -58
- package/src/ui-tailwind/chrome/use-before-unload.ts +0 -20
- package/src/ui-tailwind/editor-surface/perf-probe.ts +0 -179
- package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +0 -184
- package/src/ui-tailwind/editor-surface/pm-contextual-ui.ts +0 -31
- package/src/ui-tailwind/editor-surface/pm-decorations.ts +0 -427
- package/src/ui-tailwind/editor-surface/pm-position-map.ts +0 -123
- package/src/ui-tailwind/editor-surface/pm-schema.ts +0 -876
- package/src/ui-tailwind/editor-surface/pm-state-from-snapshot.ts +0 -504
- package/src/ui-tailwind/editor-surface/search-plugin.ts +0 -168
- package/src/ui-tailwind/editor-surface/surface-build-keys.ts +0 -61
- package/src/ui-tailwind/editor-surface/tw-caret.tsx +0 -12
- package/src/ui-tailwind/editor-surface/tw-editor-surface.tsx +0 -150
- package/src/ui-tailwind/editor-surface/tw-inline-token.tsx +0 -129
- package/src/ui-tailwind/editor-surface/tw-opaque-block.tsx +0 -58
- package/src/ui-tailwind/editor-surface/tw-paragraph-block.tsx +0 -151
- package/src/ui-tailwind/editor-surface/tw-prosemirror-surface.tsx +0 -944
- package/src/ui-tailwind/editor-surface/tw-segment-view.tsx +0 -111
- package/src/ui-tailwind/editor-surface/tw-table-node-view.tsx +0 -436
- package/src/ui-tailwind/index.ts +0 -62
- package/src/ui-tailwind/page-chrome-model.ts +0 -27
- package/src/ui-tailwind/review/tw-comment-sidebar.tsx +0 -406
- package/src/ui-tailwind/review/tw-health-panel.tsx +0 -149
- package/src/ui-tailwind/review/tw-review-rail.tsx +0 -120
- package/src/ui-tailwind/review/tw-revision-sidebar.tsx +0 -164
- package/src/ui-tailwind/status/tw-status-bar.tsx +0 -61
- package/src/ui-tailwind/toolbar/tw-toolbar-icon-button.tsx +0 -52
- package/src/ui-tailwind/toolbar/tw-toolbar.tsx +0 -1064
- package/src/ui-tailwind/tw-review-workspace.tsx +0 -1417
- package/src/validation/README.md +0 -3
- package/src/validation/compatibility-engine.ts +0 -634
- package/src/validation/compatibility-report.ts +0 -161
- package/src/validation/diagnostics.ts +0 -204
- package/src/validation/docx-comment-proof.ts +0 -707
- package/src/validation/import-diagnostics.ts +0 -128
- package/src/validation/low-priority-word-surfaces.ts +0 -373
- /package/{src → dist}/ui-tailwind/theme/editor-theme.css +0 -0
|
@@ -1,1417 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
type CSSProperties,
|
|
3
|
-
type FocusEventHandler,
|
|
4
|
-
type ReactNode,
|
|
5
|
-
type Ref,
|
|
6
|
-
useCallback,
|
|
7
|
-
useEffect,
|
|
8
|
-
useMemo,
|
|
9
|
-
useRef,
|
|
10
|
-
useState,
|
|
11
|
-
} from "react";
|
|
12
|
-
|
|
13
|
-
import * as Tooltip from "@radix-ui/react-tooltip";
|
|
14
|
-
import { ChevronLeft, ChevronRight, List } from "lucide-react";
|
|
15
|
-
|
|
16
|
-
import type {
|
|
17
|
-
CommentSidebarThreadSnapshot,
|
|
18
|
-
DocumentNavigationSnapshot,
|
|
19
|
-
EditorViewStateSnapshot,
|
|
20
|
-
FormattingStateSnapshot,
|
|
21
|
-
FormattingAlignment,
|
|
22
|
-
HeaderFooterLinkPatch,
|
|
23
|
-
InteractionGuardSnapshot,
|
|
24
|
-
InsertImageOptions,
|
|
25
|
-
RuntimeRenderSnapshot,
|
|
26
|
-
SectionPageNumberingPatch,
|
|
27
|
-
SectionBreakType,
|
|
28
|
-
StyleCatalogSnapshot,
|
|
29
|
-
SurfaceBlockSnapshot,
|
|
30
|
-
TrackedChangeEntrySnapshot,
|
|
31
|
-
WordReviewEditorChromeVisibility,
|
|
32
|
-
WorkflowScopeSnapshot,
|
|
33
|
-
WorkspaceMode,
|
|
34
|
-
ZoomLevel,
|
|
35
|
-
} from "../api/public-types";
|
|
36
|
-
import { findPageForOffset } from "../runtime/document-navigation.ts";
|
|
37
|
-
import {
|
|
38
|
-
DEFAULT_PAGE_ESTIMATE_PX_PER_TWIP,
|
|
39
|
-
estimateBlockHeight,
|
|
40
|
-
estimateParagraphLineCount,
|
|
41
|
-
estimateParagraphLineHeight,
|
|
42
|
-
getUsableColumnWidth,
|
|
43
|
-
} from "../runtime/page-layout-estimation.ts";
|
|
44
|
-
import {
|
|
45
|
-
incrementInvalidationCounter,
|
|
46
|
-
recordPerfSample,
|
|
47
|
-
} from "./editor-surface/perf-probe.ts";
|
|
48
|
-
import { computeLineMarkersIfEnabled } from "./page-chrome-model.ts";
|
|
49
|
-
import type { SessionCapabilities } from "../runtime/session-capabilities";
|
|
50
|
-
import type {
|
|
51
|
-
SelectionToolbarAnchor,
|
|
52
|
-
SelectionToolbarModel,
|
|
53
|
-
SuggestionCardModel,
|
|
54
|
-
} from "../ui/headless/selection-toolbar-model";
|
|
55
|
-
import type { MarkupDisplay } from "../ui/headless/comment-decoration-model";
|
|
56
|
-
import type { EditorCommandBag } from "../ui/editor-command-bag.ts";
|
|
57
|
-
import { preserveEditorSelectionMouseDown } from "../ui/headless/preserve-editor-selection";
|
|
58
|
-
import { TwAlertBanner } from "./chrome/tw-alert-banner";
|
|
59
|
-
import { TwImageContextToolbar, type ActiveImageContext } from "./chrome/tw-image-context-toolbar";
|
|
60
|
-
import { TwLayoutPanel } from "./chrome/tw-layout-panel";
|
|
61
|
-
import { TwObjectContextToolbar, type ActiveObjectContext } from "./chrome/tw-object-context-toolbar";
|
|
62
|
-
import { TwPageRuler } from "./chrome/tw-page-ruler";
|
|
63
|
-
import { TwSelectionToolbar } from "./chrome/tw-selection-toolbar";
|
|
64
|
-
import { TwSuggestionCard } from "./chrome/tw-suggestion-card";
|
|
65
|
-
import { TwTableContextToolbar } from "./chrome/tw-table-context-toolbar";
|
|
66
|
-
import { TwReviewRail, type ReviewRailTab } from "./review/tw-review-rail";
|
|
67
|
-
import { TwStatusBar } from "./status/tw-status-bar";
|
|
68
|
-
import { TwToolbar, type ToolbarInteractionPolicy } from "./toolbar/tw-toolbar";
|
|
69
|
-
|
|
70
|
-
export type ReviewWorkspaceChromeVisibility = WordReviewEditorChromeVisibility;
|
|
71
|
-
|
|
72
|
-
export interface TwReviewWorkspaceProps {
|
|
73
|
-
snapshot: RuntimeRenderSnapshot;
|
|
74
|
-
viewState: EditorViewStateSnapshot;
|
|
75
|
-
markupDisplay: MarkupDisplay;
|
|
76
|
-
currentUserId?: string;
|
|
77
|
-
capabilities?: SessionCapabilities;
|
|
78
|
-
reviewMode?: "editing" | "review";
|
|
79
|
-
document: ReactNode;
|
|
80
|
-
workspaceMode: WorkspaceMode;
|
|
81
|
-
zoomLevel?: ZoomLevel;
|
|
82
|
-
formattingState?: FormattingStateSnapshot;
|
|
83
|
-
styleCatalog?: StyleCatalogSnapshot;
|
|
84
|
-
activeRailTab: ReviewRailTab;
|
|
85
|
-
activeCommentId?: string;
|
|
86
|
-
activeRevisionId?: string;
|
|
87
|
-
showTrackedChanges: boolean;
|
|
88
|
-
workflowScopeSnapshot?: WorkflowScopeSnapshot | null;
|
|
89
|
-
interactionGuardSnapshot?: InteractionGuardSnapshot;
|
|
90
|
-
commands: EditorCommandBag;
|
|
91
|
-
selectionToolbar?: SelectionToolbarModel | null;
|
|
92
|
-
suggestionCard?: SuggestionCardModel | null;
|
|
93
|
-
selectionToolbarAnchor?: SelectionToolbarAnchor | null;
|
|
94
|
-
documentNavigation?: DocumentNavigationSnapshot;
|
|
95
|
-
onWorkspaceModeChange?: (value: WorkspaceMode) => void;
|
|
96
|
-
onZoomChange?: (level: ZoomLevel) => void;
|
|
97
|
-
onActiveRailTabChange?: (value: ReviewRailTab) => void;
|
|
98
|
-
onShowTrackedChangesChange?: (show: boolean) => void;
|
|
99
|
-
onUndo?: () => void;
|
|
100
|
-
onRedo?: () => void;
|
|
101
|
-
onSetParagraphStyle?: (styleId: string) => void;
|
|
102
|
-
onToggleBold?: () => void;
|
|
103
|
-
onToggleItalic?: () => void;
|
|
104
|
-
onToggleUnderline?: () => void;
|
|
105
|
-
onSetSelectionTextColor?: (color: string) => void;
|
|
106
|
-
onSetSelectionHighlightColor?: (color: string | null) => void;
|
|
107
|
-
onToggleStrikethrough?: () => void;
|
|
108
|
-
onToggleSuperscript?: () => void;
|
|
109
|
-
onToggleSubscript?: () => void;
|
|
110
|
-
onSetFontFamily?: (fontFamily: string) => void;
|
|
111
|
-
onSetFontSize?: (fontSize: number) => void;
|
|
112
|
-
onSetTextColor?: (color: string) => void;
|
|
113
|
-
onSetHighlightColor?: (color: string | null) => void;
|
|
114
|
-
onSetAlignment?: (alignment: FormattingAlignment) => void;
|
|
115
|
-
onOutdent?: () => void;
|
|
116
|
-
onIndent?: () => void;
|
|
117
|
-
onAddComment?: () => void;
|
|
118
|
-
onInsertPageBreak?: () => void;
|
|
119
|
-
onInsertTable?: () => void;
|
|
120
|
-
onInsertSectionBreak?: (type: SectionBreakType) => void;
|
|
121
|
-
onInsertImage?: (options: InsertImageOptions) => void;
|
|
122
|
-
onSetTableStyle?: (styleId: string) => void;
|
|
123
|
-
onAddRowBefore?: () => void;
|
|
124
|
-
onAddRowAfter?: () => void;
|
|
125
|
-
onAddColumnBefore?: () => void;
|
|
126
|
-
onAddColumnAfter?: () => void;
|
|
127
|
-
onDeleteRow?: () => void;
|
|
128
|
-
onDeleteColumn?: () => void;
|
|
129
|
-
onDeleteTable?: () => void;
|
|
130
|
-
onMergeCells?: () => void;
|
|
131
|
-
onSplitCell?: () => void;
|
|
132
|
-
onSetCellBackground?: (color: string) => void;
|
|
133
|
-
activeImageContext?: ActiveImageContext | null;
|
|
134
|
-
activeObjectContext?: ActiveObjectContext | null;
|
|
135
|
-
onSetImageLayout?: (
|
|
136
|
-
mediaId: string,
|
|
137
|
-
dimensions: { widthEmu: number; heightEmu: number },
|
|
138
|
-
) => void;
|
|
139
|
-
onSetImageFrame?: (
|
|
140
|
-
mediaId: string,
|
|
141
|
-
offsets: { horizontalOffsetEmu?: number; verticalOffsetEmu?: number },
|
|
142
|
-
) => void;
|
|
143
|
-
onDeleteSectionBreak?: (sectionIndex: number) => void;
|
|
144
|
-
onUpdateSectionLayout?: (
|
|
145
|
-
sectionIndex: number,
|
|
146
|
-
patch: {
|
|
147
|
-
pageSize?: { width?: number; height?: number; orientation?: "portrait" | "landscape" };
|
|
148
|
-
pageMargins?: {
|
|
149
|
-
top?: number;
|
|
150
|
-
right?: number;
|
|
151
|
-
bottom?: number;
|
|
152
|
-
left?: number;
|
|
153
|
-
header?: number;
|
|
154
|
-
footer?: number;
|
|
155
|
-
gutter?: number;
|
|
156
|
-
};
|
|
157
|
-
columns?: {
|
|
158
|
-
count?: number;
|
|
159
|
-
space?: number;
|
|
160
|
-
equalWidth?: boolean;
|
|
161
|
-
columns?: Array<{ width: number; space?: number }>;
|
|
162
|
-
separator?: boolean;
|
|
163
|
-
};
|
|
164
|
-
titlePage?: boolean;
|
|
165
|
-
sectionType?: SectionBreakType;
|
|
166
|
-
},
|
|
167
|
-
) => void;
|
|
168
|
-
onSetSectionPageNumbering?: (
|
|
169
|
-
sectionIndex: number,
|
|
170
|
-
patch: SectionPageNumberingPatch | null,
|
|
171
|
-
) => void;
|
|
172
|
-
onSetHeaderFooterLink?: (
|
|
173
|
-
sectionIndex: number,
|
|
174
|
-
patch: HeaderFooterLinkPatch,
|
|
175
|
-
) => void;
|
|
176
|
-
onAddCommentFromSelection?: () => void;
|
|
177
|
-
onExport?: () => void;
|
|
178
|
-
onDismissSelectionToolbar?: () => void;
|
|
179
|
-
onAcceptSuggestion?: () => void;
|
|
180
|
-
onRejectSuggestion?: () => void;
|
|
181
|
-
onEditSuggestion?: () => void;
|
|
182
|
-
onAddCommentFromSuggestion?: () => void;
|
|
183
|
-
onSelectionToolbarFocusCapture?: FocusEventHandler<HTMLDivElement>;
|
|
184
|
-
onSelectionToolbarBlurCapture?: FocusEventHandler<HTMLDivElement>;
|
|
185
|
-
selectionToolbarRef?: Ref<HTMLDivElement>;
|
|
186
|
-
onOpenComment?: (thread: CommentSidebarThreadSnapshot) => void;
|
|
187
|
-
onResolveComment?: (commentId: string) => void;
|
|
188
|
-
onReopenComment?: (commentId: string) => void;
|
|
189
|
-
onAddReply?: (commentId: string, body: string) => void;
|
|
190
|
-
onEditBody?: (commentId: string, body: string) => void;
|
|
191
|
-
onOpenRevision?: (revision: TrackedChangeEntrySnapshot) => void;
|
|
192
|
-
onAcceptRevision?: (revisionId: string) => void;
|
|
193
|
-
onRejectRevision?: (revisionId: string) => void;
|
|
194
|
-
onAcceptAllChanges?: () => void;
|
|
195
|
-
onRejectAllChanges?: () => void;
|
|
196
|
-
onCloseStory?: () => void;
|
|
197
|
-
onOpenHeaderStory?: () => void;
|
|
198
|
-
onOpenFooterStory?: () => void;
|
|
199
|
-
onSetParagraphIndentation?: (indentation: {
|
|
200
|
-
left?: number;
|
|
201
|
-
right?: number;
|
|
202
|
-
firstLine?: number;
|
|
203
|
-
hanging?: number;
|
|
204
|
-
}) => void;
|
|
205
|
-
onSetParagraphTabStops?: (tabStops: Array<{ pos: number; val?: string; leader?: string }>) => void;
|
|
206
|
-
onRestartNumbering?: () => void;
|
|
207
|
-
onContinueNumbering?: () => void;
|
|
208
|
-
onNavigateHeading?: (headingId: string) => void;
|
|
209
|
-
chromeVisibility?: Partial<ReviewWorkspaceChromeVisibility>;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
export function TwReviewWorkspace(inputProps: TwReviewWorkspaceProps) {
|
|
213
|
-
const props = {
|
|
214
|
-
...inputProps,
|
|
215
|
-
...inputProps.commands,
|
|
216
|
-
} as TwReviewWorkspaceProps & EditorCommandBag;
|
|
217
|
-
const { snapshot, viewState } = props;
|
|
218
|
-
const selectionToolbarRootRef = useRef<HTMLDivElement>(null);
|
|
219
|
-
const caps = props.capabilities;
|
|
220
|
-
const isPageWorkspace = props.workspaceMode === "page";
|
|
221
|
-
const markupDisplay = props.markupDisplay;
|
|
222
|
-
const [navOpen, setNavOpen] = useState(false);
|
|
223
|
-
const [layoutToolsOpen, setLayoutToolsOpen] = useState(false);
|
|
224
|
-
const zoomLevel = props.zoomLevel ?? 100;
|
|
225
|
-
const zoomScale = typeof zoomLevel === "number" ? zoomLevel / 100 : 1;
|
|
226
|
-
const preserveOnlyCount = caps?.preserveOnlyCount ??
|
|
227
|
-
snapshot.compatibility.featureEntries.filter(
|
|
228
|
-
(entry) => entry.featureClass === "preserve-only",
|
|
229
|
-
).length;
|
|
230
|
-
const blockedReasons =
|
|
231
|
-
props.interactionGuardSnapshot?.blockedReasons ??
|
|
232
|
-
props.workflowScopeSnapshot?.blockedReasons ??
|
|
233
|
-
[];
|
|
234
|
-
const chromeVisibility: ReviewWorkspaceChromeVisibility = {
|
|
235
|
-
toolbar: true,
|
|
236
|
-
alerts: true,
|
|
237
|
-
selectionOverlay: true,
|
|
238
|
-
contextToolbars: true,
|
|
239
|
-
pageChrome: true,
|
|
240
|
-
statusBar: true,
|
|
241
|
-
reviewRail: true,
|
|
242
|
-
...props.chromeVisibility,
|
|
243
|
-
};
|
|
244
|
-
const showReviewRail = chromeVisibility.reviewRail && (caps?.reviewRailVisible ?? true);
|
|
245
|
-
const headings = props.documentNavigation?.headings ?? [];
|
|
246
|
-
const headerVariant = snapshot.pageLayout?.headerVariants[0]?.variant ?? "default";
|
|
247
|
-
const footerVariant = snapshot.pageLayout?.footerVariants[0]?.variant ?? "default";
|
|
248
|
-
const selectionPosition =
|
|
249
|
-
viewState.selection.activeRange.kind === "node"
|
|
250
|
-
? viewState.selection.activeRange.at
|
|
251
|
-
: viewState.selection.head;
|
|
252
|
-
const activeParagraphLayout = useMemo(
|
|
253
|
-
() => resolveActiveParagraphLayout(snapshot.surface, selectionPosition),
|
|
254
|
-
[selectionPosition, snapshot.surface],
|
|
255
|
-
);
|
|
256
|
-
const isTableContext = Boolean(
|
|
257
|
-
props.formattingState?.breadcrumb.some((item) => item.kind === "table" || item.kind === "table_cell" || item.kind === "table_row"),
|
|
258
|
-
);
|
|
259
|
-
const contextualSurface =
|
|
260
|
-
props.activeImageContext
|
|
261
|
-
? "image"
|
|
262
|
-
: props.activeObjectContext
|
|
263
|
-
? "object"
|
|
264
|
-
: isTableContext
|
|
265
|
-
? "table"
|
|
266
|
-
: null;
|
|
267
|
-
const pageChromeModel = useMemo(
|
|
268
|
-
() =>
|
|
269
|
-
buildPageChromeModel(
|
|
270
|
-
snapshot.surface,
|
|
271
|
-
snapshot.pageLayout,
|
|
272
|
-
props.documentNavigation,
|
|
273
|
-
snapshot.activeStory,
|
|
274
|
-
),
|
|
275
|
-
[props.documentNavigation, snapshot.activeStory, snapshot.pageLayout, snapshot.surface],
|
|
276
|
-
);
|
|
277
|
-
const selectionToolbarPlacement = resolveSelectionToolbarPlacement(
|
|
278
|
-
props.selectionToolbarAnchor,
|
|
279
|
-
selectionToolbarRootRef.current,
|
|
280
|
-
zoomScale,
|
|
281
|
-
);
|
|
282
|
-
const activePage = props.documentNavigation?.pages[props.documentNavigation.activePageIndex] ?? null;
|
|
283
|
-
const pageShellMetrics = useMemo(
|
|
284
|
-
() => buildPageShellMetrics(snapshot.pageLayout),
|
|
285
|
-
[snapshot.pageLayout],
|
|
286
|
-
);
|
|
287
|
-
const hidePageBorderForActiveEditing =
|
|
288
|
-
isPageWorkspace &&
|
|
289
|
-
snapshot.activeStory.kind === "main" &&
|
|
290
|
-
shouldHidePageBorderForSelection(viewState.selection);
|
|
291
|
-
const effectiveSelectionMode = props.interactionGuardSnapshot?.effectiveMode ?? "edit";
|
|
292
|
-
const allowLocalChromeMutations = Boolean(caps?.canEdit) && effectiveSelectionMode === "edit";
|
|
293
|
-
const pageChromeReadOnly =
|
|
294
|
-
snapshot.readOnly ||
|
|
295
|
-
snapshot.activeStory.kind !== "main" ||
|
|
296
|
-
effectiveSelectionMode !== "edit";
|
|
297
|
-
const toolbarInteractionPolicy: ToolbarInteractionPolicy | undefined = caps
|
|
298
|
-
? {
|
|
299
|
-
mode: effectiveSelectionMode,
|
|
300
|
-
canFormatText: caps.canEdit && effectiveSelectionMode === "edit",
|
|
301
|
-
canInsertStructural: caps.canEdit && effectiveSelectionMode === "edit",
|
|
302
|
-
canAddComment:
|
|
303
|
-
caps.canAddComment &&
|
|
304
|
-
effectiveSelectionMode !== "view" &&
|
|
305
|
-
effectiveSelectionMode !== "blocked",
|
|
306
|
-
}
|
|
307
|
-
: undefined;
|
|
308
|
-
|
|
309
|
-
useEffect(() => {
|
|
310
|
-
recordPerfSample("workspace.chrome");
|
|
311
|
-
incrementInvalidationCounter("workspace.chrome.recomputes");
|
|
312
|
-
}, [activeParagraphLayout, pageChromeModel, pageShellMetrics]);
|
|
313
|
-
|
|
314
|
-
useEffect(() => {
|
|
315
|
-
if (isPageWorkspace && snapshot.activeStory.kind !== "main") {
|
|
316
|
-
setLayoutToolsOpen(true);
|
|
317
|
-
}
|
|
318
|
-
}, [isPageWorkspace, snapshot.activeStory.kind]);
|
|
319
|
-
|
|
320
|
-
const dismissSelectionToolbar = useCallback(() => {
|
|
321
|
-
props.onDismissSelectionToolbar?.();
|
|
322
|
-
}, [props.onDismissSelectionToolbar]);
|
|
323
|
-
|
|
324
|
-
const runWithSelectionToolbarDismiss = useCallback(
|
|
325
|
-
(action?: () => void) => () => {
|
|
326
|
-
dismissSelectionToolbar();
|
|
327
|
-
action?.();
|
|
328
|
-
},
|
|
329
|
-
[dismissSelectionToolbar],
|
|
330
|
-
);
|
|
331
|
-
|
|
332
|
-
return (
|
|
333
|
-
<Tooltip.Provider delayDuration={400}>
|
|
334
|
-
<div className="flex h-full flex-col bg-canvas text-primary">
|
|
335
|
-
{chromeVisibility.toolbar ? <TwToolbar
|
|
336
|
-
sourceLabel={snapshot.sourceLabel}
|
|
337
|
-
capabilities={caps}
|
|
338
|
-
compatibility={snapshot.compatibility}
|
|
339
|
-
warnings={snapshot.warnings}
|
|
340
|
-
interactionPolicy={toolbarInteractionPolicy}
|
|
341
|
-
workspaceMode={props.workspaceMode}
|
|
342
|
-
zoomLevel={props.zoomLevel}
|
|
343
|
-
formattingState={props.formattingState}
|
|
344
|
-
styleCatalog={props.styleCatalog}
|
|
345
|
-
showTrackedChanges={props.showTrackedChanges}
|
|
346
|
-
onUndo={runWithSelectionToolbarDismiss(props.onUndo)}
|
|
347
|
-
onRedo={runWithSelectionToolbarDismiss(props.onRedo)}
|
|
348
|
-
onSetParagraphStyle={props.onSetParagraphStyle
|
|
349
|
-
? (styleId) => {
|
|
350
|
-
dismissSelectionToolbar();
|
|
351
|
-
props.onSetParagraphStyle?.(styleId);
|
|
352
|
-
}
|
|
353
|
-
: undefined}
|
|
354
|
-
onToggleBold={runWithSelectionToolbarDismiss(props.onToggleBold)}
|
|
355
|
-
onToggleItalic={runWithSelectionToolbarDismiss(props.onToggleItalic)}
|
|
356
|
-
onToggleUnderline={runWithSelectionToolbarDismiss(props.onToggleUnderline)}
|
|
357
|
-
onToggleStrikethrough={runWithSelectionToolbarDismiss(props.onToggleStrikethrough)}
|
|
358
|
-
onToggleSuperscript={runWithSelectionToolbarDismiss(props.onToggleSuperscript)}
|
|
359
|
-
onToggleSubscript={runWithSelectionToolbarDismiss(props.onToggleSubscript)}
|
|
360
|
-
onSetFontFamily={props.onSetFontFamily
|
|
361
|
-
? (fontFamily) => {
|
|
362
|
-
dismissSelectionToolbar();
|
|
363
|
-
props.onSetFontFamily?.(fontFamily);
|
|
364
|
-
}
|
|
365
|
-
: undefined}
|
|
366
|
-
onSetFontSize={props.onSetFontSize
|
|
367
|
-
? (fontSize) => {
|
|
368
|
-
dismissSelectionToolbar();
|
|
369
|
-
props.onSetFontSize?.(fontSize);
|
|
370
|
-
}
|
|
371
|
-
: undefined}
|
|
372
|
-
onSetTextColor={props.onSetTextColor
|
|
373
|
-
? (color) => {
|
|
374
|
-
dismissSelectionToolbar();
|
|
375
|
-
props.onSetTextColor?.(color);
|
|
376
|
-
}
|
|
377
|
-
: undefined}
|
|
378
|
-
onSetHighlightColor={props.onSetHighlightColor
|
|
379
|
-
? (color) => {
|
|
380
|
-
dismissSelectionToolbar();
|
|
381
|
-
props.onSetHighlightColor?.(color);
|
|
382
|
-
}
|
|
383
|
-
: undefined}
|
|
384
|
-
onSetAlignment={props.onSetAlignment
|
|
385
|
-
? (alignment) => {
|
|
386
|
-
dismissSelectionToolbar();
|
|
387
|
-
props.onSetAlignment?.(alignment);
|
|
388
|
-
}
|
|
389
|
-
: undefined}
|
|
390
|
-
onOutdent={runWithSelectionToolbarDismiss(props.onOutdent)}
|
|
391
|
-
onIndent={runWithSelectionToolbarDismiss(props.onIndent)}
|
|
392
|
-
onAddComment={runWithSelectionToolbarDismiss(props.onAddComment)}
|
|
393
|
-
onInsertPageBreak={runWithSelectionToolbarDismiss(props.onInsertPageBreak)}
|
|
394
|
-
onInsertTable={runWithSelectionToolbarDismiss(props.onInsertTable)}
|
|
395
|
-
onInsertSectionBreak={props.onInsertSectionBreak
|
|
396
|
-
? (type) => {
|
|
397
|
-
dismissSelectionToolbar();
|
|
398
|
-
props.onInsertSectionBreak?.(type);
|
|
399
|
-
}
|
|
400
|
-
: undefined}
|
|
401
|
-
onInsertImage={props.onInsertImage
|
|
402
|
-
? (options) => {
|
|
403
|
-
dismissSelectionToolbar();
|
|
404
|
-
props.onInsertImage?.(options);
|
|
405
|
-
}
|
|
406
|
-
: undefined}
|
|
407
|
-
onExport={runWithSelectionToolbarDismiss(props.onExport)}
|
|
408
|
-
activeStory={snapshot.activeStory}
|
|
409
|
-
onCloseStory={props.onCloseStory
|
|
410
|
-
? runWithSelectionToolbarDismiss(props.onCloseStory)
|
|
411
|
-
: undefined}
|
|
412
|
-
onWorkspaceModeChange={(value) => {
|
|
413
|
-
dismissSelectionToolbar();
|
|
414
|
-
props.onWorkspaceModeChange(value);
|
|
415
|
-
}}
|
|
416
|
-
onZoomChange={props.onZoomChange
|
|
417
|
-
? (level) => {
|
|
418
|
-
dismissSelectionToolbar();
|
|
419
|
-
props.onZoomChange?.(level);
|
|
420
|
-
}
|
|
421
|
-
: undefined}
|
|
422
|
-
onShowTrackedChangesChange={(show) => {
|
|
423
|
-
dismissSelectionToolbar();
|
|
424
|
-
props.onShowTrackedChangesChange(show);
|
|
425
|
-
}}
|
|
426
|
-
blockedReasons={blockedReasons}
|
|
427
|
-
/> : null}
|
|
428
|
-
|
|
429
|
-
{chromeVisibility.alerts ? <TwAlertBanner
|
|
430
|
-
snapshot={snapshot}
|
|
431
|
-
preserveOnlyCount={preserveOnlyCount}
|
|
432
|
-
workflowBlockedReasons={blockedReasons}
|
|
433
|
-
/> : null}
|
|
434
|
-
|
|
435
|
-
<div className="flex flex-1 min-h-0">
|
|
436
|
-
{/* Collapsible document navigator — page mode only */}
|
|
437
|
-
{isPageWorkspace && chromeVisibility.pageChrome ? (
|
|
438
|
-
<aside
|
|
439
|
-
aria-label="Document navigator"
|
|
440
|
-
className={`shrink-0 border-r border-border bg-surface transition-[width] duration-200 ${
|
|
441
|
-
navOpen ? "w-48" : "w-0"
|
|
442
|
-
} overflow-hidden`}
|
|
443
|
-
>
|
|
444
|
-
{navOpen ? (
|
|
445
|
-
<div className="flex h-full flex-col">
|
|
446
|
-
<div className="flex items-center justify-between px-3 py-2 border-b border-border">
|
|
447
|
-
<span className="text-xs font-medium text-secondary uppercase tracking-wider">Navigator</span>
|
|
448
|
-
<Tooltip.Root>
|
|
449
|
-
<Tooltip.Trigger asChild>
|
|
450
|
-
<button
|
|
451
|
-
type="button"
|
|
452
|
-
aria-label="Collapse navigator"
|
|
453
|
-
onMouseDown={preserveEditorSelectionMouseDown}
|
|
454
|
-
onClick={() => {
|
|
455
|
-
dismissSelectionToolbar();
|
|
456
|
-
setNavOpen(false);
|
|
457
|
-
}}
|
|
458
|
-
className="inline-flex h-6 w-6 items-center justify-center rounded-md text-secondary hover:bg-surface-hover transition-colors"
|
|
459
|
-
>
|
|
460
|
-
<ChevronLeft className="h-3.5 w-3.5" />
|
|
461
|
-
</button>
|
|
462
|
-
</Tooltip.Trigger>
|
|
463
|
-
<Tooltip.Portal>
|
|
464
|
-
<Tooltip.Content className="rounded-md bg-primary px-2 py-1 text-xs text-white shadow-md z-50" sideOffset={6}>
|
|
465
|
-
Collapse navigator
|
|
466
|
-
</Tooltip.Content>
|
|
467
|
-
</Tooltip.Portal>
|
|
468
|
-
</Tooltip.Root>
|
|
469
|
-
</div>
|
|
470
|
-
<nav className="flex-1 overflow-y-auto px-2 py-2" aria-label="Document headings">
|
|
471
|
-
{headings.length > 0 ? (
|
|
472
|
-
<ul className="space-y-0.5">
|
|
473
|
-
{headings.map((entry) => (
|
|
474
|
-
<li key={entry.headingId}>
|
|
475
|
-
<button
|
|
476
|
-
type="button"
|
|
477
|
-
className="block w-full truncate rounded-md px-2 py-1 text-left text-xs text-primary hover:bg-surface-hover"
|
|
478
|
-
style={{ paddingLeft: `${8 + (entry.level - 1) * 12}px` }}
|
|
479
|
-
onMouseDown={preserveEditorSelectionMouseDown}
|
|
480
|
-
onClick={() => {
|
|
481
|
-
dismissSelectionToolbar();
|
|
482
|
-
props.onNavigateHeading?.(entry.headingId);
|
|
483
|
-
setNavOpen(false);
|
|
484
|
-
}}
|
|
485
|
-
>
|
|
486
|
-
{entry.text}
|
|
487
|
-
</button>
|
|
488
|
-
</li>
|
|
489
|
-
))}
|
|
490
|
-
</ul>
|
|
491
|
-
) : (
|
|
492
|
-
<p className="px-2 py-4 text-xs text-tertiary">No headings found.</p>
|
|
493
|
-
)}
|
|
494
|
-
</nav>
|
|
495
|
-
</div>
|
|
496
|
-
) : null}
|
|
497
|
-
</aside>
|
|
498
|
-
) : null}
|
|
499
|
-
|
|
500
|
-
{/* Navigator expand toggle — page mode only when collapsed */}
|
|
501
|
-
{isPageWorkspace && chromeVisibility.pageChrome && !navOpen ? (
|
|
502
|
-
<div className="shrink-0 flex items-start pt-2 pl-1">
|
|
503
|
-
<Tooltip.Root>
|
|
504
|
-
<Tooltip.Trigger asChild>
|
|
505
|
-
<button
|
|
506
|
-
type="button"
|
|
507
|
-
aria-label="Open document navigator"
|
|
508
|
-
onMouseDown={preserveEditorSelectionMouseDown}
|
|
509
|
-
onClick={() => {
|
|
510
|
-
dismissSelectionToolbar();
|
|
511
|
-
setNavOpen(true);
|
|
512
|
-
}}
|
|
513
|
-
className="inline-flex h-7 w-7 items-center justify-center rounded-md text-secondary hover:bg-surface-hover transition-colors"
|
|
514
|
-
>
|
|
515
|
-
<List className="h-3.5 w-3.5" />
|
|
516
|
-
</button>
|
|
517
|
-
</Tooltip.Trigger>
|
|
518
|
-
<Tooltip.Portal>
|
|
519
|
-
<Tooltip.Content className="rounded-md bg-primary px-2 py-1 text-xs text-white shadow-md z-50" sideOffset={6}>
|
|
520
|
-
Open document navigator
|
|
521
|
-
</Tooltip.Content>
|
|
522
|
-
</Tooltip.Portal>
|
|
523
|
-
</Tooltip.Root>
|
|
524
|
-
</div>
|
|
525
|
-
) : null}
|
|
526
|
-
|
|
527
|
-
{/* Document column */}
|
|
528
|
-
<div className="flex flex-1 flex-col min-w-0">
|
|
529
|
-
<div
|
|
530
|
-
className={`flex-1 overflow-y-auto ${isPageWorkspace ? "bg-surface" : "bg-canvas"}`}
|
|
531
|
-
data-wre-scroll-root="true"
|
|
532
|
-
>
|
|
533
|
-
<div
|
|
534
|
-
ref={selectionToolbarRootRef}
|
|
535
|
-
className={`mx-auto min-h-full ${
|
|
536
|
-
isPageWorkspace
|
|
537
|
-
? "wre-page-chrome wre-page-surface relative max-w-[840px] my-8 overflow-hidden"
|
|
538
|
-
: "wre-canvas-surface relative bg-canvas"
|
|
539
|
-
}`}
|
|
540
|
-
style={isPageWorkspace && zoomScale !== 1 ? { transform: `scale(${zoomScale})`, transformOrigin: "top center" } : undefined}
|
|
541
|
-
>
|
|
542
|
-
{isPageWorkspace && chromeVisibility.pageChrome && snapshot.pageLayout ? (
|
|
543
|
-
<div className="border-b border-border/70 bg-surface/65 px-5 py-3" data-testid="page-context-summary">
|
|
544
|
-
<div className="flex flex-wrap items-center justify-between gap-2">
|
|
545
|
-
<div className="flex flex-wrap items-center gap-2 text-xs text-secondary">
|
|
546
|
-
<span className="rounded-full bg-canvas px-2 py-1 font-medium text-primary">
|
|
547
|
-
{activePage
|
|
548
|
-
? `Page ${activePage.pageIndex + 1} of ${props.documentNavigation?.pageCount ?? 1}`
|
|
549
|
-
: "Page workspace"}
|
|
550
|
-
</span>
|
|
551
|
-
<span>{`Section ${snapshot.pageLayout.sectionIndex + 1}`}</span>
|
|
552
|
-
<span className="uppercase tracking-[0.12em] text-tertiary">
|
|
553
|
-
{snapshot.pageLayout.orientation}
|
|
554
|
-
</span>
|
|
555
|
-
</div>
|
|
556
|
-
<div className="flex items-center gap-2">
|
|
557
|
-
{snapshot.activeStory.kind !== "main" ? (
|
|
558
|
-
<button
|
|
559
|
-
type="button"
|
|
560
|
-
aria-label="Return to document body"
|
|
561
|
-
onMouseDown={preserveEditorSelectionMouseDown}
|
|
562
|
-
onClick={runWithSelectionToolbarDismiss(props.onCloseStory)}
|
|
563
|
-
className="inline-flex items-center gap-1 rounded-md border border-border bg-canvas px-2 py-1 text-xs font-medium text-primary transition-colors hover:bg-surface"
|
|
564
|
-
>
|
|
565
|
-
Body
|
|
566
|
-
</button>
|
|
567
|
-
) : null}
|
|
568
|
-
{snapshot.activeStory.kind === "main" && snapshot.pageLayout.sectionIndex > 0 ? (
|
|
569
|
-
<>
|
|
570
|
-
<button
|
|
571
|
-
type="button"
|
|
572
|
-
aria-label="Link header to previous"
|
|
573
|
-
disabled={!props.onSetHeaderFooterLink || !allowLocalChromeMutations}
|
|
574
|
-
onMouseDown={preserveEditorSelectionMouseDown}
|
|
575
|
-
onClick={() => {
|
|
576
|
-
dismissSelectionToolbar();
|
|
577
|
-
props.onSetHeaderFooterLink?.(snapshot.pageLayout!.sectionIndex, {
|
|
578
|
-
kind: "header",
|
|
579
|
-
variant: headerVariant,
|
|
580
|
-
linkToPrevious: true,
|
|
581
|
-
});
|
|
582
|
-
}}
|
|
583
|
-
className="inline-flex items-center gap-1 rounded-md border border-border bg-canvas px-2 py-1 text-xs font-medium text-primary transition-colors hover:bg-surface disabled:cursor-not-allowed disabled:opacity-40"
|
|
584
|
-
>
|
|
585
|
-
Link header
|
|
586
|
-
</button>
|
|
587
|
-
<button
|
|
588
|
-
type="button"
|
|
589
|
-
aria-label="Link footer to previous"
|
|
590
|
-
disabled={!props.onSetHeaderFooterLink || !allowLocalChromeMutations}
|
|
591
|
-
onMouseDown={preserveEditorSelectionMouseDown}
|
|
592
|
-
onClick={() => {
|
|
593
|
-
dismissSelectionToolbar();
|
|
594
|
-
props.onSetHeaderFooterLink?.(snapshot.pageLayout!.sectionIndex, {
|
|
595
|
-
kind: "footer",
|
|
596
|
-
variant: footerVariant,
|
|
597
|
-
linkToPrevious: true,
|
|
598
|
-
});
|
|
599
|
-
}}
|
|
600
|
-
className="inline-flex items-center gap-1 rounded-md border border-border bg-canvas px-2 py-1 text-xs font-medium text-primary transition-colors hover:bg-surface disabled:cursor-not-allowed disabled:opacity-40"
|
|
601
|
-
>
|
|
602
|
-
Link footer
|
|
603
|
-
</button>
|
|
604
|
-
</>
|
|
605
|
-
) : null}
|
|
606
|
-
<button
|
|
607
|
-
type="button"
|
|
608
|
-
aria-label="Toggle layout tools"
|
|
609
|
-
aria-expanded={layoutToolsOpen}
|
|
610
|
-
onMouseDown={preserveEditorSelectionMouseDown}
|
|
611
|
-
onClick={() => {
|
|
612
|
-
dismissSelectionToolbar();
|
|
613
|
-
setLayoutToolsOpen((open) => !open);
|
|
614
|
-
}}
|
|
615
|
-
className="inline-flex items-center gap-1 rounded-md border border-border bg-canvas px-2 py-1 text-xs font-medium text-primary transition-colors hover:bg-surface"
|
|
616
|
-
>
|
|
617
|
-
<ChevronRight className={`h-3.5 w-3.5 transition-transform ${layoutToolsOpen ? "rotate-90" : ""}`} />
|
|
618
|
-
Layout tools
|
|
619
|
-
</button>
|
|
620
|
-
</div>
|
|
621
|
-
</div>
|
|
622
|
-
</div>
|
|
623
|
-
) : null}
|
|
624
|
-
{isPageWorkspace && chromeVisibility.pageChrome && snapshot.pageLayout && layoutToolsOpen ? (
|
|
625
|
-
<div className="px-5 pt-3">
|
|
626
|
-
<TwPageRuler
|
|
627
|
-
pageLayout={snapshot.pageLayout}
|
|
628
|
-
viewState={viewState}
|
|
629
|
-
paragraphLayout={activeParagraphLayout}
|
|
630
|
-
readOnly={pageChromeReadOnly}
|
|
631
|
-
onReturnToBody={props.onCloseStory
|
|
632
|
-
? runWithSelectionToolbarDismiss(props.onCloseStory)
|
|
633
|
-
: () => undefined}
|
|
634
|
-
onOpenHeader={props.onOpenHeaderStory
|
|
635
|
-
? runWithSelectionToolbarDismiss(props.onOpenHeaderStory)
|
|
636
|
-
: undefined}
|
|
637
|
-
onOpenFooter={props.onOpenFooterStory
|
|
638
|
-
? runWithSelectionToolbarDismiss(props.onOpenFooterStory)
|
|
639
|
-
: undefined}
|
|
640
|
-
onSetIndentation={props.onSetParagraphIndentation
|
|
641
|
-
? (indentation) => {
|
|
642
|
-
dismissSelectionToolbar();
|
|
643
|
-
props.onSetParagraphIndentation?.(indentation);
|
|
644
|
-
}
|
|
645
|
-
: undefined}
|
|
646
|
-
onSetTabStops={props.onSetParagraphTabStops
|
|
647
|
-
? (tabStops) => {
|
|
648
|
-
dismissSelectionToolbar();
|
|
649
|
-
props.onSetParagraphTabStops?.(tabStops);
|
|
650
|
-
}
|
|
651
|
-
: undefined}
|
|
652
|
-
onRestartNumbering={props.onRestartNumbering
|
|
653
|
-
? runWithSelectionToolbarDismiss(props.onRestartNumbering)
|
|
654
|
-
: undefined}
|
|
655
|
-
onContinueNumbering={props.onContinueNumbering
|
|
656
|
-
? runWithSelectionToolbarDismiss(props.onContinueNumbering)
|
|
657
|
-
: undefined}
|
|
658
|
-
/>
|
|
659
|
-
<TwLayoutPanel
|
|
660
|
-
pageLayout={snapshot.pageLayout}
|
|
661
|
-
readOnly={pageChromeReadOnly}
|
|
662
|
-
onInsertSectionBreak={props.onInsertSectionBreak
|
|
663
|
-
? (type) => {
|
|
664
|
-
dismissSelectionToolbar();
|
|
665
|
-
props.onInsertSectionBreak?.(type);
|
|
666
|
-
}
|
|
667
|
-
: undefined}
|
|
668
|
-
onDeleteSectionBreak={props.onDeleteSectionBreak
|
|
669
|
-
? (sectionIndex) => {
|
|
670
|
-
dismissSelectionToolbar();
|
|
671
|
-
props.onDeleteSectionBreak?.(sectionIndex);
|
|
672
|
-
}
|
|
673
|
-
: undefined}
|
|
674
|
-
onUpdateSectionLayout={props.onUpdateSectionLayout
|
|
675
|
-
? (sectionIndex, patch) => {
|
|
676
|
-
dismissSelectionToolbar();
|
|
677
|
-
props.onUpdateSectionLayout?.(sectionIndex, patch);
|
|
678
|
-
}
|
|
679
|
-
: undefined}
|
|
680
|
-
onSetSectionPageNumbering={props.onSetSectionPageNumbering
|
|
681
|
-
? (sectionIndex, patch) => {
|
|
682
|
-
dismissSelectionToolbar();
|
|
683
|
-
props.onSetSectionPageNumbering?.(sectionIndex, patch);
|
|
684
|
-
}
|
|
685
|
-
: undefined}
|
|
686
|
-
/>
|
|
687
|
-
</div>
|
|
688
|
-
) : null}
|
|
689
|
-
{chromeVisibility.contextToolbars && contextualSurface ? (
|
|
690
|
-
<div className="px-5 pt-3 space-y-3">
|
|
691
|
-
{contextualSurface === "table" ? (
|
|
692
|
-
<TwTableContextToolbar
|
|
693
|
-
disabled={!allowLocalChromeMutations}
|
|
694
|
-
tableStyles={props.styleCatalog?.tables ?? []}
|
|
695
|
-
onSetTableStyle={props.onSetTableStyle
|
|
696
|
-
? (styleId) => {
|
|
697
|
-
dismissSelectionToolbar();
|
|
698
|
-
props.onSetTableStyle?.(styleId);
|
|
699
|
-
}
|
|
700
|
-
: undefined}
|
|
701
|
-
onAddRowBefore={runWithSelectionToolbarDismiss(props.onAddRowBefore)}
|
|
702
|
-
onAddRowAfter={runWithSelectionToolbarDismiss(props.onAddRowAfter)}
|
|
703
|
-
onAddColumnBefore={runWithSelectionToolbarDismiss(props.onAddColumnBefore)}
|
|
704
|
-
onAddColumnAfter={runWithSelectionToolbarDismiss(props.onAddColumnAfter)}
|
|
705
|
-
onDeleteRow={runWithSelectionToolbarDismiss(props.onDeleteRow)}
|
|
706
|
-
onDeleteColumn={runWithSelectionToolbarDismiss(props.onDeleteColumn)}
|
|
707
|
-
onDeleteTable={runWithSelectionToolbarDismiss(props.onDeleteTable)}
|
|
708
|
-
onMergeCells={runWithSelectionToolbarDismiss(props.onMergeCells)}
|
|
709
|
-
onSplitCell={runWithSelectionToolbarDismiss(props.onSplitCell)}
|
|
710
|
-
onSetCellBackground={props.onSetCellBackground
|
|
711
|
-
? (color) => {
|
|
712
|
-
dismissSelectionToolbar();
|
|
713
|
-
props.onSetCellBackground?.(color);
|
|
714
|
-
}
|
|
715
|
-
: undefined}
|
|
716
|
-
/>
|
|
717
|
-
) : null}
|
|
718
|
-
{contextualSurface === "image" && props.activeImageContext ? (
|
|
719
|
-
<TwImageContextToolbar
|
|
720
|
-
activeImage={props.activeImageContext}
|
|
721
|
-
disabled={!allowLocalChromeMutations}
|
|
722
|
-
onSetImageLayout={props.onSetImageLayout
|
|
723
|
-
? (mediaId, dimensions) => {
|
|
724
|
-
dismissSelectionToolbar();
|
|
725
|
-
props.onSetImageLayout?.(mediaId, dimensions);
|
|
726
|
-
}
|
|
727
|
-
: undefined}
|
|
728
|
-
onSetImageFrame={props.onSetImageFrame
|
|
729
|
-
? (mediaId, offsets) => {
|
|
730
|
-
dismissSelectionToolbar();
|
|
731
|
-
props.onSetImageFrame?.(mediaId, offsets);
|
|
732
|
-
}
|
|
733
|
-
: undefined}
|
|
734
|
-
/>
|
|
735
|
-
) : null}
|
|
736
|
-
{contextualSurface === "object" && props.activeObjectContext ? (
|
|
737
|
-
<TwObjectContextToolbar activeObject={props.activeObjectContext} />
|
|
738
|
-
) : null}
|
|
739
|
-
</div>
|
|
740
|
-
) : null}
|
|
741
|
-
{chromeVisibility.selectionOverlay && props.suggestionCard && selectionToolbarPlacement ? (
|
|
742
|
-
<div className="pointer-events-none absolute inset-0 z-20" data-testid="suggestion-card-overlay">
|
|
743
|
-
<div
|
|
744
|
-
className="pointer-events-auto absolute"
|
|
745
|
-
data-placement={selectionToolbarPlacement.placement}
|
|
746
|
-
style={selectionToolbarPlacement.style}
|
|
747
|
-
>
|
|
748
|
-
<TwSuggestionCard
|
|
749
|
-
model={props.suggestionCard}
|
|
750
|
-
onFocusCapture={props.onSelectionToolbarFocusCapture}
|
|
751
|
-
onBlurCapture={props.onSelectionToolbarBlurCapture}
|
|
752
|
-
onAccept={props.onAcceptSuggestion}
|
|
753
|
-
onReject={props.onRejectSuggestion}
|
|
754
|
-
onEditSuggestion={props.onEditSuggestion}
|
|
755
|
-
onAddComment={props.onAddCommentFromSuggestion ?? props.onAddComment}
|
|
756
|
-
/>
|
|
757
|
-
</div>
|
|
758
|
-
</div>
|
|
759
|
-
) : null}
|
|
760
|
-
{chromeVisibility.selectionOverlay && props.suggestionCard && !selectionToolbarPlacement ? (
|
|
761
|
-
<div
|
|
762
|
-
className="pointer-events-none absolute inset-x-0 top-0 z-20 flex justify-center px-4 pt-3"
|
|
763
|
-
data-testid="suggestion-card-fallback"
|
|
764
|
-
>
|
|
765
|
-
<div className="pointer-events-auto" data-placement="fallback">
|
|
766
|
-
<TwSuggestionCard
|
|
767
|
-
model={props.suggestionCard}
|
|
768
|
-
onFocusCapture={props.onSelectionToolbarFocusCapture}
|
|
769
|
-
onBlurCapture={props.onSelectionToolbarBlurCapture}
|
|
770
|
-
onAccept={props.onAcceptSuggestion}
|
|
771
|
-
onReject={props.onRejectSuggestion}
|
|
772
|
-
onEditSuggestion={props.onEditSuggestion}
|
|
773
|
-
onAddComment={props.onAddCommentFromSuggestion ?? props.onAddComment}
|
|
774
|
-
/>
|
|
775
|
-
</div>
|
|
776
|
-
</div>
|
|
777
|
-
) : null}
|
|
778
|
-
{chromeVisibility.selectionOverlay && props.selectionToolbar && !props.suggestionCard && selectionToolbarPlacement ? (
|
|
779
|
-
<div className="pointer-events-none absolute inset-0 z-20" data-testid="selection-toolbar-overlay">
|
|
780
|
-
<div
|
|
781
|
-
className="pointer-events-auto absolute"
|
|
782
|
-
data-placement={selectionToolbarPlacement.placement}
|
|
783
|
-
style={selectionToolbarPlacement.style}
|
|
784
|
-
>
|
|
785
|
-
<TwSelectionToolbar
|
|
786
|
-
ref={props.selectionToolbarRef}
|
|
787
|
-
model={props.selectionToolbar}
|
|
788
|
-
disabledReason={props.selectionToolbar.disabledReason}
|
|
789
|
-
onFocusCapture={props.onSelectionToolbarFocusCapture}
|
|
790
|
-
onBlurCapture={props.onSelectionToolbarBlurCapture}
|
|
791
|
-
onToggleBold={props.onToggleBold}
|
|
792
|
-
onToggleItalic={props.onToggleItalic}
|
|
793
|
-
onToggleUnderline={props.onToggleUnderline}
|
|
794
|
-
onSetTextColor={props.onSetSelectionTextColor}
|
|
795
|
-
onSetHighlightColor={props.onSetSelectionHighlightColor}
|
|
796
|
-
onAddComment={props.onAddCommentFromSelection ?? props.onAddComment}
|
|
797
|
-
/>
|
|
798
|
-
</div>
|
|
799
|
-
</div>
|
|
800
|
-
) : null}
|
|
801
|
-
{chromeVisibility.selectionOverlay && props.selectionToolbar && !props.suggestionCard && !selectionToolbarPlacement ? (
|
|
802
|
-
<div
|
|
803
|
-
className="pointer-events-none absolute inset-x-0 top-0 z-20 flex justify-center px-4 pt-3"
|
|
804
|
-
data-testid="selection-toolbar-fallback"
|
|
805
|
-
>
|
|
806
|
-
<div className="pointer-events-auto" data-placement="fallback">
|
|
807
|
-
<TwSelectionToolbar
|
|
808
|
-
ref={props.selectionToolbarRef}
|
|
809
|
-
model={props.selectionToolbar}
|
|
810
|
-
disabledReason={props.selectionToolbar.disabledReason}
|
|
811
|
-
onFocusCapture={props.onSelectionToolbarFocusCapture}
|
|
812
|
-
onBlurCapture={props.onSelectionToolbarBlurCapture}
|
|
813
|
-
onToggleBold={props.onToggleBold}
|
|
814
|
-
onToggleItalic={props.onToggleItalic}
|
|
815
|
-
onToggleUnderline={props.onToggleUnderline}
|
|
816
|
-
onSetTextColor={props.onSetSelectionTextColor}
|
|
817
|
-
onSetHighlightColor={props.onSetSelectionHighlightColor}
|
|
818
|
-
onAddComment={props.onAddCommentFromSelection ?? props.onAddComment}
|
|
819
|
-
/>
|
|
820
|
-
</div>
|
|
821
|
-
</div>
|
|
822
|
-
) : null}
|
|
823
|
-
<div
|
|
824
|
-
className={isPageWorkspace ? "relative" : undefined}
|
|
825
|
-
data-line-numbering={pageChromeModel.lineNumberingEnabled ? "enabled" : "disabled"}
|
|
826
|
-
>
|
|
827
|
-
{isPageWorkspace && chromeVisibility.pageChrome && pageChromeModel.lineNumberingEnabled ? (
|
|
828
|
-
<div
|
|
829
|
-
aria-hidden="true"
|
|
830
|
-
className="pointer-events-none absolute inset-y-0 left-0 z-10"
|
|
831
|
-
data-testid="page-line-number-gutter"
|
|
832
|
-
style={{ width: `${pageChromeModel.gutterWidthPx}px` }}
|
|
833
|
-
>
|
|
834
|
-
{pageChromeModel.lineMarkers.map((marker) => (
|
|
835
|
-
<span
|
|
836
|
-
key={marker.id}
|
|
837
|
-
className="absolute right-2 font-[family-name:var(--font-legal-sans)] text-[10px] font-medium tabular-nums tracking-[0.12em] text-tertiary/80"
|
|
838
|
-
style={{ top: `${marker.topPx}px` }}
|
|
839
|
-
>
|
|
840
|
-
{marker.label}
|
|
841
|
-
</span>
|
|
842
|
-
))}
|
|
843
|
-
</div>
|
|
844
|
-
) : null}
|
|
845
|
-
<div
|
|
846
|
-
className={isPageWorkspace && chromeVisibility.pageChrome && pageChromeModel.lineNumberingEnabled ? "pl-12" : undefined}
|
|
847
|
-
style={isPageWorkspace ? pageShellMetrics.contentInsetStyle : undefined}
|
|
848
|
-
>
|
|
849
|
-
<div
|
|
850
|
-
className={isPageWorkspace ? "relative" : undefined}
|
|
851
|
-
data-document-grid={pageChromeModel.documentGridType}
|
|
852
|
-
data-page-border-display={pageChromeModel.pageBorderDisplay}
|
|
853
|
-
style={isPageWorkspace
|
|
854
|
-
? {
|
|
855
|
-
...pageChromeModel.documentGridStyle,
|
|
856
|
-
...pageShellMetrics.pageFrameStyle,
|
|
857
|
-
}
|
|
858
|
-
: pageChromeModel.documentGridStyle}
|
|
859
|
-
>
|
|
860
|
-
{isPageWorkspace && chromeVisibility.pageChrome ? (
|
|
861
|
-
<div
|
|
862
|
-
data-testid="page-header-band"
|
|
863
|
-
className="relative z-10 flex items-center justify-between border-b border-dashed border-border/60 px-4 text-[11px] text-secondary"
|
|
864
|
-
style={pageShellMetrics.headerBandStyle}
|
|
865
|
-
>
|
|
866
|
-
<span className="uppercase tracking-[0.12em] text-tertiary">Header</span>
|
|
867
|
-
{snapshot.pageLayout?.headerVariants[0] ? (
|
|
868
|
-
<button
|
|
869
|
-
type="button"
|
|
870
|
-
aria-label="Open header story"
|
|
871
|
-
onClick={props.onOpenHeaderStory}
|
|
872
|
-
className="rounded-md px-2 py-1 text-xs font-medium text-primary transition-colors hover:bg-surface"
|
|
873
|
-
>
|
|
874
|
-
Edit header
|
|
875
|
-
</button>
|
|
876
|
-
) : null}
|
|
877
|
-
</div>
|
|
878
|
-
) : null}
|
|
879
|
-
{isPageWorkspace && chromeVisibility.pageChrome && pageChromeModel.showPageBorder && !hidePageBorderForActiveEditing ? (
|
|
880
|
-
<div
|
|
881
|
-
aria-hidden="true"
|
|
882
|
-
className="pointer-events-none absolute inset-0 z-0 rounded-[2px]"
|
|
883
|
-
data-testid="page-border-overlay"
|
|
884
|
-
style={pageChromeModel.pageBorderStyle}
|
|
885
|
-
/>
|
|
886
|
-
) : null}
|
|
887
|
-
<div className={isPageWorkspace ? "relative z-10" : undefined}>
|
|
888
|
-
{props.document}
|
|
889
|
-
</div>
|
|
890
|
-
{isPageWorkspace && chromeVisibility.pageChrome ? (
|
|
891
|
-
<div
|
|
892
|
-
data-testid="page-footer-band"
|
|
893
|
-
className="relative z-10 flex items-center justify-between border-t border-dashed border-border/60 px-4 text-[11px] text-secondary"
|
|
894
|
-
style={pageShellMetrics.footerBandStyle}
|
|
895
|
-
>
|
|
896
|
-
<span className="uppercase tracking-[0.12em] text-tertiary">Footer</span>
|
|
897
|
-
{snapshot.pageLayout?.footerVariants[0] ? (
|
|
898
|
-
<button
|
|
899
|
-
type="button"
|
|
900
|
-
aria-label="Open footer story"
|
|
901
|
-
onClick={props.onOpenFooterStory}
|
|
902
|
-
className="rounded-md px-2 py-1 text-xs font-medium text-primary transition-colors hover:bg-surface"
|
|
903
|
-
>
|
|
904
|
-
Edit footer
|
|
905
|
-
</button>
|
|
906
|
-
) : null}
|
|
907
|
-
</div>
|
|
908
|
-
) : null}
|
|
909
|
-
</div>
|
|
910
|
-
</div>
|
|
911
|
-
</div>
|
|
912
|
-
</div>
|
|
913
|
-
</div>
|
|
914
|
-
|
|
915
|
-
{chromeVisibility.statusBar ? (
|
|
916
|
-
<TwStatusBar
|
|
917
|
-
isDirty={snapshot.isDirty}
|
|
918
|
-
isExportBlocked={snapshot.compatibility.blockExport}
|
|
919
|
-
preserveOnlyCount={preserveOnlyCount}
|
|
920
|
-
commentCount={snapshot.comments.totalCount}
|
|
921
|
-
changeCount={snapshot.trackedChanges.totalCount}
|
|
922
|
-
sessionId={snapshot.sessionId}
|
|
923
|
-
/>
|
|
924
|
-
) : null}
|
|
925
|
-
</div>
|
|
926
|
-
|
|
927
|
-
{/* Review rail — hidden in editing mode unless toggled */}
|
|
928
|
-
{showReviewRail ? <TwReviewRail
|
|
929
|
-
activeTab={props.activeRailTab}
|
|
930
|
-
currentUserId={props.currentUserId}
|
|
931
|
-
comments={snapshot.comments}
|
|
932
|
-
trackedChanges={snapshot.trackedChanges}
|
|
933
|
-
compatibility={snapshot.compatibility}
|
|
934
|
-
warnings={snapshot.warnings}
|
|
935
|
-
markupDisplay={markupDisplay}
|
|
936
|
-
activeCommentId={props.activeCommentId}
|
|
937
|
-
activeRevisionId={props.activeRevisionId}
|
|
938
|
-
onActiveTabChange={props.onActiveRailTabChange}
|
|
939
|
-
onOpenComment={props.onOpenComment}
|
|
940
|
-
onResolveComment={props.onResolveComment}
|
|
941
|
-
onReopenComment={props.onReopenComment}
|
|
942
|
-
onAddReply={props.onAddReply}
|
|
943
|
-
onEditBody={props.onEditBody}
|
|
944
|
-
onOpenRevision={props.onOpenRevision}
|
|
945
|
-
onAcceptRevision={props.onAcceptRevision}
|
|
946
|
-
onRejectRevision={props.onRejectRevision}
|
|
947
|
-
onAcceptAllChanges={props.onAcceptAllChanges}
|
|
948
|
-
onRejectAllChanges={props.onRejectAllChanges}
|
|
949
|
-
/> : null}
|
|
950
|
-
</div>
|
|
951
|
-
</div>
|
|
952
|
-
</Tooltip.Provider>
|
|
953
|
-
);
|
|
954
|
-
}
|
|
955
|
-
|
|
956
|
-
function shouldHidePageBorderForSelection(
|
|
957
|
-
selection: EditorViewStateSnapshot["selection"],
|
|
958
|
-
): boolean {
|
|
959
|
-
if (selection.isCollapsed) {
|
|
960
|
-
return false;
|
|
961
|
-
}
|
|
962
|
-
|
|
963
|
-
return selection.activeRange.kind === "range";
|
|
964
|
-
}
|
|
965
|
-
|
|
966
|
-
function resolveActiveParagraphLayout(
|
|
967
|
-
surface: RuntimeRenderSnapshot["surface"],
|
|
968
|
-
position: number,
|
|
969
|
-
): {
|
|
970
|
-
leftIndent: number;
|
|
971
|
-
rightIndent: number;
|
|
972
|
-
firstLineOffset: number;
|
|
973
|
-
tabStops: Array<{ pos: number; val?: string; leader?: string }>;
|
|
974
|
-
} | null {
|
|
975
|
-
const paragraph = surface ? findActiveParagraph(surface.blocks, position) : null;
|
|
976
|
-
if (!paragraph) {
|
|
977
|
-
return null;
|
|
978
|
-
}
|
|
979
|
-
|
|
980
|
-
return {
|
|
981
|
-
leftIndent: paragraph.indentation?.left ?? 0,
|
|
982
|
-
rightIndent: paragraph.indentation?.right ?? 0,
|
|
983
|
-
firstLineOffset:
|
|
984
|
-
paragraph.indentation?.firstLine ??
|
|
985
|
-
(paragraph.indentation?.hanging ? -paragraph.indentation.hanging : 0),
|
|
986
|
-
tabStops: paragraph.tabStops ? [...paragraph.tabStops] : [],
|
|
987
|
-
};
|
|
988
|
-
}
|
|
989
|
-
|
|
990
|
-
function findActiveParagraph(
|
|
991
|
-
blocks: readonly SurfaceBlockSnapshot[],
|
|
992
|
-
position: number,
|
|
993
|
-
): Extract<SurfaceBlockSnapshot, { kind: "paragraph" }> | null {
|
|
994
|
-
for (const block of blocks) {
|
|
995
|
-
if (block.kind === "paragraph" && position >= block.from && position <= block.to) {
|
|
996
|
-
return block;
|
|
997
|
-
}
|
|
998
|
-
if (block.kind === "table") {
|
|
999
|
-
for (const row of block.rows) {
|
|
1000
|
-
for (const cell of row.cells) {
|
|
1001
|
-
const paragraph = findActiveParagraph(cell.content, position);
|
|
1002
|
-
if (paragraph) {
|
|
1003
|
-
return paragraph;
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
if (block.kind === "sdt_block") {
|
|
1009
|
-
const paragraph = findActiveParagraph(block.children, position);
|
|
1010
|
-
if (paragraph) {
|
|
1011
|
-
return paragraph;
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
return null;
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
interface PageChromeModel {
|
|
1019
|
-
lineNumberingEnabled: boolean;
|
|
1020
|
-
gutterWidthPx: number;
|
|
1021
|
-
lineMarkers: Array<{ id: string; label: string; topPx: number }>;
|
|
1022
|
-
showPageBorder: boolean;
|
|
1023
|
-
pageBorderDisplay: string;
|
|
1024
|
-
pageBorderStyle: CSSProperties | undefined;
|
|
1025
|
-
documentGridType: string;
|
|
1026
|
-
documentGridStyle: CSSProperties | undefined;
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1029
|
-
const EMPTY_PAGE_CHROME_MODEL: PageChromeModel = {
|
|
1030
|
-
lineNumberingEnabled: false,
|
|
1031
|
-
gutterWidthPx: 0,
|
|
1032
|
-
lineMarkers: [],
|
|
1033
|
-
showPageBorder: false,
|
|
1034
|
-
pageBorderDisplay: "none",
|
|
1035
|
-
pageBorderStyle: undefined,
|
|
1036
|
-
documentGridType: "none",
|
|
1037
|
-
documentGridStyle: undefined,
|
|
1038
|
-
};
|
|
1039
|
-
|
|
1040
|
-
const DOCUMENT_CONTENT_TOP_PADDING_PX = 40;
|
|
1041
|
-
|
|
1042
|
-
interface PageShellMetrics {
|
|
1043
|
-
contentInsetStyle: CSSProperties;
|
|
1044
|
-
pageFrameStyle: CSSProperties;
|
|
1045
|
-
headerBandStyle: CSSProperties;
|
|
1046
|
-
footerBandStyle: CSSProperties;
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
function buildPageChromeModel(
|
|
1050
|
-
surface: RuntimeRenderSnapshot["surface"] | undefined,
|
|
1051
|
-
pageLayout: RuntimeRenderSnapshot["pageLayout"] | undefined,
|
|
1052
|
-
navigation: DocumentNavigationSnapshot | undefined,
|
|
1053
|
-
activeStory: RuntimeRenderSnapshot["activeStory"],
|
|
1054
|
-
): PageChromeModel {
|
|
1055
|
-
if (!surface || !pageLayout || !navigation || activeStory.kind !== "main") {
|
|
1056
|
-
return EMPTY_PAGE_CHROME_MODEL;
|
|
1057
|
-
}
|
|
1058
|
-
|
|
1059
|
-
const lineMarkers = computeLineMarkersIfEnabled({
|
|
1060
|
-
pageLayout,
|
|
1061
|
-
surfaceBlocks: surface.blocks,
|
|
1062
|
-
pages: navigation.pages,
|
|
1063
|
-
buildLineNumberMarkers,
|
|
1064
|
-
});
|
|
1065
|
-
const lineNumberingEnabled =
|
|
1066
|
-
Boolean(pageLayout.lineNumbering) && lineMarkers.length > 0;
|
|
1067
|
-
const distance = pageLayout.lineNumbering?.distance ?? 0;
|
|
1068
|
-
const gutterWidthPx = lineNumberingEnabled
|
|
1069
|
-
? Math.max(40, Math.min(88, 24 + Math.round(distance * DEFAULT_PAGE_ESTIMATE_PX_PER_TWIP)))
|
|
1070
|
-
: 0;
|
|
1071
|
-
const showPageBorder = shouldRenderPageBorder(pageLayout, navigation.pages, navigation.activePageIndex);
|
|
1072
|
-
|
|
1073
|
-
return {
|
|
1074
|
-
lineNumberingEnabled,
|
|
1075
|
-
gutterWidthPx,
|
|
1076
|
-
lineMarkers,
|
|
1077
|
-
showPageBorder,
|
|
1078
|
-
pageBorderDisplay: pageLayout.pageBorders?.display ?? "none",
|
|
1079
|
-
pageBorderStyle: showPageBorder ? buildPageBorderStyle(pageLayout) : undefined,
|
|
1080
|
-
documentGridType: pageLayout.documentGrid?.type ?? "none",
|
|
1081
|
-
documentGridStyle: buildDocumentGridStyle(pageLayout.documentGrid),
|
|
1082
|
-
};
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
function buildPageShellMetrics(
|
|
1086
|
-
pageLayout: RuntimeRenderSnapshot["pageLayout"] | undefined,
|
|
1087
|
-
): PageShellMetrics {
|
|
1088
|
-
if (!pageLayout) {
|
|
1089
|
-
return {
|
|
1090
|
-
contentInsetStyle: {},
|
|
1091
|
-
pageFrameStyle: {},
|
|
1092
|
-
headerBandStyle: {},
|
|
1093
|
-
footerBandStyle: {},
|
|
1094
|
-
};
|
|
1095
|
-
}
|
|
1096
|
-
|
|
1097
|
-
const horizontalInsetPx = Math.max(
|
|
1098
|
-
24,
|
|
1099
|
-
Math.min(120, Math.round(pageLayout.marginLeft * DEFAULT_PAGE_ESTIMATE_PX_PER_TWIP)),
|
|
1100
|
-
);
|
|
1101
|
-
const verticalInsetPx = Math.max(
|
|
1102
|
-
24,
|
|
1103
|
-
Math.min(140, Math.round(pageLayout.marginTop * DEFAULT_PAGE_ESTIMATE_PX_PER_TWIP)),
|
|
1104
|
-
);
|
|
1105
|
-
const headerBandHeightPx = Math.max(
|
|
1106
|
-
40,
|
|
1107
|
-
Math.min(96, Math.round(pageLayout.headerMargin * DEFAULT_PAGE_ESTIMATE_PX_PER_TWIP + 16)),
|
|
1108
|
-
);
|
|
1109
|
-
const footerBandHeightPx = Math.max(
|
|
1110
|
-
40,
|
|
1111
|
-
Math.min(96, Math.round(pageLayout.footerMargin * DEFAULT_PAGE_ESTIMATE_PX_PER_TWIP + 16)),
|
|
1112
|
-
);
|
|
1113
|
-
|
|
1114
|
-
return {
|
|
1115
|
-
contentInsetStyle: {
|
|
1116
|
-
paddingLeft: `${horizontalInsetPx}px`,
|
|
1117
|
-
paddingRight: `${horizontalInsetPx}px`,
|
|
1118
|
-
paddingTop: `${Math.max(20, verticalInsetPx - 12)}px`,
|
|
1119
|
-
paddingBottom: `${Math.max(20, Math.round(pageLayout.marginBottom * DEFAULT_PAGE_ESTIMATE_PX_PER_TWIP) - 12)}px`,
|
|
1120
|
-
},
|
|
1121
|
-
pageFrameStyle: {
|
|
1122
|
-
backgroundColor: "var(--color-page-bg)",
|
|
1123
|
-
},
|
|
1124
|
-
headerBandStyle: {
|
|
1125
|
-
minHeight: `${headerBandHeightPx}px`,
|
|
1126
|
-
},
|
|
1127
|
-
footerBandStyle: {
|
|
1128
|
-
minHeight: `${footerBandHeightPx}px`,
|
|
1129
|
-
},
|
|
1130
|
-
};
|
|
1131
|
-
}
|
|
1132
|
-
|
|
1133
|
-
function buildLineNumberMarkers(
|
|
1134
|
-
blocks: readonly SurfaceBlockSnapshot[],
|
|
1135
|
-
pages: ReadonlyArray<DocumentNavigationSnapshot["pages"][number]>,
|
|
1136
|
-
): Array<{ id: string; label: string; topPx: number }> {
|
|
1137
|
-
const markers: Array<{ id: string; label: string; topPx: number }> = [];
|
|
1138
|
-
if (pages.length === 0) {
|
|
1139
|
-
return markers;
|
|
1140
|
-
}
|
|
1141
|
-
|
|
1142
|
-
let currentTopTwips = 0;
|
|
1143
|
-
let lineNumber = 1;
|
|
1144
|
-
let lastPageIndex = -1;
|
|
1145
|
-
let lastSectionIndex = -1;
|
|
1146
|
-
|
|
1147
|
-
for (const block of blocks) {
|
|
1148
|
-
const pageIndex = findPageForOffset(pages, block.from);
|
|
1149
|
-
const page = pages[pageIndex];
|
|
1150
|
-
if (!page) {
|
|
1151
|
-
continue;
|
|
1152
|
-
}
|
|
1153
|
-
|
|
1154
|
-
const lineNumbering = page.layout.lineNumbering;
|
|
1155
|
-
const restartMode = lineNumbering?.restart ?? "newPage";
|
|
1156
|
-
const restartStart = lineNumbering?.start ?? 1;
|
|
1157
|
-
const countBy = Math.max(1, lineNumbering?.countBy ?? 1);
|
|
1158
|
-
const columnWidth = getUsableColumnWidth(page.layout);
|
|
1159
|
-
|
|
1160
|
-
if (pageIndex !== lastPageIndex) {
|
|
1161
|
-
if (restartMode === "newPage" || lastPageIndex === -1) {
|
|
1162
|
-
lineNumber = restartStart;
|
|
1163
|
-
}
|
|
1164
|
-
lastPageIndex = pageIndex;
|
|
1165
|
-
}
|
|
1166
|
-
if (page.sectionIndex !== lastSectionIndex) {
|
|
1167
|
-
if (restartMode === "newSection" || lastSectionIndex === -1) {
|
|
1168
|
-
lineNumber = restartStart;
|
|
1169
|
-
}
|
|
1170
|
-
lastSectionIndex = page.sectionIndex;
|
|
1171
|
-
}
|
|
1172
|
-
|
|
1173
|
-
if (block.kind === "paragraph" && lineNumbering) {
|
|
1174
|
-
const lineCount = estimateParagraphLineCount(block, columnWidth);
|
|
1175
|
-
const lineHeight = estimateParagraphLineHeight(block);
|
|
1176
|
-
const suppress = block.suppressLineNumbers === true;
|
|
1177
|
-
for (let lineIndex = 0; lineIndex < lineCount; lineIndex += 1) {
|
|
1178
|
-
if (!suppress && (lineNumber - restartStart) % countBy === 0) {
|
|
1179
|
-
markers.push({
|
|
1180
|
-
id: `${block.blockId}-${lineIndex}`,
|
|
1181
|
-
label: String(lineNumber),
|
|
1182
|
-
topPx:
|
|
1183
|
-
DOCUMENT_CONTENT_TOP_PADDING_PX +
|
|
1184
|
-
(currentTopTwips + lineIndex * lineHeight) * DEFAULT_PAGE_ESTIMATE_PX_PER_TWIP,
|
|
1185
|
-
});
|
|
1186
|
-
}
|
|
1187
|
-
if (!suppress) {
|
|
1188
|
-
lineNumber += 1;
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
|
|
1193
|
-
currentTopTwips += estimateBlockHeight(block, columnWidth);
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
return markers;
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
function shouldRenderPageBorder(
|
|
1200
|
-
pageLayout: RuntimeRenderSnapshot["pageLayout"],
|
|
1201
|
-
pages: ReadonlyArray<DocumentNavigationSnapshot["pages"][number]>,
|
|
1202
|
-
activePageIndex: number,
|
|
1203
|
-
): boolean {
|
|
1204
|
-
const display = pageLayout?.pageBorders?.display ?? "allPages";
|
|
1205
|
-
const activePage = pages[activePageIndex];
|
|
1206
|
-
if (!pageLayout?.pageBorders || !activePage) {
|
|
1207
|
-
return false;
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
switch (display) {
|
|
1211
|
-
case "firstPage":
|
|
1212
|
-
return activePage.pageInSection === 0;
|
|
1213
|
-
case "notFirstPage":
|
|
1214
|
-
return activePage.pageInSection > 0;
|
|
1215
|
-
default:
|
|
1216
|
-
return true;
|
|
1217
|
-
}
|
|
1218
|
-
}
|
|
1219
|
-
|
|
1220
|
-
function buildPageBorderStyle(
|
|
1221
|
-
pageLayout: NonNullable<RuntimeRenderSnapshot["pageLayout"]>,
|
|
1222
|
-
): CSSProperties | undefined {
|
|
1223
|
-
const pageBorders = pageLayout.pageBorders;
|
|
1224
|
-
if (!pageBorders) {
|
|
1225
|
-
return undefined;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
const leftInset = createInsetValue(
|
|
1229
|
-
pageBorders.left?.space,
|
|
1230
|
-
pageBorders.offsetFrom === "text"
|
|
1231
|
-
? (pageLayout.marginLeft / Math.max(1, pageLayout.pageWidth)) * 100
|
|
1232
|
-
: 1.25,
|
|
1233
|
-
);
|
|
1234
|
-
const rightInset = createInsetValue(
|
|
1235
|
-
pageBorders.right?.space,
|
|
1236
|
-
pageBorders.offsetFrom === "text"
|
|
1237
|
-
? (pageLayout.marginRight / Math.max(1, pageLayout.pageWidth)) * 100
|
|
1238
|
-
: 1.25,
|
|
1239
|
-
);
|
|
1240
|
-
const topInset = createInsetValue(
|
|
1241
|
-
pageBorders.top?.space,
|
|
1242
|
-
pageBorders.offsetFrom === "text"
|
|
1243
|
-
? (pageLayout.marginTop / Math.max(1, pageLayout.pageHeight)) * 100
|
|
1244
|
-
: 1.5,
|
|
1245
|
-
);
|
|
1246
|
-
const bottomInset = createInsetValue(
|
|
1247
|
-
pageBorders.bottom?.space,
|
|
1248
|
-
pageBorders.offsetFrom === "text"
|
|
1249
|
-
? (pageLayout.marginBottom / Math.max(1, pageLayout.pageHeight)) * 100
|
|
1250
|
-
: 1.5,
|
|
1251
|
-
);
|
|
1252
|
-
|
|
1253
|
-
return {
|
|
1254
|
-
top: topInset,
|
|
1255
|
-
right: rightInset,
|
|
1256
|
-
bottom: bottomInset,
|
|
1257
|
-
left: leftInset,
|
|
1258
|
-
borderTop: toBorderCss(pageBorders.top),
|
|
1259
|
-
borderRight: toBorderCss(pageBorders.right),
|
|
1260
|
-
borderBottom: toBorderCss(pageBorders.bottom),
|
|
1261
|
-
borderLeft: toBorderCss(pageBorders.left),
|
|
1262
|
-
boxSizing: "border-box",
|
|
1263
|
-
mixBlendMode: pageBorders.zOrder === "back" ? "multiply" : undefined,
|
|
1264
|
-
};
|
|
1265
|
-
}
|
|
1266
|
-
|
|
1267
|
-
function buildDocumentGridStyle(
|
|
1268
|
-
documentGrid: NonNullable<RuntimeRenderSnapshot["pageLayout"]>["documentGrid"] | undefined,
|
|
1269
|
-
): CSSProperties | undefined {
|
|
1270
|
-
if (!documentGrid || !documentGrid.type || documentGrid.type === "default") {
|
|
1271
|
-
return undefined;
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
const linePitchPx = Math.max(
|
|
1275
|
-
18,
|
|
1276
|
-
Math.round((documentGrid.linePitch ?? 360) * DEFAULT_PAGE_ESTIMATE_PX_PER_TWIP),
|
|
1277
|
-
);
|
|
1278
|
-
const charSpacePx = Math.max(
|
|
1279
|
-
12,
|
|
1280
|
-
Math.round((documentGrid.charSpace ?? 204) * DEFAULT_PAGE_ESTIMATE_PX_PER_TWIP),
|
|
1281
|
-
);
|
|
1282
|
-
const gridColor = "rgba(15, 23, 42, 0.06)";
|
|
1283
|
-
const backgrounds: string[] = [];
|
|
1284
|
-
|
|
1285
|
-
if (
|
|
1286
|
-
documentGrid.type === "lines" ||
|
|
1287
|
-
documentGrid.type === "linesAndChars" ||
|
|
1288
|
-
documentGrid.type === "snapToChars"
|
|
1289
|
-
) {
|
|
1290
|
-
backgrounds.push(
|
|
1291
|
-
`repeating-linear-gradient(to bottom, ${gridColor} 0, ${gridColor} 1px, transparent 1px, transparent ${linePitchPx}px)`,
|
|
1292
|
-
);
|
|
1293
|
-
}
|
|
1294
|
-
if (
|
|
1295
|
-
documentGrid.type === "linesAndChars" ||
|
|
1296
|
-
documentGrid.type === "snapToChars"
|
|
1297
|
-
) {
|
|
1298
|
-
backgrounds.push(
|
|
1299
|
-
`repeating-linear-gradient(to right, rgba(15, 23, 42, 0.04) 0, rgba(15, 23, 42, 0.04) 1px, transparent 1px, transparent ${charSpacePx}px)`,
|
|
1300
|
-
);
|
|
1301
|
-
}
|
|
1302
|
-
|
|
1303
|
-
if (backgrounds.length === 0) {
|
|
1304
|
-
return undefined;
|
|
1305
|
-
}
|
|
1306
|
-
|
|
1307
|
-
return {
|
|
1308
|
-
backgroundImage: backgrounds.join(", "),
|
|
1309
|
-
backgroundOrigin: "content-box",
|
|
1310
|
-
};
|
|
1311
|
-
}
|
|
1312
|
-
|
|
1313
|
-
function createInsetValue(spaceTwips: number | undefined, percent: number): string {
|
|
1314
|
-
const spacingPx = Math.max(0, Math.round((spaceTwips ?? 0) * DEFAULT_PAGE_ESTIMATE_PX_PER_TWIP));
|
|
1315
|
-
return `calc(${percent.toFixed(2)}% + ${spacingPx}px)`;
|
|
1316
|
-
}
|
|
1317
|
-
|
|
1318
|
-
function resolveSelectionToolbarPlacement(
|
|
1319
|
-
anchor: SelectionToolbarAnchor | null | undefined,
|
|
1320
|
-
root: HTMLDivElement | null,
|
|
1321
|
-
zoomScale: number,
|
|
1322
|
-
): { placement: "right" | "left" | "above" | "below"; style: CSSProperties } | null {
|
|
1323
|
-
if (!anchor || !root) {
|
|
1324
|
-
return null;
|
|
1325
|
-
}
|
|
1326
|
-
|
|
1327
|
-
const rootRect = root.getBoundingClientRect();
|
|
1328
|
-
if (rootRect.width <= 0 || rootRect.height <= 0 || zoomScale <= 0) {
|
|
1329
|
-
return null;
|
|
1330
|
-
}
|
|
1331
|
-
|
|
1332
|
-
const centerX = (anchor.left + anchor.right) / 2;
|
|
1333
|
-
const centerY = (anchor.top + anchor.bottom) / 2;
|
|
1334
|
-
const localLeftEdge = (anchor.left - rootRect.left) / zoomScale;
|
|
1335
|
-
const localRightEdge = (anchor.right - rootRect.left) / zoomScale;
|
|
1336
|
-
const localLeft = (centerX - rootRect.left) / zoomScale;
|
|
1337
|
-
const localCenterY = (centerY - rootRect.top) / zoomScale;
|
|
1338
|
-
const localTop = (anchor.top - rootRect.top) / zoomScale;
|
|
1339
|
-
const localBottom = (anchor.bottom - rootRect.top) / zoomScale;
|
|
1340
|
-
const edgePadding = 16 / zoomScale;
|
|
1341
|
-
const containerWidth = rootRect.width / zoomScale;
|
|
1342
|
-
const containerHeight = rootRect.height / zoomScale;
|
|
1343
|
-
const gapPx = 12 / zoomScale;
|
|
1344
|
-
const estimatedToolbarWidth = Math.min(260 / zoomScale, Math.max(168 / zoomScale, containerWidth * 0.32));
|
|
1345
|
-
const estimatedToolbarHeight = 44 / zoomScale;
|
|
1346
|
-
const clampedCenterLeft = Math.max(
|
|
1347
|
-
edgePadding,
|
|
1348
|
-
Math.min(localLeft, Math.max(edgePadding, containerWidth - edgePadding)),
|
|
1349
|
-
);
|
|
1350
|
-
const clampedCenterY = Math.max(
|
|
1351
|
-
edgePadding + estimatedToolbarHeight / 2,
|
|
1352
|
-
Math.min(localCenterY, Math.max(edgePadding + estimatedToolbarHeight / 2, containerHeight - edgePadding - estimatedToolbarHeight / 2)),
|
|
1353
|
-
);
|
|
1354
|
-
const rightClearance = containerWidth - localRightEdge - gapPx - edgePadding;
|
|
1355
|
-
const leftClearance = localLeftEdge - gapPx - edgePadding;
|
|
1356
|
-
|
|
1357
|
-
if (rightClearance >= estimatedToolbarWidth) {
|
|
1358
|
-
return {
|
|
1359
|
-
placement: "right",
|
|
1360
|
-
style: {
|
|
1361
|
-
left: `${localRightEdge}px`,
|
|
1362
|
-
top: `${clampedCenterY}px`,
|
|
1363
|
-
maxWidth: `${Math.max(220, containerWidth - edgePadding * 2)}px`,
|
|
1364
|
-
transform: `translate(${gapPx}px, -50%)`,
|
|
1365
|
-
},
|
|
1366
|
-
};
|
|
1367
|
-
}
|
|
1368
|
-
|
|
1369
|
-
if (leftClearance >= estimatedToolbarWidth) {
|
|
1370
|
-
return {
|
|
1371
|
-
placement: "left",
|
|
1372
|
-
style: {
|
|
1373
|
-
left: `${localLeftEdge}px`,
|
|
1374
|
-
top: `${clampedCenterY}px`,
|
|
1375
|
-
maxWidth: `${Math.max(220, containerWidth - edgePadding * 2)}px`,
|
|
1376
|
-
transform: `translate(calc(-100% - ${gapPx}px), -50%)`,
|
|
1377
|
-
},
|
|
1378
|
-
};
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
const placement = localTop < estimatedToolbarHeight + gapPx + edgePadding ? "below" : "above";
|
|
1382
|
-
|
|
1383
|
-
return {
|
|
1384
|
-
placement,
|
|
1385
|
-
style: {
|
|
1386
|
-
left: `${clampedCenterLeft}px`,
|
|
1387
|
-
top: `${placement === "above" ? localTop : localBottom}px`,
|
|
1388
|
-
maxWidth: `${Math.max(220, containerWidth - edgePadding * 2)}px`,
|
|
1389
|
-
transform:
|
|
1390
|
-
placement === "above"
|
|
1391
|
-
? `translate(-50%, calc(-100% - ${gapPx}px))`
|
|
1392
|
-
: `translate(-50%, ${gapPx}px)`,
|
|
1393
|
-
},
|
|
1394
|
-
};
|
|
1395
|
-
}
|
|
1396
|
-
|
|
1397
|
-
function toBorderCss(
|
|
1398
|
-
border:
|
|
1399
|
-
| NonNullable<NonNullable<RuntimeRenderSnapshot["pageLayout"]>["pageBorders"]>["top"]
|
|
1400
|
-
| undefined,
|
|
1401
|
-
): string | undefined {
|
|
1402
|
-
if (!border || border.value === "none" || border.value === "nil") {
|
|
1403
|
-
return undefined;
|
|
1404
|
-
}
|
|
1405
|
-
|
|
1406
|
-
const width = border.size ? `${Math.max(1, Math.round(border.size / 8))}px` : "1px";
|
|
1407
|
-
const style =
|
|
1408
|
-
border.value === "double"
|
|
1409
|
-
? "double"
|
|
1410
|
-
: border.value === "dotted"
|
|
1411
|
-
? "dotted"
|
|
1412
|
-
: border.value === "dashed" || border.value === "dashSmallGap"
|
|
1413
|
-
? "dashed"
|
|
1414
|
-
: "solid";
|
|
1415
|
-
const color = border.color && border.color !== "auto" ? `#${border.color}` : "rgba(31, 31, 31, 0.28)";
|
|
1416
|
-
return `${width} ${style} ${color}`;
|
|
1417
|
-
}
|