@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,876 +0,0 @@
|
|
|
1
|
-
import { Schema } from "prosemirror-model";
|
|
2
|
-
import {
|
|
3
|
-
tableNodeSpec,
|
|
4
|
-
tableRowNodeSpec,
|
|
5
|
-
tableCellNodeSpec,
|
|
6
|
-
tableHeaderCellNodeSpec,
|
|
7
|
-
} from "../../runtime/table-schema.ts";
|
|
8
|
-
|
|
9
|
-
const HEX_COLOR_RE = /^[0-9A-Fa-f]{3,8}$/;
|
|
10
|
-
const SAFE_FONT_RE = /^[A-Za-z0-9 ,\-'"]+$/;
|
|
11
|
-
const SAFE_ALIGNMENT = new Set(["left", "center", "right", "justify", "start", "end"]);
|
|
12
|
-
|
|
13
|
-
function resolveHeadingLevel(
|
|
14
|
-
styleId: string | null,
|
|
15
|
-
outlineLevel: number | null,
|
|
16
|
-
): number | null {
|
|
17
|
-
if (styleId) {
|
|
18
|
-
const normalized = styleId.toLowerCase();
|
|
19
|
-
const compact = normalized.replace(/[\s_-]+/g, "");
|
|
20
|
-
const headingMatch = /^heading([1-6])$/.exec(compact);
|
|
21
|
-
if (headingMatch) {
|
|
22
|
-
return Number.parseInt(headingMatch[1], 10);
|
|
23
|
-
}
|
|
24
|
-
if (compact === "title") {
|
|
25
|
-
return 1;
|
|
26
|
-
}
|
|
27
|
-
if (compact === "subtitle") {
|
|
28
|
-
return 2;
|
|
29
|
-
}
|
|
30
|
-
if (compact === "tocheading") {
|
|
31
|
-
return 1;
|
|
32
|
-
}
|
|
33
|
-
if (/^(appendix|schedule|annex|exhibit|attachment)(heading|title)$/.test(compact)) {
|
|
34
|
-
return 2;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if (
|
|
39
|
-
typeof outlineLevel === "number" &&
|
|
40
|
-
Number.isInteger(outlineLevel) &&
|
|
41
|
-
outlineLevel >= 0 &&
|
|
42
|
-
outlineLevel <= 5
|
|
43
|
-
) {
|
|
44
|
-
return outlineLevel + 1;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function headingClassList(level: number): string[] {
|
|
51
|
-
switch (level) {
|
|
52
|
-
case 1:
|
|
53
|
-
return ["text-3xl", "font-semibold", "tracking-tight", "leading-tight"];
|
|
54
|
-
case 2:
|
|
55
|
-
return ["text-2xl", "font-semibold", "tracking-tight"];
|
|
56
|
-
case 3:
|
|
57
|
-
return ["text-xl", "font-medium"];
|
|
58
|
-
case 4:
|
|
59
|
-
return ["text-lg", "font-medium"];
|
|
60
|
-
case 5:
|
|
61
|
-
return ["text-base", "font-semibold", "uppercase", "tracking-[0.12em]"];
|
|
62
|
-
case 6:
|
|
63
|
-
return ["text-sm", "font-semibold", "uppercase", "tracking-[0.16em]"];
|
|
64
|
-
default:
|
|
65
|
-
return [];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** Validate a raw hex color string from OOXML (no leading #). Returns sanitized `#hex` or null. */
|
|
70
|
-
function safeHexColor(raw: string | null | undefined): string | null {
|
|
71
|
-
if (!raw || raw === "auto") return null;
|
|
72
|
-
return HEX_COLOR_RE.test(raw) ? `#${raw}` : null;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** Validate a CSS color value (may already include #). Returns the value or null. */
|
|
76
|
-
function safeCssColor(raw: string | null | undefined): string | null {
|
|
77
|
-
if (!raw) return null;
|
|
78
|
-
// Allow #hex, named colors (single word), rgb/rgba functions
|
|
79
|
-
if (/^#[0-9A-Fa-f]{3,8}$/.test(raw)) return raw;
|
|
80
|
-
if (/^[a-zA-Z]+$/.test(raw)) return raw;
|
|
81
|
-
return null;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function sanitizeLinkHref(raw: string | null | undefined): string | null {
|
|
85
|
-
if (!raw) return null;
|
|
86
|
-
const trimmed = raw.trim();
|
|
87
|
-
if (trimmed.startsWith("#")) {
|
|
88
|
-
return trimmed;
|
|
89
|
-
}
|
|
90
|
-
const lower = trimmed.toLowerCase();
|
|
91
|
-
if (
|
|
92
|
-
lower.startsWith("http://") ||
|
|
93
|
-
lower.startsWith("https://") ||
|
|
94
|
-
lower.startsWith("mailto:") ||
|
|
95
|
-
lower.startsWith("tel:")
|
|
96
|
-
) {
|
|
97
|
-
return trimmed;
|
|
98
|
-
}
|
|
99
|
-
return null;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* ProseMirror schema for the supported live surface slice.
|
|
104
|
-
*
|
|
105
|
-
* Maps canonical document node types to PM nodes and marks.
|
|
106
|
-
* This schema is used for rendering and input capture only —
|
|
107
|
-
* ProseMirror does not own the canonical document state.
|
|
108
|
-
*/
|
|
109
|
-
export const editorSchema = new Schema({
|
|
110
|
-
nodes: {
|
|
111
|
-
doc: {
|
|
112
|
-
content: "block+",
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
paragraph: {
|
|
116
|
-
content: "inline*",
|
|
117
|
-
group: "block",
|
|
118
|
-
attrs: {
|
|
119
|
-
styleId: { default: null },
|
|
120
|
-
numberingInstanceId: { default: null },
|
|
121
|
-
numberingLevel: { default: null },
|
|
122
|
-
numberingPrefix: { default: null },
|
|
123
|
-
numberingSuffix: { default: null },
|
|
124
|
-
alignment: { default: null },
|
|
125
|
-
spacingBefore: { default: null },
|
|
126
|
-
spacingAfter: { default: null },
|
|
127
|
-
lineSpacing: { default: null },
|
|
128
|
-
lineRule: { default: null },
|
|
129
|
-
contextualSpacing: { default: null },
|
|
130
|
-
listContinuation: { default: null },
|
|
131
|
-
contextualSpacingBefore: { default: null },
|
|
132
|
-
contextualSpacingAfter: { default: null },
|
|
133
|
-
indentLeft: { default: null },
|
|
134
|
-
indentRight: { default: null },
|
|
135
|
-
indentFirstLine: { default: null },
|
|
136
|
-
indentHanging: { default: null },
|
|
137
|
-
shadingFill: { default: null },
|
|
138
|
-
borderTop: { default: null },
|
|
139
|
-
borderBottom: { default: null },
|
|
140
|
-
borderLeft: { default: null },
|
|
141
|
-
borderRight: { default: null },
|
|
142
|
-
outlineLevel: { default: null },
|
|
143
|
-
bidi: { default: null },
|
|
144
|
-
pageBreakBefore: { default: null },
|
|
145
|
-
},
|
|
146
|
-
parseDOM: [{ tag: "p" }],
|
|
147
|
-
toDOM(node) {
|
|
148
|
-
const classes: string[] = ["leading-relaxed"];
|
|
149
|
-
const styleId = node.attrs.styleId as string | null;
|
|
150
|
-
const outlineLevel = node.attrs.outlineLevel as number | null;
|
|
151
|
-
const headingLevel = resolveHeadingLevel(styleId, outlineLevel);
|
|
152
|
-
if (headingLevel) {
|
|
153
|
-
classes.push(...headingClassList(headingLevel));
|
|
154
|
-
}
|
|
155
|
-
const attrs: Record<string, string> = { class: classes.join(" ") };
|
|
156
|
-
const styles: string[] = [];
|
|
157
|
-
const alignment = node.attrs.alignment as string | null;
|
|
158
|
-
const safeAlign = alignment === "both" ? "justify" : alignment;
|
|
159
|
-
if (safeAlign && SAFE_ALIGNMENT.has(safeAlign)) styles.push(`text-align: ${safeAlign}`);
|
|
160
|
-
const spacingBefore = node.attrs.spacingBefore as number | null;
|
|
161
|
-
const contextualSpacingBefore = node.attrs.contextualSpacingBefore as boolean | null;
|
|
162
|
-
if (contextualSpacingBefore) styles.push("margin-top: 0");
|
|
163
|
-
else if (spacingBefore) styles.push(`margin-top: ${spacingBefore / 20}px`);
|
|
164
|
-
const contextualSpacingAfter = node.attrs.contextualSpacingAfter as boolean | null;
|
|
165
|
-
const spacingAfter = node.attrs.spacingAfter as number | null;
|
|
166
|
-
if (contextualSpacingAfter) styles.push("margin-bottom: 0");
|
|
167
|
-
else if (spacingAfter) styles.push(`margin-bottom: ${spacingAfter / 20}px`);
|
|
168
|
-
const lineSpacing = node.attrs.lineSpacing as number | null;
|
|
169
|
-
const lineRule = node.attrs.lineRule as string | null;
|
|
170
|
-
if (lineSpacing && lineRule === "auto") styles.push(`line-height: ${lineSpacing / 240}`);
|
|
171
|
-
else if (lineSpacing && lineRule === "exact") styles.push(`line-height: ${lineSpacing / 20}px`);
|
|
172
|
-
else if (lineSpacing && lineRule === "atLeast") styles.push(`min-height: ${lineSpacing / 20}px`);
|
|
173
|
-
const indentLeft = node.attrs.indentLeft as number | null;
|
|
174
|
-
if (indentLeft) styles.push(`padding-left: ${indentLeft / 20}px`);
|
|
175
|
-
const indentRight = node.attrs.indentRight as number | null;
|
|
176
|
-
if (indentRight) styles.push(`padding-right: ${indentRight / 20}px`);
|
|
177
|
-
const indentFirstLine = node.attrs.indentFirstLine as number | null;
|
|
178
|
-
const indentHanging = node.attrs.indentHanging as number | null;
|
|
179
|
-
if (indentHanging) styles.push(`text-indent: -${indentHanging / 20}px`);
|
|
180
|
-
else if (indentFirstLine) styles.push(`text-indent: ${indentFirstLine / 20}px`);
|
|
181
|
-
const shadingColor = safeHexColor(node.attrs.shadingFill as string | null);
|
|
182
|
-
if (shadingColor) styles.push(`background-color: ${shadingColor}`);
|
|
183
|
-
for (const [side, attrName] of [["top", "borderTop"], ["bottom", "borderBottom"], ["left", "borderLeft"], ["right", "borderRight"]] as const) {
|
|
184
|
-
const border = node.attrs[attrName] as { color?: string; sz?: number; val?: string } | null;
|
|
185
|
-
if (border && border.val && border.val !== "none") {
|
|
186
|
-
const width = border.sz ? `${border.sz / 8}px` : "1px";
|
|
187
|
-
const color = safeHexColor(border.color ?? null) ?? "#000000";
|
|
188
|
-
const bStyle = border.val === "dotted" ? "dotted" : border.val === "dashed" ? "dashed" : "solid";
|
|
189
|
-
styles.push(`border-${side}: ${width} ${bStyle} ${color}`);
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
const pageBreak = node.attrs.pageBreakBefore as boolean | null;
|
|
193
|
-
if (pageBreak) styles.push("border-top: 2px dashed rgba(0,0,0,0.1); padding-top: 8px; margin-top: 16px");
|
|
194
|
-
const bidi = node.attrs.bidi as boolean | null;
|
|
195
|
-
if (bidi) attrs.dir = "rtl";
|
|
196
|
-
if (headingLevel) {
|
|
197
|
-
attrs["data-heading-level"] = String(headingLevel);
|
|
198
|
-
}
|
|
199
|
-
const isNumbered = node.attrs.numberingInstanceId !== null;
|
|
200
|
-
if (isNumbered) {
|
|
201
|
-
attrs["data-numbered"] = "true";
|
|
202
|
-
}
|
|
203
|
-
const contextualSpacing = node.attrs.contextualSpacing as boolean | null;
|
|
204
|
-
if (contextualSpacing) {
|
|
205
|
-
attrs["data-contextual-spacing"] = "true";
|
|
206
|
-
}
|
|
207
|
-
const listContinuation = node.attrs.listContinuation as boolean | null;
|
|
208
|
-
if (listContinuation) {
|
|
209
|
-
attrs["data-list-continuation"] = "true";
|
|
210
|
-
}
|
|
211
|
-
if (contextualSpacingBefore) {
|
|
212
|
-
attrs["data-contextual-spacing-before"] = "true";
|
|
213
|
-
}
|
|
214
|
-
if (contextualSpacingAfter) {
|
|
215
|
-
attrs["data-contextual-spacing-after"] = "true";
|
|
216
|
-
}
|
|
217
|
-
if (styles.length > 0) attrs.style = styles.join("; ");
|
|
218
|
-
const numberingPrefix = node.attrs.numberingPrefix as string | null;
|
|
219
|
-
const numberingLevel = node.attrs.numberingLevel as number | null;
|
|
220
|
-
const numberingSuffix = node.attrs.numberingSuffix as "tab" | "space" | "nothing" | null;
|
|
221
|
-
const children: Array<string | number | readonly unknown[]> = [];
|
|
222
|
-
if (pageBreak) {
|
|
223
|
-
children.push([
|
|
224
|
-
"span",
|
|
225
|
-
{
|
|
226
|
-
class:
|
|
227
|
-
"mb-2 inline-flex items-center gap-2 text-[10px] font-medium uppercase tracking-[0.18em] text-tertiary",
|
|
228
|
-
contenteditable: "false",
|
|
229
|
-
"data-page-break-before": "true",
|
|
230
|
-
},
|
|
231
|
-
"Page break",
|
|
232
|
-
]);
|
|
233
|
-
}
|
|
234
|
-
if (numberingPrefix) {
|
|
235
|
-
const minWidth = Math.min(Math.max(numberingPrefix.length + 1, 4), 14);
|
|
236
|
-
const marginRight = numberingSuffix === "nothing" ? "0.25rem" : numberingSuffix === "space" ? "0.5rem" : "0.75rem";
|
|
237
|
-
children.push([
|
|
238
|
-
"span",
|
|
239
|
-
{
|
|
240
|
-
class:
|
|
241
|
-
"inline-flex select-none items-center justify-end text-tertiary font-[family-name:var(--font-legal-sans)]",
|
|
242
|
-
contenteditable: "false",
|
|
243
|
-
"data-numbering-prefix": numberingPrefix,
|
|
244
|
-
...(typeof numberingLevel === "number"
|
|
245
|
-
? { "data-numbering-level": String(numberingLevel) }
|
|
246
|
-
: {}),
|
|
247
|
-
...(numberingSuffix ? { "data-numbering-suffix": numberingSuffix } : {}),
|
|
248
|
-
style: `min-width: ${minWidth}ch; margin-right: ${marginRight}; font-variant-numeric: tabular-nums;`,
|
|
249
|
-
},
|
|
250
|
-
numberingPrefix,
|
|
251
|
-
]);
|
|
252
|
-
}
|
|
253
|
-
children.push([
|
|
254
|
-
"span",
|
|
255
|
-
{
|
|
256
|
-
class: "pm-paragraph-content",
|
|
257
|
-
},
|
|
258
|
-
0,
|
|
259
|
-
]);
|
|
260
|
-
return ["p", attrs, ...children];
|
|
261
|
-
},
|
|
262
|
-
},
|
|
263
|
-
|
|
264
|
-
text: {
|
|
265
|
-
group: "inline",
|
|
266
|
-
},
|
|
267
|
-
|
|
268
|
-
hard_break: {
|
|
269
|
-
inline: true,
|
|
270
|
-
group: "inline",
|
|
271
|
-
selectable: false,
|
|
272
|
-
parseDOM: [{ tag: "br" }],
|
|
273
|
-
toDOM() {
|
|
274
|
-
return ["br"];
|
|
275
|
-
},
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
tab_char: {
|
|
279
|
-
inline: true,
|
|
280
|
-
group: "inline",
|
|
281
|
-
atom: true,
|
|
282
|
-
selectable: false,
|
|
283
|
-
attrs: {
|
|
284
|
-
tabWidth: { default: null },
|
|
285
|
-
leader: { default: null },
|
|
286
|
-
align: { default: null },
|
|
287
|
-
},
|
|
288
|
-
toDOM(node) {
|
|
289
|
-
const width = node.attrs.tabWidth as number | null;
|
|
290
|
-
const leader = node.attrs.leader as string | null;
|
|
291
|
-
const align = node.attrs.align as string | null;
|
|
292
|
-
const styles = [
|
|
293
|
-
`display: inline-block`,
|
|
294
|
-
`width: ${width && width > 0 ? width : 32}px`,
|
|
295
|
-
`min-width: 8px`,
|
|
296
|
-
];
|
|
297
|
-
if (leader === "dot" || leader === "middleDot") {
|
|
298
|
-
styles.push(
|
|
299
|
-
`background-image: radial-gradient(circle, currentColor 1px, transparent 1.25px)`,
|
|
300
|
-
`background-size: 6px 3px`,
|
|
301
|
-
`background-repeat: repeat-x`,
|
|
302
|
-
`background-position: left calc(100% - 2px)`,
|
|
303
|
-
`opacity: 0.55`,
|
|
304
|
-
);
|
|
305
|
-
} else if (leader === "hyphen") {
|
|
306
|
-
styles.push(`border-bottom: 1px dashed rgba(107,107,107,0.65)`);
|
|
307
|
-
} else if (leader === "underscore") {
|
|
308
|
-
styles.push(`border-bottom: 1px solid rgba(107,107,107,0.65)`);
|
|
309
|
-
} else if (leader === "heavy") {
|
|
310
|
-
styles.push(`border-bottom: 2px solid rgba(107,107,107,0.75)`);
|
|
311
|
-
}
|
|
312
|
-
return [
|
|
313
|
-
"span",
|
|
314
|
-
{
|
|
315
|
-
style: styles.join("; "),
|
|
316
|
-
"data-node-type": "tab",
|
|
317
|
-
title: align ? `Tab stop · ${align}` : "Tab stop",
|
|
318
|
-
},
|
|
319
|
-
"\u00A0",
|
|
320
|
-
];
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
|
|
324
|
-
image_atom: {
|
|
325
|
-
inline: true,
|
|
326
|
-
group: "inline",
|
|
327
|
-
atom: true,
|
|
328
|
-
attrs: {
|
|
329
|
-
mediaId: { default: "" },
|
|
330
|
-
altText: { default: null },
|
|
331
|
-
state: { default: "editable" },
|
|
332
|
-
display: { default: "inline" },
|
|
333
|
-
detail: { default: null },
|
|
334
|
-
src: { default: null },
|
|
335
|
-
widthEmu: { default: null },
|
|
336
|
-
heightEmu: { default: null },
|
|
337
|
-
},
|
|
338
|
-
toDOM(node) {
|
|
339
|
-
const isMissing = node.attrs.state === "missing";
|
|
340
|
-
const isFloating = node.attrs.display === "floating";
|
|
341
|
-
const src = node.attrs.src as string | null;
|
|
342
|
-
const widthEmu = node.attrs.widthEmu as number | null;
|
|
343
|
-
const heightEmu = node.attrs.heightEmu as number | null;
|
|
344
|
-
if (!isMissing && src) {
|
|
345
|
-
const widthPx = widthEmu ? Math.max(24, Math.round(widthEmu / 9525)) : undefined;
|
|
346
|
-
const heightPx = heightEmu ? Math.max(24, Math.round(heightEmu / 9525)) : undefined;
|
|
347
|
-
const style = [
|
|
348
|
-
"display:inline-block",
|
|
349
|
-
"vertical-align:middle",
|
|
350
|
-
"margin:0 4px",
|
|
351
|
-
widthPx ? `width:${widthPx}px` : "",
|
|
352
|
-
heightPx ? `height:${heightPx}px` : "",
|
|
353
|
-
].filter(Boolean).join(";");
|
|
354
|
-
return [
|
|
355
|
-
"span",
|
|
356
|
-
{
|
|
357
|
-
class: "inline-flex items-center rounded",
|
|
358
|
-
"data-node-type": "image",
|
|
359
|
-
title: (node.attrs.detail as string) ?? (node.attrs.altText as string) ?? "Image",
|
|
360
|
-
},
|
|
361
|
-
[
|
|
362
|
-
"img",
|
|
363
|
-
{
|
|
364
|
-
src,
|
|
365
|
-
alt: (node.attrs.altText as string) ?? "",
|
|
366
|
-
style,
|
|
367
|
-
},
|
|
368
|
-
],
|
|
369
|
-
];
|
|
370
|
-
}
|
|
371
|
-
return [
|
|
372
|
-
"span",
|
|
373
|
-
{
|
|
374
|
-
class: `inline-flex items-center gap-1 mx-0.5 px-1.5 py-0.5 rounded text-xs border-none ${
|
|
375
|
-
isMissing ? "text-danger bg-delete-soft" : "text-secondary bg-surface"
|
|
376
|
-
}`,
|
|
377
|
-
"data-node-type": "image",
|
|
378
|
-
title: (node.attrs.detail as string) ?? (node.attrs.altText as string) ?? "Image",
|
|
379
|
-
},
|
|
380
|
-
"\uD83D\uDCF7 " + ((node.attrs.altText as string) ?? (isMissing ? "Missing" : isFloating ? "Floating image" : "Image")),
|
|
381
|
-
];
|
|
382
|
-
},
|
|
383
|
-
},
|
|
384
|
-
|
|
385
|
-
sdt_block: {
|
|
386
|
-
group: "block",
|
|
387
|
-
content: "block+",
|
|
388
|
-
isolating: true,
|
|
389
|
-
attrs: {
|
|
390
|
-
sdtType: { default: null },
|
|
391
|
-
alias: { default: null },
|
|
392
|
-
tag: { default: null },
|
|
393
|
-
lock: { default: null },
|
|
394
|
-
checkboxChecked: { default: null },
|
|
395
|
-
dateValue: { default: null },
|
|
396
|
-
dropdownItems: { default: null },
|
|
397
|
-
comboBoxItems: { default: null },
|
|
398
|
-
showingPlcHdr: { default: false },
|
|
399
|
-
},
|
|
400
|
-
toDOM(node) {
|
|
401
|
-
const sdtType = node.attrs.sdtType as string | null;
|
|
402
|
-
const typeLabel = sdtType === "checkbox" ? "\u2611 Checkbox"
|
|
403
|
-
: sdtType === "date" ? "\uD83D\uDCC5 Date"
|
|
404
|
-
: sdtType === "dropDownList" ? "\u25BE Dropdown"
|
|
405
|
-
: sdtType === "comboBox" ? "\u25BE Combo box"
|
|
406
|
-
: sdtType === "plainText" ? "\u270E Plain text"
|
|
407
|
-
: sdtType === "richText" ? "\u270E Rich text"
|
|
408
|
-
: sdtType ?? undefined;
|
|
409
|
-
const meta = [node.attrs.alias, node.attrs.tag, typeLabel].filter(Boolean).join(" \u00B7 ");
|
|
410
|
-
return [
|
|
411
|
-
"section",
|
|
412
|
-
{
|
|
413
|
-
class: "my-2 rounded-xl border border-primary/15 bg-surface-raised/60 px-3 py-2",
|
|
414
|
-
"data-node-type": "sdt_block",
|
|
415
|
-
...(sdtType ? { "data-sdt-type": sdtType } : {}),
|
|
416
|
-
},
|
|
417
|
-
[
|
|
418
|
-
"div",
|
|
419
|
-
{
|
|
420
|
-
class: "mb-2 text-[11px] uppercase tracking-[0.18em] text-tertiary",
|
|
421
|
-
contenteditable: "false",
|
|
422
|
-
},
|
|
423
|
-
meta || "Content control",
|
|
424
|
-
],
|
|
425
|
-
["div", 0],
|
|
426
|
-
];
|
|
427
|
-
},
|
|
428
|
-
},
|
|
429
|
-
|
|
430
|
-
opaque_inline: {
|
|
431
|
-
inline: true,
|
|
432
|
-
group: "inline",
|
|
433
|
-
atom: true,
|
|
434
|
-
selectable: false,
|
|
435
|
-
attrs: {
|
|
436
|
-
fragmentId: { default: "" },
|
|
437
|
-
warningId: { default: "" },
|
|
438
|
-
label: { default: "Locked" },
|
|
439
|
-
detail: { default: "" },
|
|
440
|
-
presentation: { default: "inline-chip" },
|
|
441
|
-
},
|
|
442
|
-
toDOM(node) {
|
|
443
|
-
const presentation = node.attrs.presentation as string;
|
|
444
|
-
if (presentation === "quiet-marker") {
|
|
445
|
-
return [
|
|
446
|
-
"span",
|
|
447
|
-
{
|
|
448
|
-
class: "inline-block h-0 w-0 overflow-hidden align-baseline",
|
|
449
|
-
"data-node-type": "opaque_inline",
|
|
450
|
-
"data-inline-presentation": "quiet-marker",
|
|
451
|
-
contenteditable: "false",
|
|
452
|
-
title: node.attrs.detail as string,
|
|
453
|
-
"aria-label": node.attrs.label as string,
|
|
454
|
-
},
|
|
455
|
-
];
|
|
456
|
-
}
|
|
457
|
-
return [
|
|
458
|
-
"span",
|
|
459
|
-
{
|
|
460
|
-
class: "inline-flex items-center gap-1 mx-0.5 px-1.5 py-0.5 rounded text-xs text-comment bg-warning-soft",
|
|
461
|
-
"data-node-type": "opaque_inline",
|
|
462
|
-
"data-inline-presentation": "inline-chip",
|
|
463
|
-
title: node.attrs.detail as string,
|
|
464
|
-
},
|
|
465
|
-
"\uD83D\uDD12 " + (node.attrs.label as string),
|
|
466
|
-
];
|
|
467
|
-
},
|
|
468
|
-
},
|
|
469
|
-
|
|
470
|
-
field_ref_atom: {
|
|
471
|
-
inline: true,
|
|
472
|
-
group: "inline",
|
|
473
|
-
atom: true,
|
|
474
|
-
selectable: false,
|
|
475
|
-
attrs: {
|
|
476
|
-
fieldFamily: { default: "REF" },
|
|
477
|
-
fieldTarget: { default: null },
|
|
478
|
-
instruction: { default: "" },
|
|
479
|
-
refreshStatus: { default: "stale" },
|
|
480
|
-
label: { default: "Field" },
|
|
481
|
-
},
|
|
482
|
-
toDOM(node) {
|
|
483
|
-
const refreshStatus = node.attrs.refreshStatus as string;
|
|
484
|
-
const statusClass =
|
|
485
|
-
refreshStatus === "current"
|
|
486
|
-
? "text-blue-700 bg-blue-50 border-blue-200"
|
|
487
|
-
: refreshStatus === "unresolvable"
|
|
488
|
-
? "text-amber-800 bg-amber-50 border-amber-200"
|
|
489
|
-
: "text-slate-700 bg-slate-50 border-slate-200";
|
|
490
|
-
return [
|
|
491
|
-
"span",
|
|
492
|
-
{
|
|
493
|
-
class: `inline-flex items-center gap-1 mx-0.5 px-1.5 py-0.5 rounded text-xs border ${statusClass}`,
|
|
494
|
-
"data-node-type": "field_ref_atom",
|
|
495
|
-
"data-field-family": node.attrs.fieldFamily as string,
|
|
496
|
-
title: node.attrs.instruction as string,
|
|
497
|
-
},
|
|
498
|
-
(node.attrs.label as string) || "Field",
|
|
499
|
-
];
|
|
500
|
-
},
|
|
501
|
-
},
|
|
502
|
-
|
|
503
|
-
table: tableNodeSpec,
|
|
504
|
-
table_row: tableRowNodeSpec,
|
|
505
|
-
table_cell: tableCellNodeSpec,
|
|
506
|
-
table_header_cell: tableHeaderCellNodeSpec,
|
|
507
|
-
|
|
508
|
-
// ---- Complex rendering atoms (read-only previews) ----
|
|
509
|
-
|
|
510
|
-
chart_atom: {
|
|
511
|
-
inline: true,
|
|
512
|
-
group: "inline",
|
|
513
|
-
atom: true,
|
|
514
|
-
selectable: false,
|
|
515
|
-
attrs: {
|
|
516
|
-
previewMediaId: { default: null },
|
|
517
|
-
detail: { default: null },
|
|
518
|
-
},
|
|
519
|
-
toDOM(node) {
|
|
520
|
-
return [
|
|
521
|
-
"span",
|
|
522
|
-
{
|
|
523
|
-
class: "inline-flex items-center gap-1 mx-0.5 px-1.5 py-0.5 rounded text-xs text-blue-700 bg-blue-50 border border-blue-200",
|
|
524
|
-
"data-node-type": "chart_atom",
|
|
525
|
-
contenteditable: "false",
|
|
526
|
-
title: (node.attrs.detail as string) ?? "Chart",
|
|
527
|
-
},
|
|
528
|
-
"\uD83D\uDCC8 Chart",
|
|
529
|
-
];
|
|
530
|
-
},
|
|
531
|
-
},
|
|
532
|
-
|
|
533
|
-
smartart_atom: {
|
|
534
|
-
inline: true,
|
|
535
|
-
group: "inline",
|
|
536
|
-
atom: true,
|
|
537
|
-
selectable: false,
|
|
538
|
-
attrs: {
|
|
539
|
-
previewMediaId: { default: null },
|
|
540
|
-
detail: { default: null },
|
|
541
|
-
},
|
|
542
|
-
toDOM(node) {
|
|
543
|
-
return [
|
|
544
|
-
"span",
|
|
545
|
-
{
|
|
546
|
-
class: "inline-flex items-center gap-1 mx-0.5 px-1.5 py-0.5 rounded text-xs text-purple-700 bg-purple-50 border border-purple-200",
|
|
547
|
-
"data-node-type": "smartart_atom",
|
|
548
|
-
contenteditable: "false",
|
|
549
|
-
title: (node.attrs.detail as string) ?? "SmartArt",
|
|
550
|
-
},
|
|
551
|
-
"\uD83D\uDDFA SmartArt",
|
|
552
|
-
];
|
|
553
|
-
},
|
|
554
|
-
},
|
|
555
|
-
|
|
556
|
-
shape_atom: {
|
|
557
|
-
inline: true,
|
|
558
|
-
group: "inline",
|
|
559
|
-
atom: true,
|
|
560
|
-
selectable: true,
|
|
561
|
-
attrs: {
|
|
562
|
-
text: { default: null },
|
|
563
|
-
geometry: { default: null },
|
|
564
|
-
detail: { default: null },
|
|
565
|
-
},
|
|
566
|
-
toDOM(node) {
|
|
567
|
-
const text = node.attrs.text as string | null;
|
|
568
|
-
const label = text ? `Shape: ${text}` : "Shape";
|
|
569
|
-
return [
|
|
570
|
-
"span",
|
|
571
|
-
{
|
|
572
|
-
class: "inline-flex items-center gap-1 mx-0.5 px-1.5 py-0.5 rounded text-xs text-green-700 bg-green-50 border border-green-200",
|
|
573
|
-
"data-node-type": "shape_atom",
|
|
574
|
-
contenteditable: "false",
|
|
575
|
-
title: (node.attrs.detail as string) ?? label,
|
|
576
|
-
},
|
|
577
|
-
"\u25A1 " + label,
|
|
578
|
-
];
|
|
579
|
-
},
|
|
580
|
-
},
|
|
581
|
-
|
|
582
|
-
wordart_atom: {
|
|
583
|
-
inline: true,
|
|
584
|
-
group: "inline",
|
|
585
|
-
atom: true,
|
|
586
|
-
selectable: false,
|
|
587
|
-
attrs: {
|
|
588
|
-
text: { default: "" },
|
|
589
|
-
geometry: { default: null },
|
|
590
|
-
detail: { default: null },
|
|
591
|
-
},
|
|
592
|
-
toDOM(node) {
|
|
593
|
-
const text = node.attrs.text as string;
|
|
594
|
-
return [
|
|
595
|
-
"span",
|
|
596
|
-
{
|
|
597
|
-
class: "inline-flex items-center gap-1 mx-0.5 px-1.5 py-0.5 rounded text-xs text-orange-700 bg-orange-50 border border-orange-200 font-medium italic",
|
|
598
|
-
"data-node-type": "wordart_atom",
|
|
599
|
-
contenteditable: "false",
|
|
600
|
-
title: (node.attrs.detail as string) ?? `WordArt: ${text}`,
|
|
601
|
-
},
|
|
602
|
-
"\u2728 " + (text || "WordArt"),
|
|
603
|
-
];
|
|
604
|
-
},
|
|
605
|
-
},
|
|
606
|
-
|
|
607
|
-
vml_atom: {
|
|
608
|
-
inline: true,
|
|
609
|
-
group: "inline",
|
|
610
|
-
atom: true,
|
|
611
|
-
selectable: true,
|
|
612
|
-
attrs: {
|
|
613
|
-
text: { default: null },
|
|
614
|
-
shapeType: { default: null },
|
|
615
|
-
detail: { default: null },
|
|
616
|
-
},
|
|
617
|
-
toDOM(node) {
|
|
618
|
-
const text = node.attrs.text as string | null;
|
|
619
|
-
const label = text ? `VML: ${text}` : "VML shape";
|
|
620
|
-
return [
|
|
621
|
-
"span",
|
|
622
|
-
{
|
|
623
|
-
class: "inline-flex items-center gap-1 mx-0.5 px-1.5 py-0.5 rounded text-xs text-gray-600 bg-gray-100 border border-gray-300",
|
|
624
|
-
"data-node-type": "vml_atom",
|
|
625
|
-
contenteditable: "false",
|
|
626
|
-
title: (node.attrs.detail as string) ?? label,
|
|
627
|
-
},
|
|
628
|
-
"\u25A6 " + label,
|
|
629
|
-
];
|
|
630
|
-
},
|
|
631
|
-
},
|
|
632
|
-
|
|
633
|
-
opaque_block: {
|
|
634
|
-
group: "block",
|
|
635
|
-
atom: true,
|
|
636
|
-
selectable: false,
|
|
637
|
-
attrs: {
|
|
638
|
-
fragmentId: { default: "" },
|
|
639
|
-
warningId: { default: "" },
|
|
640
|
-
label: { default: "Locked" },
|
|
641
|
-
detail: { default: "" },
|
|
642
|
-
},
|
|
643
|
-
toDOM(node) {
|
|
644
|
-
const fragmentId = node.attrs.fragmentId as string;
|
|
645
|
-
const isPreview = fragmentId.startsWith("preview:");
|
|
646
|
-
return [
|
|
647
|
-
"div",
|
|
648
|
-
{
|
|
649
|
-
class: isPreview
|
|
650
|
-
? "my-3 rounded-xl border border-primary/15 bg-surface-raised/50 px-4 py-3"
|
|
651
|
-
: "border-l-2 border-dashed border-warning/30 pl-4 py-2 rounded-r bg-warning-soft/20 my-2",
|
|
652
|
-
contenteditable: "false",
|
|
653
|
-
"data-node-type": "opaque_block",
|
|
654
|
-
},
|
|
655
|
-
[
|
|
656
|
-
"div",
|
|
657
|
-
{
|
|
658
|
-
class: isPreview
|
|
659
|
-
? "mb-2 text-[11px] uppercase tracking-[0.18em] text-tertiary"
|
|
660
|
-
: "flex items-center gap-1.5 text-xs text-tertiary mb-1",
|
|
661
|
-
},
|
|
662
|
-
`${isPreview ? "" : "\uD83D\uDD12 "}${node.attrs.label as string}`,
|
|
663
|
-
],
|
|
664
|
-
[
|
|
665
|
-
"p",
|
|
666
|
-
{
|
|
667
|
-
class: isPreview ? "text-sm text-secondary whitespace-pre-wrap leading-relaxed" : "text-sm text-secondary whitespace-pre-wrap",
|
|
668
|
-
},
|
|
669
|
-
node.attrs.detail as string,
|
|
670
|
-
],
|
|
671
|
-
];
|
|
672
|
-
},
|
|
673
|
-
},
|
|
674
|
-
},
|
|
675
|
-
|
|
676
|
-
marks: {
|
|
677
|
-
bold: {
|
|
678
|
-
parseDOM: [{ tag: "strong" }, { tag: "b" }],
|
|
679
|
-
toDOM() {
|
|
680
|
-
return ["strong", 0];
|
|
681
|
-
},
|
|
682
|
-
},
|
|
683
|
-
italic: {
|
|
684
|
-
parseDOM: [{ tag: "em" }, { tag: "i" }],
|
|
685
|
-
toDOM() {
|
|
686
|
-
return ["em", 0];
|
|
687
|
-
},
|
|
688
|
-
},
|
|
689
|
-
underline: {
|
|
690
|
-
parseDOM: [{ tag: "u" }],
|
|
691
|
-
toDOM() {
|
|
692
|
-
return ["u", 0];
|
|
693
|
-
},
|
|
694
|
-
},
|
|
695
|
-
strikethrough: {
|
|
696
|
-
parseDOM: [{ tag: "s" }, { tag: "del" }],
|
|
697
|
-
toDOM() {
|
|
698
|
-
return ["s", 0];
|
|
699
|
-
},
|
|
700
|
-
},
|
|
701
|
-
doubleStrikethrough: {
|
|
702
|
-
toDOM() {
|
|
703
|
-
return ["span", { style: "text-decoration: line-through double" }, 0];
|
|
704
|
-
},
|
|
705
|
-
},
|
|
706
|
-
vanish: {
|
|
707
|
-
toDOM() {
|
|
708
|
-
return [
|
|
709
|
-
"span",
|
|
710
|
-
{
|
|
711
|
-
style: "display: none",
|
|
712
|
-
"data-hidden-text": "true",
|
|
713
|
-
"aria-hidden": "true",
|
|
714
|
-
},
|
|
715
|
-
0,
|
|
716
|
-
];
|
|
717
|
-
},
|
|
718
|
-
},
|
|
719
|
-
emboss: {
|
|
720
|
-
toDOM() {
|
|
721
|
-
return ["span", { style: "text-shadow: 1px -1px 0 rgba(255,255,255,0.6), -1px 1px 0 rgba(0,0,0,0.2)" }, 0];
|
|
722
|
-
},
|
|
723
|
-
},
|
|
724
|
-
imprint: {
|
|
725
|
-
toDOM() {
|
|
726
|
-
return ["span", { style: "text-shadow: -1px 1px 0 rgba(255,255,255,0.6), 1px -1px 0 rgba(0,0,0,0.2)" }, 0];
|
|
727
|
-
},
|
|
728
|
-
},
|
|
729
|
-
shadow: {
|
|
730
|
-
toDOM() {
|
|
731
|
-
return ["span", { style: "text-shadow: 1px 1px 2px rgba(0,0,0,0.3)" }, 0];
|
|
732
|
-
},
|
|
733
|
-
},
|
|
734
|
-
superscript: {
|
|
735
|
-
excludes: "subscript",
|
|
736
|
-
parseDOM: [{ tag: "sup" }],
|
|
737
|
-
toDOM() {
|
|
738
|
-
return ["sup", 0];
|
|
739
|
-
},
|
|
740
|
-
},
|
|
741
|
-
subscript: {
|
|
742
|
-
excludes: "superscript",
|
|
743
|
-
parseDOM: [{ tag: "sub" }],
|
|
744
|
-
toDOM() {
|
|
745
|
-
return ["sub", 0];
|
|
746
|
-
},
|
|
747
|
-
},
|
|
748
|
-
small_caps: {
|
|
749
|
-
parseDOM: [
|
|
750
|
-
{
|
|
751
|
-
style: "font-variant",
|
|
752
|
-
getAttrs: (value) => (value === "small-caps" ? null : false),
|
|
753
|
-
},
|
|
754
|
-
],
|
|
755
|
-
toDOM() {
|
|
756
|
-
return ["span", { style: "font-variant: small-caps" }, 0];
|
|
757
|
-
},
|
|
758
|
-
},
|
|
759
|
-
all_caps: {
|
|
760
|
-
parseDOM: [
|
|
761
|
-
{
|
|
762
|
-
style: "text-transform",
|
|
763
|
-
getAttrs: (value) => (value === "uppercase" ? null : false),
|
|
764
|
-
},
|
|
765
|
-
],
|
|
766
|
-
toDOM() {
|
|
767
|
-
return ["span", { style: "text-transform: uppercase" }, 0];
|
|
768
|
-
},
|
|
769
|
-
},
|
|
770
|
-
char_spacing: {
|
|
771
|
-
attrs: { value: { default: 0 } },
|
|
772
|
-
toDOM(mark) {
|
|
773
|
-
const twips = mark.attrs.value as number;
|
|
774
|
-
return ["span", { style: `letter-spacing: ${twips / 20}px` }, 0];
|
|
775
|
-
},
|
|
776
|
-
},
|
|
777
|
-
font_kerning: {
|
|
778
|
-
attrs: { threshold: { default: 0 } },
|
|
779
|
-
toDOM() {
|
|
780
|
-
return ["span", { style: "font-kerning: normal" }, 0];
|
|
781
|
-
},
|
|
782
|
-
},
|
|
783
|
-
font_family: {
|
|
784
|
-
attrs: { family: { default: null } },
|
|
785
|
-
parseDOM: [
|
|
786
|
-
{
|
|
787
|
-
style: "font-family",
|
|
788
|
-
getAttrs: (value) => ({ family: (value as string).replace(/['"]/g, "") }),
|
|
789
|
-
},
|
|
790
|
-
],
|
|
791
|
-
toDOM(mark) {
|
|
792
|
-
const family = mark.attrs.family as string;
|
|
793
|
-
if (!SAFE_FONT_RE.test(family)) return ["span", 0];
|
|
794
|
-
return ["span", { style: `font-family: ${family}` }, 0];
|
|
795
|
-
},
|
|
796
|
-
},
|
|
797
|
-
font_size: {
|
|
798
|
-
attrs: { size: { default: null } },
|
|
799
|
-
parseDOM: [
|
|
800
|
-
{
|
|
801
|
-
style: "font-size",
|
|
802
|
-
getAttrs: (value) => {
|
|
803
|
-
const match = (value as string).match(/^(\d+(?:\.\d+)?)/);
|
|
804
|
-
return match ? { size: Number.parseFloat(match[1]) } : false;
|
|
805
|
-
},
|
|
806
|
-
},
|
|
807
|
-
],
|
|
808
|
-
toDOM(mark) {
|
|
809
|
-
return ["span", { style: `font-size: ${mark.attrs.size as number}pt` }, 0];
|
|
810
|
-
},
|
|
811
|
-
},
|
|
812
|
-
text_color: {
|
|
813
|
-
attrs: { color: { default: null } },
|
|
814
|
-
parseDOM: [
|
|
815
|
-
{
|
|
816
|
-
style: "color",
|
|
817
|
-
getAttrs: (value) => ({ color: value }),
|
|
818
|
-
},
|
|
819
|
-
],
|
|
820
|
-
toDOM(mark) {
|
|
821
|
-
const color = safeCssColor(mark.attrs.color as string);
|
|
822
|
-
if (!color) return ["span", 0];
|
|
823
|
-
return ["span", { style: `color: ${color}` }, 0];
|
|
824
|
-
},
|
|
825
|
-
},
|
|
826
|
-
highlight: {
|
|
827
|
-
attrs: { color: { default: "yellow" } },
|
|
828
|
-
parseDOM: [
|
|
829
|
-
{
|
|
830
|
-
tag: "mark",
|
|
831
|
-
getAttrs: (dom) => ({ color: (dom as HTMLElement).style.backgroundColor || "yellow" }),
|
|
832
|
-
},
|
|
833
|
-
],
|
|
834
|
-
toDOM(mark) {
|
|
835
|
-
const color = safeCssColor(mark.attrs.color as string);
|
|
836
|
-
if (!color) return ["mark", 0];
|
|
837
|
-
return ["mark", { style: `background-color: ${color}` }, 0];
|
|
838
|
-
},
|
|
839
|
-
},
|
|
840
|
-
link: {
|
|
841
|
-
attrs: { href: { default: "" } },
|
|
842
|
-
inclusive: false,
|
|
843
|
-
parseDOM: [
|
|
844
|
-
{
|
|
845
|
-
tag: "a[href]",
|
|
846
|
-
getAttrs(dom) {
|
|
847
|
-
return { href: sanitizeLinkHref((dom as HTMLElement).getAttribute("href")) ?? "" };
|
|
848
|
-
},
|
|
849
|
-
},
|
|
850
|
-
],
|
|
851
|
-
toDOM(mark) {
|
|
852
|
-
const href = sanitizeLinkHref(mark.attrs.href as string);
|
|
853
|
-
if (!href) {
|
|
854
|
-
return [
|
|
855
|
-
"span",
|
|
856
|
-
{
|
|
857
|
-
class: "text-accent underline decoration-1 underline-offset-2",
|
|
858
|
-
"data-invalid-link": "true",
|
|
859
|
-
},
|
|
860
|
-
0,
|
|
861
|
-
];
|
|
862
|
-
}
|
|
863
|
-
return [
|
|
864
|
-
"a",
|
|
865
|
-
{
|
|
866
|
-
href,
|
|
867
|
-
class: "text-accent underline decoration-1 underline-offset-2",
|
|
868
|
-
target: "_blank",
|
|
869
|
-
rel: "noopener noreferrer",
|
|
870
|
-
},
|
|
871
|
-
0,
|
|
872
|
-
];
|
|
873
|
-
},
|
|
874
|
-
},
|
|
875
|
-
},
|
|
876
|
-
});
|