reactive-md 0.6.1 → 0.8.0
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/CHANGELOG-ch.md +66 -0
- package/CHANGELOG.md +66 -0
- package/CONTRIBUTING-ch.md +6 -62
- package/CONTRIBUTING.md +5 -63
- package/README-ch.md +232 -67
- package/README-en.md +209 -71
- package/README.md +209 -71
- package/SECURITY-ch.md +3 -1
- package/SECURITY.md +3 -1
- package/THIRD_PARTY_NOTICES.md +1909 -87
- package/cli/args.mjs +33 -1
- package/cli/build.mjs +62 -1
- package/cli/check.mjs +444 -0
- package/cli/help.mjs +181 -3
- package/cli/init.mjs +1577 -0
- package/cli/main.mjs +11 -1
- package/cli/package-loader.mjs +41 -0
- package/dist-library/LocalDocumentView-6trX7xJc.js +97920 -0
- package/dist-library/{authoring-BEVyth5X.js → authoring-BsfSwQRm.js} +237 -209
- package/dist-library/compiler--ea2CKQF.js +61 -0
- package/dist-library/compiler-core-kPiH-gOV.js +11805 -0
- package/dist-library/component-state-Cq2K5gkS.js +490 -0
- package/dist-library/component-state-D_cw_EHe.js +54 -0
- package/dist-library/config-validation-DXTynAw7.js +3005 -0
- package/dist-library/default-components-Z_YMio5P.js +2346 -0
- package/dist-library/identity-MYJXKSkB.js +1443 -0
- package/dist-library/math-display-BJz4gbFc.js +24000 -0
- package/dist-library/math-sample-BGEW49zY.js +1124 -0
- package/dist-library/options-CX5m5n-J.js +115 -0
- package/dist-library/parser-standard-DlCk7sLo.js +10122 -0
- package/dist-library/props-DGlBk0e5.js +183 -0
- package/dist-library/react-ByOHunUW.js +122 -0
- package/dist-library/reactive-md-authoring.js +712 -1077
- package/dist-library/reactive-md-build.js +7966 -0
- package/dist-library/reactive-md-compiler-standard.js +33 -0
- package/dist-library/reactive-md-compiler.js +22 -0
- package/dist-library/reactive-md-default-packs.js +71 -0
- package/dist-library/reactive-md-default-preset.js +10 -0
- package/dist-library/reactive-md-export.js +111 -0
- package/dist-library/reactive-md-print.css +18 -3
- package/dist-library/reactive-md-react-runtime.js +251 -0
- package/dist-library/reactive-md-react-server.js +55 -0
- package/dist-library/reactive-md-react-unstyled.js +9 -1
- package/dist-library/reactive-md-react.js +9 -1
- package/dist-library/reactive-md-runtime-browser.js +51 -0
- package/dist-library/reactive-md-runtime.js +3 -0
- package/dist-library/reactive-md-sdk.js +6 -0
- package/dist-library/reactive-md-standalone-host.js +442 -0
- package/dist-library/reactive-md-testing-browser.js +523 -0
- package/dist-library/reactive-md-testing-react.js +221 -0
- package/dist-library/reactive-md-testing.js +638 -0
- package/dist-library/reactive-md-vite.js +959 -0
- package/dist-library/reactive-md.css +1 -1
- package/dist-library/reactive-md.js +1080 -795
- package/dist-library/registry-B9Jc3FVe.js +1174 -0
- package/dist-library/resources-BGt8mpDA.js +204 -0
- package/dist-library/runtime-C-sbfpOX.js +1157 -0
- package/dist-library/runtime-Dkq7ldyg.js +172 -0
- package/dist-library/schema-ZFufO8V0.js +39 -0
- package/dist-library/shareable-DDVL4Fi9.js +844 -0
- package/dist-library/types/authoring/catalog.d.ts +168 -0
- package/dist-library/types/authoring/conformance.d.ts +24 -0
- package/dist-library/types/{editor → authoring}/editor-i18n.d.ts +3 -24
- package/dist-library/types/authoring/extensions.d.ts +13 -0
- package/dist-library/types/authoring/index.d.ts +14 -11
- package/dist-library/types/authoring/insert.d.ts +16 -0
- package/dist-library/types/{editor → authoring}/native-components.d.ts +19 -2
- package/dist-library/types/authoring/templates.d.ts +65 -0
- package/dist-library/types/build/diagnostics.d.ts +8 -0
- package/dist-library/types/build/digest.d.ts +5 -0
- package/dist-library/types/build/entry.d.ts +9 -0
- package/dist-library/types/build/host.d.ts +36 -0
- package/dist-library/types/build/index.d.ts +99 -0
- package/dist-library/types/build/notices.d.ts +29 -0
- package/dist-library/types/build/resources.d.ts +60 -0
- package/dist-library/types/build/vite.d.ts +15 -0
- package/dist-library/types/compiler/index.d.ts +22 -0
- package/dist-library/types/compiler/result.d.ts +30 -0
- package/dist-library/types/compiler/standard.d.ts +16 -0
- package/dist-library/types/compiler/types.d.ts +69 -0
- package/dist-library/types/components/chart-motion.d.ts +12 -0
- package/dist-library/types/components/controls.d.ts +21 -0
- package/dist-library/types/{local → components}/data-table.d.ts +10 -24
- package/dist-library/types/components/default-chart-types.d.ts +22 -0
- package/dist-library/types/components/default-chart.d.ts +2 -0
- package/dist-library/types/components/default-preset.d.ts +10 -0
- package/dist-library/types/components/diagram-inspector.d.ts +24 -0
- package/dist-library/types/components/gallery.d.ts +6 -0
- package/dist-library/types/components/layout.d.ts +23 -0
- package/dist-library/types/components/mafs-plot-grid.d.ts +57 -0
- package/dist-library/types/components/mafs-visuals.d.ts +40 -0
- package/dist-library/types/components/numeric-sliders.d.ts +3 -0
- package/dist-library/types/components/uiarc/calendar/calendar.d.ts +26 -0
- package/dist-library/types/components/uiarc/date-picker/date-picker.d.ts +29 -0
- package/dist-library/types/components/uiarc/lib/motion-tokens.d.ts +2 -0
- package/dist-library/types/components/uiarc/lib/use-today.d.ts +2 -0
- package/dist-library/types/components/uiarc/motion-tokens.d.ts +60 -0
- package/dist-library/types/components/uiarc/rmd-motion.d.ts +12 -0
- package/dist-library/types/components/uiarc/select/select.d.ts +21 -0
- package/dist-library/types/components/uiarc/slider/slider.d.ts +53 -0
- package/dist-library/types/components/use-hydrated.d.ts +6 -0
- package/dist-library/types/components/visuals.d.ts +13 -0
- package/dist-library/types/export/component-state.d.ts +39 -0
- package/dist-library/types/export/index.d.ts +47 -0
- package/dist-library/types/export/requirements.d.ts +23 -0
- package/dist-library/types/export/resources.d.ts +8 -0
- package/dist-library/types/export/restoration.d.ts +52 -0
- package/dist-library/types/index.d.ts +1 -0
- package/dist-library/types/local/compilation/compiler-core.d.ts +16 -0
- package/dist-library/types/local/compilation/compiler-services.d.ts +64 -0
- package/dist-library/types/local/compilation/compiler-structure.d.ts +46 -0
- package/dist-library/types/local/compilation/compiler-values.d.ts +9 -0
- package/dist-library/types/local/compilation/compiler.d.ts +34 -0
- package/dist-library/types/local/compilation/component-kernel.d.ts +487 -0
- package/dist-library/types/local/{dependencies.d.ts → compilation/dependencies.d.ts} +4 -3
- package/dist-library/types/local/{diagnostics.d.ts → configuration/diagnostic-messages.d.ts} +193 -65
- package/dist-library/types/local/configuration/diagnostics.d.ts +58 -0
- package/dist-library/types/local/{limits.d.ts → configuration/limits.d.ts} +15 -2
- package/dist-library/types/local/configuration/options-core.d.ts +120 -0
- package/dist-library/types/local/configuration/options.d.ts +17 -0
- package/dist-library/types/local/configuration/portable-options.d.ts +3 -0
- package/dist-library/types/local/configuration/schema-core.d.ts +32 -0
- package/dist-library/types/local/configuration/schema.d.ts +12 -0
- package/dist-library/types/local/contracts/types.d.ts +519 -0
- package/dist-library/types/local/{version.d.ts → contracts/version.d.ts} +1 -1
- package/dist-library/types/local/{computations.d.ts → evaluation/computations.d.ts} +6 -3
- package/dist-library/types/local/{expression.d.ts → evaluation/expression.d.ts} +2 -2
- package/dist-library/types/local/{math-display.d.ts → evaluation/math-display.d.ts} +2 -16
- package/dist-library/types/local/evaluation/math-sample.d.ts +23 -0
- package/dist-library/types/local/evaluation/math.d.ts +73 -0
- package/dist-library/types/local/{validation.d.ts → evaluation/validation.d.ts} +1 -1
- package/dist-library/types/local/html/html-details.d.ts +16 -0
- package/dist-library/types/local/html/html-entities.d.ts +7 -0
- package/dist-library/types/local/html/html-policy.d.ts +43 -0
- package/dist-library/types/local/html/html-recovery.d.ts +16 -0
- package/dist-library/types/local/html/html-table-names.d.ts +9 -0
- package/dist-library/types/local/{html-table.d.ts → html/html-table.d.ts} +2 -6
- package/dist-library/types/local/{html.d.ts → html/html.d.ts} +1 -1
- package/dist-library/types/local/index.d.ts +31 -24
- package/dist-library/types/local/markdown/fast-markdown.d.ts +137 -0
- package/dist-library/types/local/{footnotes.d.ts → markdown/footnotes.d.ts} +1 -1
- package/dist-library/types/local/{heading-anchors.d.ts → markdown/heading-anchors.d.ts} +12 -2
- package/dist-library/types/local/markdown/markdown-blocks.d.ts +55 -0
- package/dist-library/types/local/markdown/markdown-structure.d.ts +3 -0
- package/dist-library/types/local/markdown/plain-paragraphs.d.ts +10 -0
- package/dist-library/types/local/parsing/lexical.d.ts +21 -0
- package/dist-library/types/local/parsing/parse-budget.d.ts +67 -0
- package/dist-library/types/local/parsing/parser-capabilities.d.ts +42 -0
- package/dist-library/types/local/parsing/parser-core.d.ts +65 -0
- package/dist-library/types/local/parsing/parser-standard.d.ts +7 -0
- package/dist-library/types/local/parsing/parser.d.ts +16 -0
- package/dist-library/types/local/parsing/rmd-recovery.d.ts +48 -0
- package/dist-library/types/local/{LocalDocumentView.d.ts → rendering/LocalDocumentView.d.ts} +67 -24
- package/dist-library/types/local/rendering/legacy-component-adapter.d.ts +36 -0
- package/dist-library/types/local/rendering/render-types.d.ts +57 -0
- package/dist-library/types/local/rendering/view-revision.d.ts +75 -0
- package/dist-library/types/local/{retention.d.ts → runtime/retention.d.ts} +1 -1
- package/dist-library/types/local/runtime/runtime.d.ts +34 -0
- package/dist-library/types/local/{state.d.ts → runtime/state.d.ts} +4 -4
- package/dist-library/types/local/session/compiler-cache.d.ts +44 -0
- package/dist-library/types/local/session/incremental.d.ts +48 -0
- package/dist-library/types/local/session/parse-session.d.ts +62 -0
- package/dist-library/types/local/session/row-reuse.d.ts +46 -0
- package/dist-library/types/local/{authoring.d.ts → source/authoring.d.ts} +11 -3
- package/dist-library/types/local/source/node-walk.d.ts +3 -0
- package/dist-library/types/local/source/source-context.d.ts +63 -0
- package/dist-library/types/local/{source-migration.d.ts → source/source-migration.d.ts} +2 -2
- package/dist-library/types/local/{i18n.d.ts → theme/i18n.d.ts} +2 -2
- package/dist-library/types/local/theme/theme-name.d.ts +3 -0
- package/dist-library/types/local/{theme.d.ts → theme/theme.d.ts} +3 -3
- package/dist-library/types/local/transport/compile-patch.d.ts +127 -0
- package/dist-library/types/local/{compiled-data.d.ts → transport/compiled-data.d.ts} +1 -1
- package/dist-library/types/local/transport/flat-compiled-data.d.ts +17 -0
- package/dist-library/types/local/transport/shared-data.d.ts +10 -0
- package/dist-library/types/local/transport/worker.d.ts +265 -0
- package/dist-library/types/local/widgets/visuals.d.ts +25 -0
- package/dist-library/types/presets/default-authoring.d.ts +50 -0
- package/dist-library/types/presets/default-components.d.ts +4 -0
- package/dist-library/types/presets/default-semantics.d.ts +8 -0
- package/dist-library/types/presets/default.d.ts +11 -0
- package/dist-library/types/presets/identity.d.ts +7 -0
- package/dist-library/types/presets/packs.d.ts +4 -0
- package/dist-library/types/react/component-api.d.ts +260 -0
- package/dist-library/types/react/component-primitives.d.ts +21 -0
- package/dist-library/types/react/component-utils.d.ts +125 -0
- package/dist-library/types/react/default-theme.d.ts +6 -0
- package/dist-library/types/react/field-validation.d.ts +11 -0
- package/dist-library/types/react/index.d.ts +17 -5
- package/dist-library/types/react/overflow-text-tooltip.d.ts +6 -0
- package/dist-library/types/react/package.d.ts +69 -0
- package/dist-library/types/react/runtime/common.d.ts +4 -0
- package/dist-library/types/react/runtime/index.d.ts +8 -0
- package/dist-library/types/react/runtime/useComponentState.d.ts +30 -0
- package/dist-library/types/react/runtime/useKeys.d.ts +16 -0
- package/dist-library/types/react/runtime/useSwipe.d.ts +27 -0
- package/dist-library/types/react/runtime/useTicker.d.ts +17 -0
- package/dist-library/types/react/sdk.d.ts +110 -0
- package/dist-library/types/react/server.d.ts +15 -0
- package/dist-library/types/react/tooltip-layer.d.ts +10 -0
- package/dist-library/types/react/use-draft-field.d.ts +17 -0
- package/dist-library/types/runtime-services/browser/index.d.ts +63 -0
- package/dist-library/types/runtime-services/component-state.d.ts +152 -0
- package/dist-library/types/runtime-services/identity.d.ts +41 -0
- package/dist-library/types/runtime-services/index.d.ts +10 -0
- package/dist-library/types/runtime-services/random.d.ts +42 -0
- package/dist-library/types/runtime-services/runtime.d.ts +51 -0
- package/dist-library/types/runtime-services/scheduler.d.ts +44 -0
- package/dist-library/types/sdk/assembly.d.ts +73 -0
- package/dist-library/types/sdk/compat-profile.d.ts +57 -0
- package/dist-library/types/sdk/compiler-config.d.ts +33 -0
- package/dist-library/types/sdk/config-validation.d.ts +33 -0
- package/dist-library/types/sdk/config.d.ts +35 -0
- package/dist-library/types/sdk/hash.d.ts +9 -0
- package/dist-library/types/sdk/index.d.ts +10 -0
- package/dist-library/types/sdk/manifest.d.ts +49 -0
- package/dist-library/types/sdk/pattern.d.ts +11 -0
- package/dist-library/types/sdk/preset-core.d.ts +11 -0
- package/dist-library/types/sdk/preset.d.ts +9 -0
- package/dist-library/types/sdk/props.d.ts +33 -0
- package/dist-library/types/sdk/registry-core.d.ts +16 -0
- package/dist-library/types/sdk/registry.d.ts +18 -0
- package/dist-library/types/sdk/theme.d.ts +73 -0
- package/dist-library/types/sdk/types.d.ts +221 -0
- package/dist-library/types/sdk/version.d.ts +49 -0
- package/dist-library/types/shareable.d.ts +29 -3
- package/dist-library/types/standalone/diagnostics.d.ts +16 -0
- package/dist-library/types/standalone/events.d.ts +4 -0
- package/dist-library/types/standalone/library.d.ts +6 -0
- package/dist-library/types/standalone/payload.d.ts +15 -0
- package/dist-library/types/standalone/prepare.d.ts +21 -0
- package/dist-library/types/standalone/session.d.ts +68 -0
- package/dist-library/types/standalone/version.d.ts +7 -0
- package/dist-library/types/testing/behavior.d.ts +19 -0
- package/dist-library/types/testing/browser.d.ts +126 -0
- package/dist-library/types/testing/cases.d.ts +16 -0
- package/dist-library/types/testing/index.d.ts +13 -0
- package/dist-library/types/testing/manifest.d.ts +10 -0
- package/dist-library/types/testing/react.d.ts +45 -0
- package/dist-library/types/testing/report.d.ts +20 -0
- package/dist-library/types/testing/types.d.ts +125 -0
- package/dist-library/types/testing/values.d.ts +22 -0
- package/dist-library/types/vite/client.d.ts +36 -0
- package/dist-library/types/vite/discovery.d.ts +51 -0
- package/dist-library/types/vite/index.d.ts +31 -0
- package/dist-library/types/vite/registration.d.ts +109 -0
- package/dist-library/types-BFCrMrg0.js +52 -0
- package/dist-library/validation-W-bmny-x.js +2253 -0
- package/dist-library/values-CIt8AjiU.js +134 -0
- package/dist-standalone/reactive-md-standalone.css +1 -1
- package/dist-standalone/reactive-md-standalone.js +591 -95
- package/docs/README-ch.md +90 -0
- package/docs/README.md +87 -81
- package/docs/compatibility/compatibility-ch.md +22 -14
- package/docs/compatibility/compatibility-en.md +22 -14
- package/docs/compatibility/source-versioning-ch.md +15 -12
- package/docs/compatibility/source-versioning-en.md +16 -13
- package/docs/development/component-development-ch.md +51 -195
- package/docs/development/component-development-en.md +51 -195
- package/docs/development/component-development-reference-ch.md +253 -0
- package/docs/development/component-development-reference-en.md +238 -0
- package/docs/development/component-protocol-ch.md +51 -50
- package/docs/development/component-protocol-en.md +52 -49
- package/docs/development/local-module-layout-ch.md +59 -0
- package/docs/development/local-module-layout-en.md +59 -0
- package/docs/development/performance-overview-ch.md +402 -0
- package/docs/development/performance-overview-en.md +402 -0
- package/docs/development/releasing-ch.md +8 -104
- package/docs/development/releasing-en.md +8 -104
- package/docs/guides/local-guide-ch.md +28 -9
- package/docs/guides/local-guide-en.md +31 -12
- package/docs/integration/author-tools-ch.md +4 -2
- package/docs/integration/author-tools-en.md +4 -2
- package/docs/integration/codemirror-ch.md +52 -0
- package/docs/integration/codemirror-en.md +29 -0
- package/docs/integration/compiler-ch.md +47 -0
- package/docs/integration/compiler-en.md +34 -0
- package/docs/integration/directory-discovery-ch.md +53 -0
- package/docs/integration/directory-discovery-en.md +31 -0
- package/docs/integration/editor-ch.md +48 -21
- package/docs/integration/editor-en.md +48 -21
- package/docs/integration/extension-sdk-ch.md +392 -0
- package/docs/integration/extension-sdk-en.md +377 -0
- package/docs/integration/local-integration-ch.md +63 -9
- package/docs/integration/local-integration-en.md +89 -13
- package/docs/integration/repository-split-ch.md +40 -0
- package/docs/integration/repository-split-en.md +23 -0
- package/docs/integration/shareable-export-ch.md +46 -2
- package/docs/integration/shareable-export-en.md +46 -2
- package/docs/reference/computations-formatting-ch.md +4 -2
- package/docs/reference/computations-formatting-en.md +4 -2
- package/docs/reference/constraints-collections-ch.md +21 -1
- package/docs/reference/constraints-collections-en.md +21 -1
- package/docs/reference/diagnostics-counting-ch.md +1 -1
- package/docs/reference/diagnostics-counting-en.md +1 -1
- package/docs/reference/html-compatibility-ch.md +4 -0
- package/docs/reference/html-compatibility-en.md +4 -0
- package/docs/reference/local-components-v2-ch.md +2 -0
- package/docs/reference/local-components-v2-en.md +2 -0
- package/docs/reference/local-interaction-syntax-ch.md +51 -15
- package/docs/reference/local-interaction-syntax-en.md +58 -14
- package/docs/reference/theme-protocol-ch.md +79 -7
- package/docs/reference/theme-protocol-en.md +79 -7
- package/docs/reference/tolerance-ch.md +64 -0
- package/docs/reference/tolerance-en.md +57 -0
- package/docs/releases/release-0.4.0-ch.md +2 -0
- package/docs/releases/release-0.4.0-en.md +2 -0
- package/docs/releases/release-0.4.1-ch.md +2 -0
- package/docs/releases/release-0.4.1-en.md +2 -0
- package/docs/releases/release-0.5.0-ch.md +2 -0
- package/docs/releases/release-0.5.0-en.md +2 -0
- package/docs/releases/release-0.5.1-ch.md +2 -0
- package/docs/releases/release-0.5.1-en.md +2 -0
- package/docs/releases/release-0.5.2-ch.md +2 -0
- package/docs/releases/release-0.5.2-en.md +2 -0
- package/docs/releases/release-0.5.3-ch.md +2 -0
- package/docs/releases/release-0.5.3-en.md +2 -0
- package/docs/releases/release-0.6.0-ch.md +2 -0
- package/docs/releases/release-0.6.0-en.md +2 -0
- package/docs/releases/release-0.6.1-ch.md +2 -0
- package/docs/releases/release-0.6.1-en.md +2 -0
- package/docs/releases/release-0.7.0-ch.md +86 -0
- package/docs/releases/release-0.7.0-en.md +86 -0
- package/docs/releases/release-0.8.0-ch.md +126 -0
- package/docs/releases/release-0.8.0-en.md +126 -0
- package/examples/component-package/LICENSE +21 -0
- package/examples/component-package/NOTICES.md +12 -0
- package/examples/component-package/README-ch.md +101 -0
- package/examples/component-package/README.md +133 -0
- package/examples/component-package/package.json +35 -0
- package/examples/component-package/sample/document.reactive.md +14 -0
- package/examples/component-package/scripts/build-export.mjs +44 -0
- package/examples/component-package/scripts/build.mjs +130 -0
- package/examples/component-package/scripts/verify.mjs +257 -0
- package/examples/component-package/src/assets/notice.svg +4 -0
- package/examples/component-package/src/component.css +40 -0
- package/examples/component-package/src/components.tsx +105 -0
- package/examples/component-package/src/harness.tsx +34 -0
- package/examples/component-package/src/manifests.ts +71 -0
- package/examples/component-package/src/node-entry.ts +18 -0
- package/examples/component-package/src/sample.ts +4 -0
- package/examples/component-package/src/theme.css +44 -0
- package/examples/component-package/src/theme.ts +22 -0
- package/examples/component-package/tsconfig.json +15 -0
- package/examples/conformance/README-ch.md +55 -0
- package/examples/conformance/README.md +2 -0
- package/examples/conformance/local-draft-3.json +296 -0
- package/examples/game-2048-package/LICENSE +21 -0
- package/examples/game-2048-package/NOTICES.md +11 -0
- package/examples/game-2048-package/README-ch.md +97 -0
- package/examples/game-2048-package/README.md +102 -0
- package/examples/game-2048-package/package.json +35 -0
- package/examples/game-2048-package/sample/document.reactive.md +17 -0
- package/examples/game-2048-package/scripts/build-export.mjs +44 -0
- package/examples/game-2048-package/scripts/build.mjs +130 -0
- package/examples/game-2048-package/scripts/verify.mjs +180 -0
- package/examples/game-2048-package/src/component.css +161 -0
- package/examples/game-2048-package/src/components.tsx +326 -0
- package/examples/game-2048-package/src/game-engine.ts +228 -0
- package/examples/game-2048-package/src/harness.tsx +34 -0
- package/examples/game-2048-package/src/manifest.ts +85 -0
- package/examples/game-2048-package/src/node-entry.ts +30 -0
- package/examples/game-2048-package/src/sample.ts +4 -0
- package/examples/game-2048-package/tsconfig.json +15 -0
- package/examples/integration/README-ch.md +63 -0
- package/examples/integration/README.md +17 -1
- package/examples/integration/extension-sdk/README-ch.md +24 -0
- package/examples/integration/extension-sdk/README.md +24 -0
- package/examples/integration/extension-sdk/advanced-standalone.ts +6 -0
- package/examples/integration/extension-sdk/advanced.tsx +101 -0
- package/examples/integration/extension-sdk/env.d.ts +2 -0
- package/examples/integration/extension-sdk/extensions.tsx +97 -0
- package/examples/integration/extension-sdk/index.html +3 -0
- package/examples/integration/extension-sdk/main.tsx +10 -0
- package/examples/integration/extension-sdk/package.json +6 -0
- package/examples/integration/extension-sdk/standalone.ts +7 -0
- package/examples/integration/extension-sdk/tsconfig.json +8 -0
- package/examples/integration/react-comprehensive/index.html +12 -0
- package/examples/integration/react-comprehensive/main.jsx +123 -0
- package/examples/integration/react-comprehensive/package.json +18 -0
- package/examples/local/README-ch.md +76 -0
- package/examples/local/README.md +4 -2
- package/examples/local/scenarios/blog-zh.reactive.md +71 -0
- package/examples/local/scenarios/blog.reactive.md +71 -0
- package/examples/local/scenarios/classroom-zh.reactive.md +97 -0
- package/examples/local/scenarios/classroom.reactive.md +97 -0
- package/examples/local/scenarios/proposal-zh.reactive.md +79 -0
- package/examples/local/scenarios/proposal.reactive.md +79 -0
- package/examples/local/scenarios/survey-zh.reactive.md +74 -0
- package/examples/local/scenarios/survey.reactive.md +74 -0
- package/examples/local/showcase/README-ch.md +22 -0
- package/examples/local/showcase/README.md +9 -3
- package/examples/local/showcase/features.reactive.md +637 -0
- package/examples/local/showcase/zh/features.reactive.md +637 -0
- package/examples/sci-fi-theme/README-ch.md +131 -0
- package/examples/sci-fi-theme/README.md +146 -0
- package/examples/sci-fi-theme/demo/demo.css +532 -0
- package/examples/sci-fi-theme/demo/document.reactive.md +185 -0
- package/examples/sci-fi-theme/demo/index.html +13 -0
- package/examples/sci-fi-theme/demo/main.tsx +180 -0
- package/examples/sci-fi-theme/docs/design-system-ch.md +245 -0
- package/examples/sci-fi-theme/docs/design-system.md +474 -0
- package/examples/sci-fi-theme/package.json +27 -0
- package/examples/sci-fi-theme/scripts/screenshot.mjs +98 -0
- package/examples/sci-fi-theme/src/components.css +1460 -0
- package/examples/sci-fi-theme/src/index.ts +6 -0
- package/examples/sci-fi-theme/src/sci-fi.css +5 -0
- package/examples/sci-fi-theme/src/theme.ts +37 -0
- package/examples/sci-fi-theme/src/tokens.css +408 -0
- package/examples/sci-fi-theme/tsconfig.json +20 -0
- package/examples/sci-fi-theme/vite.config.ts +24 -0
- package/examples/tetris-package/LICENSE +21 -0
- package/examples/tetris-package/NOTICES.md +11 -0
- package/examples/tetris-package/README-ch.md +91 -0
- package/examples/tetris-package/README.md +95 -0
- package/examples/tetris-package/package.json +35 -0
- package/examples/tetris-package/sample/document.reactive.md +16 -0
- package/examples/tetris-package/scripts/build-export.mjs +44 -0
- package/examples/tetris-package/scripts/build.mjs +130 -0
- package/examples/tetris-package/scripts/verify.mjs +173 -0
- package/examples/tetris-package/src/component.css +145 -0
- package/examples/tetris-package/src/components.tsx +334 -0
- package/examples/tetris-package/src/harness.tsx +34 -0
- package/examples/tetris-package/src/manifests.ts +93 -0
- package/examples/tetris-package/src/node-entry.ts +16 -0
- package/examples/tetris-package/src/sample.ts +4 -0
- package/examples/tetris-package/src/tetris-engine.ts +325 -0
- package/examples/tetris-package/tsconfig.json +15 -0
- package/package.json +98 -44
- package/dist-library/compiler-Cm3ppMxG.js +0 -46044
- package/dist-library/react-Bh7_oxZp.js +0 -59655
- package/dist-library/reactive-md-editor.css +0 -2
- package/dist-library/reactive-md-editor.js +0 -3853
- package/dist-library/runtime-DlFYQ4s_.js +0 -498
- package/dist-library/types/editor/ReactiveMarkdownEditor.d.ts +0 -7
- package/dist-library/types/editor/editor-toolbar.d.ts +0 -24
- package/dist-library/types/editor/editor-view-bar.d.ts +0 -11
- package/dist-library/types/editor/extended-native-components.d.ts +0 -58
- package/dist-library/types/editor/index.d.ts +0 -9
- package/dist-library/types/editor/locale.d.ts +0 -13
- package/dist-library/types/editor/source-authoring.d.ts +0 -59
- package/dist-library/types/editor/types.d.ts +0 -48
- package/dist-library/types/editor/use-gutter-metrics.d.ts +0 -5
- package/dist-library/types/editor/use-source-history.d.ts +0 -16
- package/dist-library/types/local/compiler.d.ts +0 -4
- package/dist-library/types/local/math.d.ts +0 -48
- package/dist-library/types/local/options.d.ts +0 -36
- package/dist-library/types/local/parser.d.ts +0 -13
- package/dist-library/types/local/render-types.d.ts +0 -27
- package/dist-library/types/local/runtime.d.ts +0 -2
- package/dist-library/types/local/schema.d.ts +0 -77
- package/dist-library/types/local/types.d.ts +0 -263
- package/dist-library/types/local/visuals.d.ts +0 -12
- package/dist-library/types/local/worker.d.ts +0 -98
- package/docs/development/performance-ch.md +0 -76
- package/docs/development/performance-en.md +0 -76
- /package/dist-library/types/{editor → authoring}/command-types.d.ts +0 -0
- /package/dist-library/types/{editor → authoring}/editor-commands.d.ts +0 -0
- /package/dist-library/types/local/{locale.d.ts → contracts/locale.d.ts} +0 -0
- /package/dist-library/types/local/{collection-functions.d.ts → evaluation/collection-functions.d.ts} +0 -0
- /package/dist-library/types/local/{data-functions.d.ts → evaluation/data-functions.d.ts} +0 -0
- /package/dist-library/types/local/{dates.d.ts → evaluation/dates.d.ts} +0 -0
- /package/dist-library/types/local/{formatting.d.ts → evaluation/formatting.d.ts} +0 -0
- /package/dist-library/types/local/{html-names.d.ts → html/html-names.d.ts} +0 -0
- /package/dist-library/types/local/{text-length.d.ts → source/text-length.d.ts} +0 -0
- /package/dist-library/types/local/{colors.d.ts → theme/colors.d.ts} +0 -0
- /package/dist-library/types/local/{code-block.d.ts → widgets/code-block.d.ts} +0 -0
- /package/dist-library/types/local/{code-languages.d.ts → widgets/code-languages.d.ts} +0 -0
- /package/dist-library/types/local/{diagram-layout.d.ts → widgets/diagram-layout.d.ts} +0 -0
- /package/dist-library/types/local/{image-view.d.ts → widgets/image-view.d.ts} +0 -0
- /package/dist-library/types/local/{math-view.d.ts → widgets/math-view.d.ts} +0 -0
- /package/dist-library/types/local/{table-surface.d.ts → widgets/table-surface.d.ts} +0 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Load themes and components from directories
|
|
2
|
+
|
|
3
|
+
Enable `reactiveMd()` from `reactive-md/vite` once in the consuming project's Vite config. It scans immediate child directories under `theme/` and `plugin/`, relative to Vite root.
|
|
4
|
+
|
|
5
|
+
```text
|
|
6
|
+
theme/paper/theme.css
|
|
7
|
+
theme/paper/theme.json # optional
|
|
8
|
+
plugin/tetris/index.ts
|
|
9
|
+
plugin/tetris/component.css # optional
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
A theme needs only `theme.css`. Its directory supplies the name, `local/theme/<directory>` supplies the package ID, and the version defaults to `0.0.0`. Optional `theme.json` can set `id`, `name`, `version`, `protocol` and `colorSchemes`. The loader calls `defineLocalTheme` for validation, scoping and freezing. Write both color schemes using the theme protocol. A document selects a discovered theme with `<theme name="paper">`.
|
|
13
|
+
|
|
14
|
+
A component entry exports a `LocalReactPackage`, preferably as its default export. A single distinct named package export also works; aliases of the same object count once. Continue using `defineReactComponentPackage` to declare the tag, props, capabilities and React implementation. An installed package can be forwarded through its public entry:
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
// plugin/tetris/index.ts
|
|
18
|
+
export { tetrisPackage as default } from 'reactive-md-tetris-package/react';
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Recognized entry names are `index.ts`, `index.tsx`, `index.js`, `index.jsx`, `index.mts` and `index.mjs`. Multiple entries in one directory are an error. Helper files are imported by the entry. Optional `component.css` is collected automatically. Package resources, themes and notices are preserved; an entry may also export a `notices` array.
|
|
22
|
+
|
|
23
|
+
The app reads `host` from `virtual:reactive-md/host`. React uses `host.reactConfig`; compilation and authoring use `host.compileOptions`. Workers receive the serializable `host.config`. SSR and exports use `host.resources` and `host.notices`. Import `reactive-md/styles.css` for the base styles and reference `reactive-md/vite/client` for virtual-module types. The offline bundle and browser host use the same discovery result.
|
|
24
|
+
|
|
25
|
+
Directories have a fixed sort order. Local CSS imports and relative assets are resolved and inlined at build time, with source paths, digests and byte sizes in the asset manifest. Remote references, paths outside the allowed directory and resource budget violations fail. SDK scoping and CSS rules still apply. Duplicate theme names, theme IDs, component IDs and tags identify both source entries; conflicting resource contents fail too.
|
|
26
|
+
|
|
27
|
+
The dev server watches entry creation, deletion and renaming. Theme CSS and asset changes update styles and invalidate the offline bundle cache; registration changes reload the page. Discovery makes themes available for selection and components available for authored tags.
|
|
28
|
+
|
|
29
|
+
Use `reactiveMd({ themeDir: 'themes', pluginDir: 'components' })` for alternate roots. Advanced hosts can keep `reactiveMd({ extensions: './extensions.ts' })`, whose module exports `host = createReactHost(...)`. Manual and directory options are mutually exclusive. Keep application metadata, such as example navigation, in ordinary application modules.
|
|
30
|
+
|
|
31
|
+
The Demo uses its existing Tetris and 2048 packages and sci-fi theme through these directories. Its local sci-fi CSS was copied from the installed theme package's public CSS entries; synchronize those files when updating that package.
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
# React 源码编辑器
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**中文** · [English](editor-en.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`reactive-md@0.8.0` 将编辑器拆分到独立的 `reactive-md-editor@0.1.0`,引擎先发布,编辑器随后发布。原 0.7 包已统一为 CodeMirror 6 编辑器;CM6 的事务、共享分析和坐标约定见 [CM6 集成](codemirror-ch.md)。
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`reactive-md-editor` 是用于 Reactive MD 源码的受控 React 19 编辑器,由 Playground 编辑器抽出。它提供源码高亮、格式与插入工具栏、补全、绑定导航、重命名与格式化、撤销重做、行号及滚动同步。编辑器内置字数底栏及编辑、并排、预览三种视图。宿主保存源码,并提供预览内容、持久化和导出。
|
|
8
|
+
|
|
9
|
+
编辑器有独立样式表 `reactive-md-editor/styles.css`,与 `reactive-md/styles.css` 分开。只编辑源码的页面不会加载文档渲染样式。
|
|
10
|
+
|
|
11
|
+
升级时将旧的 `reactive-md/editor` 子路径及其样式导入换成独立包入口,见[三仓库迁移](repository-split-ch.md)。文档渲染仍使用 `reactive-md/react` 和 `reactive-md/styles.css`。
|
|
8
12
|
|
|
9
13
|
## 安装
|
|
10
14
|
|
|
11
15
|
```sh
|
|
12
|
-
npm install reactive-md
|
|
16
|
+
npm install reactive-md@0.8.0 reactive-md-editor@0.1.0
|
|
13
17
|
npm install react@19 react-dom@19
|
|
14
18
|
```
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
以上命令用于两个正式版本发布之后;准备期间安装各自经过验证的本地 tarball。包只提供 ESM,工具和服务端渲染需要 Node.js 22.12 或更新版本。
|
|
17
21
|
|
|
18
22
|
## 最小受控编辑器
|
|
19
23
|
|
|
20
24
|
```tsx
|
|
21
25
|
import { useState } from 'react';
|
|
22
|
-
import { ReactiveMarkdownEditor } from 'reactive-md
|
|
23
|
-
import 'reactive-md
|
|
26
|
+
import { ReactiveMarkdownEditor } from 'reactive-md-editor';
|
|
27
|
+
import 'reactive-md-editor/styles.css';
|
|
24
28
|
|
|
25
29
|
const initialSource = `# 费用估算
|
|
26
30
|
|
|
@@ -41,14 +45,14 @@ export function SourceEditor() {
|
|
|
41
45
|
}
|
|
42
46
|
```
|
|
43
47
|
|
|
44
|
-
`value` 和 `onChange`
|
|
48
|
+
`value` 和 `onChange` 为必需属性。组件使用 CM6 按视口创建源码行 DOM,并使用 CM6 原生历史;源码文本保存在宿主状态中。内置文案默认为英文。
|
|
45
49
|
|
|
46
50
|
## 入口
|
|
47
51
|
|
|
48
52
|
| 入口 | 内容 | 依赖 |
|
|
49
53
|
| --- | --- | --- |
|
|
50
|
-
| `reactive-md
|
|
51
|
-
| `reactive-md
|
|
54
|
+
| `reactive-md-editor` | `ReactiveMarkdownEditor` 及其类型 | React 19 |
|
|
55
|
+
| `reactive-md-editor/styles.css` | 编辑器样式,作用域限定在编辑器根节点 | 由宿主显式引入 |
|
|
52
56
|
|
|
53
57
|
样式表在应用或渲染编辑器的组件模块中引入一次即可。支持 CSS 导入的构建工具或框架可以把它放在编辑器模块旁边。
|
|
54
58
|
|
|
@@ -59,7 +63,7 @@ import { useRef, useState } from 'react';
|
|
|
59
63
|
import {
|
|
60
64
|
ReactiveMarkdownEditor,
|
|
61
65
|
type ReactiveMarkdownEditorHandle,
|
|
62
|
-
} from 'reactive-md
|
|
66
|
+
} from 'reactive-md-editor';
|
|
63
67
|
|
|
64
68
|
export function SourceEditor() {
|
|
65
69
|
const [source, setSource] = useState('');
|
|
@@ -80,11 +84,13 @@ export function SourceEditor() {
|
|
|
80
84
|
|
|
81
85
|
| 方法 | 行为 |
|
|
82
86
|
| --- | --- |
|
|
83
|
-
| `focus(selection?)` |
|
|
87
|
+
| `focus(selection?)` | 聚焦源码编辑区,可同时应用选区。 |
|
|
84
88
|
| `selectRange(range)` | 选中一段源码。区间与编译诊断一样使用 UTF-16 半开区间偏移。 |
|
|
85
89
|
| `insertText(text)` | 用文本替换当前选区,记录为一次可撤销编辑,并将光标放到插入内容之后。只读或禁用时不执行。 |
|
|
86
90
|
| `getSelection()` | 返回当前选区。 |
|
|
87
|
-
| `
|
|
91
|
+
| `getSource()` | 返回完整原始源码,包含视口外文本。 |
|
|
92
|
+
| `getEditorElement()` | 返回可编辑 DOM 元素;挂载前为 `null`。 |
|
|
93
|
+
| `getVisibleRanges()` | 返回当前可见源码区间。 |
|
|
88
94
|
| `undo()` / `redo()` | 在该实例的历史中前后移动,并通过 `onChange` 发出结果值。到达历史两端或 `readOnly`、`disabled` 时不执行操作。 |
|
|
89
95
|
|
|
90
96
|
入口同时导出 `ReactiveMarkdownEditorProps`、`ReactiveMarkdownEditorHandle`、`EditorLocale`、`EditorTheme` 和 `EditorSelection` 类型。
|
|
@@ -101,13 +107,13 @@ export function SourceEditor() {
|
|
|
101
107
|
| `viewMode` | `EditorViewMode` | 无 | 受控视图:`'edit'`、`'split'` 或 `'preview'`。 |
|
|
102
108
|
| `defaultViewMode` | `EditorViewMode` | `'edit'` | 非受控视图的初始模式。 |
|
|
103
109
|
| `onViewModeChange` | `(mode: EditorViewMode) => void` | 无 | 用户点击底栏视图按钮时调用。 |
|
|
104
|
-
| `id` | `string` | 自动生成 |
|
|
110
|
+
| `id` | `string` | 自动生成 | 源码可编辑元素的 id。 |
|
|
105
111
|
| `className` | `string` | 无 | 加到 `.reactive-md-editor` 根节点。 |
|
|
106
112
|
| `style` | `CSSProperties` | 无 | 根节点的内联样式。 |
|
|
107
113
|
| `height` | `number \| string` | `560` | 数字按像素计算,字符串可使用任意 CSS 长度。 |
|
|
108
114
|
| `minHeight` | `number \| string` | `280` | 最小高度,单位规则与 `height` 相同。 |
|
|
109
115
|
| `placeholder` | `string` | 无 | 源码为空时的占位提示。 |
|
|
110
|
-
| `ariaLabel` | `string` | 本地化标签 |
|
|
116
|
+
| `ariaLabel` | `string` | 本地化标签 | 源码编辑区的可访问名称。 |
|
|
111
117
|
| `readOnly` | `boolean` | `false` | 文本仍可选中和复制,但不能修改。 |
|
|
112
118
|
| `disabled` | `boolean` | `false` | 阻止聚焦和编辑。 |
|
|
113
119
|
| `documentKey` | `string \| number` | 无 | 切换到独立源码文档时修改该值。变化会重置撤销历史与选区。 |
|
|
@@ -116,7 +122,9 @@ export function SourceEditor() {
|
|
|
116
122
|
| `toolbar` | `boolean` | `true` | 显示格式与插入工具栏,包括导出操作。 |
|
|
117
123
|
| `authoring` | `boolean` | `true` | 启用补全、绑定导航、重命名和格式化工具。 |
|
|
118
124
|
| `onExport` | `() => void` | 无 | 工具栏导出操作调用该回调,用于打开宿主导出对话框或自行写文件。 |
|
|
119
|
-
| `
|
|
125
|
+
| `analysis` | `EditorAuthorAnalysis \| null` | 无 | 省略时使用私有分析 Worker;`null` 表示等待宿主共享分析。 |
|
|
126
|
+
| `onTransaction` | `(transaction: EditorTransaction) => void` | 无 | 接收原始源码坐标下的编辑事务。 |
|
|
127
|
+
| `createAnalysisWorker` | `() => Worker` | 无 | 提供符合宿主 CSP 的分析 Worker 工厂。 |
|
|
120
128
|
|
|
121
129
|
## 编辑器内置视图
|
|
122
130
|
|
|
@@ -133,6 +141,25 @@ export function SourceEditor() {
|
|
|
133
141
|
|
|
134
142
|
切换视图会保留源码选区、撤销历史及预览组件的状态。需要从外部控制视图时,同时传入 `viewMode` 和 `onViewModeChange`。只编辑源码时可省略 `preview`,底栏保留字符数及键盘提示。在源码中按 Esc,再按 Tab 可聚焦工具栏。
|
|
135
143
|
|
|
144
|
+
## 预览定位源码
|
|
145
|
+
|
|
146
|
+
`LocalDocumentView` 与 `LocalReactiveDocument` 接受 `onSourceNavigate`。提供回调后,渲染出的段落、标题、插值、公式、控件标签和图表框会携带源码元数据,普通点击会报告目标:
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
<LocalDocumentView
|
|
150
|
+
document={document}
|
|
151
|
+
runtime={runtime}
|
|
152
|
+
onSourceNavigate={(target) => {
|
|
153
|
+
editor.current?.selectRange(target.range);
|
|
154
|
+
editor.current?.focus();
|
|
155
|
+
}}
|
|
156
|
+
/>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`target` 包含 `range`(UTF-16 半开区间)、`nodeId`、`nodeType`,组件还包含 `componentName`。输入框、按钮、链接和表格控件等交互后代会被忽略,因此拖动滑块或点击表头排序不会误触跳转;点击控件标签才会定位到其标签源码。定位不会增加 Tab 停靠点;隐藏内容不渲染,原生 HTML iframe 内容没有可靠映射。
|
|
160
|
+
|
|
161
|
+
省略回调时 DOM 与静态导出保持原样。容器宽度不超过 600px 时编辑器可能只显示编辑和预览;定位预览目标前先切换到并排视图,确保选区可见。`selectRange` 只聚焦源码,不会产生编辑或撤销步骤。
|
|
162
|
+
|
|
136
163
|
## 受控值与历史
|
|
137
164
|
|
|
138
165
|
每次编辑都会以新源码调用 `onChange`,包括输入、工具栏格式化、插入模板、重命名、格式化及撤销重做。把该值回传给 `value`。编辑器把自己发出的修改视为当前会话的一部分,常规受控值回传会保留撤销步骤。
|
|
@@ -197,7 +224,7 @@ const result = compileLocal(source);
|
|
|
197
224
|
/>
|
|
198
225
|
```
|
|
199
226
|
|
|
200
|
-
`diagnostics`
|
|
227
|
+
`diagnostics` 在行号栏标记报告所在行。未完成的源码仍可继续输入,编译错误不会锁住编辑器。`document` 为作者检查面板提供绑定值类型。两个属性都可省略;只编辑 Markdown 时无需传入。
|
|
201
228
|
|
|
202
229
|
## 尺寸与布局
|
|
203
230
|
|
|
@@ -207,7 +234,7 @@ const result = compileLocal(source);
|
|
|
207
234
|
|
|
208
235
|
## 工具栏与作者工具
|
|
209
236
|
|
|
210
|
-
`toolbar={false}` 移除格式与插入工具栏,包括导出操作。`authoring={false}` 保留
|
|
237
|
+
`toolbar={false}` 移除格式与插入工具栏,包括导出操作。`authoring={false}` 保留 CM6 和工具栏,停用作者分析、绑定导航、重命名和格式化;基础 Markdown 高亮继续可用。两者默认启用。
|
|
211
238
|
|
|
212
239
|
工具栏处理 Markdown 格式,插入列表、表格、链接、图片和内置组块模板,并提供撤销重做。格式化命令基于当前选区,通过 `onChange` 返回新源码。
|
|
213
240
|
|
|
@@ -223,16 +250,16 @@ const result = compileLocal(source);
|
|
|
223
250
|
|
|
224
251
|
## 服务端渲染
|
|
225
252
|
|
|
226
|
-
编辑器入口没有顶层 `window` 或 `document`
|
|
253
|
+
编辑器入口没有顶层 `window` 或 `document` 访问。服务端渲染输出编辑器外框,CM6 编辑视图在客户端挂载。聚焦、选区、补全、布局测量和工具栏菜单需要浏览器环境。
|
|
227
254
|
|
|
228
255
|
## 样式与作用域
|
|
229
256
|
|
|
230
|
-
`reactive-md
|
|
257
|
+
`reactive-md-editor/styles.css` 包含编辑器自己的 token 和规则,所有选择器限定在 `.reactive-md-editor` 及其后代,不会改写宿主的按钮、输入框或页面正文。主题由上面的实例属性提供。
|
|
231
258
|
|
|
232
259
|
同一页面还渲染文档预览时,再引入 `reactive-md/styles.css`。两份样式表彼此独立,加载顺序不限。
|
|
233
260
|
|
|
234
261
|
## 兼容性
|
|
235
262
|
|
|
236
|
-
`
|
|
263
|
+
从 textarea 编辑器迁移时,移除 `textareaRef`,以 ref 的 `getSource()` 读取完整源码、`getSelection()` 读取选区、`selectRange()` 设置选区。`getEditorElement()` 提供可编辑 DOM 元素。`reactive-md-editor/codemirror` 保留为同一组件的兼容别名,共用样式和运行时代码。文档中的 `<textarea>` 表单组件继续受支持。
|
|
237
264
|
|
|
238
265
|
0.5.3 新增接受编译配置的作者工具及显式屏幕、打印样式入口,见 [0.5.3 宿主集成](../releases/release-0.5.3-ch.md)。0.6.0 为 ref 句柄新增 `insertText`,见 [0.6.0 发布说明](../releases/release-0.6.0-ch.md)。
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
# React source editor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**English** · [中文](editor-ch.md)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
`reactive-md@0.8.0` moves the editor into the independent `reactive-md-editor@0.1.0` package; the engine publishes before the editor. The old 0.7 package already used CodeMirror 6. See [CM6 integration](codemirror-en.md) for transactions, shared analysis and source coordinates.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`reactive-md-editor` is a controlled React 19 editor for Reactive MD source. It comes from the Playground editor and provides source highlighting, a formatting and insertion toolbar, completion, binding navigation, rename and format commands, undo and redo, line numbers and scroll synchronization. Its built-in status bar provides a character count and Edit, Split and Preview views. The host keeps the source text and supplies preview content, persistence and export.
|
|
8
|
+
|
|
9
|
+
The editor has its own stylesheet at `reactive-md-editor/styles.css`. It is separate from `reactive-md/styles.css`, so a page that only edits source does not load document rendering styles.
|
|
10
|
+
|
|
11
|
+
Replace the old `reactive-md/editor` subpaths and styles with the independent package entries; see [repository migration](repository-split-en.md). Document rendering continues to use `reactive-md/react` and `reactive-md/styles.css`.
|
|
8
12
|
|
|
9
13
|
## Install
|
|
10
14
|
|
|
11
15
|
```sh
|
|
12
|
-
npm install reactive-md
|
|
16
|
+
npm install reactive-md@0.8.0 reactive-md-editor@0.1.0
|
|
13
17
|
npm install react@19 react-dom@19
|
|
14
18
|
```
|
|
15
19
|
|
|
16
|
-
|
|
20
|
+
Use these commands after both stable versions are published; during preparation, install their verified local tarballs. The packages ship ESM only and need Node.js 22.12 or newer for tooling and server rendering.
|
|
17
21
|
|
|
18
22
|
## Minimal controlled editor
|
|
19
23
|
|
|
20
24
|
```tsx
|
|
21
25
|
import { useState } from 'react';
|
|
22
|
-
import { ReactiveMarkdownEditor } from 'reactive-md
|
|
23
|
-
import 'reactive-md
|
|
26
|
+
import { ReactiveMarkdownEditor } from 'reactive-md-editor';
|
|
27
|
+
import 'reactive-md-editor/styles.css';
|
|
24
28
|
|
|
25
29
|
const initialSource = `# Cost estimate
|
|
26
30
|
|
|
@@ -41,14 +45,14 @@ export function SourceEditor() {
|
|
|
41
45
|
}
|
|
42
46
|
```
|
|
43
47
|
|
|
44
|
-
`value` and `onChange` are required.
|
|
48
|
+
`value` and `onChange` are required. CM6 renders source lines around the viewport and provides native undo history. The complete source text stays in your state. Built-in labels default to English.
|
|
45
49
|
|
|
46
50
|
## Entries
|
|
47
51
|
|
|
48
52
|
| Entry | Contents | Dependency |
|
|
49
53
|
| --- | --- | --- |
|
|
50
|
-
| `reactive-md
|
|
51
|
-
| `reactive-md
|
|
54
|
+
| `reactive-md-editor` | `ReactiveMarkdownEditor` and its types | React 19 |
|
|
55
|
+
| `reactive-md-editor/styles.css` | Editor styles, scoped to the editor root | Imported explicitly by the host |
|
|
52
56
|
|
|
53
57
|
Import the stylesheet once in the application or in the component module that renders the editor. A bundler or framework that handles CSS imports can place it with the editor module.
|
|
54
58
|
|
|
@@ -59,7 +63,7 @@ import { useRef, useState } from 'react';
|
|
|
59
63
|
import {
|
|
60
64
|
ReactiveMarkdownEditor,
|
|
61
65
|
type ReactiveMarkdownEditorHandle,
|
|
62
|
-
} from 'reactive-md
|
|
66
|
+
} from 'reactive-md-editor';
|
|
63
67
|
|
|
64
68
|
export function SourceEditor() {
|
|
65
69
|
const [source, setSource] = useState('');
|
|
@@ -80,11 +84,13 @@ export function SourceEditor() {
|
|
|
80
84
|
|
|
81
85
|
| Method | Behavior |
|
|
82
86
|
| --- | --- |
|
|
83
|
-
| `focus(selection?)` | Focuses the
|
|
87
|
+
| `focus(selection?)` | Focuses the source editor. Applies the optional selection. |
|
|
84
88
|
| `selectRange(range)` | Selects a source range. Ranges use the same UTF-16 half-open offsets as compile diagnostics. |
|
|
85
89
|
| `insertText(text)` | Replaces the current selection with text as one undoable edit, then places the caret after it. Read-only and disabled editors ignore the call. |
|
|
86
90
|
| `getSelection()` | Returns the current selection. |
|
|
87
|
-
| `
|
|
91
|
+
| `getSource()` | Returns the complete original source, including offscreen text. |
|
|
92
|
+
| `getEditorElement()` | Returns the editable DOM element, or `null` before mount. |
|
|
93
|
+
| `getVisibleRanges()` | Returns the visible source ranges. |
|
|
88
94
|
| `undo()` / `redo()` | Moves through this instance's history and emits the resulting value through `onChange`. Both are no-ops at the ends of the history and while `readOnly` or `disabled` is set. |
|
|
89
95
|
|
|
90
96
|
The entry also exports `ReactiveMarkdownEditorProps`, `ReactiveMarkdownEditorHandle`, `EditorLocale`, `EditorTheme` and `EditorSelection` types.
|
|
@@ -101,13 +107,13 @@ The entry also exports `ReactiveMarkdownEditorProps`, `ReactiveMarkdownEditorHan
|
|
|
101
107
|
| `viewMode` | `EditorViewMode` | none | Controlled view: `'edit'`, `'split'` or `'preview'`. |
|
|
102
108
|
| `defaultViewMode` | `EditorViewMode` | `'edit'` | Initial mode for an uncontrolled instance. |
|
|
103
109
|
| `onViewModeChange` | `(mode: EditorViewMode) => void` | none | Called when a view button is clicked. |
|
|
104
|
-
| `id` | `string` | generated |
|
|
110
|
+
| `id` | `string` | generated | Id of the editable source element. |
|
|
105
111
|
| `className` | `string` | none | Added to the `.reactive-md-editor` root. |
|
|
106
112
|
| `style` | `CSSProperties` | none | Inline styles for the root. |
|
|
107
113
|
| `height` | `number \| string` | `560` | A number is pixels. A string accepts any CSS length. |
|
|
108
114
|
| `minHeight` | `number \| string` | `280` | Minimum editor height, in the same units as `height`. |
|
|
109
115
|
| `placeholder` | `string` | none | Placeholder for an empty source. |
|
|
110
|
-
| `ariaLabel` | `string` | localized label | Accessible name for the
|
|
116
|
+
| `ariaLabel` | `string` | localized label | Accessible name for the source editor. |
|
|
111
117
|
| `readOnly` | `boolean` | `false` | Keeps text selectable and copyable while blocking changes. |
|
|
112
118
|
| `disabled` | `boolean` | `false` | Blocks focus and editing. |
|
|
113
119
|
| `documentKey` | `string \| number` | none | Change it when the editor switches to an independent source document. The change resets undo history and selection. |
|
|
@@ -116,7 +122,9 @@ The entry also exports `ReactiveMarkdownEditorProps`, `ReactiveMarkdownEditorHan
|
|
|
116
122
|
| `toolbar` | `boolean` | `true` | Shows the formatting and insertion toolbar, including its export action. |
|
|
117
123
|
| `authoring` | `boolean` | `true` | Enables completion, binding navigation, rename and format tools. |
|
|
118
124
|
| `onExport` | `() => void` | none | Called by the toolbar export action. Use it to open your export dialog or write the file yourself. |
|
|
119
|
-
| `
|
|
125
|
+
| `analysis` | `EditorAuthorAnalysis \| null` | none | Omit to use a private analysis Worker; pass `null` while awaiting host analysis. |
|
|
126
|
+
| `onTransaction` | `(transaction: EditorTransaction) => void` | none | Receives edits in original source coordinates. |
|
|
127
|
+
| `createAnalysisWorker` | `() => Worker` | none | Supplies a CSP-compatible analysis Worker factory. |
|
|
120
128
|
|
|
121
129
|
## Built-in editor views
|
|
122
130
|
|
|
@@ -133,6 +141,25 @@ The status bar sits inside the editor frame, directly below its editing area. It
|
|
|
133
141
|
|
|
134
142
|
Switching views preserves the source selection, undo history and preview component state. Pass both `viewMode` and `onViewModeChange` to control the mode from the host. Source-only instances retain the count and keyboard hint. Press Esc, then Tab in the source to focus the toolbar.
|
|
135
143
|
|
|
144
|
+
## Preview to source navigation
|
|
145
|
+
|
|
146
|
+
`LocalDocumentView` and `LocalReactiveDocument` accept `onSourceNavigate`. When present, rendered paragraphs, headings, interpolations, formulas, control labels and visual frames carry source metadata, and a plain click reports the target:
|
|
147
|
+
|
|
148
|
+
```tsx
|
|
149
|
+
<LocalDocumentView
|
|
150
|
+
document={document}
|
|
151
|
+
runtime={runtime}
|
|
152
|
+
onSourceNavigate={(target) => {
|
|
153
|
+
editor.current?.selectRange(target.range);
|
|
154
|
+
editor.current?.focus();
|
|
155
|
+
}}
|
|
156
|
+
/>
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
`target` contains `range` (UTF-16 half-open offsets), `nodeId`, `nodeType` and, for components, `componentName`. Interactive descendants such as inputs, buttons, links and table controls are ignored, so dragging a slider or sorting a table keeps its behavior; click a control's label to jump to its tag. No extra tab stops are added, hidden content is not rendered, and native HTML iframe content has no reliable mapping.
|
|
160
|
+
|
|
161
|
+
Omit the callback to keep the exact previous DOM and static export. In a 600px-or-narrower container the editor may show only Edit and Preview; switch to Split before selecting a preview target so the selection is visible. `selectRange` focuses the source and does not create an edit or undo step.
|
|
162
|
+
|
|
136
163
|
## Controlled value and history
|
|
137
164
|
|
|
138
165
|
Every edit calls `onChange` with the next source: typing, toolbar formatting, insertion templates, rename, format and undo or redo. Pass that value back into `value`. The editor treats the edits it emits as part of the current session, so a normal controlled round trip keeps undo steps.
|
|
@@ -197,7 +224,7 @@ const result = compileLocal(source);
|
|
|
197
224
|
/>
|
|
198
225
|
```
|
|
199
226
|
|
|
200
|
-
`diagnostics` marks the reported lines in the gutter. Incomplete source remains editable
|
|
227
|
+
`diagnostics` marks the reported lines in the gutter. Incomplete source remains editable through compile errors. `document` supplies binding value types for the authoring inspection panel. Both props are optional.
|
|
201
228
|
|
|
202
229
|
## Sizing and layout
|
|
203
230
|
|
|
@@ -207,7 +234,7 @@ Use `className` or `style` for margins and placement in a host layout. Internal
|
|
|
207
234
|
|
|
208
235
|
## Toolbar and authoring tools
|
|
209
236
|
|
|
210
|
-
`toolbar={false}` removes the formatting and insertion toolbar, including its export action. `authoring={false}` keeps
|
|
237
|
+
`toolbar={false}` removes the formatting and insertion toolbar, including its export action. `authoring={false}` keeps CM6 and its toolbar while disabling author analysis, binding navigation, rename and format. Basic Markdown highlighting remains available. Both default to enabled.
|
|
211
238
|
|
|
212
239
|
The toolbar formats Markdown, inserts lists, tables, links, images and the built-in component templates, and exposes undo and redo. Formatting commands use the current selection and return the next source through `onChange`.
|
|
213
240
|
|
|
@@ -223,16 +250,16 @@ Compilation scheduling and debouncing also stay in the host. See [Local mode int
|
|
|
223
250
|
|
|
224
251
|
## Server rendering
|
|
225
252
|
|
|
226
|
-
The editor entry has no top-level `window` or `document` access.
|
|
253
|
+
The editor entry has no top-level `window` or `document` access. Server rendering produces the editor frame; the CM6 editing view mounts on the client. Focus, selection, completion, layout measurement and toolbar menus require a browser.
|
|
227
254
|
|
|
228
255
|
## Styles and scope
|
|
229
256
|
|
|
230
|
-
`reactive-md
|
|
257
|
+
`reactive-md-editor/styles.css` contains the editor's own tokens and rules. All selectors are scoped to `.reactive-md-editor` or its descendants, so the stylesheet does not restyle host buttons, inputs or the page body. The theme comes from the instance attribute described above.
|
|
231
258
|
|
|
232
259
|
If the same page also renders a document preview, import `reactive-md/styles.css` as well. The two stylesheets are independent and can be loaded in either order.
|
|
233
260
|
|
|
234
261
|
## Compatibility
|
|
235
262
|
|
|
236
|
-
|
|
263
|
+
To migrate from the textarea editor, remove `textareaRef`. Use the ref's `getSource()`, `getSelection()` and `selectRange()` for source and selection, and `getEditorElement()` for DOM access. `reactive-md-editor/codemirror` remains a compatibility alias for the same component, stylesheet and runtime. Document `<textarea>` form controls remain supported.
|
|
237
264
|
|
|
238
265
|
0.5.3 adds compile-option-aware authoring and explicit screen/print styles. See [0.5.3 host integration](../releases/release-0.5.3-en.md). 0.6.0 adds `insertText` to the ref handle; see the [0.6.0 release notes](../releases/release-0.6.0-en.md).
|