ZJU-REAL/Easel / skills/builtin/gzh-design
gzh-design
Verified微信公众号文章排版引擎:把 Markdown / Word(.docx) / PDF / 纯文本转成可直接粘贴进公众号编辑器的 HTML,自动章节编号、关键词标记、引言卡、目录、代码块、图片/GIF、作者签名;主题从 references/theme-index.md 组件库按题材推荐,支持"一键自动排版"与按描述/参考图生成自定义主题。触发:用户提到"公众号排版/微信排版/gzh"、想把文章(md/docx/pdf/纯文本)转成公众号 HTML、说"自动排版/一键排版"公众号内容。不用于普通网页/落地页/PPT。
assets/preview-template.html
View on GitHub<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<!-- 预览页必须能跑脚本(右上角「复制到公众号」走 execCommand),所以内容库的 iframe 给了
sandbox="allow-scripts"。但正文是生成内容,可能混进外部来源的片段,里面的脚本会跟着一起
执行;而 Easel 的 web 是 CORS 全放开(app.py 的 allow_origins=["*"])且无鉴权,光靠
opaque origin 拦不住 —— 实测带 Origin: null 一样拿得到 access-control-allow-origin: *,
脚本能调本站接口并读到响应。这条 CSP 才是真正的闸:connect-src 'none' 掐掉 fetch/XHR/
WebSocket/sendBeacon,正文里的脚本就算跑起来也读不到任何接口、发不出去。
script/style 必须留 'unsafe-inline'(复制按钮是 onclick,公众号正文全是内联样式);
img/media 放行 data: 与远程,否则内联图和正文引用的远程图渲染不出来。 -->
<meta http-equiv="Content-Security-Policy" content="default-src 'none'; script-src 'unsafe-inline'; style-src 'unsafe-inline'; img-src data: https: http:; media-src data: https: http:; font-src data:; connect-src 'none'; form-action 'none'; frame-src 'none'; object-src 'none'; base-uri 'none'">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{TITLE}} · 公众号排版预览</title>
<style>
body{margin:0;background:#eef0f2;font-family:-apple-system,BlinkMacSystemFont,'PingFang SC','Hiragino Sans GB','Microsoft YaHei',sans-serif;-webkit-text-size-adjust:100%;}
.gzh-toolbar{position:fixed;top:0;left:0;right:0;height:54px;background:#ffffff;box-shadow:0 1px 10px rgba(0,0,0,.08);display:flex;align-items:center;justify-content:space-between;padding:0 16px;z-index:99;}
.gzh-hint{font-size:13px;color:#6b7280;line-height:1.4;}
.gzh-hint b{color:#111827;}
.gzh-copy{background:#059669;color:#fff;border:0;border-radius:9px;padding:10px 20px;font-size:14px;font-weight:700;cursor:pointer;box-shadow:0 3px 10px rgba(5,150,105,.28);white-space:nowrap;transition:transform .08s,background .15s;}
.gzh-copy:hover{background:#047857;}
.gzh-copy:active{transform:translateY(1px);}
.gzh-toast{position:fixed;top:66px;left:50%;transform:translateX(-50%);background:#111827;color:#fff;padding:11px 20px;border-radius:10px;font-size:14px;font-weight:600;opacity:0;pointer-events:none;transition:opacity .25s;z-index:100;box-shadow:0 6px 20px rgba(0,0,0,.25);max-width:88vw;text-align:center;}
.gzh-toast.show{opacity:1;}
.gzh-stage{max-width:700px;margin:78px auto 64px;padding:0 8px;}
@media(max-width:520px){.gzh-hint{max-width:150px;}}
</style>
</head>
<body>
<div class="gzh-toolbar">
<span class="gzh-hint">👇 下方是排版效果 · 点右侧 <b>复制</b> 直接粘到公众号</span>
<button class="gzh-copy" id="gzhCopyBtn" onclick="gzhCopy()">📋 复制到公众号</button>
</div>
<div class="gzh-toast" id="gzhToast"></div>
<div class="gzh-stage">
<div id="gzh-content">
<!--GZH_CONTENT-->
</div>
</div>
<script>
function gzhShowToast(msg){
var t=document.getElementById('gzhToast');
t.textContent=msg;t.classList.add('show');
clearTimeout(t._timer);
t._timer=setTimeout(function(){t.classList.remove('show');},2800);
}
function gzhCopy(){
var el=document.getElementById('gzh-content');
// 选中渲染后的富文本节点并复制(等价于手动 Ctrl+A / Ctrl+C,保留全部样式)
var range=document.createRange();
range.selectNodeContents(el);
var sel=window.getSelection();
sel.removeAllRanges();
sel.addRange(range);
var ok=false;
try{ok=document.execCommand('copy');}catch(e){ok=false;}
sel.removeAllRanges();
var btn=document.getElementById('gzhCopyBtn');
if(ok){
gzhShowToast('✅ 已复制!去公众号编辑器按 Ctrl/⌘+V 粘贴即可');
var old=btn.textContent;btn.textContent='✅ 已复制';
setTimeout(function(){btn.textContent=old;},2200);
}else{
gzhShowToast('⚠ 自动复制失败,请手动全选(Ctrl/⌘+A)再复制(Ctrl/⌘+C)');
}
}
</script>
</body>
</html>
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| canvas-designanthropics/skillsCreate beautiful visual art in .png and .pdf documents using design philosophy. You should use this skill when the user asks to create a poster, piece of art, design, or other static piece. Create original visual designs, never copying existing artists' work to avoid copyright violations. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| docxanthropics/skillsUse this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include: any mention of 'Word doc', 'word document', '.docx', '.dotx', or requests to produce professional documents with formatting like tables of contents, headings, page numbers, or letterheads. Also use when extracting or reorganizing content from .docx or .dotx files, inserting or replacing images in documents, performing find-and-replace in Word files, working with tracked changes or comments, or converting content into a polished Word document. If the user asks for a 'report', 'memo', 'letter', 'template', or similar deliverable as a Word or .docx file, use this skill. Do NOT use for PDFs, spreadsheets, Google Docs, or general coding tasks unrelated to document generation. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pdfanthropics/skillsUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple PDFs into one, splitting PDFs apart, rotating pages, adding watermarks, creating new PDFs, filling PDF forms, encrypting/decrypting PDFs, extracting images, and OCR on scanned PDFs to make them searchable. If the user mentions a .pdf file or asks to produce one, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |
| pptxanthropics/skillsUse this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or presentations; reading, parsing, or extracting text from any .pptx or .potx file (even if the extracted content will be used elsewhere, like in an email or summary); editing, modifying, or updating existing presentations; combining or splitting slide files; working with templates (.potx), layouts, speaker notes, or comments. Trigger whenever the user mentions "deck," "slides," "presentation," or references a .pptx or .potx filename, regardless of what they plan to do with the content afterward. If a .pptx or .potx file needs to be opened, created, or touched, use this skill. | Stars: 198k | Updated | Claude CodeCodex | Verified | Install |