skill怎么写?一份skill使用和编写方法
<div class="ce-block" data-id="VkPbJASile" ><div class="ce-block__content" style="">
<h2 class="ce-header ce-header--left">一、 到底什么是 Skill?</h2>
</div>
</div><div class="ce-block ce-block--focused" data-id="PLEonKb2gk" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">简单来说,<b>Skill 就是写给 AI Agent 看的标准操作手册(SOP)。</b></div>
</div>
</div><div class="ce-block ce-block--focused" data-id="eymZR_BxNe" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">它是一个后缀为 <code><b>.md</b></code> 的文件。在普通的对话中,你的 Prompt(提示词)是用完就丢的;而 Skill 是<b>持久化</b>的,<b>全局</b>的。你写好一次规则放入项目中,当你在对话框里提出需求时,AI 会智能判断当前场景,自动把这本“手册”调出来配合使用。</div>
</div>
</div><div class="ce-block" data-id="2ukZZyyfmz" >
<div class="ce-block__content" style="">
<h2 class="ce-header ce-header--left">二、 如何写一个基础的 Skill?</h2>
</div>
</div><div class="ce-block ce-block--focused" data-id="hmqgJh6fcE" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">无论是排版复杂的 LaTeX 文档,还是开发一个小程序,Skill 的基本格式都是固定的。主要由两部分组成:</div>
</div>
</div><div class="ce-block" data-id="WWeGq5UYUz" >
<div class="ce-block__content" style="">
<h3 class="ce-header ce-header--left">1. 头部声明(YAML 元数据)</h3>
</div>
</div><div class="ce-block ce-block--focused" data-id="Ae3jwA-8Zk" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">这是 Skill 的“触发器”,你必须在这里告诉 AI 什么时候该用它。需要用 <code>---</code> 包裹起来。</div>
</div>
</div><div class="ce-block" data-id="k8nzn-L--T" >
<div class="ce-block__content" style="">
<h3 class="ce-header ce-header--left">2. 正文规则(Markdown主体)</h3>
</div>
</div><div class="ce-block ce-block--focused" data-id="vRGZ8ku1SI" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">这里是你对 AI 提出的具体要求,建议分段落、加小标题,越清晰越好。</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="wectT8_K8h" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>举个例子:一个小程序前端设计规范的 Skill (<code>frontend-design.md</code>)</b></div>
</div>
</div><div class="ce-block ce-block--focused" data-id="h5tw9ccH0_" >
<div class="ce-block__content">
<div class="editorjs-codeFlask_Wrapper">
<div class="editorjs-codeFlask_Header">
<div class="editorjs-codeFlask_LangDisplay">markdown</div>
<button class="editorjs-codeFlask_CopyButton" title="复制代码" id="codeflask-copy-h5tw9ccH0_">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
</button>
<button class="editorjs-codeFlask_Toggle" id="codeflask-Toggle-h5tw9ccH0_">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
</div>
<div class="editorjs-codeFlask_ContentContainer">
<div class="editorjs-codeFlask_Editor" id="codeflask-h5tw9ccH0_" >
</div>
</div>
<div class="editorjs-codeFlask_BottomButtonContainer" id="codeflask-bottomBtn-h5tw9ccH0_">
<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="static/js/editorjs/tools/codeflask/codeflask150.min.js?SVu"></script>
<script type="application/javascript">
const editorElem1788010343RJUAD = document.getElementById('codeflask-h5tw9ccH0_');
var isCollapsed1788010343RJUAD = true;
const flask1788010343RJUAD = new CodeFlask(editorElem1788010343RJUAD, {
language: 'markdown',
lineNumbers: true,
styleParent: this.shadowRoot,
rtl: false,
readonly: true
});
var code1788010343RJUAD = `---
name: frontend-design
description: 在设计前端页面、开发小程序 UI 时调用。当用户要求写 CSS 或组件样式时触发。
---
## 1. 色彩使用
在编写相关色彩内容时,请遵循以下描述:
- 页面基底请严格使用白色。
- 元素尽量使用浅色系,不要使用黑色、棕色等深色系。
- 不要自作主张添加“暗黑模式”。
## 2. 动画过渡
在有组件切换或页面路由跳转时:
- 拒绝硬切,必须使用过渡动画。
- 动画可以带一点类似弹簧(spring)的物理效果,让交互更自然。`;
code1788010343RJUAD = code1788010343RJUAD.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'");
flask1788010343RJUAD.addLanguage('markdown', Prism.languages['markdown']);
flask1788010343RJUAD.onUpdate((code) => {
// do something with code here.
// this will trigger whenever the code
// in the editor changes.
// console.log(code)
});
// flask.updateCode('');
// This will also trigger .onUpdate()
flask1788010343RJUAD.updateCode(code1788010343RJUAD);
const currentCode1788010343RJUAD = flask1788010343RJUAD.getCode();
var coderow1788010343RJUAD = parseInt('');
if (coderow1788010343RJUAD === undefined || coderow1788010343RJUAD !== coderow1788010343RJUAD || coderow1788010343RJUAD === 0) {
coderow1788010343RJUAD = flask1788010343RJUAD.lineNumber;
}
if (coderow1788010343RJUAD < 20) {
editorElem1788010343RJUAD.parentElement.style.height = '300px';
editorElem1788010343RJUAD.style.height = '300px';
} else if (coderow1788010343RJUAD >= 20) {
editorElem1788010343RJUAD.parentElement.style.height = '500px';
editorElem1788010343RJUAD.style.height = '500px';
}
//console.log({currentCode1788010343RJUAD})
const copyBtn1788010343RJUAD = document.getElementById('codeflask-copy-h5tw9ccH0_');
copyBtn1788010343RJUAD.addEventListener('click', function() {
try {
// 先检查 Clipboard API 是否可用
if (navigator.clipboard && navigator.clipboard.writeText) {
// 使用 Clipboard API 复制代码
navigator.clipboard.writeText(code1788010343RJUAD).then(function() {
// 复制成功提示
const originalText = copyBtn1788010343RJUAD.innerHTML;
copyBtn1788010343RJUAD.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
// 一段时间后恢复原文本
setTimeout(function() {
copyBtn1788010343RJUAD.innerHTML = originalText;
}, 2000);
}).catch(function(err) {
// 复制失败处理
console.error('复制失败:', err);
// 降级方案:使用传统的复制方法
fallbackCopyTextToClipboard(code1788010343RJUAD);
});
} else {
// Clipboard API 不可用时直接使用降级方案
fallbackCopyTextToClipboard(code1788010343RJUAD);
}
// 提取降级方案为独立函数
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.opacity = '0';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
const originalText = copyBtn1788010343RJUAD.innerHTML;
copyBtn1788010343RJUAD.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
setTimeout(function() {
copyBtn1788010343RJUAD.innerHTML = originalText;
}, 2000);
} catch (copyErr) {
console.error('传统复制方法也失败了:', copyErr);
} finally {
document.body.removeChild(textArea);
}
}
} catch (err) {
console.error('复制功能不可用:', err);
}
});
const bottomBtn1788010343RJUAD = document.getElementById('codeflask-bottomBtn-h5tw9ccH0_');
const Toggle1788010343RJUAD = document.getElementById('codeflask-Toggle-h5tw9ccH0_');
bottomBtn1788010343RJUAD.addEventListener('click', function() {
if (isCollapsed1788010343RJUAD) {
// 展开代码
isCollapsed1788010343RJUAD = false;
const codeElement1788010343RJUAD = editorElem1788010343RJUAD.querySelector('.codeflask__code');
if (codeElement1788010343RJUAD) {
const actualHeight1788010343RJUAD = codeElement1788010343RJUAD.scrollHeight + 20;
editorElem1788010343RJUAD.parentElement.style.height = actualHeight1788010343RJUAD + 'px';
editorElem1788010343RJUAD.style.height = actualHeight1788010343RJUAD + 'px';
}
bottomBtn1788010343RJUAD.innerHTML = '<button class="editorjs-codeFlask_BottomToggle" title="折叠代码"><span class="toggle-icon">▲</span> 折叠</button>';
Toggle1788010343RJUAD.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>';
} else {
// 折叠代码
isCollapsed1788010343RJUAD = true;
if (coderow1788010343RJUAD < 20) {
editorElem1788010343RJUAD.parentElement.style.height = '300px';
editorElem1788010343RJUAD.style.height = '300px';
} else if (coderow1788010343RJUAD >= 20) {
editorElem1788010343RJUAD.parentElement.style.height = '500px';
editorElem1788010343RJUAD.style.height = '500px';
}
bottomBtn1788010343RJUAD.innerHTML = '<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>';
Toggle1788010343RJUAD.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
}
});
Toggle1788010343RJUAD.addEventListener('click', function() {
bottomBtn1788010343RJUAD.click();
});
</script><div class="ce-block ce-block--focused" data-id="O-RnsqU3XR" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>核心技巧:</b> <code>description</code> 是整个 Skill 的灵魂。写得越精准,AI 触发得越准。推荐的句式是:<b>“在 [触发条件] 时,用于执行 [目标行动]。”</b></div>
</div>
</div><div class="ce-block" data-id="OHk89BqqsG" >
<div class="ce-block__content" style="">
<h2 class="ce-header ce-header--left">三、 进阶玩法:复杂任务的目录拆分</h2>
</div>
</div><div class="ce-block ce-block--focused" data-id="4pdcx3EMRf" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">如果你的 Skill 只有几十行,像上面那样写一个 <code>SKILL.md</code> 就够了。但如果你要让 AI 帮你处理复杂的工程——比如一套包含数据解析、清洗和测试的 Python 脚本项目,把所有规则都塞进一个文件会让 AI 的“大脑(上下文)”超载。</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="wwdYqTYFTQ" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">这时候,就需要用到<b>工程化目录结构</b>,实现“渐进式加载”。</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="flrvTzrw6-" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">一个标准的高级 Skill 目录长这样:</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="-NArJZgOds" >
<div class="ce-block__content">
<div class="editorjs-codeFlask_Wrapper">
<div class="editorjs-codeFlask_Header">
<div class="editorjs-codeFlask_LangDisplay">markdown</div>
<button class="editorjs-codeFlask_CopyButton" title="复制代码" id="codeflask-copy--NArJZgOds">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<rect x="9" y="9" width="13" height="13" rx="2" ry="2"></rect>
<path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1"></path>
</svg>
</button>
<button class="editorjs-codeFlask_Toggle" id="codeflask-Toggle--NArJZgOds">
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<polyline points="6 9 12 15 18 9"></polyline>
</svg>
</button>
</div>
<div class="editorjs-codeFlask_ContentContainer">
<div class="editorjs-codeFlask_Editor" id="codeflask--NArJZgOds" >
</div>
</div>
<div class="editorjs-codeFlask_BottomButtonContainer" id="codeflask-bottomBtn--NArJZgOds">
<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="static/js/editorjs/tools/codeflask/codeflask150.min.js?SVu"></script>
<script type="application/javascript">
const editorElem1788010343lhC7i = document.getElementById('codeflask--NArJZgOds');
var isCollapsed1788010343lhC7i = true;
const flask1788010343lhC7i = new CodeFlask(editorElem1788010343lhC7i, {
language: 'markdown',
lineNumbers: true,
styleParent: this.shadowRoot,
rtl: false,
readonly: true
});
var code1788010343lhC7i = `my-python-parser-skill/
├── SKILL.md ← 核心:操作手册(触发器和主流程)
├── scripts/ ← 脚本区:放 bash 或 python 脚本(需要精确执行的命令)
│ └── test-run.py
├── references/ ← 文档区:放长篇规范(需要时 AI 才会去读)
│ └── data-cleaning-rules.md
└── assets/ ← 资源区:配置模板
└── config-template.json`;
code1788010343lhC7i = code1788010343lhC7i.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, '"').replace(/'/g, "'");
flask1788010343lhC7i.addLanguage('markdown', Prism.languages['markdown']);
flask1788010343lhC7i.onUpdate((code) => {
// do something with code here.
// this will trigger whenever the code
// in the editor changes.
// console.log(code)
});
// flask.updateCode('');
// This will also trigger .onUpdate()
flask1788010343lhC7i.updateCode(code1788010343lhC7i);
const currentCode1788010343lhC7i = flask1788010343lhC7i.getCode();
var coderow1788010343lhC7i = parseInt('');
if (coderow1788010343lhC7i === undefined || coderow1788010343lhC7i !== coderow1788010343lhC7i || coderow1788010343lhC7i === 0) {
coderow1788010343lhC7i = flask1788010343lhC7i.lineNumber;
}
if (coderow1788010343lhC7i < 20) {
editorElem1788010343lhC7i.parentElement.style.height = '300px';
editorElem1788010343lhC7i.style.height = '300px';
} else if (coderow1788010343lhC7i >= 20) {
editorElem1788010343lhC7i.parentElement.style.height = '500px';
editorElem1788010343lhC7i.style.height = '500px';
}
//console.log({currentCode1788010343lhC7i})
const copyBtn1788010343lhC7i = document.getElementById('codeflask-copy--NArJZgOds');
copyBtn1788010343lhC7i.addEventListener('click', function() {
try {
// 先检查 Clipboard API 是否可用
if (navigator.clipboard && navigator.clipboard.writeText) {
// 使用 Clipboard API 复制代码
navigator.clipboard.writeText(code1788010343lhC7i).then(function() {
// 复制成功提示
const originalText = copyBtn1788010343lhC7i.innerHTML;
copyBtn1788010343lhC7i.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
// 一段时间后恢复原文本
setTimeout(function() {
copyBtn1788010343lhC7i.innerHTML = originalText;
}, 2000);
}).catch(function(err) {
// 复制失败处理
console.error('复制失败:', err);
// 降级方案:使用传统的复制方法
fallbackCopyTextToClipboard(code1788010343lhC7i);
});
} else {
// Clipboard API 不可用时直接使用降级方案
fallbackCopyTextToClipboard(code1788010343lhC7i);
}
// 提取降级方案为独立函数
function fallbackCopyTextToClipboard(text) {
const textArea = document.createElement('textarea');
textArea.value = text;
textArea.style.position = 'fixed';
textArea.style.opacity = '0';
document.body.appendChild(textArea);
textArea.select();
try {
document.execCommand('copy');
const originalText = copyBtn1788010343lhC7i.innerHTML;
copyBtn1788010343lhC7i.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="20 6 9 17 4 12"></polyline></svg> 已复制';
setTimeout(function() {
copyBtn1788010343lhC7i.innerHTML = originalText;
}, 2000);
} catch (copyErr) {
console.error('传统复制方法也失败了:', copyErr);
} finally {
document.body.removeChild(textArea);
}
}
} catch (err) {
console.error('复制功能不可用:', err);
}
});
const bottomBtn1788010343lhC7i = document.getElementById('codeflask-bottomBtn--NArJZgOds');
const Toggle1788010343lhC7i = document.getElementById('codeflask-Toggle--NArJZgOds');
bottomBtn1788010343lhC7i.addEventListener('click', function() {
if (isCollapsed1788010343lhC7i) {
// 展开代码
isCollapsed1788010343lhC7i = false;
const codeElement1788010343lhC7i = editorElem1788010343lhC7i.querySelector('.codeflask__code');
if (codeElement1788010343lhC7i) {
const actualHeight1788010343lhC7i = codeElement1788010343lhC7i.scrollHeight + 20;
editorElem1788010343lhC7i.parentElement.style.height = actualHeight1788010343lhC7i + 'px';
editorElem1788010343lhC7i.style.height = actualHeight1788010343lhC7i + 'px';
}
bottomBtn1788010343lhC7i.innerHTML = '<button class="editorjs-codeFlask_BottomToggle" title="折叠代码"><span class="toggle-icon">▲</span> 折叠</button>';
Toggle1788010343lhC7i.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>';
} else {
// 折叠代码
isCollapsed1788010343lhC7i = true;
if (coderow1788010343lhC7i < 20) {
editorElem1788010343lhC7i.parentElement.style.height = '300px';
editorElem1788010343lhC7i.style.height = '300px';
} else if (coderow1788010343lhC7i >= 20) {
editorElem1788010343lhC7i.parentElement.style.height = '500px';
editorElem1788010343lhC7i.style.height = '500px';
}
bottomBtn1788010343lhC7i.innerHTML = '<button class="editorjs-codeFlask_BottomToggle expand-mode" title="展开代码" data-empty="false"><span class="toggle-icon">▼</span> 展开</button>';
Toggle1788010343lhC7i.innerHTML = '<svg width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="6 9 12 15 18 9"></polyline></svg>';
}
});
Toggle1788010343lhC7i.addEventListener('click', function() {
bottomBtn1788010343lhC7i.click();
});
</script><div class="ce-block ce-block--focused" data-id="h8x5m3ILqD" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>为什么这么做?</b>
AI 默认只把 <code>SKILL.md</code> 放在脑子里。当它根据 <code>SKILL.md</code> 的指引,发现需要更详细的数据清洗规则时,它才会去读取 <code>references/data-cleaning-rules.md</code>。这样既保证了任务的精准度,又节省了 Token,防止 AI 产生幻觉。</div>
</div>
</div><div class="ce-block" data-id="v3ZIIJjs7p" >
<div class="ce-block__content" style="">
<h2 class="ce-header ce-header--left">四、 优化建议</h2>
</div>
</div><div class="ce-block ce-block--focused" data-id="1W35Jf_8z_" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">在你创建完 Skill 强烈建议用下面这个原则优化skill:</div>
</div>
</div><div class="ce-block" data-id="D6yNAte-nt" >
<div class="ce-block__content" style="">
<h3 class="ce-header ce-header--left">单一职责原则</h3>
</div>
</div><div class="ce-block ce-block--focused" data-id="lAQw1MHGNC" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left">不要试图写一个“无所不能”的 Skill(比如把前端 UI 规范、后端数据库设计、部署脚本全塞进一个文件)。超过 500 行的 Skill 就应该被拆分。<b>每个 Skill 只干一件事</b>,这样你在日后开发不同的项目时,才能像搭积木一样灵活组合调用。</div>
</div>
</div><div class="ce-block ce-block--focused" data-id="c_boJoEvYv" >
<div class="ce-block__content">
<div class="ce-paragraph cdx-block ce-paragraph--left"><b>总结一下:</b>
建立个人专属的 Skill 库,前期可能需要花个半天时间来调试和撰写,但一旦沉淀下来,你在后续的编码、学术排版和项目开发中,就能省下无数次重复输入提示词的时间。写完后一定要在实际对话中多跑几次,根据 AI 的表现不断微调,你的 AI 助手就会变得越来越懂你。</div>
</div>
</div><style type="text/css">
.ce-block {
margin-top: 20px;
margin-bottom: 20px;
}
.ce-block__content,.ce-toolbar__content {
/* max-width:calc(100% - 50px) */
margin-left: auto;
margin-right: auto;
}
/**
* Plugin styles
*/
.ce-header {
position: relative;
padding: 1px 0px 1px 15px;
margin: 0;
line-height: 1.25em;
outline: none;
margin-bottom: 10px;
}
.ce-header p,
.ce-header div {
padding: 0 !important;
margin: 0 !important;
}
.ce-header::before {
content: "";
background-color: #3e8fe3;
width: 6px;
height: 100%;
position: absolute;
left: 0;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
/**
* Styles for Plugin icon in Toolbar
*/
.ce-header__icon {
}
.ce-header::before {
position: absolute;
content: attr(data-placeholder);
color: #707684;
font-weight: normal;
display: none;
cursor: text;
}
.ce-header:empty::before {
display: block;
}
.ce-header:empty:focus::before {
display: none;
}
/* FontSize */
h1.ce-header {
font-size: 2.0em;
}
h2.ce-header {
font-size: 1.7em;
}
h3.ce-header {
font-size: 1.4em;
}
h4.ce-header {
font-size: 1.15em;
}
h5.ce-header {
font-size: 0.95em;
}
h6.ce-header {
font-size: 0.8em;
}
/* Alignment*/
.ce-header--right {
text-align: right;
}
.ce-header--center {
text-align: center;
}
.ce-header--left {
text-align: left;
}
.ce-header--justify {
text-align: justify;
}
</style><style type="text/css">
.ce-block {
margin-bottom: 20px;
}
.ce-block__content,.ce-toolbar__content {
/* max-width:calc(100% - 50px) */
margin-left: auto;
margin-right: auto;
}
.ce-paragraph {
line-height: 1.6em;
outline: none;
text-indent: 2em;
font-size: 16px;
}
.ce-paragraph--right {
text-align: right;
}
.ce-paragraph--center {
text-align: center;
}
.ce-paragraph--left {
text-align: left;
}
.ce-paragraph--justify {
text-align: justify;
}
.ce-paragraph-text-indent {
text-align: justify;
}
.ce-paragraph:empty::before{
content: attr(data-placeholder);
color: #707684;
font-weight: normal;
opacity: 0;
}
/** Show placeholder at the first paragraph if Editor is empty */
.codex-editor--empty .ce-block:first-child .ce-paragraph:empty::before {
opacity: 1;
}
.codex-editor--toolbox-opened .ce-block:first-child .ce-paragraph:empty::before,
.codex-editor--empty .ce-block:first-child .ce-paragraph:empty:focus::before {
opacity: 0;
}
.ce-paragraph p:first-of-type{
margin-top: 0;
}
.ce-paragraph p:last-of-type{
margin-bottom: 0;
}
.svg-icon {
width: 1em;
height: 1em;
}
.svg-icon path,
.svg-icon polygon,
.svg-icon rect {
fill: #4691f6;
}
.svg-icon circle {
stroke: #4691f6;
stroke-width: 1;
}
</style><style type="text/css">
.ce-block {
margin-bottom: 20px;
}
.ce-block__content,.ce-toolbar__content {
/* max-width:calc(100% - 50px) */
margin-left: auto;
margin-right: auto;
position: relative;
}
/* 主容器 */
.editorjs-codeFlask_Wrapper {
border: 1px solid #dcdfe6;
border-radius: 5px;
background-color: #f6f8fa;
margin-bottom: 10px;
position: relative;
transition: all 0.3s ease;
width: 100%;
min-height: 100px;
overflow: hidden;
}
/* 标题栏 */
.editorjs-codeFlask_Header {
display: flex;
justify-content: flex-end;
align-items: center;
padding: 8px 12px;
background-color: #e9ecef;
border-bottom: 1px solid #dcdfe6;
position: relative;
z-index: 0; /* 从10降低到2 */
}
/* 语言显示 */
.editorjs-codeFlask_LangDisplay {
padding: 2px 8px;
background-color: #409eff;
color: white;
border-radius: 3px;
font-size: 12px;
font-weight: 500;
position: absolute;
left: 12px;
top: 50%;
transform: translateY(-50%);
}
/* 内容容器 - 禁止纵向滚动 */
.editorjs-codeFlask_ContentContainer {
position: relative;
min-height: 100px;
overflow-x: hidden; /* 禁止横向滚动 */
overflow-y: hidden;
transition: height 0.3s ease;
}
/* 编辑器容器 - 禁止纵向滚动 */
.editorjs-codeFlask_Editor {
position: relative;
min-height: 100px;
overflow-x: hidden; /* 禁止横向滚动 */
overflow-y: hidden;
transition: height 0.3s ease;
}
/* 底部按钮容器 - 优化为更简洁的样式 */
.editorjs-codeFlask_BottomButtonContainer {
display: flex;
justify-content: center;
align-items: center;
padding: 4px;
background-color: #f8f9fa;
border-top: 1px solid #e9ecef;
position: relative;
z-index: 0;
}
/* 底部横向折叠/展开按钮 - 优化样式,使其更融入设计 */
.editorjs-codeFlask_BottomToggle {
width: 100%;
background-color: transparent;
color: #606266;
border: none;
border-radius: 4px;
padding: 6px 12px;
font-size: 12px;
font-weight: 400;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
gap: 4px;
text-align: center;
position: relative;
}
.editorjs-codeFlask_BottomToggle:hover {
background-color: #e9ecef;
color: #409eff;
}
.editorjs-codeFlask_BottomToggle:active {
background-color: #dee2e6;
}
.editorjs-codeFlask_BottomToggle .toggle-icon {
font-size: 11px;
transition: transform 0.3s ease;
}
/* 展开按钮(显示"展开"文本)上边缘添加渐变虚化效果 */
.editorjs-codeFlask_BottomToggle:has(span.toggle-icon:contains("▲"))::before {
content: '';
position: absolute;
top: 0;
left: 0;
right: 0;
height: 6px;
background: linear-gradient(to bottom, rgba(248, 249, 250, 0) 0%, rgba(248, 249, 250, 1) 100%);
pointer-events: none;
}
/* 展开按钮(显示"展开"文本)上边缘添加渐变虚化效果 */
/* 删除不被广泛支持的:contains()选择器 */
.editorjs-codeFlask_BottomToggle.expand-mode::before {
content: '';
position: absolute;
top: -60px;
left: 0;
right: 0;
height: 60px;
background: linear-gradient(to bottom, rgb(255 255 255 / 0%) 0%, rgba(248, 249, 250, 1) 100%);
pointer-events: none;
}
/* CodeFlask 主容器样式 */
.editorjs-codeFlask_Editor .codeflask {
position: relative;
background: #fafafa;
border-radius: 0 0 4px 4px;
min-height: 100px;
overflow-x: hidden; /* 禁止横向滚动 */
overflow-y: hidden;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}
/* 行号容器 */
.editorjs-codeFlask_Editor .codeflask.codeflask--has-line-numbers:before {
content: '';
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 40px;
background-color: #f5f5f5;
border-right: 1px solid #e0e0e0;
z-index: 0;
}
/* 行号 */
.editorjs-codeFlask_Editor .codeflask__lines {
position: absolute;
left: 0;
top: 0;
bottom: 0;
width: 40px;
padding: 10px 0;
background-color: #f5f5f5;
border-right: 1px solid #e0e0e0;
z-index: 0;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 14px;
line-height: 21px;
color: #666;
text-align: right;
user-select: none;
overflow: hidden;
}
.editorjs-codeFlask_Editor .codeflask__lines__line {
padding-right: 8px;
}
/* 文本区域 - 输入框 */
.editorjs-codeFlask_Editor .codeflask__textarea {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
padding: 10px;
border: none;
background: transparent;
color: transparent;
caret-color: #333;
resize: none;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 14px;
line-height: 21px;
z-index: 1;
overflow-x: hidden; /* 禁止横向滚动 */
overflow-y: hidden;
white-space: pre-wrap; /* 自动换行 */
tab-size: 4;
outline: none;
}
/* 添加选中文本样式 */
.editorjs-codeFlask_Editor .codeflask__textarea::selection {
background-color: #b3d4fc;
color: #333;
}
.editorjs-codeFlask_Editor .codeflask__textarea::-moz-selection {
background-color: #b3d4fc;
color: #333;
}
/* 代码预览区域 */
.editorjs-codeFlask_Editor .codeflask__pre {
position: absolute;
top: 0;
left: 0;
width: 100%; /* 确保宽度不超出容器 */
height: 100%;
padding: 10px;
margin: 0;
border: none;
background: transparent;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 14px;
line-height: 21px;
z-index: 0;
overflow-x: hidden; /* 禁止横向滚动 */
overflow-y: hidden;
white-space: pre-wrap; /* 自动换行 */
pointer-events: none;
}
/* 代码高亮区域 */
.editorjs-codeFlask_Editor .codeflask__code {
display: block;
font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
font-size: 14px;
line-height: 21px;
color: #333;
white-space: pre-wrap; /* 自动换行 */
tab-size: 4;
overflow: visible;
}
/* 语法高亮样式 - 确保Prism.js样式正确应用 */
.editorjs-codeFlask_Editor .codeflask__code {
background: transparent !important;
}
/* 通用语法高亮token样式 */
.editorjs-codeFlask_Editor .token.comment,
.editorjs-codeFlask_Editor .token.prolog,
.editorjs-codeFlask_Editor .token.doctype,
.editorjs-codeFlask_Editor .token.cdata {
color: #708090;
}
.editorjs-codeFlask_Editor .token.punctuation {
color: #999;
}
.editorjs-codeFlask_Editor .token.namespace {
opacity: 0.7;
}
.editorjs-codeFlask_Editor .token.property,
.editorjs-codeFlask_Editor .token.tag,
.editorjs-codeFlask_Editor .token.boolean,
.editorjs-codeFlask_Editor .token.number,
.editorjs-codeFlask_Editor .token.constant,
.editorjs-codeFlask_Editor .token.symbol,
.editorjs-codeFlask_Editor .token.deleted {
color: #905;
}
.editorjs-codeFlask_Editor .token.selector,
.editorjs-codeFlask_Editor .token.attr-name,
.editorjs-codeFlask_Editor .token.string,
.editorjs-codeFlask_Editor .token.char,
.editorjs-codeFlask_Editor .token.builtin,
.editorjs-codeFlask_Editor .token.inserted {
color: #690;
}
.editorjs-codeFlask_Editor .token.operator,
.editorjs-codeFlask_Editor .token.entity,
.editorjs-codeFlask_Editor .token.url,
.editorjs-codeFlask_Editor .language-css .token.string,
.editorjs-codeFlask_Editor .style .token.string {
color: #9a6e3a;
background: hsla(0, 0%, 100%, 0.5);
}
.editorjs-codeFlask_Editor .token.atrule,
.editorjs-codeFlask_Editor .token.attr-value,
.editorjs-codeFlask_Editor .token.keyword {
color: #07a;
}
.editorjs-codeFlask_Editor .token.function,
.editorjs-codeFlask_Editor .token.class-name {
color: #dd4a68;
}
.editorjs-codeFlask_Editor .token.regex,
.editorjs-codeFlask_Editor .token.important,
.editorjs-codeFlask_Editor .token.variable {
color: #e90;
}
/* 复制按钮样式 */
.editorjs-codeFlask_CopyButton {
background-color: #409eff;
color: white;
border: none;
border-radius: 3px;
padding: 6px 12px;
margin-right: 8px;
font-size: 12px;
cursor: pointer;
transition: background-color 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
min-width: 28px;
height: 28px;
}
.editorjs-codeFlask_CopyButton:hover {
background-color: #66b1ff;
}
.editorjs-codeFlask_CopyButton.copied {
background-color: #67c23a;
}
/* 折叠/展开按钮样式 */
.editorjs-codeFlask_Toggle {
background-color: #909399;
color: white;
border: none;
border-radius: 3px;
padding: 0 8px;
font-size: 12px;
cursor: pointer;
transition: background-color 0.2s ease;
display: flex;
align-items: center;
justify-content: center;
min-width: 28px;
height: 28px;
font-weight: bold;
}
.editorjs-codeFlask_Toggle:hover {
background-color: #a6a9ad;
}
/* 响应式调整 */
@media (max-width: 768px) {
.editorjs-codeFlask_Header {
padding: 6px 8px;
}
.editorjs-codeFlask_Editor .codeflask__textarea,
.editorjs-codeFlask_Editor .codeflask__pre,
.editorjs-codeFlask_Editor .codeflask__code {
font-size: 13px;
line-height: 19px;
padding: 8px;
}
.editorjs-codeFlask_Editor .codeflask.codeflask--has-line-numbers:before {
width: 35px;
}
.editorjs-codeFlask_Editor .codeflask__lines {
width: 35px;
font-size: 12px;
}
}
/* 滚动条样式 - 完全隐藏纵向滚动条 */
.editorjs-codeFlask_Wrapper ::-webkit-scrollbar {
width: 0;/* 纵向滚动条宽度为0 */
height: 6px;/* 横向滚动条保持6px宽度 */
}
.editorjs-codeFlask_Wrapper ::-webkit-scrollbar-track {
background: transparent;
border-radius: 0;
}
.editorjs-codeFlask_Wrapper ::-webkit-scrollbar-thumb {
background: transparent;
border-radius: 0;
}
/* Firefox 滚动条隐藏 */
.editorjs-codeFlask_Wrapper {
scrollbar-width: none;/* Firefox 隐藏纵向滚动条 */
}
.editorjs-codeFlask_Wrapper ::-moz-scrollbar {
width: 0;
height: 6px;
}
/* 焦点状态 */
.editorjs-codeFlask_Wrapper:focus-within {
border-color: #409eff;
box-shadow: 0 0 0 2px rgba(64, 158, 255, 0.2);
}
/* 只读模式样式 */
.editorjs-codeFlask_Wrapper.readonly .editorjs-codeFlask_Header {
background-color: #f5f7fa;
}
.editorjs-codeFlask_Wrapper.readonly .editorjs-codeFlask_Editor .codeflask__textarea {
cursor: default;
}
/* 确保所有元素正确显示 */
.editorjs-codeFlask_Wrapper * {
box-sizing: border-box;
}
/* 修复行号对齐 */
.editorjs-codeFlask_Editor .codeflask--has-line-numbers .codeflask__textarea,
.editorjs-codeFlask_Editor .codeflask--has-line-numbers .codeflask__pre {
padding-left: 50px;
}
.editorjs-codeFlask_Editor .codeflask--has-line-numbers .codeflask__lines {
padding-top: 10px;
}
/* 语言显示元素 - 添加点击样式 */
.editorjs-codeFlask_LangDisplay {
padding: 2px 8px;
background-color: #409eff;
color: white;
border-radius: 3px;
font-size: 12px;
font-weight: 500;
position: absolute;
left: 12px;
top: 50%;
transform: translateY(-50%);
cursor: pointer;
transition: all 0.2s ease;
}
.editorjs-codeFlask_LangDisplay:hover {
background-color: #66b1ff;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
/* 语言选择弹窗 */
.editorjs-codeFlask_LanguagePopup {
background-color: white;
border: 1px solid #dcdfe6;
border-radius: 4px;
box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
width: 250px;
max-height: 300px;
z-index: 1000;
overflow: hidden;
}
/* 搜索框 */
.editorjs-codeFlask_LanguageSearch {
width: 100%;
padding: 8px 12px;
border: none;
border-bottom: 1px solid #ebeef5;
font-size: 12px;
outline: none;
box-sizing: border-box;
}
/* 语言列表 */
.editorjs-codeFlask_LanguagesList {
max-height: 250px;
overflow-y: auto;
}
/* 语言选项 */
.editorjs-codeFlask_LanguageItem {
padding: 8px 12px;
font-size: 12px;
cursor: pointer;
transition: background-color 0.2s ease;
}
.editorjs-codeFlask_LanguageItem:hover {
background-color: #f5f7fa;
}
.editorjs-codeFlask_LanguageItem.selected {
background-color: #ecf5ff;
color: #409eff;
font-weight: 500;
}
/* 滚动条样式 */
.editorjs-codeFlask_LanguagesList::-webkit-scrollbar {
width: 6px;
}
.editorjs-codeFlask_LanguagesList::-webkit-scrollbar-track {
background-color: #f5f7fa;
}
.editorjs-codeFlask_LanguagesList::-webkit-scrollbar-thumb {
background-color: #c0c4cc;
border-radius: 3px;
}
.editorjs-codeFlask_LanguagesList::-webkit-scrollbar-thumb:hover {
background-color: #909399;
}
</style><style type="text/css">
.inline-code {
background: rgba(250, 239, 240, 0.78);
color: #b44437;
padding: 3px 4px;
border-radius: 5px;
margin: 0 1px;
font-family: inherit;
font-size: 0.86em;
font-weight: 500;
letter-spacing: 0.3px;
}
</style>
页:
[1]