feat: 实现 Mermaid 导出功能
- 添加导出按钮到工具栏,支持 PNG 和 SVG 格式导出 - 实现导出菜单,点击导出按钮显示格式选项 - PNG 导出:将 SVG 转换为 PNG 图片并下载 - SVG 导出:保存 SVG 代码为文件并下载 - 导出时保持图表当前的缩放级别和样式 - 添加导出错误处理,显示友好的错误提示 - 导出菜单支持点击外部关闭 - 添加导出菜单样式,支持夜间模式 - 移动端导出菜单适配,调整按钮大小和位置 - 错误提示自动消失(3秒后) 需求:15.1, 15.2, 15.3, 15.4, 15.5
This commit is contained in:
109
style.css
109
style.css
@@ -1176,6 +1176,103 @@ html.darkmode .mermaid-fullscreen .mermaid-zoom-controls {
|
||||
color: var(--themecolor);
|
||||
}
|
||||
|
||||
/* 需求 15: Mermaid 导出功能样式 */
|
||||
/* 导出按钮 */
|
||||
.mermaid-export-btn {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* 导出菜单 */
|
||||
.mermaid-export-menu {
|
||||
position: absolute;
|
||||
top: 45px;
|
||||
right: 10px;
|
||||
background: white;
|
||||
border-radius: 6px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
padding: 8px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
opacity: 0;
|
||||
visibility: hidden;
|
||||
transform: translateY(-10px);
|
||||
transition: all 0.2s ease;
|
||||
z-index: 11;
|
||||
min-width: 140px;
|
||||
}
|
||||
|
||||
.mermaid-export-menu.visible {
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
transform: translateY(0);
|
||||
}
|
||||
|
||||
html.darkmode .mermaid-export-menu {
|
||||
background: #2a2a2a;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
|
||||
}
|
||||
|
||||
/* 导出选项按钮 */
|
||||
.mermaid-export-option {
|
||||
padding: 8px 12px;
|
||||
border: none;
|
||||
background: transparent;
|
||||
color: #333;
|
||||
text-align: left;
|
||||
cursor: pointer;
|
||||
border-radius: 4px;
|
||||
font-size: 14px;
|
||||
transition: background 0.2s;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.mermaid-export-option:hover {
|
||||
background: rgba(94, 114, 228, 0.1);
|
||||
color: var(--themecolor);
|
||||
}
|
||||
|
||||
html.darkmode .mermaid-export-option {
|
||||
color: #ddd;
|
||||
}
|
||||
|
||||
html.darkmode .mermaid-export-option:hover {
|
||||
background: rgba(94, 114, 228, 0.2);
|
||||
}
|
||||
|
||||
/* 需求 15.5: 导出错误提示 */
|
||||
.mermaid-export-error {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
background: rgba(220, 53, 69, 0.95);
|
||||
color: white;
|
||||
padding: 12px 20px;
|
||||
border-radius: 6px;
|
||||
font-size: 14px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
|
||||
z-index: 100;
|
||||
animation: slideInDown 0.3s ease;
|
||||
max-width: 80%;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
@keyframes slideInDown {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translate(-50%, -60%);
|
||||
}
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
}
|
||||
|
||||
html.darkmode .mermaid-export-error {
|
||||
background: rgba(200, 35, 51, 0.95);
|
||||
}
|
||||
|
||||
/* 全屏模式下的内部容器 */
|
||||
.mermaid-fullscreen .mermaid-container-inner {
|
||||
max-height: calc(100vh - 100px);
|
||||
@@ -1243,6 +1340,18 @@ article.card .mermaid-container {
|
||||
padding: 5px 10px;
|
||||
bottom: 8px;
|
||||
}
|
||||
|
||||
/* 移动端导出菜单调整 */
|
||||
.mermaid-export-menu {
|
||||
right: 8px;
|
||||
top: 50px;
|
||||
min-width: 150px;
|
||||
}
|
||||
|
||||
.mermaid-export-option {
|
||||
padding: 10px 14px;
|
||||
font-size: 15px;
|
||||
}
|
||||
}
|
||||
|
||||
/* 需求 16.5: 横屏模式优化 - 自动调整图表布局 */
|
||||
|
||||
Reference in New Issue
Block a user