Install
openclaw skills install html-editor把任意静态 HTML 转成可视化编辑版:注入工具栏、颜色/字号/布局/预设面板、就地文字编辑、撤销保存导出、元素与面板双向跳转。适用于用户说可编辑版HTML、html可视化编辑、让html可编辑、样式面板、改html不写代码、所见即所得、点击直接编辑、把报告/页面/演示稿变成可调样式。
openclaw skills install html-editor把任意静态 HTML 升级成「可视化编辑版」:文字可直接点开编辑,右侧面板可调颜色、字号、布局和主题预设,改完可导出新的 HTML。
python <skill-dir>/scripts/adapt.py <your-report.html>
# 输出:<your-report>-editable.html
指定输出路径:
python <skill-dir>/scripts/adapt.py <your-report.html> -o <your-report>-editable.html --force
依赖只有一个:
pip install beautifulsoup4
打开生成的 *-editable.html,页面会多出左上工具栏和右侧样式面板:
:root CSS 变量;自动把渐变里的硬编码色提取成变量,例如 linear-gradient(..., #003DA5) 会变成可调色块。font-size 规则,自动生成 slider;目标选择器使用真实组合选择器,例如 .header h1、.stat-card .number,避免裸 h1/p/li 误伤其它区域。HTML
↓ parse_css.py
抽取 CSS 变量、font-size、background、color、选择器规则
↓ scan_dom.py
扫描 DOM、生成元素到面板的映射
↓ generate_panel.py
生成颜色/字号/布局/预设面板与 window.X 常量
↓ inject.py
注入 toolbar、panel、editor-core.css/js,并标记 data-editable
↓ verify.py
运行 34 项 sanity checks;失败则不产出坏件
不配置 API key 也能跑,启发式命名会兜底。若环境变量可用,会使用 LLM 给 CSS 变量生成更语义化的 label,例如「主色调 Accent」而不是「蓝色 Blue」。
支持的环境变量:
ANTHROPIC_API_KEYOPENAI_API_KEY<style>,且 :root 里有 5 个以上 CSS 变量;效果最好。把整个 html-visual-editor/ 目录放到对应工具可读取的位置:
~/.workbuddy/skills/html-visual-editor/~/.claude/skills/html-visual-editor/ 或项目级 skills 目录scripts/adapt.pypython /path/to/html-visual-editor/scripts/adapt.py <html>python <skill-dir>/scripts/adapt.py <skill-dir>/examples/demo-report.html --force --verbose
open <skill-dir>/examples/demo-report-editable.html
adapt.py 会自动运行 34 项检查,重点覆盖:
PAGE_ELEMENT_TO_PANEL row 字符级一致PRESETS 为 flat 格式,且变量名能映射到 host CSS 变量font-size 规则h1/p/li 这类易误伤选择器data-editable 覆盖率达标applyFallbackSize / applyFallbackLayout 等绕开核心引擎的 shim若检查失败,修源 HTML 或脚本,不要绕过检查。
html-visual-editor/
├── SKILL.md
├── README.md
├── LICENSE
├── assets/
│ ├── editor-core.css
│ ├── editor-core.js
│ └── panel.template.html
├── presets/
│ ├── builtin.json
│ └── llm_label_prompt.txt
├── scripts/
│ ├── adapt.py
│ ├── parse_css.py
│ ├── scan_dom.py
│ ├── generate_panel.py
│ ├── inject.py
│ ├── verify.py
│ └── utils/diagnose_css.py
└── examples/
└── demo-report.html
adapt.py,不要手写 panel。assets/editor-core.js,所有适配逻辑放在 scripts 和 window.X 常量里。