fix: scale A2 frames to 2/3 width and keep H1 adaptive
Some checks are pending
Test / test (macos-latest) (push) Waiting to run
Test / test (ubuntu-latest) (push) Waiting to run
Test / test (windows-latest) (push) Waiting to run

Shorten shared H1/code/hr min width, grow H1 with long titles, fix missing newline before hr, and keep Windows one-click NSIS icons.
This commit is contained in:
hackrobot 2026-10-03 09:37:40 +08:00
parent 5f9cf37c48
commit 84d523558e
5 changed files with 35 additions and 26 deletions

View File

@ -17,7 +17,7 @@
|------|------|
| 三栏联动 | 左编辑 / 中 Emoji 纯文本 / 右长文富文本;滚动按比例同步,语法与渲染对应 |
| Markdown 实时预览 | 基于 `marked`:中间栏自定义 Emoji Renderer,右侧栏 GFM 富文本 |
| 四套 + A2 主题 | 经典 / **A2 商务**(B 式线框 H1 + 📋📌🔹1️⃣ 职场 emoji;表格全角 `-|`)/ 青简 / 精简 / 聚焦 |
| 四套 + A2 主题 | 经典 / **A2 商务**(B 式线框 H1 + 📋📌🔸1️⃣;表格全角 `-|`)/ 青简 / 精简 / 聚焦 |
| Emoji 装饰排版 | 标题边框、列表符号、任务勾选、引用、分隔线等用 Unicode/Emoji 呈现;纯文本栏禁止 CSS 画框 |
| 一键复制 | 中间栏复制纯文本(所见即粘贴);右侧栏复制富文本 HTML |
| 可视化表格 | MarkText 风格插入/编辑表格,插入前可填单元格 |
@ -46,11 +46,12 @@
### 主题 A2 · 商务(纯文本栏)
- **H1**:主题 B 同款 `┌─┐│└─┘` 线框 + `📋`
- **H2**:`📌` + 细横线;**H3**:`📎`;列表 `🔹` / `1️⃣…`
- **行内代码**:`『…』`;代码块:`┌─┐` 线框
- **H1**:主题 B 同款 `┌─┐│└─┘` 线框 + `📋`(最短宽约原 2/3,超长自适应)
- **H2**:`📌`;**H3**:`📎`;列表 `🔸` / `1️⃣…`
- **行内代码**:`『…』`;代码块:`┌─┐` 线框(最短宽与 H1 对齐,超长自适应)
- **表格**:全角 `-|` 线框(与微信/雅黑对齐);图片在纯文本栏不输出
- **任务**:`✅` / `⬜`(无额外列表符)
- **分隔线**:与 H1 最短框同宽虚线 `· · · …`
## 技术栈

BIN
assets/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 KiB

View File

@ -220,7 +220,20 @@
"win": {
"target": [
"nsis"
]
],
"icon": "assets/icon.ico"
},
"nsis": {
"oneClick": true,
"perMachine": false,
"allowToChangeInstallationDirectory": false,
"createDesktopShortcut": true,
"createStartMenuShortcut": true,
"shortcutName": "emojiTool",
"installerIcon": "assets/icon.ico",
"uninstallerIcon": "assets/icon.ico",
"installerHeaderIcon": "assets/icon.ico",
"deleteAppDataOnUninstall": false
},
"linux": {
"target": [

View File

@ -953,6 +953,8 @@
margin: 1.1em 0;
text-align: left;
color: inherit;
white-space: pre;
overflow-x: auto;
}
:global(.emoji-quote) {

View File

@ -65,28 +65,23 @@ function frameTitleB(text: string): string {
/**
* A2 一级标题:沿用主题 B 线框 ┌─┐│└─┘,emoji 用 📋。
* 最短固定宽度为原 28 的 2/3;标题更长时框线随字数加长。
*/
const A2_FRAME_MIN_WIDTH = Math.round(28 * (2 / 3)); // 19
function frameTitleA2(text: string): string {
const body = `📋 ${text}`;
const width = Math.max(displayWidth(body), 10);
const width = Math.max(displayWidth(body), A2_FRAME_MIN_WIDTH);
const line = '─'.repeat(width);
return `<div class="emoji-h1">┌${line}┐<br/>│ ${body}<br/>└${line}┘</div>`;
return `<div class="emoji-h1">┌${line}┐<br/>│ ${body}<br/>└${line}┘</div>\n`;
}
/** A2 线条:等长、无 emoji,细线 / 虚线 */
const A2_LINE_WIDTH = 16;
function a2Line(style: 'title' | 'section'): string {
if (style === 'title') {
return repeatToDisplayWidth('─', A2_LINE_WIDTH);
}
return Array.from({ length: Math.ceil(A2_LINE_WIDTH / 2) }, () => '·').join(
/** 分隔线与 H1 最短框同宽虚线 */
function businessHr(): string {
const dots = Array.from({ length: A2_FRAME_MIN_WIDTH }, () => '·').join(
' ',
);
}
function businessHr(): string {
return `<div class="emoji-hr">${a2Line('section')}</div>\n`;
return `<div class="emoji-hr">${dots}</div>\n`;
}
function frameTitleC(text: string): string {
@ -107,12 +102,13 @@ function plainCodeBlockA2(title: string, code: string): string {
const body = escapeCode(code.replace(/\n$/, ''));
const lines = body.split('\n');
const head = `💻 ${title}`;
// 最短宽与 H1/分割线一致(原约 12+余量的 2/3 量级),内容更长时自适应
const maxW = Math.max(
displayWidth(head),
...lines.map((line) => displayWidth(line)),
12,
A2_FRAME_MIN_WIDTH,
);
const edge = repeatToDisplayWidth('─', maxW + 2);
const edge = repeatToDisplayWidth('─', maxW);
return `<div class="emoji-code emoji-code-a2"><pre>┌${edge}┐
│ ${head}
├${edge}┤
@ -174,7 +170,7 @@ export const THEME_A2: EmojiTheme = {
shortName: 'A2 商务',
description:
'正式商务 + 职场 emoji 色彩:B 式线框、钉选/清单符号、彩色序号',
listSymbol: '🔹',
listSymbol: '🔸',
orderedNumbers: [
'1️⃣',
'2️⃣',
@ -191,10 +187,7 @@ export const THEME_A2: EmojiTheme = {
taskChecked: '✅',
taskUnchecked: '⬜',
heading1: frameTitleA2,
heading2: (text) => {
const title = `📌 ${text}`;
return `<div class="emoji-h2">${title}<br/>${a2Line('title')}</div>\n`;
},
heading2: (text) => `<div class="emoji-h2">📌 ${text}</div>\n`,
heading3: (text) => `<div class="emoji-h3">📎 ${text}</div>\n`,
heading4: (text) => `<div class="emoji-h4">▪️ ${text}</div>\n`,
hr: businessHr(),