From 2282b13325743f0f827243d7e76295c60062fdff Mon Sep 17 00:00:00 2001 From: navi Date: Sun, 27 Sep 2026 21:58:26 +0200 Subject: [PATCH] feat: author styles in a \n

test

` } ] -const editor = createEditor(projectStyle) +const editor = createEditor() const slideList = document.querySelector('.slide-list-items')! const addSlideButton = document.querySelector('.add-slide')! const stage = document.querySelector('.stage')! const compileError = document.querySelector('.compile-error')! -const slidesTab = document.querySelector('.buffer-tab-slides')! -const styleTab = document.querySelector('.buffer-tab-style')! const presentButton = document.querySelector('.present-button')! let currentSlide = 0 let draggedSlide: number | null = null @@ -93,14 +91,6 @@ function updateSelection() { }) } -function syncBufferTabs() { - const showingSlides = getEditorBuffer() === 'slides' - slidesTab.classList.toggle('active', showingSlides) - styleTab.classList.toggle('active', !showingSlides) - slidesTab.setAttribute('aria-pressed', String(showingSlides)) - styleTab.setAttribute('aria-pressed', String(!showingSlides)) -} - function setEditorText(text: string) { applyingToEditor = true try { @@ -111,8 +101,6 @@ function setEditorText(text: string) { } function showSlideInEditor(index: number) { - setEditorBuffer('slides') - syncBufferTabs() setEditorText(index === -1 ? globalSlide : (slides[index]?.code ?? '')) } @@ -150,8 +138,7 @@ async function rebuildPreview(): Promise { try { const result = await compilePresentation({ slides: slides.map((slide) => slide.code), - global: globalSlide, - style: projectStyle + global: globalSlide }) slideStyles.textContent = result.css @@ -199,7 +186,9 @@ async function generateSlideThumbnail(slide: Slide, i: number) { slideNumber.classList.add('slide-number') slideNumber.textContent = i === -1 ? 'G' : `${i + 1}` - const thumbnail = await createCodeThumbnail(slide.code) + // Style tags are the project stylesheet, never slide content: the + // thumbnail renders markup only, exactly like the presentation does. + const thumbnail = await createCodeThumbnail(extractStyles(slide.code).html) slideInList.append(slideNumber, thumbnail) slideElement.append(slideInList) @@ -357,15 +346,6 @@ addSlideButton.addEventListener('click', async () => { scheduleCompile() }) -slidesTab.addEventListener('click', () => { - showSlideInEditor(currentSlide) -}) - -styleTab.addEventListener('click', () => { - setEditorBuffer('style') - syncBufferTabs() -}) - presentButton.addEventListener('click', () => { stage.requestFullscreen().catch(() => { // Browsers can refuse fullscreen; presenting inside the panel still works. @@ -418,12 +398,6 @@ editor.onDidChangeModelContent(() => { return } - if (getEditorBuffer() === 'style') { - projectStyle = editor.getValue() - scheduleCompile() - return - } - const code = editor.getValue() const slideIndex = currentSlide const slide = slideIndex === -1 ? { code } : slides[slideIndex] @@ -445,7 +419,6 @@ editor.onDidChangeModelContent(() => { }) async function render() { - syncBufferTabs() await setSlideList() setSlide(currentSlide) await rebuildPreview() diff --git a/src/slides/compile.ts b/src/slides/compile.ts index c654795..3dcd312 100644 --- a/src/slides/compile.ts +++ b/src/slides/compile.ts @@ -26,8 +26,6 @@ export interface CompileInput { slides: string[] /** HTML shared by every slide (the "global" slide in the editor). */ global?: string - /** Project Less source. `:thisSlide` resolves to the slide being compiled. */ - style: string } export interface CompiledPresentation { @@ -35,6 +33,28 @@ export interface CompiledPresentation { css: string } +/** + * Pull `