@open-slide/core 2.0.0-beta.3 → 2.0.0-beta.6

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 (51) hide show
  1. package/README.md +1 -1
  2. package/dist/{build-Bzy-qlGc.js → build-Cu5_qRyE.js} +1 -1
  3. package/dist/cli/bin.js +3 -3
  4. package/dist/{config-nbSvY7z_.js → config-BQ6rD2iE.js} +226 -27
  5. package/dist/{config-DjWifhaA.d.ts → config-GMR1QUlM.d.ts} +1 -1
  6. package/dist/{dev-MXa5Tod4.js → dev-BK641O5e.js} +1 -1
  7. package/dist/index.d.ts +2 -2
  8. package/dist/index.js +1 -1
  9. package/dist/locale/index.d.ts +1 -1
  10. package/dist/locale/index.js +1 -1
  11. package/dist/{preview-DEpQcKz3.js → preview-BuCI-RMW.js} +1 -1
  12. package/dist/{types-BWg-Dtbg.d.ts → types-BcbaKTNY.d.ts} +60 -0
  13. package/dist/vite/index.d.ts +1 -1
  14. package/dist/vite/index.js +1 -1
  15. package/dist/{zh-tw-DlKyeNX7.js → zh-tw-DlZoAc2-.js} +271 -35
  16. package/package.json +6 -6
  17. package/src/app/components/asset-view.tsx +448 -0
  18. package/src/app/components/history-provider.tsx +68 -44
  19. package/src/app/components/icon-switcher-indicator.tsx +10 -0
  20. package/src/app/components/inspector/arrange-panel.tsx +449 -0
  21. package/src/app/components/inspector/inline-text-editor.tsx +170 -284
  22. package/src/app/components/inspector/inspect-overlay.tsx +642 -295
  23. package/src/app/components/inspector/inspector-panel.tsx +434 -427
  24. package/src/app/components/inspector/inspector-provider.tsx +564 -293
  25. package/src/app/components/inspector/save-bar.tsx +36 -0
  26. package/src/app/components/note-markdown.test.tsx +42 -0
  27. package/src/app/components/note-markdown.tsx +85 -0
  28. package/src/app/components/panel/editor-sidebar.tsx +50 -0
  29. package/src/app/components/panel/panel-fields.tsx +204 -16
  30. package/src/app/components/panel/panel-shell.tsx +3 -18
  31. package/src/app/components/style-panel/style-panel.tsx +4 -69
  32. package/src/app/lib/assets.ts +33 -0
  33. package/src/app/lib/export-html.ts +48 -5
  34. package/src/app/lib/inspector/geometry.test.ts +324 -0
  35. package/src/app/lib/inspector/geometry.ts +207 -0
  36. package/src/app/lib/inspector/text-edit-timeline.test.ts +121 -0
  37. package/src/app/lib/inspector/text-edit-timeline.ts +12 -0
  38. package/src/app/lib/inspector/text-selection.ts +117 -0
  39. package/src/app/lib/inspector/use-editor.ts +1 -1
  40. package/src/app/lib/inspector/use-visual-editor.ts +429 -0
  41. package/src/app/lib/inspector/visual-dom.ts +255 -0
  42. package/src/app/lib/keys.ts +9 -0
  43. package/src/app/lib/note-markdown.test.ts +147 -0
  44. package/src/app/lib/note-markdown.ts +116 -0
  45. package/src/app/routes/presenter.tsx +3 -2
  46. package/src/app/routes/slide.tsx +34 -9
  47. package/src/locale/en.ts +71 -9
  48. package/src/locale/ja.ts +73 -8
  49. package/src/locale/types.ts +60 -0
  50. package/src/locale/zh-cn.ts +69 -9
  51. package/src/locale/zh-tw.ts +69 -9
@@ -0,0 +1,255 @@
1
+ import type { SelectedTarget } from '@/components/inspector/inspector-provider';
2
+ import { findSlideSource } from './fiber';
3
+ import {
4
+ type Point,
5
+ type Rect,
6
+ rectContains,
7
+ rectsIntersect,
8
+ solveResizeDimensions,
9
+ } from './geometry';
10
+ import type { EditOp } from './use-editor';
11
+
12
+ export type Canvas = {
13
+ root: HTMLElement;
14
+ rect: DOMRect;
15
+ scale: number;
16
+ width: number;
17
+ height: number;
18
+ };
19
+
20
+ export function readCanvas(): Canvas | null {
21
+ const root = document.querySelector<HTMLElement>('[data-inspector-root] [data-osd-canvas]');
22
+ if (!root) return null;
23
+ const rect = root.getBoundingClientRect();
24
+ const width = root.offsetWidth;
25
+ const height = root.offsetHeight;
26
+ if (!width || !height || !rect.width) return null;
27
+ return { root, rect, scale: rect.width / width, width, height };
28
+ }
29
+
30
+ export function readFrame(anchor: HTMLElement, canvas: Canvas): Rect {
31
+ const rect = anchor.getBoundingClientRect();
32
+ return {
33
+ x: (rect.left - canvas.rect.left) / canvas.scale,
34
+ y: (rect.top - canvas.rect.top) / canvas.scale,
35
+ width: rect.width / canvas.scale,
36
+ height: rect.height / canvas.scale,
37
+ };
38
+ }
39
+
40
+ export function readRotation(anchor: HTMLElement): number {
41
+ const value = getComputedStyle(anchor).rotate;
42
+ if (value === 'none') return 0;
43
+ const angle = value.split(' ').at(-1) ?? '0';
44
+ const n = Number.parseFloat(angle) || 0;
45
+ return angle.endsWith('grad')
46
+ ? n * 0.9
47
+ : angle.endsWith('rad')
48
+ ? (n * 180) / Math.PI
49
+ : angle.endsWith('turn')
50
+ ? n * 360
51
+ : n;
52
+ }
53
+
54
+ export function editableTargets(canvas: Canvas, slideId: string): SelectedTarget[] {
55
+ const anchors = new Set<HTMLElement>();
56
+ const targets: SelectedTarget[] = [];
57
+ for (const element of canvas.root.querySelectorAll<HTMLElement>('[data-slide-loc]')) {
58
+ const hit = findSlideSource(element, slideId, { hostOnly: true });
59
+ if (!hit || anchors.has(hit.anchor) || hit.anchor.closest('[aria-hidden="true"]')) continue;
60
+ const rect = hit.anchor.getBoundingClientRect();
61
+ const style = getComputedStyle(hit.anchor);
62
+ if (!rect.width || !rect.height || style.visibility === 'hidden' || style.display === 'none')
63
+ continue;
64
+ anchors.add(hit.anchor);
65
+ targets.push(hit);
66
+ }
67
+ return targets;
68
+ }
69
+
70
+ export function independentTargets(targets: SelectedTarget[]): SelectedTarget[] {
71
+ return targets.filter(
72
+ (target, index) =>
73
+ targets.findIndex((other) => other.anchor === target.anchor) === index &&
74
+ !targets.some(
75
+ (other) => other.anchor !== target.anchor && other.anchor.contains(target.anchor),
76
+ ),
77
+ );
78
+ }
79
+
80
+ // A partially covered ancestor yields to the children the marquee also
81
+ // touches, so sweeping across a few cards picks the cards, not their wrapper.
82
+ export function marqueeTargets(
83
+ rect: Rect,
84
+ candidates: Array<{ target: SelectedTarget; frame: Rect }>,
85
+ ): SelectedTarget[] {
86
+ const hits = candidates.filter(({ frame }) => rectsIntersect(rect, frame));
87
+ return hits
88
+ .filter(
89
+ ({ target, frame }) =>
90
+ rectContains(rect, frame) ||
91
+ !hits.some(
92
+ (other) =>
93
+ other.target.anchor !== target.anchor && target.anchor.contains(other.target.anchor),
94
+ ),
95
+ )
96
+ .map(({ target }) => target);
97
+ }
98
+
99
+ export function canTransform(target: SelectedTarget, canvas: Canvas): boolean {
100
+ const style = getComputedStyle(target.anchor);
101
+ const rect = target.anchor.getBoundingClientRect();
102
+ return (
103
+ target.anchor.isConnected &&
104
+ canvas.root.contains(target.anchor) &&
105
+ style.display !== 'contents' &&
106
+ rect.width > 0 &&
107
+ rect.height > 0 &&
108
+ (style.display !== 'inline' || target.anchor instanceof HTMLImageElement) &&
109
+ canvas.root.querySelectorAll(`[data-slide-loc="${target.line}:${target.column}"]`).length === 1
110
+ );
111
+ }
112
+
113
+ export type TransformSnapshot = {
114
+ target: SelectedTarget;
115
+ frame: Rect;
116
+ style: string | null;
117
+ translate: Point;
118
+ basis: { a: number; b: number; c: number; d: number };
119
+ rotation: number;
120
+ width: number;
121
+ height: number;
122
+ };
123
+
124
+ export function captureTransform(target: SelectedTarget, canvas: Canvas): TransformSnapshot {
125
+ const { anchor } = target;
126
+ const style = anchor.getAttribute('style');
127
+ const frame = readFrame(anchor, canvas);
128
+ const rotation = readRotation(anchor);
129
+ const computed = getComputedStyle(anchor);
130
+ const width = Number.parseFloat(computed.width) || anchor.offsetWidth;
131
+ const height = Number.parseFloat(computed.height) || anchor.offsetHeight;
132
+ const before = anchor.getBoundingClientRect();
133
+ // Probe the browser's coordinate basis so nested transforms and percentage translations survive.
134
+ anchor.style.transition = 'none';
135
+ anchor.style.translate = '0px 0px';
136
+ const zero = anchor.getBoundingClientRect();
137
+ anchor.style.translate = '100px 0px';
138
+ const x = anchor.getBoundingClientRect();
139
+ anchor.style.translate = '0px 100px';
140
+ const y = anchor.getBoundingClientRect();
141
+ restoreStyle(anchor, style);
142
+ const basis = {
143
+ a: (x.x - zero.x) / 100,
144
+ b: (x.y - zero.y) / 100,
145
+ c: (y.x - zero.x) / 100,
146
+ d: (y.y - zero.y) / 100,
147
+ };
148
+ const translate = localDelta(basis, { x: before.x - zero.x, y: before.y - zero.y });
149
+ return { target, frame, style, translate, basis, rotation, width, height };
150
+ }
151
+
152
+ function localDelta(basis: TransformSnapshot['basis'], delta: Point): Point {
153
+ const determinant = basis.a * basis.d - basis.b * basis.c;
154
+ if (Math.abs(determinant) < 0.000001) return { x: 0, y: 0 };
155
+ return {
156
+ x: (basis.d * delta.x - basis.c * delta.y) / determinant,
157
+ y: (basis.a * delta.y - basis.b * delta.x) / determinant,
158
+ };
159
+ }
160
+
161
+ export function styleOp(key: string, value: string): EditOp {
162
+ return { kind: 'set-style', key, value };
163
+ }
164
+
165
+ export function moveOps(snapshot: TransformSnapshot, delta: Point, canvas: Canvas): EditOp[] {
166
+ const local = localDelta(snapshot.basis, {
167
+ x: delta.x * canvas.scale,
168
+ y: delta.y * canvas.scale,
169
+ });
170
+ return [
171
+ styleOp(
172
+ 'translate',
173
+ `${round(snapshot.translate.x + local.x)}px ${round(snapshot.translate.y + local.y)}px`,
174
+ ),
175
+ ];
176
+ }
177
+
178
+ export function sizeOps(
179
+ snapshot: TransformSnapshot,
180
+ frame: Rect,
181
+ canvas: Canvas,
182
+ fixedPoint: Point = { x: 0, y: 0 },
183
+ ): EditOp[] {
184
+ const anchor = snapshot.target.anchor;
185
+ restoreTransform(snapshot);
186
+ const constraints = [
187
+ styleOp('minWidth', '0px'),
188
+ styleOp('minHeight', '0px'),
189
+ styleOp('maxWidth', 'none'),
190
+ styleOp('maxHeight', 'none'),
191
+ styleOp('flexShrink', '0'),
192
+ styleOp('flexGrow', '0'),
193
+ styleOp('flexBasis', 'auto'),
194
+ ];
195
+ const dimensions = (width: number, height: number) => [
196
+ styleOp('width', `${round(Math.max(8, width))}px`),
197
+ styleOp('height', `${round(Math.max(8, height))}px`),
198
+ ];
199
+ anchor.style.transition = 'none';
200
+ previewOps(anchor, [
201
+ ...constraints,
202
+ ...dimensions(snapshot.width, snapshot.height),
203
+ ...moveOps(snapshot, { x: 0, y: 0 }, canvas),
204
+ ]);
205
+ const base = readFrame(anchor, canvas);
206
+ previewOps(anchor, dimensions(snapshot.width + 100, snapshot.height));
207
+ const wider = readFrame(anchor, canvas);
208
+ previewOps(anchor, dimensions(snapshot.width, snapshot.height + 100));
209
+ const taller = readFrame(anchor, canvas);
210
+ const basis = {
211
+ a: (wider.width - base.width) / 100,
212
+ b: (wider.height - base.height) / 100,
213
+ c: (taller.width - base.width) / 100,
214
+ d: (taller.height - base.height) / 100,
215
+ };
216
+ const size = solveResizeDimensions(snapshot, basis, {
217
+ x: frame.width - base.width,
218
+ y: frame.height - base.height,
219
+ });
220
+ const ops = [...constraints, ...dimensions(size.width, size.height)];
221
+ previewOps(anchor, ops);
222
+ const measured = readFrame(anchor, canvas);
223
+ const position = moveOps(
224
+ snapshot,
225
+ {
226
+ x: frame.x + (frame.width - measured.width) * fixedPoint.x - measured.x,
227
+ y: frame.y + (frame.height - measured.height) * fixedPoint.y - measured.y,
228
+ },
229
+ canvas,
230
+ );
231
+ restoreTransform(snapshot);
232
+ return [...ops, ...position];
233
+ }
234
+
235
+ export function previewOps(anchor: HTMLElement, ops: EditOp[]) {
236
+ const style = anchor.style as unknown as Record<string, string>;
237
+ for (const op of ops) if (op.kind === 'set-style') style[op.key] = op.value ?? '';
238
+ }
239
+
240
+ export function restoreTransform(snapshot: TransformSnapshot) {
241
+ restoreStyle(snapshot.target.anchor, snapshot.style);
242
+ }
243
+
244
+ function restoreStyle(anchor: HTMLElement, style: string | null) {
245
+ if (style === null) anchor.removeAttribute('style');
246
+ else anchor.setAttribute('style', style);
247
+ anchor.style.transition = 'none';
248
+ anchor.getBoundingClientRect();
249
+ if (style === null) anchor.removeAttribute('style');
250
+ else anchor.setAttribute('style', style);
251
+ }
252
+
253
+ export function round(value: number): number {
254
+ return Math.round(value * 100) / 100;
255
+ }
@@ -4,6 +4,15 @@ export function isTypingTarget(target: EventTarget | null): boolean {
4
4
  );
5
5
  }
6
6
 
7
+ export function isShortcutControlTarget(target: EventTarget | null): boolean {
8
+ return (
9
+ target instanceof Element &&
10
+ !!target.closest(
11
+ 'button, a, input, textarea, select, summary, [role="dialog"], [role="menu"], [role="listbox"], [role="tablist"], [data-inspector-ui], [data-design-ui]',
12
+ )
13
+ );
14
+ }
15
+
7
16
  // Single-letter shortcuts bail on this so browser combos (⌘P, ⌘F…) still work.
8
17
  export function hasModifier(e: KeyboardEvent): boolean {
9
18
  return e.altKey || e.ctrlKey || e.metaKey;
@@ -0,0 +1,147 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { type NoteInline, parseInline, parseNoteMarkdown } from './note-markdown.ts';
3
+
4
+ const text = (t: string): NoteInline => ({ type: 'text', text: t });
5
+
6
+ describe('parseInline', () => {
7
+ it('returns plain text untouched', () => {
8
+ expect(parseInline('just a sentence')).toEqual([text('just a sentence')]);
9
+ });
10
+
11
+ it('parses bold', () => {
12
+ expect(parseInline('a **key** point')).toEqual([
13
+ text('a '),
14
+ { type: 'strong', children: [text('key')] },
15
+ text(' point'),
16
+ ]);
17
+ });
18
+
19
+ it('parses italic with stars and underscores', () => {
20
+ expect(parseInline('*a* and _b_')).toEqual([
21
+ { type: 'em', children: [text('a')] },
22
+ text(' and '),
23
+ { type: 'em', children: [text('b')] },
24
+ ]);
25
+ });
26
+
27
+ it('parses inline code literally', () => {
28
+ expect(parseInline('run `pnpm **dev**`')).toEqual([
29
+ text('run '),
30
+ { type: 'code', text: 'pnpm **dev**' },
31
+ ]);
32
+ });
33
+
34
+ it('parses italic nested in bold', () => {
35
+ expect(parseInline('**bold _in_ here**')).toEqual([
36
+ {
37
+ type: 'strong',
38
+ children: [text('bold '), { type: 'em', children: [text('in')] }, text(' here')],
39
+ },
40
+ ]);
41
+ });
42
+
43
+ it('leaves snake_case and unpaired markers alone', () => {
44
+ expect(parseInline('use snake_case_names here')).toEqual([text('use snake_case_names here')]);
45
+ expect(parseInline('2 * 3 and a_b')).toEqual([text('2 * 3 and a_b')]);
46
+ });
47
+
48
+ it('treats backslash-escaped delimiters as literal text', () => {
49
+ expect(parseInline('\\*not italic\\*')).toEqual([text('*not italic*')]);
50
+ expect(parseInline('\\**emphasis**')).toEqual([
51
+ text('*'),
52
+ { type: 'em', children: [text('emphasis')] },
53
+ text('*'),
54
+ ]);
55
+ expect(parseInline('a \\` b and \\\\ done')).toEqual([text('a ` b and \\ done')]);
56
+ });
57
+
58
+ it('keeps the backslash inside code spans', () => {
59
+ expect(parseInline('`a\\*b`')).toEqual([{ type: 'code', text: 'a\\*b' }]);
60
+ });
61
+
62
+ it('does not pair emphasis markers padded with spaces', () => {
63
+ expect(parseInline('2 * 3 = 6 and 5 * 4')).toEqual([text('2 * 3 = 6 and 5 * 4')]);
64
+ expect(parseInline('a ** b ** c')).toEqual([text('a ** b ** c')]);
65
+ expect(parseInline('a _ b _ c')).toEqual([text('a _ b _ c')]);
66
+ expect(parseInline('*a* and *no trail *')).toEqual([
67
+ { type: 'em', children: [text('a')] },
68
+ text(' and *no trail *'),
69
+ ]);
70
+ });
71
+ });
72
+
73
+ describe('parseNoteMarkdown', () => {
74
+ it('splits paragraphs on blank lines and keeps line breaks inside one', () => {
75
+ expect(parseNoteMarkdown('one\ntwo\n\nthree')).toEqual([
76
+ { type: 'paragraph', lines: [[text('one')], [text('two')]] },
77
+ { type: 'paragraph', lines: [[text('three')]] },
78
+ ]);
79
+ });
80
+
81
+ it('parses headings up to level 3', () => {
82
+ expect(parseNoteMarkdown('# Intro\n#### not a heading')).toEqual([
83
+ { type: 'heading', level: 1, children: [text('Intro')] },
84
+ { type: 'paragraph', lines: [[text('#### not a heading')]] },
85
+ ]);
86
+ });
87
+
88
+ it('groups consecutive bullets into one list', () => {
89
+ expect(parseNoteMarkdown('- a\n- **b**\ntail')).toEqual([
90
+ {
91
+ type: 'list',
92
+ ordered: false,
93
+ items: [[text('a')], [{ type: 'strong', children: [text('b')] }]],
94
+ },
95
+ { type: 'paragraph', lines: [[text('tail')]] },
96
+ ]);
97
+ });
98
+
99
+ it('parses ordered lists with dot or paren markers', () => {
100
+ expect(parseNoteMarkdown('1. a\n2) b')).toEqual([
101
+ { type: 'list', ordered: true, items: [[text('a')], [text('b')]] },
102
+ ]);
103
+ });
104
+
105
+ it('keeps unordered and ordered runs as separate lists', () => {
106
+ expect(parseNoteMarkdown('- a\n1. b')).toEqual([
107
+ { type: 'list', ordered: false, items: [[text('a')]] },
108
+ { type: 'list', ordered: true, items: [[text('b')]] },
109
+ ]);
110
+ });
111
+
112
+ it('does not treat a mid-sentence star line as a bullet without a space', () => {
113
+ expect(parseNoteMarkdown('*emphasis line*')).toEqual([
114
+ { type: 'paragraph', lines: [[{ type: 'em', children: [text('emphasis line')] }]] },
115
+ ]);
116
+ });
117
+
118
+ it('escapes disable heading and list markers', () => {
119
+ expect(parseNoteMarkdown('\\# not a heading')).toEqual([
120
+ { type: 'paragraph', lines: [[text('# not a heading')]] },
121
+ ]);
122
+ expect(parseNoteMarkdown('\\- not a bullet\n1\\. not a list')).toEqual([
123
+ { type: 'paragraph', lines: [[text('- not a bullet')], [text('1. not a list')]] },
124
+ ]);
125
+ });
126
+
127
+ it('does not treat a 4-digit year line as an ordered list', () => {
128
+ expect(parseNoteMarkdown('1995. the year it began')).toEqual([
129
+ { type: 'paragraph', lines: [[text('1995. the year it began')]] },
130
+ ]);
131
+ });
132
+
133
+ it('treats a bare # without content as plain text', () => {
134
+ expect(parseNoteMarkdown('# ')).toEqual([{ type: 'paragraph', lines: [[text('#')]] }]);
135
+ });
136
+
137
+ it('preserves leading whitespace in paragraph lines', () => {
138
+ expect(parseNoteMarkdown('plan:\n indented detail')).toEqual([
139
+ { type: 'paragraph', lines: [[text('plan:')], [text(' indented detail')]] },
140
+ ]);
141
+ });
142
+
143
+ it('handles empty input', () => {
144
+ expect(parseNoteMarkdown('')).toEqual([]);
145
+ expect(parseNoteMarkdown('\n\n')).toEqual([]);
146
+ });
147
+ });
@@ -0,0 +1,116 @@
1
+ export type NoteInline =
2
+ | { type: 'text'; text: string }
3
+ | { type: 'strong'; children: NoteInline[] }
4
+ | { type: 'em'; children: NoteInline[] }
5
+ | { type: 'code'; text: string };
6
+
7
+ export type NoteBlock =
8
+ | { type: 'paragraph'; lines: NoteInline[][] }
9
+ | { type: 'heading'; level: 1 | 2 | 3; children: NoteInline[] }
10
+ | { type: 'list'; ordered: boolean; items: NoteInline[][] };
11
+
12
+ const HEADING = /^(#{1,3})\s+(.*)$/;
13
+ // Ordered before the single-star branch so `**bold**` never parses as
14
+ // empty italics. Emphasis content must start and end with non-whitespace
15
+ // (CommonMark) so spaced stars like `2 * 3 … 5 * 4` never pair up, and `_`
16
+ // needs word boundaries to leave snake_case alone.
17
+ const INLINE =
18
+ /`([^`\n]+)`|\*\*(\S(?:[^\n]*?\S)?)\*\*|\*([^\s*](?:[^*\n]*[^\s*])?)\*|(?<![\w])_([^\s_](?:[^_\n]*[^\s_])?)_(?![\w])/g;
19
+
20
+ // Backslash-escaped punctuation is swapped for private-use characters before
21
+ // any block or inline matching, so an escaped delimiter can never open or
22
+ // close anything. Leaves swap them back — code spans keep the backslash,
23
+ // matching CommonMark's "no escapes inside code" rule.
24
+ const ESCAPABLE = '\\`*_#-.)';
25
+ const ESCAPE = /\\([\\`*_#\-.)])/g;
26
+ const HIDDEN = /[-]/g;
27
+
28
+ function hideEscapes(text: string): string {
29
+ return text
30
+ .replace(HIDDEN, '')
31
+ .replace(ESCAPE, (_, ch: string) => String.fromCharCode(0xe000 + ESCAPABLE.indexOf(ch)));
32
+ }
33
+
34
+ function restoreEscapes(text: string, keepBackslash: boolean): string {
35
+ return text.replace(HIDDEN, (ch) => {
36
+ const original = ESCAPABLE[ch.charCodeAt(0) - 0xe000];
37
+ return keepBackslash ? `\\${original}` : original;
38
+ });
39
+ }
40
+
41
+ function matchListItem(line: string): { ordered: boolean; content: string } | null {
42
+ const unordered = /^\s*[-*]\s+(.*)$/.exec(line);
43
+ if (unordered) return { ordered: false, content: unordered[1] };
44
+ const ordered = /^\s*\d{1,3}[.)]\s+(.*)$/.exec(line);
45
+ if (ordered) return { ordered: true, content: ordered[1] };
46
+ return null;
47
+ }
48
+
49
+ function parseInlineHidden(text: string): NoteInline[] {
50
+ const out: NoteInline[] = [];
51
+ const pushText = (raw: string) => {
52
+ if (raw) out.push({ type: 'text', text: restoreEscapes(raw, false) });
53
+ };
54
+ let last = 0;
55
+ for (const m of text.matchAll(INLINE)) {
56
+ pushText(text.slice(last, m.index));
57
+ if (m[1] !== undefined) out.push({ type: 'code', text: restoreEscapes(m[1], true) });
58
+ else if (m[2] !== undefined) out.push({ type: 'strong', children: parseInlineHidden(m[2]) });
59
+ else out.push({ type: 'em', children: parseInlineHidden(m[3] ?? m[4]) });
60
+ last = m.index + m[0].length;
61
+ }
62
+ pushText(text.slice(last));
63
+ return out;
64
+ }
65
+
66
+ export function parseInline(text: string): NoteInline[] {
67
+ return parseInlineHidden(hideEscapes(text));
68
+ }
69
+
70
+ export function parseNoteMarkdown(text: string): NoteBlock[] {
71
+ const lines = hideEscapes(text).split('\n');
72
+ const blocks: NoteBlock[] = [];
73
+ let i = 0;
74
+ while (i < lines.length) {
75
+ const trimmed = lines[i].trim();
76
+ if (trimmed === '') {
77
+ i++;
78
+ continue;
79
+ }
80
+ const heading = HEADING.exec(trimmed);
81
+ if (heading) {
82
+ blocks.push({
83
+ type: 'heading',
84
+ level: heading[1].length as 1 | 2 | 3,
85
+ children: parseInlineHidden(heading[2].trim()),
86
+ });
87
+ i++;
88
+ continue;
89
+ }
90
+ const item = matchListItem(lines[i]);
91
+ if (item) {
92
+ const items: NoteInline[][] = [];
93
+ while (i < lines.length) {
94
+ const next = matchListItem(lines[i]);
95
+ if (!next || next.ordered !== item.ordered) break;
96
+ items.push(parseInlineHidden(next.content.trim()));
97
+ i++;
98
+ }
99
+ blocks.push({ type: 'list', ordered: item.ordered, items });
100
+ continue;
101
+ }
102
+ // Paragraph lines keep leading whitespace (rendered with pre-wrap) so
103
+ // plain-text notes don't lose manual indentation or spacing.
104
+ const paragraph = [parseInlineHidden(lines[i].trimEnd())];
105
+ i++;
106
+ while (i < lines.length) {
107
+ const next = lines[i];
108
+ const nextTrimmed = next.trim();
109
+ if (nextTrimmed === '' || HEADING.test(nextTrimmed) || matchListItem(next)) break;
110
+ paragraph.push(parseInlineHidden(next.trimEnd()));
111
+ i++;
112
+ }
113
+ blocks.push({ type: 'paragraph', lines: paragraph });
114
+ }
115
+ return blocks;
116
+ }
@@ -24,6 +24,7 @@ import { hasModifier, isBackwardKey, isForwardKey, isTypingTarget } from '@/lib/
24
24
  import { useDocumentTitle } from '@/lib/use-document-title';
25
25
  import { format, useLocale } from '@/lib/use-locale';
26
26
  import { cn, pad2 } from '@/lib/utils';
27
+ import { NoteMarkdown } from '../components/note-markdown';
27
28
  import {
28
29
  type PresenterState,
29
30
  usePresenterChannel,
@@ -591,11 +592,11 @@ function SpeakerNotes({ note }: { note: string | undefined }) {
591
592
  </div>
592
593
  </div>
593
594
  <div
594
- className="min-h-0 flex-1 overflow-y-auto rounded-[6px] border border-border bg-card p-3 leading-relaxed whitespace-pre-wrap text-card-foreground"
595
+ className="min-h-0 flex-1 overflow-y-auto rounded-[6px] border border-border bg-card p-3 leading-relaxed text-card-foreground"
595
596
  style={{ fontSize: NOTES_FONT_SIZES[sizeIndex] }}
596
597
  >
597
598
  {note?.trim() ? (
598
- note
599
+ <NoteMarkdown text={note} />
599
600
  ) : (
600
601
  <span className="text-muted-foreground">
601
602
  {t.presenter.noNotesPrefix}
@@ -32,15 +32,16 @@ import { HistoryProvider } from '@/components/history-provider';
32
32
  import { CommentWidget } from '@/components/inspector/comment-widget';
33
33
  import { InlineEditLayer } from '@/components/inspector/inline-text-editor';
34
34
  import { InspectOverlay } from '@/components/inspector/inspect-overlay';
35
- import { InspectorPanel } from '@/components/inspector/inspector-panel';
36
35
  import {
36
+ InspectModeSwitcher,
37
37
  InspectorProvider,
38
- InspectToggleButton,
38
+ InspectPanelButton,
39
39
  useInspector,
40
40
  } from '@/components/inspector/inspector-provider';
41
41
  import { SaveBar } from '@/components/inspector/save-bar';
42
+ import { EditorSidebar } from '@/components/panel/editor-sidebar';
42
43
  import { DesignProvider } from '@/components/style-panel/design-provider';
43
- import { DesignPanel, DesignToggleButton } from '@/components/style-panel/style-panel';
44
+ import { DesignToggleButton } from '@/components/style-panel/style-panel';
44
45
  import { Button, buttonVariants } from '@/components/ui/button';
45
46
  import {
46
47
  DropdownMenu,
@@ -53,7 +54,13 @@ import {
53
54
  import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs';
54
55
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '@/components/ui/tooltip';
55
56
  import { useFolders } from '@/lib/folders';
56
- import { hasModifier, isBackwardKey, isForwardKey, isTypingTarget } from '@/lib/keys';
57
+ import {
58
+ hasModifier,
59
+ isBackwardKey,
60
+ isForwardKey,
61
+ isShortcutControlTarget,
62
+ isTypingTarget,
63
+ } from '@/lib/keys';
57
64
  import { readLastHomeLocation } from '@/lib/last-home-location';
58
65
  import { useAgentSocketConnected } from '@/lib/use-agent-socket';
59
66
  import { useClickPageNavigation } from '@/lib/use-click-page-navigation';
@@ -298,7 +305,14 @@ export function Slide() {
298
305
  // page-nav handler too would race it and skip <Steps> reveals, so bail out.
299
306
  if (playMode || !showSlideUi) return;
300
307
  const onKey = (e: KeyboardEvent) => {
301
- if (isTypingTarget(e.target)) return;
308
+ if (
309
+ isTypingTarget(e.target) ||
310
+ isShortcutControlTarget(e.target) ||
311
+ e.isComposing ||
312
+ e.keyCode === 229 ||
313
+ e.defaultPrevented
314
+ )
315
+ return;
302
316
  // Letter shortcuts only fire bare so browser combos (Cmd/Ctrl-P, ⌘F…) stay intact.
303
317
  if (hasModifier(e)) return;
304
318
  // Toggle overview from either state — the overview's own capture-phase
@@ -595,7 +609,12 @@ export function Slide() {
595
609
 
596
610
  return (
597
611
  <HistoryProvider>
598
- <InspectorProvider slideId={slideId} pageIndex={index}>
612
+ <InspectorProvider
613
+ slideId={slideId}
614
+ pageIndex={index}
615
+ panelHidden={designOpen}
616
+ onPanelOpen={() => setDesignOpen(false)}
617
+ >
599
618
  <SelectionReporter />
600
619
  <div className="flex h-dvh flex-col overflow-hidden bg-sidebar text-foreground">
601
620
  {/* Toolbar sits directly on the chrome ground — three zones, mono-folio center */}
@@ -647,6 +666,10 @@ export function Slide() {
647
666
  </div>
648
667
 
649
668
  <div className="flex flex-1 items-center justify-end gap-1 md:ml-auto md:flex-none">
669
+ {view === 'slides' && <InspectModeSwitcher />}
670
+ {import.meta.env.DEV && view === 'slides' && (
671
+ <span aria-hidden className="mx-0.5 hidden h-5 w-px bg-hairline md:block" />
672
+ )}
650
673
  {view === 'slides' && (
651
674
  <button
652
675
  type="button"
@@ -732,7 +755,7 @@ export function Slide() {
732
755
  {view === 'slides' && (
733
756
  <DesignToggleButton active={designOpen} onToggle={() => setDesignOpen((v) => !v)} />
734
757
  )}
735
- {view === 'slides' && <InspectToggleButton />}
758
+ {view === 'slides' && <InspectPanelButton />}
736
759
  <span aria-hidden className="mx-0.5 hidden h-5 w-px bg-hairline md:block" />
737
760
  {view === 'slides' && (
738
761
  <div className="inline-flex items-stretch">
@@ -845,8 +868,10 @@ export function Slide() {
845
868
  actions={thumbnailActions}
846
869
  />
847
870
  </div>
848
- <InspectorPanel />
849
- <DesignPanel open={designOpen} onClose={() => setDesignOpen(false)} />
871
+ <EditorSidebar
872
+ designOpen={designOpen}
873
+ onCloseDesign={() => setDesignOpen(false)}
874
+ />
850
875
  </div>
851
876
  {import.meta.env.DEV && (
852
877
  <NotesDrawer