reactive-md 0.4.0 → 0.5.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.
Files changed (52) hide show
  1. package/CHANGELOG-ch.md +33 -1
  2. package/CHANGELOG.md +33 -1
  3. package/README-ch.md +36 -6
  4. package/README-en.md +37 -7
  5. package/README.md +37 -7
  6. package/THIRD_PARTY_NOTICES.md +94 -1
  7. package/dist-library/reactive-md-editor.css +2 -0
  8. package/dist-library/reactive-md-editor.js +3710 -0
  9. package/dist-library/reactive-md-react.js +9179 -1606
  10. package/dist-library/reactive-md.css +1 -1
  11. package/dist-library/reactive-md.js +98 -97
  12. package/dist-library/{runtime-DtjdPXxJ.js → runtime-DPuMxM_y.js} +1856 -1461
  13. package/dist-library/types/editor/ReactiveMarkdownEditor.d.ts +7 -0
  14. package/dist-library/types/editor/editor-commands.d.ts +50 -0
  15. package/dist-library/types/editor/editor-i18n.d.ts +102 -0
  16. package/dist-library/types/editor/editor-toolbar.d.ts +24 -0
  17. package/dist-library/types/editor/extended-native-components.d.ts +58 -0
  18. package/dist-library/types/editor/index.d.ts +9 -0
  19. package/dist-library/types/editor/locale.d.ts +13 -0
  20. package/dist-library/types/editor/native-components.d.ts +47 -0
  21. package/dist-library/types/editor/source-authoring.d.ts +57 -0
  22. package/dist-library/types/editor/types.d.ts +44 -0
  23. package/dist-library/types/editor/use-gutter-metrics.d.ts +5 -0
  24. package/dist-library/types/editor/use-source-history.d.ts +16 -0
  25. package/dist-library/types/local/code-block.d.ts +24 -0
  26. package/dist-library/types/local/footnotes.d.ts +51 -0
  27. package/dist-library/types/local/image-view.d.ts +21 -0
  28. package/dist-library/types/local/types.d.ts +7 -0
  29. package/dist-standalone/reactive-md-standalone.css +1 -1
  30. package/dist-standalone/reactive-md-standalone.js +47 -36
  31. package/docs/compatibility-ch.md +12 -8
  32. package/docs/compatibility-en.md +12 -8
  33. package/docs/component-protocol-ch.md +2 -2
  34. package/docs/component-protocol-en.md +2 -2
  35. package/docs/editor-ch.md +216 -0
  36. package/docs/editor-en.md +216 -0
  37. package/docs/local-guide-ch.md +11 -5
  38. package/docs/local-guide-en.md +11 -5
  39. package/docs/local-interaction-syntax-ch.md +7 -2
  40. package/docs/local-interaction-syntax-en.md +7 -2
  41. package/docs/release-0.4.0-ch.md +4 -4
  42. package/docs/release-0.4.0-en.md +4 -4
  43. package/docs/release-0.4.1-ch.md +23 -0
  44. package/docs/release-0.4.1-en.md +23 -0
  45. package/docs/release-0.5.0-ch.md +41 -0
  46. package/docs/release-0.5.0-en.md +41 -0
  47. package/docs/releasing-ch.md +18 -11
  48. package/docs/releasing-en.md +18 -11
  49. package/docs/shareable-export-ch.md +4 -2
  50. package/docs/shareable-export-en.md +4 -2
  51. package/examples/integration/react-editor.tsx +74 -0
  52. package/package.json +54 -11
@@ -0,0 +1,74 @@
1
+ import { useMemo, useRef, useState } from 'react';
2
+ import { compileLocal } from 'reactive-md';
3
+ import {
4
+ ReactiveMarkdownEditor,
5
+ type ReactiveMarkdownEditorHandle,
6
+ } from 'reactive-md/editor';
7
+ import 'reactive-md/editor/styles.css';
8
+ import { LocalReactiveDocument } from 'reactive-md/react';
9
+ import 'reactive-md/styles.css';
10
+
11
+ const documents = {
12
+ estimate: `# Cost estimate
13
+
14
+ <panel title="Adjust the plan">
15
+ <slider bind="people" label="People" initial="2" min="1" max="20">
16
+ <toggle bind="annual" label="Annual billing">
17
+ </panel>
18
+
19
+ Monthly cost: **{{ people * (annual ? 80 : 100) }} USD**.`,
20
+ notes: `# Notes
21
+
22
+ Write Markdown here. The source stays in React state.
23
+
24
+ - The editor owns formatting and undo history.
25
+ - The host owns compilation, preview and saving.`,
26
+ };
27
+
28
+ type DocumentId = keyof typeof documents;
29
+
30
+ export function SourceAndPreview() {
31
+ const [documentId, setDocumentId] = useState<DocumentId>('estimate');
32
+ const [source, setSource] = useState(documents.estimate);
33
+ const editor = useRef<ReactiveMarkdownEditorHandle>(null);
34
+ const result = useMemo(() => compileLocal(source), [source]);
35
+
36
+ function openDocument(id: DocumentId) {
37
+ setDocumentId(id);
38
+ setSource(documents[id]);
39
+ }
40
+
41
+ return (
42
+ <div style={{ display: 'grid', gap: 16 }}>
43
+ <div style={{ display: 'flex', gap: 8, flexWrap: 'wrap' }}>
44
+ <button type="button" onClick={() => openDocument('estimate')}>Estimate</button>
45
+ <button type="button" onClick={() => openDocument('notes')}>Notes</button>
46
+ <button type="button" onClick={() => editor.current?.undo()}>Undo</button>
47
+ <button type="button" onClick={() => editor.current?.redo()}>Redo</button>
48
+ </div>
49
+
50
+ <ReactiveMarkdownEditor
51
+ ref={editor}
52
+ value={source}
53
+ onChange={setSource}
54
+ documentKey={documentId}
55
+ diagnostics={result.diagnostics}
56
+ document={result.ok ? result.document : null}
57
+ ariaLabel="Reactive MD source"
58
+ onExport={() => {
59
+ const blob = new Blob([source], { type: 'text/markdown;charset=utf-8' });
60
+ const url = URL.createObjectURL(blob);
61
+ const link = document.createElement('a');
62
+ link.href = url;
63
+ link.download = `${documentId}.reactive.md`;
64
+ link.click();
65
+ URL.revokeObjectURL(url);
66
+ }}
67
+ />
68
+
69
+ {result.ok
70
+ ? <LocalReactiveDocument source={source} />
71
+ : <pre>{result.diagnostics.map(item => `${item.line}:${item.column} ${item.message}`).join('\n')}</pre>}
72
+ </div>
73
+ );
74
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "reactive-md",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Author interactive local documents in Markdown, with expression-bound inputs, charts and diagrams.",
5
5
  "keywords": [
6
6
  "markdown",
@@ -25,16 +25,39 @@
25
25
  "node": ">=22.12.0"
26
26
  },
27
27
  "type": "module",
28
- "workspaces": ["demo"],
29
- "files": ["dist-library", "dist-standalone", "bin", "cli", "README.md", "README-en.md", "README-ch.md", "CONTRIBUTING.md", "CONTRIBUTING-ch.md", "CHANGELOG.md", "CHANGELOG-ch.md", "SECURITY.md", "SECURITY-ch.md", "THIRD_PARTY_NOTICES.md", "docs", "examples"],
30
- "bin": { "reactive-md": "./bin/reactive-md.mjs" },
31
- "sideEffects": ["**/*.css"],
28
+ "workspaces": [
29
+ "demo"
30
+ ],
31
+ "files": [
32
+ "dist-library",
33
+ "dist-standalone",
34
+ "bin",
35
+ "cli",
36
+ "README.md",
37
+ "README-en.md",
38
+ "README-ch.md",
39
+ "CONTRIBUTING.md",
40
+ "CONTRIBUTING-ch.md",
41
+ "CHANGELOG.md",
42
+ "CHANGELOG-ch.md",
43
+ "SECURITY.md",
44
+ "SECURITY-ch.md",
45
+ "THIRD_PARTY_NOTICES.md",
46
+ "docs",
47
+ "examples"
48
+ ],
49
+ "bin": {
50
+ "reactive-md": "./bin/reactive-md.mjs"
51
+ },
52
+ "sideEffects": [
53
+ "**/*.css"
54
+ ],
32
55
  "scripts": {
33
56
  "dev": "npm run build:lib && npm run dev --workspace=@reactive-md/demo",
34
57
  "dev:lib": "vite build --config vite.lib.config.ts --watch",
35
58
  "build": "npm run typecheck && npm run build:lib",
36
59
  "build:standalone": "vite build --config vite.standalone.config.ts",
37
- "build:lib": "vite build --config vite.lib.config.ts && npm run build:standalone && tsc -p tsconfig.lib.json && node scripts/finalize-declarations.mjs",
60
+ "build:lib": "vite build --config vite.lib.config.ts && vite build --config vite.editor.config.ts && npm run build:standalone && tsc -p tsconfig.lib.json && node scripts/finalize-declarations.mjs",
38
61
  "build:demo": "npm run build && npm run build --workspace=@reactive-md/demo",
39
62
  "preview": "npm run preview --workspace=@reactive-md/demo",
40
63
  "typecheck": "tsc --noEmit",
@@ -49,6 +72,10 @@
49
72
  "test:packed": "node scripts/verify-packed.mjs",
50
73
  "test:docs": "node scripts/verify-docs.mjs",
51
74
  "test:theme-browser": "node scripts/verify-theme-browser.mjs",
75
+ "test:date-browser": "node scripts/verify-date-input-browser.mjs",
76
+ "test:editor-browser": "node scripts/verify-editor-browser.mjs",
77
+ "test:markdown-browser": "node scripts/verify-markdown-browser.mjs",
78
+ "test:media-browser": "node scripts/verify-media-browser.mjs",
52
79
  "test:computations-browser": "node scripts/verify-computations-browser.mjs",
53
80
  "test:constraints-browser": "node scripts/verify-constraints-browser.mjs",
54
81
  "verify:memo": "node scripts/verify-memo-browser.mjs",
@@ -62,22 +89,38 @@
62
89
  "prepack": "npm run build && npm run notices"
63
90
  },
64
91
  "exports": {
65
- ".": { "types": "./dist-library/types/index.d.ts", "import": "./dist-library/reactive-md.js" },
66
- "./react": { "types": "./dist-library/types/react/index.d.ts", "import": "./dist-library/reactive-md-react.js" },
67
- "./styles.css": "./dist-library/reactive-md.css"
92
+ ".": {
93
+ "types": "./dist-library/types/index.d.ts",
94
+ "import": "./dist-library/reactive-md.js"
95
+ },
96
+ "./react": {
97
+ "types": "./dist-library/types/react/index.d.ts",
98
+ "import": "./dist-library/reactive-md-react.js"
99
+ },
100
+ "./styles.css": "./dist-library/reactive-md.css",
101
+ "./editor": {
102
+ "types": "./dist-library/types/editor/index.d.ts",
103
+ "import": "./dist-library/reactive-md-editor.js"
104
+ },
105
+ "./editor/styles.css": "./dist-library/reactive-md-editor.css"
68
106
  },
69
107
  "peerDependencies": {
70
108
  "react": "^19.0.0",
71
109
  "react-dom": "^19.0.0"
72
110
  },
73
111
  "peerDependenciesMeta": {
74
- "react": { "optional": true },
75
- "react-dom": { "optional": true }
112
+ "react": {
113
+ "optional": true
114
+ },
115
+ "react-dom": {
116
+ "optional": true
117
+ }
76
118
  },
77
119
  "devDependencies": {
78
120
  "@types/node": "26.6.5",
79
121
  "@types/react": "19.3.0",
80
122
  "@types/react-dom": "19.3.0",
123
+ "lowlight": "3.3.0",
81
124
  "react": "19.3.1",
82
125
  "react-dom": "19.3.1",
83
126
  "remark-gfm": "4.0.1",