orz-slides 0.2.0 → 0.4.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/browser-entry.d.ts +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +53 -113
- package/dist/layout.d.ts +15 -0
- package/dist/lib.d.ts +43 -0
- package/dist/lib.js +189 -0
- package/dist/orz-slides.browser.js +69 -73
- package/dist/render-slide.d.ts +18 -0
- package/dist/slide-parser.d.ts +15 -0
- package/dist/template.d.ts +76 -0
- package/dist/types.d.ts +127 -0
- package/package.json +10 -2
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP5 — Assembler. A parsed `Slide` → a reveal.js `<section>` per
|
|
3
|
+
* docs/dom-contract.md: title band + content grid (regions filled with
|
|
4
|
+
* orz-markdown) + footer + floats + speaker notes.
|
|
5
|
+
*
|
|
6
|
+
* Pure: takes a markdown renderer (orz-markdown's `md`) so this module has no
|
|
7
|
+
* direct orz-markdown dependency and stays unit-testable in node.
|
|
8
|
+
*/
|
|
9
|
+
import type { Slide, DeckConfig, Deck } from './types.js';
|
|
10
|
+
/** Minimal markdown renderer interface (orz-markdown's `md` satisfies it). */
|
|
11
|
+
export interface Renderer {
|
|
12
|
+
render(src: string): string;
|
|
13
|
+
renderInline?(src: string): string;
|
|
14
|
+
}
|
|
15
|
+
/** Render one slide to a reveal `<section>`. */
|
|
16
|
+
export declare function renderSlide(slide: Slide, md: Renderer, deck: DeckConfig): string;
|
|
17
|
+
/** Render a whole deck's slides (joined `<section>`s for `.reveal .slides`). */
|
|
18
|
+
export declare function renderDeck(deck: Deck, md: Renderer): string;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WP1 — Slide parser. Deck source → Deck AST.
|
|
3
|
+
*
|
|
4
|
+
* Pure functions only (no DOM, no network). Implements DESIGN.md §4–§5:
|
|
5
|
+
* - split the source into slides at `<!-- slide … -->` markers,
|
|
6
|
+
* - parse a leading `<!-- deck … -->` block into DeckConfig,
|
|
7
|
+
* - expand a preset alias (or parse a raw row/col split grammar) into a
|
|
8
|
+
* fully-expanded LayoutNode tree (the layout engine never sees a preset
|
|
9
|
+
* name — the parser owns expansion, §5.4.1),
|
|
10
|
+
* - parse region bodies (`<!-- @name -->`), reserved regions
|
|
11
|
+
* (`@notes` / `@footer` / `@float`), per-slide options, the leading-h2
|
|
12
|
+
* title, and the heading lint rules (§5.2).
|
|
13
|
+
*/
|
|
14
|
+
import type { Deck } from './types.js';
|
|
15
|
+
export declare function parseDeck(source: string): Deck;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Builds the self-contained `.slides.html` shell:
|
|
3
|
+
* <head> reveal.js CSS + KaTeX CSS + the slide theme (inline or CDN link)
|
|
4
|
+
* + the editor chrome styles
|
|
5
|
+
* <body> an empty .reveal/.slides container, the editor chrome (FAB + docked
|
|
6
|
+
* CodeMirror panel + banners), the embedded deck source in
|
|
7
|
+
* <script id="orz-deck">, the engine bundle (inline or CDN), a config
|
|
8
|
+
* object, the boot call, and the in-file app (assets/app.js).
|
|
9
|
+
*
|
|
10
|
+
* The deck source in #orz-deck is the single source of truth: the engine renders
|
|
11
|
+
* it on load, and the editor re-serialises it on save (self-reproducing).
|
|
12
|
+
*/
|
|
13
|
+
export interface ThemeEntry {
|
|
14
|
+
id: string;
|
|
15
|
+
name: string;
|
|
16
|
+
scheme: 'light' | 'dark';
|
|
17
|
+
href: string;
|
|
18
|
+
}
|
|
19
|
+
export type RendererSpec = {
|
|
20
|
+
mode: 'inline';
|
|
21
|
+
js: string;
|
|
22
|
+
} | {
|
|
23
|
+
mode: 'cdn';
|
|
24
|
+
src: string;
|
|
25
|
+
};
|
|
26
|
+
export type ThemeSpec = {
|
|
27
|
+
mode: 'inline';
|
|
28
|
+
base: string;
|
|
29
|
+
themes: Array<{
|
|
30
|
+
id: string;
|
|
31
|
+
css: string;
|
|
32
|
+
}>;
|
|
33
|
+
} | {
|
|
34
|
+
mode: 'cdn';
|
|
35
|
+
};
|
|
36
|
+
export type RevealCssSpec = {
|
|
37
|
+
mode: 'inline';
|
|
38
|
+
reset: string;
|
|
39
|
+
core: string;
|
|
40
|
+
} | {
|
|
41
|
+
mode: 'cdn';
|
|
42
|
+
resetUrl: string;
|
|
43
|
+
coreUrl: string;
|
|
44
|
+
};
|
|
45
|
+
export interface EditorLibs {
|
|
46
|
+
codemirrorCss: string;
|
|
47
|
+
codemirrorLightThemeCss: string;
|
|
48
|
+
codemirrorDarkThemeCss: string;
|
|
49
|
+
codemirrorJs: string;
|
|
50
|
+
codemirrorMarkdownJs: string;
|
|
51
|
+
codemirrorContinuelistJs: string;
|
|
52
|
+
}
|
|
53
|
+
export interface BuildOptions {
|
|
54
|
+
source: string;
|
|
55
|
+
title: string;
|
|
56
|
+
filename: string;
|
|
57
|
+
docId: string;
|
|
58
|
+
rendererVersion: string;
|
|
59
|
+
renderer: RendererSpec;
|
|
60
|
+
theme: ThemeSpec;
|
|
61
|
+
defaultTheme: string;
|
|
62
|
+
themes: ThemeEntry[];
|
|
63
|
+
ratio: string;
|
|
64
|
+
versionManifest: string;
|
|
65
|
+
appJs: string;
|
|
66
|
+
runtime: string;
|
|
67
|
+
editorLibs: EditorLibs;
|
|
68
|
+
revealCss: RevealCssSpec;
|
|
69
|
+
cdn: {
|
|
70
|
+
katexCss: string;
|
|
71
|
+
mermaidJs: string;
|
|
72
|
+
smilesJs: string;
|
|
73
|
+
chartJs: string;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
export declare function buildHtml(o: BuildOptions): string;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* orz-slides — shared types (the locked interface for all modules).
|
|
3
|
+
*
|
|
4
|
+
* The parser (WP1) produces a `Deck`; the layout engine (WP2) turns a
|
|
5
|
+
* `LayoutNode` into grid DOM; the assembler (WP5) renders a `Slide` to a reveal
|
|
6
|
+
* `<section>`. These types are the contract — do not change them without
|
|
7
|
+
* updating BUILD-PLAN.md and the affected modules.
|
|
8
|
+
*
|
|
9
|
+
* See DESIGN.md §5 for the authoring syntax these types model, and
|
|
10
|
+
* docs/dom-contract.md for the rendered DOM/CSS contract.
|
|
11
|
+
*/
|
|
12
|
+
/** Deck-level config from the leading `<!-- deck … -->` block. */
|
|
13
|
+
export interface DeckConfig {
|
|
14
|
+
title?: string;
|
|
15
|
+
/** Theme id, e.g. 'paper' | 'executive' | 'neon' … (default chosen by app). */
|
|
16
|
+
theme?: string;
|
|
17
|
+
/** Slide aspect ratio: '16:9' (default) | '4:3'. */
|
|
18
|
+
ratio?: string;
|
|
19
|
+
author?: string;
|
|
20
|
+
/** Deck-wide footer (markdown/text), shown on normal slides unless overridden. */
|
|
21
|
+
footer?: string;
|
|
22
|
+
/** Default reveal transition. */
|
|
23
|
+
transition?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* A grid track size token, as written in the layout grammar:
|
|
27
|
+
* '2' (= 2fr) · 'auto' · '1fr' · '30%' · '200px'
|
|
28
|
+
* The layout engine normalizes bare numbers to `fr`.
|
|
29
|
+
*/
|
|
30
|
+
export type Track = string;
|
|
31
|
+
/** A layout node is either a split (row/col) or a region leaf. */
|
|
32
|
+
export type LayoutNode = SplitNode | RegionLeaf;
|
|
33
|
+
export interface SplitNode {
|
|
34
|
+
kind: 'split';
|
|
35
|
+
dir: 'row' | 'col';
|
|
36
|
+
/** One track per child (same length as `children`). */
|
|
37
|
+
tracks: Track[];
|
|
38
|
+
children: LayoutNode[];
|
|
39
|
+
}
|
|
40
|
+
export interface RegionLeaf {
|
|
41
|
+
kind: 'region';
|
|
42
|
+
/** Region name; filled by a `<!-- @name -->` marker. Flat + unique per slide. */
|
|
43
|
+
name: string;
|
|
44
|
+
}
|
|
45
|
+
/** A content region: the markdown that fills one layout leaf. */
|
|
46
|
+
export interface Region {
|
|
47
|
+
name: string;
|
|
48
|
+
/** Raw orz-markdown for this region (rendered by the assembler). */
|
|
49
|
+
markdown: string;
|
|
50
|
+
}
|
|
51
|
+
/** A free-positioned overlay box (`<!-- @float … -->`), outside the grid. */
|
|
52
|
+
export interface FloatRegion {
|
|
53
|
+
/** Geometry; values are CSS lengths ('30%', '200px'). z defaults to order. */
|
|
54
|
+
geom: {
|
|
55
|
+
left?: string;
|
|
56
|
+
right?: string;
|
|
57
|
+
top?: string;
|
|
58
|
+
bottom?: string;
|
|
59
|
+
w?: string;
|
|
60
|
+
h?: string;
|
|
61
|
+
z?: number;
|
|
62
|
+
};
|
|
63
|
+
markdown: string;
|
|
64
|
+
}
|
|
65
|
+
/** Per-slide options from the `<!-- slide … -->` marker. */
|
|
66
|
+
export interface SlideOptions {
|
|
67
|
+
/** Background color or image. */
|
|
68
|
+
bg?: string;
|
|
69
|
+
transition?: string;
|
|
70
|
+
/** Overflow behavior; default 'fit' (scale-to-fit). */
|
|
71
|
+
fit?: 'fit' | 'scroll' | 'off';
|
|
72
|
+
class?: string;
|
|
73
|
+
id?: string;
|
|
74
|
+
/** Step-reveal: auto-tag the slide's content as reveal fragments (lists
|
|
75
|
+
* reveal per-item, other top-level blocks one at a time, in document order). */
|
|
76
|
+
step?: boolean;
|
|
77
|
+
}
|
|
78
|
+
export interface LintMsg {
|
|
79
|
+
level: 'error' | 'warn';
|
|
80
|
+
message: string;
|
|
81
|
+
}
|
|
82
|
+
export type SlideKind = 'normal' | 'template';
|
|
83
|
+
export interface Slide {
|
|
84
|
+
/** 0-based position in the deck. */
|
|
85
|
+
index: number;
|
|
86
|
+
kind: SlideKind;
|
|
87
|
+
/** For kind==='template': 'title' | 'section' | 'outline' | 'closing'. */
|
|
88
|
+
template?: string;
|
|
89
|
+
/** Template visual variant (from `v=`). */
|
|
90
|
+
templateVariant?: number;
|
|
91
|
+
/**
|
|
92
|
+
* Normal slide title — the markdown of the single leading h2 (without the
|
|
93
|
+
* `## `), auto-lifted into the title band. Undefined if none.
|
|
94
|
+
*/
|
|
95
|
+
title?: string;
|
|
96
|
+
/** Content-area layout (normal slides). Template slides carry their own. */
|
|
97
|
+
layout: LayoutNode;
|
|
98
|
+
/** Content regions (by name) parsed from `<!-- @name -->` markers. */
|
|
99
|
+
regions: Region[];
|
|
100
|
+
/** Float overlays (`<!-- @float … -->`), in declaration order. */
|
|
101
|
+
floats: FloatRegion[];
|
|
102
|
+
/** Slide-level footer markdown (`<!-- @footer -->`), overrides deck footer. */
|
|
103
|
+
footer?: string;
|
|
104
|
+
/** Speaker notes markdown (`<!-- @notes -->`). */
|
|
105
|
+
notes?: string;
|
|
106
|
+
options: SlideOptions;
|
|
107
|
+
/** Lint findings (heading rules, unknown regions, etc.). */
|
|
108
|
+
lint: LintMsg[];
|
|
109
|
+
/** Original source text of this slide (for lossless round-trip on save). */
|
|
110
|
+
raw: string;
|
|
111
|
+
}
|
|
112
|
+
export interface Deck {
|
|
113
|
+
config: DeckConfig;
|
|
114
|
+
slides: Slide[];
|
|
115
|
+
}
|
|
116
|
+
/** WP1 — parse a deck source into a `Deck`. */
|
|
117
|
+
export type ParseDeck = (source: string) => Deck;
|
|
118
|
+
/** WP2 — expand a preset alias (+ optional ratio like '3/2') to a layout tree. */
|
|
119
|
+
export type ExpandPreset = (name: string, ratio?: string) => LayoutNode | null;
|
|
120
|
+
/** WP2 — render a layout tree to nested grid DOM with empty region cells. */
|
|
121
|
+
export interface GridRender {
|
|
122
|
+
/** Grid container HTML; leaves are `<div class="orz-region" data-region="…">`. */
|
|
123
|
+
html: string;
|
|
124
|
+
/** Region names in document order (for the assembler to fill). */
|
|
125
|
+
regions: string[];
|
|
126
|
+
}
|
|
127
|
+
export type RenderLayout = (node: LayoutNode) => GridRender;
|
package/package.json
CHANGED
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orz-slides",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Self-contained, editable HTML slide decks (.slides.html) authored in orz-markdown with a layout syntax. Sibling of orz-mdhtml.",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"main": "./dist/lib.js",
|
|
7
|
+
"types": "./dist/lib.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/lib.d.ts",
|
|
11
|
+
"default": "./dist/lib.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
6
14
|
"bin": {
|
|
7
15
|
"orz-slides": "dist/cli.js"
|
|
8
16
|
},
|
|
@@ -36,7 +44,7 @@
|
|
|
36
44
|
"url": "https://github.com/wangyu16/orz-slides"
|
|
37
45
|
},
|
|
38
46
|
"dependencies": {
|
|
39
|
-
"orz-markdown": "^1.3.
|
|
47
|
+
"orz-markdown": "^1.3.2",
|
|
40
48
|
"reveal.js": "^5.0.4"
|
|
41
49
|
},
|
|
42
50
|
"devDependencies": {
|