From 41815d9cd6914050a4fc7c3eee3e139a0a9dce87 Mon Sep 17 00:00:00 2001 From: Yang Jun Date: Mon, 22 Jun 2026 20:48:23 +0800 Subject: [PATCH] refactor(docs): revert playground capture changes to master behavior Restore Ace output pane, drop Prism and output-preview styling. Simplify docs:dev to rely on docs prestart. Co-authored-by: Cursor --- .../navy/layout/partial/after_footer.swig | 2 -- docs/themes/navy/layout/playground.swig | 4 +--- .../navy/source/css/_partial/playground.styl | 21 ----------------- docs/themes/navy/source/js/main.js | 23 ++++++++----------- package.json | 2 +- 5 files changed, 11 insertions(+), 41 deletions(-) diff --git a/docs/themes/navy/layout/partial/after_footer.swig b/docs/themes/navy/layout/partial/after_footer.swig index 4cc27d2c8..e6778541a 100644 --- a/docs/themes/navy/layout/partial/after_footer.swig +++ b/docs/themes/navy/layout/partial/after_footer.swig @@ -1,8 +1,6 @@ {% if page.layout === 'playground' %} {{ js('js/liquid.browser.min.js') }} - - {% endif %} {{ js('js/main') }} diff --git a/docs/themes/navy/layout/playground.swig b/docs/themes/navy/layout/playground.swig index 1897d2f5d..e09cfa1d0 100644 --- a/docs/themes/navy/layout/playground.swig +++ b/docs/themes/navy/layout/playground.swig @@ -13,9 +13,7 @@

Output

-
-
{{__('playground.loading')}}
-
+
{{__('playground.loading')}}

diff --git a/docs/themes/navy/source/css/_partial/playground.styl b/docs/themes/navy/source/css/_partial/playground.styl index 52037c6ff..953dd1e88 100644 --- a/docs/themes/navy/source/css/_partial/playground.styl +++ b/docs/themes/navy/source/css/_partial/playground.styl @@ -68,27 +68,6 @@ overflow: hidden @media mq-mobile min-height: 240px - .output-preview - flex: 1 1 auto - min-height: 0 - code-block-chrome() - overflow: auto - cursor: default - pre.highlight - margin: 0 - min-height: 100% - padding: 16px - border: none - box-shadow: none - border-radius: 0 - background: var(--highlight-background) - code - display: block - font-size: 14px - line-height: 1.5 - background: transparent - padding: 0 - white-space: pre .ace_editor font-family: font-mono font-size: 14px diff --git a/docs/themes/navy/source/js/main.js b/docs/themes/navy/source/js/main.js index b9c5e2154..b113fb27b 100644 --- a/docs/themes/navy/source/js/main.js +++ b/docs/themes/navy/source/js/main.js @@ -48,17 +48,20 @@ const colorScheme = window.matchMedia('(prefers-color-scheme: dark)'); const editor = createEditor('editorEl', 'liquid'); const dataEditor = createEditor('dataEl', 'json'); - const previewCode = document.getElementById('previewCode'); + const preview = createEditor('previewEl', 'html'); + preview.setReadOnly(true); + preview.renderer.setShowGutter(false); + preview.renderer.setPadding(16); - const editors = [editor, dataEditor]; + const editors = [editor, dataEditor, preview]; colorScheme.addEventListener('change', function() { editors.forEach(applyEditorTheme); }); const init = parseArgs(location.hash.slice(1)); if (init) { - editor.setValue(init.tpl, -1); - dataEditor.setValue(init.data, -1); + editor.setValue(init.tpl, 1); + dataEditor.setValue(init.data, 1); } editor.on('change', update); dataEditor.on('change', update); @@ -115,23 +118,15 @@ return utoa(obj.tpl) + ',' + utoa(obj.data); } - function setPreview(value) { - previewCode.textContent = value; - if (window.Prism) { - delete previewCode.dataset.highlighted; - window.Prism.highlightElement(previewCode); - } - } - async function update() { const tpl = editor.getValue(); const data = dataEditor.getValue(); history.replaceState({}, '', '#' + serializeArgs({tpl, data})); try { const html = await engine.parseAndRender(tpl, JSON.parse(data)); - setPreview(html); + preview.setValue(html, 1); } catch (err) { - setPreview(err.stack); + preview.setValue(err.stack, 1); throw err; } } diff --git a/package.json b/package.json index 5329ecb99..dac14c52c 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "build:apidoc": "shx rm -rf docs/source/api && typedoc --plugin typedoc-plugin-missing-exports ./src --gitRevision master --out docs/source/api", "build:changelog": "node bin/build-changelog.js", "build:docs-hexo": "cd docs && npm ci && npm run build && shx cp CNAME public/", - "docs:dev": "run-s build:docs-liquid build:contributors docs:serve", + "docs:dev": "npm run docs:serve", "docs:serve": "cd docs && npm run start" }, "bin": {