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,1103 @@
|
|
|
1
|
+
import { PathApi } from "../interfaces/path.js";
|
|
2
|
+
import { PointApi } from "../interfaces/point.js";
|
|
3
|
+
import { RangeApi } from "../interfaces/range.js";
|
|
4
|
+
import { TextApi } from "../interfaces/text.js";
|
|
5
|
+
import { reportEditorLifecycleError } from "../core/lifecycle-error.js";
|
|
6
|
+
import { NodeApi } from "../interfaces/node.js";
|
|
7
|
+
import { getPliteStringDirectPlacement } from "../dom/plugin/dom-geometry.js";
|
|
8
|
+
import { SOFT_LINE_END_SELECTOR, SOFT_LINE_FLAG } from "../dom/dom-soft-line-end.js";
|
|
9
|
+
import { invalidatePageLayoutEngines } from "./page-layout-engine-invalidation.internal.js";
|
|
10
|
+
import { createEstimatedPageLayoutEngine, createPretextPageLayoutEngine, measurePages, pageSettingsCodec } from "./index.js";
|
|
11
|
+
import { useEditorContext } from "../react/hooks/use-editor-context.js";
|
|
12
|
+
import { useEditorReadOnly } from "../react/hooks/use-editor-read-only.js";
|
|
13
|
+
import { toReactRuntimeEditor } from "../react/plugin/react-editor.js";
|
|
14
|
+
import { landInViewBlock, landOnViewLine, nearestViewText, placeOnViewText } from "../react/editable/view-lines.js";
|
|
15
|
+
import { useEditorState } from "../react/hooks/use-editor-selector.js";
|
|
16
|
+
import { useHydrated } from "../react/hooks/use-hydrated.js";
|
|
17
|
+
import { DecorationContext } from "../react/decoration-context.js";
|
|
18
|
+
import { createContainerDecorationSlice } from "../react/decoration-source.js";
|
|
19
|
+
import { ImperativeTextFlowContext } from "../react/components/editable-text-flow.js";
|
|
20
|
+
import { defaultScrollSelectionIntoView, getElementTransformScale } from "../react/components/editable.js";
|
|
21
|
+
import { getElementPlacementBox, pathKey } from "../react/components/editable-element-placement.js";
|
|
22
|
+
import { TextRenderScopeContext } from "../react/components/editable-text-pieces.js";
|
|
23
|
+
import { SurfaceRoot } from "../react/components/plite.js";
|
|
24
|
+
import { useElementPath } from "../react/hooks/use-element-path.js";
|
|
25
|
+
import { WindowedEditable } from "../react/components/windowed-editable.internal.js";
|
|
26
|
+
import { useEditableLayoutPass } from "../react/hooks/use-editable-layout-pass.js";
|
|
27
|
+
import { bounds, createPageLayoutGeometry, toCanvasRect } from "./page-geometry.internal.js";
|
|
28
|
+
import { createPagedEditablePageMountPlan, getPagedEditableVisiblePageMountItems } from "./page-mount-plan.js";
|
|
29
|
+
import { isNativeFlowBlock, pagedLineTarget, placedTextAt } from "./paged-view-lines.js";
|
|
30
|
+
import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
31
|
+
import { flushSync } from "react-dom";
|
|
32
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
33
|
+
//#region src/pagination/react.tsx
|
|
34
|
+
const lineStartAfterTrailingBreak = (editor, point) => editor.read((state) => {
|
|
35
|
+
const node = state.nodes.get(point.path)?.[0];
|
|
36
|
+
return TextApi.isText(node) && point.offset === node.text.length && node.text.endsWith("\n") ? state.points.after(point, { unit: "offset" }) ?? point : point;
|
|
37
|
+
});
|
|
38
|
+
const RUN_ATTRIBUTE = "data-pagination-run";
|
|
39
|
+
const createPagedViewLines = ({ editor, readLayout, readVersion, readViewport }) => ({
|
|
40
|
+
lineAfter: ({ direction, from, readX }) => {
|
|
41
|
+
const layout = readLayout();
|
|
42
|
+
if (!layout || layout.measuredVersion !== readVersion()) return null;
|
|
43
|
+
const upper = from.side === "upper";
|
|
44
|
+
const target = pagedLineTarget({
|
|
45
|
+
direction,
|
|
46
|
+
from: {
|
|
47
|
+
point: upper ? from.point : lineStartAfterTrailingBreak(editor, from.point),
|
|
48
|
+
upper
|
|
49
|
+
},
|
|
50
|
+
isSelectable: (path) => editor.read((state) => {
|
|
51
|
+
const start = state.points.start(path);
|
|
52
|
+
return !!start && !state.nodes.above({
|
|
53
|
+
at: start,
|
|
54
|
+
match: (node) => NodeApi.isElement(node) && !state.nodes.isSelectable(node),
|
|
55
|
+
mode: "highest",
|
|
56
|
+
voids: true
|
|
57
|
+
});
|
|
58
|
+
}),
|
|
59
|
+
mountedPageIndexes: layout.mountedPageIndexes,
|
|
60
|
+
selectedPaths: layout.selectedPaths,
|
|
61
|
+
snapshot: layout.snapshot
|
|
62
|
+
});
|
|
63
|
+
if (!target) return null;
|
|
64
|
+
const root = target.drawn ? layout.root : null;
|
|
65
|
+
const { path } = target;
|
|
66
|
+
return target.kind === "line" ? landOnViewLine({
|
|
67
|
+
editor,
|
|
68
|
+
end: target.end,
|
|
69
|
+
path,
|
|
70
|
+
readX,
|
|
71
|
+
root,
|
|
72
|
+
start: target.start
|
|
73
|
+
}) : landInViewBlock({
|
|
74
|
+
direction,
|
|
75
|
+
editor,
|
|
76
|
+
path,
|
|
77
|
+
readX,
|
|
78
|
+
root
|
|
79
|
+
});
|
|
80
|
+
},
|
|
81
|
+
placementAt: ({ reach, target, x, y }) => {
|
|
82
|
+
const layout = readLayout();
|
|
83
|
+
if (!layout?.root || !layout.canvas || !layout.geometry || layout.measuredVersion !== readVersion()) return null;
|
|
84
|
+
const { canvas, geometry, root } = layout;
|
|
85
|
+
const direct = getPliteStringDirectPlacement({
|
|
86
|
+
root,
|
|
87
|
+
target,
|
|
88
|
+
x,
|
|
89
|
+
y
|
|
90
|
+
});
|
|
91
|
+
if (direct) return direct;
|
|
92
|
+
const canvasRect = canvas.getBoundingClientRect();
|
|
93
|
+
const scale = geometry.height > 0 && canvasRect.height > 0 ? canvasRect.height / geometry.height : 1;
|
|
94
|
+
const viewport = readViewport();
|
|
95
|
+
const canvasY = (y - canvasRect.top) / scale;
|
|
96
|
+
const visibleY = viewport ? Math.min(Math.max(canvasY, viewport.top), viewport.bottom) : canvasY;
|
|
97
|
+
const point = {
|
|
98
|
+
x,
|
|
99
|
+
y: canvasRect.top + visibleY * scale
|
|
100
|
+
};
|
|
101
|
+
const placed = placedTextAt({
|
|
102
|
+
measureBlock: ({ path }) => {
|
|
103
|
+
const hit = nearestViewText({
|
|
104
|
+
editor,
|
|
105
|
+
root,
|
|
106
|
+
scopes: [{ path }],
|
|
107
|
+
target,
|
|
108
|
+
...point
|
|
109
|
+
});
|
|
110
|
+
return hit ? {
|
|
111
|
+
distance: [hit.vertical / scale, hit.horizontal / scale],
|
|
112
|
+
text: hit
|
|
113
|
+
} : null;
|
|
114
|
+
},
|
|
115
|
+
mountedPageIndexes: layout.mountedPageIndexes,
|
|
116
|
+
occupiedSizes: geometry.occupiedSizes,
|
|
117
|
+
pagePlacements: geometry.pagePlacements,
|
|
118
|
+
snapshot: layout.snapshot,
|
|
119
|
+
x: (x - canvasRect.left) / scale,
|
|
120
|
+
y: visibleY
|
|
121
|
+
});
|
|
122
|
+
const hit = placed?.kind === "line" ? nearestViewText({
|
|
123
|
+
editor,
|
|
124
|
+
root,
|
|
125
|
+
scopes: placed.box.line.runs.map((run, runIndex) => ({
|
|
126
|
+
path: run.source.anchor.path,
|
|
127
|
+
selector: `[${RUN_ATTRIBUTE}="${placed.box.fragment.pageIndex}:${placed.box.lineIndex}:${runIndex}"]`
|
|
128
|
+
})),
|
|
129
|
+
target: null,
|
|
130
|
+
...point
|
|
131
|
+
}) : placed?.text ?? null;
|
|
132
|
+
return hit ? placeOnViewText(hit, {
|
|
133
|
+
reach,
|
|
134
|
+
x
|
|
135
|
+
}) : null;
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
const createPublishedLayoutStore = () => {
|
|
139
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
140
|
+
let snapshot = null;
|
|
141
|
+
return {
|
|
142
|
+
getSnapshot: () => snapshot,
|
|
143
|
+
setSnapshot(next) {
|
|
144
|
+
if (snapshot === next) return;
|
|
145
|
+
snapshot = next;
|
|
146
|
+
listeners.forEach((listener) => listener());
|
|
147
|
+
},
|
|
148
|
+
subscribe(listener) {
|
|
149
|
+
listeners.add(listener);
|
|
150
|
+
return () => listeners.delete(listener);
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
const LAYOUT_STORE_BY_HOST = /* @__PURE__ */ new WeakMap();
|
|
155
|
+
const layoutHostListeners = /* @__PURE__ */ new Set();
|
|
156
|
+
const bindLayoutHost = (host, store) => {
|
|
157
|
+
LAYOUT_STORE_BY_HOST.set(host, store);
|
|
158
|
+
layoutHostListeners.forEach((listener) => listener());
|
|
159
|
+
return () => {
|
|
160
|
+
if (LAYOUT_STORE_BY_HOST.get(host) === store) {
|
|
161
|
+
LAYOUT_STORE_BY_HOST.delete(host);
|
|
162
|
+
layoutHostListeners.forEach((listener) => listener());
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
const usePageLayout = (editableRef) => {
|
|
167
|
+
return useSyncExternalStore(useCallback((listener) => {
|
|
168
|
+
let unsubscribeStore = () => {};
|
|
169
|
+
let currentStore;
|
|
170
|
+
const bind = () => {
|
|
171
|
+
const nextStore = editableRef.current ? LAYOUT_STORE_BY_HOST.get(editableRef.current) : void 0;
|
|
172
|
+
if (nextStore === currentStore) return;
|
|
173
|
+
unsubscribeStore();
|
|
174
|
+
currentStore = nextStore;
|
|
175
|
+
unsubscribeStore = nextStore?.subscribe(listener) ?? (() => {});
|
|
176
|
+
listener();
|
|
177
|
+
};
|
|
178
|
+
layoutHostListeners.add(bind);
|
|
179
|
+
bind();
|
|
180
|
+
return () => {
|
|
181
|
+
layoutHostListeners.delete(bind);
|
|
182
|
+
unsubscribeStore();
|
|
183
|
+
};
|
|
184
|
+
}, [editableRef]), useCallback(() => editableRef.current ? LAYOUT_STORE_BY_HOST.get(editableRef.current)?.getSnapshot() ?? null : null, [editableRef]), () => null);
|
|
185
|
+
};
|
|
186
|
+
const FragmentContext = createContext(null);
|
|
187
|
+
const usePageLayoutFragments = () => {
|
|
188
|
+
const context = useContext(FragmentContext);
|
|
189
|
+
const path = useElementPath();
|
|
190
|
+
return useMemo(() => context && path ? context.placementsByPath.get(pathKey(path)) ?? [] : [], [context, path]);
|
|
191
|
+
};
|
|
192
|
+
const EMPTY_DECORATIONS = Object.freeze([]);
|
|
193
|
+
const sameSlices = (left, right) => left === right || left.length === right.length && left.every((slice, index) => slice.key === right[index]?.key && slice.start === right[index]?.start && slice.end === right[index]?.end && JSON.stringify(slice.attributes) === JSON.stringify(right[index]?.attributes));
|
|
194
|
+
const createSurfaceDecorationStore = (inherited) => {
|
|
195
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
196
|
+
const listenersByNodeKey = /* @__PURE__ */ new Map();
|
|
197
|
+
const merged = /* @__PURE__ */ new Map();
|
|
198
|
+
let local = /* @__PURE__ */ new Map();
|
|
199
|
+
let version = 0;
|
|
200
|
+
let unsubscribeInherited = () => {};
|
|
201
|
+
const publish = (keys) => {
|
|
202
|
+
if (keys.length === 0) return;
|
|
203
|
+
version += 1;
|
|
204
|
+
keys.forEach((key) => {
|
|
205
|
+
merged.delete(key);
|
|
206
|
+
listenersByNodeKey.get(key)?.forEach((listener) => listener());
|
|
207
|
+
});
|
|
208
|
+
listeners.forEach((listener) => listener(keys));
|
|
209
|
+
};
|
|
210
|
+
return {
|
|
211
|
+
destroy() {
|
|
212
|
+
unsubscribeInherited();
|
|
213
|
+
listeners.clear();
|
|
214
|
+
listenersByNodeKey.clear();
|
|
215
|
+
merged.clear();
|
|
216
|
+
local.clear();
|
|
217
|
+
},
|
|
218
|
+
getNodeSnapshot(nodeKey) {
|
|
219
|
+
const cached = merged.get(nodeKey);
|
|
220
|
+
if (cached) return cached;
|
|
221
|
+
const inheritedSlices = inherited?.getNodeSnapshot(nodeKey) ?? EMPTY_DECORATIONS;
|
|
222
|
+
const localSlices = local.get(nodeKey) ?? EMPTY_DECORATIONS;
|
|
223
|
+
const next = inheritedSlices.length === 0 ? localSlices : localSlices.length === 0 ? inheritedSlices : Object.freeze([...inheritedSlices, ...localSlices]);
|
|
224
|
+
merged.set(nodeKey, next);
|
|
225
|
+
return next;
|
|
226
|
+
},
|
|
227
|
+
getVersion: () => version,
|
|
228
|
+
hasSources: () => Boolean(inherited?.hasSources() || local.size > 0),
|
|
229
|
+
mount() {
|
|
230
|
+
unsubscribeInherited = inherited?.subscribe((keys) => publish(keys)) ?? (() => {});
|
|
231
|
+
return () => {
|
|
232
|
+
unsubscribeInherited();
|
|
233
|
+
unsubscribeInherited = () => {};
|
|
234
|
+
};
|
|
235
|
+
},
|
|
236
|
+
setLocalBuckets(nextBuckets) {
|
|
237
|
+
const changed = /* @__PURE__ */ new Set([...local.keys(), ...nextBuckets.keys()]);
|
|
238
|
+
const next = /* @__PURE__ */ new Map();
|
|
239
|
+
changed.forEach((key) => {
|
|
240
|
+
const previousBucket = local.get(key) ?? EMPTY_DECORATIONS;
|
|
241
|
+
const candidate = nextBuckets.get(key) ?? EMPTY_DECORATIONS;
|
|
242
|
+
if (candidate.length > 0) next.set(key, sameSlices(previousBucket, candidate) ? previousBucket : candidate);
|
|
243
|
+
if (sameSlices(previousBucket, candidate)) changed.delete(key);
|
|
244
|
+
});
|
|
245
|
+
local = next;
|
|
246
|
+
publish([...changed]);
|
|
247
|
+
},
|
|
248
|
+
subscribe(listener) {
|
|
249
|
+
listeners.add(listener);
|
|
250
|
+
return () => listeners.delete(listener);
|
|
251
|
+
},
|
|
252
|
+
subscribeNodeKey(nodeKey, listener) {
|
|
253
|
+
const nodeListeners = listenersByNodeKey.get(nodeKey) ?? /* @__PURE__ */ new Set();
|
|
254
|
+
nodeListeners.add(listener);
|
|
255
|
+
listenersByNodeKey.set(nodeKey, nodeListeners);
|
|
256
|
+
return () => {
|
|
257
|
+
nodeListeners.delete(listener);
|
|
258
|
+
if (nodeListeners.size === 0) listenersByNodeKey.delete(nodeKey);
|
|
259
|
+
};
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
const FONT_OWNERS = /* @__PURE__ */ new WeakMap();
|
|
264
|
+
const attachFontView = (fonts, view) => {
|
|
265
|
+
let owner = FONT_OWNERS.get(fonts);
|
|
266
|
+
if (!owner) {
|
|
267
|
+
const views = /* @__PURE__ */ new Set();
|
|
268
|
+
const invalidate = () => {
|
|
269
|
+
if (views.size === 0) return;
|
|
270
|
+
invalidatePageLayoutEngines(new Set([...views].map((entry) => entry.engine)));
|
|
271
|
+
views.forEach((entry) => entry.invalidate());
|
|
272
|
+
};
|
|
273
|
+
fonts.addEventListener("loadingdone", invalidate);
|
|
274
|
+
fonts.addEventListener("loadingerror", invalidate);
|
|
275
|
+
fonts.ready.then(invalidate);
|
|
276
|
+
owner = {
|
|
277
|
+
cleanup: () => {
|
|
278
|
+
fonts.removeEventListener("loadingdone", invalidate);
|
|
279
|
+
fonts.removeEventListener("loadingerror", invalidate);
|
|
280
|
+
},
|
|
281
|
+
views
|
|
282
|
+
};
|
|
283
|
+
FONT_OWNERS.set(fonts, owner);
|
|
284
|
+
}
|
|
285
|
+
owner.views.add(view);
|
|
286
|
+
return () => {
|
|
287
|
+
owner?.views.delete(view);
|
|
288
|
+
if (owner?.views.size === 0) {
|
|
289
|
+
owner.cleanup();
|
|
290
|
+
FONT_OWNERS.delete(fonts);
|
|
291
|
+
}
|
|
292
|
+
};
|
|
293
|
+
};
|
|
294
|
+
const SCROLLABLE_OVERFLOW_PATTERN = /(auto|scroll|overlay)/;
|
|
295
|
+
const parseCSSPixels = (value) => {
|
|
296
|
+
if (!value || value === "auto" || value === "none") return 0;
|
|
297
|
+
const parsed = Number.parseFloat(value);
|
|
298
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
299
|
+
};
|
|
300
|
+
const canScroll = (element) => {
|
|
301
|
+
if (!element) return false;
|
|
302
|
+
const style = element.ownerDocument.defaultView?.getComputedStyle(element);
|
|
303
|
+
return SCROLLABLE_OVERFLOW_PATTERN.test(`${style?.overflow ?? ""} ${style?.overflowY ?? ""}`) && (element.clientHeight > 0 || parseCSSPixels(style?.height) > 0 || parseCSSPixels(style?.maxHeight) > 0);
|
|
304
|
+
};
|
|
305
|
+
const getScrollRoot = (element) => {
|
|
306
|
+
const editable = element?.querySelector("[data-editor=\"true\"]") ?? null;
|
|
307
|
+
if (canScroll(editable)) return editable;
|
|
308
|
+
let current = element;
|
|
309
|
+
while (current) {
|
|
310
|
+
if (canScroll(current)) return current;
|
|
311
|
+
current = current.parentElement;
|
|
312
|
+
}
|
|
313
|
+
return null;
|
|
314
|
+
};
|
|
315
|
+
const INACTIVE_VIEWPORT = {
|
|
316
|
+
canTrackContentViewport: false,
|
|
317
|
+
viewport: null
|
|
318
|
+
};
|
|
319
|
+
const EMPTY_PAGE_MOUNT_PLAN = {
|
|
320
|
+
itemIndexesByPath: /* @__PURE__ */ new Map(),
|
|
321
|
+
itemIndexesByTopLevelIndex: /* @__PURE__ */ new Map(),
|
|
322
|
+
items: []
|
|
323
|
+
};
|
|
324
|
+
const createViewportStore = () => {
|
|
325
|
+
const listeners = /* @__PURE__ */ new Set();
|
|
326
|
+
let root = null;
|
|
327
|
+
let geometryHeight = 0;
|
|
328
|
+
let cleanup = () => {};
|
|
329
|
+
let lastScrollAt = Number.NEGATIVE_INFINITY;
|
|
330
|
+
let snapshot = INACTIVE_VIEWPORT;
|
|
331
|
+
let measured = null;
|
|
332
|
+
const publish = (next, sync = false) => {
|
|
333
|
+
const commit = () => {
|
|
334
|
+
snapshot = next;
|
|
335
|
+
listeners.forEach((listener) => listener());
|
|
336
|
+
};
|
|
337
|
+
if (sync) flushSync(commit);
|
|
338
|
+
else commit();
|
|
339
|
+
};
|
|
340
|
+
const restart = () => {
|
|
341
|
+
cleanup();
|
|
342
|
+
if (listeners.size === 0 || !root) return;
|
|
343
|
+
const scrollRoot = getScrollRoot(root);
|
|
344
|
+
if (!scrollRoot) {
|
|
345
|
+
publish(INACTIVE_VIEWPORT);
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
const update = (sync = false) => {
|
|
349
|
+
if (!root) return;
|
|
350
|
+
const rootRect = root.getBoundingClientRect();
|
|
351
|
+
const scrollRect = scrollRoot.getBoundingClientRect();
|
|
352
|
+
const offset = root.contains(scrollRoot) ? scrollRoot.scrollTop : 0;
|
|
353
|
+
const scale = geometryHeight > 0 && rootRect.height > 0 ? rootRect.height / geometryHeight : 1;
|
|
354
|
+
const top = Math.max(0, (scrollRect.top - rootRect.top + offset) / scale);
|
|
355
|
+
measured = {
|
|
356
|
+
scale,
|
|
357
|
+
scrollRoot,
|
|
358
|
+
scrollTop: scrollRoot.scrollTop
|
|
359
|
+
};
|
|
360
|
+
publish({
|
|
361
|
+
canTrackContentViewport: true,
|
|
362
|
+
viewport: {
|
|
363
|
+
bottom: Math.max(top, (scrollRect.bottom - rootRect.top + offset) / scale),
|
|
364
|
+
top
|
|
365
|
+
}
|
|
366
|
+
}, sync);
|
|
367
|
+
};
|
|
368
|
+
const onScroll = () => {
|
|
369
|
+
lastScrollAt = performance.now();
|
|
370
|
+
update(true);
|
|
371
|
+
};
|
|
372
|
+
const onResize = () => update();
|
|
373
|
+
update();
|
|
374
|
+
scrollRoot.addEventListener("scroll", onScroll, { passive: true });
|
|
375
|
+
root.ownerDocument.defaultView?.addEventListener("resize", onResize);
|
|
376
|
+
const observer = typeof ResizeObserver === "undefined" ? null : new ResizeObserver(onResize);
|
|
377
|
+
observer?.observe(root);
|
|
378
|
+
observer?.observe(scrollRoot);
|
|
379
|
+
cleanup = () => {
|
|
380
|
+
scrollRoot.removeEventListener("scroll", onScroll);
|
|
381
|
+
root?.ownerDocument.defaultView?.removeEventListener("resize", onResize);
|
|
382
|
+
observer?.disconnect();
|
|
383
|
+
};
|
|
384
|
+
};
|
|
385
|
+
const getSnapshot = () => snapshot;
|
|
386
|
+
const readViewport = () => {
|
|
387
|
+
const { canTrackContentViewport, viewport } = snapshot;
|
|
388
|
+
if (!canTrackContentViewport || !viewport) return null;
|
|
389
|
+
const shift = measured ? (measured.scrollRoot.scrollTop - measured.scrollTop) / measured.scale : 0;
|
|
390
|
+
return {
|
|
391
|
+
bottom: viewport.bottom + shift,
|
|
392
|
+
top: viewport.top + shift
|
|
393
|
+
};
|
|
394
|
+
};
|
|
395
|
+
const subscribe = (listener) => {
|
|
396
|
+
listeners.add(listener);
|
|
397
|
+
if (listeners.size === 1) restart();
|
|
398
|
+
return () => {
|
|
399
|
+
listeners.delete(listener);
|
|
400
|
+
if (listeners.size === 0) {
|
|
401
|
+
cleanup();
|
|
402
|
+
cleanup = () => {};
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
};
|
|
406
|
+
return {
|
|
407
|
+
configure(nextRoot, nextHeight) {
|
|
408
|
+
root = nextRoot;
|
|
409
|
+
geometryHeight = nextHeight;
|
|
410
|
+
restart();
|
|
411
|
+
},
|
|
412
|
+
getLastScrollAt: () => lastScrollAt,
|
|
413
|
+
getSnapshot,
|
|
414
|
+
readViewport,
|
|
415
|
+
subscribe
|
|
416
|
+
};
|
|
417
|
+
};
|
|
418
|
+
const sameSelectedPaths = (left, right) => left === right || left !== null && left.length === right.length && left.every((path, index) => PathApi.equals(path, right[index]));
|
|
419
|
+
const selectedPathsFor = (selection) => selection ? [selection.anchor.path, selection.focus.path] : [];
|
|
420
|
+
const setRef = (ref, value) => {
|
|
421
|
+
if (typeof ref === "function") ref(value);
|
|
422
|
+
else if (ref) ref.current = value;
|
|
423
|
+
};
|
|
424
|
+
const createPlacementsByPath = (fragments, geometry) => {
|
|
425
|
+
const placements = /* @__PURE__ */ new Map();
|
|
426
|
+
const add = (path, placement) => {
|
|
427
|
+
const key = pathKey(path);
|
|
428
|
+
const values = placements.get(key) ?? [];
|
|
429
|
+
values.push(placement);
|
|
430
|
+
placements.set(key, values);
|
|
431
|
+
};
|
|
432
|
+
fragments.forEach((fragment) => {
|
|
433
|
+
add(fragment.path, {
|
|
434
|
+
pageIndex: fragment.pageIndex,
|
|
435
|
+
rect: toCanvasRect(fragment.rect, fragment.pageIndex, geometry)
|
|
436
|
+
});
|
|
437
|
+
if (fragment.type === "direct-children") fragment.children.forEach((child) => add(child.path, {
|
|
438
|
+
pageIndex: fragment.pageIndex,
|
|
439
|
+
rect: toCanvasRect(child.rect, fragment.pageIndex, geometry)
|
|
440
|
+
}));
|
|
441
|
+
});
|
|
442
|
+
return placements;
|
|
443
|
+
};
|
|
444
|
+
const boxRect = (rects) => {
|
|
445
|
+
const [first] = rects;
|
|
446
|
+
const sharesLeftEdge = rects.every((rect) => rect.left === first.left);
|
|
447
|
+
return {
|
|
448
|
+
rect: sharesLeftEdge ? bounds(rects) : first,
|
|
449
|
+
spillsPastBox: !sharesLeftEdge
|
|
450
|
+
};
|
|
451
|
+
};
|
|
452
|
+
const createElementLayouts = (fragments, placementsByPath, previous) => {
|
|
453
|
+
const paths = /* @__PURE__ */ new Map();
|
|
454
|
+
const textPaths = /* @__PURE__ */ new Set();
|
|
455
|
+
fragments.forEach((fragment) => {
|
|
456
|
+
paths.set(pathKey(fragment.path), fragment.path);
|
|
457
|
+
if (fragment.type === "text") textPaths.add(pathKey(fragment.path));
|
|
458
|
+
if (fragment.type === "direct-children") fragment.children.forEach((child) => paths.set(pathKey(child.path), child.path));
|
|
459
|
+
});
|
|
460
|
+
const boxes = /* @__PURE__ */ new Map();
|
|
461
|
+
placementsByPath.forEach((placements, key) => {
|
|
462
|
+
boxes.set(key, boxRect(placements.map((placement) => placement.rect)));
|
|
463
|
+
});
|
|
464
|
+
const layouts = /* @__PURE__ */ new Map();
|
|
465
|
+
paths.forEach((path, key) => {
|
|
466
|
+
const box = boxes.get(key);
|
|
467
|
+
if (!box) return;
|
|
468
|
+
let parent = path.slice(0, -1);
|
|
469
|
+
let parentRect;
|
|
470
|
+
while (parent.length > 0 && !parentRect) {
|
|
471
|
+
parentRect = boxes.get(pathKey(parent))?.rect;
|
|
472
|
+
parent = parent.slice(0, -1);
|
|
473
|
+
}
|
|
474
|
+
const layout = {
|
|
475
|
+
hasTextLines: textPaths.has(key),
|
|
476
|
+
height: box.rect.height,
|
|
477
|
+
left: box.rect.left - (parentRect?.left ?? 0),
|
|
478
|
+
spillsPastBox: box.spillsPastBox,
|
|
479
|
+
top: box.rect.top - (parentRect?.top ?? 0),
|
|
480
|
+
width: box.rect.width
|
|
481
|
+
};
|
|
482
|
+
const kept = previous.get(key);
|
|
483
|
+
layouts.set(key, kept && kept.hasTextLines === layout.hasTextLines && kept.height === layout.height && kept.left === layout.left && kept.spillsPastBox === layout.spillsPastBox && kept.top === layout.top && kept.width === layout.width ? kept : layout);
|
|
484
|
+
});
|
|
485
|
+
return layouts;
|
|
486
|
+
};
|
|
487
|
+
const EMPTY_ADMISSION = {
|
|
488
|
+
parked: [],
|
|
489
|
+
projected: []
|
|
490
|
+
};
|
|
491
|
+
const admitFragments = (fragments, mountedPageIndexes, mountedTopLevelIndexes) => {
|
|
492
|
+
const projected = [];
|
|
493
|
+
const parked = [];
|
|
494
|
+
fragments.forEach((fragment) => {
|
|
495
|
+
if (mountedPageIndexes.has(fragment.pageIndex)) projected.push(fragment);
|
|
496
|
+
else if (fragment.type === "text" && mountedTopLevelIndexes.has(fragment.path[0])) parked.push(fragment);
|
|
497
|
+
});
|
|
498
|
+
return {
|
|
499
|
+
parked,
|
|
500
|
+
projected
|
|
501
|
+
};
|
|
502
|
+
};
|
|
503
|
+
const sameItems = (left, right) => left.length === right.length && left.every((item, index) => item === right[index]);
|
|
504
|
+
const reuseUnchangedAdmission = (previous, next) => {
|
|
505
|
+
const sameProjected = sameItems(previous.projected, next.projected);
|
|
506
|
+
const sameParked = sameItems(previous.parked, next.parked);
|
|
507
|
+
if (sameProjected && sameParked) return previous;
|
|
508
|
+
return {
|
|
509
|
+
parked: sameParked ? previous.parked : next.parked,
|
|
510
|
+
projected: sameProjected ? previous.projected : next.projected
|
|
511
|
+
};
|
|
512
|
+
};
|
|
513
|
+
const PARK_INTERVALS = /* @__PURE__ */ new WeakMap();
|
|
514
|
+
const readParkIntervals = (fragment) => {
|
|
515
|
+
const cached = PARK_INTERVALS.get(fragment);
|
|
516
|
+
if (cached) return cached;
|
|
517
|
+
const intervals = /* @__PURE__ */ new Map();
|
|
518
|
+
fragment.lines.forEach((line) => line.runs.forEach(({ source }) => {
|
|
519
|
+
const key = pathKey(source.anchor.path);
|
|
520
|
+
const start = Math.min(source.anchor.offset, source.focus.offset);
|
|
521
|
+
const end = Math.max(source.anchor.offset, source.focus.offset);
|
|
522
|
+
const current = intervals.get(key);
|
|
523
|
+
intervals.set(key, {
|
|
524
|
+
end: Math.max(end, current?.end ?? end),
|
|
525
|
+
path: source.anchor.path,
|
|
526
|
+
start: Math.min(start, current?.start ?? start)
|
|
527
|
+
});
|
|
528
|
+
}));
|
|
529
|
+
const result = [...intervals.values()];
|
|
530
|
+
PARK_INTERVALS.set(fragment, result);
|
|
531
|
+
return result;
|
|
532
|
+
};
|
|
533
|
+
const NATIVE_FLOW_BREAK_RULE = `[${SOFT_LINE_FLAG}='true']::after{content:'\\A';white-space:pre}`;
|
|
534
|
+
const SOFT_LINE_END_RULE = `${SOFT_LINE_END_SELECTOR}::after{content:'\\A';white-space:pre}`;
|
|
535
|
+
const PARK_RULE = "[data-pagination-unmounted-page]{opacity:0;pointer-events:none}[data-pagination-unmounted-page],[data-pagination-unmounted-page] *{font-size:0!important;line-height:0!important;margin:0!important;padding:0!important;border-width:0!important}";
|
|
536
|
+
/**
|
|
537
|
+
* A line whose last character is a hard `\n` already breaks under the run's
|
|
538
|
+
* `white-space: pre`, so no run carries the native-flow break. A line that
|
|
539
|
+
* ends at an inline void's empty text breaks after the run before the void,
|
|
540
|
+
* because the void's renderer can wrap its text in an `inline-block`, as the
|
|
541
|
+
* registry mention does, and a forced break inside an inline-block ends that
|
|
542
|
+
* box's line, not the paragraph's.
|
|
543
|
+
*/
|
|
544
|
+
const nativeFlowBreakRunIndex = (line, readNode, isVoid) => {
|
|
545
|
+
const end = RangeApi.end(line.source);
|
|
546
|
+
const endIndex = line.runs.findIndex((run) => PointApi.equals(RangeApi.end(run.source), end));
|
|
547
|
+
const lastCharacter = line.runs.findLast((run, index) => index <= endIndex && RangeApi.isExpanded(run.source));
|
|
548
|
+
if (lastCharacter) {
|
|
549
|
+
const { offset, path } = RangeApi.end(lastCharacter.source);
|
|
550
|
+
const node = readNode(path);
|
|
551
|
+
if (TextApi.isText(node) && node.text[offset - 1] === "\n") return -1;
|
|
552
|
+
}
|
|
553
|
+
return line.runs.findLastIndex((run, index) => index <= endIndex && (RangeApi.isExpanded(run.source) || !isVoid(readNode(PathApi.parent(run.source.anchor.path)))));
|
|
554
|
+
};
|
|
555
|
+
const createPaginationBuckets = (editor, { parked, projected: fragments }, geometry, selectedPaths) => {
|
|
556
|
+
const buckets = /* @__PURE__ */ new Map();
|
|
557
|
+
const blockRects = /* @__PURE__ */ new Map();
|
|
558
|
+
const push = (nodeKey, slice) => {
|
|
559
|
+
const current = buckets.get(nodeKey) ?? [];
|
|
560
|
+
current.push(slice);
|
|
561
|
+
buckets.set(nodeKey, current);
|
|
562
|
+
};
|
|
563
|
+
fragments.forEach((fragment) => {
|
|
564
|
+
if (fragment.type !== "text") return;
|
|
565
|
+
const key = pathKey(fragment.path);
|
|
566
|
+
const rects = blockRects.get(key) ?? [];
|
|
567
|
+
rects.push(toCanvasRect(fragment.rect, fragment.pageIndex, geometry));
|
|
568
|
+
blockRects.set(key, rects);
|
|
569
|
+
});
|
|
570
|
+
const blockBoxes = /* @__PURE__ */ new Map();
|
|
571
|
+
blockRects.forEach((rects, key) => blockBoxes.set(key, boxRect(rects).rect));
|
|
572
|
+
editor.read((state) => {
|
|
573
|
+
const { index } = state.runtime.snapshot();
|
|
574
|
+
fragments.forEach((fragment) => {
|
|
575
|
+
if (fragment.type !== "text") return;
|
|
576
|
+
const blockKey = pathKey(fragment.path);
|
|
577
|
+
const nativeFlow = isNativeFlowBlock(fragment.path, blockRects.get(blockKey)?.length ?? 0, selectedPaths);
|
|
578
|
+
const blockRect = blockBoxes.get(blockKey) ?? toCanvasRect(fragment.rect, fragment.pageIndex, geometry);
|
|
579
|
+
fragment.lines.forEach((line, lineIndex) => {
|
|
580
|
+
const breakRunIndex = nativeFlow && lineIndex < fragment.lines.length - 1 ? nativeFlowBreakRunIndex(line, (path) => state.nodes.get(path)?.[0], (node) => NodeApi.isElement(node) && editor.read.schema.isVoid(node)) : -1;
|
|
581
|
+
line.runs.forEach((run, runIndex) => {
|
|
582
|
+
const nodeKey = index.keyAt(run.source.anchor.path);
|
|
583
|
+
if (!nodeKey) return;
|
|
584
|
+
const rangeStart = Math.min(run.source.anchor.offset, run.source.focus.offset);
|
|
585
|
+
const rangeEnd = Math.max(run.source.anchor.offset, run.source.focus.offset);
|
|
586
|
+
const rect = toCanvasRect(run.rect, fragment.pageIndex, geometry);
|
|
587
|
+
const runKey = `${fragment.pageIndex}:${lineIndex}:${runIndex}`;
|
|
588
|
+
const slice = createContainerDecorationSlice({
|
|
589
|
+
attributes: Object.freeze(nativeFlow ? {
|
|
590
|
+
"data-pagination-line": true,
|
|
591
|
+
[RUN_ATTRIBUTE]: runKey,
|
|
592
|
+
[SOFT_LINE_FLAG]: runIndex === breakRunIndex || void 0,
|
|
593
|
+
style: Object.freeze({ whiteSpace: "pre" })
|
|
594
|
+
} : {
|
|
595
|
+
"data-pagination-line": true,
|
|
596
|
+
[RUN_ATTRIBUTE]: runKey,
|
|
597
|
+
style: Object.freeze({
|
|
598
|
+
display: "inline-block",
|
|
599
|
+
height: rect.height,
|
|
600
|
+
left: `calc(${rect.left - blockRect.left}px - var(${RUN_ORIGIN_LEFT}, 0px))`,
|
|
601
|
+
lineHeight: `${rect.height}px`,
|
|
602
|
+
minWidth: rect.width === 0 ? 1 : void 0,
|
|
603
|
+
pointerEvents: "auto",
|
|
604
|
+
position: "absolute",
|
|
605
|
+
top: `calc(${rect.top - blockRect.top}px - var(${RUN_ORIGIN_TOP}, 0px))`,
|
|
606
|
+
whiteSpace: "pre",
|
|
607
|
+
width: rect.width
|
|
608
|
+
})
|
|
609
|
+
}),
|
|
610
|
+
end: rangeEnd,
|
|
611
|
+
key: `pagination:${fragment.pageIndex}:${blockKey}:${lineIndex}:${runIndex}`,
|
|
612
|
+
start: rangeStart
|
|
613
|
+
});
|
|
614
|
+
push(nodeKey, slice);
|
|
615
|
+
});
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
parked.forEach((fragment) => {
|
|
619
|
+
const blockKey = pathKey(fragment.path);
|
|
620
|
+
if (!blockBoxes.has(blockKey)) return;
|
|
621
|
+
readParkIntervals(fragment).forEach(({ end, path, start }) => {
|
|
622
|
+
const nodeKey = index.keyAt(path);
|
|
623
|
+
if (!nodeKey) return;
|
|
624
|
+
push(nodeKey, createContainerDecorationSlice({
|
|
625
|
+
attributes: Object.freeze({ "data-pagination-unmounted-page": fragment.pageIndex }),
|
|
626
|
+
end,
|
|
627
|
+
key: `pagination-park:${fragment.pageIndex}:${blockKey}:${pathKey(path)}`,
|
|
628
|
+
start
|
|
629
|
+
}));
|
|
630
|
+
});
|
|
631
|
+
});
|
|
632
|
+
});
|
|
633
|
+
return buckets;
|
|
634
|
+
};
|
|
635
|
+
const defaultRenderPage = ({ attributes }) => /* @__PURE__ */ jsx("div", { ...attributes });
|
|
636
|
+
const pageDependency = (page) => "margins" in page && "preset" in page ? `${page.preset}:${JSON.stringify(page.margins)}` : page;
|
|
637
|
+
const readEditorVersion = (editor) => editor.read((state) => state.lastCommit()?.version ?? state.runtime.snapshot().version);
|
|
638
|
+
const samePageLayoutSnapshot = (left, right) => left.version === right.version && JSON.stringify(left) === JSON.stringify(right);
|
|
639
|
+
const measurePagedEditable = (editor, options) => measurePages(editor, options);
|
|
640
|
+
const createPagedCanvasStyles = (geometry, style) => ({
|
|
641
|
+
editor: {
|
|
642
|
+
inset: 0,
|
|
643
|
+
pointerEvents: "auto",
|
|
644
|
+
position: "absolute"
|
|
645
|
+
},
|
|
646
|
+
host: {
|
|
647
|
+
...style,
|
|
648
|
+
minHeight: geometry.height,
|
|
649
|
+
position: "relative",
|
|
650
|
+
width: geometry.width,
|
|
651
|
+
zIndex: 0
|
|
652
|
+
},
|
|
653
|
+
overlay: {
|
|
654
|
+
height: geometry.height,
|
|
655
|
+
inset: 0,
|
|
656
|
+
pointerEvents: "none",
|
|
657
|
+
position: "absolute",
|
|
658
|
+
width: geometry.width,
|
|
659
|
+
zIndex: 1
|
|
660
|
+
},
|
|
661
|
+
root: {
|
|
662
|
+
minHeight: geometry.height,
|
|
663
|
+
position: "relative",
|
|
664
|
+
width: geometry.width
|
|
665
|
+
}
|
|
666
|
+
});
|
|
667
|
+
const RUN_ORIGIN_LEFT = "--editor-run-origin-left";
|
|
668
|
+
const RUN_ORIGIN_TOP = "--editor-run-origin-top";
|
|
669
|
+
const RUN_ORIGIN_TOLERANCE = .05;
|
|
670
|
+
const readRunOriginChanges = (root) => {
|
|
671
|
+
const changes = [];
|
|
672
|
+
const boxes = /* @__PURE__ */ new Map();
|
|
673
|
+
const parentRects = /* @__PURE__ */ new Map();
|
|
674
|
+
const runParents = /* @__PURE__ */ new Set();
|
|
675
|
+
root.querySelectorAll("[data-pagination-line]").forEach((run) => {
|
|
676
|
+
const runParent = run.parentElement;
|
|
677
|
+
if (run.style.position !== "absolute" || !runParent || runParents.has(runParent)) return;
|
|
678
|
+
runParents.add(runParent);
|
|
679
|
+
const { offsetParent } = run;
|
|
680
|
+
const block = run.closest("[data-editor-node=\"element\"]:not([data-editor-inline=\"true\"])");
|
|
681
|
+
if (!offsetParent || !block) return;
|
|
682
|
+
let box = boxes.get(block);
|
|
683
|
+
if (!box) {
|
|
684
|
+
const placed = getElementPlacementBox(block);
|
|
685
|
+
const rect = placed.getBoundingClientRect();
|
|
686
|
+
box = {
|
|
687
|
+
rect,
|
|
688
|
+
scale: getElementTransformScale(placed, rect)
|
|
689
|
+
};
|
|
690
|
+
boxes.set(block, box);
|
|
691
|
+
}
|
|
692
|
+
let parentRect = parentRects.get(offsetParent);
|
|
693
|
+
if (!parentRect) {
|
|
694
|
+
parentRect = offsetParent.getBoundingClientRect();
|
|
695
|
+
parentRects.set(offsetParent, parentRect);
|
|
696
|
+
}
|
|
697
|
+
const origin = {
|
|
698
|
+
[RUN_ORIGIN_LEFT]: (parentRect.left - box.rect.left) / box.scale.x + offsetParent.clientLeft,
|
|
699
|
+
[RUN_ORIGIN_TOP]: (parentRect.top - box.rect.top) / box.scale.y + offsetParent.clientTop
|
|
700
|
+
};
|
|
701
|
+
for (const property of [RUN_ORIGIN_LEFT, RUN_ORIGIN_TOP]) {
|
|
702
|
+
const current = Number.parseFloat(runParent.style.getPropertyValue(property));
|
|
703
|
+
if (Number.isNaN(current) || Math.abs(origin[property] - current) >= RUN_ORIGIN_TOLERANCE) changes.push([
|
|
704
|
+
runParent,
|
|
705
|
+
property,
|
|
706
|
+
`${Math.round(origin[property] * 100) / 100}px`
|
|
707
|
+
]);
|
|
708
|
+
}
|
|
709
|
+
});
|
|
710
|
+
return changes;
|
|
711
|
+
};
|
|
712
|
+
const readRunOriginWrite = (root) => {
|
|
713
|
+
const changes = readRunOriginChanges(root);
|
|
714
|
+
if (changes.length === 0) return null;
|
|
715
|
+
return () => {
|
|
716
|
+
changes.forEach(([runParent, property, value]) => runParent.style.setProperty(property, value));
|
|
717
|
+
};
|
|
718
|
+
};
|
|
719
|
+
const useReportEachNewMeasureFailure = (editor, error) => {
|
|
720
|
+
const lastReportedFailure = useRef(null);
|
|
721
|
+
useEffect(() => {
|
|
722
|
+
if (!error) {
|
|
723
|
+
lastReportedFailure.current = null;
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
const failure = error instanceof Error ? error.message : error;
|
|
727
|
+
if (Object.is(failure, lastReportedFailure.current)) return;
|
|
728
|
+
lastReportedFailure.current = failure;
|
|
729
|
+
reportEditorLifecycleError({
|
|
730
|
+
cause: error,
|
|
731
|
+
editor,
|
|
732
|
+
phase: "measure",
|
|
733
|
+
source: "pagination"
|
|
734
|
+
});
|
|
735
|
+
}, [editor, error]);
|
|
736
|
+
};
|
|
737
|
+
const PagedEditableInner = ({ engine: suppliedEngine, fragmentation, ignoreBlankEditableRootClicks = true, page, pageView, ref: forwardedRef, renderPage = defaultRenderPage, style, typography, virtualize = false, ...editableProps }) => {
|
|
738
|
+
const editor = useEditorContext();
|
|
739
|
+
const inheritedDecorations = useContext(DecorationContext);
|
|
740
|
+
const [fallbackEngine] = useState(() => createPretextPageLayoutEngine());
|
|
741
|
+
const engine = suppliedEngine ?? fallbackEngine;
|
|
742
|
+
const [fontEpoch, setFontEpoch] = useState(0);
|
|
743
|
+
const [editableHost, setEditableHost] = useState(null);
|
|
744
|
+
const rootRef = useRef(null);
|
|
745
|
+
const publishedStore = useMemo(createPublishedLayoutStore, []);
|
|
746
|
+
const decorationStore = useMemo(() => createSurfaceDecorationStore(inheritedDecorations), [inheritedDecorations]);
|
|
747
|
+
const [viewportStore] = useState(createViewportStore);
|
|
748
|
+
const selectedPaths = useEditorState((state) => selectedPathsFor(state.selection()), {
|
|
749
|
+
equalityFn: sameSelectedPaths,
|
|
750
|
+
shouldUpdate: (change) => !change || change.selectionChanged || change.changed.hasAny("structure")
|
|
751
|
+
});
|
|
752
|
+
const pageFieldKey = "margins" in page && "preset" in page ? null : page.key;
|
|
753
|
+
const [documentVersion, setDocumentVersion] = useState(() => readEditorVersion(editor));
|
|
754
|
+
const invalidationVersion = useRef(documentVersion);
|
|
755
|
+
useLayoutEffect(() => {
|
|
756
|
+
invalidationVersion.current = readEditorVersion(editor);
|
|
757
|
+
setDocumentVersion(invalidationVersion.current);
|
|
758
|
+
return editor.subscribeCommit((change) => {
|
|
759
|
+
if (change.changed.hasAny("document") || pageFieldKey !== null && change.dirtyStateKeys.includes(pageFieldKey)) {
|
|
760
|
+
invalidationVersion.current = change.version;
|
|
761
|
+
setDocumentVersion(change.version);
|
|
762
|
+
}
|
|
763
|
+
});
|
|
764
|
+
}, [editor, pageFieldKey]);
|
|
765
|
+
const dependency = pageDependency(page);
|
|
766
|
+
const canMeasure = useHydrated();
|
|
767
|
+
const measuredSnapshot = useRef(null);
|
|
768
|
+
const measurement = useMemo(() => {
|
|
769
|
+
if (!canMeasure) return {
|
|
770
|
+
error: null,
|
|
771
|
+
snapshot: null
|
|
772
|
+
};
|
|
773
|
+
try {
|
|
774
|
+
const snapshot = measurePagedEditable(editor, {
|
|
775
|
+
engine,
|
|
776
|
+
fragmentation,
|
|
777
|
+
page,
|
|
778
|
+
typography
|
|
779
|
+
});
|
|
780
|
+
if (readEditorVersion(editor) !== snapshot.version) return {
|
|
781
|
+
error: null,
|
|
782
|
+
snapshot: null
|
|
783
|
+
};
|
|
784
|
+
const previous = measuredSnapshot.current;
|
|
785
|
+
const stable = previous && samePageLayoutSnapshot(previous, snapshot) ? previous : snapshot;
|
|
786
|
+
measuredSnapshot.current = stable;
|
|
787
|
+
return {
|
|
788
|
+
error: null,
|
|
789
|
+
snapshot: stable
|
|
790
|
+
};
|
|
791
|
+
} catch (error) {
|
|
792
|
+
return {
|
|
793
|
+
error,
|
|
794
|
+
snapshot: null
|
|
795
|
+
};
|
|
796
|
+
}
|
|
797
|
+
}, [
|
|
798
|
+
canMeasure,
|
|
799
|
+
dependency,
|
|
800
|
+
documentVersion,
|
|
801
|
+
editor,
|
|
802
|
+
engine,
|
|
803
|
+
fontEpoch,
|
|
804
|
+
fragmentation,
|
|
805
|
+
typography
|
|
806
|
+
]);
|
|
807
|
+
const { snapshot } = measurement;
|
|
808
|
+
const gap = pageView?.gap ?? 24;
|
|
809
|
+
const mode = pageView?.mode ?? "single";
|
|
810
|
+
const geometry = useMemo(() => snapshot ? createPageLayoutGeometry({
|
|
811
|
+
fragments: snapshot.fragments,
|
|
812
|
+
gap,
|
|
813
|
+
mode,
|
|
814
|
+
pages: snapshot.pages
|
|
815
|
+
}) : null, [
|
|
816
|
+
gap,
|
|
817
|
+
mode,
|
|
818
|
+
snapshot
|
|
819
|
+
]);
|
|
820
|
+
useReportEachNewMeasureFailure(editor, measurement.error);
|
|
821
|
+
useLayoutEffect(() => decorationStore.mount(), [decorationStore]);
|
|
822
|
+
useEffect(() => () => decorationStore.destroy(), [decorationStore]);
|
|
823
|
+
useLayoutEffect(() => {
|
|
824
|
+
if (!editableHost) return void 0;
|
|
825
|
+
return bindLayoutHost(editableHost, publishedStore);
|
|
826
|
+
}, [editableHost, publishedStore]);
|
|
827
|
+
useLayoutEffect(() => {
|
|
828
|
+
publishedStore.setSnapshot(snapshot);
|
|
829
|
+
}, [publishedStore, snapshot]);
|
|
830
|
+
const viewLayout = useRef(null);
|
|
831
|
+
const viewLines = useMemo(() => createPagedViewLines({
|
|
832
|
+
editor: toReactRuntimeEditor(editor),
|
|
833
|
+
readLayout: () => viewLayout.current,
|
|
834
|
+
readVersion: () => invalidationVersion.current,
|
|
835
|
+
readViewport: viewportStore.readViewport
|
|
836
|
+
}), [editor, viewportStore]);
|
|
837
|
+
useEffect(() => {
|
|
838
|
+
const fonts = editableHost?.ownerDocument.fonts;
|
|
839
|
+
if (!fonts) return void 0;
|
|
840
|
+
return attachFontView(fonts, {
|
|
841
|
+
engine,
|
|
842
|
+
invalidate: () => setFontEpoch((value) => value + 1)
|
|
843
|
+
});
|
|
844
|
+
}, [editableHost, engine]);
|
|
845
|
+
const editableRef = useCallback((host) => {
|
|
846
|
+
setEditableHost(host);
|
|
847
|
+
setRef(forwardedRef, host);
|
|
848
|
+
}, [forwardedRef]);
|
|
849
|
+
const pageMountPlan = useMemo(() => snapshot && geometry ? createPagedEditablePageMountPlan({
|
|
850
|
+
fragments: snapshot.fragments,
|
|
851
|
+
geometry,
|
|
852
|
+
mode,
|
|
853
|
+
pages: snapshot.pages
|
|
854
|
+
}) : EMPTY_PAGE_MOUNT_PLAN, [
|
|
855
|
+
geometry,
|
|
856
|
+
mode,
|
|
857
|
+
snapshot
|
|
858
|
+
]);
|
|
859
|
+
useLayoutEffect(() => {
|
|
860
|
+
viewportStore.configure(rootRef.current, geometry?.height ?? 0);
|
|
861
|
+
}, [geometry?.height, viewportStore]);
|
|
862
|
+
const viewportState = useSyncExternalStore(viewportStore.subscribe, viewportStore.getSnapshot, () => INACTIVE_VIEWPORT);
|
|
863
|
+
const visibleItems = useMemo(() => virtualize ? getPagedEditableVisiblePageMountItems(pageMountPlan, {
|
|
864
|
+
gap,
|
|
865
|
+
overscan: 0,
|
|
866
|
+
pages: snapshot?.pages ?? [],
|
|
867
|
+
virtualizes: true,
|
|
868
|
+
viewport: viewportState.canTrackContentViewport ? viewportState.viewport : null
|
|
869
|
+
}) : pageMountPlan.items, [
|
|
870
|
+
gap,
|
|
871
|
+
pageMountPlan,
|
|
872
|
+
snapshot?.pages,
|
|
873
|
+
viewportState,
|
|
874
|
+
virtualize
|
|
875
|
+
]);
|
|
876
|
+
const [promotedPath, setPromotedPath] = useState(null);
|
|
877
|
+
const windowedItems = useMemo(() => {
|
|
878
|
+
const requiredItemIndexes = new Set(visibleItems.map((item) => item.index));
|
|
879
|
+
[...selectedPaths, promotedPath].forEach((path) => {
|
|
880
|
+
if (!path) return;
|
|
881
|
+
let ownerPath = path;
|
|
882
|
+
let itemIndexes;
|
|
883
|
+
while (ownerPath.length > 0 && !itemIndexes) {
|
|
884
|
+
itemIndexes = pageMountPlan.itemIndexesByPath.get(pathKey(ownerPath));
|
|
885
|
+
ownerPath = ownerPath.slice(0, -1);
|
|
886
|
+
}
|
|
887
|
+
itemIndexes?.forEach((itemIndex) => requiredItemIndexes.add(itemIndex));
|
|
888
|
+
});
|
|
889
|
+
return pageMountPlan.items.filter((item) => requiredItemIndexes.has(item.index));
|
|
890
|
+
}, [
|
|
891
|
+
pageMountPlan,
|
|
892
|
+
promotedPath,
|
|
893
|
+
selectedPaths,
|
|
894
|
+
visibleItems
|
|
895
|
+
]);
|
|
896
|
+
const visiblePageIndexes = useMemo(() => new Set(windowedItems.flatMap((item) => item.pageIndexes)), [windowedItems]);
|
|
897
|
+
const previousMountedTopLevelIndexes = useRef([]);
|
|
898
|
+
const mountedTopLevelIndexes = useMemo(() => {
|
|
899
|
+
const next = [...new Set(windowedItems.flatMap((item) => item.topLevelIndexes))].sort((left, right) => left - right);
|
|
900
|
+
const previous = previousMountedTopLevelIndexes.current;
|
|
901
|
+
if (sameItems(previous, next)) return previous;
|
|
902
|
+
previousMountedTopLevelIndexes.current = next;
|
|
903
|
+
return next;
|
|
904
|
+
}, [windowedItems]);
|
|
905
|
+
const previousAdmission = useRef(EMPTY_ADMISSION);
|
|
906
|
+
const admission = useMemo(() => {
|
|
907
|
+
const fragments = snapshot?.fragments ?? [];
|
|
908
|
+
const next = virtualize ? admitFragments(fragments, visiblePageIndexes, new Set(mountedTopLevelIndexes)) : {
|
|
909
|
+
parked: EMPTY_ADMISSION.parked,
|
|
910
|
+
projected: fragments
|
|
911
|
+
};
|
|
912
|
+
const kept = reuseUnchangedAdmission(previousAdmission.current, next);
|
|
913
|
+
previousAdmission.current = kept;
|
|
914
|
+
return kept;
|
|
915
|
+
}, [
|
|
916
|
+
mountedTopLevelIndexes,
|
|
917
|
+
snapshot?.fragments,
|
|
918
|
+
virtualize,
|
|
919
|
+
visiblePageIndexes
|
|
920
|
+
]);
|
|
921
|
+
const projectedFragments = admission.projected;
|
|
922
|
+
const placementsByPath = useMemo(() => geometry ? createPlacementsByPath(projectedFragments, geometry) : /* @__PURE__ */ new Map(), [geometry, projectedFragments]);
|
|
923
|
+
const previousElementLayouts = useRef(/* @__PURE__ */ new Map());
|
|
924
|
+
const elementLayouts = useMemo(() => {
|
|
925
|
+
if (!geometry) return void 0;
|
|
926
|
+
const layouts = createElementLayouts(snapshot?.fragments ?? [], placementsByPath, previousElementLayouts.current);
|
|
927
|
+
previousElementLayouts.current = layouts;
|
|
928
|
+
return layouts;
|
|
929
|
+
}, [
|
|
930
|
+
geometry,
|
|
931
|
+
placementsByPath,
|
|
932
|
+
snapshot?.fragments
|
|
933
|
+
]);
|
|
934
|
+
useLayoutEffect(() => {
|
|
935
|
+
viewLayout.current = snapshot ? {
|
|
936
|
+
canvas: rootRef.current,
|
|
937
|
+
geometry,
|
|
938
|
+
measuredVersion: documentVersion,
|
|
939
|
+
mountedPageIndexes: virtualize ? visiblePageIndexes : "all",
|
|
940
|
+
root: editableHost,
|
|
941
|
+
selectedPaths,
|
|
942
|
+
snapshot
|
|
943
|
+
} : null;
|
|
944
|
+
}, [
|
|
945
|
+
documentVersion,
|
|
946
|
+
editableHost,
|
|
947
|
+
geometry,
|
|
948
|
+
selectedPaths,
|
|
949
|
+
snapshot,
|
|
950
|
+
virtualize,
|
|
951
|
+
visiblePageIndexes
|
|
952
|
+
]);
|
|
953
|
+
const localBuckets = useMemo(() => geometry ? createPaginationBuckets(editor, admission, geometry, selectedPaths) : /* @__PURE__ */ new Map(), [
|
|
954
|
+
admission,
|
|
955
|
+
editor,
|
|
956
|
+
geometry,
|
|
957
|
+
selectedPaths
|
|
958
|
+
]);
|
|
959
|
+
useEditableLayoutPass(editor, editableHost, "Pagination run origins", readRunOriginWrite);
|
|
960
|
+
const fragmentContext = useMemo(() => ({ placementsByPath }), [placementsByPath]);
|
|
961
|
+
useLayoutEffect(() => {
|
|
962
|
+
decorationStore.setLocalBuckets(localBuckets);
|
|
963
|
+
}, [decorationStore, localBuckets]);
|
|
964
|
+
const scrollSelectionIntoView = useMemo(() => {
|
|
965
|
+
const custom = editableProps.scrollSelectionIntoView;
|
|
966
|
+
return ((innerEditor, domRange) => {
|
|
967
|
+
if (virtualize && performance.now() - viewportStore.getLastScrollAt() < 500) return;
|
|
968
|
+
if (custom) custom(innerEditor, domRange);
|
|
969
|
+
else defaultScrollSelectionIntoView(editor, domRange);
|
|
970
|
+
});
|
|
971
|
+
}, [
|
|
972
|
+
editableProps.scrollSelectionIntoView,
|
|
973
|
+
editor,
|
|
974
|
+
viewportStore,
|
|
975
|
+
virtualize
|
|
976
|
+
]);
|
|
977
|
+
const scrollToPath = useCallback((path, align = "auto") => {
|
|
978
|
+
const index = path[0];
|
|
979
|
+
const itemIndex = typeof index === "number" ? pageMountPlan.itemIndexesByTopLevelIndex.get(index)?.[0] : void 0;
|
|
980
|
+
const item = itemIndex === void 0 ? void 0 : pageMountPlan.items[itemIndex];
|
|
981
|
+
const scrollRoot = getScrollRoot(rootRef.current);
|
|
982
|
+
if (!item || !scrollRoot) return false;
|
|
983
|
+
const viewportHeight = Math.max(1, scrollRoot.clientHeight || scrollRoot.getBoundingClientRect().height);
|
|
984
|
+
const top = align === "center" ? item.start - (viewportHeight - item.size) / 2 : align === "end" ? item.start - viewportHeight + item.size : item.start;
|
|
985
|
+
scrollRoot.scrollTo({ top: Math.max(0, top) });
|
|
986
|
+
return true;
|
|
987
|
+
}, [pageMountPlan]);
|
|
988
|
+
const { pageArrayIndex, pageByIndex } = useMemo(() => {
|
|
989
|
+
const pages = snapshot?.pages ?? [];
|
|
990
|
+
return {
|
|
991
|
+
pageArrayIndex: new Map(pages.map((value, index) => [value.index, index])),
|
|
992
|
+
pageByIndex: new Map(pages.map((value) => [value.index, value]))
|
|
993
|
+
};
|
|
994
|
+
}, [snapshot?.pages]);
|
|
995
|
+
const canvas = geometry && createPagedCanvasStyles(geometry, style);
|
|
996
|
+
return /* @__PURE__ */ jsx(FragmentContext, {
|
|
997
|
+
value: fragmentContext,
|
|
998
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
999
|
+
"data-editor-paged-editable": true,
|
|
1000
|
+
"data-editor-paged-editable-page-virtualization": canvas && virtualize ? "true" : void 0,
|
|
1001
|
+
ref: rootRef,
|
|
1002
|
+
style: canvas?.root,
|
|
1003
|
+
children: [
|
|
1004
|
+
/* @__PURE__ */ jsx("style", {
|
|
1005
|
+
href: "editor-pagination-native-flow-break",
|
|
1006
|
+
precedence: "editor",
|
|
1007
|
+
children: NATIVE_FLOW_BREAK_RULE
|
|
1008
|
+
}),
|
|
1009
|
+
/* @__PURE__ */ jsx("style", {
|
|
1010
|
+
href: "editor-pagination-park",
|
|
1011
|
+
precedence: "editor",
|
|
1012
|
+
children: PARK_RULE
|
|
1013
|
+
}),
|
|
1014
|
+
/* @__PURE__ */ jsx("style", {
|
|
1015
|
+
href: "editor-pagination-soft-line-end",
|
|
1016
|
+
precedence: "editor",
|
|
1017
|
+
children: SOFT_LINE_END_RULE
|
|
1018
|
+
}),
|
|
1019
|
+
geometry && (virtualize ? windowedItems : pageMountPlan.items).flatMap((item) => item.pageIndexes.map((pageIndex) => {
|
|
1020
|
+
const layoutPage = pageByIndex.get(pageIndex);
|
|
1021
|
+
const arrayIndex = pageArrayIndex.get(pageIndex);
|
|
1022
|
+
if (!layoutPage || arrayIndex === void 0) return null;
|
|
1023
|
+
const placement = geometry.pagePlacements[arrayIndex] ?? {
|
|
1024
|
+
left: 0,
|
|
1025
|
+
top: 0
|
|
1026
|
+
};
|
|
1027
|
+
const occupied = geometry.occupiedSizes[arrayIndex] ?? layoutPage;
|
|
1028
|
+
const attributes = {
|
|
1029
|
+
"data-editor-page": true,
|
|
1030
|
+
"data-editor-page-index": layoutPage.index,
|
|
1031
|
+
style: {
|
|
1032
|
+
boxSizing: "border-box",
|
|
1033
|
+
height: layoutPage.height,
|
|
1034
|
+
overflow: "hidden",
|
|
1035
|
+
pointerEvents: "none",
|
|
1036
|
+
position: "relative",
|
|
1037
|
+
width: layoutPage.width
|
|
1038
|
+
}
|
|
1039
|
+
};
|
|
1040
|
+
return /* @__PURE__ */ jsx("div", {
|
|
1041
|
+
"data-editor-page-mount-item-index": item.index,
|
|
1042
|
+
"data-editor-page-surface": true,
|
|
1043
|
+
style: {
|
|
1044
|
+
height: occupied.height,
|
|
1045
|
+
left: placement.left,
|
|
1046
|
+
pointerEvents: "none",
|
|
1047
|
+
position: "absolute",
|
|
1048
|
+
top: placement.top,
|
|
1049
|
+
width: occupied.width
|
|
1050
|
+
},
|
|
1051
|
+
children: renderPage({
|
|
1052
|
+
attributes,
|
|
1053
|
+
page: layoutPage
|
|
1054
|
+
})
|
|
1055
|
+
}, layoutPage.index);
|
|
1056
|
+
})),
|
|
1057
|
+
/* @__PURE__ */ jsx("div", {
|
|
1058
|
+
"data-editor-paged-editable-editor-overlay": true,
|
|
1059
|
+
style: canvas?.overlay,
|
|
1060
|
+
children: /* @__PURE__ */ jsx("div", {
|
|
1061
|
+
"data-editor-paged-editable-editor": true,
|
|
1062
|
+
style: canvas?.editor,
|
|
1063
|
+
children: /* @__PURE__ */ jsx(ImperativeTextFlowContext, {
|
|
1064
|
+
value: false,
|
|
1065
|
+
children: /* @__PURE__ */ jsx(TextRenderScopeContext, {
|
|
1066
|
+
value: "paged",
|
|
1067
|
+
children: /* @__PURE__ */ jsx(WindowedEditable, {
|
|
1068
|
+
...editableProps,
|
|
1069
|
+
decorationStore,
|
|
1070
|
+
elementLayouts,
|
|
1071
|
+
enabled: Boolean(canvas) && virtualize,
|
|
1072
|
+
ignoreBlankEditableRootClicks,
|
|
1073
|
+
mountedTopLevelIndexes,
|
|
1074
|
+
onRequestMount: (index, path) => setPromotedPath(path ?? [index]),
|
|
1075
|
+
ref: editableRef,
|
|
1076
|
+
scrollSelectionIntoView,
|
|
1077
|
+
scrollToPath,
|
|
1078
|
+
style: canvas ? canvas.host : style,
|
|
1079
|
+
totalSize: geometry?.height ?? 0,
|
|
1080
|
+
viewLines
|
|
1081
|
+
})
|
|
1082
|
+
})
|
|
1083
|
+
})
|
|
1084
|
+
})
|
|
1085
|
+
})
|
|
1086
|
+
]
|
|
1087
|
+
})
|
|
1088
|
+
});
|
|
1089
|
+
};
|
|
1090
|
+
const PagedEditable = ({ root, ...props }) => {
|
|
1091
|
+
if (root === "main") throw new Error("Omit root to render the primary document.");
|
|
1092
|
+
const editor = useEditorContext();
|
|
1093
|
+
const inheritedReadOnly = useEditorReadOnly();
|
|
1094
|
+
const editable = /* @__PURE__ */ jsx(PagedEditableInner, { ...props });
|
|
1095
|
+
return root === void 0 ? editable : /* @__PURE__ */ jsx(SurfaceRoot, {
|
|
1096
|
+
editor,
|
|
1097
|
+
readOnly: props.readOnly || inheritedReadOnly,
|
|
1098
|
+
root,
|
|
1099
|
+
children: editable
|
|
1100
|
+
});
|
|
1101
|
+
};
|
|
1102
|
+
//#endregion
|
|
1103
|
+
export { PagedEditable, createEstimatedPageLayoutEngine, createPretextPageLayoutEngine, measurePages, pageSettingsCodec, usePageLayout, usePageLayoutFragments };
|