Files
qiming/qiming-mobile/subpackages/uni_modules/mp-html/components/mp-html/styles/highlight.scss

239 lines
4.9 KiB
SCSS

/* 代码高亮样式 - 基于 uni-ai-msg-code 深色主题 */
/* FiraCode 字体已被移除以减小包体积 */
/* @font-face {
font-family: CodeFontFamily;
src: url('@uni_modules/mp-html/static/font/FiraCode-Regular.ttf') format('truetype');
} */
:deep(.hl-code) {
color: #d4d4d4;
background: transparent;
font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
font-size: 14px;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
flex: 1;
min-width: 0;
overflow-x: auto;
overflow-y: hidden; /* 防止代码区自己产生内部垂直滚动条 */
padding: 10px 12px; /* 代码内容的内边距 */
box-sizing: border-box;
min-height: 100%;
align-self: stretch;
}
:deep(.hl-pre) {
color: #d4d4d4;
background: #1e1e1e;
font-family: Consolas, Monaco, "Andale Mono", "Ubuntu Mono", monospace;
font-size: 14px;
text-align: left;
white-space: pre;
word-spacing: normal;
word-break: normal;
word-wrap: normal;
line-height: 1.5;
-moz-tab-size: 4;
-o-tab-size: 4;
tab-size: 4;
-webkit-hyphens: none;
-moz-hyphens: none;
-ms-hyphens: none;
hyphens: none;
border-radius: 6px;
position: relative;
display: flex;
flex-direction: column;
padding: 0; /* Remove old padding */
overflow: hidden; /* Stop whole wrapper from sliding */
}
/* 代码头部样式 */
:deep(.hl-language) {
margin: 0; /* 确保没有外边距 */
line-height: normal; /* 重置行高 */
white-space: normal; /* 重置空白处理 */
user-select: none;
position: relative;
top: 0;
left: 0;
width: 100%;
box-sizing: border-box;
flex-shrink: 0;
display: flex;
justify-content: space-between;
align-items: center;
padding: 2px 10px;
background-color: #252526;
border-radius: 6px 6px 0 0;
font-size: 12px;
color: #999;
}
:deep(.hl-body) {
/* wrapper handle scrolling ONLY */
max-height: 60vh;
overflow-y: auto; /* vertically scroll the code and line numbers */
overflow-x: hidden;
width: 100%;
position: relative;
background-color: #1e1e1e;
}
:deep(.hl-container) {
display: flex;
flex-direction: row;
align-items: stretch; /* flex cross-axis stretch without scroll boundaries */
width: 100%;
box-sizing: border-box;
}
/* 代码高亮颜色 - 基于 uni-ai-msg-code 深色主题 */
:deep(.hl-block-comment),
:deep(.hl-cdata),
:deep(.hl-comment),
:deep(.hl-doctype),
:deep(.hl-prolog) {
color: #999; /* 注释使用灰色 */
}
:deep(.hl-punctuation) {
color: #d4d4d4; /* 标点符号使用默认文本颜色 */
}
:deep(.hl-attr-name),
:deep(.hl-deleted),
:deep(.hl-namespace),
:deep(.hl-tag) {
color: #d16969; /* 元信息使用红色 */
}
:deep(.hl-function-name) {
color: #dcdcaa; /* 函数使用黄色 */
}
:deep(.hl-boolean),
:deep(.hl-function),
:deep(.hl-number) {
color: #b5cea8; /* 常量使用浅绿色 */
}
:deep(.hl-class-name),
:deep(.hl-constant),
:deep(.hl-property),
:deep(.hl-symbol) {
color: #4ec9b0; /* 实体使用青色 */
}
:deep(.hl-atrule),
:deep(.hl-builtin),
:deep(.hl-important),
:deep(.hl-keyword),
:deep(.hl-selector) {
color: #569cd6; /* 关键字使用蓝色 */
}
:deep(.hl-attr-value),
:deep(.hl-char),
:deep(.hl-regex),
:deep(.hl-string),
:deep(.hl-variable) {
color: #ce9178; /* 字符串使用橙色 */
}
:deep(.hl-entity),
:deep(.hl-operator),
:deep(.hl-url) {
color: #4ec9b0; /* 支持类使用青色 */
}
:deep(.hl-bold),
:deep(.hl-important) {
font-weight: 700;
}
:deep(.hl-italic) {
font-style: italic;
}
:deep(.hl-entity) {
cursor: help;
}
:deep(.hl-inserted) {
color: #4ec9b0; /* 插入内容使用青色 */
}
/* 行号样式 */
:deep(.line-numbers-rows) {
position: static;
flex-shrink: 0;
min-width: 3.5em;
text-align: center;
color: #666;
font-size: 14px;
line-height: 1.5;
user-select: none;
padding-top: 10px; /* align with code padding */
padding-bottom: 10px;
background-color: transparent;
border-right: 1px solid #333;
display: flex;
flex-direction: column;
box-sizing: border-box;
min-height: 100%;
align-self: stretch;
}
:deep(.line-numbers-rows .span) {
display: flex;
height: 1.5em; /* Match code line height */
align-items: center;
justify-content: center;
}
/* 复制按钮样式 */
:deep(.hl-copy-btn) {
display: flex;
align-items: center;
padding: 2px 4px;
border-radius: 4px;
cursor: pointer;
font-size: 10px;
color: #999;
}
:deep(.hl-copy-btn:hover) {
background-color: #37373d;
}
/* 滚动条样式 */
:deep(.hl-pre::-webkit-scrollbar) {
height: 8px;
}
:deep(.hl-pre::-webkit-scrollbar-track) {
background: #252526;
border-radius: 4px;
}
:deep(.hl-pre::-webkit-scrollbar-thumb) {
background: #666;
border-radius: 4px;
}
:deep(.hl-pre::-webkit-scrollbar-thumb:hover) {
background: #888;
}