plitejs 54.0.0-beta.2 → 54.0.0-beta.4
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/{internal/view/annotation-store-metrics.js → annotation-store-metrics-Ccjkef45.js} +1 -1
- package/dist/annotations/index.d.ts +1 -1
- package/dist/annotations/index.js +1 -1
- package/dist/authored/index.d.ts +596 -9
- package/dist/authored/index.js +18679 -4
- package/dist/{core/authored-veto.js → authored-veto-D_9wCJcK.js} +2 -2
- package/dist/{internal/browser-protocol.js → browser-protocol-pvt4HFF7.js} +1 -1
- package/dist/comparison-plan-DY_vuGPq.js +1338 -0
- package/dist/{diff/lib/comparison-types.d.ts → comparison-types-DdwE6mYq.d.ts} +11 -6
- package/dist/create-editor-CLQEkEZ1.js +1108 -0
- package/dist/diff/index.d.ts +31 -3
- package/dist/diff/index.js +1747 -1
- package/dist/dom/index.d.ts +2 -19
- package/dist/dom/index.js +2 -16
- package/dist/dom-CH2BXXj6.js +9220 -0
- package/dist/{core/same-result.js → editor-owner-C9rVbMTs.js} +77 -2
- package/dist/{core/editor-view-lifetime.js → editor-view-lifetime-GJKa_QGh.js} +1 -1
- package/dist/history/index.d.ts +169 -3
- package/dist/history/index.js +6717 -2
- package/dist/hyperscript/index.d.ts +1 -19
- package/dist/hyperscript/index.js +1 -8
- package/dist/{hyperscript/creators.js → hyperscript-CeT83ZLB.js} +134 -8
- package/dist/{annotations/store.d.ts → index-BWPcE4ac.d.ts} +27 -6
- package/dist/index-BXjLmx1n.d.ts +9827 -0
- package/dist/index-DVMNewDn.d.ts +1243 -0
- package/dist/index-Db-ktCTE.d.ts +1092 -0
- package/dist/index-Dq3Jlj8O.d.ts +119 -0
- package/dist/{yjs/core/plugin.d.ts → index-UrB4jAwl.d.ts} +88 -5
- package/dist/index.d.ts +2 -51
- package/dist/index.js +4 -34
- package/dist/internal/index.d.ts +2 -54
- package/dist/internal/index.js +156 -52
- package/dist/{internal/view/mapped-view-store.js → mapped-view-store-CbWqba_1.js} +2 -3
- package/dist/{core/native-grouping-input.js → native-grouping-input-DXNhlPHd.js} +2 -2
- package/dist/pagination/index.d.ts +1 -7
- package/dist/pagination/index.js +1 -693
- package/dist/pagination/react.d.ts +2 -4
- package/dist/pagination/react.js +436 -30
- package/dist/pagination-CBdYiOuR.js +1021 -0
- package/dist/plugin-SR3HTH0j.js +51505 -0
- package/dist/{react/range-geometry.js → range-geometry-CdltxcH6.js} +23 -18
- package/dist/{react/range-geometry.d.ts → range-geometry-Dwp2oyCc.d.ts} +2 -2
- package/dist/react/index.d.ts +5 -97
- package/dist/react/index.js +7 -72
- package/dist/react/virtualized.d.ts +2 -4
- package/dist/react/virtualized.js +146 -7
- package/dist/react-CN-iBh1z.js +1018 -0
- package/dist/{core/change/retraction.js → retraction-BmPJB9cE.js} +16 -4
- package/dist/src-B-zm0kz4.js +1511 -0
- package/dist/{internal/view/stable-id-mapped-source.js → store-51r4zpCR.js} +253 -3
- package/dist/testing/index.d.ts +182 -8
- package/dist/testing/index.js +95 -8
- package/dist/use-editor-dom-scope-uDJQ692F.js +28370 -0
- package/dist/yjs/index.d.ts +1 -4
- package/dist/yjs/index.js +1 -2
- package/dist/yjs/react/index.d.ts +25 -5
- package/dist/yjs/react/index.js +84 -3
- package/dist/yjs-IGE0Al3n.js +13416 -0
- package/package.json +1 -1
- package/dist/annotations/store.js +0 -244
- package/dist/authored/authored.d.ts +0 -116
- package/dist/authored/authored.js +0 -1271
- package/dist/authored/changes.js +0 -365
- package/dist/authored/comparison.d.ts +0 -41
- package/dist/authored/comparison.js +0 -270
- package/dist/authored/decision-window.js +0 -42
- package/dist/authored/decision.js +0 -306
- package/dist/authored/facts/admission.js +0 -388
- package/dist/authored/facts/compact.d.ts +0 -2
- package/dist/authored/facts/compact.js +0 -91
- package/dist/authored/facts/dependencies.d.ts +0 -5
- package/dist/authored/facts/dependencies.js +0 -66
- package/dist/authored/facts/editing.js +0 -12
- package/dist/authored/facts/facts.d.ts +0 -8
- package/dist/authored/facts/facts.js +0 -535
- package/dist/authored/facts/records.d.ts +0 -28
- package/dist/authored/facts/records.js +0 -226
- package/dist/authored/facts/settle.js +0 -529
- package/dist/authored/format.d.ts +0 -34
- package/dist/authored/format.js +0 -175
- package/dist/authored/ledger/book.js +0 -809
- package/dist/authored/ledger/cards.js +0 -223
- package/dist/authored/ledger/ledger.js +0 -830
- package/dist/authored/ledger/level.js +0 -1081
- package/dist/authored/ledger/links.js +0 -20
- package/dist/authored/ledger/pairs.js +0 -334
- package/dist/authored/ledger/places.js +0 -524
- package/dist/authored/ledger/preview-lens.js +0 -252
- package/dist/authored/ledger/projection.js +0 -163
- package/dist/authored/ledger/roots.js +0 -11
- package/dist/authored/ledger/runs.js +0 -480
- package/dist/authored/ledger/slots.js +0 -330
- package/dist/authored/ledger/work.js +0 -66
- package/dist/authored/refusal.d.ts +0 -33
- package/dist/authored/refusal.js +0 -188
- package/dist/authored/resolve-schema.js +0 -62
- package/dist/authored/tree/alignment.js +0 -456
- package/dist/authored/tree/carried.js +0 -205
- package/dist/authored/tree/command-values.js +0 -344
- package/dist/authored/tree/cuts.js +0 -320
- package/dist/authored/tree/grid.js +0 -49
- package/dist/authored/tree/halves.js +0 -120
- package/dist/authored/tree/holders.js +0 -345
- package/dist/authored/tree/holds.js +0 -135
- package/dist/authored/tree/layers.d.ts +0 -49
- package/dist/authored/tree/layers.js +0 -354
- package/dist/authored/tree/marks.d.ts +0 -136
- package/dist/authored/tree/marks.js +0 -263
- package/dist/authored/tree/proposed.js +0 -212
- package/dist/authored/tree/readiness.js +0 -545
- package/dist/authored/tree/record-completion.js +0 -423
- package/dist/authored/tree/record.js +0 -2908
- package/dist/authored/tree/reserves.js +0 -449
- package/dist/authored/tree/resolve.d.ts +0 -9
- package/dist/authored/tree/resolve.js +0 -1860
- package/dist/authored/tree/shown.js +0 -153
- package/dist/authored/tree/spare-lines.js +0 -119
- package/dist/authored/tree/spares.js +0 -61
- package/dist/authored/types.d.ts +0 -177
- package/dist/core/anchor-state.d.ts +0 -15
- package/dist/core/anchor-state.js +0 -792
- package/dist/core/anchor.d.ts +0 -34
- package/dist/core/anchor.js +0 -843
- package/dist/core/authored-document-capability.d.ts +0 -106
- package/dist/core/authored-document-capability.js +0 -6
- package/dist/core/authored-runtime.d.ts +0 -10
- package/dist/core/authored-runtime.js +0 -67
- package/dist/core/authored-veto.d.ts +0 -30
- package/dist/core/change/builder.d.ts +0 -546
- package/dist/core/change/builder.js +0 -1120
- package/dist/core/change/carried-projection.js +0 -1518
- package/dist/core/change/carried-run.d.ts +0 -26
- package/dist/core/change/carried-run.js +0 -251
- package/dist/core/change/carry-program.js +0 -537
- package/dist/core/change/classification.d.ts +0 -22
- package/dist/core/change/classification.js +0 -205
- package/dist/core/change/cross-rule.js +0 -238
- package/dist/core/change/cross.js +0 -577
- package/dist/core/change/document-change.d.ts +0 -137
- package/dist/core/change/document-change.js +0 -872
- package/dist/core/change/document-index.d.ts +0 -117
- package/dist/core/change/document-index.js +0 -542
- package/dist/core/change/draft-facts.js +0 -323
- package/dist/core/change/enclosure.d.ts +0 -12
- package/dist/core/change/enclosure.js +0 -272
- package/dist/core/change/join.js +0 -751
- package/dist/core/change/json.d.ts +0 -4
- package/dist/core/change/json.js +0 -26
- package/dist/core/change/lazy-root.d.ts +0 -1
- package/dist/core/change/lazy-root.js +0 -73
- package/dist/core/change/lineage.d.ts +0 -49
- package/dist/core/change/lineage.js +0 -390
- package/dist/core/change/mapping.d.ts +0 -31
- package/dist/core/change/mapping.js +0 -186
- package/dist/core/change/new-letters.d.ts +0 -14
- package/dist/core/change/new-letters.js +0 -139
- package/dist/core/change/range-association.js +0 -10
- package/dist/core/change/read-back.d.ts +0 -7
- package/dist/core/change/read-back.js +0 -7
- package/dist/core/change/record.d.ts +0 -59
- package/dist/core/change/record.js +0 -346
- package/dist/core/change/root-change.d.ts +0 -180
- package/dist/core/change/root-change.js +0 -3544
- package/dist/core/change/slice-facts.js +0 -89
- package/dist/core/change/text-splices.js +0 -98
- package/dist/core/change/tokens.d.ts +0 -97
- package/dist/core/change/tokens.js +0 -449
- package/dist/core/change/transform.d.ts +0 -36
- package/dist/core/change/transform.js +0 -97
- package/dist/core/change/wrap-fidelity.js +0 -295
- package/dist/core/change-events.js +0 -223
- package/dist/core/clone.js +0 -28
- package/dist/core/command-definition.d.ts +0 -25
- package/dist/core/command-definition.js +0 -48
- package/dist/core/command-document.d.ts +0 -4
- package/dist/core/command-document.js +0 -20
- package/dist/core/command-frame.js +0 -628
- package/dist/core/command-registry.d.ts +0 -36
- package/dist/core/command-registry.js +0 -283
- package/dist/core/commit-publication.js +0 -40
- package/dist/core/commit.d.ts +0 -26
- package/dist/core/commit.js +0 -686
- package/dist/core/composition-stamp.d.ts +0 -14
- package/dist/core/composition-stamp.js +0 -79
- package/dist/core/content-completion.d.ts +0 -4
- package/dist/core/content-completion.js +0 -343
- package/dist/core/content-landing.js +0 -124
- package/dist/core/content-slice-roots.js +0 -36
- package/dist/core/content-slice.d.ts +0 -38
- package/dist/core/content-slice.js +0 -253
- package/dist/core/content.js +0 -18
- package/dist/core/correction.js +0 -25
- package/dist/core/default-storage.js +0 -53
- package/dist/core/document-admission.d.ts +0 -4
- package/dist/core/document-admission.js +0 -64
- package/dist/core/document-change.d.ts +0 -3
- package/dist/core/document-recorder.d.ts +0 -6
- package/dist/core/document-recorder.js +0 -67
- package/dist/core/document-shape.d.ts +0 -68
- package/dist/core/document-shape.js +0 -173
- package/dist/core/document-view-read.d.ts +0 -16
- package/dist/core/document-view-read.js +0 -36
- package/dist/core/draft-track.d.ts +0 -3
- package/dist/core/draft-track.js +0 -90
- package/dist/core/editor-commands.d.ts +0 -99
- package/dist/core/editor-commands.js +0 -505
- package/dist/core/editor-lifecycle-api.d.ts +0 -8
- package/dist/core/editor-lifecycle-api.js +0 -219
- package/dist/core/editor-lifetime.js +0 -12
- package/dist/core/editor-owner.d.ts +0 -24
- package/dist/core/editor-owner.js +0 -78
- package/dist/core/editor-read-execution.d.ts +0 -6
- package/dist/core/editor-read-execution.js +0 -64
- package/dist/core/editor-read-runtime.js +0 -176
- package/dist/core/editor-reads.d.ts +0 -128
- package/dist/core/editor-reads.js +0 -63
- package/dist/core/editor-runtime.d.ts +0 -112
- package/dist/core/editor-runtime.js +0 -20
- package/dist/core/editor-schema.d.ts +0 -314
- package/dist/core/editor-schema.js +0 -2295
- package/dist/core/element-owned-root-index.d.ts +0 -4
- package/dist/core/element-owned-root-index.js +0 -353
- package/dist/core/get-content-slice.js +0 -118
- package/dist/core/get-fragment.js +0 -22
- package/dist/core/identity-owner.js +0 -697
- package/dist/core/import-content-slice.js +0 -26
- package/dist/core/initial-value.js +0 -87
- package/dist/core/insert-limit.js +0 -81
- package/dist/core/is-empty-element.js +0 -20
- package/dist/core/json-fingerprint.js +0 -16
- package/dist/core/landing.d.ts +0 -11
- package/dist/core/landing.js +0 -279
- package/dist/core/lifecycle-error.d.ts +0 -11
- package/dist/core/lifecycle-error.js +0 -68
- package/dist/core/listener-state.d.ts +0 -1
- package/dist/core/listener-state.js +0 -59
- package/dist/core/measured-sequence.d.ts +0 -43
- package/dist/core/measured-sequence.js +0 -404
- package/dist/core/missing-reference.js +0 -15
- package/dist/core/node-property-mutation.js +0 -10
- package/dist/core/node-selection.js +0 -85
- package/dist/core/node-write-veto.d.ts +0 -37
- package/dist/core/node-write-veto.js +0 -17
- package/dist/core/persisted-document.d.ts +0 -6
- package/dist/core/persisted-document.js +0 -39
- package/dist/core/persistent-map.js +0 -139
- package/dist/core/plain-text.d.ts +0 -32
- package/dist/core/plain-text.js +0 -92
- package/dist/core/plugin-dispatch.d.ts +0 -21
- package/dist/core/plugin-dispatch.js +0 -166
- package/dist/core/plugin-point.d.ts +0 -6
- package/dist/core/plugin-point.js +0 -21
- package/dist/core/plugin-registry.d.ts +0 -78
- package/dist/core/plugin-registry.js +0 -485
- package/dist/core/plugin-slot.d.ts +0 -23
- package/dist/core/plugin-slot.js +0 -30
- package/dist/core/plugin.d.ts +0 -125
- package/dist/core/plugin.js +0 -1485
- package/dist/core/prefix-occupant-join.js +0 -52
- package/dist/core/profiling.js +0 -18
- package/dist/core/property-validity.d.ts +0 -14
- package/dist/core/property-validity.js +0 -65
- package/dist/core/public-root.d.ts +0 -10
- package/dist/core/public-root.js +0 -50
- package/dist/core/public-state.d.ts +0 -191
- package/dist/core/public-state.js +0 -6772
- package/dist/core/read-definition.js +0 -22
- package/dist/core/read-registry.js +0 -127
- package/dist/core/record-store.d.ts +0 -12
- package/dist/core/record-store.js +0 -297
- package/dist/core/refusal.d.ts +0 -1
- package/dist/core/refusal.js +0 -40
- package/dist/core/representation.d.ts +0 -11
- package/dist/core/representation.js +0 -844
- package/dist/core/resolved-token-cursor.d.ts +0 -21
- package/dist/core/resolved-token-cursor.js +0 -294
- package/dist/core/root-entries.js +0 -121
- package/dist/core/root-ownership.d.ts +0 -19
- package/dist/core/root-ownership.js +0 -354
- package/dist/core/root-target.d.ts +0 -7
- package/dist/core/root-target.js +0 -281
- package/dist/core/same-result.d.ts +0 -18
- package/dist/core/schema-compiler.d.ts +0 -345
- package/dist/core/schema-compiler.js +0 -3166
- package/dist/core/schema-contribution-registry.d.ts +0 -12
- package/dist/core/schema-contribution-registry.js +0 -88
- package/dist/core/schema-definition.d.ts +0 -307
- package/dist/core/schema-definition.js +0 -628
- package/dist/core/schema-source.internal.d.ts +0 -49
- package/dist/core/schema-validation.d.ts +0 -11
- package/dist/core/schema-validation.js +0 -85
- package/dist/core/screen-reader-announcement.d.ts +0 -13
- package/dist/core/screen-reader-announcement.js +0 -17
- package/dist/core/selection-protocol.d.ts +0 -38
- package/dist/core/selection-protocol.js +0 -523
- package/dist/core/selection-state.js +0 -9
- package/dist/core/semantic-update-method.d.ts +0 -11
- package/dist/core/semantic-update-method.js +0 -26
- package/dist/core/set-root.d.ts +0 -3
- package/dist/core/set-root.js +0 -244
- package/dist/core/slice-end-matter.js +0 -77
- package/dist/core/slice-fit/compiled-slice-fitter.d.ts +0 -56
- package/dist/core/slice-fit/compiled-slice-fitter.js +0 -2087
- package/dist/core/slice-fit/fit-report.d.ts +0 -36
- package/dist/core/slice-fit/fit-report.js +0 -122
- package/dist/core/slice-fit/frontier.js +0 -98
- package/dist/core/slice-fit/origin.js +0 -57
- package/dist/core/slice-fit/provenance.d.ts +0 -30
- package/dist/core/slice-fit/provenance.js +0 -245
- package/dist/core/slice-identities.js +0 -21
- package/dist/core/slice-landing-types.d.ts +0 -61
- package/dist/core/slice-landing.js +0 -124
- package/dist/core/snapshot-index.d.ts +0 -13
- package/dist/core/snapshot-index.js +0 -860
- package/dist/core/state-field.d.ts +0 -12
- package/dist/core/state-field.js +0 -102
- package/dist/core/state-fields.js +0 -36
- package/dist/core/survival.js +0 -61
- package/dist/core/target-runtime.d.ts +0 -5
- package/dist/core/target-runtime.js +0 -42
- package/dist/core/transaction-values.d.ts +0 -47
- package/dist/core/transaction-values.js +0 -66
- package/dist/core/transfer-guard.js +0 -299
- package/dist/core/transfer-types.d.ts +0 -170
- package/dist/core/transfer.d.ts +0 -72
- package/dist/core/transfer.js +0 -655
- package/dist/core/tx-only.d.ts +0 -64
- package/dist/core/tx-only.js +0 -84
- package/dist/core/unique-values.js +0 -298
- package/dist/core/update-context.js +0 -28
- package/dist/core/update-policy.d.ts +0 -17
- package/dist/core/update-policy.js +0 -45
- package/dist/core/value-codec.d.ts +0 -35
- package/dist/core/value-codec.js +0 -240
- package/dist/core/view-carets.d.ts +0 -39
- package/dist/core/view-carets.js +0 -676
- package/dist/core/view-presentation.d.ts +0 -9
- package/dist/core/view-presentation.js +0 -70
- package/dist/core/work.d.ts +0 -192
- package/dist/core/work.js +0 -122
- package/dist/core/writable-text.js +0 -37
- package/dist/create-editor.d.ts +0 -187
- package/dist/create-editor.js +0 -281
- package/dist/diff/lib/compare.d.ts +0 -33
- package/dist/diff/lib/compare.js +0 -459
- package/dist/diff/lib/comparison-align.js +0 -324
- package/dist/diff/lib/comparison-index.js +0 -160
- package/dist/diff/lib/comparison-internal.js +0 -108
- package/dist/diff/lib/comparison-matcher.js +0 -1221
- package/dist/diff/lib/comparison-moves.js +0 -151
- package/dist/diff/lib/comparison-plan.js +0 -556
- package/dist/diff/lib/index.d.ts +0 -3
- package/dist/dom/dom-soft-line-end.d.ts +0 -3
- package/dist/dom/dom-soft-line-end.js +0 -295
- package/dist/dom/internal/index.d.ts +0 -15
- package/dist/dom/plugin/data-transfer-format.d.ts +0 -90
- package/dist/dom/plugin/data-transfer-format.js +0 -525
- package/dist/dom/plugin/dom-clipboard-runtime.d.ts +0 -50
- package/dist/dom/plugin/dom-clipboard-runtime.js +0 -482
- package/dist/dom/plugin/dom-coverage.d.ts +0 -140
- package/dist/dom/plugin/dom-coverage.js +0 -443
- package/dist/dom/plugin/dom-drag-scroll.js +0 -176
- package/dist/dom/plugin/dom-drag.d.ts +0 -54
- package/dist/dom/plugin/dom-drag.js +0 -507
- package/dist/dom/plugin/dom-editor.d.ts +0 -421
- package/dist/dom/plugin/dom-editor.js +0 -1316
- package/dist/dom/plugin/dom-event-range-targets.js +0 -39
- package/dist/dom/plugin/dom-geometry.d.ts +0 -11
- package/dist/dom/plugin/dom-geometry.js +0 -888
- package/dist/dom/plugin/dom-input-runtime.d.ts +0 -1
- package/dist/dom/plugin/dom-input-runtime.js +0 -571
- package/dist/dom/plugin/dom-integrity-observer.js +0 -436
- package/dist/dom/plugin/dom-node-path.js +0 -61
- package/dist/dom/plugin/dom-phase-scheduler.d.ts +0 -1
- package/dist/dom/plugin/dom-phase-scheduler.js +0 -284
- package/dist/dom/plugin/dom-root-runtime.d.ts +0 -10
- package/dist/dom/plugin/dom-root-runtime.js +0 -716
- package/dist/dom/plugin/dom-sync-mutation-ownership.d.ts +0 -1
- package/dist/dom/plugin/dom-sync-mutation-ownership.js +0 -120
- package/dist/dom/plugin/dom-text-flow-index.js +0 -396
- package/dist/dom/plugin/dom-text-freshness.js +0 -188
- package/dist/dom/plugin/dom-text-proofs.d.ts +0 -2
- package/dist/dom/plugin/dom-text-proofs.js +0 -350
- package/dist/dom/plugin/dom-view-caret.js +0 -28
- package/dist/dom/plugin/with-dom.d.ts +0 -53
- package/dist/dom/plugin/with-dom.js +0 -101
- package/dist/dom/utils/constants.d.ts +0 -5
- package/dist/dom/utils/constants.js +0 -5
- package/dist/dom/utils/diff-text.d.ts +0 -51
- package/dist/dom/utils/diff-text.js +0 -264
- package/dist/dom/utils/dom.d.ts +0 -104
- package/dist/dom/utils/dom.js +0 -257
- package/dist/dom/utils/drag-session.d.ts +0 -2
- package/dist/dom/utils/drag-session.js +0 -115
- package/dist/dom/utils/drop-indicator.d.ts +0 -18
- package/dist/dom/utils/drop-indicator.js +0 -36
- package/dist/dom/utils/environment.d.ts +0 -12
- package/dist/dom/utils/environment.js +0 -118
- package/dist/dom/utils/hotkey-match.d.ts +0 -36
- package/dist/dom/utils/hotkey-match.js +0 -208
- package/dist/dom/utils/hotkeys.d.ts +0 -32
- package/dist/dom/utils/hotkeys.js +0 -121
- package/dist/dom/utils/key.d.ts +0 -14
- package/dist/dom/utils/key.js +0 -18
- package/dist/dom/utils/plite-dom-markers.d.ts +0 -26
- package/dist/dom/utils/plite-dom-markers.js +0 -25
- package/dist/dom/utils/selection-writes.d.ts +0 -18
- package/dist/dom/utils/selection-writes.js +0 -63
- package/dist/dom/utils/weak-maps.d.ts +0 -2
- package/dist/dom/utils/weak-maps.js +0 -51
- package/dist/editor/above.js +0 -30
- package/dist/editor/add-mark.js +0 -79
- package/dist/editor/adjacent-character-point.js +0 -120
- package/dist/editor/after.js +0 -37
- package/dist/editor/before.js +0 -124
- package/dist/editor/block-void-break.js +0 -20
- package/dist/editor/correct-document.js +0 -225
- package/dist/editor/delete-backward.js +0 -64
- package/dist/editor/delete-forward.js +0 -11
- package/dist/editor/delete-fragment.js +0 -40
- package/dist/editor/edges.js +0 -5
- package/dist/editor/element-read-only.js +0 -35
- package/dist/editor/end.d.ts +0 -7
- package/dist/editor/end.js +0 -5
- package/dist/editor/exit-break.js +0 -51
- package/dist/editor/first.js +0 -8
- package/dist/editor/get-void.js +0 -9
- package/dist/editor/has-blocks.js +0 -6
- package/dist/editor/has-inlines.js +0 -6
- package/dist/editor/has-path.js +0 -5
- package/dist/editor/has-texts.js +0 -5
- package/dist/editor/insert-break.js +0 -77
- package/dist/editor/insert-default-child.js +0 -55
- package/dist/editor/insert-soft-break.js +0 -14
- package/dist/editor/insert-text.js +0 -83
- package/dist/editor/is-block.js +0 -5
- package/dist/editor/is-edge.js +0 -5
- package/dist/editor/is-editor.js +0 -13
- package/dist/editor/is-empty.js +0 -6
- package/dist/editor/is-end.js +0 -9
- package/dist/editor/is-start.js +0 -9
- package/dist/editor/last.js +0 -20
- package/dist/editor/leaf.js +0 -9
- package/dist/editor/levels.js +0 -21
- package/dist/editor/next.js +0 -46
- package/dist/editor/node.js +0 -9
- package/dist/editor/nodes.js +0 -106
- package/dist/editor/parent.js +0 -14
- package/dist/editor/path.js +0 -26
- package/dist/editor/point.js +0 -52
- package/dist/editor/positions.js +0 -322
- package/dist/editor/previous.js +0 -48
- package/dist/editor/project-range.js +0 -6
- package/dist/editor/range.js +0 -12
- package/dist/editor/remove-mark.js +0 -65
- package/dist/editor/should-merge-nodes-remove-prev-node.js +0 -11
- package/dist/editor/string.js +0 -35
- package/dist/editor/toggle-mark.js +0 -71
- package/dist/editor/unhang-range.js +0 -71
- package/dist/editor-runtime-view.d.ts +0 -33
- package/dist/editor-runtime-view.js +0 -788
- package/dist/history/history-carets.js +0 -127
- package/dist/history/history-character-map.js +0 -425
- package/dist/history/history-codec.js +0 -176
- package/dist/history/history-merge-policy.js +0 -164
- package/dist/history/history-plugin.d.ts +0 -71
- package/dist/history/history-plugin.js +0 -814
- package/dist/history/history-replay.js +0 -799
- package/dist/history/history-selection.js +0 -75
- package/dist/history/history-state.js +0 -1287
- package/dist/history/history.d.ts +0 -112
- package/dist/history/history.js +0 -29
- package/dist/hyperscript/creators.d.ts +0 -51
- package/dist/hyperscript/hyperscript.d.ts +0 -36
- package/dist/hyperscript/hyperscript.js +0 -66
- package/dist/hyperscript/tokens.d.ts +0 -31
- package/dist/hyperscript/tokens.js +0 -63
- package/dist/interfaces/decoration.d.ts +0 -35
- package/dist/interfaces/editor.d.ts +0 -2783
- package/dist/interfaces/editor.js +0 -348
- package/dist/interfaces/element.d.ts +0 -66
- package/dist/interfaces/element.js +0 -34
- package/dist/interfaces/index.d.ts +0 -13
- package/dist/interfaces/json.d.ts +0 -7
- package/dist/interfaces/location.d.ts +0 -50
- package/dist/interfaces/location.js +0 -26
- package/dist/interfaces/node.d.ts +0 -306
- package/dist/interfaces/node.js +0 -339
- package/dist/interfaces/path.d.ts +0 -118
- package/dist/interfaces/path.js +0 -116
- package/dist/interfaces/point.d.ts +0 -45
- package/dist/interfaces/point.js +0 -32
- package/dist/interfaces/range.d.ts +0 -80
- package/dist/interfaces/range.js +0 -85
- package/dist/interfaces/schema-validation.d.ts +0 -33
- package/dist/interfaces/schema.d.ts +0 -870
- package/dist/interfaces/selection.d.ts +0 -61
- package/dist/interfaces/selection.js +0 -106
- package/dist/interfaces/text.d.ts +0 -68
- package/dist/interfaces/text.js +0 -52
- package/dist/interfaces/transforms/node.d.ts +0 -222
- package/dist/interfaces/transforms/selection.d.ts +0 -48
- package/dist/interfaces/transforms/text.d.ts +0 -58
- package/dist/internal/browser-protocol.d.ts +0 -5
- package/dist/internal/document-range.d.ts +0 -9
- package/dist/internal/document-range.js +0 -31
- package/dist/internal/editor-options.d.ts +0 -37
- package/dist/internal/editor-options.js +0 -36
- package/dist/internal/fail-invariant.d.ts +0 -4
- package/dist/internal/fail-invariant.js +0 -6
- package/dist/internal/get-defined.js +0 -7
- package/dist/internal/law-check.js +0 -7
- package/dist/internal/range-text-marks.js +0 -31
- package/dist/internal/root-location.d.ts +0 -23
- package/dist/internal/root-location.js +0 -86
- package/dist/internal/text-run.d.ts +0 -13
- package/dist/internal/text-run.js +0 -44
- package/dist/internal/view/annotation-store-metrics.d.ts +0 -11
- package/dist/internal/view/view-source.d.ts +0 -20
- package/dist/pagination/page-composition.internal.js +0 -313
- package/dist/pagination/page-geometry.internal.js +0 -99
- package/dist/pagination/page-layout-engine-invalidation.internal.js +0 -20
- package/dist/pagination/page-mount-plan.js +0 -84
- package/dist/pagination/paged-view-lines.js +0 -163
- package/dist/range-projection.d.ts +0 -7
- package/dist/range-projection.js +0 -50
- package/dist/react/components/dom-coverage-boundary.d.ts +0 -14
- package/dist/react/components/dom-coverage-boundary.js +0 -143
- package/dist/react/components/editable-descendant-binding.js +0 -70
- package/dist/react/components/editable-dom-commit-fence.js +0 -107
- package/dist/react/components/editable-element-placement.d.ts +0 -2
- package/dist/react/components/editable-element-placement.js +0 -117
- package/dist/react/components/editable-external-text.js +0 -47
- package/dist/react/components/editable-node-equality.js +0 -25
- package/dist/react/components/editable-rendered-element.d.ts +0 -3
- package/dist/react/components/editable-rendered-element.js +0 -61
- package/dist/react/components/editable-text-blocks.d.ts +0 -192
- package/dist/react/components/editable-text-blocks.js +0 -896
- package/dist/react/components/editable-text-containers.d.ts +0 -3
- package/dist/react/components/editable-text-containers.js +0 -28
- package/dist/react/components/editable-text-flow.js +0 -1039
- package/dist/react/components/editable-text-pieces.d.ts +0 -7
- package/dist/react/components/editable-text-pieces.js +0 -193
- package/dist/react/components/editable-text.d.ts +0 -80
- package/dist/react/components/editable-text.js +0 -322
- package/dist/react/components/editable.d.ts +0 -35
- package/dist/react/components/editable.js +0 -406
- package/dist/react/components/editor-announcement-live-region.js +0 -113
- package/dist/react/components/plite-element.d.ts +0 -18
- package/dist/react/components/plite-element.js +0 -54
- package/dist/react/components/plite-leaf.d.ts +0 -18
- package/dist/react/components/plite-leaf.js +0 -21
- package/dist/react/components/plite-placeholder.d.ts +0 -19
- package/dist/react/components/plite-placeholder.js +0 -39
- package/dist/react/components/plite-spacer.js +0 -14
- package/dist/react/components/plite-text.d.ts +0 -23
- package/dist/react/components/plite-text.js +0 -32
- package/dist/react/components/plite-void-shell.js +0 -49
- package/dist/react/components/plite.d.ts +0 -45
- package/dist/react/components/plite.js +0 -297
- package/dist/react/components/text-string.js +0 -18
- package/dist/react/components/windowed-editable.internal.js +0 -51
- package/dist/react/components/zero-width-string.js +0 -26
- package/dist/react/context.js +0 -11
- package/dist/react/decoration-context.d.ts +0 -2
- package/dist/react/decoration-context.js +0 -22
- package/dist/react/decoration-source.d.ts +0 -11
- package/dist/react/decoration-source.js +0 -1030
- package/dist/react/dom-text-sync.d.ts +0 -24
- package/dist/react/dom-text-sync.js +0 -48
- package/dist/react/editable/android-composition.d.ts +0 -3
- package/dist/react/editable/android-composition.js +0 -496
- package/dist/react/editable/browser-handle.js +0 -515
- package/dist/react/editable/caret-engine.js +0 -681
- package/dist/react/editable/clipboard-input-strategy.js +0 -632
- package/dist/react/editable/composition-lease.d.ts +0 -3
- package/dist/react/editable/composition-lease.js +0 -350
- package/dist/react/editable/composition-state.js +0 -716
- package/dist/react/editable/content-root-boundaries.js +0 -79
- package/dist/react/editable/content-root-coordinate-navigation.js +0 -28
- package/dist/react/editable/content-root-navigation-actions.js +0 -190
- package/dist/react/editable/content-root-navigation.js +0 -819
- package/dist/react/editable/content-root-owner-target.js +0 -36
- package/dist/react/editable/content-root-owners.js +0 -191
- package/dist/react/editable/content-root-vertical-geometry.js +0 -60
- package/dist/react/editable/decoration-repair-bridge.js +0 -29
- package/dist/react/editable/dom-coverage-selection.js +0 -158
- package/dist/react/editable/dom-coverage-vertical-selection.js +0 -446
- package/dist/react/editable/dom-input-event.js +0 -14
- package/dist/react/editable/dom-repair-queue.d.ts +0 -7
- package/dist/react/editable/dom-repair-queue.js +0 -543
- package/dist/react/editable/dom-repair-text.js +0 -47
- package/dist/react/editable/editable-command-types.d.ts +0 -1
- package/dist/react/editable/editable-dom-runtime.d.ts +0 -66
- package/dist/react/editable/editable-dom-runtime.js +0 -1022
- package/dist/react/editable/editing-epoch-adapter.js +0 -46
- package/dist/react/editable/editing-kernel.d.ts +0 -7
- package/dist/react/editable/editing-kernel.js +0 -593
- package/dist/react/editable/external-text-binding.js +0 -43
- package/dist/react/editable/external-text-runtime.d.ts +0 -5
- package/dist/react/editable/external-text-runtime.js +0 -851
- package/dist/react/editable/history-focus.js +0 -71
- package/dist/react/editable/history-keyboard.d.ts +0 -4
- package/dist/react/editable/history-keyboard.js +0 -9
- package/dist/react/editable/input-controller.d.ts +0 -7
- package/dist/react/editable/input-controller.js +0 -175
- package/dist/react/editable/input-history.js +0 -21
- package/dist/react/editable/input-router.js +0 -742
- package/dist/react/editable/input-state.d.ts +0 -18
- package/dist/react/editable/input-state.js +0 -330
- package/dist/react/editable/input-target.js +0 -30
- package/dist/react/editable/install-browser-handle.d.ts +0 -12
- package/dist/react/editable/install-browser-handle.js +0 -18
- package/dist/react/editable/interaction-owner.js +0 -88
- package/dist/react/editable/keyboard-input-strategy.js +0 -730
- package/dist/react/editable/line-boundary.js +0 -37
- package/dist/react/editable/model-input-strategy.d.ts +0 -9
- package/dist/react/editable/model-input-strategy.js +0 -242
- package/dist/react/editable/model-selection-dom-preference.js +0 -11
- package/dist/react/editable/mutation-block-editing.js +0 -48
- package/dist/react/editable/mutation-controller.d.ts +0 -32
- package/dist/react/editable/mutation-controller.js +0 -632
- package/dist/react/editable/mutation-full-block-editing.d.ts +0 -2
- package/dist/react/editable/mutation-full-block-editing.js +0 -44
- package/dist/react/editable/mutation-history.d.ts +0 -3
- package/dist/react/editable/mutation-history.js +0 -146
- package/dist/react/editable/native-input-strategy.js +0 -86
- package/dist/react/editable/native-text-input-delta.js +0 -40
- package/dist/react/editable/placed-drag.js +0 -177
- package/dist/react/editable/plite-string-coordinate-placement.js +0 -46
- package/dist/react/editable/press-fence.d.ts +0 -2
- package/dist/react/editable/press-fence.js +0 -70
- package/dist/react/editable/projected-clipboard.js +0 -123
- package/dist/react/editable/projected-native-affordance.js +0 -30
- package/dist/react/editable/projected-selection-target.js +0 -13
- package/dist/react/editable/render-contract-monitor.d.ts +0 -3
- package/dist/react/editable/render-contract-monitor.js +0 -152
- package/dist/react/editable/root-interaction-controller.js +0 -1400
- package/dist/react/editable/root-interaction-dom-selection-replay.js +0 -40
- package/dist/react/editable/root-interaction-resolver.js +0 -116
- package/dist/react/editable/root-selector-sources.js +0 -90
- package/dist/react/editable/runtime-android-engine.js +0 -40
- package/dist/react/editable/runtime-before-input-events.js +0 -671
- package/dist/react/editable/runtime-browser-handle-events.js +0 -40
- package/dist/react/editable/runtime-clipboard-events.js +0 -169
- package/dist/react/editable/runtime-composition-events.js +0 -163
- package/dist/react/editable/runtime-drag-events.js +0 -136
- package/dist/react/editable/runtime-editor-api.d.ts +0 -20
- package/dist/react/editable/runtime-editor-api.js +0 -21
- package/dist/react/editable/runtime-event-engine.js +0 -213
- package/dist/react/editable/runtime-focus-mouse-events.js +0 -264
- package/dist/react/editable/runtime-input-events.js +0 -166
- package/dist/react/editable/runtime-kernel-trace.js +0 -185
- package/dist/react/editable/runtime-keyboard-events.js +0 -333
- package/dist/react/editable/runtime-live-state.js +0 -44
- package/dist/react/editable/runtime-mutation-state.js +0 -11
- package/dist/react/editable/runtime-repair-engine.js +0 -118
- package/dist/react/editable/runtime-root-engine.js +0 -244
- package/dist/react/editable/runtime-root-lifecycle.js +0 -118
- package/dist/react/editable/runtime-root-selection-export.js +0 -38
- package/dist/react/editable/runtime-root-selection-import.js +0 -54
- package/dist/react/editable/runtime-root-state.js +0 -62
- package/dist/react/editable/runtime-selection-engine.js +0 -260
- package/dist/react/editable/runtime-selection-state.js +0 -12
- package/dist/react/editable/runtime-target-bridge.js +0 -29
- package/dist/react/editable/schema-runtime-invalidation.js +0 -26
- package/dist/react/editable/selection-change-listener.js +0 -99
- package/dist/react/editable/selection-claim.d.ts +0 -3
- package/dist/react/editable/selection-claim.js +0 -398
- package/dist/react/editable/selection-controller.d.ts +0 -8
- package/dist/react/editable/selection-controller.js +0 -693
- package/dist/react/editable/selection-dom-range.js +0 -84
- package/dist/react/editable/selection-projected-dom.js +0 -156
- package/dist/react/editable/selection-reconciler.js +0 -630
- package/dist/react/editable/selection-runtime.js +0 -89
- package/dist/react/editable/selection-side-effect-policy.js +0 -20
- package/dist/react/editable/selection-triple-click.js +0 -48
- package/dist/react/editable/selection-void-target.js +0 -172
- package/dist/react/editable/set-root-endpoints.js +0 -75
- package/dist/react/editable/soft-line-end-delete.js +0 -106
- package/dist/react/editable/text-direction.js +0 -82
- package/dist/react/editable/typed-text.d.ts +0 -17
- package/dist/react/editable/typed-text.js +0 -89
- package/dist/react/editable/unread-press.d.ts +0 -2
- package/dist/react/editable/unread-press.js +0 -86
- package/dist/react/editable/view-caret-restore.js +0 -128
- package/dist/react/editable/view-lines.d.ts +0 -7
- package/dist/react/editable/view-lines.js +0 -166
- package/dist/react/external-text.d.ts +0 -131
- package/dist/react/history-step-views.d.ts +0 -4
- package/dist/react/history-step-views.js +0 -119
- package/dist/react/hooks/android-input-manager/android-input-manager.d.ts +0 -7
- package/dist/react/hooks/android-input-manager/android-input-manager.js +0 -716
- package/dist/react/hooks/android-input-manager/use-android-input-manager.js +0 -53
- package/dist/react/hooks/focus-plite-editable.js +0 -116
- package/dist/react/hooks/use-claim-editable-dom-commit.d.ts +0 -12
- package/dist/react/hooks/use-claim-editable-dom-commit.js +0 -31
- package/dist/react/hooks/use-drop-indicator.d.ts +0 -9
- package/dist/react/hooks/use-drop-indicator.js +0 -14
- package/dist/react/hooks/use-editable-clip.d.ts +0 -18
- package/dist/react/hooks/use-editable-clip.js +0 -31
- package/dist/react/hooks/use-editable-layout-pass.js +0 -53
- package/dist/react/hooks/use-editor-composing.d.ts +0 -7
- package/dist/react/hooks/use-editor-composing.js +0 -12
- package/dist/react/hooks/use-editor-context.d.ts +0 -10
- package/dist/react/hooks/use-editor-context.js +0 -18
- package/dist/react/hooks/use-editor-dom-scope.d.ts +0 -27
- package/dist/react/hooks/use-editor-dom-scope.js +0 -23
- package/dist/react/hooks/use-editor-focused.d.ts +0 -7
- package/dist/react/hooks/use-editor-focused.js +0 -12
- package/dist/react/hooks/use-editor-read-only.d.ts +0 -25
- package/dist/react/hooks/use-editor-read-only.js +0 -19
- package/dist/react/hooks/use-editor-runtime-state.d.ts +0 -18
- package/dist/react/hooks/use-editor-runtime-state.js +0 -38
- package/dist/react/hooks/use-editor-selection.d.ts +0 -10
- package/dist/react/hooks/use-editor-selection.js +0 -13
- package/dist/react/hooks/use-editor-selector.d.ts +0 -38
- package/dist/react/hooks/use-editor-selector.js +0 -265
- package/dist/react/hooks/use-editor-view-state.d.ts +0 -16
- package/dist/react/hooks/use-editor-view-state.js +0 -20
- package/dist/react/hooks/use-editor.d.ts +0 -26
- package/dist/react/hooks/use-editor.js +0 -27
- package/dist/react/hooks/use-element-path.d.ts +0 -7
- package/dist/react/hooks/use-element-path.js +0 -36
- package/dist/react/hooks/use-element-selected.d.ts +0 -26
- package/dist/react/hooks/use-element-selected.js +0 -91
- package/dist/react/hooks/use-element.d.ts +0 -13
- package/dist/react/hooks/use-element.js +0 -17
- package/dist/react/hooks/use-generic-selector.js +0 -91
- package/dist/react/hooks/use-hydrated.js +0 -12
- package/dist/react/hooks/use-isomorphic-layout-effect.js +0 -9
- package/dist/react/hooks/use-node-selector.d.ts +0 -40
- package/dist/react/hooks/use-node-selector.js +0 -102
- package/dist/react/hooks/use-plite-annotation-store.d.ts +0 -21
- package/dist/react/hooks/use-plite-annotation-store.js +0 -61
- package/dist/react/hooks/use-plite-annotations.d.ts +0 -9
- package/dist/react/hooks/use-plite-annotations.js +0 -16
- package/dist/react/hooks/use-plite-child-root.d.ts +0 -14
- package/dist/react/hooks/use-plite-child-root.js +0 -38
- package/dist/react/hooks/use-plite-content-root.d.ts +0 -21
- package/dist/react/hooks/use-plite-content-root.js +0 -26
- package/dist/react/hooks/use-plite-history.d.ts +0 -43
- package/dist/react/hooks/use-plite-history.js +0 -137
- package/dist/react/hooks/use-plite-node-ref.js +0 -513
- package/dist/react/hooks/use-plite-root-chrome.d.ts +0 -34
- package/dist/react/hooks/use-plite-root-chrome.js +0 -98
- package/dist/react/hooks/use-plite-runtime.d.ts +0 -86
- package/dist/react/hooks/use-plite-runtime.js +0 -433
- package/dist/react/hooks/use-runtime-focus-state.js +0 -37
- package/dist/react/hooks/use-selection-geometry.d.ts +0 -12
- package/dist/react/hooks/use-selection-geometry.js +0 -39
- package/dist/react/hooks/use-selection-view.d.ts +0 -14
- package/dist/react/hooks/use-selection-view.js +0 -14
- package/dist/react/hooks/use-state-field.d.ts +0 -26
- package/dist/react/hooks/use-state-field.js +0 -38
- package/dist/react/inactive-selection.js +0 -175
- package/dist/react/plugin/react-editor.d.ts +0 -20
- package/dist/react/plugin/react-editor.js +0 -6
- package/dist/react/plugin/with-react.d.ts +0 -108
- package/dist/react/plugin/with-react.js +0 -58
- package/dist/react/render-profiler.js +0 -20
- package/dist/react/root-key.js +0 -12
- package/dist/react/shell-runtime.js +0 -29
- package/dist/react/update-policy.d.ts +0 -10
- package/dist/react/update-policy.js +0 -15
- package/dist/react/utils/environment.js +0 -5
- package/dist/react/view-boundary-graph-core.d.ts +0 -1
- package/dist/react/view-boundary-graph-core.js +0 -208
- package/dist/react/view-boundary-graph.js +0 -105
- package/dist/react/view-selection-decoration.js +0 -97
- package/dist/react/view-selection.js +0 -184
- package/dist/react/viewport-boundary.js +0 -45
- package/dist/react/viewport-commands.d.ts +0 -1
- package/dist/react/viewport-commands.js +0 -17
- package/dist/react/viewport-plan.d.ts +0 -2
- package/dist/react/viewport-plan.js +0 -77
- package/dist/react/virtualized/use-virtualized-root-plan.js +0 -148
- package/dist/testing/createDataTransfer.d.ts +0 -4
- package/dist/testing/createDataTransfer.js +0 -13
- package/dist/testing/jsx.d.ts +0 -181
- package/dist/testing/jsx.js +0 -82
- package/dist/transforms-node/insert-nodes.js +0 -143
- package/dist/transforms-node/lift-nodes.js +0 -117
- package/dist/transforms-node/merge-nodes.js +0 -180
- package/dist/transforms-node/move-nodes.js +0 -58
- package/dist/transforms-node/remove-nodes.js +0 -86
- package/dist/transforms-node/replace-children.js +0 -117
- package/dist/transforms-node/set-nodes.js +0 -188
- package/dist/transforms-node/split-nodes.js +0 -258
- package/dist/transforms-node/unset-nodes.js +0 -10
- package/dist/transforms-node/unwrap-nodes.js +0 -182
- package/dist/transforms-node/wrap-nodes.js +0 -250
- package/dist/transforms-selection/collapse.js +0 -20
- package/dist/transforms-selection/deselect.js +0 -8
- package/dist/transforms-selection/move.js +0 -35
- package/dist/transforms-selection/select.js +0 -59
- package/dist/transforms-selection/set-point.js +0 -32
- package/dist/transforms-selection/set-selection.js +0 -52
- package/dist/transforms-text/delete-text-collapsed-path-targets.js +0 -102
- package/dist/transforms-text/delete-text-grid.js +0 -402
- package/dist/transforms-text/delete-text-inline-points.js +0 -82
- package/dist/transforms-text/delete-text-plan.js +0 -55
- package/dist/transforms-text/delete-text-removal.js +0 -153
- package/dist/transforms-text/delete-text-structural-cleanup.js +0 -130
- package/dist/transforms-text/delete-text-whole-blocks.js +0 -70
- package/dist/transforms-text/delete-text.js +0 -804
- package/dist/transforms-text/full-document-range.js +0 -12
- package/dist/transforms-text/insert-text.js +0 -314
- package/dist/types/types.d.ts +0 -13
- package/dist/utils/format-debug-value.d.ts +0 -8
- package/dist/utils/format-debug-value.js +0 -31
- package/dist/utils/get-default-insert-location.js +0 -19
- package/dist/utils/is-object.d.ts +0 -4
- package/dist/utils/is-object.js +0 -4
- package/dist/utils/match-path.js +0 -8
- package/dist/utils/node-keys.d.ts +0 -15
- package/dist/utils/node-keys.js +0 -179
- package/dist/utils/node-match.js +0 -9
- package/dist/utils/string.js +0 -283
- package/dist/yjs/core/addresses.js +0 -98
- package/dist/yjs/core/ancestor-properties.js +0 -56
- package/dist/yjs/core/attributes.js +0 -21
- package/dist/yjs/core/awareness-adapter.d.ts +0 -5
- package/dist/yjs/core/awareness-adapter.js +0 -399
- package/dist/yjs/core/awareness-relative-selection.js +0 -22
- package/dist/yjs/core/awareness.js +0 -25
- package/dist/yjs/core/binding.d.ts +0 -3
- package/dist/yjs/core/binding.js +0 -128
- package/dist/yjs/core/boundaries.js +0 -453
- package/dist/yjs/core/canonical-split.js +0 -130
- package/dist/yjs/core/change-bridge.js +0 -124
- package/dist/yjs/core/change-regions.js +0 -119
- package/dist/yjs/core/controller-registry.js +0 -70
- package/dist/yjs/core/controller.d.ts +0 -6
- package/dist/yjs/core/controller.js +0 -1282
- package/dist/yjs/core/document.js +0 -1499
- package/dist/yjs/core/editor-adapter.d.ts +0 -18
- package/dist/yjs/core/editor-adapter.js +0 -145
- package/dist/yjs/core/editor-only-roots.js +0 -53
- package/dist/yjs/core/editor-types.d.ts +0 -1
- package/dist/yjs/core/enclosures.js +0 -410
- package/dist/yjs/core/event-change-bridge.js +0 -3642
- package/dist/yjs/core/index.d.ts +0 -4
- package/dist/yjs/core/joined-lines.js +0 -81
- package/dist/yjs/core/joins.js +0 -587
- package/dist/yjs/core/json-equality.js +0 -31
- package/dist/yjs/core/keys.js +0 -29
- package/dist/yjs/core/letter-scripts.js +0 -449
- package/dist/yjs/core/new-letters.js +0 -300
- package/dist/yjs/core/path.js +0 -25
- package/dist/yjs/core/plugin.js +0 -206
- package/dist/yjs/core/record.js +0 -4
- package/dist/yjs/core/replacement.js +0 -165
- package/dist/yjs/core/retraction.js +0 -132
- package/dist/yjs/core/root-owners.js +0 -110
- package/dist/yjs/core/root-projection-index.js +0 -428
- package/dist/yjs/core/schema-metadata.js +0 -88
- package/dist/yjs/core/selection.js +0 -34
- package/dist/yjs/core/set-valued-attributes.js +0 -57
- package/dist/yjs/core/shared-effect-log.d.ts +0 -4
- package/dist/yjs/core/shared-effect-log.js +0 -674
- package/dist/yjs/core/text-runs.js +0 -1596
- package/dist/yjs/core/types.d.ts +0 -76
- package/dist/yjs/react/useYjs.d.ts +0 -25
- package/dist/yjs/react/useYjs.js +0 -85
|
@@ -0,0 +1,1511 @@
|
|
|
1
|
+
import { $f as PathApi, $i as trackDraftSpans, Af as decodeVersionedValue, Ai as planPaste, An as finalizeTransactionRepresentation, B as NodeApi, Bf as defineEffect, Cl as getPluginContributions, Cu as getEditorRuntime, Dl as markDefinedStateField, Eu as getEditorSchema, Gf as RangeApi, Gr as replaceSliceAtBlockBoundary, Hs as EditorSchemaValidationError, Jf as PointApi, Ji as getContentSlice, Jl as resolveCompiledSchemaProperty, Kc as isDocumentView, Ln as getAppliedSpecLanding, Mf as encodeVersionedValue, Pf as normalizeEditorValuePersistence, Qi as settleDraftTrack, Sa as editorReads, Si as withEditorRootChildren, Sl as getConfiguredPluginRegistry, Tu as getEditorRuntimeRoot, Vd as canonicalJsonKey, Xc as getMovableAnchors, Xi as readDraftTrack, Zi as readDraftTrackAt, Zl as toCompiledNodeContext, _r as getTransactionSnapshot, bi as withDraftMove, bs as withFitLanding, cp as countCoreWork, du as definePluginPoint, ea as isEditorDraftView, eu as uniquePropertiesOf, fa as resolveDeletedRange, hp as getDefined, hu as ElementApi, i as compilePlugin, ji as writePaste, l as definePlugin, lc as ContentSlice, md as mapInternalDocumentChangePosition, mp as cloneFrozen, mu as SelectionApi, na as registerEditorDraftGuard, oa as coversContent, pa as removeNodes, tl as placeAnchorsOnCommit, tr as getEditorStateView, ua as deleteText, uo as createEditorViewRuntime, wi as withEditorUpdateRootScope, wu as getEditorRuntimeOwner, xa as executeEditorRead, xl as getCompiledEditorSchema, xn as applyTransactionSpec, ys as payloadKeyOf, zc as readAuthoredView } from "./plugin-SR3HTH0j.js";
|
|
2
|
+
import { _ as screenReaderAnnouncementEffect } from "./create-editor-CLQEkEZ1.js";
|
|
3
|
+
//#region src/core/landing.ts
|
|
4
|
+
/** Contribute a veto that refuses a landing on its final edge. */
|
|
5
|
+
const transferVeto = definePluginPoint("transfer.veto");
|
|
6
|
+
var TransferRefusalError = class extends Error {
|
|
7
|
+
reason;
|
|
8
|
+
constructor(reason) {
|
|
9
|
+
super(`Transfer refused: ${reason}`);
|
|
10
|
+
this.name = "TransferRefusalError";
|
|
11
|
+
this.reason = reason;
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
const refuse = (reason) => {
|
|
15
|
+
throw new TransferRefusalError(reason);
|
|
16
|
+
};
|
|
17
|
+
const reachableRoots = (editor, value, nodes) => {
|
|
18
|
+
const roots = /* @__PURE__ */ new Set();
|
|
19
|
+
const visit = (children) => {
|
|
20
|
+
for (const node of children) {
|
|
21
|
+
if (!ElementApi.isElement(node)) continue;
|
|
22
|
+
for (const root of Object.values(editor.read.schema.getElementContentRoots(node))) {
|
|
23
|
+
if (roots.has(root)) continue;
|
|
24
|
+
roots.add(root);
|
|
25
|
+
visit(value.roots?.[root] ?? []);
|
|
26
|
+
}
|
|
27
|
+
visit(node.children);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
visit(nodes);
|
|
31
|
+
return roots;
|
|
32
|
+
};
|
|
33
|
+
const liveTarget = (editor, { key }) => {
|
|
34
|
+
const entry = editor.read.nodes.get(key);
|
|
35
|
+
if (!entry || !ElementApi.isElement(entry[0])) refuse("policy");
|
|
36
|
+
return entry;
|
|
37
|
+
};
|
|
38
|
+
const insertionPath = (path, edge) => [...path.slice(0, -1), path.at(-1) + (edge === "after" ? 1 : 0)];
|
|
39
|
+
const insertionIndex = (edge, targetPath) => insertionPath(targetPath, edge.edge).at(-1);
|
|
40
|
+
const checkInside = (editor, { moving }, targetPath) => {
|
|
41
|
+
if (!moving) return;
|
|
42
|
+
const targetRoot = getEditorRuntimeRoot(editor);
|
|
43
|
+
if (moving.root === targetRoot && moving.entries.some(([, path]) => PathApi.equals(path, targetPath) || PathApi.isAncestor(path, targetPath))) refuse("inside-source");
|
|
44
|
+
if (targetRoot !== "main" && reachableRoots(editor, editor.read.value(), moving.entries.map(([node]) => node)).has(targetRoot)) refuse("inside-source");
|
|
45
|
+
};
|
|
46
|
+
const checkIdentity = (editor, request, edge, targetPath) => {
|
|
47
|
+
checkInside(editor, request, targetPath);
|
|
48
|
+
const { moving } = request;
|
|
49
|
+
if (!moving || moving.root !== getEditorRuntimeRoot(editor)) return;
|
|
50
|
+
const parentPath = targetPath.slice(0, -1);
|
|
51
|
+
const index = insertionIndex(edge, targetPath);
|
|
52
|
+
const indices = moving.entries.map(([, path]) => path.at(-1));
|
|
53
|
+
if (moving.entries.every(([, path]) => PathApi.equals(path.slice(0, -1), parentPath)) && indices.every((value, i) => i === 0 || value === indices[i - 1] + 1) && index >= indices[0] && index <= indices.at(-1) + 1) refuse("no-op");
|
|
54
|
+
};
|
|
55
|
+
const checkPlacement = (editor, { fit, intent, moving }, edge, targetPath, replacing = []) => {
|
|
56
|
+
const parentPath = targetPath.slice(0, -1);
|
|
57
|
+
const parent = parentPath.length === 0 ? null : editor.read.nodes.get(parentPath)?.[0];
|
|
58
|
+
const root = getEditorRuntimeRoot(editor);
|
|
59
|
+
const removing = moving?.root === root ? moving.entries.filter(([, path]) => PathApi.equals(path.slice(0, -1), parentPath)).map(([, path]) => path.at(-1)) : [];
|
|
60
|
+
if (!getEditorSchema(editor).canPlaceAt(parent, parent ? parent.children : editor.read.children(), fit, insertionIndex(edge, targetPath), {
|
|
61
|
+
removing: [...removing, ...replacing],
|
|
62
|
+
root,
|
|
63
|
+
strict: intent === "copy"
|
|
64
|
+
})) refuse("schema");
|
|
65
|
+
};
|
|
66
|
+
const runVetoes = (editor, input) => {
|
|
67
|
+
for (const veto of getPluginContributions(editor, transferVeto)) if (veto(input, editor)) refuse("policy");
|
|
68
|
+
};
|
|
69
|
+
const landingInput = (request, edge, target) => ({
|
|
70
|
+
edge: edge.edge,
|
|
71
|
+
from: request.from,
|
|
72
|
+
intent: request.intent,
|
|
73
|
+
payload: request.payload,
|
|
74
|
+
relation: request.relation,
|
|
75
|
+
target
|
|
76
|
+
});
|
|
77
|
+
const readLanding = (editor, input, edge) => executeEditorRead(editor, editorReads.transfer.landing, input, () => edge, editor);
|
|
78
|
+
const sameEdge = (a, b) => a.key === b.key && a.edge === b.edge;
|
|
79
|
+
/** @internal */
|
|
80
|
+
const landingMetrics = { copiedEntries: 0 };
|
|
81
|
+
const copyChildren = (node) => {
|
|
82
|
+
landingMetrics.copiedEntries += node.children.length;
|
|
83
|
+
return {
|
|
84
|
+
...node,
|
|
85
|
+
children: [...node.children]
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
const patchAt = (roots, path, properties, owned) => {
|
|
89
|
+
let siblings = roots;
|
|
90
|
+
for (const [depth, index] of path.entries()) {
|
|
91
|
+
const found = siblings[index];
|
|
92
|
+
const node = ElementApi.isElement(found) ? found : refuse("policy");
|
|
93
|
+
const copy = owned.has(node) ? node : copyChildren(node);
|
|
94
|
+
const next = depth === path.length - 1 ? Object.fromEntries(Object.entries({
|
|
95
|
+
...copy,
|
|
96
|
+
...properties
|
|
97
|
+
}).filter(([, value]) => value !== void 0)) : copy;
|
|
98
|
+
owned.add(next);
|
|
99
|
+
siblings[index] = next;
|
|
100
|
+
siblings = next.children;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const adoptAt = (editor, { fit, intent, payload }, { input }) => {
|
|
104
|
+
if (payload.kind !== "nodes") return null;
|
|
105
|
+
const patches = executeEditorRead(editor, editorReads.transfer.adopt, {
|
|
106
|
+
...input,
|
|
107
|
+
payload
|
|
108
|
+
}, () => [], editor);
|
|
109
|
+
if (patches.length === 0) return null;
|
|
110
|
+
const schema = getEditorSchema(editor);
|
|
111
|
+
const root = getEditorRuntimeRoot(editor);
|
|
112
|
+
const [, targetPath] = input.target;
|
|
113
|
+
const destination = targetPath.slice(0, -1).map((_, depth) => editor.read.nodes.get(targetPath.slice(0, depth + 1))?.[0]).filter((node) => ElementApi.isElement(node)).reverse();
|
|
114
|
+
const fitted = [...fit];
|
|
115
|
+
const nodes = [...payload.nodes];
|
|
116
|
+
const owned = /* @__PURE__ */ new WeakSet();
|
|
117
|
+
landingMetrics.copiedEntries += fitted.length + nodes.length;
|
|
118
|
+
for (const { at, properties } of patches) {
|
|
119
|
+
const ancestors = [];
|
|
120
|
+
let children = nodes;
|
|
121
|
+
let element;
|
|
122
|
+
for (const index of at) {
|
|
123
|
+
if (element) ancestors.unshift(element);
|
|
124
|
+
const node = children[index];
|
|
125
|
+
if (!ElementApi.isElement(node)) return refuse("policy");
|
|
126
|
+
element = node;
|
|
127
|
+
({children} = node);
|
|
128
|
+
}
|
|
129
|
+
if (!element || intent === "move" && Object.values(properties).includes(null) || Object.keys(properties).some((key) => schema.elementPropertyLanding(element, key, [...ancestors, ...destination], root) !== "adopt")) return refuse("policy");
|
|
130
|
+
patchAt(nodes, at, properties, owned);
|
|
131
|
+
patchAt(fitted, at, properties, owned);
|
|
132
|
+
}
|
|
133
|
+
return {
|
|
134
|
+
fit: fitted,
|
|
135
|
+
patches,
|
|
136
|
+
payload: {
|
|
137
|
+
...payload,
|
|
138
|
+
nodes
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
const judgeLanding = (editor, request, { edge, input, target: [, path] }, adopted) => {
|
|
143
|
+
checkPlacement(editor, adopted ? {
|
|
144
|
+
...request,
|
|
145
|
+
fit: adopted.fit
|
|
146
|
+
} : request, edge, path);
|
|
147
|
+
runVetoes(editor, adopted ? {
|
|
148
|
+
...input,
|
|
149
|
+
payload: adopted.payload
|
|
150
|
+
} : input);
|
|
151
|
+
return {
|
|
152
|
+
adopted,
|
|
153
|
+
edge
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
const resolveLanding = (editor, request, edge) => {
|
|
157
|
+
const target = liveTarget(editor, edge);
|
|
158
|
+
checkIdentity(editor, request, edge, target[1]);
|
|
159
|
+
const to = readLanding(editor, landingInput(request, edge, target), edge);
|
|
160
|
+
const redirected = !sameEdge(to, edge);
|
|
161
|
+
const final = redirected ? liveTarget(editor, to) : target;
|
|
162
|
+
const input = landingInput(request, to, final);
|
|
163
|
+
if (redirected) {
|
|
164
|
+
if (!sameEdge(readLanding(editor, input, to), to)) refuse("policy");
|
|
165
|
+
checkIdentity(editor, request, to, final[1]);
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
edge: to,
|
|
169
|
+
input,
|
|
170
|
+
target: final
|
|
171
|
+
};
|
|
172
|
+
};
|
|
173
|
+
const landAt = (editor, request, edge) => {
|
|
174
|
+
const resolved = resolveLanding(editor, request, edge);
|
|
175
|
+
return judgeLanding(editor, request, resolved, adoptAt(editor, request, resolved));
|
|
176
|
+
};
|
|
177
|
+
const withSlot = (shell, slot, children) => {
|
|
178
|
+
if (slot.length === 0) return {
|
|
179
|
+
...shell,
|
|
180
|
+
children: [...children]
|
|
181
|
+
};
|
|
182
|
+
const [index, ...rest] = slot;
|
|
183
|
+
return {
|
|
184
|
+
...shell,
|
|
185
|
+
children: shell.children.map((child, i) => i === index ? withSlot(child, rest, children) : child)
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
const slotIn = (shell, slot) => {
|
|
189
|
+
const element = slot.length === 0 ? shell : NodeApi.getIf(shell, slot);
|
|
190
|
+
return ElementApi.isElement(element) && element.children.length === 0 ? element : null;
|
|
191
|
+
};
|
|
192
|
+
const checkSlot = (editor, slot, fit) => {
|
|
193
|
+
if (!getEditorSchema(editor).canPlaceAt(slot, [], fit, 0, { root: getEditorRuntimeRoot(editor) })) refuse("schema");
|
|
194
|
+
};
|
|
195
|
+
/**
|
|
196
|
+
* A wrap that takes the target's place moves the target alone, so a target
|
|
197
|
+
* whose feature family reaches past it refuses.
|
|
198
|
+
*/
|
|
199
|
+
const landBeside = (editor, request, moving, side) => {
|
|
200
|
+
const target = liveTarget(editor, side);
|
|
201
|
+
const [targetNode, targetPath] = target;
|
|
202
|
+
checkInside(editor, request, targetPath);
|
|
203
|
+
const wrap = executeEditorRead(editor, editorReads.transfer.side, {
|
|
204
|
+
from: request.from,
|
|
205
|
+
intent: request.intent,
|
|
206
|
+
payload: request.payload,
|
|
207
|
+
relation: request.relation,
|
|
208
|
+
side: side.side,
|
|
209
|
+
target
|
|
210
|
+
}, () => null, editor);
|
|
211
|
+
const payloadSlot = wrap && slotIn(wrap.shell, wrap.payload);
|
|
212
|
+
const targetSlot = wrap && "target" in wrap ? slotIn(wrap.shell, wrap.target) : null;
|
|
213
|
+
if (!wrap || !payloadSlot || "target" in wrap && (!targetSlot || PathApi.equals(wrap.target, wrap.payload))) return refuse("policy");
|
|
214
|
+
let anchor;
|
|
215
|
+
let replaced = null;
|
|
216
|
+
if ("target" in wrap) {
|
|
217
|
+
if (moving.entries.some(([, path]) => PathApi.isAncestor(targetPath, path))) refuse("inside-source");
|
|
218
|
+
if (executeEditorRead(editor, editorReads.transfer.source, { selection: SelectionApi.nodes([targetPath], { mode: "block" }) }, ({ selection }) => selection, editor).paths.some((path) => !PathApi.equals(path, targetPath))) return refuse("policy");
|
|
219
|
+
anchor = {
|
|
220
|
+
edge: "before",
|
|
221
|
+
key: side.key
|
|
222
|
+
};
|
|
223
|
+
replaced = {
|
|
224
|
+
key: side.key,
|
|
225
|
+
node: targetNode,
|
|
226
|
+
slot: wrap.target
|
|
227
|
+
};
|
|
228
|
+
} else {
|
|
229
|
+
const key = wrap.ancestor >= 0 && wrap.ancestor < targetPath.length ? editor.key(targetPath.slice(0, targetPath.length - wrap.ancestor)) : null;
|
|
230
|
+
if (!key) return refuse("policy");
|
|
231
|
+
anchor = {
|
|
232
|
+
edge: wrap.edge,
|
|
233
|
+
key
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
const anchorEntry = liveTarget(editor, anchor);
|
|
237
|
+
const [, anchorPath] = anchorEntry;
|
|
238
|
+
const filled = withSlot(wrap.shell, wrap.payload, request.fit);
|
|
239
|
+
checkPlacement(editor, {
|
|
240
|
+
...request,
|
|
241
|
+
fit: [replaced ? withSlot(filled, replaced.slot, [targetNode]) : filled]
|
|
242
|
+
}, anchor, anchorPath, replaced ? [anchorPath.at(-1)] : []);
|
|
243
|
+
checkSlot(editor, payloadSlot, request.fit);
|
|
244
|
+
if (targetSlot) checkSlot(editor, targetSlot, [targetNode]);
|
|
245
|
+
const input = {
|
|
246
|
+
...landingInput(request, anchor, anchorEntry),
|
|
247
|
+
wrap
|
|
248
|
+
};
|
|
249
|
+
runVetoes(editor, input);
|
|
250
|
+
if (replaced) {
|
|
251
|
+
const parentPath = targetPath.slice(0, -1);
|
|
252
|
+
runVetoes(editor, {
|
|
253
|
+
...input,
|
|
254
|
+
from: editor,
|
|
255
|
+
intent: "move",
|
|
256
|
+
payload: {
|
|
257
|
+
kind: "nodes",
|
|
258
|
+
nodes: [targetNode],
|
|
259
|
+
parentKeys: [parentPath.length > 0 ? editor.key(parentPath) : null]
|
|
260
|
+
},
|
|
261
|
+
relation: "document"
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
return {
|
|
265
|
+
anchor,
|
|
266
|
+
payload: wrap.payload,
|
|
267
|
+
replaced,
|
|
268
|
+
shell: wrap.shell
|
|
269
|
+
};
|
|
270
|
+
};
|
|
271
|
+
//#endregion
|
|
272
|
+
//#region src/core/moved-anchors.ts
|
|
273
|
+
const SUSPENDED_PLACEMENT = /* @__PURE__ */ new WeakMap();
|
|
274
|
+
const suspendMovePlacement = (editor) => {
|
|
275
|
+
let bound = true;
|
|
276
|
+
SUSPENDED_PLACEMENT.set(editor, (SUSPENDED_PLACEMENT.get(editor) ?? 0) + 1);
|
|
277
|
+
return () => {
|
|
278
|
+
if (!bound) return;
|
|
279
|
+
bound = false;
|
|
280
|
+
const left = getDefined(SUSPENDED_PLACEMENT.get(editor)) - 1;
|
|
281
|
+
if (left > 0) SUSPENDED_PLACEMENT.set(editor, left);
|
|
282
|
+
else SUSPENDED_PLACEMENT.delete(editor);
|
|
283
|
+
};
|
|
284
|
+
};
|
|
285
|
+
const contentOf = (editor, index, from, to) => {
|
|
286
|
+
const tokens = [];
|
|
287
|
+
const { isVoid } = getEditorSchema(editor);
|
|
288
|
+
for (const entry of index.nodeRangesTouching(from, to)) if (entry.kind === "text") {
|
|
289
|
+
const { text } = index.node(entry.path);
|
|
290
|
+
const end = Math.min(to, entry.contentTo);
|
|
291
|
+
for (let at = Math.max(from, entry.contentFrom); at < end; at++) tokens.push([
|
|
292
|
+
at,
|
|
293
|
+
"text",
|
|
294
|
+
text[at - entry.contentFrom]
|
|
295
|
+
]);
|
|
296
|
+
} else {
|
|
297
|
+
const node = index.node(entry.path);
|
|
298
|
+
const kind = isVoid(node) ? "void" : "block";
|
|
299
|
+
if (entry.from >= from && entry.from < to) tokens.push([
|
|
300
|
+
entry.from,
|
|
301
|
+
`${kind}-open`,
|
|
302
|
+
kind === "void" ? node.type : void 0
|
|
303
|
+
]);
|
|
304
|
+
if (entry.to > from && entry.to <= to) tokens.push([entry.to - 1, `${kind}-close`]);
|
|
305
|
+
}
|
|
306
|
+
return tokens.sort((left, right) => left[0] - right[0]);
|
|
307
|
+
};
|
|
308
|
+
const collectMovedAnchors = (editor, root, source) => {
|
|
309
|
+
const { builder } = getDefined(getTransactionSnapshot(editor));
|
|
310
|
+
if (SUSPENDED_PLACEMENT.has(editor)) return null;
|
|
311
|
+
const index = builder.getIndex(root);
|
|
312
|
+
const schema = getEditorSchema(editor);
|
|
313
|
+
const [from, to] = RangeApi.edges(source).map((point) => index.positionAt(point));
|
|
314
|
+
const tokenHoldsContent = (at) => index.nodeRangesTouching(at, at + 1).some((entry) => entry.kind === "text" ? entry.contentFrom <= at && at < entry.contentTo : entry.from <= at && at < entry.to && schema.isVoid(index.node(entry.path)));
|
|
315
|
+
let low = from;
|
|
316
|
+
while (low > 0 && !tokenHoldsContent(low - 1)) low -= 1;
|
|
317
|
+
const keys = withEditorRootChildren(editor, root, () => index.nodeRangesTouching(Math.max(0, low - 1), Math.min(index.length, to + 1)).flatMap(({ path }) => getEditorRuntime(editor).getNodeKey(path) ?? []));
|
|
318
|
+
const kept = [];
|
|
319
|
+
for (const listener of getMovableAnchors(editor, keys)) {
|
|
320
|
+
const span = listener.root === root && listener.move?.span(index, builder.value);
|
|
321
|
+
if (!span) continue;
|
|
322
|
+
const first = Math.min(...span);
|
|
323
|
+
const last = Math.max(...span);
|
|
324
|
+
if (!coversContent(index, first, from, schema) && !coversContent(index, to, last, schema) && coversContent(index, Math.max(first, from), Math.min(last, to), schema)) kept.push([listener, span]);
|
|
325
|
+
}
|
|
326
|
+
if (kept.length === 0) return null;
|
|
327
|
+
const tokens = contentOf(editor, index, from, to);
|
|
328
|
+
const tokensBefore = (position) => {
|
|
329
|
+
let below = 0;
|
|
330
|
+
let above = tokens.length;
|
|
331
|
+
while (below < above) {
|
|
332
|
+
const middle = below + above >> 1;
|
|
333
|
+
if (tokens[middle][0] < position) below = middle + 1;
|
|
334
|
+
else above = middle;
|
|
335
|
+
}
|
|
336
|
+
return below;
|
|
337
|
+
};
|
|
338
|
+
return {
|
|
339
|
+
anchors: kept.map(([listener, span]) => [
|
|
340
|
+
listener,
|
|
341
|
+
tokensBefore(span[0]),
|
|
342
|
+
tokensBefore(span[1])
|
|
343
|
+
]),
|
|
344
|
+
from,
|
|
345
|
+
root,
|
|
346
|
+
struck: isEditorDraftView(editor),
|
|
347
|
+
to,
|
|
348
|
+
tokens
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
const runOf = (tokens, kind, last) => {
|
|
352
|
+
let count = 0;
|
|
353
|
+
while (tokens.at(last ? -1 - count : count)?.[1] === kind) count += 1;
|
|
354
|
+
return count;
|
|
355
|
+
};
|
|
356
|
+
const trimWrapperBlocks = (tokens, moved) => tokens.slice(Math.max(0, runOf(tokens, "block-open", false) - runOf(moved, "block-open", false)), tokens.length - Math.max(0, runOf(tokens, "block-close", true) - runOf(moved, "block-close", true)));
|
|
357
|
+
const placeMovedAnchors = (editor, moved, track) => placeAnchorsOnCommit(editor, (context, place) => {
|
|
358
|
+
const spans = settleDraftTrack(track);
|
|
359
|
+
if (!spans?.length) return;
|
|
360
|
+
const after = context.afterRoot(moved.root);
|
|
361
|
+
const landFrom = spans[0].from;
|
|
362
|
+
const landTo = getDefined(spans.at(-1)).to;
|
|
363
|
+
const [from, to] = [moved.from, moved.to].map((position, end) => mapInternalDocumentChangePosition(context.change, moved.root, position, end ? -1 : 1));
|
|
364
|
+
const struckSource = moved.struck && from !== null && to !== null ? [[from, Math.min(to, landFrom)], [Math.max(from, landTo), to]].filter(([start, end]) => start < end).flatMap(([start, end]) => contentOf(editor, after, start, end)) : [];
|
|
365
|
+
const matchingMoved = (tokens) => {
|
|
366
|
+
const kept = trimWrapperBlocks(tokens, moved.tokens);
|
|
367
|
+
return kept.length === moved.tokens.length && kept.every(([, kind, letter], at) => kind === moved.tokens[at][1] && letter === moved.tokens[at][2]) ? kept : void 0;
|
|
368
|
+
};
|
|
369
|
+
const landed = matchingMoved(struckSource.some(([, kind]) => !kind.startsWith("block")) ? struckSource : contentOf(editor, after, landFrom, landTo));
|
|
370
|
+
if (!landed) return;
|
|
371
|
+
const kindPastBlockEdges = (start, step) => {
|
|
372
|
+
let at = start;
|
|
373
|
+
while (landed[at]?.[1].startsWith("block")) at += step;
|
|
374
|
+
return landed[at]?.[1];
|
|
375
|
+
};
|
|
376
|
+
const places = /* @__PURE__ */ new Map();
|
|
377
|
+
const endPlace = (count) => {
|
|
378
|
+
const known = places.get(count);
|
|
379
|
+
if (known) return known;
|
|
380
|
+
const before = landed[count - 1];
|
|
381
|
+
const next = landed[count];
|
|
382
|
+
const anchorPlace = {
|
|
383
|
+
backward: before ? [before[0] + 1, kindPastBlockEdges(count - 1, -1) === "void-close" ? 1 : -1] : [next[0], -1],
|
|
384
|
+
forward: next ? [next[0], kindPastBlockEdges(count, 1) === "void-open" ? -1 : 1] : [before[0] + 1, 1]
|
|
385
|
+
};
|
|
386
|
+
places.set(count, anchorPlace);
|
|
387
|
+
return anchorPlace;
|
|
388
|
+
};
|
|
389
|
+
for (const [listener, first, second] of moved.anchors) place(listener, endPlace(first), endPlace(second));
|
|
390
|
+
});
|
|
391
|
+
//#endregion
|
|
392
|
+
//#region src/core/transfer-guard.ts
|
|
393
|
+
const rootChildren = (value, root) => root === "main" ? value.children : value.roots?.[root] ?? [];
|
|
394
|
+
const childrenAt = (children, path) => {
|
|
395
|
+
let current = children;
|
|
396
|
+
for (const index of path) {
|
|
397
|
+
const node = current[index];
|
|
398
|
+
if (!node || !ElementApi.isElement(node)) return null;
|
|
399
|
+
({children: current} = node);
|
|
400
|
+
}
|
|
401
|
+
return current;
|
|
402
|
+
};
|
|
403
|
+
const nodeAt = (children, path) => path.length === 0 ? null : childrenAt(children, path.slice(0, -1))?.[path.at(-1)] ?? null;
|
|
404
|
+
/** The elements above `path` in `children`, nearest first. */
|
|
405
|
+
const ancestorsAt = (children, path) => {
|
|
406
|
+
const ancestors = [];
|
|
407
|
+
let current = children;
|
|
408
|
+
for (const index of path.slice(0, -1)) {
|
|
409
|
+
const node = current[index];
|
|
410
|
+
if (!node || !ElementApi.isElement(node)) break;
|
|
411
|
+
ancestors.unshift(node);
|
|
412
|
+
({children: current} = node);
|
|
413
|
+
}
|
|
414
|
+
return ancestors;
|
|
415
|
+
};
|
|
416
|
+
/**
|
|
417
|
+
* Visits each node of `nodes`, the fragment of a range that starts at `start`,
|
|
418
|
+
* with its path in the children the range was read from.
|
|
419
|
+
*/
|
|
420
|
+
const eachFragmentNode = (nodes, start, visit) => {
|
|
421
|
+
const walk = (list, parent, onStartEdge) => {
|
|
422
|
+
list.forEach((node, at) => {
|
|
423
|
+
const path = [...parent, onStartEdge ? start[parent.length] + at : at];
|
|
424
|
+
visit(node, path);
|
|
425
|
+
if (ElementApi.isElement(node)) walk(node.children, path, onStartEdge && at === 0);
|
|
426
|
+
});
|
|
427
|
+
};
|
|
428
|
+
walk(nodes, [], true);
|
|
429
|
+
};
|
|
430
|
+
const NO_KEYS = /* @__PURE__ */ new Set();
|
|
431
|
+
const noDroppedKeys = () => NO_KEYS;
|
|
432
|
+
/** The drops `steps` recorded, by the node each value was carried from. */
|
|
433
|
+
const droppedKeysOf = (steps) => {
|
|
434
|
+
const keys = /* @__PURE__ */ new Map();
|
|
435
|
+
for (const step of steps) for (const { key, place } of step.drops ?? []) {
|
|
436
|
+
const entry = place?.document.nodeStartingAt(place.at);
|
|
437
|
+
if (!place || entry?.from !== place.at) continue;
|
|
438
|
+
const node = place.document.node(entry.path);
|
|
439
|
+
const found = keys.get(node) ?? /* @__PURE__ */ new Set();
|
|
440
|
+
found.add(key);
|
|
441
|
+
keys.set(node, found);
|
|
442
|
+
}
|
|
443
|
+
return keys.size === 0 ? noDroppedKeys : (source) => keys.get(source) ?? NO_KEYS;
|
|
444
|
+
};
|
|
445
|
+
const withoutDropped = (expected, landed, dropped) => dropped.size === 0 ? expected : Object.fromEntries(Object.entries(expected).filter(([key]) => !dropped.has(key) || Object.hasOwn(landed, key)));
|
|
446
|
+
const sameContent = (a, aRoots, b, bRoots, dropped = noDroppedKeys) => {
|
|
447
|
+
if (NodeApi.isText(a) || NodeApi.isText(b)) return canonicalJsonKey(withoutDropped(a, b, dropped(a))) === canonicalJsonKey(b);
|
|
448
|
+
const { children: aChildren, childRoots: aChildRoots, ...aProps } = a;
|
|
449
|
+
const { children: bChildren, childRoots: bChildRoots, ...bProps } = b;
|
|
450
|
+
if (canonicalJsonKey(withoutDropped(aProps, bProps, dropped(a))) !== canonicalJsonKey(bProps)) return false;
|
|
451
|
+
if (aChildren.length !== bChildren.length) return false;
|
|
452
|
+
const aRootNames = Object.keys(aChildRoots ?? {}).sort();
|
|
453
|
+
const bRootNames = Object.keys(bChildRoots ?? {}).sort();
|
|
454
|
+
if (aRootNames.join(",") !== bRootNames.join(",")) return false;
|
|
455
|
+
for (const slot of aRootNames) {
|
|
456
|
+
const aRoot = aRoots?.[aChildRoots?.[slot]] ?? [];
|
|
457
|
+
const bRoot = bRoots?.[bChildRoots?.[slot]] ?? [];
|
|
458
|
+
if (aRoot.length !== bRoot.length || aRoot.some((node, i) => !sameContent(node, aRoots, bRoot[i], bRoots, dropped))) return false;
|
|
459
|
+
}
|
|
460
|
+
return aChildren.every((child, i) => sameContent(child, aRoots, bChildren[i], bRoots, dropped));
|
|
461
|
+
};
|
|
462
|
+
const firstOf = (list) => list[0];
|
|
463
|
+
const lastOf = (list) => list.at(-1);
|
|
464
|
+
const nonEmpty = (nodes) => nodes.filter((node) => !NodeApi.isText(node) || node.text !== "");
|
|
465
|
+
const edgeDepth = (nodes, edge) => {
|
|
466
|
+
let depth = 0;
|
|
467
|
+
for (let node = edge(nonEmpty(nodes)); node && ElementApi.isElement(node); node = edge(nonEmpty(node.children))) depth += 1;
|
|
468
|
+
return depth;
|
|
469
|
+
};
|
|
470
|
+
const closedEdges = ({ content, openEnd, openStart }) => ({
|
|
471
|
+
end: edgeDepth(content, lastOf) - openEnd,
|
|
472
|
+
start: edgeDepth(content, firstOf) - openStart
|
|
473
|
+
});
|
|
474
|
+
const openAtEdge = (node, atStart, atEnd, closed) => !!closed && (atStart && edgeDepth([node], firstOf) > closed.start || atEnd && edgeDepth([node], lastOf) > closed.end);
|
|
475
|
+
const textTokens = (fragment, closed, kind) => {
|
|
476
|
+
const tokens = [];
|
|
477
|
+
const visit = (nodes, onStart, onEnd) => {
|
|
478
|
+
const list = nonEmpty(nodes);
|
|
479
|
+
list.forEach((node, index) => {
|
|
480
|
+
if (NodeApi.isText(node)) {
|
|
481
|
+
tokens.push(canonicalJsonKey(node));
|
|
482
|
+
return;
|
|
483
|
+
}
|
|
484
|
+
const atStart = onStart && index === 0;
|
|
485
|
+
const atEnd = onEnd && index === list.length - 1;
|
|
486
|
+
const open = openAtEdge(node, atStart, atEnd, closed);
|
|
487
|
+
if (!open) {
|
|
488
|
+
const { children: _children, ...props } = node;
|
|
489
|
+
tokens.push(`<${canonicalJsonKey(props)}>`);
|
|
490
|
+
}
|
|
491
|
+
if (kind(node) === "void") for (const child of node.children) tokens.push(canonicalJsonKey(child));
|
|
492
|
+
else visit(node.children, atStart, atEnd);
|
|
493
|
+
if (!open) tokens.push("</>");
|
|
494
|
+
});
|
|
495
|
+
};
|
|
496
|
+
visit(fragment, true, true);
|
|
497
|
+
return tokens.join("\0");
|
|
498
|
+
};
|
|
499
|
+
const headChain = (nodes, kind) => {
|
|
500
|
+
const chain = [];
|
|
501
|
+
let node = nodes[0];
|
|
502
|
+
while (node && ElementApi.isElement(node) && kind(node) === "block") {
|
|
503
|
+
chain.push(node);
|
|
504
|
+
node = node.children[0];
|
|
505
|
+
}
|
|
506
|
+
return chain;
|
|
507
|
+
};
|
|
508
|
+
const openPrefix = (slice, chain) => {
|
|
509
|
+
let nodes = slice.content;
|
|
510
|
+
let count = 0;
|
|
511
|
+
while (count < slice.openStart && count < chain.length && nodes[0] === chain[count]) {
|
|
512
|
+
nodes = chain[count].children;
|
|
513
|
+
count += 1;
|
|
514
|
+
}
|
|
515
|
+
return count;
|
|
516
|
+
};
|
|
517
|
+
const payloadItems = (nodes, exempt) => {
|
|
518
|
+
const items = [];
|
|
519
|
+
const visit = (list, ancestors) => {
|
|
520
|
+
for (const node of list) {
|
|
521
|
+
if (NodeApi.isText(node)) {
|
|
522
|
+
if (node.text !== "") items.push({ text: node });
|
|
523
|
+
continue;
|
|
524
|
+
}
|
|
525
|
+
const shown = !exempt.has(node);
|
|
526
|
+
if (shown) items.push({
|
|
527
|
+
ancestors,
|
|
528
|
+
element: node
|
|
529
|
+
});
|
|
530
|
+
visit(node.children, [node, ...ancestors]);
|
|
531
|
+
if (shown) items.push("</>");
|
|
532
|
+
}
|
|
533
|
+
};
|
|
534
|
+
visit(nodes, []);
|
|
535
|
+
return items;
|
|
536
|
+
};
|
|
537
|
+
const belowCarried = (nodes, kind, carried) => {
|
|
538
|
+
const chain = headChain(nodes, kind);
|
|
539
|
+
const atDrop = chain.length - carried;
|
|
540
|
+
return atDrop < 0 ? null : {
|
|
541
|
+
head: chain[atDrop] ?? null,
|
|
542
|
+
items: payloadItems(nodes, new Set(chain.slice(0, atDrop)))
|
|
543
|
+
};
|
|
544
|
+
};
|
|
545
|
+
const shellOf = (element, skip) => {
|
|
546
|
+
const { children: _children, ...props } = element;
|
|
547
|
+
return canonicalJsonKey(Object.fromEntries(Object.entries(props).filter(([key]) => !skip(key))));
|
|
548
|
+
};
|
|
549
|
+
const carryMove = ({ followsDrop, kind, moved, replaced, sources = /* @__PURE__ */ new Map(), written }) => {
|
|
550
|
+
const movedChain = headChain(moved.content, kind);
|
|
551
|
+
const writtenChain = headChain(written.content, kind);
|
|
552
|
+
const uncarried = movedChain.length - writtenChain.length + openPrefix(written, writtenChain);
|
|
553
|
+
const addsShell = uncarried < 0;
|
|
554
|
+
const losesShell = uncarried > openPrefix(moved, movedChain);
|
|
555
|
+
if (addsShell || losesShell) return null;
|
|
556
|
+
const head = movedChain[uncarried] ?? null;
|
|
557
|
+
return {
|
|
558
|
+
carried: movedChain.length - uncarried,
|
|
559
|
+
followsDrop,
|
|
560
|
+
head,
|
|
561
|
+
inherited: head && replaced ? Object.fromEntries(Object.entries(replaced).filter(([key]) => !(key in head))) : null,
|
|
562
|
+
items: payloadItems(moved.content, new Set(movedChain.slice(0, uncarried))),
|
|
563
|
+
kind,
|
|
564
|
+
sources
|
|
565
|
+
};
|
|
566
|
+
};
|
|
567
|
+
const landsMoved = (landed, { carried, followsDrop, head, inherited, items, kind, sources }, dropped = noDroppedKeys) => {
|
|
568
|
+
const below = belowCarried(landed, kind, carried);
|
|
569
|
+
if (!below) return false;
|
|
570
|
+
const droppedFrom = (node) => {
|
|
571
|
+
const source = sources.get(node);
|
|
572
|
+
return source ? dropped(source) : NO_KEYS;
|
|
573
|
+
};
|
|
574
|
+
const inheritedBy = (element, isHead) => (key) => isHead && !!inherited && Object.hasOwn(inherited, key) && canonicalJsonKey(element[key]) === canonicalJsonKey(inherited[key]);
|
|
575
|
+
return below.items.length === items.length && below.items.every((item, index) => {
|
|
576
|
+
const expected = items[index];
|
|
577
|
+
if (typeof item === "string" || typeof expected === "string") return item === expected;
|
|
578
|
+
if ("text" in item || "text" in expected) {
|
|
579
|
+
if (!("text" in item) || !("text" in expected)) return false;
|
|
580
|
+
return canonicalJsonKey(withoutDropped(expected.text, item.text, droppedFrom(expected.text))) === canonicalJsonKey(item.text);
|
|
581
|
+
}
|
|
582
|
+
const skip = followsDrop(item.element, item.ancestors);
|
|
583
|
+
const landedInherits = inheritedBy(item.element, item.element === below.head);
|
|
584
|
+
const expectedInherits = inheritedBy(expected.element, expected.element === head);
|
|
585
|
+
const dropsHere = droppedFrom(expected.element);
|
|
586
|
+
return shellOf(item.element, (key) => skip(key) || landedInherits(key)) === shellOf(expected.element, (key) => skip(key) || expectedInherits(key) || dropsHere.has(key) && !Object.hasOwn(item.element, key));
|
|
587
|
+
});
|
|
588
|
+
};
|
|
589
|
+
const selectionRange = (from, to) => ({
|
|
590
|
+
anchor: from,
|
|
591
|
+
focus: to
|
|
592
|
+
});
|
|
593
|
+
const trackedRange = (index, { from, to }) => {
|
|
594
|
+
const start = index.pointAt(from, 1);
|
|
595
|
+
const end = index.pointAt(to, -1);
|
|
596
|
+
return start && end ? selectionRange({
|
|
597
|
+
offset: start.offset,
|
|
598
|
+
path: [...start.path]
|
|
599
|
+
}, {
|
|
600
|
+
offset: end.offset,
|
|
601
|
+
path: [...end.path]
|
|
602
|
+
}) : null;
|
|
603
|
+
};
|
|
604
|
+
const childRootNames = (element) => {
|
|
605
|
+
const { childRoots } = element;
|
|
606
|
+
return childRoots ? Object.keys(childRoots).sort().map((slot) => childRoots[slot]) : [];
|
|
607
|
+
};
|
|
608
|
+
const PLACE_MARK = "\0";
|
|
609
|
+
const apartFromPlaces = (name) => name.startsWith(PLACE_MARK) ? `${PLACE_MARK}${name}` : void 0;
|
|
610
|
+
const copyNormalizer = (schema, copyChildren, root) => {
|
|
611
|
+
const unique = uniquePropertiesOf(schema);
|
|
612
|
+
const referenced = new Set([...schema.properties.byId.values()].flatMap(({ references }) => references && unique.has(references.key) ? [references.key] : []));
|
|
613
|
+
return (nodes, roots, { closed, nearestAncestorsOf = () => [] } = {}) => {
|
|
614
|
+
const places = /* @__PURE__ */ new Map();
|
|
615
|
+
const walked = /* @__PURE__ */ new Set();
|
|
616
|
+
const inputs = /* @__PURE__ */ new WeakMap();
|
|
617
|
+
const placeHolders = (list, rootPlace, edges) => {
|
|
618
|
+
let carried = 0;
|
|
619
|
+
const visit = (children, onStart, onEnd) => {
|
|
620
|
+
const kept = nonEmpty(children);
|
|
621
|
+
kept.forEach((node, index) => {
|
|
622
|
+
if (!ElementApi.isElement(node)) return;
|
|
623
|
+
const atStart = onStart && index === 0;
|
|
624
|
+
const atEnd = onEnd && index === kept.length - 1;
|
|
625
|
+
if (!openAtEdge(node, atStart, atEnd, edges)) {
|
|
626
|
+
const place = `${rootPlace}.${carried += 1}`;
|
|
627
|
+
for (const key of referenced) {
|
|
628
|
+
if (node[key] === void 0) continue;
|
|
629
|
+
const byValue = places.get(key) ?? /* @__PURE__ */ new Map();
|
|
630
|
+
const value = canonicalJsonKey(node[key]);
|
|
631
|
+
places.set(key, byValue);
|
|
632
|
+
if (!byValue.has(value)) byValue.set(value, place);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
visit(node.children, atStart, atEnd);
|
|
636
|
+
for (const name of childRootNames(node)) {
|
|
637
|
+
if (walked.has(name)) continue;
|
|
638
|
+
walked.add(name);
|
|
639
|
+
placeHolders(roots?.[name] ?? [], `${PLACE_MARK}${walked.size}`);
|
|
640
|
+
}
|
|
641
|
+
});
|
|
642
|
+
};
|
|
643
|
+
visit(list, true, true);
|
|
644
|
+
};
|
|
645
|
+
placeHolders(nodes, `${PLACE_MARK}0`, closed);
|
|
646
|
+
const nameByPlace = (list, ancestors, at) => {
|
|
647
|
+
const out = list.map((node) => {
|
|
648
|
+
if (!ElementApi.isElement(node)) return node;
|
|
649
|
+
const context = toCompiledNodeContext(node, ancestors, at);
|
|
650
|
+
const renamed = {};
|
|
651
|
+
for (const [key, value] of Object.entries(node)) {
|
|
652
|
+
const references = resolveCompiledSchemaProperty(schema, "element", key, context)?.references;
|
|
653
|
+
const byValue = references && places.get(references.key);
|
|
654
|
+
if (!references || !byValue) continue;
|
|
655
|
+
const mapped = references.map(value, (name) => byValue.get(canonicalJsonKey(name)) ?? apartFromPlaces(name));
|
|
656
|
+
if (canonicalJsonKey(mapped) !== canonicalJsonKey(value)) renamed[key] = mapped;
|
|
657
|
+
}
|
|
658
|
+
const element = Object.keys(renamed).length === 0 ? node : {
|
|
659
|
+
...node,
|
|
660
|
+
...renamed
|
|
661
|
+
};
|
|
662
|
+
const children = nameByPlace(node.children, [element, ...ancestors], at);
|
|
663
|
+
return element === node && children === node.children ? node : {
|
|
664
|
+
...element,
|
|
665
|
+
children
|
|
666
|
+
};
|
|
667
|
+
});
|
|
668
|
+
return out.every((node, index) => node === list[index]) ? list : out;
|
|
669
|
+
};
|
|
670
|
+
const copyRecordingInputs = (list, ancestors, at) => {
|
|
671
|
+
const result = copyChildren(places.size === 0 ? list : nameByPlace(list, ancestors, at), at, ancestors);
|
|
672
|
+
const trace = (out, input) => {
|
|
673
|
+
out.forEach((node, index) => {
|
|
674
|
+
const from = input[index];
|
|
675
|
+
if (node === from) return;
|
|
676
|
+
inputs.set(node, from);
|
|
677
|
+
if (ElementApi.isElement(node) && ElementApi.isElement(from)) trace(node.children, from.children);
|
|
678
|
+
});
|
|
679
|
+
};
|
|
680
|
+
trace(result, list);
|
|
681
|
+
return result;
|
|
682
|
+
};
|
|
683
|
+
return {
|
|
684
|
+
nodes: nodes.flatMap((node, index) => copyRecordingInputs([node], nearestAncestorsOf(index), root)),
|
|
685
|
+
roots: roots && {
|
|
686
|
+
...roots,
|
|
687
|
+
...Object.fromEntries([...walked].map((name) => [name, copyRecordingInputs(roots[name] ?? [], [], name)]))
|
|
688
|
+
},
|
|
689
|
+
inputOf: (node) => inputs.get(node) ?? node
|
|
690
|
+
};
|
|
691
|
+
};
|
|
692
|
+
};
|
|
693
|
+
const fragmentOf = (children, range) => NodeApi.fragment({
|
|
694
|
+
children,
|
|
695
|
+
type: ""
|
|
696
|
+
}, range);
|
|
697
|
+
const trackedPaths = (index, spans) => spans.map(({ from, to }) => {
|
|
698
|
+
const entry = index.nodeStartingAt(from);
|
|
699
|
+
return entry && entry.to === to ? [...entry.path] : null;
|
|
700
|
+
});
|
|
701
|
+
const landingHolds = (expected, { children, dropped, index, roots, spans }, copy) => {
|
|
702
|
+
const asCopied = (nodes, from, of) => copy ? copy(nodes, from, of) : {
|
|
703
|
+
inputOf: (node) => node,
|
|
704
|
+
nodes,
|
|
705
|
+
roots: from
|
|
706
|
+
};
|
|
707
|
+
if (expected.kind === "nodes") {
|
|
708
|
+
const paths = trackedPaths(index, spans);
|
|
709
|
+
const nodes = paths.map((path) => path && nodeAt(children, path));
|
|
710
|
+
if (paths.length !== expected.content.length || nodes.some((node) => !node)) return false;
|
|
711
|
+
const of = { nearestAncestorsOf: (at) => ancestorsAt(children, paths[at]) };
|
|
712
|
+
const want = asCopied(expected.content, expected.roots, of);
|
|
713
|
+
const landed = asCopied(nodes, roots, of);
|
|
714
|
+
return landed.nodes.every((node, i) => sameContent(want.nodes[i], want.roots, node, landed.roots, (source) => dropped(want.inputOf(source))));
|
|
715
|
+
}
|
|
716
|
+
const [span] = spans;
|
|
717
|
+
const range = span && trackedRange(index, span);
|
|
718
|
+
if (!range) return false;
|
|
719
|
+
const landed = fragmentOf(children, range);
|
|
720
|
+
if (expected.kind === "range-move") return landsMoved(landed, expected.moved, dropped);
|
|
721
|
+
const { closed, landedKind } = expected;
|
|
722
|
+
return textTokens(asCopied(landed, roots, { closed }).nodes, closed, landedKind) === textTokens(asCopied(expected.content, expected.roots, { closed }).nodes, closed, landedKind);
|
|
723
|
+
};
|
|
724
|
+
/**
|
|
725
|
+
* What a command frame's draft must hold: the landing as the projection the
|
|
726
|
+
* frame started from shows it, or `null` when the projection cannot place the
|
|
727
|
+
* landing.
|
|
728
|
+
*/
|
|
729
|
+
const rebaseLanding = ({ expected, track }, frame, root) => {
|
|
730
|
+
const start = readDraftTrackAt(track, frame);
|
|
731
|
+
if (!start) return null;
|
|
732
|
+
const { value } = frame.start;
|
|
733
|
+
const children = rootChildren(value, root);
|
|
734
|
+
if (expected.kind === "nodes") {
|
|
735
|
+
const content = [];
|
|
736
|
+
for (const path of trackedPaths(start.index, start.spans)) {
|
|
737
|
+
const node = path && nodeAt(children, path);
|
|
738
|
+
if (!path || !node) return null;
|
|
739
|
+
content.push(node);
|
|
740
|
+
}
|
|
741
|
+
return {
|
|
742
|
+
content,
|
|
743
|
+
kind: "nodes",
|
|
744
|
+
roots: value.roots
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
const [span] = start.spans;
|
|
748
|
+
const range = span && trackedRange(start.index, span);
|
|
749
|
+
if (!range) return null;
|
|
750
|
+
const started = fragmentOf(children, range);
|
|
751
|
+
if (expected.kind === "range-copy") return {
|
|
752
|
+
...expected,
|
|
753
|
+
content: started,
|
|
754
|
+
roots: value.roots
|
|
755
|
+
};
|
|
756
|
+
const { moved } = expected;
|
|
757
|
+
const below = belowCarried(started, moved.kind, moved.carried);
|
|
758
|
+
if (!below) return null;
|
|
759
|
+
const sources = /* @__PURE__ */ new Map();
|
|
760
|
+
eachFragmentNode(started, range.anchor.path, (node, path) => {
|
|
761
|
+
const source = nodeAt(children, path);
|
|
762
|
+
if (source) sources.set(node, source);
|
|
763
|
+
});
|
|
764
|
+
return {
|
|
765
|
+
kind: "range-move",
|
|
766
|
+
moved: {
|
|
767
|
+
...moved,
|
|
768
|
+
...below,
|
|
769
|
+
sources
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
};
|
|
773
|
+
const guardLanding = (editor, copy, draft, check, diagnostics) => registerEditorDraftGuard(editor, (written, frame) => {
|
|
774
|
+
const landing = draft.current;
|
|
775
|
+
if (!landing || check(landing, written, frame)) return;
|
|
776
|
+
draft.current = null;
|
|
777
|
+
if (!copy) throw new TransferRefusalError("lossy");
|
|
778
|
+
diagnostics.push({
|
|
779
|
+
impact: "lossy",
|
|
780
|
+
message: "Some dragged content does not fit here."
|
|
781
|
+
});
|
|
782
|
+
}, "plain", "transaction");
|
|
783
|
+
//#endregion
|
|
784
|
+
//#region src/core/transfer.ts
|
|
785
|
+
const targetOf = (landing) => landing.kind === "edge" ? landing.edge : landing.kind === "point" ? { point: landing.point } : landing.side;
|
|
786
|
+
const authoredIdentity = (editor) => {
|
|
787
|
+
const view = readAuthoredView(editor);
|
|
788
|
+
return view && "preview" in view ? view.preview : "native";
|
|
789
|
+
};
|
|
790
|
+
const relationOf = (from, to) => {
|
|
791
|
+
if (getEditorRuntimeOwner(from) !== getEditorRuntimeOwner(to)) return "independent";
|
|
792
|
+
return isDocumentView(from) || isDocumentView(to) || authoredIdentity(from) !== authoredIdentity(to) ? "identity" : "document";
|
|
793
|
+
};
|
|
794
|
+
const pruneAndSort = (entries) => {
|
|
795
|
+
const sorted = [...entries].sort(([, a], [, b]) => PathApi.compare(a, b));
|
|
796
|
+
const kept = [];
|
|
797
|
+
for (const entry of sorted) {
|
|
798
|
+
const previous = kept.at(-1);
|
|
799
|
+
if (previous && PathApi.isAncestor(previous[1], entry[1])) continue;
|
|
800
|
+
kept.push(entry);
|
|
801
|
+
}
|
|
802
|
+
return kept;
|
|
803
|
+
};
|
|
804
|
+
const expandSource = (from, paths) => {
|
|
805
|
+
const expanded = executeEditorRead(from, editorReads.transfer.source, { selection: SelectionApi.nodes(paths, { mode: "block" }) }, ({ selection }) => selection, from);
|
|
806
|
+
return pruneAndSort(expanded.paths.flatMap((path) => {
|
|
807
|
+
const entry = from.read.nodes.get(path);
|
|
808
|
+
return entry ? [entry] : [];
|
|
809
|
+
}));
|
|
810
|
+
};
|
|
811
|
+
const transferEntries = (editor, node) => {
|
|
812
|
+
const selected = editor.read.selection.nodes().map(([, path]) => path);
|
|
813
|
+
const path = node === void 0 ? void 0 : editor.read.nodes.path(node);
|
|
814
|
+
if (node !== void 0 && !path) return [];
|
|
815
|
+
const paths = path ? selected.some((candidate) => PathApi.equals(candidate, path)) ? selected : [path] : selected.length > 0 ? selected : editor.read.nodes.blocks().map(([, blockPath]) => blockPath);
|
|
816
|
+
return paths.length === 0 ? [] : expandSource(editor, paths).filter((entry) => ElementApi.isElement(entry[0]));
|
|
817
|
+
};
|
|
818
|
+
const resolveSource = (from, input) => {
|
|
819
|
+
const root = getEditorRuntimeRoot(from);
|
|
820
|
+
if (input.range) {
|
|
821
|
+
if (RangeApi.isCollapsed(input.range)) refuse("source-missing");
|
|
822
|
+
return {
|
|
823
|
+
deleted: resolveDeletedRange(from, input.range),
|
|
824
|
+
kind: "text",
|
|
825
|
+
range: input.range,
|
|
826
|
+
root
|
|
827
|
+
};
|
|
828
|
+
}
|
|
829
|
+
const found = input.nodes?.map((key) => from.read.nodes.get(key));
|
|
830
|
+
if (found && (found.length === 0 || found.some((entry) => !entry))) refuse("source-missing");
|
|
831
|
+
const entries = found ? expandSource(from, found.map(([, path]) => path)) : transferEntries(from);
|
|
832
|
+
if (entries.length === 0) refuse("source-missing");
|
|
833
|
+
return {
|
|
834
|
+
entries,
|
|
835
|
+
kind: "nodes",
|
|
836
|
+
root
|
|
837
|
+
};
|
|
838
|
+
};
|
|
839
|
+
const payloadOf = (from, source) => source.kind === "text" ? { kind: "text" } : {
|
|
840
|
+
kind: "nodes",
|
|
841
|
+
nodes: source.entries.map(([node]) => node),
|
|
842
|
+
parentKeys: source.entries.map(([, path]) => path.length > 1 ? from.key(path.slice(0, -1)) : null)
|
|
843
|
+
};
|
|
844
|
+
/**
|
|
845
|
+
* Where each node of a moved range's payload came from, so its landing can
|
|
846
|
+
* judge a value the node carried. An open edge block merges into the
|
|
847
|
+
* landing's block instead of landing as itself, so it gets no source.
|
|
848
|
+
*/
|
|
849
|
+
const payloadSourcesOf = (index, range, slice, inline) => {
|
|
850
|
+
const open = /* @__PURE__ */ new Set();
|
|
851
|
+
const edges = [[slice.openStart, (list) => list[0]], [slice.openEnd, (list) => list.at(-1)]];
|
|
852
|
+
for (const [depth, edge] of edges) {
|
|
853
|
+
let list = slice.content;
|
|
854
|
+
for (let level = 0; level < depth; level += 1) {
|
|
855
|
+
const node = edge(list);
|
|
856
|
+
if (!node || !ElementApi.isElement(node)) break;
|
|
857
|
+
if (!inline(node)) open.add(node);
|
|
858
|
+
list = node.children;
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
const [start] = RangeApi.edges(range);
|
|
862
|
+
const landing = [];
|
|
863
|
+
const nodes = /* @__PURE__ */ new Map();
|
|
864
|
+
eachFragmentNode(slice.content, start.path, (node, path) => {
|
|
865
|
+
if (NodeApi.isText(node) ? node.text === "" : open.has(node)) return;
|
|
866
|
+
countCoreWork("landingSources");
|
|
867
|
+
landing.push({
|
|
868
|
+
at: index.nodeRange(path).from,
|
|
869
|
+
document: index,
|
|
870
|
+
kind: NodeApi.isText(node) ? "text" : "element",
|
|
871
|
+
payload: payloadKeyOf(node)
|
|
872
|
+
});
|
|
873
|
+
nodes.set(node, index.node(path));
|
|
874
|
+
});
|
|
875
|
+
return {
|
|
876
|
+
landing,
|
|
877
|
+
nodes
|
|
878
|
+
};
|
|
879
|
+
};
|
|
880
|
+
const checkTextLanding = (editor, admission, point) => {
|
|
881
|
+
const { source, intent, relation } = admission;
|
|
882
|
+
if (source.kind !== "text" || intent !== "move" || relation !== "document" || source.root !== getEditorRuntimeRoot(editor)) return;
|
|
883
|
+
const [selectedStart, selectedEnd] = RangeApi.edges(source.range);
|
|
884
|
+
const [deletedStart, deletedEnd] = RangeApi.edges(source.deleted ?? source.range);
|
|
885
|
+
if ([
|
|
886
|
+
selectedStart,
|
|
887
|
+
selectedEnd,
|
|
888
|
+
deletedStart,
|
|
889
|
+
deletedEnd
|
|
890
|
+
].some((edge) => PointApi.equals(point, edge))) refuse("no-op");
|
|
891
|
+
const start = PointApi.isBefore(deletedStart, selectedStart) ? deletedStart : selectedStart;
|
|
892
|
+
const end = PointApi.isAfter(deletedEnd, selectedEnd) ? deletedEnd : selectedEnd;
|
|
893
|
+
if (PointApi.isAfter(point, start) && PointApi.isBefore(point, end)) refuse("inside-source");
|
|
894
|
+
};
|
|
895
|
+
const requestOf = (from, intent, payload, relation, source, slice) => ({
|
|
896
|
+
fit: source.kind !== "nodes" ? [] : slice ? slice.content : source.entries.map(([node]) => node),
|
|
897
|
+
from,
|
|
898
|
+
intent,
|
|
899
|
+
moving: source.kind === "nodes" && intent === "move" && relation === "document" ? {
|
|
900
|
+
entries: source.entries,
|
|
901
|
+
root: source.root
|
|
902
|
+
} : null,
|
|
903
|
+
payload,
|
|
904
|
+
relation
|
|
905
|
+
});
|
|
906
|
+
const resolveStep = (editor, request, source, direction) => {
|
|
907
|
+
if (source.kind !== "nodes" || source.root !== getEditorRuntimeRoot(editor)) return refuse("policy");
|
|
908
|
+
const parent = source.entries[0][1].slice(0, -1);
|
|
909
|
+
if (source.entries.some(([, path]) => !PathApi.equals(path.slice(0, -1), parent))) return refuse("policy");
|
|
910
|
+
const next = direction === "next";
|
|
911
|
+
const [, anchorPath] = next ? source.entries.at(-1) : source.entries[0];
|
|
912
|
+
const anchorKey = request.from.key(anchorPath);
|
|
913
|
+
const payload = new Set(source.entries.map(([node]) => node));
|
|
914
|
+
let path = anchorKey ? editor.read.nodes.path(anchorKey) : void 0;
|
|
915
|
+
let reason = "no-op";
|
|
916
|
+
while (path) {
|
|
917
|
+
path = next ? PathApi.next(path) : PathApi.hasPrevious(path) ? PathApi.previous(path) : void 0;
|
|
918
|
+
const entry = path && editor.read.nodes.get(path);
|
|
919
|
+
const key = path && editor.key(path);
|
|
920
|
+
if (!entry || !key) break;
|
|
921
|
+
if (payload.has(entry[0])) continue;
|
|
922
|
+
try {
|
|
923
|
+
const resolved = resolveLanding(editor, request, {
|
|
924
|
+
edge: next ? "after" : "before",
|
|
925
|
+
key
|
|
926
|
+
});
|
|
927
|
+
judgeLanding(editor, request, resolved, null);
|
|
928
|
+
const landed = editor.read.nodes.path(resolved.edge.key);
|
|
929
|
+
if (landed && PathApi.equals(landed.slice(0, -1), parent)) {
|
|
930
|
+
const adopted = adoptAt(editor, request, resolved);
|
|
931
|
+
return adopted ? judgeLanding(editor, request, resolved, adopted) : {
|
|
932
|
+
adopted,
|
|
933
|
+
edge: resolved.edge
|
|
934
|
+
};
|
|
935
|
+
}
|
|
936
|
+
reason = "policy";
|
|
937
|
+
} catch (error) {
|
|
938
|
+
if (!(error instanceof TransferRefusalError)) throw error;
|
|
939
|
+
({reason} = error);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
return refuse(reason);
|
|
943
|
+
};
|
|
944
|
+
const sameKey = (left, right) => left.every((part, i) => Object.is(part, right[i]));
|
|
945
|
+
const SOURCES = /* @__PURE__ */ new WeakMap();
|
|
946
|
+
const resolvePayload = (from, input) => {
|
|
947
|
+
const key = [
|
|
948
|
+
input.nodes?.join("\0") ?? (input.range ? JSON.stringify(input.range) : from.read.selection()),
|
|
949
|
+
from.read.runtime.snapshot(),
|
|
950
|
+
getConfiguredPluginRegistry(from).configurationRevision
|
|
951
|
+
];
|
|
952
|
+
const cached = SOURCES.get(from);
|
|
953
|
+
if (cached && sameKey(cached.key, key)) return cached;
|
|
954
|
+
const source = resolveSource(from, input);
|
|
955
|
+
const resolved = {
|
|
956
|
+
key,
|
|
957
|
+
payload: payloadOf(from, source),
|
|
958
|
+
slices: {},
|
|
959
|
+
source
|
|
960
|
+
};
|
|
961
|
+
SOURCES.set(from, resolved);
|
|
962
|
+
return resolved;
|
|
963
|
+
};
|
|
964
|
+
const admit = (editor, input, method) => {
|
|
965
|
+
const from = input.from ?? editor;
|
|
966
|
+
const { payload, slices, source } = resolvePayload(from, input);
|
|
967
|
+
const relation = relationOf(from, editor);
|
|
968
|
+
const intent = method === "copy" || relation !== "document" || from.read.view.isReadOnly() ? "copy" : "move";
|
|
969
|
+
if (editor.read.view.isReadOnly()) refuse("read-only-target");
|
|
970
|
+
if (source.kind === "text" && intent === "move") {
|
|
971
|
+
const { deleted } = source;
|
|
972
|
+
if (!deleted) refuse("lossy");
|
|
973
|
+
else if (RangeApi.isCollapsed(deleted)) refuse("no-op");
|
|
974
|
+
}
|
|
975
|
+
const slice = source.kind === "nodes" && intent === "move" && source.root === getEditorRuntimeRoot(editor) ? null : slices[intent] ??= getContentSlice(from, source.kind === "text" ? intent === "move" && source.deleted || source.range : SelectionApi.nodes(source.entries.map(([, path]) => path), { mode: "block" }), void 0, intent);
|
|
976
|
+
const request = requestOf(from, intent, payload, relation, source, slice);
|
|
977
|
+
const admitted = (landing) => ({
|
|
978
|
+
relocatedAdoption: null,
|
|
979
|
+
intent,
|
|
980
|
+
landing,
|
|
981
|
+
relation,
|
|
982
|
+
slice,
|
|
983
|
+
source
|
|
984
|
+
});
|
|
985
|
+
const admittedEdge = ({ adopted, edge }) => ({
|
|
986
|
+
...admitted({
|
|
987
|
+
edge,
|
|
988
|
+
kind: "edge"
|
|
989
|
+
}),
|
|
990
|
+
relocatedAdoption: slice ? null : adopted,
|
|
991
|
+
slice: adopted && slice ? ContentSlice.withContent(slice, adopted.fit, { open: "preserve" }) : slice
|
|
992
|
+
});
|
|
993
|
+
if (typeof input.to === "string") return admittedEdge(resolveStep(editor, request, source, input.to));
|
|
994
|
+
if ("point" in input.to) {
|
|
995
|
+
if (source.kind === "nodes") refuse("schema");
|
|
996
|
+
const admission = admitted({
|
|
997
|
+
kind: "point",
|
|
998
|
+
point: input.to.point
|
|
999
|
+
});
|
|
1000
|
+
checkTextLanding(editor, admission, input.to.point);
|
|
1001
|
+
return admission;
|
|
1002
|
+
}
|
|
1003
|
+
if ("side" in input.to) {
|
|
1004
|
+
if (source.kind !== "nodes" || slice || !request.moving) return refuse("policy");
|
|
1005
|
+
return admitted({
|
|
1006
|
+
keys: source.entries.map(([, path]) => from.key(path)),
|
|
1007
|
+
kind: "wrap",
|
|
1008
|
+
side: input.to,
|
|
1009
|
+
wrap: landBeside(editor, request, request.moving, input.to)
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
return admittedEdge(landAt(editor, request, input.to));
|
|
1013
|
+
};
|
|
1014
|
+
const runTransfer = (editor, input, method) => {
|
|
1015
|
+
const from = input.from ?? editor;
|
|
1016
|
+
const diagnostics = [];
|
|
1017
|
+
let admission;
|
|
1018
|
+
try {
|
|
1019
|
+
admission = admit(editor, input, method);
|
|
1020
|
+
} catch (error) {
|
|
1021
|
+
if (error instanceof TransferRefusalError) return {
|
|
1022
|
+
reason: error.reason,
|
|
1023
|
+
status: "refused"
|
|
1024
|
+
};
|
|
1025
|
+
throw error;
|
|
1026
|
+
}
|
|
1027
|
+
const { intent, landing, relation, relocatedAdoption, slice, source } = admission;
|
|
1028
|
+
const copy = intent === "copy";
|
|
1029
|
+
const targetRoot = getEditorRuntimeRoot(editor);
|
|
1030
|
+
const before = from.read.value();
|
|
1031
|
+
const relocate = !slice;
|
|
1032
|
+
const carried = landing.kind === "wrap" && landing.wrap.replaced ? [landing.wrap.replaced] : [];
|
|
1033
|
+
const content = slice ? slice.content : source.kind === "nodes" ? [...relocatedAdoption?.payload.nodes ?? source.entries.map(([node]) => node), ...carried.map(({ node }) => node)] : [];
|
|
1034
|
+
const schema = getEditorSchema(editor);
|
|
1035
|
+
const normalize = copy ? copyNormalizer(getCompiledEditorSchema(editor), schema.copyChildren, targetRoot) : null;
|
|
1036
|
+
const draft = { current: null };
|
|
1037
|
+
const runtime = getEditorRuntimeOwner(editor);
|
|
1038
|
+
const trackNodes = (paths) => {
|
|
1039
|
+
const snapshot = getDefined(getTransactionSnapshot(runtime));
|
|
1040
|
+
const index = snapshot.builder.getIndex(targetRoot);
|
|
1041
|
+
return {
|
|
1042
|
+
expected: {
|
|
1043
|
+
content,
|
|
1044
|
+
kind: "nodes",
|
|
1045
|
+
roots: slice ? slice.roots : before.roots
|
|
1046
|
+
},
|
|
1047
|
+
track: trackDraftSpans(snapshot, snapshot.builder, targetRoot, paths.map((path) => index.nodeRange(path)))
|
|
1048
|
+
};
|
|
1049
|
+
};
|
|
1050
|
+
const followsDrop = (element, ancestors) => (key) => schema.elementPropertyLanding(element, key, ancestors, targetRoot) !== "preserve";
|
|
1051
|
+
const release = guardLanding(editor, copy, draft, (drafted, after, frame) => {
|
|
1052
|
+
const builder = getTransactionSnapshot(runtime)?.builder;
|
|
1053
|
+
const spans = builder?.value === after ? readDraftTrack(drafted.track, after, frame) : null;
|
|
1054
|
+
if (!builder || !spans) return false;
|
|
1055
|
+
const expected = frame ? rebaseLanding(drafted, frame, targetRoot) : drafted.expected;
|
|
1056
|
+
return !!expected && landingHolds(expected, {
|
|
1057
|
+
children: rootChildren(after, targetRoot),
|
|
1058
|
+
dropped: droppedKeysOf(builder.draftSteps),
|
|
1059
|
+
index: builder.getIndex(targetRoot),
|
|
1060
|
+
roots: after.roots,
|
|
1061
|
+
spans
|
|
1062
|
+
}, normalize);
|
|
1063
|
+
}, diagnostics);
|
|
1064
|
+
let landed = null;
|
|
1065
|
+
const select = typeof input.to !== "string";
|
|
1066
|
+
let held = null;
|
|
1067
|
+
const hold = (range) => {
|
|
1068
|
+
const [start, end] = RangeApi.edges(range);
|
|
1069
|
+
held = {
|
|
1070
|
+
end: editor.anchor(end, {
|
|
1071
|
+
association: "backward",
|
|
1072
|
+
deletion: "nearest"
|
|
1073
|
+
}),
|
|
1074
|
+
kind: "range",
|
|
1075
|
+
start: editor.anchor(start, {
|
|
1076
|
+
association: "forward",
|
|
1077
|
+
deletion: "nearest"
|
|
1078
|
+
})
|
|
1079
|
+
};
|
|
1080
|
+
};
|
|
1081
|
+
const holdNodes = (nodes) => {
|
|
1082
|
+
held = {
|
|
1083
|
+
first: editor.anchor(nodes.anchorPath, { deletion: "nearest" }),
|
|
1084
|
+
kind: "nodes",
|
|
1085
|
+
last: editor.anchor(nodes.focusPath, { deletion: "nearest" })
|
|
1086
|
+
};
|
|
1087
|
+
};
|
|
1088
|
+
const asMove = (role, run) => copy ? run() : withDraftMove(getEditorRuntimeOwner(editor), { role }, run);
|
|
1089
|
+
let accepted;
|
|
1090
|
+
try {
|
|
1091
|
+
accepted = editor.update((tx) => {
|
|
1092
|
+
if (input.announce) tx.effects.emit(screenReaderAnnouncementEffect, input.announce);
|
|
1093
|
+
const pathOf = (key) => tx.nodes.get(key)?.[1] ?? refuse("source-missing");
|
|
1094
|
+
const besidePath = (anchor, edge, leaving) => {
|
|
1095
|
+
const index = anchor.at(-1);
|
|
1096
|
+
const shifted = PathApi.equals(leaving.slice(0, -1), anchor.slice(0, -1)) && leaving.at(-1) < index ? index - 1 : index;
|
|
1097
|
+
return [...anchor.slice(0, -1), edge === "before" ? shifted : shifted + 1];
|
|
1098
|
+
};
|
|
1099
|
+
const moveChain = (keys, first) => {
|
|
1100
|
+
keys.forEach((key, index) => {
|
|
1101
|
+
const at = pathOf(key);
|
|
1102
|
+
tx.nodes.move({
|
|
1103
|
+
at,
|
|
1104
|
+
to: index === 0 ? first() : besidePath(pathOf(keys[index - 1]), "after", at)
|
|
1105
|
+
});
|
|
1106
|
+
});
|
|
1107
|
+
};
|
|
1108
|
+
const selectLanded = (keys) => {
|
|
1109
|
+
const paths = keys.map(pathOf);
|
|
1110
|
+
const nodes = SelectionApi.nodes(paths, { mode: "block" });
|
|
1111
|
+
landed = nodes;
|
|
1112
|
+
draft.current = trackNodes([...paths, ...carried.map(({ key }) => pathOf(key))]);
|
|
1113
|
+
holdNodes(nodes);
|
|
1114
|
+
if (select) tx.selection.set(nodes);
|
|
1115
|
+
};
|
|
1116
|
+
if (landing.kind === "wrap") {
|
|
1117
|
+
const { anchor, payload, replaced, shell } = landing.wrap;
|
|
1118
|
+
const shellPath = insertionPath(pathOf(anchor.key), anchor.edge);
|
|
1119
|
+
tx.nodes.insert(shell, { at: shellPath });
|
|
1120
|
+
const shellKey = tx.key(shellPath) ?? refuse("schema");
|
|
1121
|
+
const slot = (path, index) => [
|
|
1122
|
+
...pathOf(shellKey),
|
|
1123
|
+
...path,
|
|
1124
|
+
index
|
|
1125
|
+
];
|
|
1126
|
+
if (replaced) tx.nodes.move({
|
|
1127
|
+
at: pathOf(replaced.key),
|
|
1128
|
+
to: slot(replaced.slot, 0)
|
|
1129
|
+
});
|
|
1130
|
+
moveChain(landing.keys, () => slot(payload, 0));
|
|
1131
|
+
selectLanded(landing.keys);
|
|
1132
|
+
return true;
|
|
1133
|
+
}
|
|
1134
|
+
if (relocate && source.kind === "nodes" && landing.kind === "edge") {
|
|
1135
|
+
const keys = source.entries.map(([, path]) => from.key(path));
|
|
1136
|
+
const { edge } = landing;
|
|
1137
|
+
moveChain(keys, () => besidePath(pathOf(edge.key), edge.edge, pathOf(keys[0])));
|
|
1138
|
+
for (const { at, properties } of relocatedAdoption?.patches ?? []) {
|
|
1139
|
+
const [index, ...rest] = at;
|
|
1140
|
+
tx.nodes.set(properties, {
|
|
1141
|
+
at: [...pathOf(keys[index]), ...rest],
|
|
1142
|
+
voids: true
|
|
1143
|
+
});
|
|
1144
|
+
}
|
|
1145
|
+
selectLanded(keys);
|
|
1146
|
+
return true;
|
|
1147
|
+
}
|
|
1148
|
+
const removeSource = () => {
|
|
1149
|
+
if (copy) return;
|
|
1150
|
+
asMove("source", removeSourceSteps);
|
|
1151
|
+
};
|
|
1152
|
+
const removeSourceSteps = () => {
|
|
1153
|
+
if (source.root === targetRoot) {
|
|
1154
|
+
if (source.kind === "text") tx.text.delete({ at: source.range });
|
|
1155
|
+
else for (const [, path] of [...source.entries].reverse()) tx.nodes.remove({ at: path });
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
const owner = getEditorRuntimeOwner(editor);
|
|
1159
|
+
withEditorUpdateRootScope(owner, source.root, () => {
|
|
1160
|
+
if (source.kind === "text") deleteText(owner, { at: source.range });
|
|
1161
|
+
else for (const [, path] of [...source.entries].reverse()) removeNodes(owner, { at: path });
|
|
1162
|
+
});
|
|
1163
|
+
};
|
|
1164
|
+
const collectMoved = () => copy || source.kind !== "text" || source.root !== targetRoot ? null : collectMovedAnchors(runtime, targetRoot, source.deleted ?? source.range);
|
|
1165
|
+
const landedKind = (element) => {
|
|
1166
|
+
const behavior = schema.getElementBehavior(element);
|
|
1167
|
+
return behavior.void ? "void" : behavior.inline ? "inline" : "block";
|
|
1168
|
+
};
|
|
1169
|
+
const landAsPaste = (at, copied, sources = null) => {
|
|
1170
|
+
const plan = planPaste(editor, getEditorStateView(editor), {
|
|
1171
|
+
options: { at },
|
|
1172
|
+
slice: copied
|
|
1173
|
+
}, intent, { drop: true });
|
|
1174
|
+
if (!plan) return null;
|
|
1175
|
+
if (!copy && (plan.inputCut || plan.landingCut)) refuse("lossy");
|
|
1176
|
+
const written = withFitLanding(copy ? { kind: "paste" } : {
|
|
1177
|
+
kind: "move",
|
|
1178
|
+
sources: sources?.landing ?? []
|
|
1179
|
+
}, () => writePaste(editor, plan, { landing: true }));
|
|
1180
|
+
if (!written) return null;
|
|
1181
|
+
if (written.lossy) diagnostics.push({
|
|
1182
|
+
impact: "lossy",
|
|
1183
|
+
message: "Some dragged content does not fit here."
|
|
1184
|
+
});
|
|
1185
|
+
applyTransactionSpec(getEditorRuntimeOwner(editor), written.spec);
|
|
1186
|
+
return {
|
|
1187
|
+
expected: copy ? {
|
|
1188
|
+
closed: closedEdges(written.written),
|
|
1189
|
+
content: written.written.content,
|
|
1190
|
+
kind: "range-copy",
|
|
1191
|
+
landedKind,
|
|
1192
|
+
roots: written.written.roots
|
|
1193
|
+
} : {
|
|
1194
|
+
kind: "range-move",
|
|
1195
|
+
moved: carryMove({
|
|
1196
|
+
followsDrop,
|
|
1197
|
+
kind: landedKind,
|
|
1198
|
+
moved: copied,
|
|
1199
|
+
replaced: written.written === plan.emptyBlockReplacement ? plan.site.target.block?.[0] ?? null : null,
|
|
1200
|
+
sources: sources?.nodes,
|
|
1201
|
+
written: written.written
|
|
1202
|
+
}) ?? refuse("lossy")
|
|
1203
|
+
},
|
|
1204
|
+
spec: written.spec
|
|
1205
|
+
};
|
|
1206
|
+
};
|
|
1207
|
+
if (landing.kind === "point") {
|
|
1208
|
+
const drop = tx.anchor(landing.point, {
|
|
1209
|
+
association: "backward",
|
|
1210
|
+
deletion: "nearest"
|
|
1211
|
+
});
|
|
1212
|
+
const { builder: moving } = getDefined(getTransactionSnapshot(runtime));
|
|
1213
|
+
const sources = moving.tracksPlaces && !copy && slice && source.kind === "text" && source.root === targetRoot ? payloadSourcesOf(moving.getIndex(targetRoot), source.deleted ?? source.range, slice, (element) => schema.getElementBehavior(element).inline) : null;
|
|
1214
|
+
const moved = collectMoved();
|
|
1215
|
+
removeSource();
|
|
1216
|
+
finalizeTransactionRepresentation(getEditorRuntimeOwner(editor));
|
|
1217
|
+
const point = drop.resolve();
|
|
1218
|
+
const pasted = point && slice && asMove("landing", () => landAsPaste(point, slice, sources)) || refuse("schema");
|
|
1219
|
+
const track = getAppliedSpecLanding(pasted.spec) ?? refuse("schema");
|
|
1220
|
+
if (moved) placeMovedAnchors(runtime, moved, track);
|
|
1221
|
+
const { builder } = getDefined(getTransactionSnapshot(runtime));
|
|
1222
|
+
const [span] = readDraftTrack(track, builder.value) ?? [];
|
|
1223
|
+
const index = builder.getIndex(targetRoot);
|
|
1224
|
+
const range = (span && trackedRange(index, span)) ?? refuse("schema");
|
|
1225
|
+
const nodeAtPath = (path) => index.find(path);
|
|
1226
|
+
const beside = (edge, step) => {
|
|
1227
|
+
const at = edge.path.slice(0, -1);
|
|
1228
|
+
const node = nodeAtPath(at);
|
|
1229
|
+
const behavior = node && ElementApi.isElement(node) && schema.getElementBehavior(node);
|
|
1230
|
+
const path = [...at.slice(0, -1), at.at(-1) + step];
|
|
1231
|
+
const text = behavior && behavior.void && behavior.inline && nodeAtPath(path);
|
|
1232
|
+
return text && NodeApi.isText(text) ? {
|
|
1233
|
+
offset: step < 0 ? text.text.length : 0,
|
|
1234
|
+
path
|
|
1235
|
+
} : edge;
|
|
1236
|
+
};
|
|
1237
|
+
landed = selectionRange(beside(range.anchor, -1), beside(range.focus, 1));
|
|
1238
|
+
draft.current = {
|
|
1239
|
+
expected: pasted.expected,
|
|
1240
|
+
track
|
|
1241
|
+
};
|
|
1242
|
+
hold(landed);
|
|
1243
|
+
if (select) tx.selection.set(landed);
|
|
1244
|
+
return true;
|
|
1245
|
+
}
|
|
1246
|
+
const moved = collectMoved();
|
|
1247
|
+
removeSource();
|
|
1248
|
+
const target = tx.nodes.get(landing.edge.key);
|
|
1249
|
+
if (!target || !slice) refuse("policy");
|
|
1250
|
+
const [, targetPath] = target;
|
|
1251
|
+
const boundary = insertionPath(targetPath, landing.edge.edge);
|
|
1252
|
+
if (!asMove("landing", () => replaceSliceAtBlockBoundary(getEditorRuntimeOwner(editor), slice, boundary, { drop: true }))) refuse("schema");
|
|
1253
|
+
const first = boundary.at(-1);
|
|
1254
|
+
const paths = content.map((_, i) => [...boundary.slice(0, -1), first + i]);
|
|
1255
|
+
const nodes = SelectionApi.nodes(paths, { mode: "block" });
|
|
1256
|
+
landed = nodes;
|
|
1257
|
+
draft.current = trackNodes(paths);
|
|
1258
|
+
if (moved) placeMovedAnchors(runtime, moved, draft.current.track);
|
|
1259
|
+
holdNodes(nodes);
|
|
1260
|
+
if (select) tx.selection.set(nodes);
|
|
1261
|
+
return true;
|
|
1262
|
+
});
|
|
1263
|
+
} catch (error) {
|
|
1264
|
+
releaseHeld(held);
|
|
1265
|
+
if (error instanceof TransferRefusalError) return {
|
|
1266
|
+
reason: error.reason,
|
|
1267
|
+
status: "refused"
|
|
1268
|
+
};
|
|
1269
|
+
if (error instanceof EditorSchemaValidationError) return {
|
|
1270
|
+
reason: "schema",
|
|
1271
|
+
status: "refused"
|
|
1272
|
+
};
|
|
1273
|
+
throw error;
|
|
1274
|
+
} finally {
|
|
1275
|
+
release();
|
|
1276
|
+
}
|
|
1277
|
+
if (!accepted) {
|
|
1278
|
+
releaseHeld(held);
|
|
1279
|
+
return {
|
|
1280
|
+
reason: "policy",
|
|
1281
|
+
status: "refused"
|
|
1282
|
+
};
|
|
1283
|
+
}
|
|
1284
|
+
const at = readHeld(held, landed);
|
|
1285
|
+
if (!at) return {
|
|
1286
|
+
reason: "schema",
|
|
1287
|
+
status: "refused"
|
|
1288
|
+
};
|
|
1289
|
+
if (!copy) return {
|
|
1290
|
+
at,
|
|
1291
|
+
status: "moved"
|
|
1292
|
+
};
|
|
1293
|
+
return {
|
|
1294
|
+
at,
|
|
1295
|
+
diagnostics,
|
|
1296
|
+
reason: method === "copy" ? "intent" : relation === "independent" ? "independent" : relation === "identity" ? "identity" : "read-only-source",
|
|
1297
|
+
status: "copied"
|
|
1298
|
+
};
|
|
1299
|
+
};
|
|
1300
|
+
const releaseHeld = (held) => {
|
|
1301
|
+
if (held?.kind === "range") {
|
|
1302
|
+
held.start.release();
|
|
1303
|
+
held.end.release();
|
|
1304
|
+
} else if (held) {
|
|
1305
|
+
held.first.release();
|
|
1306
|
+
held.last.release();
|
|
1307
|
+
}
|
|
1308
|
+
};
|
|
1309
|
+
const readHeld = (held, landed) => {
|
|
1310
|
+
if (!held || !landed) return landed;
|
|
1311
|
+
const edges = held.kind === "range" ? [held.start.resolve(), held.end.resolve()] : [held.first.resolve(), held.last.resolve()];
|
|
1312
|
+
releaseHeld(held);
|
|
1313
|
+
const [start, end] = edges;
|
|
1314
|
+
if (!start || !end) return landed;
|
|
1315
|
+
if (held.kind === "range") return selectionRange(start, end);
|
|
1316
|
+
const first = start;
|
|
1317
|
+
const parent = first.slice(0, -1);
|
|
1318
|
+
const from = first.at(-1);
|
|
1319
|
+
const to = end.at(-1);
|
|
1320
|
+
const rest = Array.from({ length: Math.max(0, to - from) }, (_, offset) => [...parent, from + offset + 1]);
|
|
1321
|
+
return SelectionApi.nodes([first, ...rest], { mode: "block" });
|
|
1322
|
+
};
|
|
1323
|
+
const CHECKS = /* @__PURE__ */ new WeakMap();
|
|
1324
|
+
const checkKey = (editor, input, method) => {
|
|
1325
|
+
const from = input.from ?? editor;
|
|
1326
|
+
return [
|
|
1327
|
+
from,
|
|
1328
|
+
method,
|
|
1329
|
+
input.nodes?.join("\0") ?? JSON.stringify(input.range ?? null),
|
|
1330
|
+
editor.read.runtime.snapshot(),
|
|
1331
|
+
from.read.runtime.snapshot(),
|
|
1332
|
+
editor.read.view.isReadOnly(),
|
|
1333
|
+
from.read.view.isReadOnly(),
|
|
1334
|
+
authoredIdentity(editor),
|
|
1335
|
+
authoredIdentity(from),
|
|
1336
|
+
getConfiguredPluginRegistry(editor).configurationRevision
|
|
1337
|
+
];
|
|
1338
|
+
};
|
|
1339
|
+
const checkTransfer = (editor, input, method) => {
|
|
1340
|
+
const key = checkKey(editor, input, method);
|
|
1341
|
+
const kept = CHECKS.get(editor);
|
|
1342
|
+
const cached = kept && sameKey(kept.key, key) ? kept : {
|
|
1343
|
+
checks: /* @__PURE__ */ new Map(),
|
|
1344
|
+
key
|
|
1345
|
+
};
|
|
1346
|
+
const to = JSON.stringify(input.to);
|
|
1347
|
+
const known = cached.checks.get(to);
|
|
1348
|
+
if (known) return known;
|
|
1349
|
+
let check;
|
|
1350
|
+
try {
|
|
1351
|
+
check = {
|
|
1352
|
+
admitted: true,
|
|
1353
|
+
to: targetOf(admit(editor, input, method).landing)
|
|
1354
|
+
};
|
|
1355
|
+
} catch (error) {
|
|
1356
|
+
if (!(error instanceof TransferRefusalError)) throw error;
|
|
1357
|
+
check = {
|
|
1358
|
+
admitted: false,
|
|
1359
|
+
reason: error.reason
|
|
1360
|
+
};
|
|
1361
|
+
}
|
|
1362
|
+
cached.checks.set(to, check);
|
|
1363
|
+
CHECKS.set(editor, cached);
|
|
1364
|
+
return check;
|
|
1365
|
+
};
|
|
1366
|
+
const checkFilesLanding = (editor, types, fit, to) => {
|
|
1367
|
+
try {
|
|
1368
|
+
if (editor.read.view.isReadOnly()) refuse("read-only-target");
|
|
1369
|
+
return {
|
|
1370
|
+
admitted: true,
|
|
1371
|
+
to: landAt(editor, {
|
|
1372
|
+
fit,
|
|
1373
|
+
from: editor,
|
|
1374
|
+
intent: "copy",
|
|
1375
|
+
moving: null,
|
|
1376
|
+
payload: {
|
|
1377
|
+
kind: "files",
|
|
1378
|
+
types
|
|
1379
|
+
},
|
|
1380
|
+
relation: "independent"
|
|
1381
|
+
}, to).edge
|
|
1382
|
+
};
|
|
1383
|
+
} catch (error) {
|
|
1384
|
+
if (!(error instanceof TransferRefusalError)) throw error;
|
|
1385
|
+
return {
|
|
1386
|
+
admitted: false,
|
|
1387
|
+
reason: error.reason
|
|
1388
|
+
};
|
|
1389
|
+
}
|
|
1390
|
+
};
|
|
1391
|
+
const selectionReader = (from) => {
|
|
1392
|
+
const selection = from.read.selection();
|
|
1393
|
+
const root = selection && SelectionApi.root(selection);
|
|
1394
|
+
return !root || root === getEditorRuntimeRoot(from) ? from : createEditorViewRuntime(from, { root });
|
|
1395
|
+
};
|
|
1396
|
+
const fromSelectionRoot = (editor, input) => input.nodes || input.range ? input : {
|
|
1397
|
+
...input,
|
|
1398
|
+
from: selectionReader(input.from ?? editor)
|
|
1399
|
+
};
|
|
1400
|
+
const TRANSFER_PLUGIN = definePlugin("transfer", {
|
|
1401
|
+
read: ({ editor }) => ({
|
|
1402
|
+
check: (input) => checkTransfer(editor, fromSelectionRoot(editor, input), "move"),
|
|
1403
|
+
nodes: (options) => {
|
|
1404
|
+
const reader = options?.node === void 0 ? selectionReader(editor) : editor;
|
|
1405
|
+
return transferEntries(reader, options?.node).flatMap(([node]) => reader.key(node) ?? []);
|
|
1406
|
+
}
|
|
1407
|
+
}),
|
|
1408
|
+
api: ({ editor }) => ({
|
|
1409
|
+
copy: (input) => runTransfer(editor, fromSelectionRoot(editor, input), "copy"),
|
|
1410
|
+
move: (input) => runTransfer(editor, fromSelectionRoot(editor, input), "move")
|
|
1411
|
+
})
|
|
1412
|
+
});
|
|
1413
|
+
/** The drag-and-drop and keyboard move action; React editors install it. */
|
|
1414
|
+
const transfer = () => TRANSFER_PLUGIN;
|
|
1415
|
+
//#endregion
|
|
1416
|
+
//#region src/core/state-field.ts
|
|
1417
|
+
/**
|
|
1418
|
+
* Creates an editor-scoped state field from a keyed descriptor.
|
|
1419
|
+
*
|
|
1420
|
+
* State fields register when their plugin is installed and are read through
|
|
1421
|
+
* the editor state API.
|
|
1422
|
+
*/
|
|
1423
|
+
const defineStateField = (descriptor) => {
|
|
1424
|
+
if (!descriptor.key) throw new Error("State field key cannot be empty.");
|
|
1425
|
+
if (descriptor.key === "__proto__") throw new Error("State field key cannot be \"__proto__\".");
|
|
1426
|
+
const normalizedDescriptor = Object.freeze({
|
|
1427
|
+
...descriptor,
|
|
1428
|
+
compare: descriptor.compare ?? Object.is,
|
|
1429
|
+
...descriptor.persist ? { persist: normalizeEditorValuePersistence(descriptor.persist) } : {},
|
|
1430
|
+
...descriptor.initial !== void 0 && typeof descriptor.initial !== "function" ? { initial: cloneFrozen(descriptor.initial) } : {}
|
|
1431
|
+
});
|
|
1432
|
+
if (normalizedDescriptor.collab === "shared" && !normalizedDescriptor.persist) throw new Error(`Shared state field "${normalizedDescriptor.key}" requires persistence.`);
|
|
1433
|
+
if (normalizedDescriptor.collab === "shared" && normalizedDescriptor.reduce) throw new Error(`Shared state field "${normalizedDescriptor.key}" cannot define reduce. Set it with tx.setField so every peer receives the value.`);
|
|
1434
|
+
const transitionCodec = normalizedDescriptor.persist ? normalizeEditorValuePersistence({
|
|
1435
|
+
decode(value) {
|
|
1436
|
+
if (typeof value !== "object" || value === null || !Object.hasOwn(value, "previousValue") || !Object.hasOwn(value, "value")) throw new Error(`Invalid state field "${descriptor.key}" transition.`);
|
|
1437
|
+
return Object.freeze({
|
|
1438
|
+
previousValue: getDefined(normalizedDescriptor.persist).decode(value.previousValue),
|
|
1439
|
+
value: getDefined(normalizedDescriptor.persist).decode(value.value)
|
|
1440
|
+
});
|
|
1441
|
+
},
|
|
1442
|
+
encode: ({ previousValue, value }) => ({
|
|
1443
|
+
previousValue: getDefined(normalizedDescriptor.persist).encode(previousValue),
|
|
1444
|
+
value: getDefined(normalizedDescriptor.persist).encode(value)
|
|
1445
|
+
}),
|
|
1446
|
+
...normalizedDescriptor.persist.legacyDecoders ? { legacyDecoders: Object.fromEntries(Object.entries(normalizedDescriptor.persist.legacyDecoders).map(([version, decode]) => [version, (value) => {
|
|
1447
|
+
if (typeof value !== "object" || value === null || !Object.hasOwn(value, "previousValue") || !Object.hasOwn(value, "value")) throw new Error(`Invalid state field "${descriptor.key}" transition.`);
|
|
1448
|
+
return Object.freeze({
|
|
1449
|
+
previousValue: decode(value.previousValue),
|
|
1450
|
+
value: decode(value.value)
|
|
1451
|
+
});
|
|
1452
|
+
}])) } : {},
|
|
1453
|
+
version: normalizedDescriptor.persist.version
|
|
1454
|
+
}) : void 0;
|
|
1455
|
+
const effectOptions = {
|
|
1456
|
+
history: normalizedDescriptor.history,
|
|
1457
|
+
key: `state:${normalizedDescriptor.key}`
|
|
1458
|
+
};
|
|
1459
|
+
let field;
|
|
1460
|
+
const effect = normalizedDescriptor.collab === "shared" ? defineEffect({
|
|
1461
|
+
...effectOptions,
|
|
1462
|
+
persist: getDefined(transitionCodec),
|
|
1463
|
+
collab: "shared",
|
|
1464
|
+
collabReplay: "latest",
|
|
1465
|
+
collabSnapshot: (state) => {
|
|
1466
|
+
const value = state.getField(field);
|
|
1467
|
+
return {
|
|
1468
|
+
previousValue: value,
|
|
1469
|
+
value
|
|
1470
|
+
};
|
|
1471
|
+
},
|
|
1472
|
+
invert: ({ previousValue, value }) => ({
|
|
1473
|
+
previousValue: value,
|
|
1474
|
+
value: previousValue
|
|
1475
|
+
})
|
|
1476
|
+
}) : defineEffect({
|
|
1477
|
+
...effectOptions,
|
|
1478
|
+
...transitionCodec ? { persist: transitionCodec } : {},
|
|
1479
|
+
collab: "local",
|
|
1480
|
+
invert: ({ previousValue, value }) => ({
|
|
1481
|
+
previousValue: value,
|
|
1482
|
+
value: previousValue
|
|
1483
|
+
})
|
|
1484
|
+
});
|
|
1485
|
+
const definition = {
|
|
1486
|
+
...normalizedDescriptor,
|
|
1487
|
+
deserialize(value) {
|
|
1488
|
+
if (!normalizedDescriptor.persist) throw new Error(`State field "${normalizedDescriptor.key}" does not define persistence.`);
|
|
1489
|
+
return decodeVersionedValue(normalizedDescriptor.persist, value, `state field "${normalizedDescriptor.key}"`);
|
|
1490
|
+
},
|
|
1491
|
+
effectTypes: Object.freeze([effect]),
|
|
1492
|
+
effect,
|
|
1493
|
+
stateFields: [],
|
|
1494
|
+
name: `state-field:${normalizedDescriptor.key}`,
|
|
1495
|
+
reduce(value, nextEffect) {
|
|
1496
|
+
if (nextEffect.type === effect) return nextEffect.value.value;
|
|
1497
|
+
return normalizedDescriptor.reduce?.(value, nextEffect) ?? value;
|
|
1498
|
+
},
|
|
1499
|
+
serialize(value) {
|
|
1500
|
+
if (!normalizedDescriptor.persist) throw new Error(`State field "${normalizedDescriptor.key}" does not define persistence.`);
|
|
1501
|
+
return encodeVersionedValue(normalizedDescriptor.persist, value, `state field "${normalizedDescriptor.key}"`);
|
|
1502
|
+
}
|
|
1503
|
+
};
|
|
1504
|
+
field = definition;
|
|
1505
|
+
definition.stateFields = Object.freeze([field]);
|
|
1506
|
+
field = compilePlugin(definition);
|
|
1507
|
+
markDefinedStateField(field);
|
|
1508
|
+
return field;
|
|
1509
|
+
};
|
|
1510
|
+
//#endregion
|
|
1511
|
+
export { transferEntries as a, transfer as i, checkFilesLanding as n, suspendMovePlacement as o, checkTransfer as r, transferVeto as s, defineStateField as t };
|