plitejs 0.0.1 → 54.0.0-beta.2
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/LICENSE +4 -1
- package/README.md +83 -0
- package/dist/annotations/index.d.ts +2 -0
- package/dist/annotations/index.js +2 -0
- package/dist/annotations/store.d.ts +50 -0
- package/dist/annotations/store.js +244 -0
- package/dist/authored/authored.d.ts +116 -0
- package/dist/authored/authored.js +1271 -0
- package/dist/authored/changes.js +365 -0
- package/dist/authored/comparison.d.ts +41 -0
- package/dist/authored/comparison.js +270 -0
- package/dist/authored/decision-window.js +42 -0
- package/dist/authored/decision.js +306 -0
- package/dist/authored/facts/admission.js +388 -0
- package/dist/authored/facts/compact.d.ts +2 -0
- package/dist/authored/facts/compact.js +91 -0
- package/dist/authored/facts/dependencies.d.ts +5 -0
- package/dist/authored/facts/dependencies.js +66 -0
- package/dist/authored/facts/editing.js +12 -0
- package/dist/authored/facts/facts.d.ts +8 -0
- package/dist/authored/facts/facts.js +535 -0
- package/dist/authored/facts/records.d.ts +28 -0
- package/dist/authored/facts/records.js +226 -0
- package/dist/authored/facts/settle.js +529 -0
- package/dist/authored/format.d.ts +34 -0
- package/dist/authored/format.js +175 -0
- package/dist/authored/index.d.ts +9 -0
- package/dist/authored/index.js +5 -0
- package/dist/authored/ledger/book.js +809 -0
- package/dist/authored/ledger/cards.js +223 -0
- package/dist/authored/ledger/ledger.js +830 -0
- package/dist/authored/ledger/level.js +1081 -0
- package/dist/authored/ledger/links.js +20 -0
- package/dist/authored/ledger/pairs.js +334 -0
- package/dist/authored/ledger/places.js +524 -0
- package/dist/authored/ledger/preview-lens.js +252 -0
- package/dist/authored/ledger/projection.js +163 -0
- package/dist/authored/ledger/roots.js +11 -0
- package/dist/authored/ledger/runs.js +480 -0
- package/dist/authored/ledger/slots.js +330 -0
- package/dist/authored/ledger/work.js +66 -0
- package/dist/authored/refusal.d.ts +33 -0
- package/dist/authored/refusal.js +188 -0
- package/dist/authored/resolve-schema.js +62 -0
- package/dist/authored/tree/alignment.js +456 -0
- package/dist/authored/tree/carried.js +205 -0
- package/dist/authored/tree/command-values.js +344 -0
- package/dist/authored/tree/cuts.js +320 -0
- package/dist/authored/tree/grid.js +49 -0
- package/dist/authored/tree/halves.js +120 -0
- package/dist/authored/tree/holders.js +345 -0
- package/dist/authored/tree/holds.js +135 -0
- package/dist/authored/tree/layers.d.ts +49 -0
- package/dist/authored/tree/layers.js +354 -0
- package/dist/authored/tree/marks.d.ts +136 -0
- package/dist/authored/tree/marks.js +263 -0
- package/dist/authored/tree/proposed.js +212 -0
- package/dist/authored/tree/readiness.js +545 -0
- package/dist/authored/tree/record-completion.js +423 -0
- package/dist/authored/tree/record.js +2908 -0
- package/dist/authored/tree/reserves.js +449 -0
- package/dist/authored/tree/resolve.d.ts +9 -0
- package/dist/authored/tree/resolve.js +1860 -0
- package/dist/authored/tree/shown.js +153 -0
- package/dist/authored/tree/spare-lines.js +119 -0
- package/dist/authored/tree/spares.js +61 -0
- package/dist/authored/types.d.ts +177 -0
- package/dist/core/anchor-state.d.ts +15 -0
- package/dist/core/anchor-state.js +792 -0
- package/dist/core/anchor.d.ts +34 -0
- package/dist/core/anchor.js +843 -0
- package/dist/core/authored-document-capability.d.ts +106 -0
- package/dist/core/authored-document-capability.js +6 -0
- package/dist/core/authored-runtime.d.ts +10 -0
- package/dist/core/authored-runtime.js +67 -0
- package/dist/core/authored-veto.d.ts +30 -0
- package/dist/core/authored-veto.js +6 -0
- package/dist/core/change/builder.d.ts +546 -0
- package/dist/core/change/builder.js +1120 -0
- package/dist/core/change/carried-projection.js +1518 -0
- package/dist/core/change/carried-run.d.ts +26 -0
- package/dist/core/change/carried-run.js +251 -0
- package/dist/core/change/carry-program.js +537 -0
- package/dist/core/change/classification.d.ts +22 -0
- package/dist/core/change/classification.js +205 -0
- package/dist/core/change/cross-rule.js +238 -0
- package/dist/core/change/cross.js +577 -0
- package/dist/core/change/document-change.d.ts +137 -0
- package/dist/core/change/document-change.js +872 -0
- package/dist/core/change/document-index.d.ts +117 -0
- package/dist/core/change/document-index.js +542 -0
- package/dist/core/change/draft-facts.js +323 -0
- package/dist/core/change/enclosure.d.ts +12 -0
- package/dist/core/change/enclosure.js +272 -0
- package/dist/core/change/join.js +751 -0
- package/dist/core/change/json.d.ts +4 -0
- package/dist/core/change/json.js +26 -0
- package/dist/core/change/lazy-root.d.ts +1 -0
- package/dist/core/change/lazy-root.js +73 -0
- package/dist/core/change/lineage.d.ts +49 -0
- package/dist/core/change/lineage.js +390 -0
- package/dist/core/change/mapping.d.ts +31 -0
- package/dist/core/change/mapping.js +186 -0
- package/dist/core/change/new-letters.d.ts +14 -0
- package/dist/core/change/new-letters.js +139 -0
- package/dist/core/change/range-association.js +10 -0
- package/dist/core/change/read-back.d.ts +7 -0
- package/dist/core/change/read-back.js +7 -0
- package/dist/core/change/record.d.ts +59 -0
- package/dist/core/change/record.js +346 -0
- package/dist/core/change/retraction.js +97 -0
- package/dist/core/change/root-change.d.ts +180 -0
- package/dist/core/change/root-change.js +3544 -0
- package/dist/core/change/slice-facts.js +89 -0
- package/dist/core/change/text-splices.js +98 -0
- package/dist/core/change/tokens.d.ts +97 -0
- package/dist/core/change/tokens.js +449 -0
- package/dist/core/change/transform.d.ts +36 -0
- package/dist/core/change/transform.js +97 -0
- package/dist/core/change/wrap-fidelity.js +295 -0
- package/dist/core/change-events.js +223 -0
- package/dist/core/clone.js +28 -0
- package/dist/core/command-definition.d.ts +25 -0
- package/dist/core/command-definition.js +48 -0
- package/dist/core/command-document.d.ts +4 -0
- package/dist/core/command-document.js +20 -0
- package/dist/core/command-frame.js +628 -0
- package/dist/core/command-registry.d.ts +36 -0
- package/dist/core/command-registry.js +283 -0
- package/dist/core/commit-publication.js +40 -0
- package/dist/core/commit.d.ts +26 -0
- package/dist/core/commit.js +686 -0
- package/dist/core/composition-stamp.d.ts +14 -0
- package/dist/core/composition-stamp.js +79 -0
- package/dist/core/content-completion.d.ts +4 -0
- package/dist/core/content-completion.js +343 -0
- package/dist/core/content-landing.js +124 -0
- package/dist/core/content-slice-roots.js +36 -0
- package/dist/core/content-slice.d.ts +38 -0
- package/dist/core/content-slice.js +253 -0
- package/dist/core/content.js +18 -0
- package/dist/core/correction.js +25 -0
- package/dist/core/default-storage.js +53 -0
- package/dist/core/document-admission.d.ts +4 -0
- package/dist/core/document-admission.js +64 -0
- package/dist/core/document-change.d.ts +3 -0
- package/dist/core/document-recorder.d.ts +6 -0
- package/dist/core/document-recorder.js +67 -0
- package/dist/core/document-shape.d.ts +68 -0
- package/dist/core/document-shape.js +173 -0
- package/dist/core/document-view-read.d.ts +16 -0
- package/dist/core/document-view-read.js +36 -0
- package/dist/core/draft-track.d.ts +3 -0
- package/dist/core/draft-track.js +90 -0
- package/dist/core/editor-commands.d.ts +99 -0
- package/dist/core/editor-commands.js +505 -0
- package/dist/core/editor-lifecycle-api.d.ts +8 -0
- package/dist/core/editor-lifecycle-api.js +219 -0
- package/dist/core/editor-lifetime.js +12 -0
- package/dist/core/editor-owner.d.ts +24 -0
- package/dist/core/editor-owner.js +78 -0
- package/dist/core/editor-read-execution.d.ts +6 -0
- package/dist/core/editor-read-execution.js +64 -0
- package/dist/core/editor-read-runtime.js +176 -0
- package/dist/core/editor-reads.d.ts +128 -0
- package/dist/core/editor-reads.js +63 -0
- package/dist/core/editor-runtime.d.ts +112 -0
- package/dist/core/editor-runtime.js +20 -0
- package/dist/core/editor-schema.d.ts +314 -0
- package/dist/core/editor-schema.js +2295 -0
- package/dist/core/editor-view-lifetime.js +23 -0
- package/dist/core/element-owned-root-index.d.ts +4 -0
- package/dist/core/element-owned-root-index.js +353 -0
- package/dist/core/get-content-slice.js +118 -0
- package/dist/core/get-fragment.js +22 -0
- package/dist/core/identity-owner.js +697 -0
- package/dist/core/import-content-slice.js +26 -0
- package/dist/core/initial-value.js +87 -0
- package/dist/core/insert-limit.js +81 -0
- package/dist/core/is-empty-element.js +20 -0
- package/dist/core/json-fingerprint.js +16 -0
- package/dist/core/landing.d.ts +11 -0
- package/dist/core/landing.js +279 -0
- package/dist/core/lifecycle-error.d.ts +11 -0
- package/dist/core/lifecycle-error.js +68 -0
- package/dist/core/listener-state.d.ts +1 -0
- package/dist/core/listener-state.js +59 -0
- package/dist/core/measured-sequence.d.ts +43 -0
- package/dist/core/measured-sequence.js +404 -0
- package/dist/core/missing-reference.js +15 -0
- package/dist/core/native-grouping-input.js +8 -0
- package/dist/core/node-property-mutation.js +10 -0
- package/dist/core/node-selection.js +85 -0
- package/dist/core/node-write-veto.d.ts +37 -0
- package/dist/core/node-write-veto.js +17 -0
- package/dist/core/persisted-document.d.ts +6 -0
- package/dist/core/persisted-document.js +39 -0
- package/dist/core/persistent-map.js +139 -0
- package/dist/core/plain-text.d.ts +32 -0
- package/dist/core/plain-text.js +92 -0
- package/dist/core/plugin-dispatch.d.ts +21 -0
- package/dist/core/plugin-dispatch.js +166 -0
- package/dist/core/plugin-point.d.ts +6 -0
- package/dist/core/plugin-point.js +21 -0
- package/dist/core/plugin-registry.d.ts +78 -0
- package/dist/core/plugin-registry.js +485 -0
- package/dist/core/plugin-slot.d.ts +23 -0
- package/dist/core/plugin-slot.js +30 -0
- package/dist/core/plugin.d.ts +125 -0
- package/dist/core/plugin.js +1485 -0
- package/dist/core/prefix-occupant-join.js +52 -0
- package/dist/core/profiling.js +18 -0
- package/dist/core/property-validity.d.ts +14 -0
- package/dist/core/property-validity.js +65 -0
- package/dist/core/public-root.d.ts +10 -0
- package/dist/core/public-root.js +50 -0
- package/dist/core/public-state.d.ts +191 -0
- package/dist/core/public-state.js +6772 -0
- package/dist/core/read-definition.js +22 -0
- package/dist/core/read-registry.js +127 -0
- package/dist/core/record-store.d.ts +12 -0
- package/dist/core/record-store.js +297 -0
- package/dist/core/refusal.d.ts +1 -0
- package/dist/core/refusal.js +40 -0
- package/dist/core/representation.d.ts +11 -0
- package/dist/core/representation.js +844 -0
- package/dist/core/resolved-token-cursor.d.ts +21 -0
- package/dist/core/resolved-token-cursor.js +294 -0
- package/dist/core/root-entries.js +121 -0
- package/dist/core/root-ownership.d.ts +19 -0
- package/dist/core/root-ownership.js +354 -0
- package/dist/core/root-target.d.ts +7 -0
- package/dist/core/root-target.js +281 -0
- package/dist/core/same-result.d.ts +18 -0
- package/dist/core/same-result.js +96 -0
- package/dist/core/schema-compiler.d.ts +345 -0
- package/dist/core/schema-compiler.js +3166 -0
- package/dist/core/schema-contribution-registry.d.ts +12 -0
- package/dist/core/schema-contribution-registry.js +88 -0
- package/dist/core/schema-definition.d.ts +307 -0
- package/dist/core/schema-definition.js +628 -0
- package/dist/core/schema-source.internal.d.ts +49 -0
- package/dist/core/schema-validation.d.ts +11 -0
- package/dist/core/schema-validation.js +85 -0
- package/dist/core/screen-reader-announcement.d.ts +13 -0
- package/dist/core/screen-reader-announcement.js +17 -0
- package/dist/core/selection-protocol.d.ts +38 -0
- package/dist/core/selection-protocol.js +523 -0
- package/dist/core/selection-state.js +9 -0
- package/dist/core/semantic-update-method.d.ts +11 -0
- package/dist/core/semantic-update-method.js +26 -0
- package/dist/core/set-root.d.ts +3 -0
- package/dist/core/set-root.js +244 -0
- package/dist/core/slice-end-matter.js +77 -0
- package/dist/core/slice-fit/compiled-slice-fitter.d.ts +56 -0
- package/dist/core/slice-fit/compiled-slice-fitter.js +2087 -0
- package/dist/core/slice-fit/fit-report.d.ts +36 -0
- package/dist/core/slice-fit/fit-report.js +122 -0
- package/dist/core/slice-fit/frontier.js +98 -0
- package/dist/core/slice-fit/origin.js +57 -0
- package/dist/core/slice-fit/provenance.d.ts +30 -0
- package/dist/core/slice-fit/provenance.js +245 -0
- package/dist/core/slice-identities.js +21 -0
- package/dist/core/slice-landing-types.d.ts +61 -0
- package/dist/core/slice-landing.js +124 -0
- package/dist/core/snapshot-index.d.ts +13 -0
- package/dist/core/snapshot-index.js +860 -0
- package/dist/core/state-field.d.ts +12 -0
- package/dist/core/state-field.js +102 -0
- package/dist/core/state-fields.js +36 -0
- package/dist/core/survival.js +61 -0
- package/dist/core/target-runtime.d.ts +5 -0
- package/dist/core/target-runtime.js +42 -0
- package/dist/core/transaction-values.d.ts +47 -0
- package/dist/core/transaction-values.js +66 -0
- package/dist/core/transfer-guard.js +299 -0
- package/dist/core/transfer-types.d.ts +170 -0
- package/dist/core/transfer.d.ts +72 -0
- package/dist/core/transfer.js +655 -0
- package/dist/core/tx-only.d.ts +64 -0
- package/dist/core/tx-only.js +84 -0
- package/dist/core/unique-values.js +298 -0
- package/dist/core/update-context.js +28 -0
- package/dist/core/update-policy.d.ts +17 -0
- package/dist/core/update-policy.js +45 -0
- package/dist/core/value-codec.d.ts +35 -0
- package/dist/core/value-codec.js +240 -0
- package/dist/core/view-carets.d.ts +39 -0
- package/dist/core/view-carets.js +676 -0
- package/dist/core/view-presentation.d.ts +9 -0
- package/dist/core/view-presentation.js +70 -0
- package/dist/core/work.d.ts +192 -0
- package/dist/core/work.js +122 -0
- package/dist/core/writable-text.js +37 -0
- package/dist/create-editor.d.ts +187 -0
- package/dist/create-editor.js +281 -0
- package/dist/diff/index.d.ts +4 -0
- package/dist/diff/index.js +2 -0
- package/dist/diff/lib/compare.d.ts +33 -0
- package/dist/diff/lib/compare.js +459 -0
- package/dist/diff/lib/comparison-align.js +324 -0
- package/dist/diff/lib/comparison-index.js +160 -0
- package/dist/diff/lib/comparison-internal.js +108 -0
- package/dist/diff/lib/comparison-matcher.js +1221 -0
- package/dist/diff/lib/comparison-moves.js +151 -0
- package/dist/diff/lib/comparison-plan.js +556 -0
- package/dist/diff/lib/comparison-types.d.ts +174 -0
- package/dist/diff/lib/index.d.ts +3 -0
- package/dist/dom/dom-soft-line-end.d.ts +3 -0
- package/dist/dom/dom-soft-line-end.js +295 -0
- package/dist/dom/index.d.ts +19 -0
- package/dist/dom/index.js +16 -0
- package/dist/dom/internal/index.d.ts +15 -0
- package/dist/dom/plugin/data-transfer-format.d.ts +90 -0
- package/dist/dom/plugin/data-transfer-format.js +525 -0
- package/dist/dom/plugin/dom-clipboard-runtime.d.ts +50 -0
- package/dist/dom/plugin/dom-clipboard-runtime.js +482 -0
- package/dist/dom/plugin/dom-coverage.d.ts +140 -0
- package/dist/dom/plugin/dom-coverage.js +443 -0
- package/dist/dom/plugin/dom-drag-scroll.js +176 -0
- package/dist/dom/plugin/dom-drag.d.ts +54 -0
- package/dist/dom/plugin/dom-drag.js +507 -0
- package/dist/dom/plugin/dom-editor.d.ts +421 -0
- package/dist/dom/plugin/dom-editor.js +1316 -0
- package/dist/dom/plugin/dom-event-range-targets.js +39 -0
- package/dist/dom/plugin/dom-geometry.d.ts +11 -0
- package/dist/dom/plugin/dom-geometry.js +888 -0
- package/dist/dom/plugin/dom-input-runtime.d.ts +1 -0
- package/dist/dom/plugin/dom-input-runtime.js +571 -0
- package/dist/dom/plugin/dom-integrity-observer.js +436 -0
- package/dist/dom/plugin/dom-node-path.js +61 -0
- package/dist/dom/plugin/dom-phase-scheduler.d.ts +1 -0
- package/dist/dom/plugin/dom-phase-scheduler.js +284 -0
- package/dist/dom/plugin/dom-root-runtime.d.ts +10 -0
- package/dist/dom/plugin/dom-root-runtime.js +716 -0
- package/dist/dom/plugin/dom-sync-mutation-ownership.d.ts +1 -0
- package/dist/dom/plugin/dom-sync-mutation-ownership.js +120 -0
- package/dist/dom/plugin/dom-text-flow-index.js +396 -0
- package/dist/dom/plugin/dom-text-freshness.js +188 -0
- package/dist/dom/plugin/dom-text-proofs.d.ts +2 -0
- package/dist/dom/plugin/dom-text-proofs.js +350 -0
- package/dist/dom/plugin/dom-view-caret.js +28 -0
- package/dist/dom/plugin/with-dom.d.ts +53 -0
- package/dist/dom/plugin/with-dom.js +101 -0
- package/dist/dom/utils/constants.d.ts +5 -0
- package/dist/dom/utils/constants.js +5 -0
- package/dist/dom/utils/diff-text.d.ts +51 -0
- package/dist/dom/utils/diff-text.js +264 -0
- package/dist/dom/utils/dom.d.ts +104 -0
- package/dist/dom/utils/dom.js +257 -0
- package/dist/dom/utils/drag-session.d.ts +2 -0
- package/dist/dom/utils/drag-session.js +115 -0
- package/dist/dom/utils/drop-indicator.d.ts +18 -0
- package/dist/dom/utils/drop-indicator.js +36 -0
- package/dist/dom/utils/environment.d.ts +12 -0
- package/dist/dom/utils/environment.js +118 -0
- package/dist/dom/utils/hotkey-match.d.ts +36 -0
- package/dist/dom/utils/hotkey-match.js +208 -0
- package/dist/dom/utils/hotkeys.d.ts +32 -0
- package/dist/dom/utils/hotkeys.js +121 -0
- package/dist/dom/utils/key.d.ts +14 -0
- package/dist/dom/utils/key.js +18 -0
- package/dist/dom/utils/plite-dom-markers.d.ts +26 -0
- package/dist/dom/utils/plite-dom-markers.js +25 -0
- package/dist/dom/utils/selection-writes.d.ts +18 -0
- package/dist/dom/utils/selection-writes.js +63 -0
- package/dist/dom/utils/weak-maps.d.ts +2 -0
- package/dist/dom/utils/weak-maps.js +51 -0
- package/dist/editor/above.js +30 -0
- package/dist/editor/add-mark.js +79 -0
- package/dist/editor/adjacent-character-point.js +120 -0
- package/dist/editor/after.js +37 -0
- package/dist/editor/before.js +124 -0
- package/dist/editor/block-void-break.js +20 -0
- package/dist/editor/correct-document.js +225 -0
- package/dist/editor/delete-backward.js +64 -0
- package/dist/editor/delete-forward.js +11 -0
- package/dist/editor/delete-fragment.js +40 -0
- package/dist/editor/edges.js +5 -0
- package/dist/editor/element-read-only.js +35 -0
- package/dist/editor/end.d.ts +7 -0
- package/dist/editor/end.js +5 -0
- package/dist/editor/exit-break.js +51 -0
- package/dist/editor/first.js +8 -0
- package/dist/editor/get-void.js +9 -0
- package/dist/editor/has-blocks.js +6 -0
- package/dist/editor/has-inlines.js +6 -0
- package/dist/editor/has-path.js +5 -0
- package/dist/editor/has-texts.js +5 -0
- package/dist/editor/insert-break.js +77 -0
- package/dist/editor/insert-default-child.js +55 -0
- package/dist/editor/insert-soft-break.js +14 -0
- package/dist/editor/insert-text.js +83 -0
- package/dist/editor/is-block.js +5 -0
- package/dist/editor/is-edge.js +5 -0
- package/dist/editor/is-editor.js +13 -0
- package/dist/editor/is-empty.js +6 -0
- package/dist/editor/is-end.js +9 -0
- package/dist/editor/is-start.js +9 -0
- package/dist/editor/last.js +20 -0
- package/dist/editor/leaf.js +9 -0
- package/dist/editor/levels.js +21 -0
- package/dist/editor/next.js +46 -0
- package/dist/editor/node.js +9 -0
- package/dist/editor/nodes.js +106 -0
- package/dist/editor/parent.js +14 -0
- package/dist/editor/path.js +26 -0
- package/dist/editor/point.js +52 -0
- package/dist/editor/positions.js +322 -0
- package/dist/editor/previous.js +48 -0
- package/dist/editor/project-range.js +6 -0
- package/dist/editor/range.js +12 -0
- package/dist/editor/remove-mark.js +65 -0
- package/dist/editor/should-merge-nodes-remove-prev-node.js +11 -0
- package/dist/editor/string.js +35 -0
- package/dist/editor/toggle-mark.js +71 -0
- package/dist/editor/unhang-range.js +71 -0
- package/dist/editor-runtime-view.d.ts +33 -0
- package/dist/editor-runtime-view.js +788 -0
- package/dist/history/history-carets.js +127 -0
- package/dist/history/history-character-map.js +425 -0
- package/dist/history/history-codec.js +176 -0
- package/dist/history/history-merge-policy.js +164 -0
- package/dist/history/history-plugin.d.ts +71 -0
- package/dist/history/history-plugin.js +814 -0
- package/dist/history/history-replay.js +799 -0
- package/dist/history/history-selection.js +75 -0
- package/dist/history/history-state.js +1287 -0
- package/dist/history/history.d.ts +112 -0
- package/dist/history/history.js +29 -0
- package/dist/history/index.d.ts +4 -0
- package/dist/history/index.js +3 -0
- package/dist/hyperscript/creators.d.ts +51 -0
- package/dist/hyperscript/creators.js +173 -0
- package/dist/hyperscript/hyperscript.d.ts +36 -0
- package/dist/hyperscript/hyperscript.js +66 -0
- package/dist/hyperscript/index.d.ts +20 -0
- package/dist/hyperscript/index.js +9 -0
- package/dist/hyperscript/tokens.d.ts +31 -0
- package/dist/hyperscript/tokens.js +63 -0
- package/dist/index.d.ts +51 -0
- package/dist/index.js +35 -0
- package/dist/interfaces/decoration.d.ts +35 -0
- package/dist/interfaces/editor.d.ts +2783 -0
- package/dist/interfaces/editor.js +348 -0
- package/dist/interfaces/element.d.ts +66 -0
- package/dist/interfaces/element.js +34 -0
- package/dist/interfaces/index.d.ts +13 -0
- package/dist/interfaces/json.d.ts +7 -0
- package/dist/interfaces/location.d.ts +50 -0
- package/dist/interfaces/location.js +26 -0
- package/dist/interfaces/node.d.ts +306 -0
- package/dist/interfaces/node.js +339 -0
- package/dist/interfaces/path.d.ts +118 -0
- package/dist/interfaces/path.js +116 -0
- package/dist/interfaces/point.d.ts +45 -0
- package/dist/interfaces/point.js +32 -0
- package/dist/interfaces/range.d.ts +80 -0
- package/dist/interfaces/range.js +85 -0
- package/dist/interfaces/schema-validation.d.ts +33 -0
- package/dist/interfaces/schema.d.ts +870 -0
- package/dist/interfaces/selection.d.ts +61 -0
- package/dist/interfaces/selection.js +106 -0
- package/dist/interfaces/text.d.ts +68 -0
- package/dist/interfaces/text.js +52 -0
- package/dist/interfaces/transforms/node.d.ts +222 -0
- package/dist/interfaces/transforms/selection.d.ts +48 -0
- package/dist/interfaces/transforms/text.d.ts +58 -0
- package/dist/internal/browser-protocol.d.ts +5 -0
- package/dist/internal/browser-protocol.js +5 -0
- package/dist/internal/document-range.d.ts +9 -0
- package/dist/internal/document-range.js +31 -0
- package/dist/internal/editor-options.d.ts +37 -0
- package/dist/internal/editor-options.js +36 -0
- package/dist/internal/fail-invariant.d.ts +4 -0
- package/dist/internal/fail-invariant.js +6 -0
- package/dist/internal/get-defined.js +7 -0
- package/dist/internal/index.d.ts +54 -0
- package/dist/internal/index.js +52 -0
- package/dist/internal/law-check.js +7 -0
- package/dist/internal/range-text-marks.js +31 -0
- package/dist/internal/root-location.d.ts +23 -0
- package/dist/internal/root-location.js +86 -0
- package/dist/internal/text-run.d.ts +13 -0
- package/dist/internal/text-run.js +44 -0
- package/dist/internal/view/annotation-store-metrics.d.ts +11 -0
- package/dist/internal/view/annotation-store-metrics.js +12 -0
- package/dist/internal/view/mapped-view-store.js +121 -0
- package/dist/internal/view/stable-id-mapped-source.js +467 -0
- package/dist/internal/view/view-source.d.ts +20 -0
- package/dist/pagination/index.d.ts +175 -0
- package/dist/pagination/index.js +694 -0
- package/dist/pagination/page-composition.internal.js +313 -0
- package/dist/pagination/page-geometry.internal.js +99 -0
- package/dist/pagination/page-layout-engine-invalidation.internal.js +20 -0
- package/dist/pagination/page-mount-plan.js +84 -0
- package/dist/pagination/paged-view-lines.js +163 -0
- package/dist/pagination/react.d.ts +35 -0
- package/dist/pagination/react.js +1103 -0
- package/dist/range-projection.d.ts +7 -0
- package/dist/range-projection.js +50 -0
- package/dist/react/components/dom-coverage-boundary.d.ts +14 -0
- package/dist/react/components/dom-coverage-boundary.js +143 -0
- package/dist/react/components/editable-descendant-binding.js +70 -0
- package/dist/react/components/editable-dom-commit-fence.js +107 -0
- package/dist/react/components/editable-element-placement.d.ts +2 -0
- package/dist/react/components/editable-element-placement.js +117 -0
- package/dist/react/components/editable-external-text.js +47 -0
- package/dist/react/components/editable-node-equality.js +25 -0
- package/dist/react/components/editable-rendered-element.d.ts +3 -0
- package/dist/react/components/editable-rendered-element.js +61 -0
- package/dist/react/components/editable-text-blocks.d.ts +192 -0
- package/dist/react/components/editable-text-blocks.js +896 -0
- package/dist/react/components/editable-text-containers.d.ts +3 -0
- package/dist/react/components/editable-text-containers.js +28 -0
- package/dist/react/components/editable-text-flow.js +1039 -0
- package/dist/react/components/editable-text-pieces.d.ts +7 -0
- package/dist/react/components/editable-text-pieces.js +193 -0
- package/dist/react/components/editable-text.d.ts +80 -0
- package/dist/react/components/editable-text.js +322 -0
- package/dist/react/components/editable.d.ts +35 -0
- package/dist/react/components/editable.js +406 -0
- package/dist/react/components/editor-announcement-live-region.js +113 -0
- package/dist/react/components/plite-element.d.ts +18 -0
- package/dist/react/components/plite-element.js +54 -0
- package/dist/react/components/plite-leaf.d.ts +18 -0
- package/dist/react/components/plite-leaf.js +21 -0
- package/dist/react/components/plite-placeholder.d.ts +19 -0
- package/dist/react/components/plite-placeholder.js +39 -0
- package/dist/react/components/plite-spacer.js +14 -0
- package/dist/react/components/plite-text.d.ts +23 -0
- package/dist/react/components/plite-text.js +32 -0
- package/dist/react/components/plite-void-shell.js +49 -0
- package/dist/react/components/plite.d.ts +45 -0
- package/dist/react/components/plite.js +297 -0
- package/dist/react/components/text-string.js +18 -0
- package/dist/react/components/windowed-editable.internal.js +51 -0
- package/dist/react/components/zero-width-string.js +26 -0
- package/dist/react/context.js +11 -0
- package/dist/react/decoration-context.d.ts +2 -0
- package/dist/react/decoration-context.js +22 -0
- package/dist/react/decoration-source.d.ts +11 -0
- package/dist/react/decoration-source.js +1030 -0
- package/dist/react/dom-text-sync.d.ts +24 -0
- package/dist/react/dom-text-sync.js +48 -0
- package/dist/react/editable/android-composition.d.ts +3 -0
- package/dist/react/editable/android-composition.js +496 -0
- package/dist/react/editable/browser-handle.js +515 -0
- package/dist/react/editable/caret-engine.js +681 -0
- package/dist/react/editable/clipboard-input-strategy.js +632 -0
- package/dist/react/editable/composition-lease.d.ts +3 -0
- package/dist/react/editable/composition-lease.js +350 -0
- package/dist/react/editable/composition-state.js +716 -0
- package/dist/react/editable/content-root-boundaries.js +79 -0
- package/dist/react/editable/content-root-coordinate-navigation.js +28 -0
- package/dist/react/editable/content-root-navigation-actions.js +190 -0
- package/dist/react/editable/content-root-navigation.js +819 -0
- package/dist/react/editable/content-root-owner-target.js +36 -0
- package/dist/react/editable/content-root-owners.js +191 -0
- package/dist/react/editable/content-root-vertical-geometry.js +60 -0
- package/dist/react/editable/decoration-repair-bridge.js +29 -0
- package/dist/react/editable/dom-coverage-selection.js +158 -0
- package/dist/react/editable/dom-coverage-vertical-selection.js +446 -0
- package/dist/react/editable/dom-input-event.js +14 -0
- package/dist/react/editable/dom-repair-queue.d.ts +7 -0
- package/dist/react/editable/dom-repair-queue.js +543 -0
- package/dist/react/editable/dom-repair-text.js +47 -0
- package/dist/react/editable/editable-command-types.d.ts +1 -0
- package/dist/react/editable/editable-dom-runtime.d.ts +66 -0
- package/dist/react/editable/editable-dom-runtime.js +1022 -0
- package/dist/react/editable/editing-epoch-adapter.js +46 -0
- package/dist/react/editable/editing-kernel.d.ts +7 -0
- package/dist/react/editable/editing-kernel.js +593 -0
- package/dist/react/editable/external-text-binding.js +43 -0
- package/dist/react/editable/external-text-runtime.d.ts +5 -0
- package/dist/react/editable/external-text-runtime.js +851 -0
- package/dist/react/editable/history-focus.js +71 -0
- package/dist/react/editable/history-keyboard.d.ts +4 -0
- package/dist/react/editable/history-keyboard.js +9 -0
- package/dist/react/editable/input-controller.d.ts +7 -0
- package/dist/react/editable/input-controller.js +175 -0
- package/dist/react/editable/input-history.js +21 -0
- package/dist/react/editable/input-router.js +742 -0
- package/dist/react/editable/input-state.d.ts +18 -0
- package/dist/react/editable/input-state.js +330 -0
- package/dist/react/editable/input-target.js +30 -0
- package/dist/react/editable/install-browser-handle.d.ts +12 -0
- package/dist/react/editable/install-browser-handle.js +18 -0
- package/dist/react/editable/interaction-owner.js +88 -0
- package/dist/react/editable/keyboard-input-strategy.js +730 -0
- package/dist/react/editable/line-boundary.js +37 -0
- package/dist/react/editable/model-input-strategy.d.ts +9 -0
- package/dist/react/editable/model-input-strategy.js +242 -0
- package/dist/react/editable/model-selection-dom-preference.js +11 -0
- package/dist/react/editable/mutation-block-editing.js +48 -0
- package/dist/react/editable/mutation-controller.d.ts +32 -0
- package/dist/react/editable/mutation-controller.js +632 -0
- package/dist/react/editable/mutation-full-block-editing.d.ts +2 -0
- package/dist/react/editable/mutation-full-block-editing.js +44 -0
- package/dist/react/editable/mutation-history.d.ts +3 -0
- package/dist/react/editable/mutation-history.js +146 -0
- package/dist/react/editable/native-input-strategy.js +86 -0
- package/dist/react/editable/native-text-input-delta.js +40 -0
- package/dist/react/editable/placed-drag.js +177 -0
- package/dist/react/editable/plite-string-coordinate-placement.js +46 -0
- package/dist/react/editable/press-fence.d.ts +2 -0
- package/dist/react/editable/press-fence.js +70 -0
- package/dist/react/editable/projected-clipboard.js +123 -0
- package/dist/react/editable/projected-native-affordance.js +30 -0
- package/dist/react/editable/projected-selection-target.js +13 -0
- package/dist/react/editable/render-contract-monitor.d.ts +3 -0
- package/dist/react/editable/render-contract-monitor.js +152 -0
- package/dist/react/editable/root-interaction-controller.js +1400 -0
- package/dist/react/editable/root-interaction-dom-selection-replay.js +40 -0
- package/dist/react/editable/root-interaction-resolver.js +116 -0
- package/dist/react/editable/root-selector-sources.js +90 -0
- package/dist/react/editable/runtime-android-engine.js +40 -0
- package/dist/react/editable/runtime-before-input-events.js +671 -0
- package/dist/react/editable/runtime-browser-handle-events.js +40 -0
- package/dist/react/editable/runtime-clipboard-events.js +169 -0
- package/dist/react/editable/runtime-composition-events.js +163 -0
- package/dist/react/editable/runtime-drag-events.js +136 -0
- package/dist/react/editable/runtime-editor-api.d.ts +20 -0
- package/dist/react/editable/runtime-editor-api.js +21 -0
- package/dist/react/editable/runtime-event-engine.js +213 -0
- package/dist/react/editable/runtime-focus-mouse-events.js +264 -0
- package/dist/react/editable/runtime-input-events.js +166 -0
- package/dist/react/editable/runtime-kernel-trace.js +185 -0
- package/dist/react/editable/runtime-keyboard-events.js +333 -0
- package/dist/react/editable/runtime-live-state.js +44 -0
- package/dist/react/editable/runtime-mutation-state.js +11 -0
- package/dist/react/editable/runtime-repair-engine.js +118 -0
- package/dist/react/editable/runtime-root-engine.js +244 -0
- package/dist/react/editable/runtime-root-lifecycle.js +118 -0
- package/dist/react/editable/runtime-root-selection-export.js +38 -0
- package/dist/react/editable/runtime-root-selection-import.js +54 -0
- package/dist/react/editable/runtime-root-state.js +62 -0
- package/dist/react/editable/runtime-selection-engine.js +260 -0
- package/dist/react/editable/runtime-selection-state.js +12 -0
- package/dist/react/editable/runtime-target-bridge.js +29 -0
- package/dist/react/editable/schema-runtime-invalidation.js +26 -0
- package/dist/react/editable/selection-change-listener.js +99 -0
- package/dist/react/editable/selection-claim.d.ts +3 -0
- package/dist/react/editable/selection-claim.js +398 -0
- package/dist/react/editable/selection-controller.d.ts +8 -0
- package/dist/react/editable/selection-controller.js +693 -0
- package/dist/react/editable/selection-dom-range.js +84 -0
- package/dist/react/editable/selection-projected-dom.js +156 -0
- package/dist/react/editable/selection-reconciler.js +630 -0
- package/dist/react/editable/selection-runtime.js +89 -0
- package/dist/react/editable/selection-side-effect-policy.js +20 -0
- package/dist/react/editable/selection-triple-click.js +48 -0
- package/dist/react/editable/selection-void-target.js +172 -0
- package/dist/react/editable/set-root-endpoints.js +75 -0
- package/dist/react/editable/soft-line-end-delete.js +106 -0
- package/dist/react/editable/text-direction.js +82 -0
- package/dist/react/editable/typed-text.d.ts +17 -0
- package/dist/react/editable/typed-text.js +89 -0
- package/dist/react/editable/unread-press.d.ts +2 -0
- package/dist/react/editable/unread-press.js +86 -0
- package/dist/react/editable/view-caret-restore.js +128 -0
- package/dist/react/editable/view-lines.d.ts +7 -0
- package/dist/react/editable/view-lines.js +166 -0
- package/dist/react/external-text.d.ts +131 -0
- package/dist/react/history-step-views.d.ts +4 -0
- package/dist/react/history-step-views.js +119 -0
- package/dist/react/hooks/android-input-manager/android-input-manager.d.ts +7 -0
- package/dist/react/hooks/android-input-manager/android-input-manager.js +716 -0
- package/dist/react/hooks/android-input-manager/use-android-input-manager.js +53 -0
- package/dist/react/hooks/focus-plite-editable.js +116 -0
- package/dist/react/hooks/use-claim-editable-dom-commit.d.ts +12 -0
- package/dist/react/hooks/use-claim-editable-dom-commit.js +31 -0
- package/dist/react/hooks/use-drop-indicator.d.ts +9 -0
- package/dist/react/hooks/use-drop-indicator.js +14 -0
- package/dist/react/hooks/use-editable-clip.d.ts +18 -0
- package/dist/react/hooks/use-editable-clip.js +31 -0
- package/dist/react/hooks/use-editable-layout-pass.js +53 -0
- package/dist/react/hooks/use-editor-composing.d.ts +7 -0
- package/dist/react/hooks/use-editor-composing.js +12 -0
- package/dist/react/hooks/use-editor-context.d.ts +10 -0
- package/dist/react/hooks/use-editor-context.js +18 -0
- package/dist/react/hooks/use-editor-dom-scope.d.ts +27 -0
- package/dist/react/hooks/use-editor-dom-scope.js +23 -0
- package/dist/react/hooks/use-editor-focused.d.ts +7 -0
- package/dist/react/hooks/use-editor-focused.js +12 -0
- package/dist/react/hooks/use-editor-read-only.d.ts +25 -0
- package/dist/react/hooks/use-editor-read-only.js +19 -0
- package/dist/react/hooks/use-editor-runtime-state.d.ts +18 -0
- package/dist/react/hooks/use-editor-runtime-state.js +38 -0
- package/dist/react/hooks/use-editor-selection.d.ts +10 -0
- package/dist/react/hooks/use-editor-selection.js +13 -0
- package/dist/react/hooks/use-editor-selector.d.ts +38 -0
- package/dist/react/hooks/use-editor-selector.js +265 -0
- package/dist/react/hooks/use-editor-view-state.d.ts +16 -0
- package/dist/react/hooks/use-editor-view-state.js +20 -0
- package/dist/react/hooks/use-editor.d.ts +26 -0
- package/dist/react/hooks/use-editor.js +27 -0
- package/dist/react/hooks/use-element-path.d.ts +7 -0
- package/dist/react/hooks/use-element-path.js +36 -0
- package/dist/react/hooks/use-element-selected.d.ts +26 -0
- package/dist/react/hooks/use-element-selected.js +91 -0
- package/dist/react/hooks/use-element.d.ts +13 -0
- package/dist/react/hooks/use-element.js +17 -0
- package/dist/react/hooks/use-generic-selector.js +91 -0
- package/dist/react/hooks/use-hydrated.js +12 -0
- package/dist/react/hooks/use-isomorphic-layout-effect.js +9 -0
- package/dist/react/hooks/use-node-selector.d.ts +40 -0
- package/dist/react/hooks/use-node-selector.js +102 -0
- package/dist/react/hooks/use-plite-annotation-store.d.ts +21 -0
- package/dist/react/hooks/use-plite-annotation-store.js +61 -0
- package/dist/react/hooks/use-plite-annotations.d.ts +9 -0
- package/dist/react/hooks/use-plite-annotations.js +16 -0
- package/dist/react/hooks/use-plite-child-root.d.ts +14 -0
- package/dist/react/hooks/use-plite-child-root.js +38 -0
- package/dist/react/hooks/use-plite-content-root.d.ts +21 -0
- package/dist/react/hooks/use-plite-content-root.js +26 -0
- package/dist/react/hooks/use-plite-history.d.ts +43 -0
- package/dist/react/hooks/use-plite-history.js +137 -0
- package/dist/react/hooks/use-plite-node-ref.js +513 -0
- package/dist/react/hooks/use-plite-root-chrome.d.ts +34 -0
- package/dist/react/hooks/use-plite-root-chrome.js +98 -0
- package/dist/react/hooks/use-plite-runtime.d.ts +86 -0
- package/dist/react/hooks/use-plite-runtime.js +433 -0
- package/dist/react/hooks/use-runtime-focus-state.js +37 -0
- package/dist/react/hooks/use-selection-geometry.d.ts +12 -0
- package/dist/react/hooks/use-selection-geometry.js +39 -0
- package/dist/react/hooks/use-selection-view.d.ts +14 -0
- package/dist/react/hooks/use-selection-view.js +14 -0
- package/dist/react/hooks/use-state-field.d.ts +26 -0
- package/dist/react/hooks/use-state-field.js +38 -0
- package/dist/react/inactive-selection.js +175 -0
- package/dist/react/index.d.ts +97 -0
- package/dist/react/index.js +72 -0
- package/dist/react/plugin/react-editor.d.ts +20 -0
- package/dist/react/plugin/react-editor.js +6 -0
- package/dist/react/plugin/with-react.d.ts +108 -0
- package/dist/react/plugin/with-react.js +58 -0
- package/dist/react/range-geometry.d.ts +38 -0
- package/dist/react/range-geometry.js +481 -0
- package/dist/react/render-profiler.js +20 -0
- package/dist/react/root-key.js +12 -0
- package/dist/react/shell-runtime.js +29 -0
- package/dist/react/update-policy.d.ts +10 -0
- package/dist/react/update-policy.js +15 -0
- package/dist/react/utils/environment.js +5 -0
- package/dist/react/view-boundary-graph-core.d.ts +1 -0
- package/dist/react/view-boundary-graph-core.js +208 -0
- package/dist/react/view-boundary-graph.js +105 -0
- package/dist/react/view-selection-decoration.js +97 -0
- package/dist/react/view-selection.js +184 -0
- package/dist/react/viewport-boundary.js +45 -0
- package/dist/react/viewport-commands.d.ts +1 -0
- package/dist/react/viewport-commands.js +17 -0
- package/dist/react/viewport-plan.d.ts +2 -0
- package/dist/react/viewport-plan.js +77 -0
- package/dist/react/virtualized/use-virtualized-root-plan.js +148 -0
- package/dist/react/virtualized.d.ts +15 -0
- package/dist/react/virtualized.js +70 -0
- package/dist/testing/createDataTransfer.d.ts +4 -0
- package/dist/testing/createDataTransfer.js +13 -0
- package/dist/testing/index.d.ts +9 -0
- package/dist/testing/index.js +9 -0
- package/dist/testing/jsx.d.ts +181 -0
- package/dist/testing/jsx.js +82 -0
- package/dist/transforms-node/insert-nodes.js +143 -0
- package/dist/transforms-node/lift-nodes.js +117 -0
- package/dist/transforms-node/merge-nodes.js +180 -0
- package/dist/transforms-node/move-nodes.js +58 -0
- package/dist/transforms-node/remove-nodes.js +86 -0
- package/dist/transforms-node/replace-children.js +117 -0
- package/dist/transforms-node/set-nodes.js +188 -0
- package/dist/transforms-node/split-nodes.js +258 -0
- package/dist/transforms-node/unset-nodes.js +10 -0
- package/dist/transforms-node/unwrap-nodes.js +182 -0
- package/dist/transforms-node/wrap-nodes.js +250 -0
- package/dist/transforms-selection/collapse.js +20 -0
- package/dist/transforms-selection/deselect.js +8 -0
- package/dist/transforms-selection/move.js +35 -0
- package/dist/transforms-selection/select.js +59 -0
- package/dist/transforms-selection/set-point.js +32 -0
- package/dist/transforms-selection/set-selection.js +52 -0
- package/dist/transforms-text/delete-text-collapsed-path-targets.js +102 -0
- package/dist/transforms-text/delete-text-grid.js +402 -0
- package/dist/transforms-text/delete-text-inline-points.js +82 -0
- package/dist/transforms-text/delete-text-plan.js +55 -0
- package/dist/transforms-text/delete-text-removal.js +153 -0
- package/dist/transforms-text/delete-text-structural-cleanup.js +130 -0
- package/dist/transforms-text/delete-text-whole-blocks.js +70 -0
- package/dist/transforms-text/delete-text.js +804 -0
- package/dist/transforms-text/full-document-range.js +12 -0
- package/dist/transforms-text/insert-text.js +314 -0
- package/dist/types/types.d.ts +13 -0
- package/dist/utils/format-debug-value.d.ts +8 -0
- package/dist/utils/format-debug-value.js +31 -0
- package/dist/utils/get-default-insert-location.js +19 -0
- package/dist/utils/is-object.d.ts +4 -0
- package/dist/utils/is-object.js +4 -0
- package/dist/utils/match-path.js +8 -0
- package/dist/utils/node-keys.d.ts +15 -0
- package/dist/utils/node-keys.js +179 -0
- package/dist/utils/node-match.js +9 -0
- package/dist/utils/string.js +283 -0
- package/dist/yjs/core/addresses.js +98 -0
- package/dist/yjs/core/ancestor-properties.js +56 -0
- package/dist/yjs/core/attributes.js +21 -0
- package/dist/yjs/core/awareness-adapter.d.ts +5 -0
- package/dist/yjs/core/awareness-adapter.js +399 -0
- package/dist/yjs/core/awareness-relative-selection.js +22 -0
- package/dist/yjs/core/awareness.js +25 -0
- package/dist/yjs/core/binding.d.ts +3 -0
- package/dist/yjs/core/binding.js +128 -0
- package/dist/yjs/core/boundaries.js +453 -0
- package/dist/yjs/core/canonical-split.js +130 -0
- package/dist/yjs/core/change-bridge.js +124 -0
- package/dist/yjs/core/change-regions.js +119 -0
- package/dist/yjs/core/controller-registry.js +70 -0
- package/dist/yjs/core/controller.d.ts +6 -0
- package/dist/yjs/core/controller.js +1282 -0
- package/dist/yjs/core/document.js +1499 -0
- package/dist/yjs/core/editor-adapter.d.ts +18 -0
- package/dist/yjs/core/editor-adapter.js +145 -0
- package/dist/yjs/core/editor-only-roots.js +53 -0
- package/dist/yjs/core/editor-types.d.ts +1 -0
- package/dist/yjs/core/enclosures.js +410 -0
- package/dist/yjs/core/event-change-bridge.js +3642 -0
- package/dist/yjs/core/index.d.ts +4 -0
- package/dist/yjs/core/joined-lines.js +81 -0
- package/dist/yjs/core/joins.js +587 -0
- package/dist/yjs/core/json-equality.js +31 -0
- package/dist/yjs/core/keys.js +29 -0
- package/dist/yjs/core/letter-scripts.js +449 -0
- package/dist/yjs/core/new-letters.js +300 -0
- package/dist/yjs/core/path.js +25 -0
- package/dist/yjs/core/plugin.d.ts +107 -0
- package/dist/yjs/core/plugin.js +206 -0
- package/dist/yjs/core/record.js +4 -0
- package/dist/yjs/core/replacement.js +165 -0
- package/dist/yjs/core/retraction.js +132 -0
- package/dist/yjs/core/root-owners.js +110 -0
- package/dist/yjs/core/root-projection-index.js +428 -0
- package/dist/yjs/core/schema-metadata.js +88 -0
- package/dist/yjs/core/selection.js +34 -0
- package/dist/yjs/core/set-valued-attributes.js +57 -0
- package/dist/yjs/core/shared-effect-log.d.ts +4 -0
- package/dist/yjs/core/shared-effect-log.js +674 -0
- package/dist/yjs/core/text-runs.js +1596 -0
- package/dist/yjs/core/types.d.ts +76 -0
- package/dist/yjs/index.d.ts +5 -0
- package/dist/yjs/index.js +3 -0
- package/dist/yjs/react/index.d.ts +6 -0
- package/dist/yjs/react/index.js +4 -0
- package/dist/yjs/react/useYjs.d.ts +25 -0
- package/dist/yjs/react/useYjs.js +85 -0
- package/package.json +191 -43
|
@@ -0,0 +1,1271 @@
|
|
|
1
|
+
import { getDefined } from "../internal/get-defined.js";
|
|
2
|
+
import { countCoreWork } from "../core/work.js";
|
|
3
|
+
import { jsonEqual } from "../core/change/json.js";
|
|
4
|
+
import { copyFields, lazyRootOf, setLazyRoot, visitRootNames } from "../core/change/lazy-root.js";
|
|
5
|
+
import { NO_RECORD_OPS, composeRecordOps, deriveValue, getValueRecords, withValueRecords } from "../core/record-store.js";
|
|
6
|
+
import { DocumentIndex, rootIndexOf } from "../core/change/document-index.js";
|
|
7
|
+
import { DocumentChange, createInternalDocumentChange, filterDocumentChangeRoots, getInternalDocumentChangeEntries, getInternalDocumentChangeRanges, getInternalDocumentChangeRecords, getInternalDocumentChangeRootKeys, getInternalDocumentRootChange, valueRoot, valueRootIndex, valueRootNodes, withDocumentChangeRecords } from "../core/change/document-change.js";
|
|
8
|
+
import { UNSCOPED_ORIGINS } from "../core/change/builder.js";
|
|
9
|
+
import { getEditorRuntime, getEditorRuntimeOwner, getEditorRuntimeRoot, getEditorSchema } from "../core/editor-runtime.js";
|
|
10
|
+
import { registerEditorCommandDocument } from "../core/command-document.js";
|
|
11
|
+
import { PathApi } from "../interfaces/path.js";
|
|
12
|
+
import { PointApi } from "../interfaces/point.js";
|
|
13
|
+
import { RangeApi } from "../interfaces/range.js";
|
|
14
|
+
import { registerEditorContent } from "../core/content.js";
|
|
15
|
+
import { SelectionApi } from "../interfaces/selection.js";
|
|
16
|
+
import { crossesUniqueTarget, holdsUniqueKey, tracksPlaces, uniquePropertiesOf } from "../core/schema-compiler.js";
|
|
17
|
+
import { getCompiledEditorSchema, getPluginContributions } from "../core/plugin-registry.js";
|
|
18
|
+
import { EditorRefusalError, publishEditorRefusal, subscribeEditorRefusals } from "../core/refusal.js";
|
|
19
|
+
import { notifyObservers, runEditorObserver } from "../core/lifecycle-error.js";
|
|
20
|
+
import { getAuthoredUpdateView, registerAuthoredRuntime } from "../core/authored-runtime.js";
|
|
21
|
+
import { authoredDocumentCapabilityPoint } from "../core/authored-document-capability.js";
|
|
22
|
+
import { changedRootsOf, orphanedValueRoots, rootsDeletedByName } from "../core/root-ownership.js";
|
|
23
|
+
import { elementSplitOutput } from "../core/default-storage.js";
|
|
24
|
+
import { readingCovered } from "../core/property-validity.js";
|
|
25
|
+
import { completeChildrenAt } from "../core/representation.js";
|
|
26
|
+
import { holdsOneText, withoutGeneration } from "../core/editor-schema.js";
|
|
27
|
+
import { admitDocument, documentAdmissionPoint } from "../core/document-admission.js";
|
|
28
|
+
import { txOnly, txStored } from "../core/tx-only.js";
|
|
29
|
+
import { getBaseViewPresentation } from "../core/view-presentation.js";
|
|
30
|
+
import { getViewAuthor, getViewPresentation } from "../editor-runtime-view.js";
|
|
31
|
+
import { getPlacementGeneration, nextMintedGeneration, subscribeCommittedPlacement } from "../core/view-carets.js";
|
|
32
|
+
import { gridHoldersOf, gridRolesOf } from "../core/survival.js";
|
|
33
|
+
import { registerEditorDocumentRecorder, registerEditorDraftGuard, registerEditorDraftView } from "../core/document-recorder.js";
|
|
34
|
+
import { applyDocumentChange, getActiveEditorUpdateId, getActiveEditorUpdateTags, getCurrentSelection, getCurrentSelectionRoot, isPresentationComposing, notifyPresentationViewState, subscribePresentationComposition, withEditorDocumentProjection } from "../core/public-state.js";
|
|
35
|
+
import { prepareCommandFrame } from "../core/command-frame.js";
|
|
36
|
+
import { definePlugin } from "../core/plugin.js";
|
|
37
|
+
import { authoredVeto } from "../core/authored-veto.js";
|
|
38
|
+
import { contentRootsOf, rootOf } from "./ledger/roots.js";
|
|
39
|
+
import { editingChangeOf, isEditingChange } from "./facts/editing.js";
|
|
40
|
+
import { acceptedValues } from "./tree/layers.js";
|
|
41
|
+
import { authoredMarksSchema, followsOf, isAuthoredSetValued, readAuthoredMarks, readMembers } from "./tree/marks.js";
|
|
42
|
+
import { authoredRecords, incarnationOfLink, landedOf, putContexts, putLanded, withStore } from "./facts/records.js";
|
|
43
|
+
import { claimsOf, factsOf, isAccepted, isSettledDeletion, marksOf, standingClaimsOf } from "./facts/facts.js";
|
|
44
|
+
import { relinkCuts } from "./tree/cuts.js";
|
|
45
|
+
import { indexAuthoredChanges, readAuthoredDetails } from "./changes.js";
|
|
46
|
+
import { carriedIn } from "./facts/compact.js";
|
|
47
|
+
import { createDependencies } from "./facts/dependencies.js";
|
|
48
|
+
import { joinCompares } from "./tree/halves.js";
|
|
49
|
+
import { claimsBreakBefore, isTextBlock, pastFollowers, projectAuthoredValue, resolveAuthoredChildren } from "./tree/resolve.js";
|
|
50
|
+
import { characterAlignedChange } from "./tree/alignment.js";
|
|
51
|
+
import { blockFactsOf, isBuilt } from "./ledger/runs.js";
|
|
52
|
+
import { NO_SPARE_WRITES, changedSitesOf, spareWritesChange, sparesFor, storesSpares } from "./tree/reserves.js";
|
|
53
|
+
import { authoredResolveSchemaOf, storedResolveSchemaOf } from "./resolve-schema.js";
|
|
54
|
+
import { claimOf, decide, isRefusal, spareGuardOver } from "./decision.js";
|
|
55
|
+
import { closeCommandValues, generatedOf } from "./tree/command-values.js";
|
|
56
|
+
import { GENERATED_VALUES_REFUSAL, proposalRefusal, splitOneTextRefusal, storesGeneratedValues, unplaced, unrepresentable, unrepresentableFor } from "./refusal.js";
|
|
57
|
+
import { projectAuthoredBlocks, projectAuthoredDocumentUnder } from "./format.js";
|
|
58
|
+
import { createReviewLedger, getReviewLedger } from "./ledger/ledger.js";
|
|
59
|
+
import { authoredAdmission, createDocumentMarksValidator } from "./facts/admission.js";
|
|
60
|
+
import { recordAuthoredSteps } from "./tree/record.js";
|
|
61
|
+
import { completeProposed, framedChild } from "./tree/record-completion.js";
|
|
62
|
+
import { spareBlock, spareRoot } from "./tree/spare-lines.js";
|
|
63
|
+
//#region src/authored/authored.ts
|
|
64
|
+
const STATES = /* @__PURE__ */ new WeakMap();
|
|
65
|
+
const authoredProposerOf = (editor) => {
|
|
66
|
+
const state = STATES.get(getEditorRuntimeOwner(editor));
|
|
67
|
+
const authorId = state?.authorId() ?? null;
|
|
68
|
+
if (!state || authorId === null) return null;
|
|
69
|
+
return {
|
|
70
|
+
authorId,
|
|
71
|
+
createChangeId: state.createChangeId,
|
|
72
|
+
pending: changesOf(editor, storedValue(editor)).idsAuthoredBy(authorId)
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
const elementOf = (props) => ({
|
|
76
|
+
...props,
|
|
77
|
+
children: [],
|
|
78
|
+
type: String(props.type)
|
|
79
|
+
});
|
|
80
|
+
const isReplay = (tags) => tags.includes("historic") || tags.includes("collaboration");
|
|
81
|
+
const isStruck = (editor, node) => {
|
|
82
|
+
if (!readAuthoredMarks(node).some((mark) => mark.kind === "delete")) return false;
|
|
83
|
+
const facts = factsOf(storedValue(editor));
|
|
84
|
+
return isSettledDeletion(node, facts) || marksOf(node, facts).some((mark) => mark.kind === "delete");
|
|
85
|
+
};
|
|
86
|
+
const positionOf = (value, root, point) => valueRootIndex(value, root).positionAt(point);
|
|
87
|
+
const mapPoint = (point, input, assoc) => {
|
|
88
|
+
const index = input.indexes.get(input.root);
|
|
89
|
+
if (!index) return point;
|
|
90
|
+
const position = input.map(input.root, positionOf(input.after, input.root, point), assoc);
|
|
91
|
+
const recorded = position === null || position === void 0 ? null : index.pointAt(position, assoc);
|
|
92
|
+
return recorded ? {
|
|
93
|
+
...point,
|
|
94
|
+
offset: recorded.offset,
|
|
95
|
+
path: [...recorded.path]
|
|
96
|
+
} : point;
|
|
97
|
+
};
|
|
98
|
+
/** Map a selection on the written draft onto the document recorded from it. */
|
|
99
|
+
const mapSelection = (selection, input, assoc = -1) => {
|
|
100
|
+
if (selection?.kind === "text") return {
|
|
101
|
+
...selection,
|
|
102
|
+
anchor: mapPoint(selection.anchor, input, assoc),
|
|
103
|
+
focus: mapPoint(selection.focus, input, assoc)
|
|
104
|
+
};
|
|
105
|
+
const index = input.indexes.get(input.root);
|
|
106
|
+
if (selection?.kind !== "node" || !index) return selection;
|
|
107
|
+
const draft = DocumentIndex.fromValue(valueRoot(input.after, input.root));
|
|
108
|
+
const mapPath = (path) => {
|
|
109
|
+
const position = input.map(input.root, draft.nodeRange(path).from, 1);
|
|
110
|
+
const entry = position === null || position === void 0 ? null : index.nodeStartingAt(position);
|
|
111
|
+
return entry ? [...entry.path] : null;
|
|
112
|
+
};
|
|
113
|
+
const [first, ...rest] = selection.paths.flatMap((path) => {
|
|
114
|
+
const mapped = mapPath(path);
|
|
115
|
+
return mapped ? [mapped] : [];
|
|
116
|
+
});
|
|
117
|
+
if (!first) return null;
|
|
118
|
+
const { paths } = SelectionApi.nodes([first, ...rest], { mode: "block" });
|
|
119
|
+
const endpoint = (path, fallback) => {
|
|
120
|
+
const mapped = mapPath(path);
|
|
121
|
+
return mapped && paths.some((kept) => PathApi.equals(kept, mapped)) ? mapped : fallback;
|
|
122
|
+
};
|
|
123
|
+
return SelectionApi.nodes(paths, {
|
|
124
|
+
anchorPath: endpoint(selection.anchorPath, paths[0]),
|
|
125
|
+
focusPath: endpoint(selection.focusPath, paths.at(-1) ?? paths[0]),
|
|
126
|
+
mode: selection.mode,
|
|
127
|
+
...selection.root === void 0 ? {} : { root: selection.root }
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
const framedLawCheck = () => {
|
|
131
|
+
const env = globalThis.process?.env;
|
|
132
|
+
return env?.NODE_ENV === "test" ? env.PLITE_LAW_CHECK : "0";
|
|
133
|
+
};
|
|
134
|
+
const isEmptiedGrid = (node, holdsParts) => holdsParts(node) && (node.children ?? []).every((child) => holdsParts(child) && isEmptiedGrid(child, holdsParts));
|
|
135
|
+
const listAcceptsTo = (acceptedList, wroteList, holdsParts) => {
|
|
136
|
+
const withoutEmptiedGrids = (list) => list.filter((node) => !isEmptiedGrid(node, holdsParts));
|
|
137
|
+
const accepted = withoutEmptiedGrids(acceptedList);
|
|
138
|
+
const wrote = withoutEmptiedGrids(wroteList);
|
|
139
|
+
let end = wrote.length;
|
|
140
|
+
while (end > accepted.length && isBuilt(getDefined(wrote[end - 1]))) end -= 1;
|
|
141
|
+
return end === accepted.length && accepted.every((node, index) => {
|
|
142
|
+
const other = getDefined(wrote[index]);
|
|
143
|
+
return jsonEqual(node, other) || !!node.children && !!other.children && jsonEqual(nodePropsOf(node), nodePropsOf(other)) && listAcceptsTo(node.children, other.children, holdsParts);
|
|
144
|
+
});
|
|
145
|
+
};
|
|
146
|
+
const acceptsTo = (accepted, wrote, holdsParts) => {
|
|
147
|
+
const { children, records: _records, roots = {}, ...fields } = accepted;
|
|
148
|
+
const { children: wroteChildren, records: _wroteRecords, roots: wroteRoots = {}, ...wroteFields } = wrote;
|
|
149
|
+
const names = Object.keys(roots);
|
|
150
|
+
return jsonEqual(fields, wroteFields) && listAcceptsTo(children, wroteChildren, holdsParts) && jsonEqual(names.toSorted(), Object.keys(wroteRoots).toSorted()) && names.every((name) => listAcceptsTo(getDefined(roots[name]), getDefined(wroteRoots[name]), holdsParts));
|
|
151
|
+
};
|
|
152
|
+
const assertFramedLaw = (input, schema, selection, mapAfter) => {
|
|
153
|
+
const { frame, root, stored } = input;
|
|
154
|
+
const written = contentOf(stored.value);
|
|
155
|
+
const accepted = contentOf(projectAuthoredValue(stored.value, "proposed", schema).value);
|
|
156
|
+
if (!acceptsTo(accepted, contentOf(frame.value), gridHoldersOf(schema.ownership))) throw new Error(`A framed recording does not accept to what its commands wrote: ${JSON.stringify({
|
|
157
|
+
accepted: accepted.children,
|
|
158
|
+
wrote: frame.value.children
|
|
159
|
+
})}`);
|
|
160
|
+
if (!selection || frame.selection?.kind !== "text" || stored.selection?.kind !== "text") return;
|
|
161
|
+
const map = mapAfter();
|
|
162
|
+
const index = DocumentIndex.fromValue(valueRoot(accepted, root));
|
|
163
|
+
for (const edge of ["anchor", "focus"]) {
|
|
164
|
+
const position = positionOf(written, root, stored.selection[edge]);
|
|
165
|
+
const expected = frame.selection[edge];
|
|
166
|
+
if (!["backward", "forward"].some((association) => [-1, 1].some((assoc) => {
|
|
167
|
+
const projected = map.toProjected(root, position, association);
|
|
168
|
+
const point = projected === null ? null : index.pointAt(projected, assoc);
|
|
169
|
+
return point !== null && point.offset === expected.offset && PathApi.equals(point.path, expected.path);
|
|
170
|
+
}))) throw new Error(`A framed recording does not accept to its commands' ${edge}: ${JSON.stringify({
|
|
171
|
+
accepted: valueRoot(accepted, root),
|
|
172
|
+
stored: stored.selection[edge],
|
|
173
|
+
whereCommandsLeftIt: expected,
|
|
174
|
+
written: valueRoot(written, root)
|
|
175
|
+
})}`);
|
|
176
|
+
}
|
|
177
|
+
};
|
|
178
|
+
const STORED_READS = /* @__PURE__ */ new WeakSet();
|
|
179
|
+
const NO_ROOTS = /* @__PURE__ */ new Set();
|
|
180
|
+
const PUBLISHERS = /* @__PURE__ */ new WeakMap();
|
|
181
|
+
const storedRead = (editor, read) => {
|
|
182
|
+
const owner = getEditorRuntimeOwner(editor);
|
|
183
|
+
if (STORED_READS.has(owner)) return read(owner);
|
|
184
|
+
STORED_READS.add(owner);
|
|
185
|
+
try {
|
|
186
|
+
return read(owner);
|
|
187
|
+
} finally {
|
|
188
|
+
STORED_READS.delete(owner);
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const storedValue = (editor) => storedRead(editor, (owner) => owner.read.value());
|
|
192
|
+
const readCursor = (cursor) => {
|
|
193
|
+
let parsed;
|
|
194
|
+
try {
|
|
195
|
+
parsed = JSON.parse(cursor);
|
|
196
|
+
} catch {
|
|
197
|
+
parsed = null;
|
|
198
|
+
}
|
|
199
|
+
if (!Array.isArray(parsed) || parsed.length !== 3 || parsed.some((part) => typeof part !== "string")) throw new Error("Stale authored page cursor.");
|
|
200
|
+
return parsed;
|
|
201
|
+
};
|
|
202
|
+
/**
|
|
203
|
+
* A review read on a preview named a point or a range, which a preview does
|
|
204
|
+
* not read: it reads the changes of a node by its key or path.
|
|
205
|
+
*/
|
|
206
|
+
var AuthoredPlaceError = class extends Error {
|
|
207
|
+
name = "AuthoredPlaceError";
|
|
208
|
+
constructor() {
|
|
209
|
+
super("A preview reads review changes by a node's key or path, not by a point or a range.");
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
const NOTHING_DISSOLVES = () => false;
|
|
213
|
+
const placeIds = (editor, book, at, places) => {
|
|
214
|
+
const viewRoot = getEditorRuntimeRoot(editor);
|
|
215
|
+
if (typeof at === "string" || PathApi.isPath(at)) {
|
|
216
|
+
const path = typeof at === "string" ? editor.read.nodes.path(at) : at;
|
|
217
|
+
const index = places?.index ?? valueRootIndex(storedValue(editor), viewRoot);
|
|
218
|
+
let from;
|
|
219
|
+
let to;
|
|
220
|
+
if (!path) return [];
|
|
221
|
+
try {
|
|
222
|
+
({from, to} = index.nodeRange(path));
|
|
223
|
+
if (typeof index.node(path).text === "string") to -= 1;
|
|
224
|
+
} catch {
|
|
225
|
+
return [];
|
|
226
|
+
}
|
|
227
|
+
return book.pendingInOrder(book.idsShown(viewRoot, places ? places.spans(from, to) : [[from, to]], places?.dissolves ?? NOTHING_DISSOLVES));
|
|
228
|
+
}
|
|
229
|
+
if (places) throw new AuthoredPlaceError();
|
|
230
|
+
const inViewRoot = (point) => point.root === void 0 ? {
|
|
231
|
+
...point,
|
|
232
|
+
root: viewRoot
|
|
233
|
+
} : point;
|
|
234
|
+
const range = RangeApi.isRange(at) ? {
|
|
235
|
+
...at,
|
|
236
|
+
anchor: inViewRoot(at.anchor),
|
|
237
|
+
focus: inViewRoot(at.focus)
|
|
238
|
+
} : {
|
|
239
|
+
anchor: inViewRoot(at),
|
|
240
|
+
focus: inViewRoot(at)
|
|
241
|
+
};
|
|
242
|
+
const [start, end] = RangeApi.edges(range);
|
|
243
|
+
return book.pendingInOrder([...book.idsIn(start.root ?? viewRoot, getDefined(start.path[0]), getDefined(end.path[0]) + 1)].filter((id) => getDefined(book.change(id)).ranges.some((candidate) => RangeApi.intersection(candidate, range) !== null)));
|
|
244
|
+
};
|
|
245
|
+
const ledgerOf = (editor) => getDefined(getReviewLedger(getEditorRuntimeOwner(editor)));
|
|
246
|
+
const changesOf = (editor, value) => ledgerOf(editor).changes(value);
|
|
247
|
+
/** `value` without its records, which a decision only adds to. */
|
|
248
|
+
const contentOf = (value) => {
|
|
249
|
+
const { records: _records, ...plain } = value;
|
|
250
|
+
return plain;
|
|
251
|
+
};
|
|
252
|
+
const contentChangeOf = (change) => withDocumentChangeRecords(change, NO_RECORD_OPS);
|
|
253
|
+
/** Whether `change` only removes tokens, in roots it neither creates nor deletes. */
|
|
254
|
+
const onlyRemovesTokens = (change) => change.createRoots.size === 0 && change.deleteRoots.size === 0 && getInternalDocumentChangeRootKeys(change).every((root) => getDefined(getInternalDocumentRootChange(change, root)).sections.every((value, index) => index % 2 === 0 || value === 0 || value === -1));
|
|
255
|
+
/**
|
|
256
|
+
* Whether a decision settles by removing text alone, so its undo can take
|
|
257
|
+
* the settlement back apart from everything else it wrote: every change it
|
|
258
|
+
* decides is an accepted deletion of text leaves that each keep an inline
|
|
259
|
+
* sibling, it withdraws nothing, and its text change only removes tokens.
|
|
260
|
+
* Without a withdrawal, the decision's verdicts name every occurrence of
|
|
261
|
+
* every change it acts on.
|
|
262
|
+
*/
|
|
263
|
+
const settlesTextAlone = (value, change, decided, actions, occurrencesOf, withdraws) => {
|
|
264
|
+
if (withdraws) return false;
|
|
265
|
+
const removed = /* @__PURE__ */ new Map();
|
|
266
|
+
for (const id of decided) {
|
|
267
|
+
if (actions.get(id) !== "accept") return false;
|
|
268
|
+
for (const { mark, node, path, root } of occurrencesOf(id)) {
|
|
269
|
+
if (mark.kind !== "delete" || typeof node.text !== "string") return false;
|
|
270
|
+
let children = valueRootNodes(value, root);
|
|
271
|
+
for (const index of path.slice(0, -1)) children = children?.at(index)?.children;
|
|
272
|
+
if (!children) return false;
|
|
273
|
+
const count = (removed.get(children) ?? 0) + 1;
|
|
274
|
+
if (count >= children.length) return false;
|
|
275
|
+
removed.set(children, count);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
return onlyRemovesTokens(contentChangeOf(change));
|
|
279
|
+
};
|
|
280
|
+
const nodePropsOf = ({ children: _children, text: _text, ...props }) => props;
|
|
281
|
+
/**
|
|
282
|
+
* The deepest element whose children hold the range as whole blocks, so a
|
|
283
|
+
* join or split in the range lands among the blocks beside it.
|
|
284
|
+
*/
|
|
285
|
+
const siteOf = (index, from, to) => {
|
|
286
|
+
let site = [];
|
|
287
|
+
for (const range of index.openContextAt(from)) {
|
|
288
|
+
if (range.kind !== "element" || range.contentFrom > from || range.contentTo < to || isTextBlock(index.node(range.path))) break;
|
|
289
|
+
site = range.path;
|
|
290
|
+
}
|
|
291
|
+
return site;
|
|
292
|
+
};
|
|
293
|
+
const childrenOf = (index, path) => path.length === 0 ? index.nodes : index.node(path).children ?? [];
|
|
294
|
+
const holdsOwnStructure = (node, facts) => claimsOf(node, facts).some((mark) => (mark.kind === "join" || mark.kind === "split") && isEditingChange(mark.change)) || (node.children ?? []).some((child) => holdsOwnStructure(child, facts));
|
|
295
|
+
/** The pending joins Editing's claims in `node` say their blocks go with. */
|
|
296
|
+
const ownFollowed = (node, facts) => [...claimsOf(node, facts).flatMap((mark) => {
|
|
297
|
+
const key = isEditingChange(mark.change) ? followsOf(mark) : void 0;
|
|
298
|
+
return key ? [incarnationOfLink(key)] : [];
|
|
299
|
+
}), ...(node.children ?? []).flatMap((child) => ownFollowed(child, facts))];
|
|
300
|
+
/**
|
|
301
|
+
* The run around blocks `from` to `to` of the element at `path`: a
|
|
302
|
+
* line on either side, where a join in the run or a pending join after it
|
|
303
|
+
* lands, and before it whatever block a join or split in it lands on.
|
|
304
|
+
*/
|
|
305
|
+
const runAround = (index, path, from, to, facts) => {
|
|
306
|
+
const siblings = childrenOf(index, path);
|
|
307
|
+
const structural = siblings.slice(from, to).some((node) => holdsOwnStructure(node, facts));
|
|
308
|
+
let start = from > 0 && (structural || isTextBlock(getDefined(siblings.at(from - 1)))) ? from - 1 : from;
|
|
309
|
+
const landingPassesOver = (node) => holdsOwnStructure(node, facts) || structural && isSettledDeletion(node, facts);
|
|
310
|
+
while (start > 0 && landingPassesOver(getDefined(siblings.at(start)))) start -= 1;
|
|
311
|
+
const end = pastFollowers(siblings, to, (node) => claimsOf(node, facts));
|
|
312
|
+
return {
|
|
313
|
+
from: start,
|
|
314
|
+
path,
|
|
315
|
+
to: end < siblings.length && isTextBlock(getDefined(siblings.at(end))) ? end + 1 : end
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
const ownRuns = (index, change, facts) => {
|
|
319
|
+
const sites = /* @__PURE__ */ new Map();
|
|
320
|
+
change.iterChangedRanges((_fromA, _toA, from, to) => {
|
|
321
|
+
const path = siteOf(index, from, to);
|
|
322
|
+
const key = path.join(",");
|
|
323
|
+
const site = sites.get(key) ?? {
|
|
324
|
+
at: /* @__PURE__ */ new Set(),
|
|
325
|
+
path
|
|
326
|
+
};
|
|
327
|
+
for (const range of index.nodeRangesTouching(from, to)) if ((to === from || range.from < to && range.to > from) && range.path.length === path.length + 1 && path.every((step, depth) => range.path[depth] === step)) site.at.add(range.path[path.length]);
|
|
328
|
+
sites.set(key, site);
|
|
329
|
+
});
|
|
330
|
+
const runs = [];
|
|
331
|
+
for (const { at, path } of sites.values()) for (const child of [...at].toSorted((left, right) => left - right)) {
|
|
332
|
+
const run = runAround(index, path, child, child + 1, facts);
|
|
333
|
+
const last = runs.at(-1);
|
|
334
|
+
if (last && last.path === path && run.from <= last.to) runs[runs.length - 1] = {
|
|
335
|
+
from: Math.min(last.from, run.from),
|
|
336
|
+
path,
|
|
337
|
+
to: Math.max(last.to, run.to)
|
|
338
|
+
};
|
|
339
|
+
else runs.push(run);
|
|
340
|
+
}
|
|
341
|
+
return runs;
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* The contexts a recording minted that its written content rests on, directly
|
|
345
|
+
* or through a kept context's base. Accepting one's own claims can leave a
|
|
346
|
+
* minted context named by nothing, and only content the write changed can name
|
|
347
|
+
* one it minted.
|
|
348
|
+
*/
|
|
349
|
+
const restedOn = (minted, change, indexes) => {
|
|
350
|
+
if (minted.length === 0) return minted;
|
|
351
|
+
const named = /* @__PURE__ */ new Set();
|
|
352
|
+
for (const [root, index] of indexes) for (const range of getInternalDocumentChangeRanges(change, root)) for (const { path } of index.nodeRangesTouching(range[2], range[3])) for (const member of readMembers(index.node(path))) if (member.kind === "in") named.add(member.ctx);
|
|
353
|
+
const bases = new Map(minted.map(({ base, ctx }) => [ctx, base]));
|
|
354
|
+
for (const ctx of named) {
|
|
355
|
+
const base = bases.get(ctx);
|
|
356
|
+
if (base) named.add(base);
|
|
357
|
+
}
|
|
358
|
+
return minted.filter(({ ctx }) => named.has(ctx));
|
|
359
|
+
};
|
|
360
|
+
/**
|
|
361
|
+
* Accept an Editing write's own claims in its commit, over runs of the
|
|
362
|
+
* blocks the write touched. A join or split whose landing waits on another
|
|
363
|
+
* pending change keeps its claim. Completion is left to the commit's
|
|
364
|
+
* canonical pass, which fills in place as Editing does.
|
|
365
|
+
*/
|
|
366
|
+
const acceptOwn = (change, indexes, dependencies, base) => {
|
|
367
|
+
const minted = new Map(dependencies.minted().map((record) => [record.ctx, record]));
|
|
368
|
+
const facts = minted.size === 0 ? base : {
|
|
369
|
+
...base,
|
|
370
|
+
contexts: {
|
|
371
|
+
get: (ctx) => minted.get(ctx) ?? base.contexts.get(ctx),
|
|
372
|
+
has: (ctx) => minted.has(ctx) || base.contexts.has(ctx)
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
const outcome = (id) => isEditingChange(id) ? "accept" : "keep";
|
|
376
|
+
const settledBy = (result) => {
|
|
377
|
+
const kept = /* @__PURE__ */ new Set();
|
|
378
|
+
const visit = (node) => {
|
|
379
|
+
for (const member of readMembers(node)) kept.add(member);
|
|
380
|
+
node.children?.forEach(visit);
|
|
381
|
+
};
|
|
382
|
+
result.forEach(visit);
|
|
383
|
+
const own = (kind) => (node) => claimsOf(node, facts).some((mark) => mark.kind === kind && isEditingChange(mark.change) && !kept.has(mark));
|
|
384
|
+
return {
|
|
385
|
+
joins: own("join"),
|
|
386
|
+
removes: own("delete"),
|
|
387
|
+
wholeWhenRemoved: () => false
|
|
388
|
+
};
|
|
389
|
+
};
|
|
390
|
+
const changes = /* @__PURE__ */ new Map();
|
|
391
|
+
const accepted = new Map(indexes);
|
|
392
|
+
const landed = [];
|
|
393
|
+
const resolveOwn = (nodes, root) => {
|
|
394
|
+
const resolution = resolveAuthoredChildren(nodes, outcome, null, root, {
|
|
395
|
+
dependencies,
|
|
396
|
+
facts,
|
|
397
|
+
stores: true
|
|
398
|
+
});
|
|
399
|
+
landed.push(...resolution.landed);
|
|
400
|
+
return resolution.children;
|
|
401
|
+
};
|
|
402
|
+
for (const [root, index] of indexes) {
|
|
403
|
+
const rootChange = getInternalDocumentRootChange(change, root);
|
|
404
|
+
if (!rootChange) continue;
|
|
405
|
+
const resolveRun = (first) => {
|
|
406
|
+
for (let run = first;;) {
|
|
407
|
+
const siblings = childrenOf(index, run.path);
|
|
408
|
+
const keys = new Set(siblings.slice(run.from, run.to).flatMap((node) => ownFollowed(node, facts)));
|
|
409
|
+
if (keys.size > 0) {
|
|
410
|
+
const lines = [];
|
|
411
|
+
if (run.path.length === 0) countCoreWork("wholeReadNodes", siblings.length);
|
|
412
|
+
siblings.forEach((node, at) => {
|
|
413
|
+
if (blockFactsOf(node).joins.some((key) => keys.has(key))) lines.push(at);
|
|
414
|
+
});
|
|
415
|
+
if (lines.length === 0 && run.path.length > 0) {
|
|
416
|
+
const at = getDefined(run.path.at(-1));
|
|
417
|
+
run = runAround(index, run.path.slice(0, -1), at, at + 1, facts);
|
|
418
|
+
continue;
|
|
419
|
+
}
|
|
420
|
+
run = {
|
|
421
|
+
...run,
|
|
422
|
+
from: Math.min(run.from, ...lines),
|
|
423
|
+
to: Math.max(run.to, ...lines.map((at) => at + 1))
|
|
424
|
+
};
|
|
425
|
+
}
|
|
426
|
+
const nodes = siblings.slice(run.from, run.to);
|
|
427
|
+
if (run.path.length === 0) return {
|
|
428
|
+
nodes,
|
|
429
|
+
result: resolveOwn(nodes, root),
|
|
430
|
+
run
|
|
431
|
+
};
|
|
432
|
+
const shell = {
|
|
433
|
+
...nodePropsOf(index.node(run.path)),
|
|
434
|
+
children: [...nodes]
|
|
435
|
+
};
|
|
436
|
+
const [only, ...rest] = resolveOwn([shell], root);
|
|
437
|
+
const leading = nodes.find((node) => !isSettledDeletion(node, facts));
|
|
438
|
+
if (only && rest.length === 0 && jsonEqual(nodePropsOf(only), nodePropsOf(shell)) && !(run.from === 0 && leading && holdsOwnStructure(leading, facts))) return {
|
|
439
|
+
nodes,
|
|
440
|
+
result: only.children ?? [],
|
|
441
|
+
run
|
|
442
|
+
};
|
|
443
|
+
const at = getDefined(run.path.at(-1));
|
|
444
|
+
run = runAround(index, run.path.slice(0, -1), at, at + 1, facts);
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
let runs = ownRuns(index, rootChange, facts);
|
|
448
|
+
let spans = [];
|
|
449
|
+
for (let merged = true; merged; runs = spans.map((span) => span.run)) {
|
|
450
|
+
merged = false;
|
|
451
|
+
spans = [];
|
|
452
|
+
for (const span of runs.map(resolveRun).map((entry) => ({
|
|
453
|
+
...entry,
|
|
454
|
+
from: index.childPosition(entry.run.path, entry.run.from),
|
|
455
|
+
to: index.childPosition(entry.run.path, entry.run.to)
|
|
456
|
+
})).toSorted((left, right) => left.from - right.from || right.to - left.to)) {
|
|
457
|
+
const last = spans.at(-1);
|
|
458
|
+
if (!last || span.from >= last.to) spans.push(span);
|
|
459
|
+
else if (span.to > last.to) {
|
|
460
|
+
spans[spans.length - 1] = {
|
|
461
|
+
...last,
|
|
462
|
+
run: {
|
|
463
|
+
...last.run,
|
|
464
|
+
to: span.run.to
|
|
465
|
+
},
|
|
466
|
+
to: span.to
|
|
467
|
+
};
|
|
468
|
+
merged = true;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
let current = index;
|
|
473
|
+
let composed = null;
|
|
474
|
+
for (const { from, nodes, result } of spans.toReversed()) {
|
|
475
|
+
if (jsonEqual(result, nodes)) continue;
|
|
476
|
+
const stored = { children: nodes };
|
|
477
|
+
const settled = { children: result };
|
|
478
|
+
const step = getDefined(getInternalDocumentRootChange(characterAlignedChange(stored, settled, settledBy(result)) ?? DocumentChange.between(stored, settled, { isSetValued: isAuthoredSetValued }), "main")).embed(current.length, from);
|
|
479
|
+
current = step.apply(current);
|
|
480
|
+
composed = composed ? composed.compose(step) : step;
|
|
481
|
+
}
|
|
482
|
+
if (composed) {
|
|
483
|
+
changes.set(root, composed);
|
|
484
|
+
accepted.set(root, current);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
return changes.size === 0 ? null : {
|
|
488
|
+
change: createInternalDocumentChange(changes),
|
|
489
|
+
indexes: accepted,
|
|
490
|
+
landed
|
|
491
|
+
};
|
|
492
|
+
};
|
|
493
|
+
const writtenNamedRoots = (steps) => {
|
|
494
|
+
const written = /* @__PURE__ */ new Set();
|
|
495
|
+
for (const step of steps) {
|
|
496
|
+
if (UNSCOPED_ORIGINS.has(step.origin)) continue;
|
|
497
|
+
for (const [root] of getInternalDocumentChangeEntries(step.change)) if (root !== "main") written.add(root);
|
|
498
|
+
}
|
|
499
|
+
return written;
|
|
500
|
+
};
|
|
501
|
+
/**
|
|
502
|
+
* The `authored` plugin with deterministic ids, clock and starting intent,
|
|
503
|
+
* for tests.
|
|
504
|
+
*/
|
|
505
|
+
const createAuthoredPlugin = (options) => {
|
|
506
|
+
const createChangeId = options.createChangeId ?? (() => crypto.randomUUID());
|
|
507
|
+
const createTagId = options.createTagId ?? (() => crypto.randomUUID().replaceAll("-", "").slice(0, 12));
|
|
508
|
+
const now = options.now ?? Date.now;
|
|
509
|
+
const incarnationToken = crypto.randomUUID().slice(0, 8);
|
|
510
|
+
let incarnations = 0;
|
|
511
|
+
const createIncarnationId = options.createIncarnationId ?? (() => {
|
|
512
|
+
incarnations += 1;
|
|
513
|
+
return `${incarnationToken}:${incarnations}`;
|
|
514
|
+
});
|
|
515
|
+
const authorOf = (writing) => getViewAuthor(writing) ?? (typeof options.authorId === "function" ? options.authorId(writing) : options.authorId) ?? null;
|
|
516
|
+
const stateOf = (editor) => {
|
|
517
|
+
const state = STATES.get(getEditorRuntimeOwner(editor));
|
|
518
|
+
if (!state) throw new Error("Authored changes are not installed.");
|
|
519
|
+
return state;
|
|
520
|
+
};
|
|
521
|
+
const viewOf = (editor) => {
|
|
522
|
+
const { views } = stateOf(editor);
|
|
523
|
+
for (let runtime = getEditorRuntime(editor); runtime; runtime = runtime.policySource?.current()) {
|
|
524
|
+
const view = runtime.presentation && views.get(runtime.presentation);
|
|
525
|
+
if (view) return view;
|
|
526
|
+
}
|
|
527
|
+
return views.get(getBaseViewPresentation(getEditorRuntimeOwner(editor))) ?? { intent: "edit" };
|
|
528
|
+
};
|
|
529
|
+
const applyView = (editor, view) => {
|
|
530
|
+
const presentation = getViewPresentation(editor);
|
|
531
|
+
const state = stateOf(editor);
|
|
532
|
+
state.pending.delete(presentation);
|
|
533
|
+
state.views.set(presentation, view);
|
|
534
|
+
notifyPresentationViewState(editor, "authored");
|
|
535
|
+
};
|
|
536
|
+
const applyOnceWordsAreComposed = (editor) => {
|
|
537
|
+
const presentation = getViewPresentation(editor);
|
|
538
|
+
const stop = subscribePresentationComposition(editor, () => {
|
|
539
|
+
if (isPresentationComposing(editor)) return;
|
|
540
|
+
stop();
|
|
541
|
+
const next = stateOf(editor).pending.get(presentation);
|
|
542
|
+
if (next) applyView(editor, next);
|
|
543
|
+
});
|
|
544
|
+
};
|
|
545
|
+
const requestView = (editor, view) => {
|
|
546
|
+
const presentation = getViewPresentation(editor);
|
|
547
|
+
const state = stateOf(editor);
|
|
548
|
+
const waiting = state.pending.has(presentation);
|
|
549
|
+
if (isPresentationComposing(editor)) {
|
|
550
|
+
state.pending.set(presentation, view);
|
|
551
|
+
if (!waiting) applyOnceWordsAreComposed(editor);
|
|
552
|
+
return;
|
|
553
|
+
}
|
|
554
|
+
const current = state.views.get(presentation);
|
|
555
|
+
const modeOf = (value) => "intent" in value ? value.intent : value.preview;
|
|
556
|
+
if (waiting || !current || modeOf(current) !== modeOf(view)) applyView(editor, view);
|
|
557
|
+
};
|
|
558
|
+
const settleWaitingView = (editor) => {
|
|
559
|
+
const waiting = stateOf(editor).pending.get(getViewPresentation(editor));
|
|
560
|
+
if (waiting && !isPresentationComposing(editor)) applyView(editor, waiting);
|
|
561
|
+
};
|
|
562
|
+
const previewModeOf = (editor) => {
|
|
563
|
+
const view = viewOf(editor);
|
|
564
|
+
return "preview" in view && !STORED_READS.has(getEditorRuntimeOwner(editor)) ? view.preview : null;
|
|
565
|
+
};
|
|
566
|
+
const viewPlacesOf = (editor) => {
|
|
567
|
+
const preview = previewModeOf(editor);
|
|
568
|
+
return preview ? ledgerOf(editor).viewPlaces(storedValue(editor), preview, getEditorRuntimeRoot(editor)) : null;
|
|
569
|
+
};
|
|
570
|
+
const decisionOn = (editor, value, decisions, withdraws) => {
|
|
571
|
+
const book = changesOf(editor, value);
|
|
572
|
+
const actions = /* @__PURE__ */ new Map();
|
|
573
|
+
let conflicting = false;
|
|
574
|
+
const stale = /* @__PURE__ */ new Set();
|
|
575
|
+
for (const decision of [decisions].flat()) for (const read of "groups" in decision ? decision.groups : decision.changes) {
|
|
576
|
+
const current = "groups" in decision ? book.groupOf(read.id) : book.change(read.id);
|
|
577
|
+
if (current?.id !== read.id || current.revision !== read.revision) stale.add(read.id);
|
|
578
|
+
}
|
|
579
|
+
if (stale.size > 0) return { result: {
|
|
580
|
+
ids: [...stale],
|
|
581
|
+
status: "stale"
|
|
582
|
+
} };
|
|
583
|
+
for (const decision of [decisions].flat()) {
|
|
584
|
+
const decided = "groups" in decision ? decision.groups.flatMap((group) => book.members(group.id).map((entry) => entry.id)) : decision.changes.map((change) => change.id);
|
|
585
|
+
for (const id of decided) {
|
|
586
|
+
conflicting ||= (actions.get(id) ?? decision.action) !== decision.action;
|
|
587
|
+
actions.set(id, decision.action);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
const ids = [...actions.keys()];
|
|
591
|
+
if (conflicting) return { result: {
|
|
592
|
+
ids,
|
|
593
|
+
status: "invalid"
|
|
594
|
+
} };
|
|
595
|
+
if (ids.length === 0) return { result: {
|
|
596
|
+
ids,
|
|
597
|
+
status: "unchanged"
|
|
598
|
+
} };
|
|
599
|
+
const outcome = decide(value, {
|
|
600
|
+
actions,
|
|
601
|
+
token: createIncarnationId,
|
|
602
|
+
withdraws
|
|
603
|
+
}, {
|
|
604
|
+
book,
|
|
605
|
+
resolveSchema: authoredResolveSchemaOf(editor),
|
|
606
|
+
spares: spareGuardOver(getCompiledEditorSchema(editor), getEditorSchema(editor), value)
|
|
607
|
+
});
|
|
608
|
+
if (outcome.status === "blocked") return { result: {
|
|
609
|
+
ids,
|
|
610
|
+
status: "blocked",
|
|
611
|
+
with: outcome.with
|
|
612
|
+
} };
|
|
613
|
+
if (outcome.status === "invalid") return { result: {
|
|
614
|
+
ids,
|
|
615
|
+
status: "invalid"
|
|
616
|
+
} };
|
|
617
|
+
const { change, value: decidedValue, windowed: decided } = outcome;
|
|
618
|
+
const schema = getEditorSchema(editor);
|
|
619
|
+
try {
|
|
620
|
+
if (decided) schema.checkDocumentChange({
|
|
621
|
+
after: decidedValue,
|
|
622
|
+
before: value,
|
|
623
|
+
change,
|
|
624
|
+
indexedAfter: decided.indexedAfter,
|
|
625
|
+
indexedBefore: decided.indexedBefore
|
|
626
|
+
});
|
|
627
|
+
else schema.assertDocument(decidedValue);
|
|
628
|
+
} catch (error) {
|
|
629
|
+
if (isRefusal(error)) return { result: {
|
|
630
|
+
ids,
|
|
631
|
+
status: "invalid"
|
|
632
|
+
} };
|
|
633
|
+
throw error;
|
|
634
|
+
}
|
|
635
|
+
if (change.empty) return { result: {
|
|
636
|
+
ids: [],
|
|
637
|
+
status: "unchanged"
|
|
638
|
+
} };
|
|
639
|
+
return {
|
|
640
|
+
change,
|
|
641
|
+
result: {
|
|
642
|
+
ids: [...outcome.decided],
|
|
643
|
+
status: "applied"
|
|
644
|
+
},
|
|
645
|
+
settles: settlesTextAlone(value, change, [.../* @__PURE__ */ new Set([...ids, ...outcome.decided])], actions, (id) => book.occurrences(id), withdraws)
|
|
646
|
+
};
|
|
647
|
+
};
|
|
648
|
+
const decideOn = (editor, value, decisions, withdraws, apply) => readingCovered({
|
|
649
|
+
cover: () => void 0,
|
|
650
|
+
read: () => apply(decisionOn(editor, value, decisions, withdraws))
|
|
651
|
+
});
|
|
652
|
+
return definePlugin("authored", {
|
|
653
|
+
dependencies: [authoredRecords],
|
|
654
|
+
schema: authoredMarksSchema,
|
|
655
|
+
contributions: [documentAdmissionPoint.of(authoredAdmission), authoredDocumentCapabilityPoint.of({
|
|
656
|
+
claimsBreakBefore,
|
|
657
|
+
pending: (document) => indexAuthoredChanges(document).changes.size,
|
|
658
|
+
project: (document, projection, schema) => withoutGeneration(() => projectAuthoredDocumentUnder(document, projection, storedResolveSchemaOf(schema, document))),
|
|
659
|
+
projectDecided: (document, projection, schema) => projectAuthoredDocumentUnder(document, projection, storedResolveSchemaOf(schema, document)),
|
|
660
|
+
projectBlocks: (document, projection, schema, root, paths) => withoutGeneration(() => projectAuthoredBlocks(document, projection, storedResolveSchemaOf(schema, document), root, paths)),
|
|
661
|
+
repair: (document, schema) => admitDocument(authoredAdmission, document, schema).document,
|
|
662
|
+
spareBlock,
|
|
663
|
+
spareRoot
|
|
664
|
+
})],
|
|
665
|
+
api: ({ editor }) => ({
|
|
666
|
+
setView: (view) => {
|
|
667
|
+
if (("preview" in view || view.intent === "propose") && !storesGeneratedValues(getCompiledEditorSchema(editor))) {
|
|
668
|
+
publishEditorRefusal(editor, GENERATED_VALUES_REFUSAL);
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
requestView(editor, view);
|
|
672
|
+
},
|
|
673
|
+
subscribeRefusals: (listener) => subscribeEditorRefusals(editor, (refusal) => runEditorObserver(editor, "commit-listener", () => listener(refusal))),
|
|
674
|
+
subscribeChanges: (listener) => {
|
|
675
|
+
const runtime = getEditorRuntime(editor);
|
|
676
|
+
let publisher = PUBLISHERS.get(runtime);
|
|
677
|
+
if (!publisher) {
|
|
678
|
+
const ledger = ledgerOf(editor);
|
|
679
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
680
|
+
const sink = ledger.subscribe(storedValue(editor), previewModeOf(editor));
|
|
681
|
+
const publish = () => ledger.publish(storedValue(editor), sink, previewModeOf(editor), getEditorRuntimeRoot(editor));
|
|
682
|
+
let delivered = publish().delta;
|
|
683
|
+
publisher = {
|
|
684
|
+
ledger,
|
|
685
|
+
listeners,
|
|
686
|
+
sink,
|
|
687
|
+
stop: runtime.subscribe(() => {
|
|
688
|
+
const { delta, ranks } = publish();
|
|
689
|
+
const fresh = delta !== delivered;
|
|
690
|
+
const blocks = ranks.flatMap((rank) => {
|
|
691
|
+
const key = editor.key([rank]);
|
|
692
|
+
return key ? [key] : [];
|
|
693
|
+
});
|
|
694
|
+
delivered = delta;
|
|
695
|
+
if (blocks.length === 0 && (!fresh || delta.changed.length === 0 && delta.groups.length === 0 && delta.removed.length === 0)) return;
|
|
696
|
+
const view = Object.freeze({
|
|
697
|
+
blocks: Object.freeze(blocks),
|
|
698
|
+
changed: fresh ? delta.changed : [],
|
|
699
|
+
groups: fresh ? delta.groups : [],
|
|
700
|
+
removed: fresh ? delta.removed : []
|
|
701
|
+
});
|
|
702
|
+
notifyObservers(editor, listeners, "snapshot-listener", (each) => each(view));
|
|
703
|
+
})
|
|
704
|
+
};
|
|
705
|
+
PUBLISHERS.set(runtime, publisher);
|
|
706
|
+
}
|
|
707
|
+
const { ledger, listeners, sink, stop } = publisher;
|
|
708
|
+
listeners.add(listener);
|
|
709
|
+
return () => {
|
|
710
|
+
if (!listeners.delete(listener) || listeners.size > 0) return;
|
|
711
|
+
stop();
|
|
712
|
+
ledger.unsubscribe(sink);
|
|
713
|
+
PUBLISHERS.delete(runtime);
|
|
714
|
+
};
|
|
715
|
+
}
|
|
716
|
+
}),
|
|
717
|
+
read: ({ editor }) => ({
|
|
718
|
+
view: () => viewOf(editor),
|
|
719
|
+
change: (id) => changesOf(editor, storedValue(editor)).change(id),
|
|
720
|
+
changes: (query = {}) => {
|
|
721
|
+
const limit = query.limit ?? 50;
|
|
722
|
+
if (!Number.isSafeInteger(limit) || limit < 1 || limit > 200) throw new Error("Authored page limit must be between 1 and 200.");
|
|
723
|
+
const book = changesOf(editor, storedValue(editor));
|
|
724
|
+
const { cursor: _cursor, limit: _limit, ...rest } = query;
|
|
725
|
+
const fingerprint = JSON.stringify(query.at === void 0 ? rest : [
|
|
726
|
+
rest,
|
|
727
|
+
getEditorRuntimeRoot(editor),
|
|
728
|
+
previewModeOf(editor) ?? "stored"
|
|
729
|
+
]);
|
|
730
|
+
const inCard = query.group === void 0 ? null : book.inCard(query.group);
|
|
731
|
+
const at = query.at === void 0 ? null : placeIds(editor, book, query.at, viewPlacesOf(editor)).filter((id) => !inCard || inCard(id));
|
|
732
|
+
const matches = (id) => {
|
|
733
|
+
const change = getDefined(book.change(id));
|
|
734
|
+
return query.authorId === void 0 || change.authorId === query.authorId;
|
|
735
|
+
};
|
|
736
|
+
let start = null;
|
|
737
|
+
let after = false;
|
|
738
|
+
if (query.cursor !== void 0) {
|
|
739
|
+
const [text, next, last] = readCursor(query.cursor);
|
|
740
|
+
if (text !== fingerprint) throw new Error("Stale authored page cursor.");
|
|
741
|
+
if (book.has(next) && (!at || at.includes(next))) start = next;
|
|
742
|
+
else if (book.has(last) && (!at || at.includes(last))) {
|
|
743
|
+
start = last;
|
|
744
|
+
after = true;
|
|
745
|
+
} else throw new Error("Stale authored page cursor.");
|
|
746
|
+
}
|
|
747
|
+
const ids = at ? at.slice(start === null ? 0 : at.indexOf(start) + (after ? 1 : 0)) : book.idsFrom({
|
|
748
|
+
after,
|
|
749
|
+
group: query.group,
|
|
750
|
+
start
|
|
751
|
+
});
|
|
752
|
+
const items = [];
|
|
753
|
+
let next = null;
|
|
754
|
+
for (const id of ids) {
|
|
755
|
+
if (!matches(id)) continue;
|
|
756
|
+
if (items.length === limit) {
|
|
757
|
+
next = id;
|
|
758
|
+
break;
|
|
759
|
+
}
|
|
760
|
+
items.push(getDefined(book.change(id)));
|
|
761
|
+
}
|
|
762
|
+
return Object.freeze({
|
|
763
|
+
cursor: next === null ? null : JSON.stringify([
|
|
764
|
+
fingerprint,
|
|
765
|
+
next,
|
|
766
|
+
getDefined(items.at(-1)).id
|
|
767
|
+
]),
|
|
768
|
+
items: Object.freeze(items)
|
|
769
|
+
});
|
|
770
|
+
},
|
|
771
|
+
details: (id) => {
|
|
772
|
+
const book = changesOf(editor, storedValue(editor));
|
|
773
|
+
return readAuthoredDetails({
|
|
774
|
+
changes: { get: (change) => book.change(change) ?? void 0 },
|
|
775
|
+
occurrences: { get: (change) => book.occurrences(change) }
|
|
776
|
+
}, id);
|
|
777
|
+
},
|
|
778
|
+
groupOf: (changeId) => changesOf(editor, storedValue(editor)).groupOf(changeId),
|
|
779
|
+
outcome: (id) => {
|
|
780
|
+
const value = storedValue(editor);
|
|
781
|
+
return changesOf(editor, value).change(id) ? "pending" : factsOf(value).verdictOf(id);
|
|
782
|
+
},
|
|
783
|
+
groups: ({ at }) => {
|
|
784
|
+
const book = changesOf(editor, storedValue(editor));
|
|
785
|
+
return Object.freeze(book.cardsOf(placeIds(editor, book, at, viewPlacesOf(editor))));
|
|
786
|
+
},
|
|
787
|
+
reviewOf: (node) => {
|
|
788
|
+
const facts = factsOf(storedValue(editor));
|
|
789
|
+
const marks = marksOf(node, facts);
|
|
790
|
+
return Object.freeze({
|
|
791
|
+
accepted: Object.freeze(acceptedValues(node, standingClaimsOf(node, facts, facts).filter((mark) => mark.kind === "format"), {
|
|
792
|
+
accepted: (member) => isAccepted(facts, member),
|
|
793
|
+
landed: facts.landed,
|
|
794
|
+
output: elementSplitOutput(getCompiledEditorSchema(editor))
|
|
795
|
+
})),
|
|
796
|
+
hidden: isSettledDeletion(node, facts),
|
|
797
|
+
marks
|
|
798
|
+
});
|
|
799
|
+
}
|
|
800
|
+
}),
|
|
801
|
+
update: ({ editor, tx }) => {
|
|
802
|
+
const apply = (decided) => {
|
|
803
|
+
if (!("change" in decided)) return decided.result;
|
|
804
|
+
const update = getActiveEditorUpdateId(editor);
|
|
805
|
+
if (update) stateOf(editor).passThrough.add(update);
|
|
806
|
+
try {
|
|
807
|
+
if (decided.settles) applyDocumentChange(getEditorRuntimeOwner(editor), decided.change, { settles: "content" });
|
|
808
|
+
else tx.changes.apply(decided.change);
|
|
809
|
+
} catch (error) {
|
|
810
|
+
if (isRefusal(error)) return {
|
|
811
|
+
ids: decided.result.ids,
|
|
812
|
+
status: "invalid"
|
|
813
|
+
};
|
|
814
|
+
throw error;
|
|
815
|
+
}
|
|
816
|
+
return decided.result;
|
|
817
|
+
};
|
|
818
|
+
const decideCovered = (decisions, withdraws = false) => decideOn(editor, tx.value(), decisions, withdraws, apply);
|
|
819
|
+
return {
|
|
820
|
+
decide: txStored((decisions) => decideCovered(decisions)),
|
|
821
|
+
withdraw: txStored((changes) => {
|
|
822
|
+
const author = authorOf(getAuthoredUpdateView(editor));
|
|
823
|
+
if (changes.some((change) => change.authorId !== author)) return {
|
|
824
|
+
ids: changes.map((change) => change.id),
|
|
825
|
+
status: "invalid"
|
|
826
|
+
};
|
|
827
|
+
return decideCovered({
|
|
828
|
+
action: "reject",
|
|
829
|
+
changes
|
|
830
|
+
}, true);
|
|
831
|
+
}),
|
|
832
|
+
propose: txOnly((input = {}) => {
|
|
833
|
+
const state = stateOf(editor);
|
|
834
|
+
const update = getActiveEditorUpdateId(editor);
|
|
835
|
+
if (!update) throw new Error("Authored proposals require an active update.");
|
|
836
|
+
if (input.changeId !== void 0 && isEditingChange(input.changeId)) throw new Error(`Authored change ids starting with ${editingChangeOf("")} are reserved for Editing.`);
|
|
837
|
+
const changeId = input.changeId ?? createChangeId();
|
|
838
|
+
const value = tx.value();
|
|
839
|
+
const claim = state.marks.authorOf(changeId) === null ? null : claimOf(value, changeId);
|
|
840
|
+
const decided = !claim && (state.marks.authorOf(changeId) !== null || factsOf(value).verdictOf(changeId) !== null);
|
|
841
|
+
state.forced.set(update, claim ? {
|
|
842
|
+
at: claim.at,
|
|
843
|
+
changeId,
|
|
844
|
+
inc: claim.inc
|
|
845
|
+
} : {
|
|
846
|
+
at: now(),
|
|
847
|
+
changeId,
|
|
848
|
+
inc: decided ? createIncarnationId() : void 0
|
|
849
|
+
});
|
|
850
|
+
return changeId;
|
|
851
|
+
})
|
|
852
|
+
};
|
|
853
|
+
},
|
|
854
|
+
activate: ({ afterPublish, beforePublish, editor, onCleanup }) => {
|
|
855
|
+
const owner = getEditorRuntimeOwner(editor);
|
|
856
|
+
const state = {
|
|
857
|
+
authorId: () => authorOf(editor),
|
|
858
|
+
createChangeId,
|
|
859
|
+
forced: /* @__PURE__ */ new WeakMap(),
|
|
860
|
+
marks: createDocumentMarksValidator(),
|
|
861
|
+
passThrough: /* @__PURE__ */ new WeakSet(),
|
|
862
|
+
pending: /* @__PURE__ */ new WeakMap(),
|
|
863
|
+
refused: /* @__PURE__ */ new WeakMap(),
|
|
864
|
+
views: /* @__PURE__ */ new WeakMap()
|
|
865
|
+
};
|
|
866
|
+
if (options.intent) state.views.set(getBaseViewPresentation(owner), { intent: options.intent });
|
|
867
|
+
STATES.set(owner, state);
|
|
868
|
+
onCleanup(() => STATES.delete(owner));
|
|
869
|
+
const ledger = createReviewLedger(owner, () => authoredResolveSchemaOf(editor), state.marks);
|
|
870
|
+
const { holders } = ledger;
|
|
871
|
+
const spareBlocksOf = (value) => {
|
|
872
|
+
const schema = getCompiledEditorSchema(editor);
|
|
873
|
+
const generated = generatedOf(schema);
|
|
874
|
+
const indexes = contentRootsOf(value);
|
|
875
|
+
return {
|
|
876
|
+
indexes,
|
|
877
|
+
marked: (root) => holders.at({
|
|
878
|
+
contexts: factsOf(value),
|
|
879
|
+
generated,
|
|
880
|
+
schema
|
|
881
|
+
}, root, getDefined(indexes.get(root))).marked()
|
|
882
|
+
};
|
|
883
|
+
};
|
|
884
|
+
onCleanup(getEditorRuntime(owner).subscribeCommit((commit) => {
|
|
885
|
+
ledger.carry(commit);
|
|
886
|
+
if (commit.changes.createRoots.size > 0) ledger.buildProjectionAccepted(storedValue(editor));
|
|
887
|
+
}));
|
|
888
|
+
const builtPlacements = /* @__PURE__ */ new Map();
|
|
889
|
+
const leansFor = (preview) => builtPlacements.get(getPlacementGeneration(owner)) === preview;
|
|
890
|
+
onCleanup(subscribeCommittedPlacement(owner, (generation) => {
|
|
891
|
+
for (const placed of builtPlacements.keys()) if (placed !== generation) builtPlacements.delete(placed);
|
|
892
|
+
}));
|
|
893
|
+
onCleanup(registerAuthoredRuntime(owner, {
|
|
894
|
+
mapToView: (view, root, value) => {
|
|
895
|
+
const preview = previewModeOf(view);
|
|
896
|
+
if (!preview) return value;
|
|
897
|
+
const map = ledger.lens(storedValue(owner), preview).locations(root);
|
|
898
|
+
if (PathApi.isPath(value)) return map.path(value);
|
|
899
|
+
if (PointApi.isPoint(value)) return map.point(value, -1);
|
|
900
|
+
return map.range(value);
|
|
901
|
+
},
|
|
902
|
+
readStored: storedRead,
|
|
903
|
+
readView: (view, read) => {
|
|
904
|
+
const preview = previewModeOf(view);
|
|
905
|
+
if (!preview) return read();
|
|
906
|
+
const stored = storedValue(owner);
|
|
907
|
+
const root = withEditorDocumentProjection(owner, void 0, () => getCurrentSelectionRoot(owner));
|
|
908
|
+
return withEditorDocumentProjection(owner, ledger.preview(stored, preview), read, {
|
|
909
|
+
root,
|
|
910
|
+
selection: () => ledger.lens(stored, preview).toView(withEditorDocumentProjection(owner, void 0, () => getCurrentSelection(owner)), root, leansFor(preview))
|
|
911
|
+
});
|
|
912
|
+
},
|
|
913
|
+
requestView,
|
|
914
|
+
setView: (view, value) => {
|
|
915
|
+
state.views.set(getViewPresentation(view), value);
|
|
916
|
+
},
|
|
917
|
+
toStored: (view, root, target) => {
|
|
918
|
+
const preview = previewModeOf(view);
|
|
919
|
+
if (!preview) return {
|
|
920
|
+
kind: "stored",
|
|
921
|
+
target
|
|
922
|
+
};
|
|
923
|
+
const lifted = ledger.lens(storedValue(owner), preview).fromView(target, root);
|
|
924
|
+
if (lifted.kind === "stored" && lifted.shownInBuilt) builtPlacements.set(nextMintedGeneration(owner), preview);
|
|
925
|
+
return lifted;
|
|
926
|
+
},
|
|
927
|
+
view: viewOf,
|
|
928
|
+
viewCommit: (view, commit) => {
|
|
929
|
+
const preview = previewModeOf(view);
|
|
930
|
+
return preview ? ledger.previewCommit(commit, preview, leansFor(preview)) : commit;
|
|
931
|
+
}
|
|
932
|
+
}));
|
|
933
|
+
const passesThrough = () => {
|
|
934
|
+
const update = getActiveEditorUpdateId(editor);
|
|
935
|
+
return update !== null && state.passThrough.has(update);
|
|
936
|
+
};
|
|
937
|
+
let framed = false;
|
|
938
|
+
beforePublish(() => {
|
|
939
|
+
const value = editor.read.value();
|
|
940
|
+
({framed} = ledger.prepare(value));
|
|
941
|
+
if (storesSpares(getCompiledEditorSchema(editor))) {
|
|
942
|
+
const { indexes, marked } = spareBlocksOf(value);
|
|
943
|
+
for (const root of indexes.keys()) marked(root);
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
afterPublish(() => {
|
|
947
|
+
if (framed) prepareCommandFrame(editor);
|
|
948
|
+
const schema = getCompiledEditorSchema(editor);
|
|
949
|
+
if (storesSpares(schema)) ledger.shown.load(storedRead(editor, (stored) => stored.read.value()), schema);
|
|
950
|
+
});
|
|
951
|
+
onCleanup(registerEditorDraftGuard(editor, (value) => ledger.check(value)));
|
|
952
|
+
onCleanup(registerEditorContent(editor, (reader, node) => !isStruck(reader, node)));
|
|
953
|
+
onCleanup(registerEditorCommandDocument(editor, {
|
|
954
|
+
recorded: (input) => {
|
|
955
|
+
ledger.recorded(input);
|
|
956
|
+
const check = framedLawCheck();
|
|
957
|
+
if (check !== "0") assertFramedLaw(input, authoredResolveSchemaOf(editor), check !== "content", () => ledger.projectionMap(input.stored.value, "proposed"));
|
|
958
|
+
},
|
|
959
|
+
project: (value) => {
|
|
960
|
+
if (passesThrough() || isReplay(getActiveEditorUpdateTags(editor))) return null;
|
|
961
|
+
return ledger.frame(value);
|
|
962
|
+
},
|
|
963
|
+
refuse: unrepresentableFor,
|
|
964
|
+
unplaced
|
|
965
|
+
}));
|
|
966
|
+
onCleanup(registerEditorDraftView(editor, () => {
|
|
967
|
+
if (passesThrough() || isReplay(getActiveEditorUpdateTags(editor))) return false;
|
|
968
|
+
const update = getActiveEditorUpdateId(editor);
|
|
969
|
+
const viewEditor = getAuthoredUpdateView(editor);
|
|
970
|
+
settleWaitingView(viewEditor);
|
|
971
|
+
const view = viewOf(viewEditor);
|
|
972
|
+
return update !== null && state.forced.has(update) || "intent" in view && view.intent === "propose";
|
|
973
|
+
}));
|
|
974
|
+
const minted = /* @__PURE__ */ new WeakMap();
|
|
975
|
+
onCleanup(registerEditorDocumentRecorder(editor, (input) => {
|
|
976
|
+
if (isReplay(input.tags)) return null;
|
|
977
|
+
if (input.steps.length > 0 && input.steps.every((step) => step.origin === "migration")) return null;
|
|
978
|
+
if (passesThrough()) {
|
|
979
|
+
const relink = relinkCuts(input.change, input.before, input.after, (root) => rootOf(input.after, root));
|
|
980
|
+
return relink ? {
|
|
981
|
+
change: input.change.compose(relink.change),
|
|
982
|
+
selection: input.selection
|
|
983
|
+
} : null;
|
|
984
|
+
}
|
|
985
|
+
const update = getActiveEditorUpdateId(editor);
|
|
986
|
+
const forced = update ? state.forced.get(update) ?? null : null;
|
|
987
|
+
const viewEditor = getAuthoredUpdateView(editor);
|
|
988
|
+
settleWaitingView(viewEditor);
|
|
989
|
+
const updateView = viewOf(viewEditor);
|
|
990
|
+
const before = input.before;
|
|
991
|
+
const after = input.after;
|
|
992
|
+
const contentChange = contentChangeOf(input.change);
|
|
993
|
+
const steps = input.steps.map((step) => {
|
|
994
|
+
const change = contentChangeOf(step.change);
|
|
995
|
+
return change === step.change ? step : {
|
|
996
|
+
...step,
|
|
997
|
+
change
|
|
998
|
+
};
|
|
999
|
+
});
|
|
1000
|
+
const contentSteps = steps.filter((step) => step.origin !== "root");
|
|
1001
|
+
const ownRecords = getInternalDocumentChangeRecords(input.change);
|
|
1002
|
+
const known = factsOf(withStore(before, getValueRecords(after)));
|
|
1003
|
+
if ("preview" in updateView) throw new Error("A preview view does not take this write.");
|
|
1004
|
+
if (!input.projection) {
|
|
1005
|
+
const written = writtenNamedRoots(contentSteps);
|
|
1006
|
+
if (written.size > 0) {
|
|
1007
|
+
const dropped = ledger.dropped(before);
|
|
1008
|
+
if ([...written].some((root) => dropped.has(root))) throw unplaced();
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
const editing = !forced && updateView.intent === "edit";
|
|
1012
|
+
const writer = authorOf(viewEditor);
|
|
1013
|
+
if (writer === null) throw new Error("An author ID is required for authored writes.");
|
|
1014
|
+
const byName = contentChange.deleteRoots.size > 0 ? new Set(rootsDeletedByName(getCompiledEditorSchema(editor), input.projection?.value ?? before, after, changedRootsOf(contentChange), contentChange.deleteRoots)) : NO_ROOTS;
|
|
1015
|
+
if (!editing && byName.size > 0) throw unrepresentable("Suggesting cannot delete a named root; suggest deleting its content.");
|
|
1016
|
+
const followed = byName.size === 0 ? contentChange.deleteRoots : new Set([...contentChange.deleteRoots].filter((root) => !byName.has(root)));
|
|
1017
|
+
const createdThenDeleted = new Set(steps.flatMap((step) => [...step.change.createRoots].filter((root) => !contentChange.createRoots.has(root) && !before.roots?.[root])));
|
|
1018
|
+
const createRoots = createdThenDeleted.size === 0 ? contentChange.createRoots : /* @__PURE__ */ new Set([...contentChange.createRoots, ...createdThenDeleted]);
|
|
1019
|
+
const withdrawable = createdThenDeleted.size === 0 ? followed : /* @__PURE__ */ new Set([...followed, ...createdThenDeleted]);
|
|
1020
|
+
if (!editing) {
|
|
1021
|
+
const vetoes = options.vetoes === false || updateView.intent !== "propose" ? [] : getPluginContributions(editor, authoredVeto);
|
|
1022
|
+
const refusal = (update && state.refused.get(update)) ?? (!storesGeneratedValues(getCompiledEditorSchema(editor)) ? GENERATED_VALUES_REFUSAL : vetoes.length > 0 ? proposalRefusal(contentSteps, vetoes) : null);
|
|
1023
|
+
if (refusal) {
|
|
1024
|
+
if (update) state.refused.set(update, refusal);
|
|
1025
|
+
throw new EditorRefusalError(refusal, refusal.message);
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
const { composition } = input;
|
|
1029
|
+
const focusBefore = input.selectionBefore?.kind !== "text" ? null : PointApi.equals(input.selectionBefore.anchor, input.selectionBefore.focus) ? input.selectionBefore.focus : composition ? RangeApi.start(input.selectionBefore) : null;
|
|
1030
|
+
const compositionRoot = composition ? composition.place.root ?? input.selectionBeforeRoot : null;
|
|
1031
|
+
const selectionPosition = focusBefore ? positionOf(before, input.selectionBeforeRoot, focusBefore) : null;
|
|
1032
|
+
const minting = minted.get(input.update) ?? {
|
|
1033
|
+
at: forced?.at ?? now(),
|
|
1034
|
+
changeId: editing ? editingChangeOf(writer) : createChangeId()
|
|
1035
|
+
};
|
|
1036
|
+
minted.set(input.update, minting);
|
|
1037
|
+
const { at, changeId } = minting;
|
|
1038
|
+
const dependencies = createDependencies(known, carriedIn(after));
|
|
1039
|
+
let commitWrite;
|
|
1040
|
+
const commitWriteId = () => commitWrite ??= createTagId();
|
|
1041
|
+
const landedHere = (write) => editing && write === commitWrite || known.landed(write);
|
|
1042
|
+
const standing = {
|
|
1043
|
+
accepted: (member) => isAccepted(known, member),
|
|
1044
|
+
landed: landedHere
|
|
1045
|
+
};
|
|
1046
|
+
const compiled = getCompiledEditorSchema(editor);
|
|
1047
|
+
const oneText = (type) => holdsOneText(getEditorSchema(editor), type);
|
|
1048
|
+
const recorded = recordAuthoredSteps({
|
|
1049
|
+
before,
|
|
1050
|
+
changeId,
|
|
1051
|
+
composition: composition && compositionRoot !== null ? {
|
|
1052
|
+
element: composition.place.path.slice(0, -1),
|
|
1053
|
+
position: positionOf(before, compositionRoot, composition.place),
|
|
1054
|
+
root: compositionRoot
|
|
1055
|
+
} : null,
|
|
1056
|
+
createRoots,
|
|
1057
|
+
createTagId,
|
|
1058
|
+
crossesUnique: (from, to) => crossesUniqueTarget(compiled, from, to),
|
|
1059
|
+
holdsUnique: (type, key) => holdsUniqueKey(compiled, type, key),
|
|
1060
|
+
deleteRoots: byName,
|
|
1061
|
+
dependencies,
|
|
1062
|
+
fill: (site, root) => completeChildrenAt(editor, site.map(elementOf), [], root).children,
|
|
1063
|
+
followed,
|
|
1064
|
+
forcedChangeId: forced?.changeId ?? (editing ? changeId : null),
|
|
1065
|
+
projection: input.projection,
|
|
1066
|
+
inc: forced?.inc ?? null,
|
|
1067
|
+
gridRoles: gridRolesOf(compiled),
|
|
1068
|
+
isInline: (props) => getEditorSchema(editor).isInline(elementOf(props)),
|
|
1069
|
+
emptyTextKeeps: (key, value, parents, root) => {
|
|
1070
|
+
const [parent, ...ancestors] = parents.map(elementOf);
|
|
1071
|
+
return !getEditorSchema(editor).emptyTextDrops({
|
|
1072
|
+
ancestors,
|
|
1073
|
+
parent,
|
|
1074
|
+
root
|
|
1075
|
+
})?.(key, value);
|
|
1076
|
+
},
|
|
1077
|
+
keepsOnSplit: ({ continuation, path, reviewDraft, source }, root) => getEditorSchema(editor).elementSplitKeepsAt(elementOf(source), elementOf(continuation), {
|
|
1078
|
+
children: reviewDraft,
|
|
1079
|
+
path: [...path],
|
|
1080
|
+
root
|
|
1081
|
+
}),
|
|
1082
|
+
slotted: (type, root) => (authoredResolveSchemaOf(editor).content(type, root)?.prefix ?? 0) > 0,
|
|
1083
|
+
declaredIn: (element, ancestors, root) => getEditorSchema(editor).elementDeclaredPropertiesIn(elementOf(element), {
|
|
1084
|
+
ancestors: ancestors.map(elementOf),
|
|
1085
|
+
root
|
|
1086
|
+
}),
|
|
1087
|
+
splitKeepsIn: (source, continuation, place, root) => getEditorSchema(editor).elementSplitKeepsIn(elementOf(source), elementOf(continuation), {
|
|
1088
|
+
continuationAncestors: place.continuationAncestors.map(elementOf),
|
|
1089
|
+
continuationIndex: place.continuationIndex,
|
|
1090
|
+
root,
|
|
1091
|
+
sourceAncestors: place.sourceAncestors.map(elementOf)
|
|
1092
|
+
}),
|
|
1093
|
+
joinCompares: (key) => joinCompares(getCompiledEditorSchema(editor), key),
|
|
1094
|
+
maxChildren: (type, root) => authoredResolveSchemaOf(editor).content(type, root)?.max ?? null,
|
|
1095
|
+
now: at,
|
|
1096
|
+
oneText,
|
|
1097
|
+
ownedRoots: (props) => {
|
|
1098
|
+
return getEditorSchema(editor).getElementOwnedRoots(props).map(({ ownership, root }) => ({
|
|
1099
|
+
exclusive: ownership === "exclusive",
|
|
1100
|
+
root
|
|
1101
|
+
}));
|
|
1102
|
+
},
|
|
1103
|
+
selectionBefore: selectionPosition === null ? null : {
|
|
1104
|
+
position: selectionPosition,
|
|
1105
|
+
root: input.selectionBeforeRoot
|
|
1106
|
+
},
|
|
1107
|
+
schema: tracksPlaces(compiled) ? compiled : null,
|
|
1108
|
+
unique: uniquePropertiesOf(compiled),
|
|
1109
|
+
standing,
|
|
1110
|
+
steps,
|
|
1111
|
+
commitWriteId,
|
|
1112
|
+
writer
|
|
1113
|
+
});
|
|
1114
|
+
const map = {
|
|
1115
|
+
after,
|
|
1116
|
+
indexes: recorded.indexedAfter,
|
|
1117
|
+
map: recorded.mapPosition
|
|
1118
|
+
};
|
|
1119
|
+
const kept = [.../* @__PURE__ */ new Set([...visitRootNames(before.roots), ...recorded.indexedAfter.keys()])].filter((root) => root !== "main" && !byName.has(root));
|
|
1120
|
+
const beforeRecords = getValueRecords(before);
|
|
1121
|
+
const valueWith = (roots, indexes) => {
|
|
1122
|
+
const next = copyFields({}, before, ["records", "roots"]);
|
|
1123
|
+
setLazyRoot(next, "children", indexes.get("main") ?? rootIndexOf(before, "children"));
|
|
1124
|
+
if (roots.length > 0) {
|
|
1125
|
+
const named = {};
|
|
1126
|
+
for (const root of roots) {
|
|
1127
|
+
const index = indexes.get(root) ?? lazyRootOf(before.roots, root);
|
|
1128
|
+
if (index) setLazyRoot(named, root, index);
|
|
1129
|
+
else named[root] = valueRoot(before, root);
|
|
1130
|
+
}
|
|
1131
|
+
next.roots = named;
|
|
1132
|
+
}
|
|
1133
|
+
return withValueRecords(next, beforeRecords);
|
|
1134
|
+
};
|
|
1135
|
+
const withdrawn = withdrawable.size > 0 ? orphanedValueRoots(getCompiledEditorSchema(editor), before, valueWith(kept, recorded.indexedAfter), changedRootsOf(recorded.change), createdThenDeleted).filter((root) => withdrawable.has(root)) : [];
|
|
1136
|
+
const roots = withdrawn.length > 0 ? kept.filter((root) => !withdrawn.includes(root)) : kept;
|
|
1137
|
+
const valueOf = (indexes) => valueWith(roots, indexes);
|
|
1138
|
+
const unborn = withdrawn.filter((root) => createdThenDeleted.has(root));
|
|
1139
|
+
const deleted = withdrawn.filter((root) => !createdThenDeleted.has(root));
|
|
1140
|
+
const born = unborn.length > 0 ? filterDocumentChangeRoots(recorded.change, (root) => !unborn.includes(root)) : recorded.change;
|
|
1141
|
+
const recordedChange = deleted.length > 0 ? born.compose(createInternalDocumentChange(/* @__PURE__ */ new Map(), { deleteRoots: deleted }), before) : born;
|
|
1142
|
+
const written = valueOf(recorded.indexedAfter);
|
|
1143
|
+
const relink = relinkCuts(recordedChange, before, written, (root) => recorded.indexedAfter.get(root) ?? DocumentIndex.fromValue(valueRoot(written, root)));
|
|
1144
|
+
const change = relink ? recordedChange.compose(relink.change, before) : recordedChange;
|
|
1145
|
+
const indexes = relink ? new Map([...recorded.indexedAfter, ...relink.indexes]) : recorded.indexedAfter;
|
|
1146
|
+
const writtenPlain = editing && recorded.writtenPlain;
|
|
1147
|
+
const mark = {
|
|
1148
|
+
at,
|
|
1149
|
+
author: writer,
|
|
1150
|
+
change: forced?.changeId ?? changeId,
|
|
1151
|
+
...forced?.inc === void 0 ? {} : { inc: forced.inc }
|
|
1152
|
+
};
|
|
1153
|
+
const filled = writtenPlain ? null : completeProposed({
|
|
1154
|
+
after: valueOf(indexes),
|
|
1155
|
+
before,
|
|
1156
|
+
change,
|
|
1157
|
+
dependencies,
|
|
1158
|
+
editor,
|
|
1159
|
+
indexes,
|
|
1160
|
+
mark,
|
|
1161
|
+
standing,
|
|
1162
|
+
commitWriteId
|
|
1163
|
+
});
|
|
1164
|
+
const content = filled ? change.compose(filled.change, before) : change;
|
|
1165
|
+
const writtenIndexes = filled?.indexes ?? indexes;
|
|
1166
|
+
const accepted = editing && !writtenPlain ? acceptOwn(content, writtenIndexes, dependencies, {
|
|
1167
|
+
...known,
|
|
1168
|
+
landed: landedHere
|
|
1169
|
+
}) : null;
|
|
1170
|
+
const relinkedOwn = accepted && relinkCuts(accepted.change, valueOf(writtenIndexes), valueOf(accepted.indexes), (root) => accepted.indexes.get(root) ?? DocumentIndex.fromValue(valueRoot(valueOf(accepted.indexes), root)), (root) => writtenIndexes.get(root) ?? DocumentIndex.fromValue(valueRoot(before, root)));
|
|
1171
|
+
const owned = accepted && relinkedOwn ? {
|
|
1172
|
+
change: accepted.change.compose(relinkedOwn.change),
|
|
1173
|
+
indexes: new Map([...accepted.indexes, ...relinkedOwn.indexes]),
|
|
1174
|
+
landed: accepted.landed
|
|
1175
|
+
} : accepted;
|
|
1176
|
+
const through = (changes) => (root, position, assoc) => changes.reduce((mapped, later) => (later && getInternalDocumentRootChange(later, root)?.mapPos(mapped, assoc)) ?? mapped, position);
|
|
1177
|
+
const mapPosition = (root, position, assoc) => through([
|
|
1178
|
+
relink?.change,
|
|
1179
|
+
filled?.change,
|
|
1180
|
+
owned?.change
|
|
1181
|
+
])(root, recorded.mapPosition(root, position, assoc, false), assoc);
|
|
1182
|
+
const staysAfter = 1;
|
|
1183
|
+
const record = (draftSelection, root) => {
|
|
1184
|
+
const selection = mapSelection(draftSelection, {
|
|
1185
|
+
...map,
|
|
1186
|
+
root
|
|
1187
|
+
});
|
|
1188
|
+
const filledSelection = filled ? mapSelection(selection, {
|
|
1189
|
+
after: valueOf(indexes),
|
|
1190
|
+
indexes: filled.indexes,
|
|
1191
|
+
map: through([filled.change]),
|
|
1192
|
+
root
|
|
1193
|
+
}) : selection;
|
|
1194
|
+
return owned ? mapSelection(filledSelection, {
|
|
1195
|
+
after: valueOf(writtenIndexes),
|
|
1196
|
+
indexes: owned.indexes,
|
|
1197
|
+
map: through([owned.change]),
|
|
1198
|
+
root
|
|
1199
|
+
}, staysAfter) : filledSelection;
|
|
1200
|
+
};
|
|
1201
|
+
const recordedLater = owned ? content.compose(owned.change, before) : content;
|
|
1202
|
+
const recordedIndexes = owned?.indexes ?? writtenIndexes;
|
|
1203
|
+
const recordedRecords = [putContexts(restedOn(dependencies.minted(), recordedLater, recordedIndexes)), putLanded([...editing && commitWrite !== void 0 ? [landedOf({
|
|
1204
|
+
at,
|
|
1205
|
+
change: changeId,
|
|
1206
|
+
id: commitWrite
|
|
1207
|
+
})] : [], ...owned?.landed ?? []])].reduce(composeRecordOps, ownRecords);
|
|
1208
|
+
const deferred = (filled?.deferred ?? []).flatMap((build) => {
|
|
1209
|
+
if (!owned || build.path.length === 0) return [build];
|
|
1210
|
+
const { from } = getDefined(writtenIndexes.get(build.root)).nodeRange(build.path);
|
|
1211
|
+
const rootChange = getInternalDocumentRootChange(owned.change, build.root);
|
|
1212
|
+
const start = rootChange ? rootChange.mapPos(from, 1, "after") : from;
|
|
1213
|
+
const host = start === null ? null : recordedIndexes.get(build.root)?.nodeStartingAt(start);
|
|
1214
|
+
return host && host.from === start && host.kind === "element" ? [{
|
|
1215
|
+
...build,
|
|
1216
|
+
path: host.path
|
|
1217
|
+
}] : [];
|
|
1218
|
+
});
|
|
1219
|
+
const recordedValue = deriveValue(valueOf(recordedIndexes), {}, recordedRecords);
|
|
1220
|
+
const writes = storesSpares(compiled) ? sparesFor(recordedValue, compiled, changedSitesOf(recordedLater, recordedIndexes), deferred.map(({ index, ...build }) => ({
|
|
1221
|
+
...build,
|
|
1222
|
+
node: framedChild(valueRootIndex(after, build.root), build.path.length === 0 ? null : getDefined(recordedIndexes.get(build.root)).nodeRange(build.path).from, index, String(build.node.type), (position, assoc) => mapPosition(build.root, position, assoc)) ?? build.node,
|
|
1223
|
+
writer: owned ? null : mark
|
|
1224
|
+
})), spareBlocksOf(recordedValue)) : NO_SPARE_WRITES;
|
|
1225
|
+
const spares = writes.containers.length > 0 ? spareWritesChange(writes, recordedIndexes) : null;
|
|
1226
|
+
const spared = spares ? recordedLater.compose(spares.change, before) : recordedLater;
|
|
1227
|
+
const sparedIndexes = spares?.indexes ?? recordedIndexes;
|
|
1228
|
+
const records = composeRecordOps(recordedRecords, writes.records);
|
|
1229
|
+
const shown = storesSpares(compiled) ? closeCommandValues({
|
|
1230
|
+
before,
|
|
1231
|
+
change: spared,
|
|
1232
|
+
compiled,
|
|
1233
|
+
editing,
|
|
1234
|
+
frame: after,
|
|
1235
|
+
framed: !!input.projection,
|
|
1236
|
+
holders,
|
|
1237
|
+
indexes: sparedIndexes,
|
|
1238
|
+
peek: (values, read) => ledger.peek(values, read),
|
|
1239
|
+
standing,
|
|
1240
|
+
storedOf: (edited) => deriveValue(valueOf(edited), {}, records),
|
|
1241
|
+
writer: {
|
|
1242
|
+
...mark,
|
|
1243
|
+
commitWriteId,
|
|
1244
|
+
isOwn: (tag) => tag.change === mark.change
|
|
1245
|
+
}
|
|
1246
|
+
}) : null;
|
|
1247
|
+
const later = shown ? spared.compose(shown.change, before) : spared;
|
|
1248
|
+
const indexedAfter = shown?.indexes ?? sparedIndexes;
|
|
1249
|
+
const split = splitOneTextRefusal(later, indexedAfter, oneText);
|
|
1250
|
+
if (split) throw split;
|
|
1251
|
+
return {
|
|
1252
|
+
anchorChange: (plainAfter) => [
|
|
1253
|
+
filled?.change,
|
|
1254
|
+
owned?.change,
|
|
1255
|
+
spares?.change,
|
|
1256
|
+
shown?.change
|
|
1257
|
+
].reduce((anchor, next) => next ? anchor.compose(next) : anchor, recorded.anchorChange(plainAfter)),
|
|
1258
|
+
bookmarks: input.bookmarks.map(({ root, selection }) => record(selection, root)),
|
|
1259
|
+
change: withDocumentChangeRecords(later, records),
|
|
1260
|
+
indexedAfter,
|
|
1261
|
+
mapPosition,
|
|
1262
|
+
selection: record(input.selection, input.selectionRoot)
|
|
1263
|
+
};
|
|
1264
|
+
}));
|
|
1265
|
+
}
|
|
1266
|
+
});
|
|
1267
|
+
};
|
|
1268
|
+
/** Suggestions recorded as review marks in the document. */
|
|
1269
|
+
const authored = (options) => createAuthoredPlugin({ authorId: options.authorId });
|
|
1270
|
+
//#endregion
|
|
1271
|
+
export { AuthoredPlaceError, authored, authoredProposerOf, createAuthoredPlugin };
|