@atom63/slides 0.1.1 → 0.3.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/dist/editor/index.d.ts +50 -32
- package/dist/editor/index.js +629 -89
- package/dist/editor/index.js.map +1 -1
- package/dist/vite/index.d.ts +10 -1
- package/dist/vite/index.js +40 -4
- package/dist/vite/index.js.map +1 -1
- package/package.json +11 -4
- package/src/editor/styles.css +277 -0
package/dist/editor/index.d.ts
CHANGED
|
@@ -40,43 +40,61 @@ declare function stripImports(body: string): string;
|
|
|
40
40
|
declare function compileDeck(source: string): Promise<CompileDeckResult>;
|
|
41
41
|
|
|
42
42
|
interface DeckEditorProps {
|
|
43
|
-
/** Raw deck MDX source (frontmatter + body with `---` slide separators). */
|
|
44
43
|
source: string;
|
|
45
|
-
/**
|
|
46
|
-
* Called with the next source on every edit / template insert. When omitted,
|
|
47
|
-
* the editor manages source internally (uncontrolled).
|
|
48
|
-
*/
|
|
49
44
|
onChange?: (next: string) => void;
|
|
50
|
-
/** Debounce window (ms) before recompiling the preview. Default 300. */
|
|
51
45
|
debounceMs?: number;
|
|
52
46
|
}
|
|
53
47
|
/**
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* - left: a LIVE preview rendered by `SlidesPlayer`, compiled from the source
|
|
58
|
-
* at runtime via {@link compileDeck} (browser-safe frontmatter split +
|
|
59
|
-
* strip-imports + `@mdx-js/mdx` evaluate, with slide components injected
|
|
60
|
-
* through MDX context).
|
|
61
|
-
* - right: a `<textarea>` editing surface, a registry-driven template palette
|
|
62
|
-
* (click inserts the template's MDX snippet at the end of the source), and a
|
|
63
|
-
* light/dark theme toggle for the preview container.
|
|
64
|
-
*
|
|
65
|
-
* Compilation is debounced and resilient: the LAST good preview is retained on
|
|
66
|
-
* a failed compile and the error is surfaced in a non-blocking banner, so a bad
|
|
67
|
-
* keystroke never blanks or crashes the editor.
|
|
68
|
-
*
|
|
69
|
-
* The editor's own chrome is styled by self-contained plain CSS shipped as a
|
|
70
|
-
* side-effect import — consumers must `import '@atom63/slides/editor/styles'`
|
|
71
|
-
* (the CSS is intentionally NOT bundled into the JS so it isn't orphaned by the
|
|
72
|
-
* build, mirroring how `@atom63/slides` ships `./styles`).
|
|
73
|
-
*
|
|
74
|
-
* A `<textarea>` is intentional
|
|
75
|
-
* for v0.1; CodeMirror (syntax highlight, structured editing) is a future
|
|
76
|
-
* upgrade. Structured per-slide form editing and template-switch-by-form are
|
|
77
|
-
* explicitly v2 — the source textarea is the only editing surface here.
|
|
48
|
+
* Backward-compatible editor: DeckSurface locked to Edit mode. The unified
|
|
49
|
+
* surface ({@link DeckSurface}) is the preferred API; this remains for existing
|
|
50
|
+
* consumers.
|
|
78
51
|
*/
|
|
79
|
-
declare function DeckEditor({ source
|
|
52
|
+
declare function DeckEditor({ source, onChange, debounceMs }: DeckEditorProps): react_jsx_runtime.JSX.Element;
|
|
53
|
+
|
|
54
|
+
type DeckSurfaceMode = 'present' | 'edit';
|
|
55
|
+
interface DeckSurfaceProps {
|
|
56
|
+
/**
|
|
57
|
+
* Raw deck MDX source (frontmatter + `---`-separated slide body). The single
|
|
58
|
+
* canonical input for both Present and Edit modes.
|
|
59
|
+
*
|
|
60
|
+
* **Controlled vs. uncontrolled:**
|
|
61
|
+
* - When `onChange` is provided the surface is **controlled** — the parent
|
|
62
|
+
* owns source state and must feed back the updated string on each change.
|
|
63
|
+
* - When `onChange` is omitted the surface is **uncontrolled** and
|
|
64
|
+
* **present-only**: `source` is read once on mount and later prop changes
|
|
65
|
+
* are ignored. This is the production / read-only contract.
|
|
66
|
+
*/
|
|
67
|
+
source: string;
|
|
68
|
+
/**
|
|
69
|
+
* Called with the next source string on every edit or template insert
|
|
70
|
+
* (in-memory, per-keystroke). Presence of this prop **enables Edit mode**
|
|
71
|
+
* and makes the surface controlled — the parent holds source state.
|
|
72
|
+
* When omitted the surface is present-only (no edit chrome, no keyboard
|
|
73
|
+
* shortcut to enter Edit).
|
|
74
|
+
*/
|
|
75
|
+
onChange?: (next: string) => void;
|
|
76
|
+
/**
|
|
77
|
+
* Called on an **explicit** save action (Save button or Cmd/Ctrl-S in Edit
|
|
78
|
+
* mode). This is the persistence hook, distinct from the per-keystroke
|
|
79
|
+
* `onChange`. Wire it to the dev write-back plugin (or any async persistence
|
|
80
|
+
* layer) to flush the source to disk on demand. No-op / absent in a
|
|
81
|
+
* production build.
|
|
82
|
+
*/
|
|
83
|
+
onSave?: (source: string) => void | Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* The mode the surface starts in. Defaults to `'present'`. Forced to
|
|
86
|
+
* `'present'` when `onChange` is absent (present-only surfaces cannot enter
|
|
87
|
+
* Edit mode).
|
|
88
|
+
*/
|
|
89
|
+
initialMode?: DeckSurfaceMode;
|
|
90
|
+
/**
|
|
91
|
+
* Debounce window in milliseconds before recompiling the preview after a
|
|
92
|
+
* source change. Defaults to `300`. Pass `0` in tests to compile
|
|
93
|
+
* synchronously on the next microtask tick.
|
|
94
|
+
*/
|
|
95
|
+
debounceMs?: number;
|
|
96
|
+
}
|
|
97
|
+
declare function DeckSurface({ source: sourceProp, onChange, onSave, initialMode, debounceMs, }: DeckSurfaceProps): react_jsx_runtime.JSX.Element;
|
|
80
98
|
|
|
81
99
|
/**
|
|
82
100
|
* Synthesize a minimal, valid MDX usage example from a template's schema.
|
|
@@ -93,4 +111,4 @@ declare function toInsertSnippet(t: TemplateDef): string;
|
|
|
93
111
|
/** Map of `templateName -> insertable MDX snippet`, built from the live registry. */
|
|
94
112
|
declare const templateSnippets: Record<string, string>;
|
|
95
113
|
|
|
96
|
-
export { type CompileDeckResult, DeckEditor, type DeckEditorProps, compileDeck, stripImports, synthExample, templateSnippets, toInsertSnippet };
|
|
114
|
+
export { type CompileDeckResult, DeckEditor, type DeckEditorProps, DeckSurface, type DeckSurfaceMode, type DeckSurfaceProps, compileDeck, stripImports, synthExample, templateSnippets, toInsertSnippet };
|