feat(YfmHtmlBlock): add editable preview mode with templates#1146
Draft
makhnatkin wants to merge 3 commits into
Draft
feat(YfmHtmlBlock): add editable preview mode with templates#1146makhnatkin wants to merge 3 commits into
makhnatkin wants to merge 3 commits into
Conversation
Add a templates button inside the YfmHtmlBlock node that opens a popup
with a searchable list of templates and an "add" action.
- templates are merged from plugin options and localStorage (localStorage
overrides by id); adding writes only to localStorage, never to markup
- the add form accepts several <template id title> blocks at once
- selecting a template overwrites the block srcdoc
- new `templates` plugin option: { items, showButton, allowAdd }
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Reviewer's GuideAdds an editable inline preview mode for YfmHtmlBlock along with a template system (including popup UI, storage, parsing, and i18n) and wires it into the demo playground. File-Level Changes
|
Collaborator
Author
<template id="solid-header-white" title="Solid header · white cards">
<div style="display: grid; gap: 12px; padding: 12px; grid-template-columns: repeat(3, 1fr);">
<div style="grid-column: 1 / -1; padding: 28px 32px; font-size: 30px; font-weight: 800; line-height: 1.1; letter-spacing: -0.5px; color: #fff; background: #2563eb; border-radius: 14px;">Main heading</div>
<div style="padding: 20px; color: #1f2937; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;">First</div>
<div style="padding: 20px; color: #1f2937; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;">Second</div>
<div style="padding: 20px; color: #1f2937; background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;">Third</div>
</div>
</template>
<template id="long-columns" title="Long columns">
<div style="display: grid; gap: 12px; padding: 12px; grid-template-columns: repeat(3, 1fr); grid-auto-rows: 320px;">
<div style="padding: 24px; min-height: 320px; color: #0f172a; background: #f8fafc; border-top: 4px solid #0ea5e9; border-radius: 10px;">Column one</div>
<div style="padding: 24px; min-height: 320px; color: #0f172a; background: #f8fafc; border-top: 4px solid #6366f1; border-radius: 10px;">Column two</div>
<div style="padding: 24px; min-height: 320px; color: #0f172a; background: #f8fafc; border-top: 4px solid #ec4899; border-radius: 10px;">Column three</div>
</div>
</template>
<template id="dark" title="Dark theme">
<div style="display: grid; gap: 12px; padding: 12px; grid-template-columns: repeat(3, 1fr); background: #0b1120; border-radius: 14px;">
<div style="grid-column: 1 / -1; padding: 24px; font-size: 24px; font-weight: 700; color: #f8fafc; background: #1e293b; border: 1px solid #334155; border-radius: 12px;">Header</div>
<div style="padding: 20px; color: #cbd5e1; background: #111827; border: 1px solid #334155; border-radius: 12px;">One</div>
<div style="padding: 20px; color: #cbd5e1; background: #111827; border: 1px solid #334155; border-radius: 12px;">Two</div>
<div style="padding: 20px; color: #cbd5e1; background: #111827; border: 1px solid #334155; border-radius: 12px;">Three</div>
</div>
</template>
<template id="festive" title="Festive theme">
<div style="display: grid; gap: 12px; padding: 12px; grid-template-columns: repeat(3, 1fr); background: #5b0a0a; border: 4px double #ffd700; border-radius: 16px;">
<div style="grid-column: 1 / -1; padding: 22px; font-size: 26px; font-weight: 800; text-align: center; letter-spacing: 1px; color: #ffd700; text-shadow: 0 1px 0 #7a0000; background: linear-gradient(135deg, #8b0000, #b8860b); border: 3px double #ffd700; border-radius: 12px;">✦ Праздник ✦</div>
<div style="padding: 18px; text-align: center; color: #fff6d5; background: #7a0000; border: 2px dashed #ffd700; border-radius: 12px;">❖ Узор</div>
<div style="padding: 18px; text-align: center; color: #7a0000; background: #ffd700; border: 2px solid #8b0000; border-radius: 12px;">❖ Орнамент</div>
<div style="padding: 18px; text-align: center; color: #fff6d5; background: #7a0000; border: 2px dashed #ffd700; border-radius: 12px;">❖ Золото</div>
<div style="grid-column: 1 / -1; padding: 14px; text-align: center; font-weight: 700; color: #5b0a0a; background: linear-gradient(90deg, #ffd700, #f0c000, #ffd700); border-radius: 12px;">✦ Festive footer ✦</div>
</div>
</template>
<template id="minimal" title="Minimal">
<div style="display: grid; gap: 12px; padding: 12px; grid-template-columns: repeat(2, 1fr); gap: 24px; padding: 24px;">
<div style="padding: 8px 0 24px; color: #111; background: transparent; border-bottom: 1px solid #111;">Left</div>
<div style="padding: 8px 0 24px; color: #111; background: transparent; border-bottom: 1px solid #111;">Right</div>
</div>
</template>
<template id="pastel" title="Pastel cards">
<div style="display: grid; gap: 12px; padding: 12px; grid-template-columns: repeat(2, 1fr);">
<div style="padding: 22px; color: #7c2d12; background: #ffedd5; border-radius: 16px;">Peach</div>
<div style="padding: 22px; color: #065f46; background: #d1fae5; border-radius: 16px;">Mint</div>
<div style="padding: 22px; color: #5b21b6; background: #ede9fe; border-radius: 16px;">Lavender</div>
<div style="padding: 22px; color: #075985; background: #e0f2fe; border-radius: 16px;">Sky</div>
</div>
</template>
<template id="gradient" title="Gradient cards">
<div style="display: grid; gap: 12px; padding: 12px; grid-template-columns: repeat(3, 1fr);">
<div style="padding: 26px; color: #fff; font-weight: 600; background: linear-gradient(135deg, #f97316, #db2777); border-radius: 16px;">Sunset</div>
<div style="padding: 26px; color: #fff; font-weight: 600; background: linear-gradient(135deg, #0ea5e9, #6366f1); border-radius: 16px;">Ocean</div>
<div style="padding: 26px; color: #fff; font-weight: 600; background: linear-gradient(135deg, #22c55e, #0d9488); border-radius: 16px;">Forest</div>
</div>
</template>
<template id="neon" title="Neon">
<div style="display: grid; gap: 12px; padding: 12px; grid-template-columns: repeat(2, 1fr); background: #05010f; border-radius: 14px;">
<div style="grid-column: 1 / -1; padding: 22px; text-align: center; font-size: 24px; font-weight: 800; letter-spacing: 4px; color: #22d3ee; background: #0a0a1a; border: 2px solid #22d3ee; border-radius: 12px; box-shadow: 0 0 16px rgba(34,211,238,0.7);">CYBER</div>
<div style="padding: 22px; color: #f0abfc; background: #0a0a1a; border: 2px solid #e879f9; border-radius: 12px; box-shadow: 0 0 14px rgba(232,121,249,0.6);">NODE 01</div>
<div style="padding: 22px; color: #5eead4; background: #0a0a1a; border: 2px solid #2dd4bf; border-radius: 12px; box-shadow: 0 0 14px rgba(45,212,191,0.6);">NODE 02</div>
</div>
</template>
<template id="newspaper" title="Newspaper">
<div style="display: grid; gap: 12px; padding: 12px; grid-template-columns: 2fr 1fr; gap: 0; background: #f4ecd8; border: 2px solid #3a2f1b;">
<div style="grid-column: 1 / -1; padding: 18px; text-align: center; font-family: Georgia, serif; font-size: 30px; font-weight: 700; letter-spacing: 2px; color: #2b2317; background: #f4ecd8; border-bottom: 3px double #3a2f1b;">THE DAILY GRID</div>
<div style="padding: 18px; font-family: Georgia, serif; color: #2b2317; background: #f4ecd8; border-right: 1px solid #3a2f1b;">Lead story</div>
<div style="padding: 18px; font-family: Georgia, serif; color: #2b2317; background: #efe6cf;">Sidebar</div>
</div>
</template>
<template id="areas-header-footer" title="Header · 3 cols · footer (areas)">
<div style="display: grid; gap: 12px; padding: 12px; grid-template-columns: repeat(3, 1fr); grid-template-areas: "head head head" "c1 c2 c3" "foot foot foot";">
<div style="grid-area: head; padding: 22px; font-size: 22px; font-weight: 700; color: #fff; background: #4338ca; border-radius: 12px;">Header</div>
<div style="grid-area: c1; padding: 18px; color: #312e81; background: #eef2ff; border-radius: 12px;">One</div>
<div style="grid-area: c2; padding: 18px; color: #312e81; background: #eef2ff; border-radius: 12px;">Two</div>
<div style="grid-area: c3; padding: 18px; color: #312e81; background: #eef2ff; border-radius: 12px;">Three</div>
<div style="grid-area: foot; padding: 16px; color: #fff; background: #6366f1; border-radius: 12px;">Footer</div>
</div>
</template> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Add editable preview and reusable HTML templates support to YfmHtmlBlock, including UI, persistence, and parsing utilities.
New Features:
Enhancements:
Tests: