diff --git a/src/main.ts b/src/main.ts index 4345a2a..07b0fe8 100644 --- a/src/main.ts +++ b/src/main.ts @@ -141,20 +141,22 @@ async function rebuildPreview(): Promise { compileError.hidden = true compileError.textContent = '' - if (runtime) { - runtime.setTemplate(result.template) - runtime.setSlides(result.slides) - // Follow the slide being edited; the deck may just have grown. - if (currentSlide >= 0) { - runtime.goTo(currentSlide) - } - } else { + if (!runtime) { runtime = createRuntime(stage, result.slides, { template: result.template, onCurrentChange: (index) => setSlide(index) }) + // A reload restores the slide you were on (history state): open + // the editor and the selection there too. + setSlide(runtime.current) } + runtime.setTemplate(result.template) + runtime.setSlides(result.slides) runtime.setCss(result.css) + // Follow the slide being edited; the deck may just have grown. + if (currentSlide >= 0) { + runtime.goTo(currentSlide) + } } catch (error) { // Half-typed Less should not blank the preview: keep the last good // output on screen and report what broke. diff --git a/src/slides/compile.ts b/src/slides/compile.ts index 4b3c72e..87337d4 100644 --- a/src/slides/compile.ts +++ b/src/slides/compile.ts @@ -57,21 +57,25 @@ export interface CompiledPresentation { * removed from the markup because their raw Less must never reach the DOM — * the compiled CSS is injected separately, at ``. A style tag that * *is* that injection point is left alone. + * + * Parsed as a fragment rather than a full document: as a document a leading + * `