@beyondwork/docx-react-component 1.0.27 → 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 +64 -54
- package/src/README.md +0 -85
- package/src/api/README.md +0 -26
- package/src/api/public-types.ts +0 -1418
- 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/collab-review-sync.ts +0 -254
- 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 -4097
- 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 -63
- 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-collab-plugins.ts +0 -40
- package/src/ui-tailwind/editor-surface/pm-command-bridge.ts +0 -178
- 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 -973
- 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,124 +1,60 @@
|
|
|
1
|
-
import { createSelectionSnapshot, type CanonicalDocumentEnvelope, type SelectionSnapshot } from "./editor-state.ts";
|
|
2
|
-
import type { TransactionMapping } from "../selection/mapping.ts";
|
|
3
1
|
import {
|
|
4
2
|
cloneParagraphProperties,
|
|
5
3
|
cloneStoryUnit,
|
|
6
4
|
createPlainText,
|
|
7
5
|
parseTextStory,
|
|
8
|
-
serializeTextStory
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
} from "
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
export type TextInsertion =
|
|
17
|
-
| {
|
|
18
|
-
type: "text";
|
|
19
|
-
text: string;
|
|
20
|
-
}
|
|
21
|
-
| {
|
|
22
|
-
type: "tab";
|
|
23
|
-
}
|
|
24
|
-
| {
|
|
25
|
-
type: "hard_break";
|
|
26
|
-
}
|
|
27
|
-
| {
|
|
28
|
-
type: "paragraph_break";
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export type TextTransactionIntent =
|
|
32
|
-
| {
|
|
33
|
-
type: "replace";
|
|
34
|
-
range?: {
|
|
35
|
-
from: number;
|
|
36
|
-
to: number;
|
|
37
|
-
};
|
|
38
|
-
insertion: TextInsertion[];
|
|
39
|
-
}
|
|
40
|
-
| {
|
|
41
|
-
type: "delete_backward";
|
|
42
|
-
}
|
|
43
|
-
| {
|
|
44
|
-
type: "delete_forward";
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
export interface TextTransactionResult {
|
|
48
|
-
document: CanonicalDocumentEnvelope;
|
|
49
|
-
selection: SelectionSnapshot;
|
|
50
|
-
mapping: TransactionMapping;
|
|
51
|
-
storyText: string;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export class TextTransactionError extends Error {
|
|
55
|
-
readonly code: "invalid_selection" | "unsupported_content";
|
|
6
|
+
serializeTextStory
|
|
7
|
+
} from "./chunk-KLMXQVYK.js";
|
|
8
|
+
import {
|
|
9
|
+
createEditorSurfaceSnapshot
|
|
10
|
+
} from "./chunk-EILUG3VB.js";
|
|
11
|
+
import {
|
|
12
|
+
createSelectionSnapshot
|
|
13
|
+
} from "./chunk-5FN54NDH.js";
|
|
56
14
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
) {
|
|
15
|
+
// src/core/state/text-transaction.ts
|
|
16
|
+
var TextTransactionError = class extends Error {
|
|
17
|
+
code;
|
|
18
|
+
constructor(code, message) {
|
|
61
19
|
super(message);
|
|
62
20
|
this.name = "TextTransactionError";
|
|
63
21
|
this.code = code;
|
|
64
22
|
}
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
export function applyTextTransaction(
|
|
68
|
-
document: CanonicalDocumentEnvelope,
|
|
69
|
-
selection: SelectionSnapshot,
|
|
70
|
-
intent: TextTransactionIntent,
|
|
71
|
-
options: {
|
|
72
|
-
timestamp: string;
|
|
73
|
-
},
|
|
74
|
-
): TextTransactionResult {
|
|
23
|
+
};
|
|
24
|
+
function applyTextTransaction(document, selection, intent, options) {
|
|
75
25
|
const tableScopedResult = tryApplyTableParagraphTransaction(
|
|
76
26
|
document,
|
|
77
27
|
selection,
|
|
78
28
|
intent,
|
|
79
|
-
options
|
|
29
|
+
options
|
|
80
30
|
);
|
|
81
31
|
if (tableScopedResult) {
|
|
82
32
|
return tableScopedResult;
|
|
83
33
|
}
|
|
84
|
-
|
|
85
34
|
return applyLinearTextTransaction(document, selection, intent, options);
|
|
86
35
|
}
|
|
87
|
-
|
|
88
|
-
function applyLinearTextTransaction(
|
|
89
|
-
document: CanonicalDocumentEnvelope,
|
|
90
|
-
selection: SelectionSnapshot,
|
|
91
|
-
intent: TextTransactionIntent,
|
|
92
|
-
options: {
|
|
93
|
-
timestamp: string;
|
|
94
|
-
},
|
|
95
|
-
): TextTransactionResult {
|
|
36
|
+
function applyLinearTextTransaction(document, selection, intent, options) {
|
|
96
37
|
const story = parseTextStory(document.content);
|
|
97
38
|
const normalizedRange = resolveRange(selection, story.size, intent);
|
|
98
39
|
const insertionUnits = createInsertionUnits(intent, story, normalizedRange.from);
|
|
99
|
-
|
|
100
40
|
ensureEditableRange(story.units.slice(normalizedRange.from, normalizedRange.to));
|
|
101
|
-
|
|
102
41
|
const nextUnits = [
|
|
103
42
|
...story.units.slice(0, normalizedRange.from).map(cloneStoryUnit),
|
|
104
43
|
...insertionUnits.map(cloneStoryUnit),
|
|
105
|
-
...story.units.slice(normalizedRange.to).map(cloneStoryUnit)
|
|
44
|
+
...story.units.slice(normalizedRange.to).map(cloneStoryUnit)
|
|
106
45
|
];
|
|
107
|
-
|
|
108
|
-
const nextStory: TextStory = {
|
|
46
|
+
const nextStory = {
|
|
109
47
|
firstParagraph: cloneParagraphProperties(story.firstParagraph),
|
|
110
48
|
units: normalizeStoryUnits(nextUnits),
|
|
111
|
-
size: 0
|
|
49
|
+
size: 0
|
|
112
50
|
};
|
|
113
51
|
nextStory.size = nextStory.units.length;
|
|
114
|
-
|
|
115
52
|
const caret = normalizedRange.from + insertionUnits.length;
|
|
116
|
-
|
|
117
53
|
return {
|
|
118
54
|
document: {
|
|
119
55
|
...document,
|
|
120
56
|
updatedAt: options.timestamp,
|
|
121
|
-
content: serializeTextStory(nextStory)
|
|
57
|
+
content: serializeTextStory(nextStory)
|
|
122
58
|
},
|
|
123
59
|
selection: createSelectionSnapshot(caret, caret),
|
|
124
60
|
mapping: {
|
|
@@ -126,29 +62,19 @@ function applyLinearTextTransaction(
|
|
|
126
62
|
{
|
|
127
63
|
from: normalizedRange.from,
|
|
128
64
|
to: normalizedRange.to,
|
|
129
|
-
insertSize: insertionUnits.length
|
|
130
|
-
}
|
|
65
|
+
insertSize: insertionUnits.length
|
|
66
|
+
}
|
|
131
67
|
],
|
|
132
68
|
metadata: {
|
|
133
69
|
affectsComments: true,
|
|
134
70
|
affectsRevisions: true,
|
|
135
|
-
...
|
|
136
|
-
|
|
137
|
-
: {}),
|
|
138
|
-
},
|
|
71
|
+
...containsParagraphBoundaryChange(story, normalizedRange, insertionUnits) ? { invalidatesStructures: true } : {}
|
|
72
|
+
}
|
|
139
73
|
},
|
|
140
|
-
storyText: createPlainText(nextStory)
|
|
74
|
+
storyText: createPlainText(nextStory)
|
|
141
75
|
};
|
|
142
76
|
}
|
|
143
|
-
|
|
144
|
-
function tryApplyTableParagraphTransaction(
|
|
145
|
-
document: CanonicalDocumentEnvelope,
|
|
146
|
-
selection: SelectionSnapshot,
|
|
147
|
-
intent: TextTransactionIntent,
|
|
148
|
-
options: {
|
|
149
|
-
timestamp: string;
|
|
150
|
-
},
|
|
151
|
-
): TextTransactionResult | null {
|
|
77
|
+
function tryApplyTableParagraphTransaction(document, selection, intent, options) {
|
|
152
78
|
const scope = resolveTableParagraphScope(document, selection);
|
|
153
79
|
if (!scope) {
|
|
154
80
|
return null;
|
|
@@ -156,158 +82,126 @@ function tryApplyTableParagraphTransaction(
|
|
|
156
82
|
if (scope === "unsupported") {
|
|
157
83
|
throw new TextTransactionError(
|
|
158
84
|
"unsupported_content",
|
|
159
|
-
"Text transactions inside table structures are only supported when the selection stays within one paragraph-backed table cell."
|
|
85
|
+
"Text transactions inside table structures are only supported when the selection stays within one paragraph-backed table cell."
|
|
160
86
|
);
|
|
161
87
|
}
|
|
162
|
-
|
|
163
|
-
const localDocument: CanonicalDocumentEnvelope = {
|
|
88
|
+
const localDocument = {
|
|
164
89
|
...document,
|
|
165
90
|
content: {
|
|
166
91
|
type: "doc",
|
|
167
|
-
children: [scope.paragraph]
|
|
168
|
-
}
|
|
92
|
+
children: [scope.paragraph]
|
|
93
|
+
}
|
|
169
94
|
};
|
|
170
95
|
const localSelection = createSelectionSnapshot(
|
|
171
96
|
selection.anchor - scope.paragraphStart,
|
|
172
|
-
selection.head - scope.paragraphStart
|
|
97
|
+
selection.head - scope.paragraphStart
|
|
173
98
|
);
|
|
174
99
|
const localResult = applyLinearTextTransaction(localDocument, localSelection, intent, options);
|
|
175
|
-
const nextParagraphBlocks =
|
|
176
|
-
const nextRoot
|
|
100
|
+
const nextParagraphBlocks = localResult.document.content.children;
|
|
101
|
+
const nextRoot = {
|
|
177
102
|
...scope.root,
|
|
178
103
|
children: scope.root.children.map((child, blockIndex) => {
|
|
179
104
|
if (blockIndex !== scope.tableBlockIndex) {
|
|
180
105
|
return child;
|
|
181
106
|
}
|
|
182
|
-
|
|
183
|
-
const table = child as TableNode;
|
|
107
|
+
const table = child;
|
|
184
108
|
return {
|
|
185
109
|
...table,
|
|
186
110
|
rows: table.rows.map((row, rowIndex) => {
|
|
187
111
|
if (rowIndex !== scope.rowIndex) {
|
|
188
112
|
return row;
|
|
189
113
|
}
|
|
190
|
-
|
|
191
114
|
return {
|
|
192
115
|
...row,
|
|
193
116
|
cells: row.cells.map((cell, cellIndex) => {
|
|
194
117
|
if (cellIndex !== scope.cellIndex) {
|
|
195
118
|
return cell;
|
|
196
119
|
}
|
|
197
|
-
|
|
198
120
|
return {
|
|
199
121
|
...cell,
|
|
200
122
|
children: [
|
|
201
123
|
...cell.children.slice(0, scope.childIndex),
|
|
202
124
|
...nextParagraphBlocks,
|
|
203
|
-
...cell.children.slice(scope.childIndex + 1)
|
|
204
|
-
]
|
|
125
|
+
...cell.children.slice(scope.childIndex + 1)
|
|
126
|
+
]
|
|
205
127
|
};
|
|
206
|
-
})
|
|
128
|
+
})
|
|
207
129
|
};
|
|
208
|
-
})
|
|
130
|
+
})
|
|
209
131
|
};
|
|
210
|
-
})
|
|
132
|
+
})
|
|
211
133
|
};
|
|
212
|
-
|
|
213
134
|
return {
|
|
214
135
|
document: {
|
|
215
136
|
...document,
|
|
216
137
|
updatedAt: options.timestamp,
|
|
217
|
-
content: nextRoot
|
|
138
|
+
content: nextRoot
|
|
218
139
|
},
|
|
219
140
|
selection: createSelectionSnapshot(
|
|
220
141
|
localResult.selection.anchor + scope.paragraphStart,
|
|
221
|
-
localResult.selection.head + scope.paragraphStart
|
|
142
|
+
localResult.selection.head + scope.paragraphStart
|
|
222
143
|
),
|
|
223
144
|
mapping: {
|
|
224
145
|
...localResult.mapping,
|
|
225
146
|
steps: localResult.mapping.steps.map((step) => ({
|
|
226
147
|
...step,
|
|
227
148
|
from: step.from + scope.paragraphStart,
|
|
228
|
-
to: step.to + scope.paragraphStart
|
|
229
|
-
}))
|
|
149
|
+
to: step.to + scope.paragraphStart
|
|
150
|
+
}))
|
|
230
151
|
},
|
|
231
|
-
storyText: localResult.storyText
|
|
152
|
+
storyText: localResult.storyText
|
|
232
153
|
};
|
|
233
154
|
}
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
document: CanonicalDocumentEnvelope,
|
|
237
|
-
selection: SelectionSnapshot,
|
|
238
|
-
):
|
|
239
|
-
| {
|
|
240
|
-
root: DocumentRootNode;
|
|
241
|
-
tableBlockIndex: number;
|
|
242
|
-
rowIndex: number;
|
|
243
|
-
cellIndex: number;
|
|
244
|
-
childIndex: number;
|
|
245
|
-
paragraph: ParagraphNode;
|
|
246
|
-
paragraphStart: number;
|
|
247
|
-
}
|
|
248
|
-
| "unsupported"
|
|
249
|
-
| null {
|
|
250
|
-
const root = document.content as DocumentRootNode;
|
|
155
|
+
function resolveTableParagraphScope(document, selection) {
|
|
156
|
+
const root = document.content;
|
|
251
157
|
if (!root || root.type !== "doc" || !Array.isArray(root.children)) {
|
|
252
158
|
return null;
|
|
253
159
|
}
|
|
254
|
-
|
|
255
160
|
const surface = createEditorSurfaceSnapshot(document, selection);
|
|
256
161
|
const selectionFrom = Math.min(selection.anchor, selection.head);
|
|
257
162
|
const selectionTo = Math.max(selection.anchor, selection.head);
|
|
258
|
-
|
|
259
163
|
for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {
|
|
260
164
|
const block = root.children[blockIndex];
|
|
261
165
|
const surfaceBlock = surface.blocks[blockIndex];
|
|
262
166
|
if (block?.type !== "table" || surfaceBlock?.kind !== "table") {
|
|
263
167
|
continue;
|
|
264
168
|
}
|
|
265
|
-
|
|
266
169
|
const insideTable = selectionFallsWithinSurfaceRange(
|
|
267
170
|
selectionFrom,
|
|
268
171
|
selectionTo,
|
|
269
172
|
surfaceBlock.from,
|
|
270
|
-
surfaceBlock.to
|
|
173
|
+
surfaceBlock.to
|
|
271
174
|
);
|
|
272
175
|
if (!insideTable) {
|
|
273
176
|
continue;
|
|
274
177
|
}
|
|
275
|
-
|
|
276
178
|
for (let rowIndex = 0; rowIndex < block.rows.length; rowIndex += 1) {
|
|
277
179
|
const row = block.rows[rowIndex];
|
|
278
180
|
const surfaceRow = surfaceBlock.rows[rowIndex];
|
|
279
181
|
if (!row || !surfaceRow) {
|
|
280
182
|
continue;
|
|
281
183
|
}
|
|
282
|
-
|
|
283
184
|
for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {
|
|
284
185
|
const cell = row.cells[cellIndex];
|
|
285
186
|
const surfaceCell = surfaceRow.cells[cellIndex];
|
|
286
187
|
if (!cell || !surfaceCell) {
|
|
287
188
|
continue;
|
|
288
189
|
}
|
|
289
|
-
|
|
290
|
-
for (
|
|
291
|
-
let childIndex = 0;
|
|
292
|
-
childIndex < Math.min(cell.children.length, surfaceCell.content.length);
|
|
293
|
-
childIndex += 1
|
|
294
|
-
) {
|
|
190
|
+
for (let childIndex = 0; childIndex < Math.min(cell.children.length, surfaceCell.content.length); childIndex += 1) {
|
|
295
191
|
const child = cell.children[childIndex];
|
|
296
192
|
const surfaceChild = surfaceCell.content[childIndex];
|
|
297
193
|
if (child?.type !== "paragraph" || surfaceChild?.kind !== "paragraph") {
|
|
298
194
|
continue;
|
|
299
195
|
}
|
|
300
|
-
|
|
301
196
|
const insideParagraph = selectionFallsWithinSurfaceRange(
|
|
302
197
|
selectionFrom,
|
|
303
198
|
selectionTo,
|
|
304
199
|
surfaceChild.from,
|
|
305
|
-
surfaceChild.to
|
|
200
|
+
surfaceChild.to
|
|
306
201
|
);
|
|
307
202
|
if (!insideParagraph) {
|
|
308
203
|
continue;
|
|
309
204
|
}
|
|
310
|
-
|
|
311
205
|
return {
|
|
312
206
|
root,
|
|
313
207
|
tableBlockIndex: blockIndex,
|
|
@@ -315,50 +209,30 @@ function resolveTableParagraphScope(
|
|
|
315
209
|
cellIndex,
|
|
316
210
|
childIndex,
|
|
317
211
|
paragraph: child,
|
|
318
|
-
paragraphStart: surfaceChild.from
|
|
212
|
+
paragraphStart: surfaceChild.from
|
|
319
213
|
};
|
|
320
214
|
}
|
|
321
215
|
}
|
|
322
216
|
}
|
|
323
|
-
|
|
324
217
|
return "unsupported";
|
|
325
218
|
}
|
|
326
|
-
|
|
327
219
|
return null;
|
|
328
220
|
}
|
|
329
|
-
|
|
330
|
-
function selectionFallsWithinSurfaceRange(
|
|
331
|
-
selectionFrom: number,
|
|
332
|
-
selectionTo: number,
|
|
333
|
-
rangeFrom: number,
|
|
334
|
-
rangeTo: number,
|
|
335
|
-
): boolean {
|
|
221
|
+
function selectionFallsWithinSurfaceRange(selectionFrom, selectionTo, rangeFrom, rangeTo) {
|
|
336
222
|
if (rangeFrom === rangeTo) {
|
|
337
223
|
return selectionFrom === rangeFrom && selectionTo === rangeTo;
|
|
338
224
|
}
|
|
339
|
-
|
|
340
|
-
return (
|
|
341
|
-
selectionFrom >= rangeFrom &&
|
|
342
|
-
selectionTo <= rangeTo &&
|
|
343
|
-
selectionFrom < rangeTo
|
|
344
|
-
);
|
|
225
|
+
return selectionFrom >= rangeFrom && selectionTo <= rangeTo && selectionFrom < rangeTo;
|
|
345
226
|
}
|
|
346
|
-
|
|
347
|
-
function resolveRange(
|
|
348
|
-
selection: SelectionSnapshot,
|
|
349
|
-
storySize: number,
|
|
350
|
-
intent: TextTransactionIntent,
|
|
351
|
-
): { from: number; to: number } {
|
|
227
|
+
function resolveRange(selection, storySize, intent) {
|
|
352
228
|
const from = Math.max(0, Math.min(selection.anchor, selection.head));
|
|
353
229
|
const to = Math.max(0, Math.max(selection.anchor, selection.head));
|
|
354
|
-
|
|
355
230
|
if (from > storySize || to > storySize) {
|
|
356
231
|
throw new TextTransactionError(
|
|
357
232
|
"invalid_selection",
|
|
358
|
-
`Selection ${from}-${to} exceeds story size ${storySize}
|
|
233
|
+
`Selection ${from}-${to} exceeds story size ${storySize}.`
|
|
359
234
|
);
|
|
360
235
|
}
|
|
361
|
-
|
|
362
236
|
if (intent.type === "replace") {
|
|
363
237
|
if (intent.range) {
|
|
364
238
|
const explicitFrom = Math.max(0, Math.min(intent.range.from, intent.range.to));
|
|
@@ -366,53 +240,41 @@ function resolveRange(
|
|
|
366
240
|
if (explicitFrom > storySize || explicitTo > storySize) {
|
|
367
241
|
throw new TextTransactionError(
|
|
368
242
|
"invalid_selection",
|
|
369
|
-
`Explicit range ${explicitFrom}-${explicitTo} exceeds story size ${storySize}
|
|
243
|
+
`Explicit range ${explicitFrom}-${explicitTo} exceeds story size ${storySize}.`
|
|
370
244
|
);
|
|
371
245
|
}
|
|
372
|
-
|
|
373
246
|
return {
|
|
374
247
|
from: explicitFrom,
|
|
375
|
-
to: explicitTo
|
|
248
|
+
to: explicitTo
|
|
376
249
|
};
|
|
377
250
|
}
|
|
378
|
-
|
|
379
251
|
return { from, to };
|
|
380
252
|
}
|
|
381
|
-
|
|
382
253
|
if (from !== to) {
|
|
383
254
|
return { from, to };
|
|
384
255
|
}
|
|
385
|
-
|
|
386
256
|
if (intent.type === "delete_backward") {
|
|
387
257
|
return {
|
|
388
258
|
from: Math.max(0, from - 1),
|
|
389
|
-
to: from
|
|
259
|
+
to: from
|
|
390
260
|
};
|
|
391
261
|
}
|
|
392
|
-
|
|
393
262
|
return {
|
|
394
263
|
from,
|
|
395
|
-
to: Math.min(storySize, from + 1)
|
|
264
|
+
to: Math.min(storySize, from + 1)
|
|
396
265
|
};
|
|
397
266
|
}
|
|
398
|
-
|
|
399
|
-
function createInsertionUnits(
|
|
400
|
-
intent: TextTransactionIntent,
|
|
401
|
-
story: TextStory,
|
|
402
|
-
position: number,
|
|
403
|
-
): StoryUnit[] {
|
|
267
|
+
function createInsertionUnits(intent, story, position) {
|
|
404
268
|
if (intent.type !== "replace") {
|
|
405
269
|
return [];
|
|
406
270
|
}
|
|
407
|
-
|
|
408
271
|
const inheritedProps = resolveParagraphPropertiesAtPosition(story, position);
|
|
409
|
-
|
|
410
272
|
return intent.insertion.flatMap((entry) => {
|
|
411
273
|
switch (entry.type) {
|
|
412
274
|
case "text":
|
|
413
|
-
return Array.from(entry.text).map
|
|
275
|
+
return Array.from(entry.text).map((character) => ({
|
|
414
276
|
kind: "text",
|
|
415
|
-
value: character
|
|
277
|
+
value: character
|
|
416
278
|
}));
|
|
417
279
|
case "tab":
|
|
418
280
|
return [{ kind: "tab" }];
|
|
@@ -422,19 +284,14 @@ function createInsertionUnits(
|
|
|
422
284
|
return [
|
|
423
285
|
{
|
|
424
286
|
kind: "paragraph_break",
|
|
425
|
-
nextParagraph: cloneParagraphProperties(inheritedProps)
|
|
426
|
-
}
|
|
287
|
+
nextParagraph: cloneParagraphProperties(inheritedProps)
|
|
288
|
+
}
|
|
427
289
|
];
|
|
428
290
|
}
|
|
429
291
|
});
|
|
430
292
|
}
|
|
431
|
-
|
|
432
|
-
function resolveParagraphPropertiesAtPosition(
|
|
433
|
-
story: TextStory,
|
|
434
|
-
position: number,
|
|
435
|
-
): ParagraphProperties {
|
|
293
|
+
function resolveParagraphPropertiesAtPosition(story, position) {
|
|
436
294
|
let current = cloneParagraphProperties(story.firstParagraph);
|
|
437
|
-
|
|
438
295
|
for (let index = 0; index < Math.min(position, story.units.length); index += 1) {
|
|
439
296
|
const unit = story.units[index];
|
|
440
297
|
if (unit.kind === "paragraph_break") {
|
|
@@ -443,60 +300,46 @@ function resolveParagraphPropertiesAtPosition(
|
|
|
443
300
|
current = cloneParagraphProperties(unit.nextParagraph);
|
|
444
301
|
}
|
|
445
302
|
}
|
|
446
|
-
|
|
447
303
|
return current;
|
|
448
304
|
}
|
|
449
|
-
|
|
450
|
-
function normalizeStoryUnits(units: StoryUnit[]): StoryUnit[] {
|
|
305
|
+
function normalizeStoryUnits(units) {
|
|
451
306
|
if (units.length === 0) {
|
|
452
307
|
return [];
|
|
453
308
|
}
|
|
454
|
-
|
|
455
|
-
const normalized: StoryUnit[] = [];
|
|
456
|
-
|
|
309
|
+
const normalized = [];
|
|
457
310
|
for (const unit of units) {
|
|
458
|
-
if (
|
|
459
|
-
unit.kind === "paragraph_break" &&
|
|
460
|
-
normalized[normalized.length - 1]?.kind === "paragraph_break"
|
|
461
|
-
) {
|
|
311
|
+
if (unit.kind === "paragraph_break" && normalized[normalized.length - 1]?.kind === "paragraph_break") {
|
|
462
312
|
normalized.push({
|
|
463
313
|
kind: "paragraph_break",
|
|
464
|
-
nextParagraph: cloneParagraphProperties(unit.nextParagraph)
|
|
314
|
+
nextParagraph: cloneParagraphProperties(unit.nextParagraph)
|
|
465
315
|
});
|
|
466
316
|
continue;
|
|
467
317
|
}
|
|
468
|
-
|
|
469
318
|
normalized.push(cloneStoryUnit(unit));
|
|
470
319
|
}
|
|
471
|
-
|
|
472
320
|
return normalized;
|
|
473
321
|
}
|
|
474
|
-
|
|
475
|
-
function ensureEditableRange(units: StoryUnit[]): void {
|
|
322
|
+
function ensureEditableRange(units) {
|
|
476
323
|
const protectedUnit = units.find(
|
|
477
|
-
(unit) => unit.kind === "opaque_inline" || unit.kind === "opaque_block" || unit.kind === "image"
|
|
324
|
+
(unit) => unit.kind === "opaque_inline" || unit.kind === "opaque_block" || unit.kind === "image"
|
|
478
325
|
);
|
|
479
|
-
|
|
480
326
|
if (!protectedUnit) {
|
|
481
327
|
return;
|
|
482
328
|
}
|
|
483
|
-
|
|
484
329
|
throw new TextTransactionError(
|
|
485
330
|
"unsupported_content",
|
|
486
|
-
`Text transaction crosses protected ${protectedUnit.kind} content
|
|
331
|
+
`Text transaction crosses protected ${protectedUnit.kind} content.`
|
|
487
332
|
);
|
|
488
333
|
}
|
|
489
|
-
|
|
490
|
-
function containsParagraphBoundaryChange(
|
|
491
|
-
story: TextStory,
|
|
492
|
-
range: { from: number; to: number },
|
|
493
|
-
insertionUnits: StoryUnit[],
|
|
494
|
-
): boolean {
|
|
334
|
+
function containsParagraphBoundaryChange(story, range, insertionUnits) {
|
|
495
335
|
if (insertionUnits.some((unit) => unit.kind === "paragraph_break")) {
|
|
496
336
|
return true;
|
|
497
337
|
}
|
|
498
|
-
|
|
499
|
-
return story.units
|
|
500
|
-
.slice(range.from, range.to)
|
|
501
|
-
.some((unit) => unit.kind === "paragraph_break");
|
|
338
|
+
return story.units.slice(range.from, range.to).some((unit) => unit.kind === "paragraph_break");
|
|
502
339
|
}
|
|
340
|
+
|
|
341
|
+
export {
|
|
342
|
+
TextTransactionError,
|
|
343
|
+
applyTextTransaction
|
|
344
|
+
};
|
|
345
|
+
//# sourceMappingURL=chunk-QDAQ4CJU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/core/state/text-transaction.ts"],"sourcesContent":["import { createSelectionSnapshot, type CanonicalDocumentEnvelope, type SelectionSnapshot } from \"./editor-state.ts\";\nimport type { TransactionMapping } from \"../selection/mapping.ts\";\nimport {\n cloneParagraphProperties,\n cloneStoryUnit,\n createPlainText,\n parseTextStory,\n serializeTextStory,\n type ParagraphProperties,\n type StoryUnit,\n type TextStory,\n} from \"../schema/text-schema.ts\";\nimport { createEditorSurfaceSnapshot } from \"../../runtime/surface-projection.ts\";\nimport type { DocumentRootNode, ParagraphNode, TableNode } from \"../../model/canonical-document.ts\";\n\nexport type TextInsertion =\n | {\n type: \"text\";\n text: string;\n }\n | {\n type: \"tab\";\n }\n | {\n type: \"hard_break\";\n }\n | {\n type: \"paragraph_break\";\n };\n\nexport type TextTransactionIntent =\n | {\n type: \"replace\";\n range?: {\n from: number;\n to: number;\n };\n insertion: TextInsertion[];\n }\n | {\n type: \"delete_backward\";\n }\n | {\n type: \"delete_forward\";\n };\n\nexport interface TextTransactionResult {\n document: CanonicalDocumentEnvelope;\n selection: SelectionSnapshot;\n mapping: TransactionMapping;\n storyText: string;\n}\n\nexport class TextTransactionError extends Error {\n readonly code: \"invalid_selection\" | \"unsupported_content\";\n\n constructor(\n code: TextTransactionError[\"code\"],\n message: string,\n ) {\n super(message);\n this.name = \"TextTransactionError\";\n this.code = code;\n }\n}\n\nexport function applyTextTransaction(\n document: CanonicalDocumentEnvelope,\n selection: SelectionSnapshot,\n intent: TextTransactionIntent,\n options: {\n timestamp: string;\n },\n): TextTransactionResult {\n const tableScopedResult = tryApplyTableParagraphTransaction(\n document,\n selection,\n intent,\n options,\n );\n if (tableScopedResult) {\n return tableScopedResult;\n }\n\n return applyLinearTextTransaction(document, selection, intent, options);\n}\n\nfunction applyLinearTextTransaction(\n document: CanonicalDocumentEnvelope,\n selection: SelectionSnapshot,\n intent: TextTransactionIntent,\n options: {\n timestamp: string;\n },\n): TextTransactionResult {\n const story = parseTextStory(document.content);\n const normalizedRange = resolveRange(selection, story.size, intent);\n const insertionUnits = createInsertionUnits(intent, story, normalizedRange.from);\n\n ensureEditableRange(story.units.slice(normalizedRange.from, normalizedRange.to));\n\n const nextUnits = [\n ...story.units.slice(0, normalizedRange.from).map(cloneStoryUnit),\n ...insertionUnits.map(cloneStoryUnit),\n ...story.units.slice(normalizedRange.to).map(cloneStoryUnit),\n ];\n\n const nextStory: TextStory = {\n firstParagraph: cloneParagraphProperties(story.firstParagraph),\n units: normalizeStoryUnits(nextUnits),\n size: 0,\n };\n nextStory.size = nextStory.units.length;\n\n const caret = normalizedRange.from + insertionUnits.length;\n\n return {\n document: {\n ...document,\n updatedAt: options.timestamp,\n content: serializeTextStory(nextStory),\n },\n selection: createSelectionSnapshot(caret, caret),\n mapping: {\n steps: [\n {\n from: normalizedRange.from,\n to: normalizedRange.to,\n insertSize: insertionUnits.length,\n },\n ],\n metadata: {\n affectsComments: true,\n affectsRevisions: true,\n ...(containsParagraphBoundaryChange(story, normalizedRange, insertionUnits)\n ? { invalidatesStructures: true }\n : {}),\n },\n },\n storyText: createPlainText(nextStory),\n };\n}\n\nfunction tryApplyTableParagraphTransaction(\n document: CanonicalDocumentEnvelope,\n selection: SelectionSnapshot,\n intent: TextTransactionIntent,\n options: {\n timestamp: string;\n },\n): TextTransactionResult | null {\n const scope = resolveTableParagraphScope(document, selection);\n if (!scope) {\n return null;\n }\n if (scope === \"unsupported\") {\n throw new TextTransactionError(\n \"unsupported_content\",\n \"Text transactions inside table structures are only supported when the selection stays within one paragraph-backed table cell.\",\n );\n }\n\n const localDocument: CanonicalDocumentEnvelope = {\n ...document,\n content: {\n type: \"doc\",\n children: [scope.paragraph],\n },\n };\n const localSelection = createSelectionSnapshot(\n selection.anchor - scope.paragraphStart,\n selection.head - scope.paragraphStart,\n );\n const localResult = applyLinearTextTransaction(localDocument, localSelection, intent, options);\n const nextParagraphBlocks = (localResult.document.content as DocumentRootNode).children;\n const nextRoot: DocumentRootNode = {\n ...scope.root,\n children: scope.root.children.map((child, blockIndex) => {\n if (blockIndex !== scope.tableBlockIndex) {\n return child;\n }\n\n const table = child as TableNode;\n return {\n ...table,\n rows: table.rows.map((row, rowIndex) => {\n if (rowIndex !== scope.rowIndex) {\n return row;\n }\n\n return {\n ...row,\n cells: row.cells.map((cell, cellIndex) => {\n if (cellIndex !== scope.cellIndex) {\n return cell;\n }\n\n return {\n ...cell,\n children: [\n ...cell.children.slice(0, scope.childIndex),\n ...nextParagraphBlocks,\n ...cell.children.slice(scope.childIndex + 1),\n ],\n };\n }),\n };\n }),\n };\n }),\n };\n\n return {\n document: {\n ...document,\n updatedAt: options.timestamp,\n content: nextRoot,\n },\n selection: createSelectionSnapshot(\n localResult.selection.anchor + scope.paragraphStart,\n localResult.selection.head + scope.paragraphStart,\n ),\n mapping: {\n ...localResult.mapping,\n steps: localResult.mapping.steps.map((step) => ({\n ...step,\n from: step.from + scope.paragraphStart,\n to: step.to + scope.paragraphStart,\n })),\n },\n storyText: localResult.storyText,\n };\n}\n\nfunction resolveTableParagraphScope(\n document: CanonicalDocumentEnvelope,\n selection: SelectionSnapshot,\n):\n | {\n root: DocumentRootNode;\n tableBlockIndex: number;\n rowIndex: number;\n cellIndex: number;\n childIndex: number;\n paragraph: ParagraphNode;\n paragraphStart: number;\n }\n | \"unsupported\"\n | null {\n const root = document.content as DocumentRootNode;\n if (!root || root.type !== \"doc\" || !Array.isArray(root.children)) {\n return null;\n }\n\n const surface = createEditorSurfaceSnapshot(document, selection);\n const selectionFrom = Math.min(selection.anchor, selection.head);\n const selectionTo = Math.max(selection.anchor, selection.head);\n\n for (let blockIndex = 0; blockIndex < root.children.length; blockIndex += 1) {\n const block = root.children[blockIndex];\n const surfaceBlock = surface.blocks[blockIndex];\n if (block?.type !== \"table\" || surfaceBlock?.kind !== \"table\") {\n continue;\n }\n\n const insideTable = selectionFallsWithinSurfaceRange(\n selectionFrom,\n selectionTo,\n surfaceBlock.from,\n surfaceBlock.to,\n );\n if (!insideTable) {\n continue;\n }\n\n for (let rowIndex = 0; rowIndex < block.rows.length; rowIndex += 1) {\n const row = block.rows[rowIndex];\n const surfaceRow = surfaceBlock.rows[rowIndex];\n if (!row || !surfaceRow) {\n continue;\n }\n\n for (let cellIndex = 0; cellIndex < row.cells.length; cellIndex += 1) {\n const cell = row.cells[cellIndex];\n const surfaceCell = surfaceRow.cells[cellIndex];\n if (!cell || !surfaceCell) {\n continue;\n }\n\n for (\n let childIndex = 0;\n childIndex < Math.min(cell.children.length, surfaceCell.content.length);\n childIndex += 1\n ) {\n const child = cell.children[childIndex];\n const surfaceChild = surfaceCell.content[childIndex];\n if (child?.type !== \"paragraph\" || surfaceChild?.kind !== \"paragraph\") {\n continue;\n }\n\n const insideParagraph = selectionFallsWithinSurfaceRange(\n selectionFrom,\n selectionTo,\n surfaceChild.from,\n surfaceChild.to,\n );\n if (!insideParagraph) {\n continue;\n }\n\n return {\n root,\n tableBlockIndex: blockIndex,\n rowIndex,\n cellIndex,\n childIndex,\n paragraph: child,\n paragraphStart: surfaceChild.from,\n };\n }\n }\n }\n\n return \"unsupported\";\n }\n\n return null;\n}\n\nfunction selectionFallsWithinSurfaceRange(\n selectionFrom: number,\n selectionTo: number,\n rangeFrom: number,\n rangeTo: number,\n): boolean {\n if (rangeFrom === rangeTo) {\n return selectionFrom === rangeFrom && selectionTo === rangeTo;\n }\n\n return (\n selectionFrom >= rangeFrom &&\n selectionTo <= rangeTo &&\n selectionFrom < rangeTo\n );\n}\n\nfunction resolveRange(\n selection: SelectionSnapshot,\n storySize: number,\n intent: TextTransactionIntent,\n): { from: number; to: number } {\n const from = Math.max(0, Math.min(selection.anchor, selection.head));\n const to = Math.max(0, Math.max(selection.anchor, selection.head));\n\n if (from > storySize || to > storySize) {\n throw new TextTransactionError(\n \"invalid_selection\",\n `Selection ${from}-${to} exceeds story size ${storySize}.`,\n );\n }\n\n if (intent.type === \"replace\") {\n if (intent.range) {\n const explicitFrom = Math.max(0, Math.min(intent.range.from, intent.range.to));\n const explicitTo = Math.max(0, Math.max(intent.range.from, intent.range.to));\n if (explicitFrom > storySize || explicitTo > storySize) {\n throw new TextTransactionError(\n \"invalid_selection\",\n `Explicit range ${explicitFrom}-${explicitTo} exceeds story size ${storySize}.`,\n );\n }\n\n return {\n from: explicitFrom,\n to: explicitTo,\n };\n }\n\n return { from, to };\n }\n\n if (from !== to) {\n return { from, to };\n }\n\n if (intent.type === \"delete_backward\") {\n return {\n from: Math.max(0, from - 1),\n to: from,\n };\n }\n\n return {\n from,\n to: Math.min(storySize, from + 1),\n };\n}\n\nfunction createInsertionUnits(\n intent: TextTransactionIntent,\n story: TextStory,\n position: number,\n): StoryUnit[] {\n if (intent.type !== \"replace\") {\n return [];\n }\n\n const inheritedProps = resolveParagraphPropertiesAtPosition(story, position);\n\n return intent.insertion.flatMap((entry) => {\n switch (entry.type) {\n case \"text\":\n return Array.from(entry.text).map<StoryUnit>((character) => ({\n kind: \"text\",\n value: character,\n }));\n case \"tab\":\n return [{ kind: \"tab\" }];\n case \"hard_break\":\n return [{ kind: \"hard_break\" }];\n case \"paragraph_break\":\n return [\n {\n kind: \"paragraph_break\",\n nextParagraph: cloneParagraphProperties(inheritedProps),\n },\n ];\n }\n });\n}\n\nfunction resolveParagraphPropertiesAtPosition(\n story: TextStory,\n position: number,\n): ParagraphProperties {\n let current = cloneParagraphProperties(story.firstParagraph);\n\n for (let index = 0; index < Math.min(position, story.units.length); index += 1) {\n const unit = story.units[index];\n if (unit.kind === \"paragraph_break\") {\n current = cloneParagraphProperties(unit.nextParagraph);\n } else if (unit.kind === \"opaque_block\" && unit.nextParagraph) {\n current = cloneParagraphProperties(unit.nextParagraph);\n }\n }\n\n return current;\n}\n\nfunction normalizeStoryUnits(units: StoryUnit[]): StoryUnit[] {\n if (units.length === 0) {\n return [];\n }\n\n const normalized: StoryUnit[] = [];\n\n for (const unit of units) {\n if (\n unit.kind === \"paragraph_break\" &&\n normalized[normalized.length - 1]?.kind === \"paragraph_break\"\n ) {\n normalized.push({\n kind: \"paragraph_break\",\n nextParagraph: cloneParagraphProperties(unit.nextParagraph),\n });\n continue;\n }\n\n normalized.push(cloneStoryUnit(unit));\n }\n\n return normalized;\n}\n\nfunction ensureEditableRange(units: StoryUnit[]): void {\n const protectedUnit = units.find(\n (unit) => unit.kind === \"opaque_inline\" || unit.kind === \"opaque_block\" || unit.kind === \"image\",\n );\n\n if (!protectedUnit) {\n return;\n }\n\n throw new TextTransactionError(\n \"unsupported_content\",\n `Text transaction crosses protected ${protectedUnit.kind} content.`,\n );\n}\n\nfunction containsParagraphBoundaryChange(\n story: TextStory,\n range: { from: number; to: number },\n insertionUnits: StoryUnit[],\n): boolean {\n if (insertionUnits.some((unit) => unit.kind === \"paragraph_break\")) {\n return true;\n }\n\n return story.units\n .slice(range.from, range.to)\n .some((unit) => unit.kind === \"paragraph_break\");\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqDO,IAAM,uBAAN,cAAmC,MAAM;AAAA,EACrC;AAAA,EAET,YACE,MACA,SACA;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;AAEO,SAAS,qBACd,UACA,WACA,QACA,SAGuB;AACvB,QAAM,oBAAoB;AAAA,IACxB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACA,MAAI,mBAAmB;AACrB,WAAO;AAAA,EACT;AAEA,SAAO,2BAA2B,UAAU,WAAW,QAAQ,OAAO;AACxE;AAEA,SAAS,2BACP,UACA,WACA,QACA,SAGuB;AACvB,QAAM,QAAQ,eAAe,SAAS,OAAO;AAC7C,QAAM,kBAAkB,aAAa,WAAW,MAAM,MAAM,MAAM;AAClE,QAAM,iBAAiB,qBAAqB,QAAQ,OAAO,gBAAgB,IAAI;AAE/E,sBAAoB,MAAM,MAAM,MAAM,gBAAgB,MAAM,gBAAgB,EAAE,CAAC;AAE/E,QAAM,YAAY;AAAA,IAChB,GAAG,MAAM,MAAM,MAAM,GAAG,gBAAgB,IAAI,EAAE,IAAI,cAAc;AAAA,IAChE,GAAG,eAAe,IAAI,cAAc;AAAA,IACpC,GAAG,MAAM,MAAM,MAAM,gBAAgB,EAAE,EAAE,IAAI,cAAc;AAAA,EAC7D;AAEA,QAAM,YAAuB;AAAA,IAC3B,gBAAgB,yBAAyB,MAAM,cAAc;AAAA,IAC7D,OAAO,oBAAoB,SAAS;AAAA,IACpC,MAAM;AAAA,EACR;AACA,YAAU,OAAO,UAAU,MAAM;AAEjC,QAAM,QAAQ,gBAAgB,OAAO,eAAe;AAEpD,SAAO;AAAA,IACL,UAAU;AAAA,MACR,GAAG;AAAA,MACH,WAAW,QAAQ;AAAA,MACnB,SAAS,mBAAmB,SAAS;AAAA,IACvC;AAAA,IACA,WAAW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