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
|
@@ -1,1287 +0,0 @@
|
|
|
1
|
-
import { countCoreWork, readCoreWork } from "../core/work.js";
|
|
2
|
-
import { jsonEqual } from "../core/change/json.js";
|
|
3
|
-
import { invertEffect, mapEffect } from "../core/transaction-values.js";
|
|
4
|
-
import { isElementNode, nodeProps } from "../core/change/tokens.js";
|
|
5
|
-
import { DocumentChange, getInternalDocumentChangeClassificationEntries, getInternalDocumentChangeRootKeys, transformInternalDocumentChange, valueRoot, valueRootIndex } from "../core/change/document-change.js";
|
|
6
|
-
import { landCarriedRuns } from "../core/change/carried-run.js";
|
|
7
|
-
import { classifyDocumentChange } from "../core/change/builder.js";
|
|
8
|
-
import { getEditorRuntimeOwner, getEditorSchema } from "../core/editor-runtime.js";
|
|
9
|
-
import { MAIN_ROOT_KEY } from "../internal/root-location.js";
|
|
10
|
-
import { ElementApi } from "../interfaces/element.js";
|
|
11
|
-
import { SelectionApi } from "../interfaces/selection.js";
|
|
12
|
-
import { areEditorSchemaIdentitiesEqual, propertyTargetsReadParents } from "../core/schema-compiler.js";
|
|
13
|
-
import { getCompiledEditorSchema } from "../core/plugin-registry.js";
|
|
14
|
-
import { reportEditorLifecycleError } from "../core/lifecycle-error.js";
|
|
15
|
-
import { mapAnchorHistoryRecovery } from "../core/anchor-state.js";
|
|
16
|
-
import { getEditorDocumentValue } from "../core/public-state.js";
|
|
17
|
-
import { historyReplaySchemaOf, keepsUndoThrough, mapHistoryReplay, mapHistorySelection, projectedHistoryReplay, recordHistoryReplay } from "./history-replay.js";
|
|
18
|
-
import { crossRecord } from "../core/change/cross.js";
|
|
19
|
-
import { skippedRejection, stepRejection } from "../core/change/cross-rule.js";
|
|
20
|
-
import { mapHistoryCarets } from "./history-carets.js";
|
|
21
|
-
//#region src/history/history-state.ts
|
|
22
|
-
const failInvariant = (message) => {
|
|
23
|
-
throw new Error(message);
|
|
24
|
-
};
|
|
25
|
-
const HISTORY = /* @__PURE__ */ new WeakMap();
|
|
26
|
-
const HISTORY_DRAFTS = /* @__PURE__ */ new WeakMap();
|
|
27
|
-
const PUBLISHED_HISTORY_READ_DEPTH = /* @__PURE__ */ new WeakMap();
|
|
28
|
-
const KEPT_REDO_ATTEMPTS = /* @__PURE__ */ new Map();
|
|
29
|
-
const NO_DROPS = Object.freeze([]);
|
|
30
|
-
const withDrops = (store, drops) => drops.length === 0 ? store : Object.freeze({
|
|
31
|
-
...store,
|
|
32
|
-
crossingDrops: store.crossingDrops + drops.length,
|
|
33
|
-
unreportedDrops: [...store.unreportedDrops, ...drops]
|
|
34
|
-
});
|
|
35
|
-
const holdStore = (owner, store) => {
|
|
36
|
-
const { unreportedDrops } = store;
|
|
37
|
-
HISTORY.set(owner, unreportedDrops.length === 0 ? store : Object.freeze({
|
|
38
|
-
...store,
|
|
39
|
-
unreportedDrops: NO_DROPS
|
|
40
|
-
}));
|
|
41
|
-
for (const { cause, direction, editor } of unreportedDrops) reportEditorLifecycleError({
|
|
42
|
-
cause,
|
|
43
|
-
direction,
|
|
44
|
-
editor,
|
|
45
|
-
phase: "replay",
|
|
46
|
-
source: "history"
|
|
47
|
-
});
|
|
48
|
-
};
|
|
49
|
-
const getHistoryDraft = (editor) => {
|
|
50
|
-
const owner = getEditorRuntimeOwner(editor);
|
|
51
|
-
if ((PUBLISHED_HISTORY_READ_DEPTH.get(owner) ?? 0) > 0) return void 0;
|
|
52
|
-
return HISTORY_DRAFTS.get(owner)?.at(-1);
|
|
53
|
-
};
|
|
54
|
-
const withHistoryStateDraft = (editor, state, fn) => {
|
|
55
|
-
const owner = getEditorRuntimeOwner(editor);
|
|
56
|
-
const drafts = HISTORY_DRAFTS.get(owner) ?? [];
|
|
57
|
-
const draft = { state };
|
|
58
|
-
drafts.push(draft);
|
|
59
|
-
HISTORY_DRAFTS.set(owner, drafts);
|
|
60
|
-
try {
|
|
61
|
-
return {
|
|
62
|
-
result: fn(),
|
|
63
|
-
state: draft.state
|
|
64
|
-
};
|
|
65
|
-
} finally {
|
|
66
|
-
drafts.pop();
|
|
67
|
-
if (drafts.length === 0) HISTORY_DRAFTS.delete(owner);
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
const withPublishedHistoryState = (editor, fn) => {
|
|
71
|
-
const owner = getEditorRuntimeOwner(editor);
|
|
72
|
-
const depth = PUBLISHED_HISTORY_READ_DEPTH.get(owner) ?? 0;
|
|
73
|
-
PUBLISHED_HISTORY_READ_DEPTH.set(owner, depth + 1);
|
|
74
|
-
try {
|
|
75
|
-
return fn();
|
|
76
|
-
} finally {
|
|
77
|
-
if (depth === 0) PUBLISHED_HISTORY_READ_DEPTH.delete(owner);
|
|
78
|
-
else PUBLISHED_HISTORY_READ_DEPTH.set(owner, depth);
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
const captureHistoryState = (editor) => {
|
|
82
|
-
const draft = getHistoryDraft(editor);
|
|
83
|
-
return draft ? draft.state : HISTORY.get(getEditorRuntimeOwner(editor));
|
|
84
|
-
};
|
|
85
|
-
const restoreHistoryState = (editor, state) => {
|
|
86
|
-
const owner = getEditorRuntimeOwner(editor);
|
|
87
|
-
const draft = getHistoryDraft(owner);
|
|
88
|
-
if (draft) {
|
|
89
|
-
draft.state = state;
|
|
90
|
-
return;
|
|
91
|
-
}
|
|
92
|
-
if (state) holdStore(owner, state);
|
|
93
|
-
else HISTORY.delete(owner);
|
|
94
|
-
};
|
|
95
|
-
const createStore = (editor) => ({
|
|
96
|
-
crossingDrops: 0,
|
|
97
|
-
maxDepth: 100,
|
|
98
|
-
pendingReplay: null,
|
|
99
|
-
redos: null,
|
|
100
|
-
revision: 0,
|
|
101
|
-
schema: editor.read.schema.identity(),
|
|
102
|
-
snapshot: null,
|
|
103
|
-
undos: null,
|
|
104
|
-
unreportedDrops: NO_DROPS
|
|
105
|
-
});
|
|
106
|
-
const getStore = (editor) => {
|
|
107
|
-
const owner = getEditorRuntimeOwner(editor);
|
|
108
|
-
const draft = getHistoryDraft(owner);
|
|
109
|
-
let store = draft ? draft.state : HISTORY.get(owner);
|
|
110
|
-
if (!store) {
|
|
111
|
-
store = createStore(editor);
|
|
112
|
-
if (draft) draft.state = store;
|
|
113
|
-
else HISTORY.set(owner, store);
|
|
114
|
-
}
|
|
115
|
-
return store;
|
|
116
|
-
};
|
|
117
|
-
const setStore = (editor, store) => {
|
|
118
|
-
const owner = getEditorRuntimeOwner(editor);
|
|
119
|
-
const draft = getHistoryDraft(owner);
|
|
120
|
-
if (draft) {
|
|
121
|
-
draft.state = store;
|
|
122
|
-
return;
|
|
123
|
-
}
|
|
124
|
-
holdStore(owner, store);
|
|
125
|
-
};
|
|
126
|
-
const publish = (editor, store, patch) => {
|
|
127
|
-
const next = Object.freeze({
|
|
128
|
-
...store,
|
|
129
|
-
...patch,
|
|
130
|
-
revision: store.revision + 1,
|
|
131
|
-
snapshot: null
|
|
132
|
-
});
|
|
133
|
-
setStore(editor, next);
|
|
134
|
-
return next;
|
|
135
|
-
};
|
|
136
|
-
const cloneFrozen = (value) => {
|
|
137
|
-
const clone = structuredClone(value);
|
|
138
|
-
const pending = clone && typeof clone === "object" ? [clone] : [];
|
|
139
|
-
const seen = /* @__PURE__ */ new WeakSet();
|
|
140
|
-
while (pending.length > 0) {
|
|
141
|
-
const item = pending.pop() ?? failInvariant("Expected value to be defined");
|
|
142
|
-
if (seen.has(item)) continue;
|
|
143
|
-
seen.add(item);
|
|
144
|
-
for (const nested of Object.values(item)) if (nested && typeof nested === "object") pending.push(nested);
|
|
145
|
-
Object.freeze(item);
|
|
146
|
-
}
|
|
147
|
-
return clone;
|
|
148
|
-
};
|
|
149
|
-
const omitPrimaryPointRoot = (point) => {
|
|
150
|
-
if (point.root !== "main") return point;
|
|
151
|
-
const { root: _root, ...rest } = point;
|
|
152
|
-
return rest;
|
|
153
|
-
};
|
|
154
|
-
const omitPrimarySelectionRoot = (selection) => !selection || SelectionApi.isNode(selection) ? selection : {
|
|
155
|
-
...selection,
|
|
156
|
-
anchor: omitPrimaryPointRoot(selection.anchor),
|
|
157
|
-
focus: omitPrimaryPointRoot(selection.focus)
|
|
158
|
-
};
|
|
159
|
-
const additionalRoot = (root) => root && root !== "main" ? root : void 0;
|
|
160
|
-
const STEP_IDS = /* @__PURE__ */ new WeakMap();
|
|
161
|
-
const HISTORY_STEPS = /* @__PURE__ */ new WeakMap();
|
|
162
|
-
const mintStepId = () => btoa(String.fromCodePoint(...crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(16)))).replaceAll("+", "-").replaceAll("/", "_").replaceAll("=", "");
|
|
163
|
-
const knownHistoryStepId = (step) => STEP_IDS.get(step);
|
|
164
|
-
const historyStepId = (step) => {
|
|
165
|
-
const known = STEP_IDS.get(step);
|
|
166
|
-
if (known) return known;
|
|
167
|
-
const id = mintStepId();
|
|
168
|
-
STEP_IDS.set(step, id);
|
|
169
|
-
return id;
|
|
170
|
-
};
|
|
171
|
-
const withHistoryStep = (batch, step) => {
|
|
172
|
-
HISTORY_STEPS.set(batch, step);
|
|
173
|
-
return batch;
|
|
174
|
-
};
|
|
175
|
-
const withHistoryStepId = (batch, id) => {
|
|
176
|
-
if (id === void 0) return batch;
|
|
177
|
-
const step = {};
|
|
178
|
-
STEP_IDS.set(step, id);
|
|
179
|
-
return withHistoryStep(batch, step);
|
|
180
|
-
};
|
|
181
|
-
const historyBatchStepId = (batch) => {
|
|
182
|
-
let step = HISTORY_STEPS.get(batch);
|
|
183
|
-
if (!step) {
|
|
184
|
-
step = {};
|
|
185
|
-
withHistoryStep(batch, step);
|
|
186
|
-
}
|
|
187
|
-
return historyStepId(step);
|
|
188
|
-
};
|
|
189
|
-
const HISTORY_FACTS = /* @__PURE__ */ new WeakMap();
|
|
190
|
-
const withHistoryFacts = (batch, facts) => {
|
|
191
|
-
if (facts) HISTORY_FACTS.set(batch, facts);
|
|
192
|
-
return batch;
|
|
193
|
-
};
|
|
194
|
-
const historyFactsOf = (batch) => HISTORY_FACTS.get(batch);
|
|
195
|
-
const HISTORY_PROGRAMS = /* @__PURE__ */ new WeakMap();
|
|
196
|
-
const withHistoryProgram = (batch, program) => {
|
|
197
|
-
if (program) HISTORY_PROGRAMS.set(batch, program);
|
|
198
|
-
return batch;
|
|
199
|
-
};
|
|
200
|
-
const historyProgramOf = (batch) => HISTORY_PROGRAMS.get(batch);
|
|
201
|
-
const HISTORY_FALLBACKS = /* @__PURE__ */ new WeakMap();
|
|
202
|
-
const withHistoryFallback = (batch, fallback) => {
|
|
203
|
-
HISTORY_FALLBACKS.set(batch, fallback);
|
|
204
|
-
return batch;
|
|
205
|
-
};
|
|
206
|
-
const historyFallbackOf = (batch) => {
|
|
207
|
-
const fallback = HISTORY_FALLBACKS.get(batch) ?? null;
|
|
208
|
-
if (typeof fallback !== "function") return fallback;
|
|
209
|
-
const mapped = fallback();
|
|
210
|
-
HISTORY_FALLBACKS.set(batch, mapped);
|
|
211
|
-
return mapped;
|
|
212
|
-
};
|
|
213
|
-
const outsideFallbackCount = (run) => {
|
|
214
|
-
const fallbacks = readCoreWork().carriedFallbacks;
|
|
215
|
-
const result = run();
|
|
216
|
-
countCoreWork("carriedFallbacks", fallbacks - readCoreWork().carriedFallbacks);
|
|
217
|
-
return result;
|
|
218
|
-
};
|
|
219
|
-
const freezeHistoryBatch = (batch) => {
|
|
220
|
-
const { selectionAfterRoot, selectionBeforeRoot, ...value } = batch;
|
|
221
|
-
const afterRoot = additionalRoot(selectionAfterRoot);
|
|
222
|
-
const beforeRoot = additionalRoot(selectionBeforeRoot);
|
|
223
|
-
const frozen = withHistoryProgram(Object.freeze({
|
|
224
|
-
...value,
|
|
225
|
-
...batch.carried ? { carried: Object.freeze(batch.carried.map((run) => Object.freeze({ ...run }))) } : {},
|
|
226
|
-
effects: Object.freeze(batch.effects.map((effect) => Object.freeze({ ...effect }))),
|
|
227
|
-
selectionAfter: cloneFrozen(omitPrimarySelectionRoot(batch.selectionAfter)),
|
|
228
|
-
...afterRoot ? { selectionAfterRoot: afterRoot } : {},
|
|
229
|
-
selectionBefore: cloneFrozen(omitPrimarySelectionRoot(batch.selectionBefore)),
|
|
230
|
-
...beforeRoot ? { selectionBeforeRoot: beforeRoot } : {}
|
|
231
|
-
}), HISTORY_PROGRAMS.get(batch));
|
|
232
|
-
const fallback = HISTORY_FALLBACKS.get(batch);
|
|
233
|
-
const step = HISTORY_STEPS.get(batch);
|
|
234
|
-
if (fallback !== void 0) HISTORY_FALLBACKS.set(frozen, fallback);
|
|
235
|
-
if (step) withHistoryStep(frozen, step);
|
|
236
|
-
return withHistoryFacts(frozen, HISTORY_FACTS.get(batch));
|
|
237
|
-
};
|
|
238
|
-
const freezeBatch = freezeHistoryBatch;
|
|
239
|
-
/**
|
|
240
|
-
* What a step's replay keeps beside its change: its carried runs, and the
|
|
241
|
-
* take-back and rest a two-part step replays apart.
|
|
242
|
-
*/
|
|
243
|
-
const replayedOf = (batch) => ({
|
|
244
|
-
carried: batch.carried,
|
|
245
|
-
program: HISTORY_PROGRAMS.get(batch),
|
|
246
|
-
parts: batch.rest && batch.unsettle ? {
|
|
247
|
-
rest: batch.rest,
|
|
248
|
-
unsettle: batch.unsettle
|
|
249
|
-
} : void 0
|
|
250
|
-
});
|
|
251
|
-
const branch = (batch, base, replay, next, mappings = null, group = null, recovery = null, anchorCeiling = 0, identity = {}, carets = null, kept = null) => Object.freeze({
|
|
252
|
-
anchorCeiling,
|
|
253
|
-
base,
|
|
254
|
-
batch: withHistoryStep(withHistoryFacts(withHistoryProgram(freezeBatch({
|
|
255
|
-
...batch,
|
|
256
|
-
change: replay.change
|
|
257
|
-
}), replay.program), replay.change === batch.change ? HISTORY_FACTS.get(batch) : void 0), identity),
|
|
258
|
-
carets,
|
|
259
|
-
carries: replay.carried !== void 0 || (next?.carries ?? false),
|
|
260
|
-
replay,
|
|
261
|
-
depth: (next?.depth ?? 0) + 1,
|
|
262
|
-
group,
|
|
263
|
-
identity,
|
|
264
|
-
kept,
|
|
265
|
-
mappings,
|
|
266
|
-
next,
|
|
267
|
-
recovery
|
|
268
|
-
});
|
|
269
|
-
const withKeptBranch = (kept, change) => {
|
|
270
|
-
if (!kept) return null;
|
|
271
|
-
if (kept.kind === "fallback") {
|
|
272
|
-
const plain = change(kept.plain);
|
|
273
|
-
return plain ? Object.freeze({
|
|
274
|
-
...kept,
|
|
275
|
-
plain
|
|
276
|
-
}) : null;
|
|
277
|
-
}
|
|
278
|
-
const mapped = change(kept.branch);
|
|
279
|
-
return mapped ? Object.freeze({
|
|
280
|
-
...kept,
|
|
281
|
-
branch: mapped
|
|
282
|
-
}) : null;
|
|
283
|
-
};
|
|
284
|
-
const clipBranch = (value, maxDepth) => {
|
|
285
|
-
if (!value || maxDepth === 0) return null;
|
|
286
|
-
if (value.depth <= maxDepth) return value;
|
|
287
|
-
const kept = [];
|
|
288
|
-
let current = value;
|
|
289
|
-
while (current && kept.length < maxDepth) {
|
|
290
|
-
kept.push(current);
|
|
291
|
-
current = current.next;
|
|
292
|
-
}
|
|
293
|
-
let clipped = null;
|
|
294
|
-
for (let index = kept.length - 1; index >= 0; index -= 1) {
|
|
295
|
-
const item = kept[index];
|
|
296
|
-
clipped = branch(item.batch, item.base, item.replay, clipped, item.mappings, item.group, item.recovery, item.anchorCeiling, item.identity, item.carets, withKeptBranch(item.kept, (other) => clipBranch(other, maxDepth - index)));
|
|
297
|
-
}
|
|
298
|
-
return clipped;
|
|
299
|
-
};
|
|
300
|
-
const pushBranch = (value, batchValue, base, replay, maxDepth, group = null, recovery = null, anchorCeiling = 0, identity = {}, carets = null) => branch(batchValue, base, replay, clipBranch(value, maxDepth - 1), null, group, recovery, anchorCeiling, identity, carets);
|
|
301
|
-
const addMapping = (value, entry) => {
|
|
302
|
-
if (!value) return null;
|
|
303
|
-
const previous = value.mappings;
|
|
304
|
-
const mappings = !value.carries && previous?.entry.textOnly && entry.textOnly ? Object.freeze({
|
|
305
|
-
entry: Object.freeze({
|
|
306
|
-
after: entry.after,
|
|
307
|
-
change: previous.entry.change.compose(entry.change),
|
|
308
|
-
textOnly: true
|
|
309
|
-
}),
|
|
310
|
-
previous: previous.previous
|
|
311
|
-
}) : Object.freeze({
|
|
312
|
-
entry,
|
|
313
|
-
previous
|
|
314
|
-
});
|
|
315
|
-
return Object.freeze({
|
|
316
|
-
...value,
|
|
317
|
-
kept: withKeptBranch(value.kept, (other) => addMapping(other, entry)),
|
|
318
|
-
mappings
|
|
319
|
-
});
|
|
320
|
-
};
|
|
321
|
-
const journalEntries = (journal) => {
|
|
322
|
-
const entries = [];
|
|
323
|
-
for (let item = journal; item; item = item.previous) entries.push(item.entry);
|
|
324
|
-
return entries.reverse();
|
|
325
|
-
};
|
|
326
|
-
const retainMappedCompositionGroup = (group) => {
|
|
327
|
-
if (group?.native?.composition === void 0) return null;
|
|
328
|
-
const shared = {
|
|
329
|
-
...group.closed ? { closed: group.closed } : {},
|
|
330
|
-
native: group.native,
|
|
331
|
-
...group.scope ? { scope: group.scope } : {}
|
|
332
|
-
};
|
|
333
|
-
return group.root === void 0 ? Object.freeze({
|
|
334
|
-
...shared,
|
|
335
|
-
kind: "effects",
|
|
336
|
-
root: void 0
|
|
337
|
-
}) : Object.freeze({
|
|
338
|
-
...shared,
|
|
339
|
-
kind: "document",
|
|
340
|
-
root: group.root
|
|
341
|
-
});
|
|
342
|
-
};
|
|
343
|
-
const yieldTo = (change, edit, base) => transformInternalDocumentChange(change, edit, base, { keepRecordWrites: true }).a;
|
|
344
|
-
const crossingDropCount = (editor) => captureHistoryState(editor)?.crossingDrops ?? 0;
|
|
345
|
-
const changedRootIndexes = (value, change) => new Map(getInternalDocumentChangeRootKeys(change).map((root) => [root, valueRootIndex(value, root)]));
|
|
346
|
-
const crossOrDrop = (editor, drops, replay, base, facts, mapping, crossing) => {
|
|
347
|
-
countCoreWork("crossedSteps");
|
|
348
|
-
try {
|
|
349
|
-
if (!facts) throw new Error("A crossing reached a step with no facts.");
|
|
350
|
-
const { followed, leftover } = crossRecord(base, {
|
|
351
|
-
change: replay.change,
|
|
352
|
-
facts
|
|
353
|
-
}, {
|
|
354
|
-
change: mapping.change,
|
|
355
|
-
facts: crossing
|
|
356
|
-
});
|
|
357
|
-
const after = followed.change.apply(mapping.after);
|
|
358
|
-
getEditorSchema(editor).checkDocumentChange({
|
|
359
|
-
after,
|
|
360
|
-
before: mapping.after,
|
|
361
|
-
change: followed.change,
|
|
362
|
-
indexedAfter: changedRootIndexes(after, followed.change),
|
|
363
|
-
indexedBefore: changedRootIndexes(mapping.after, followed.change)
|
|
364
|
-
});
|
|
365
|
-
const change = classifyDocumentChange(mapping.after, after, followed.change);
|
|
366
|
-
return {
|
|
367
|
-
facts: followed.facts,
|
|
368
|
-
kind: "crossed",
|
|
369
|
-
keptWrap: null,
|
|
370
|
-
projected: false,
|
|
371
|
-
readBack: false,
|
|
372
|
-
replay: recordHistoryReplay(historyReplaySchemaOf(editor), mapping.after, change, replay.direction, { after }),
|
|
373
|
-
rest: leftover.change,
|
|
374
|
-
restFacts: leftover.facts
|
|
375
|
-
};
|
|
376
|
-
} catch (error) {
|
|
377
|
-
drops.push({
|
|
378
|
-
cause: error,
|
|
379
|
-
direction: replay.direction,
|
|
380
|
-
editor
|
|
381
|
-
});
|
|
382
|
-
return { kind: "dropped" };
|
|
383
|
-
}
|
|
384
|
-
};
|
|
385
|
-
const headAfterDrop = (editor, value, target) => {
|
|
386
|
-
const { next } = value;
|
|
387
|
-
const from = next?.mappings?.entry.after ?? next?.base;
|
|
388
|
-
const correction = next && from ? DocumentChange.between(from, target, { isSetValued: historyReplaySchemaOf(editor).isSetValued }) : DocumentChange.empty;
|
|
389
|
-
return {
|
|
390
|
-
head: correction.empty ? next : addMapping(next, {
|
|
391
|
-
after: target,
|
|
392
|
-
change: correction,
|
|
393
|
-
textOnly: isTextOnlyMapping(correction)
|
|
394
|
-
}),
|
|
395
|
-
keptWrap: null,
|
|
396
|
-
projected: false,
|
|
397
|
-
projectedAfterReadBack: false,
|
|
398
|
-
readBack: false
|
|
399
|
-
};
|
|
400
|
-
};
|
|
401
|
-
const mapHead = (editor, drops, value, { anchor, readBack: reads }, count = Number.POSITIVE_INFINITY) => {
|
|
402
|
-
if (!value.mappings) return {
|
|
403
|
-
head: value,
|
|
404
|
-
keptWrap: null,
|
|
405
|
-
projected: false,
|
|
406
|
-
projectedAfterReadBack: false,
|
|
407
|
-
readBack: false
|
|
408
|
-
};
|
|
409
|
-
let keptWrap = null;
|
|
410
|
-
let readBack = false;
|
|
411
|
-
let projected = false;
|
|
412
|
-
let projectedAfterReadBack = false;
|
|
413
|
-
let batchBase = value.base;
|
|
414
|
-
let batchValue = value.batch;
|
|
415
|
-
let { replay } = value;
|
|
416
|
-
let { next } = value;
|
|
417
|
-
let { carets, recovery } = value;
|
|
418
|
-
let batchFacts = HISTORY_FACTS.get(value.batch);
|
|
419
|
-
const entries = journalEntries(value.mappings);
|
|
420
|
-
for (const mapping of entries.slice(0, count)) {
|
|
421
|
-
const nextBase = replay.record().after;
|
|
422
|
-
const crossed = mapping.crossing ? crossOrDrop(editor, drops, replay, batchBase, batchFacts, mapping, mapping.crossing) : null;
|
|
423
|
-
if (crossed?.kind === "dropped") return headAfterDrop(editor, value, (entries.at(-1) ?? mapping).after);
|
|
424
|
-
const mapped = crossed ?? mapHistoryReplay(historyReplaySchemaOf(editor), replay, batchBase, mapping, {
|
|
425
|
-
anchor: anchor && mapping.anchors === true,
|
|
426
|
-
readBack: reads
|
|
427
|
-
});
|
|
428
|
-
batchFacts = crossed?.facts;
|
|
429
|
-
keptWrap ??= mapped.keptWrap;
|
|
430
|
-
projected ||= mapped.projected;
|
|
431
|
-
projectedAfterReadBack ||= readBack && mapped.projected;
|
|
432
|
-
readBack ||= mapped.readBack;
|
|
433
|
-
const mappedBatchBase = mapping.after;
|
|
434
|
-
const mappedNextBase = mapped.replay.record().after;
|
|
435
|
-
({replay} = mapped);
|
|
436
|
-
const batchEdge = {
|
|
437
|
-
after: mappedBatchBase,
|
|
438
|
-
before: batchBase,
|
|
439
|
-
change: mapping.change,
|
|
440
|
-
facts: mapping.crossing ?? null
|
|
441
|
-
};
|
|
442
|
-
const nextEdge = {
|
|
443
|
-
after: mappedNextBase,
|
|
444
|
-
before: nextBase,
|
|
445
|
-
change: mapped.rest,
|
|
446
|
-
facts: crossed?.restFacts ?? null
|
|
447
|
-
};
|
|
448
|
-
const sides = replay.direction === "undo" ? {
|
|
449
|
-
after: batchEdge,
|
|
450
|
-
before: nextEdge
|
|
451
|
-
} : {
|
|
452
|
-
after: nextEdge,
|
|
453
|
-
before: batchEdge
|
|
454
|
-
};
|
|
455
|
-
recovery = mapAnchorHistoryRecovery(recovery, "after", sides.after);
|
|
456
|
-
recovery = mapAnchorHistoryRecovery(recovery, "before", sides.before);
|
|
457
|
-
if (carets) carets = mapHistoryCarets(editor, carets, batchValue, sides);
|
|
458
|
-
const { carried: _carried, rest: _rest, unsettle: _unmapped, ...mappedBatch } = batchValue;
|
|
459
|
-
const parts = replay.parts && {
|
|
460
|
-
rest: replay.parts.rest.change,
|
|
461
|
-
unsettle: replay.parts.unsettle.change
|
|
462
|
-
};
|
|
463
|
-
const unsettle = parts?.unsettle ?? (batchValue.unsettle && yieldTo(batchValue.unsettle, mapping.change, batchBase));
|
|
464
|
-
batchValue = freezeBatch({
|
|
465
|
-
...mappedBatch,
|
|
466
|
-
...parts ?? (unsettle && !unsettle.empty ? { unsettle } : {}),
|
|
467
|
-
...replay.carried ? { carried: replay.carried } : {},
|
|
468
|
-
change: replay.change,
|
|
469
|
-
effects: batchValue.effects.flatMap((effect) => {
|
|
470
|
-
const mappedEffect = mapEffect(effect, mapping.change);
|
|
471
|
-
return mappedEffect ? [mappedEffect] : [];
|
|
472
|
-
}),
|
|
473
|
-
selectionAfter: mapHistorySelection(editor, batchValue.selectionAfter, sides.after.change, sides.after.before, sides.after.after, batchValue.selectionAfterRoot ?? "main"),
|
|
474
|
-
selectionBefore: mapHistorySelection(editor, batchValue.selectionBefore, sides.before.change, sides.before.before, sides.before.after, batchValue.selectionBeforeRoot ?? "main")
|
|
475
|
-
});
|
|
476
|
-
if (!mapped.rest.empty) next = addMapping(next, {
|
|
477
|
-
after: mappedNextBase,
|
|
478
|
-
change: mapped.rest,
|
|
479
|
-
textOnly: false,
|
|
480
|
-
...crossed ? { crossing: crossed.restFacts } : {}
|
|
481
|
-
});
|
|
482
|
-
batchBase = mappedBatchBase;
|
|
483
|
-
}
|
|
484
|
-
const later = entries.slice(count);
|
|
485
|
-
const empty = batchValue.change.empty && batchValue.effects.length === 0;
|
|
486
|
-
if (empty) for (const mapping of later) next = addMapping(next, mapping);
|
|
487
|
-
return {
|
|
488
|
-
head: empty ? next : branch(withHistoryFacts(batchValue, batchFacts), batchBase, replay, next, later.reduce((previous, entry) => Object.freeze({
|
|
489
|
-
entry,
|
|
490
|
-
previous
|
|
491
|
-
}), null), retainMappedCompositionGroup(value.group), recovery, value.anchorCeiling, value.identity, carets),
|
|
492
|
-
keptWrap,
|
|
493
|
-
projected,
|
|
494
|
-
projectedAfterReadBack,
|
|
495
|
-
readBack
|
|
496
|
-
};
|
|
497
|
-
};
|
|
498
|
-
const mapAnchored = (editor, value, readBack) => {
|
|
499
|
-
const drops = [];
|
|
500
|
-
try {
|
|
501
|
-
return {
|
|
502
|
-
...mapHead(editor, drops, value, {
|
|
503
|
-
anchor: true,
|
|
504
|
-
readBack
|
|
505
|
-
}),
|
|
506
|
-
drops
|
|
507
|
-
};
|
|
508
|
-
} catch {
|
|
509
|
-
return null;
|
|
510
|
-
}
|
|
511
|
-
};
|
|
512
|
-
const resolveProgramHead = (editor, drops, value, readBack) => {
|
|
513
|
-
const attemptDrops = [];
|
|
514
|
-
const mapped = mapHead(editor, attemptDrops, value, {
|
|
515
|
-
anchor: false,
|
|
516
|
-
readBack
|
|
517
|
-
});
|
|
518
|
-
const { head: attempt } = mapped;
|
|
519
|
-
const fallbackReplay = projectedHistoryReplay(historyReplaySchemaOf(editor), value.replay, value.base);
|
|
520
|
-
if (!attempt?.replay.program || attempt.identity !== value.identity || !fallbackReplay) {
|
|
521
|
-
drops.push(...attemptDrops);
|
|
522
|
-
return mapped;
|
|
523
|
-
}
|
|
524
|
-
const fallbackDrops = [];
|
|
525
|
-
const { head: fallback } = mapHead(editor, fallbackDrops, branch(value.batch, value.base, fallbackReplay, value.next, value.mappings, value.group, value.recovery, value.anchorCeiling, value.identity, value.carets), {
|
|
526
|
-
anchor: false,
|
|
527
|
-
readBack: false
|
|
528
|
-
});
|
|
529
|
-
if (fallback?.identity !== value.identity) {
|
|
530
|
-
drops.push(...attemptDrops);
|
|
531
|
-
return mapped;
|
|
532
|
-
}
|
|
533
|
-
drops.push(...fallbackDrops);
|
|
534
|
-
return {
|
|
535
|
-
head: Object.freeze({
|
|
536
|
-
...fallback,
|
|
537
|
-
kept: Object.freeze({
|
|
538
|
-
branch: attempt,
|
|
539
|
-
kind: "program"
|
|
540
|
-
})
|
|
541
|
-
}),
|
|
542
|
-
projected: mapped.projected,
|
|
543
|
-
projectedAfterReadBack: mapped.projectedAfterReadBack,
|
|
544
|
-
readBack: mapped.readBack
|
|
545
|
-
};
|
|
546
|
-
};
|
|
547
|
-
const crossFirstMapping = (editor, drops, value) => mapHead(editor, drops, value, {
|
|
548
|
-
anchor: false,
|
|
549
|
-
readBack: false
|
|
550
|
-
}, 1).head;
|
|
551
|
-
const resolveHead = (editor, drops, value) => {
|
|
552
|
-
if (!value.mappings) return value;
|
|
553
|
-
if (journalEntries(value.mappings)[0]?.crossing) return crossFirstMapping(editor, drops, value);
|
|
554
|
-
const earlier = value.kept?.kind === "fallback" ? value.kept.plain : null;
|
|
555
|
-
const current = earlier ? Object.freeze({
|
|
556
|
-
...value,
|
|
557
|
-
kept: null
|
|
558
|
-
}) : value;
|
|
559
|
-
const bestDrops = [];
|
|
560
|
-
const { head: best, projected, projectedAfterReadBack, readBack: shaped } = resolveByRules(editor, bestDrops, current, true);
|
|
561
|
-
if (projectedAfterReadBack || earlier && projected) return resolveByRules(editor, drops, earlier ?? current, false).head;
|
|
562
|
-
if (current.replay.direction !== "redo" || !best || best.kept || best.identity !== value.identity || !earlier && !shaped) {
|
|
563
|
-
drops.push(...bestDrops);
|
|
564
|
-
return best;
|
|
565
|
-
}
|
|
566
|
-
const fallback = earlier ?? plainOf(editor, current);
|
|
567
|
-
if (shaped) try {
|
|
568
|
-
editor.read.schema.assertDocument(best.replay.change.apply(best.base));
|
|
569
|
-
} catch {
|
|
570
|
-
return resolveByRules(editor, drops, fallback, false).head;
|
|
571
|
-
}
|
|
572
|
-
drops.push(...bestDrops);
|
|
573
|
-
return Object.freeze({
|
|
574
|
-
...best,
|
|
575
|
-
kept: Object.freeze({
|
|
576
|
-
kind: "fallback",
|
|
577
|
-
plain: fallback
|
|
578
|
-
})
|
|
579
|
-
});
|
|
580
|
-
};
|
|
581
|
-
const plainOf = (editor, value) => {
|
|
582
|
-
const { head } = outsideFallbackCount(() => resolveByRules(editor, [], value, false));
|
|
583
|
-
return head?.identity === value.identity ? head : value;
|
|
584
|
-
};
|
|
585
|
-
const plainFallback = (editor, drops, shown) => {
|
|
586
|
-
if (shown.kept?.kind !== "fallback") return null;
|
|
587
|
-
const { head: plain } = resolveByRules(editor, drops, shown.kept.plain, false);
|
|
588
|
-
return plain && plain.identity === shown.identity && !jsonEqual(plain.replay.change.toJSON(), shown.replay.change.toJSON()) ? plain : null;
|
|
589
|
-
};
|
|
590
|
-
const resolveByRules = (editor, drops, value, readBack) => {
|
|
591
|
-
if (!value.mappings) return {
|
|
592
|
-
head: value,
|
|
593
|
-
projected: false,
|
|
594
|
-
projectedAfterReadBack: false,
|
|
595
|
-
readBack: false
|
|
596
|
-
};
|
|
597
|
-
if (value.replay.program && value.replay.direction === "redo" && !value.kept) return resolveProgramHead(editor, drops, value, readBack);
|
|
598
|
-
const anchorable = !value.kept && value.replay.direction === "redo" && journalEntries(value.mappings).some(({ anchors }) => anchors);
|
|
599
|
-
const anchored = value.kept ? mapAnchored(editor, value.kept.kind === "fallback" ? value.kept.plain : value.kept.branch, readBack) : anchorable ? mapAnchored(editor, value, readBack) : null;
|
|
600
|
-
if (anchorable && anchored && !anchored.keptWrap) {
|
|
601
|
-
drops.push(...anchored.drops);
|
|
602
|
-
return anchored;
|
|
603
|
-
}
|
|
604
|
-
const wrap = value.kept ? value.kept.kind === "wrap" ? value.kept.wrap : null : anchored?.keptWrap;
|
|
605
|
-
const attempt = anchored?.head?.identity === value.identity ? anchored.head : null;
|
|
606
|
-
const kept = attempt && wrap ? Object.freeze({
|
|
607
|
-
branch: attempt,
|
|
608
|
-
kind: "wrap",
|
|
609
|
-
wrap
|
|
610
|
-
}) : attempt?.replay.program ? Object.freeze({
|
|
611
|
-
branch: attempt,
|
|
612
|
-
kind: "program"
|
|
613
|
-
}) : null;
|
|
614
|
-
const mapped = mapHead(editor, drops, value, {
|
|
615
|
-
anchor: false,
|
|
616
|
-
readBack: readBack && !kept
|
|
617
|
-
});
|
|
618
|
-
const { head } = mapped;
|
|
619
|
-
return kept && head?.identity === value.identity ? {
|
|
620
|
-
...mapped,
|
|
621
|
-
head: Object.freeze({
|
|
622
|
-
...head,
|
|
623
|
-
kept
|
|
624
|
-
})
|
|
625
|
-
} : mapped;
|
|
626
|
-
};
|
|
627
|
-
const resolveTop = (editor, drops, value) => {
|
|
628
|
-
let current = value;
|
|
629
|
-
while (current?.mappings) current = resolveHead(editor, drops, current);
|
|
630
|
-
return current;
|
|
631
|
-
};
|
|
632
|
-
const resolveCanonicalTop = (editor, drops, value) => {
|
|
633
|
-
const head = resolveTop(editor, drops, value);
|
|
634
|
-
if (!head) return null;
|
|
635
|
-
const schema = historyReplaySchemaOf(editor);
|
|
636
|
-
const target = head.replay.change.apply(head.base);
|
|
637
|
-
const repair = schema.repairCanonical(head.base, head.replay.change, target);
|
|
638
|
-
if (repair.empty) return head;
|
|
639
|
-
const repaired = repair.apply(target);
|
|
640
|
-
const change = head.replay.change.compose(repair);
|
|
641
|
-
const rest = head.batch.rest?.compose(repair);
|
|
642
|
-
const { carried: _carried, ...repairedBatch } = head.batch;
|
|
643
|
-
const carried = head.batch.carried && landCarriedRuns(head.batch.carried, [{
|
|
644
|
-
after: repaired,
|
|
645
|
-
before: target,
|
|
646
|
-
change: repair
|
|
647
|
-
}]);
|
|
648
|
-
const undo = head.replay.direction === "undo";
|
|
649
|
-
const unmoved = {
|
|
650
|
-
after: head.base,
|
|
651
|
-
before: head.base,
|
|
652
|
-
change: DocumentChange.between(head.base, head.base)
|
|
653
|
-
};
|
|
654
|
-
const moved = {
|
|
655
|
-
after: repaired,
|
|
656
|
-
before: target,
|
|
657
|
-
change: repair
|
|
658
|
-
};
|
|
659
|
-
const restored = (selection, root) => mapHistorySelection(editor, selection, repair, target, repaired, root ?? "main");
|
|
660
|
-
return branch(freezeBatch(undo ? {
|
|
661
|
-
...repairedBatch,
|
|
662
|
-
change,
|
|
663
|
-
...rest ? { rest } : {},
|
|
664
|
-
...carried ? { carried } : {},
|
|
665
|
-
selectionBefore: restored(head.batch.selectionBefore, head.batch.selectionBeforeRoot)
|
|
666
|
-
} : {
|
|
667
|
-
...repairedBatch,
|
|
668
|
-
change,
|
|
669
|
-
...carried ? { carried } : {},
|
|
670
|
-
selectionAfter: restored(head.batch.selectionAfter, head.batch.selectionAfterRoot)
|
|
671
|
-
}), head.base, recordHistoryReplay(schema, head.base, change, head.replay.direction, {
|
|
672
|
-
carried,
|
|
673
|
-
program: head.replay.program,
|
|
674
|
-
parts: rest && head.batch.unsettle ? {
|
|
675
|
-
rest,
|
|
676
|
-
unsettle: head.batch.unsettle
|
|
677
|
-
} : void 0
|
|
678
|
-
}), addMapping(head.next, {
|
|
679
|
-
after: repaired,
|
|
680
|
-
change: repair,
|
|
681
|
-
textOnly: isTextOnlyMapping(repair)
|
|
682
|
-
}), null, head.group, mapAnchorHistoryRecovery(head.recovery, undo ? "before" : "after", {
|
|
683
|
-
after: repaired,
|
|
684
|
-
before: target,
|
|
685
|
-
change: repair,
|
|
686
|
-
facts: null
|
|
687
|
-
}), head.anchorCeiling, head.identity, head.carets && mapHistoryCarets(editor, head.carets, head.batch, undo ? {
|
|
688
|
-
after: unmoved,
|
|
689
|
-
before: moved
|
|
690
|
-
} : {
|
|
691
|
-
after: moved,
|
|
692
|
-
before: unmoved
|
|
693
|
-
}));
|
|
694
|
-
};
|
|
695
|
-
const shownBatches = (editor, drops, value) => {
|
|
696
|
-
const batches = [];
|
|
697
|
-
let current = resolveTop(editor, drops, value);
|
|
698
|
-
while (current) {
|
|
699
|
-
const shown = current.kept?.kind === "program" ? current.kept.branch : current;
|
|
700
|
-
if (shown !== current && !jsonEqual(current.replay.change.toJSON(), shown.replay.change.toJSON())) HISTORY_FALLBACKS.set(shown.batch, current.batch);
|
|
701
|
-
if (shown.kept?.kind === "fallback") {
|
|
702
|
-
const withFallback = shown;
|
|
703
|
-
HISTORY_FALLBACKS.set(shown.batch, () => outsideFallbackCount(() => plainFallback(editor, [], withFallback))?.batch ?? null);
|
|
704
|
-
}
|
|
705
|
-
batches.push(shown.batch);
|
|
706
|
-
current = resolveTop(editor, drops, shown.next);
|
|
707
|
-
}
|
|
708
|
-
return Object.freeze(batches.toReversed());
|
|
709
|
-
};
|
|
710
|
-
const resolvedEntryOf = (current) => ({
|
|
711
|
-
anchorCeiling: current.anchorCeiling,
|
|
712
|
-
base: current.base,
|
|
713
|
-
batch: current.batch,
|
|
714
|
-
carets: current.carets,
|
|
715
|
-
group: current.group,
|
|
716
|
-
identity: current.identity,
|
|
717
|
-
kept: current.kept,
|
|
718
|
-
recovery: current.recovery,
|
|
719
|
-
replay: current.replay
|
|
720
|
-
});
|
|
721
|
-
const resolveAll = (editor, drops, value) => {
|
|
722
|
-
const newest = [];
|
|
723
|
-
let current = value;
|
|
724
|
-
while (current) {
|
|
725
|
-
current = resolveTop(editor, drops, current);
|
|
726
|
-
if (!current) break;
|
|
727
|
-
newest.push(resolvedEntryOf(current));
|
|
728
|
-
current = current.next;
|
|
729
|
-
}
|
|
730
|
-
let resolved = null;
|
|
731
|
-
for (let index = newest.length - 1; index >= 0; index--) {
|
|
732
|
-
const entry = newest[index];
|
|
733
|
-
resolved = branch(entry.batch, entry.base, entry.replay, resolved, null, entry.group, entry.recovery, entry.anchorCeiling, entry.identity, entry.carets, entry.kept);
|
|
734
|
-
}
|
|
735
|
-
return {
|
|
736
|
-
batches: shownBatches(editor, drops, resolved),
|
|
737
|
-
branch: resolved,
|
|
738
|
-
entries: Object.freeze(newest)
|
|
739
|
-
};
|
|
740
|
-
};
|
|
741
|
-
const rebuildBranch = (entries, maxDepth, tail = null) => {
|
|
742
|
-
let value = tail;
|
|
743
|
-
for (let index = Math.min(entries.length, maxDepth) - 1; index >= 0; index -= 1) {
|
|
744
|
-
const entry = entries[index];
|
|
745
|
-
value = branch(entry.batch, entry.base, entry.replay, value, null, entry.group, entry.recovery, entry.anchorCeiling, entry.identity, entry.carets, withKeptBranch(entry.kept, (other) => clipBranch(other, maxDepth - index)));
|
|
746
|
-
}
|
|
747
|
-
return value;
|
|
748
|
-
};
|
|
749
|
-
const replacePendingReplay = (editor, store, pendingReplay, patch = {}) => {
|
|
750
|
-
setStore(editor, Object.freeze({
|
|
751
|
-
...store,
|
|
752
|
-
...patch,
|
|
753
|
-
pendingReplay
|
|
754
|
-
}));
|
|
755
|
-
};
|
|
756
|
-
const beginHistoryReplay = (editor, input) => {
|
|
757
|
-
const store = getStore(editor);
|
|
758
|
-
if (store.pendingReplay) throw new Error("History replay is already pending.");
|
|
759
|
-
replacePendingReplay(editor, store, Object.freeze({
|
|
760
|
-
...input,
|
|
761
|
-
edited: false,
|
|
762
|
-
entry: null,
|
|
763
|
-
phase: "attached",
|
|
764
|
-
replayMappings: null
|
|
765
|
-
}));
|
|
766
|
-
};
|
|
767
|
-
const readPendingHistoryReplay = (editor) => getStore(editor).pendingReplay;
|
|
768
|
-
const dropPendingHistoryReplayEntry = (editor) => {
|
|
769
|
-
const store = getStore(editor);
|
|
770
|
-
const pending = store.pendingReplay;
|
|
771
|
-
if (!pending || pending.phase === "dropped") return;
|
|
772
|
-
replacePendingReplay(editor, store, Object.freeze({
|
|
773
|
-
...pending,
|
|
774
|
-
entry: null,
|
|
775
|
-
phase: "dropped"
|
|
776
|
-
}));
|
|
777
|
-
};
|
|
778
|
-
const queuePendingHistoryReplayMapping = (editor, change, after) => {
|
|
779
|
-
if (change.empty) return;
|
|
780
|
-
const store = getStore(editor);
|
|
781
|
-
const pending = store.pendingReplay;
|
|
782
|
-
if (!pending || pending.phase !== "attached") return;
|
|
783
|
-
replacePendingReplay(editor, store, Object.freeze({
|
|
784
|
-
...pending,
|
|
785
|
-
replayMappings: Object.freeze({
|
|
786
|
-
entry: Object.freeze({
|
|
787
|
-
after,
|
|
788
|
-
change,
|
|
789
|
-
textOnly: isTextOnlyMapping(change)
|
|
790
|
-
}),
|
|
791
|
-
previous: pending.replayMappings
|
|
792
|
-
})
|
|
793
|
-
}));
|
|
794
|
-
};
|
|
795
|
-
const markPendingHistoryReplayEdited = (editor) => {
|
|
796
|
-
const store = getStore(editor);
|
|
797
|
-
const pending = store.pendingReplay;
|
|
798
|
-
if (!pending) return false;
|
|
799
|
-
if (pending.edited) return true;
|
|
800
|
-
if (pending.direction !== "redo" || pending.phase !== "attached") {
|
|
801
|
-
replacePendingReplay(editor, store, Object.freeze({
|
|
802
|
-
...pending,
|
|
803
|
-
edited: true
|
|
804
|
-
}));
|
|
805
|
-
return true;
|
|
806
|
-
}
|
|
807
|
-
const drops = [];
|
|
808
|
-
const redos = resolveAll(editor, drops, store.redos);
|
|
809
|
-
const entry = redos.entries.find((candidate) => candidate.identity === pending.identity) ?? null;
|
|
810
|
-
replacePendingReplay(editor, withDrops(store, drops), Object.freeze({
|
|
811
|
-
...pending,
|
|
812
|
-
edited: true,
|
|
813
|
-
entry,
|
|
814
|
-
phase: entry ? "detached" : "dropped"
|
|
815
|
-
}), { redos: redos.branch });
|
|
816
|
-
return true;
|
|
817
|
-
};
|
|
818
|
-
const settlePendingHistoryReplay = (editor, input) => {
|
|
819
|
-
const store = getStore(editor);
|
|
820
|
-
const pending = store.pendingReplay;
|
|
821
|
-
if (!pending || pending.request !== input.request) throw new Error("History replay settlement has no matching claim.");
|
|
822
|
-
if (input.status === "blocked") {
|
|
823
|
-
replacePendingReplay(editor, store, null);
|
|
824
|
-
return null;
|
|
825
|
-
}
|
|
826
|
-
if (!input.change || !input.effects) throw new Error("Applied history replay settlement requires a batch.");
|
|
827
|
-
const drops = [];
|
|
828
|
-
const undos = resolveAll(editor, drops, store.undos);
|
|
829
|
-
const redos = resolveAll(editor, drops, store.redos);
|
|
830
|
-
const attached = (pending.direction === "undo" ? undos.entries : redos.entries).find((candidate) => candidate.identity === pending.identity);
|
|
831
|
-
const claimed = pending.phase === "detached" ? pending.entry : attached ?? null;
|
|
832
|
-
if (!claimed) {
|
|
833
|
-
replacePendingReplay(editor, withDrops(store, drops), null, {
|
|
834
|
-
redos: redos.branch,
|
|
835
|
-
undos: undos.branch
|
|
836
|
-
});
|
|
837
|
-
return null;
|
|
838
|
-
}
|
|
839
|
-
let nextUndos = [...undos.entries];
|
|
840
|
-
let nextRedos = [...redos.entries];
|
|
841
|
-
let insertionIndex = null;
|
|
842
|
-
let replayBase = claimed.base;
|
|
843
|
-
let replayEffects = pending.replayMappings ? journalEntries(pending.replayMappings).reduce((mapped, mapping) => mapped.flatMap((effect) => {
|
|
844
|
-
const next = mapEffect(effect, mapping.change);
|
|
845
|
-
return next ? [next] : [];
|
|
846
|
-
}), [...input.effects]) : [...input.effects];
|
|
847
|
-
if (pending.direction === "undo") nextUndos = nextUndos.filter((candidate) => candidate.identity !== pending.identity);
|
|
848
|
-
else {
|
|
849
|
-
nextRedos = nextRedos.filter((candidate) => candidate.identity !== pending.identity);
|
|
850
|
-
if (pending.edited) {
|
|
851
|
-
insertionIndex = pending.undoAnchor ? nextUndos.findIndex((candidate) => candidate.identity === pending.undoAnchor) : nextUndos.length;
|
|
852
|
-
if (insertionIndex >= 0 && insertionIndex < store.maxDepth) {
|
|
853
|
-
const latestUndo = nextUndos.at(-1);
|
|
854
|
-
replayBase = nextUndos[insertionIndex]?.base ?? (latestUndo ? latestUndo.batch.change.apply(latestUndo.base) : claimed.base);
|
|
855
|
-
const correction = DocumentChange.between(claimed.base, replayBase);
|
|
856
|
-
if (!correction.empty) replayEffects = replayEffects.flatMap((effect) => {
|
|
857
|
-
const mapped = mapEffect(effect, correction);
|
|
858
|
-
return mapped ? [mapped] : [];
|
|
859
|
-
});
|
|
860
|
-
}
|
|
861
|
-
}
|
|
862
|
-
}
|
|
863
|
-
const { carried: _carried, rest: _rest, unsettle: _unsettle, ...claimedBatch } = claimed.batch;
|
|
864
|
-
const replayed = Object.freeze({
|
|
865
|
-
...claimed,
|
|
866
|
-
base: replayBase,
|
|
867
|
-
kept: null,
|
|
868
|
-
replay: recordHistoryReplay(historyReplaySchemaOf(editor), replayBase, input.change, pending.direction === "undo" ? "redo" : "undo"),
|
|
869
|
-
batch: Object.freeze({
|
|
870
|
-
...claimedBatch,
|
|
871
|
-
change: input.change,
|
|
872
|
-
effects: replayEffects.toReversed().map(invertEffect)
|
|
873
|
-
})
|
|
874
|
-
});
|
|
875
|
-
if (pending.direction === "undo") {
|
|
876
|
-
if (!pending.edited) nextRedos.unshift(replayed);
|
|
877
|
-
} else if (!pending.edited) nextUndos.unshift(replayed);
|
|
878
|
-
else if (insertionIndex !== null && insertionIndex >= 0 && insertionIndex < store.maxDepth) nextUndos.splice(insertionIndex, 0, replayed);
|
|
879
|
-
publish(editor, withDrops(store, drops), {
|
|
880
|
-
pendingReplay: null,
|
|
881
|
-
redos: rebuildBranch(nextRedos, store.maxDepth),
|
|
882
|
-
undos: rebuildBranch(nextUndos, store.maxDepth)
|
|
883
|
-
});
|
|
884
|
-
return claimed.identity;
|
|
885
|
-
};
|
|
886
|
-
const fromBatches = (editor, direction, batches, base, maxDepth) => {
|
|
887
|
-
const entries = [];
|
|
888
|
-
let currentBase = base;
|
|
889
|
-
for (const batchValue of batches.slice(-maxDepth).toReversed()) {
|
|
890
|
-
entries.push({
|
|
891
|
-
base: currentBase,
|
|
892
|
-
batch: batchValue
|
|
893
|
-
});
|
|
894
|
-
currentBase = batchValue.change.apply(currentBase);
|
|
895
|
-
}
|
|
896
|
-
let value = null;
|
|
897
|
-
const replayOf = (batchValue, from) => recordHistoryReplay(historyReplaySchemaOf(editor), from, batchValue.change, direction, replayedOf(batchValue));
|
|
898
|
-
for (const entry of entries.toReversed()) {
|
|
899
|
-
const fallback = direction === "redo" ? historyFallbackOf(entry.batch) : null;
|
|
900
|
-
const identity = HISTORY_STEPS.get(entry.batch) ?? {};
|
|
901
|
-
value = branch(entry.batch, entry.base, replayOf(entry.batch, entry.base), value, null, null, null, 0, identity, null, fallback ? Object.freeze({
|
|
902
|
-
kind: "fallback",
|
|
903
|
-
plain: branch(fallback, entry.base, replayOf(fallback, entry.base), value, null, null, null, 0, identity)
|
|
904
|
-
}) : null);
|
|
905
|
-
}
|
|
906
|
-
return value;
|
|
907
|
-
};
|
|
908
|
-
/** Publish activation options and the live schema as one history revision. */
|
|
909
|
-
const configureHistoryState = (editor, maxDepth, schema = editor.read.schema.identity()) => {
|
|
910
|
-
const store = getStore(editor);
|
|
911
|
-
const schemaChanged = !areEditorSchemaIdentitiesEqual(store.schema, schema);
|
|
912
|
-
if (store.maxDepth === maxDepth && !schemaChanged) return false;
|
|
913
|
-
publish(editor, store, {
|
|
914
|
-
maxDepth,
|
|
915
|
-
redos: schemaChanged ? null : clipBranch(store.redos, maxDepth),
|
|
916
|
-
schema,
|
|
917
|
-
undos: schemaChanged ? null : clipBranch(store.undos, maxDepth)
|
|
918
|
-
});
|
|
919
|
-
return schemaChanged;
|
|
920
|
-
};
|
|
921
|
-
const getWorkingHistory = (editor) => {
|
|
922
|
-
const store = getStore(editor);
|
|
923
|
-
if (store.snapshot) return store.snapshot;
|
|
924
|
-
const drops = [];
|
|
925
|
-
const redos = resolveAll(editor, drops, store.redos);
|
|
926
|
-
const undos = resolveAll(editor, drops, store.undos);
|
|
927
|
-
const snapshot = Object.freeze({
|
|
928
|
-
redos: redos.batches,
|
|
929
|
-
revision: store.revision,
|
|
930
|
-
schema: store.schema,
|
|
931
|
-
undos: undos.batches
|
|
932
|
-
});
|
|
933
|
-
setStore(editor, withDrops(Object.freeze({
|
|
934
|
-
...store,
|
|
935
|
-
redos: redos.branch,
|
|
936
|
-
snapshot,
|
|
937
|
-
undos: undos.branch
|
|
938
|
-
}), drops));
|
|
939
|
-
return snapshot;
|
|
940
|
-
};
|
|
941
|
-
const getHistory = (editor) => withPublishedHistoryState(editor, () => getWorkingHistory(editor));
|
|
942
|
-
const keptAttempt = (stack, request) => stack === "redos" && request !== void 0 ? KEPT_REDO_ATTEMPTS.get(request) : void 0;
|
|
943
|
-
const peekResolvedEntry = (editor, stack, resolve, request) => {
|
|
944
|
-
const store = getStore(editor);
|
|
945
|
-
const kept = keptAttempt(stack, request);
|
|
946
|
-
const head = kept ? kept.attempt : store[stack];
|
|
947
|
-
const drops = [];
|
|
948
|
-
const resolved = resolve(editor, drops, head);
|
|
949
|
-
if (kept) {
|
|
950
|
-
if (resolved && (resolved !== head || drops.length > 0) && request !== void 0) KEPT_REDO_ATTEMPTS.set(request, {
|
|
951
|
-
attempt: resolved,
|
|
952
|
-
drops: [...kept.drops, ...drops]
|
|
953
|
-
});
|
|
954
|
-
} else if (resolved !== head || drops.length > 0) setStore(editor, withDrops(Object.freeze({
|
|
955
|
-
...store,
|
|
956
|
-
[stack]: resolved,
|
|
957
|
-
snapshot: null
|
|
958
|
-
}), drops));
|
|
959
|
-
return resolved ? Object.freeze({
|
|
960
|
-
anchorCeiling: resolved.anchorCeiling,
|
|
961
|
-
base: resolved.base,
|
|
962
|
-
batch: resolved.batch,
|
|
963
|
-
carets: resolved.carets,
|
|
964
|
-
group: resolved.group,
|
|
965
|
-
identity: resolved.identity,
|
|
966
|
-
recovery: resolved.recovery,
|
|
967
|
-
restores: resolved.replay.after
|
|
968
|
-
}) : void 0;
|
|
969
|
-
};
|
|
970
|
-
const peekHistoryEntry = (editor, stack, request) => peekResolvedEntry(editor, stack, resolveTop, request);
|
|
971
|
-
const topJoinsNothingOnceMapped = (editor) => {
|
|
972
|
-
const head = getStore(editor).undos;
|
|
973
|
-
const mapping = head?.mappings;
|
|
974
|
-
return !!head && !!mapping && !mapping.previous && !mapping.entry.crossing && !head.kept && !retainMappedCompositionGroup(head.group) && keepsUndoThrough(historyReplaySchemaOf(editor), head.replay, head.base, mapping.entry);
|
|
975
|
-
};
|
|
976
|
-
const peekJoinableUndoEntry = (editor) => {
|
|
977
|
-
if (topJoinsNothingOnceMapped(editor)) return void 0;
|
|
978
|
-
const drops = crossingDropCount(editor);
|
|
979
|
-
const entry = peekResolvedEntry(editor, "undos", resolveSurvivingTop);
|
|
980
|
-
return crossingDropCount(editor) === drops ? entry : void 0;
|
|
981
|
-
};
|
|
982
|
-
const peekHistoryReplayEntry = (editor, stack, request) => peekResolvedEntry(editor, stack, resolveCanonicalTop, request);
|
|
983
|
-
const unwrapsTo = (after, before, props) => {
|
|
984
|
-
if (!jsonEqual(after.records, before.records)) return false;
|
|
985
|
-
const changed = [.../* @__PURE__ */ new Set([
|
|
986
|
-
MAIN_ROOT_KEY,
|
|
987
|
-
...Object.keys(after.roots ?? {}),
|
|
988
|
-
...Object.keys(before.roots ?? {})
|
|
989
|
-
])].filter((root) => !jsonEqual(valueRoot(after, root), valueRoot(before, root)));
|
|
990
|
-
if (changed.length !== 1) return false;
|
|
991
|
-
const [root] = changed;
|
|
992
|
-
const equalFrom = (left, right, from, shift) => left.length - from === right.length - from - shift && left.slice(from).every((node, index) => jsonEqual(node, right[from + shift + index]));
|
|
993
|
-
let left = valueRoot(after, root);
|
|
994
|
-
let right = valueRoot(before, root);
|
|
995
|
-
while (true) {
|
|
996
|
-
let at = 0;
|
|
997
|
-
while (at < left.length && jsonEqual(left[at], right[at])) at += 1;
|
|
998
|
-
const element = left[at];
|
|
999
|
-
const other = right[at];
|
|
1000
|
-
if (!element || !isElementNode(element)) return false;
|
|
1001
|
-
const held = element.children.length;
|
|
1002
|
-
if (jsonEqual(nodeProps(element), props) && element.children.every((child, index) => jsonEqual(child, right[at + index])) && equalFrom(left, right, at + 1, held - 1)) return true;
|
|
1003
|
-
if (!other || !isElementNode(other) || !jsonEqual(nodeProps(element), nodeProps(other)) || !equalFrom(left, right, at + 1, 0)) return false;
|
|
1004
|
-
left = element.children;
|
|
1005
|
-
right = other.children;
|
|
1006
|
-
}
|
|
1007
|
-
};
|
|
1008
|
-
const keepsOnlyWrap = (current, head, kept) => {
|
|
1009
|
-
try {
|
|
1010
|
-
return unwrapsTo(kept.branch.replay.change.apply(current), head.replay.change.apply(current), kept.wrap.props);
|
|
1011
|
-
} catch {
|
|
1012
|
-
return false;
|
|
1013
|
-
}
|
|
1014
|
-
};
|
|
1015
|
-
const attachKeptHistoryRedo = (editor, request) => {
|
|
1016
|
-
const state = getStore(editor);
|
|
1017
|
-
const head = state.redos;
|
|
1018
|
-
const kept = head?.kept;
|
|
1019
|
-
if (!head || !kept) return null;
|
|
1020
|
-
if (kept.kind === "wrap" && (head.next || !keepsOnlyWrap(getEditorDocumentValue(editor), head, kept))) {
|
|
1021
|
-
setStore(editor, Object.freeze({
|
|
1022
|
-
...state,
|
|
1023
|
-
redos: Object.freeze({
|
|
1024
|
-
...head,
|
|
1025
|
-
kept: null
|
|
1026
|
-
})
|
|
1027
|
-
}));
|
|
1028
|
-
return null;
|
|
1029
|
-
}
|
|
1030
|
-
const causes = DROPPED_HISTORY_CAUSES.get(editor)?.length ?? 0;
|
|
1031
|
-
KEPT_REDO_ATTEMPTS.set(request, {
|
|
1032
|
-
attempt: kept.kind === "fallback" ? Object.freeze({
|
|
1033
|
-
...head,
|
|
1034
|
-
kept: null
|
|
1035
|
-
}) : kept.branch,
|
|
1036
|
-
drops: NO_DROPS
|
|
1037
|
-
});
|
|
1038
|
-
return {
|
|
1039
|
-
detach: () => {
|
|
1040
|
-
KEPT_REDO_ATTEMPTS.delete(request);
|
|
1041
|
-
},
|
|
1042
|
-
fallBack: () => {
|
|
1043
|
-
DROPPED_HISTORY_CAUSES.get(editor)?.splice(causes);
|
|
1044
|
-
const waiting = getStore(editor).redos;
|
|
1045
|
-
const drops = [];
|
|
1046
|
-
const plain = waiting?.identity === head.identity && plainFallback(editor, drops, waiting);
|
|
1047
|
-
if (plain) KEPT_REDO_ATTEMPTS.set(request, {
|
|
1048
|
-
attempt: plain,
|
|
1049
|
-
drops
|
|
1050
|
-
});
|
|
1051
|
-
return () => {
|
|
1052
|
-
KEPT_REDO_ATTEMPTS.delete(request);
|
|
1053
|
-
};
|
|
1054
|
-
}
|
|
1055
|
-
};
|
|
1056
|
-
};
|
|
1057
|
-
const writeHistory = (editor, stack, batchValue, current, options = {}) => {
|
|
1058
|
-
const store = getStore(editor);
|
|
1059
|
-
const identity = {};
|
|
1060
|
-
publish(editor, store, {
|
|
1061
|
-
[stack]: pushBranch(store[stack], batchValue, current, recordHistoryReplay(historyReplaySchemaOf(editor), current, batchValue.change, stack === "undos" ? "undo" : "redo", {
|
|
1062
|
-
...replayedOf(batchValue),
|
|
1063
|
-
after: options.restores
|
|
1064
|
-
}), store.maxDepth, options.group ?? null, options.recovery ?? null, options.anchorCeiling ?? 0, identity, options.carets ?? null),
|
|
1065
|
-
...options.clearRedos ? { redos: null } : {}
|
|
1066
|
-
});
|
|
1067
|
-
return identity;
|
|
1068
|
-
};
|
|
1069
|
-
const replaceHistoryHead = (editor, stack, batchValue, current, options = {}) => {
|
|
1070
|
-
const store = getStore(editor);
|
|
1071
|
-
const drops = [];
|
|
1072
|
-
const resolved = resolveTop(editor, drops, store[stack]);
|
|
1073
|
-
if (!resolved) throw new Error(`Missing ${stack} history batch.`);
|
|
1074
|
-
publish(editor, withDrops(store, drops), {
|
|
1075
|
-
[stack]: branch(batchValue, current, recordHistoryReplay(historyReplaySchemaOf(editor), current, batchValue.change, stack === "undos" ? "undo" : "redo", {
|
|
1076
|
-
...replayedOf(batchValue),
|
|
1077
|
-
after: options.restores
|
|
1078
|
-
}), resolved.next, null, options.group ?? null, options.recovery ?? null, options.anchorCeiling ?? resolved.anchorCeiling, resolved.identity, options.carets ?? null),
|
|
1079
|
-
...options.clearRedos ? { redos: null } : {}
|
|
1080
|
-
});
|
|
1081
|
-
};
|
|
1082
|
-
const resolveDownTo = (editor, drops, value, id) => {
|
|
1083
|
-
const above = [];
|
|
1084
|
-
const causes = [];
|
|
1085
|
-
let onto = null;
|
|
1086
|
-
for (let entry = value; entry;) {
|
|
1087
|
-
const attemptDrops = [];
|
|
1088
|
-
let current = null;
|
|
1089
|
-
try {
|
|
1090
|
-
const top = resolveTop(editor, attemptDrops, entry);
|
|
1091
|
-
current = top && onto ? resolveTop(editor, attemptDrops, mappedOnto(editor, top, top.base, onto)) : top;
|
|
1092
|
-
} catch (error) {
|
|
1093
|
-
causes.push(error);
|
|
1094
|
-
onto = above.at(-1)?.replay.record().after ?? getEditorDocumentValue(editor);
|
|
1095
|
-
entry = entry.next;
|
|
1096
|
-
continue;
|
|
1097
|
-
}
|
|
1098
|
-
if (!current) break;
|
|
1099
|
-
drops.push(...attemptDrops);
|
|
1100
|
-
onto = null;
|
|
1101
|
-
if (STEP_IDS.get(current.identity) === id) return {
|
|
1102
|
-
above,
|
|
1103
|
-
causes,
|
|
1104
|
-
entry: resolvedEntryOf(current),
|
|
1105
|
-
tail: current.next
|
|
1106
|
-
};
|
|
1107
|
-
above.push(resolvedEntryOf(current));
|
|
1108
|
-
entry = current.next;
|
|
1109
|
-
}
|
|
1110
|
-
return null;
|
|
1111
|
-
};
|
|
1112
|
-
const replaceUndoStep = (editor, id, change, matches) => {
|
|
1113
|
-
const store = getStore(editor);
|
|
1114
|
-
if (store.pendingReplay) return false;
|
|
1115
|
-
const drops = [];
|
|
1116
|
-
const found = resolveDownTo(editor, drops, store.undos, id);
|
|
1117
|
-
if (!found || !matches(found.entry.base)) return false;
|
|
1118
|
-
const { above, entry, tail } = found;
|
|
1119
|
-
const { carried: _carried, rest: _rest, unsettle: _unsettle, ...plain } = entry.batch;
|
|
1120
|
-
const replay = recordHistoryReplay(historyReplaySchemaOf(editor), entry.base, change, "undo");
|
|
1121
|
-
publish(editor, withDrops(store, drops), { undos: rebuildBranch([...above, {
|
|
1122
|
-
...entry,
|
|
1123
|
-
batch: {
|
|
1124
|
-
...plain,
|
|
1125
|
-
change
|
|
1126
|
-
},
|
|
1127
|
-
kept: null,
|
|
1128
|
-
replay
|
|
1129
|
-
}], store.maxDepth, mappedOnto(editor, tail, entry.replay.record().after, replay.record().after)) });
|
|
1130
|
-
for (const cause of found.causes) recordDroppedCause(editor, cause);
|
|
1131
|
-
return true;
|
|
1132
|
-
};
|
|
1133
|
-
const forgetHistoryStep = (editor, id) => {
|
|
1134
|
-
const store = getStore(editor);
|
|
1135
|
-
if (store.pendingReplay) return false;
|
|
1136
|
-
for (const stack of ["undos", "redos"]) {
|
|
1137
|
-
const drops = [];
|
|
1138
|
-
const found = resolveDownTo(editor, drops, store[stack], id);
|
|
1139
|
-
if (!found) continue;
|
|
1140
|
-
const { above, entry, tail } = found;
|
|
1141
|
-
const below = above.length === 0 ? tail : mappedOnto(editor, tail, entry.replay.record().after, entry.base);
|
|
1142
|
-
const remaining = rebaseOnto(editor, drops, rebuildBranch(above, store.maxDepth, below), getEditorDocumentValue(editor));
|
|
1143
|
-
publish(editor, withDrops(store, drops), { [stack]: remaining });
|
|
1144
|
-
for (const cause of found.causes) recordDroppedCause(editor, cause);
|
|
1145
|
-
return true;
|
|
1146
|
-
}
|
|
1147
|
-
return false;
|
|
1148
|
-
};
|
|
1149
|
-
const DROPPED_HISTORY_CAUSES = /* @__PURE__ */ new WeakMap();
|
|
1150
|
-
const recordDroppedCause = (editor, cause) => {
|
|
1151
|
-
const causes = DROPPED_HISTORY_CAUSES.get(editor) ?? [];
|
|
1152
|
-
causes.push(cause);
|
|
1153
|
-
DROPPED_HISTORY_CAUSES.set(editor, causes);
|
|
1154
|
-
countCoreWork("carriedFallbacks");
|
|
1155
|
-
};
|
|
1156
|
-
const takeDroppedHistoryCauses = (editor) => {
|
|
1157
|
-
const causes = DROPPED_HISTORY_CAUSES.get(editor) ?? [];
|
|
1158
|
-
DROPPED_HISTORY_CAUSES.delete(editor);
|
|
1159
|
-
return causes;
|
|
1160
|
-
};
|
|
1161
|
-
const resolveSurvivingTop = (editor, drops, value) => {
|
|
1162
|
-
for (let entry = value; entry; entry = entry.next) {
|
|
1163
|
-
const attemptDrops = [];
|
|
1164
|
-
try {
|
|
1165
|
-
const head = resolveTop(editor, attemptDrops, entry);
|
|
1166
|
-
drops.push(...attemptDrops);
|
|
1167
|
-
return head;
|
|
1168
|
-
} catch (error) {
|
|
1169
|
-
recordDroppedCause(editor, error);
|
|
1170
|
-
}
|
|
1171
|
-
}
|
|
1172
|
-
return null;
|
|
1173
|
-
};
|
|
1174
|
-
const mappedOnto = (editor, value, from, to) => {
|
|
1175
|
-
if (!value) return null;
|
|
1176
|
-
const change = DocumentChange.between(from, to, { isSetValued: historyReplaySchemaOf(editor).isSetValued });
|
|
1177
|
-
return change.empty ? value : addMapping(value, {
|
|
1178
|
-
after: to,
|
|
1179
|
-
change,
|
|
1180
|
-
textOnly: isTextOnlyMapping(change)
|
|
1181
|
-
});
|
|
1182
|
-
};
|
|
1183
|
-
const rebaseOnto = (editor, drops, value, current) => {
|
|
1184
|
-
const head = resolveSurvivingTop(editor, drops, value);
|
|
1185
|
-
return head && mappedOnto(editor, head, head.base, current);
|
|
1186
|
-
};
|
|
1187
|
-
const dropHistoryHead = (editor, stack, current) => {
|
|
1188
|
-
const store = getStore(editor);
|
|
1189
|
-
const value = store[stack];
|
|
1190
|
-
if (!value) return;
|
|
1191
|
-
const drops = [];
|
|
1192
|
-
const result = rebaseOnto(editor, drops, value.next, current);
|
|
1193
|
-
publish(editor, withDrops(store, drops), { [stack]: result });
|
|
1194
|
-
};
|
|
1195
|
-
const completeHistoryAction = (editor, source, destination, batchValue, current, olderStepsMapping, request) => {
|
|
1196
|
-
const store = getStore(editor);
|
|
1197
|
-
const kept = keptAttempt(source, request);
|
|
1198
|
-
const drops = [...kept?.drops ?? []];
|
|
1199
|
-
const resolved = resolveTop(editor, drops, kept ? kept.attempt : store[source]);
|
|
1200
|
-
KEPT_REDO_ATTEMPTS.delete(request);
|
|
1201
|
-
if (!resolved) throw new Error(`Missing ${source} history batch.`);
|
|
1202
|
-
const nextSource = rebaseOnto(editor, drops, resolved.next, current);
|
|
1203
|
-
const older = olderStepsMapping ? addMapping(store[destination], {
|
|
1204
|
-
...olderStepsMapping,
|
|
1205
|
-
textOnly: false
|
|
1206
|
-
}) : store[destination];
|
|
1207
|
-
publish(editor, withDrops(store, drops), {
|
|
1208
|
-
[destination]: batchValue.change.empty && batchValue.effects.length === 0 ? older : pushBranch(older, batchValue, current, recordHistoryReplay(historyReplaySchemaOf(editor), current, batchValue.change, destination === "undos" ? "undo" : "redo", replayedOf(batchValue)), store.maxDepth, resolved.group, resolved.recovery, resolved.anchorCeiling, resolved.identity, resolved.carets),
|
|
1209
|
-
[source]: nextSource
|
|
1210
|
-
});
|
|
1211
|
-
};
|
|
1212
|
-
const isTextOnlyMapping = (change) => {
|
|
1213
|
-
const classifications = [...getInternalDocumentChangeClassificationEntries(change)];
|
|
1214
|
-
return change.createRoots.size === 0 && change.deleteRoots.size === 0 && getInternalDocumentChangeRootKeys(change).length > 0 && classifications.length > 0 && classifications.every(([, classification]) => classification.text && !classification.properties && !classification.structure);
|
|
1215
|
-
};
|
|
1216
|
-
const ELEMENT_SCHEMAS = /* @__PURE__ */ new WeakMap();
|
|
1217
|
-
const historyElementSchemaOf = (editor) => {
|
|
1218
|
-
const read = getEditorSchema(editor);
|
|
1219
|
-
const known = ELEMENT_SCHEMAS.get(read);
|
|
1220
|
-
if (known) return known;
|
|
1221
|
-
const owner = getEditorRuntimeOwner(editor);
|
|
1222
|
-
const contentOf = (element) => typeof element.type === "string" ? read.getElementContent(element.type) : null;
|
|
1223
|
-
const schema = {
|
|
1224
|
-
content: (element) => contentOf(element) ?? "unknown",
|
|
1225
|
-
isInline: (element) => ElementApi.isElement(element) && read.isInline(element),
|
|
1226
|
-
ownsContentRoot: (element) => typeof element.type === "string" && (getCompiledEditorSchema(owner).elements.byType.get(element.type)?.contentRoots.size ?? 0) > 0,
|
|
1227
|
-
propertiesReadParents: () => propertyTargetsReadParents(getCompiledEditorSchema(owner)),
|
|
1228
|
-
rootContent: (document, root) => read.getRootContent(root, document) ?? "unknown"
|
|
1229
|
-
};
|
|
1230
|
-
ELEMENT_SCHEMAS.set(read, schema);
|
|
1231
|
-
return schema;
|
|
1232
|
-
};
|
|
1233
|
-
const holdsCarry = (facts) => facts.kind === "recorded" && [...facts.roots.values()].some(({ carries }) => carries.length > 0);
|
|
1234
|
-
const waitsOnNothing = ({ batch, kept, mappings, replay }) => !mappings && !kept && !replay.program && !replay.carried && !replay.parts && !replay.exact && !batch.unsettle;
|
|
1235
|
-
const crossesEveryStep = (value, schema) => {
|
|
1236
|
-
for (let entry = value; entry; entry = entry.next) {
|
|
1237
|
-
const facts = HISTORY_FACTS.get(entry.batch);
|
|
1238
|
-
if (!facts || !waitsOnNothing(entry) || stepRejection(entry.base, {
|
|
1239
|
-
change: entry.replay.change,
|
|
1240
|
-
facts
|
|
1241
|
-
}, schema) !== null) return false;
|
|
1242
|
-
}
|
|
1243
|
-
return true;
|
|
1244
|
-
};
|
|
1245
|
-
const admits = (editor, store, skipped, before) => {
|
|
1246
|
-
if (!holdsCarry(skipped.facts) || store.pendingReplay) return false;
|
|
1247
|
-
const schema = historyElementSchemaOf(editor);
|
|
1248
|
-
return skippedRejection(before, skipped, schema) === null && crossesEveryStep(store.undos, schema) && crossesEveryStep(store.redos, schema);
|
|
1249
|
-
};
|
|
1250
|
-
const queueHistoryMapping = (editor, change, after, skipped) => {
|
|
1251
|
-
if (change.empty) return;
|
|
1252
|
-
const store = getStore(editor);
|
|
1253
|
-
const crosses = admits(editor, store, {
|
|
1254
|
-
change,
|
|
1255
|
-
facts: skipped.facts
|
|
1256
|
-
}, skipped.before);
|
|
1257
|
-
if (crosses) countCoreWork("admittedChanges");
|
|
1258
|
-
const mapping = Object.freeze({
|
|
1259
|
-
after,
|
|
1260
|
-
anchors: true,
|
|
1261
|
-
change,
|
|
1262
|
-
textOnly: isTextOnlyMapping(change),
|
|
1263
|
-
...crosses ? { crossing: skipped.facts } : {}
|
|
1264
|
-
});
|
|
1265
|
-
publish(editor, store, {
|
|
1266
|
-
redos: addMapping(store.redos, mapping),
|
|
1267
|
-
undos: addMapping(store.undos, mapping)
|
|
1268
|
-
});
|
|
1269
|
-
};
|
|
1270
|
-
const clearHistoryState = (editor) => {
|
|
1271
|
-
HISTORY.delete(getEditorRuntimeOwner(editor));
|
|
1272
|
-
};
|
|
1273
|
-
const replaceHistoryState = (editor, value, current = editor.read.value()) => {
|
|
1274
|
-
const store = getStore(editor);
|
|
1275
|
-
const next = Object.freeze({
|
|
1276
|
-
...store,
|
|
1277
|
-
redos: fromBatches(editor, "redo", value.redos, current, store.maxDepth),
|
|
1278
|
-
revision: store.revision + 1,
|
|
1279
|
-
schema: value.schema,
|
|
1280
|
-
snapshot: null,
|
|
1281
|
-
undos: fromBatches(editor, "undo", value.undos, current, store.maxDepth)
|
|
1282
|
-
});
|
|
1283
|
-
setStore(editor, next);
|
|
1284
|
-
return getWorkingHistory(editor);
|
|
1285
|
-
};
|
|
1286
|
-
//#endregion
|
|
1287
|
-
export { attachKeptHistoryRedo, beginHistoryReplay, captureHistoryState, clearHistoryState, completeHistoryAction, configureHistoryState, crossingDropCount, dropHistoryHead, dropPendingHistoryReplayEntry, forgetHistoryStep, freezeHistoryBatch, getHistory, getWorkingHistory, historyBatchStepId, historyElementSchemaOf, historyFactsOf, historyFallbackOf, historyProgramOf, historyStepId, knownHistoryStepId, markPendingHistoryReplayEdited, peekHistoryEntry, peekHistoryReplayEntry, peekJoinableUndoEntry, queueHistoryMapping, queuePendingHistoryReplayMapping, readPendingHistoryReplay, replaceHistoryHead, replaceHistoryState, replaceUndoStep, restoreHistoryState, settlePendingHistoryReplay, takeDroppedHistoryCauses, withHistoryFacts, withHistoryFallback, withHistoryProgram, withHistoryStateDraft, withHistoryStepId, withPublishedHistoryState, writeHistory };
|