dsh-composer-live 0.2.23 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +43 -0
- package/README.md +23 -5
- package/README.zh-CN.md +23 -5
- package/client.js +168 -46
- package/docs/screenshots/code-block.png +0 -0
- package/docs/screenshots/focus-line.png +0 -0
- package/docs/screenshots/overview.png +0 -0
- package/docs/screenshots/selection-bar.png +0 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,49 @@
|
|
|
2
2
|
|
|
3
3
|
> 更新日志以中文记录。Changelog entries are written in Chinese.
|
|
4
4
|
|
|
5
|
+
## 0.3.1(2026-11-15)
|
|
6
|
+
|
|
7
|
+
### 🩹 代码块配色改「从输入卡底色派生」——修复部分皮肤深色下代码块与输入框同色隐形
|
|
8
|
+
|
|
9
|
+
0.3.0 的代码块背景跟随官方变量 `--dsw-alias-markdown-code-block`,但 OnePage 这类皮肤把它定义成「页面底色 + 半透明」——深色模式下输入卡底色恰好等于页面底色,叠加后**代码块与输入框完全同色**(实测 onepage 深色:卡 `#211e1d` + 块 `#211e1db0` → 归零),浅色下也只剩勉强可辨的淡米色。
|
|
10
|
+
|
|
11
|
+
- **代码块/语言标签/行内代码(含图片胶囊、任务标记等胶囊家族)改为从「输入卡实际底色」派生**:`render()` 把卡底写成 `--dsh-cl-card-bg`,CSS `color-mix()` 派生深浅两档——跟随的正确语义是**跟随所在容器**,而非跟随消息区变量;换肤/换主题/亮暗切换自动保证有层次
|
|
12
|
+
- 派生值经方案预览页(实测色值 1:1 还原、明暗对比)拍板:深色块 = 卡底压暗一档,浅色块 = 暖灰一档
|
|
13
|
+
- `@supports` 守卫:不支持 `color-mix` 的老内核回落 0.3.0 观感,不劣化
|
|
14
|
+
- 语法高亮 token 仍跟随官方 shiki 主题不变
|
|
15
|
+
|
|
16
|
+
## 0.3.0(2026-11-15)
|
|
17
|
+
|
|
18
|
+
**主题跟随 + 焦点行(源码/阅读视图分离)——输入体验的一次跨越。**
|
|
19
|
+
|
|
20
|
+
### ✨ 焦点行:光标行是源码,其余行是阅读视图(Obsidian「实时预览」式)
|
|
21
|
+
|
|
22
|
+
以前输入 `**bold**`,星号和粗体同时出现在一行里——「源码视图」和「阅读视图」混在一起。现在:
|
|
23
|
+
|
|
24
|
+
- **光标/选区所在行显示完整源码标记**(可编辑,标记可见)
|
|
25
|
+
- **其余行自动切换为阅读形态**:
|
|
26
|
+
- 行内标记(`**` `` ` `` `~~` `[]()`)与 `##`、`>` 前缀隐身——只剩粗体、胶囊、竖条
|
|
27
|
+
- 无序列表 `-` 渲染为 **圆点符号**
|
|
28
|
+
- 任务 `- [ ]` / `- [x]` 渲染为**真复选框**(勾选态绿底白勾)
|
|
29
|
+
- 有序列表保留数字;表格行与代码围栏恒为源码(编辑结构)
|
|
30
|
+
- **输入框失焦时全部行变阅读形态**——整个输入框就是一片干净的预览
|
|
31
|
+
- 「隐身」只是渲染层不画(`color:transparent`),字符占位原样保留——**光标对齐零风险**
|
|
32
|
+
|
|
33
|
+
### 🎨 颜色全面跟随主题(不再写死任何色值)
|
|
34
|
+
|
|
35
|
+
所有渲染颜色改为优先读官方/皮肤 CSS 变量,换皮肤、换主题、亮暗切换**零改码自动跟随**:
|
|
36
|
+
|
|
37
|
+
- 强调色 → `--dsw-alias-link`;行内代码底 → `--dsw-alias-markdown-inline-code`(**与消息区同源——打字时和发送后颜色终于一致**)
|
|
38
|
+
- 代码块底 → `--dsw-alias-markdown-code-block`;**代码高亮 token 整套跟随官方 shiki 主题**(`--shiki-token-*`,与消息区代码块完全同色)
|
|
39
|
+
- 标记字符 → `--dsw-alias-label-dimmed`;任务完成 → success token;工具栏/浮动条/toast → 官方表面层 token
|
|
40
|
+
- 0.1.x 等无这套变量的宿主自动回退内置亮暗配色(双环境 136×2 E2E 验证兼容)
|
|
41
|
+
|
|
42
|
+
### 🔧 实现与验证
|
|
43
|
+
|
|
44
|
+
- 渲染签名追加 `editSig`(选区行集合指纹)——拖选跨行、焦点进出都正确触发重渲染
|
|
45
|
+
- 新增纯函数 `computeEditLines` / `toReadingForm` / `lineIndexOfOffset`;有序列表标记加 `dsh-cl-lnum` 类
|
|
46
|
+
- 单测 220 → **246 全过**;E2E 双环境(DSH 0.1.5 与 0.2.1)各 **136/136 全绿**;真环境焦点行/主题跟随逐项实测通过
|
|
47
|
+
|
|
5
48
|
## 0.2.23(2026-11-08)
|
|
6
49
|
|
|
7
50
|
**引用行多行粘贴续前缀**:光标在引用行(`> ` 开头)粘贴两行以上纯文本时,自动从第二行起补 `> ` 前缀并入引用块(Typora 同款行为)。防误伤四条:第一行永远原样(接光标处并入当前引用段落);粘贴内容本身已是引用块(非空行全带 `>`)不处理避免双重前缀;混合内容只给不带 `>` 的行补(保留嵌套 `>>`);单行粘贴与普通行光标不处理。引用语境优先于「大段粘贴包代码块」(引用行里粘代码也续前缀,撤销后可用工具栏手动包)。单测 14 例 + E2E V1–V7 场景;`pasteClip` 新 op 走真实 Ctrl+V 同事件管线。**插入通道的坑(E2E 抓出)**:paste 上下文里逐行 beforeinput(insertInline)在 0.2.x 丢首段、合成 paste 重放在 0.1.5 丢首段——两代 Lexical 的 paste 后处理竞态方向相反,终局方案 = 改写剪贴板后 **120ms 延后重放**(等 Lexical 安顿再走官方管线原生插入,一条撤销记录),双代全绿。粘贴大段 Markdown 的实时渲染(标题/粗斜/行内码/链接/代码块高亮/引用/列表/任务/表格)经实测本就完整支持,V7 场景固化防回归。
|
package/README.md
CHANGED
|
@@ -2,26 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
<h1 align="center">dsh-composer-live</h1>
|
|
4
4
|
|
|
5
|
-
<p align="center"><b>Type Markdown, see it rendered live</b> —
|
|
5
|
+
<p align="center"><b>Type Markdown, see it rendered live</b> — with a caret-aware source/reading split and theme-following colors.</p>
|
|
6
6
|
|
|
7
7
|
<p align="center">[English](./README.md) · [简体中文](./README.zh-CN.md)</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT">
|
|
11
11
|
<img src="https://img.shields.io/badge/DSH-%3E%3D%200.1.5--rc.2-4c6ef5" alt="DSH >= 0.1.5-rc.2">
|
|
12
|
-
<img src="https://img.shields.io/badge/tests-
|
|
12
|
+
<img src="https://img.shields.io/badge/tests-246%20unit%20%C2%B7%20136%20E2E-2ea44f" alt="tests">
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
15
|

|
|
16
16
|
|
|
17
17
|
dsh-composer-live turns the DSH Web input box into an Open-WebUI-style live editor: you type Markdown, it renders as you type — bold, italic, code blocks with syntax highlighting, lists, quotes, tables — while the draft itself stays plain Markdown source, so what you send is exactly what you typed.
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Since **v0.3.0** it also does what Obsidian's live preview does: **the line your caret is on shows the raw Markdown** (editable, markers visible), **every other line renders in clean reading form** — markers hidden, `-` list items become bullet dots, `- [ ]` / `- [x]` tasks become real checkboxes. And all colors now **follow your theme/skin** via official DSH variables — inline code looks the same while typing as it does after sending.
|
|
20
|
+
|
|
21
|
+
It is a **pure browser-side plugin**: zero runtime dependencies, no service injection, no patches to official code. It layers on top of the official 0.1.5+ Lexical composer without touching what DSH already does natively.
|
|
20
22
|
|
|
21
23
|
> Looking for the DSH **0.1.x** (textarea composer) version? That's [`dsh-composer-md`](#faq), the predecessor of this plugin — discontinued.
|
|
22
24
|
|
|
23
25
|
## Screenshots
|
|
24
26
|
|
|
27
|
+
### Focus-line source/reading split (v0.3.0)
|
|
28
|
+
|
|
29
|
+
Caret line shows raw markers (with the blinking caret); every other line is reading form — hidden `##`/`>`/`**`, bullet dots, checkbox tasks, ordered numbers kept.
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
25
33
|
### Live markdown rendering
|
|
26
34
|
|
|
27
35
|

|
|
@@ -36,9 +44,19 @@ It is a **pure browser-side plugin**: zero runtime dependencies, no service inje
|
|
|
36
44
|
|
|
37
45
|
## Features
|
|
38
46
|
|
|
47
|
+
### Focus-line source/reading split (v0.3.0)
|
|
48
|
+
|
|
49
|
+
Obsidian-style live preview: **the line your caret/selection is on shows raw Markdown markers** (editable), **every other line renders in reading form** — inline markers (`**`, `` ` ``, `~~`, `[]()`) and `##` / `>` prefixes are hidden, unordered `-` becomes a bullet dot, task `[ ]` / `[x]` become real checkboxes (checked = green with a tick), ordered lists keep their numbers. Table rows and code fences always stay in source form (they are editing structure). When the composer is not focused, all lines are in reading form — a clean preview.
|
|
50
|
+
|
|
51
|
+
Hiding is paint-only (`color:transparent` on the absolutely-positioned render segments; symbols drawn as pseudo-elements on those segments) — character slots are preserved, so caret alignment is unaffected.
|
|
52
|
+
|
|
53
|
+
### Theme-following colors (v0.3.0)
|
|
54
|
+
|
|
55
|
+
No hardcoded palette any more: accents follow `--dsw-alias-link`, inline-code background follows `--dsw-alias-markdown-inline-code` (**typing and sent-message colors finally match**), code-block background follows `--dsw-alias-markdown-code-block`, syntax tokens follow the official `--shiki-token-*` theme, markers follow `--dsw-alias-label-dimmed`, task-done follows the success token, toolbar/toast follow surface tokens. Change skin or theme and the composer follows automatically; on hosts without these variables (DSH 0.1.x) it falls back to the built-in light/dark palette.
|
|
56
|
+
|
|
39
57
|
### Live Markdown rendering
|
|
40
58
|
|
|
41
|
-
- Inline styles render as you type: `**bold**`, `*italic*`, `` `code` `` (
|
|
59
|
+
- Inline styles render as you type: `**bold**`, `*italic*`, `` `code` `` (theme accent capsule), `~~strikethrough~~`, `[links](url)` (whitelisted protocols), `` capsules.
|
|
42
60
|
- **Character-perfect caret alignment.** Marker characters (`**`, `` ` ``, `~~`, `[]()`) are dimmed but keep their exact width, and bold/headings use paint-only faux-bold — so the rendered line stays character-for-character aligned with the invisible editor text. The caret lands precisely everywhere, including inside formatted spans, with zero drift while typing.
|
|
43
61
|
- Task list items: `- [ ]` / `- [x]` render as checkbox capsules; completed items get struck through.
|
|
44
62
|
- The draft always remains plain Markdown source. Rendering is purely visual — the message you send is the source text you typed.
|
|
@@ -49,7 +67,7 @@ It is a **pure browser-side plugin**: zero runtime dependencies, no service inje
|
|
|
49
67
|
- **Shift+Enter on an open fence** auto-completes a closed block (blank line + closing fence + trailing line) and puts the caret inside, ready to code.
|
|
50
68
|
- ↓ on the last content line of a closed block jumps below the block.
|
|
51
69
|
- Zero-dependency regex syntax highlighting: js/ts/py/sh/json/yml/css/html, auto-detected from content when unlabeled — Chinese prose is never misdetected as code.
|
|
52
|
-
- Language label on the fence line;
|
|
70
|
+
- Language label on the fence line; token colors follow the official shiki theme (GitHub palette as fallback); fence characters dimmed.
|
|
53
71
|
- Monospace: while a closed code block is present, the whole composer (editor + overlay) switches to a monospace stack synced with the official code font. CJK characters deliberately stay on the UI font so line wrapping never diverges between the two layers.
|
|
54
72
|
|
|
55
73
|
### Lists, quotes, tables
|
package/README.zh-CN.md
CHANGED
|
@@ -2,26 +2,34 @@
|
|
|
2
2
|
|
|
3
3
|
<h1 align="center">dsh-composer-live</h1>
|
|
4
4
|
|
|
5
|
-
<p align="center"><b>打 Markdown,边打边渲染</b
|
|
5
|
+
<p align="center"><b>打 Markdown,边打边渲染</b>——焦点行源码/阅读分离 + 颜色全面跟随主题。</p>
|
|
6
6
|
|
|
7
7
|
<p align="center">[English](./README.md) · [简体中文](./README.zh-CN.md)</p>
|
|
8
8
|
|
|
9
9
|
<p align="center">
|
|
10
10
|
<img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT">
|
|
11
11
|
<img src="https://img.shields.io/badge/DSH-%3E%3D%200.1.5--rc.2-4c6ef5" alt="DSH >= 0.1.5-rc.2">
|
|
12
|
-
<img src="https://img.shields.io/badge/tests-
|
|
12
|
+
<img src="https://img.shields.io/badge/tests-246%20unit%20%C2%B7%20136%20E2E-2ea44f" alt="tests">
|
|
13
13
|
</p>
|
|
14
14
|
|
|
15
15
|

|
|
16
16
|
|
|
17
17
|
dsh-composer-live 把 DSH Web 的输入框变成 Open WebUI 风格的实时编辑器:你打 Markdown,它边打边渲染——加粗、斜体、带语法高亮的代码块、列表、引用、表格——而草稿本身始终是纯 Markdown 源文本,发送出去的就是你输入的原文。
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
**v0.3.0** 起还带来 Obsidian「实时预览」式的体验:**光标所在行显示源码标记**(可编辑),**其余行自动呈现阅读形态**——标记隐身、`-` 列表变圆点、`- [ ]` / `- [x]` 任务变真复选框;同时所有颜色**跟随你的主题/皮肤**(官方 CSS 变量驱动)——行内代码打字时和发送后颜色完全一致。
|
|
20
|
+
|
|
21
|
+
它是一个**纯浏览器端插件**:零运行时依赖、不注入任何官方服务、不改官方源码。它在官方 0.1.5+ Lexical 输入框之上叠加增强,不重复 DSH 已原生提供的功能。
|
|
20
22
|
|
|
21
23
|
> 找 DSH **0.1.x**(textarea 架构输入框)的版本?那是 [`dsh-composer-md`](#faq)——本插件的前身,已停止维护。
|
|
22
24
|
|
|
23
25
|
## 截图
|
|
24
26
|
|
|
27
|
+
### 焦点行:源码/阅读分离(v0.3.0)
|
|
28
|
+
|
|
29
|
+
光标行显示源码标记(带闪烁光标);其余行是阅读形态——`##`/`>`/`**` 隐身、圆点列表、复选框任务、有序数字保留。
|
|
30
|
+
|
|
31
|
+

|
|
32
|
+
|
|
25
33
|
### Markdown 实时渲染
|
|
26
34
|
|
|
27
35
|

|
|
@@ -36,9 +44,19 @@ dsh-composer-live 把 DSH Web 的输入框变成 Open WebUI 风格的实时编
|
|
|
36
44
|
|
|
37
45
|
## 功能
|
|
38
46
|
|
|
47
|
+
### 焦点行:源码/阅读视图分离(v0.3.0)
|
|
48
|
+
|
|
49
|
+
Obsidian「实时预览」式:**光标/选区所在行显示源码标记**(可编辑),**其余行呈现阅读形态**——行内标记(`**`、`` ` ``、`~~`、`[]()`)与 `##`、`>` 前缀隐身;无序列表 `-` 符号化为圆点;任务 `[ ]` / `[x]` 变成真复选框(勾选态绿底白勾);有序列表保留数字;表格行与代码围栏行恒为源码(属编辑结构)。输入框无焦点时全部行阅读形态——一片干净的预览。
|
|
50
|
+
|
|
51
|
+
隐身是纯画法(绝对定位渲染段 `color:transparent`,图形画在段伪元素上)——字符占位天然保留,光标对齐零影响。
|
|
52
|
+
|
|
53
|
+
### 颜色全面跟随主题(v0.3.0)
|
|
54
|
+
|
|
55
|
+
不再写死配色:强调色跟随 `--dsw-alias-link`、行内代码底跟随 `--dsw-alias-markdown-inline-code`(**打字与发送后颜色终于一致**)、代码块底跟随 `--dsw-alias-markdown-code-block`、语法高亮 token 跟随官方 `--shiki-token-*` 主题、标记字符跟随 `--dsw-alias-label-dimmed`、任务完成跟随 success token、工具栏/toast 跟随表面层 token。换皮肤/换主题自动跟随;无这套变量的宿主(DSH 0.1.x)自动回退内置亮暗配色。
|
|
56
|
+
|
|
39
57
|
### Markdown 实时渲染
|
|
40
58
|
|
|
41
|
-
- 行内样式边打边生效:`**加粗**`、`*斜体*`、`` `行内代码`
|
|
59
|
+
- 行内样式边打边生效:`**加粗**`、`*斜体*`、`` `行内代码` ``(主题强调色胶囊)、`~~删除线~~`、`[链接](url)`(白名单协议)、`` 胶囊。
|
|
42
60
|
- **光标字符级精确对齐**。标记字符(`**`、`` ` ``、`~~`、`[]()`)淡化显示但保留精确宽度,粗体/标题用 paint-only 伪粗——渲染行与编辑器透明文字逐字符完全对齐,光标落在行内任何位置(包括格式区间内部)都精确贴齐,打字零漂移。
|
|
43
61
|
- 任务列表项:`- [ ]` / `- [x]` 渲染成勾选胶囊;已完成项内容划线。
|
|
44
62
|
- 草稿始终是纯 Markdown 源文本。渲染纯视觉——发送的消息就是你输入的源文本。
|
|
@@ -49,7 +67,7 @@ dsh-composer-live 把 DSH Web 的输入框变成 Open WebUI 风格的实时编
|
|
|
49
67
|
- **未闭合围栏行上按 Shift+Enter** 自动补全封闭块(块内空行 + 闭合围栏 + 块后空行),光标落回块内,直接开写。
|
|
50
68
|
- 已闭合块最后一个内容行按 ↓ 直接跳出,落到块后的普通行。
|
|
51
69
|
- 零依赖正则语法高亮:js/ts/py/sh/json/yml/css/html,未标语言按内容自动推断——中文长文不会误判成代码。
|
|
52
|
-
- 围栏行右上角语言标签;
|
|
70
|
+
- 围栏行右上角语言标签;token 色跟随官方 shiki 主题(回退 GitHub 两套);围栏字符淡化。
|
|
53
71
|
- 等宽:草稿含已闭合代码块期间,整个输入框(编辑器 + 渲染层)同步切换等宽字体栈(与官方代码字体同源)。中文字符刻意保持界面字体,两侧换行点永不发散。
|
|
54
72
|
|
|
55
73
|
### 列表、引用、表格
|
package/client.js
CHANGED
|
@@ -268,14 +268,17 @@ window.__ModuleLoader__.load({
|
|
|
268
268
|
// 任务列表勾选样式(v0.2.10):`- [ ] 任务` / `- [x] 任务`——标记三字符
|
|
269
269
|
// 整体进胶囊背景(字符流不变,光标对齐不受影响);已勾时行内容加划线
|
|
270
270
|
// (<s> → tokenizeViaDom 映射 dsh-cl-dl,line-through 是 paint-only)。
|
|
271
|
+
// v0.3.0:有序标记(1. / 2))追加 dsh-cl-lnum——阅读形态下无序符号化
|
|
272
|
+
// 成圆点、有序保留数字(数字本身是内容)。
|
|
273
|
+
const lmCls = "dsh-cl-lmark" + (/^\d/.test(kind.mark) ? " dsh-cl-lnum" : "");
|
|
271
274
|
const tm = kind.text.match(/^(\[(?: |x|X)\])(\s+)([\s\S]*)$/);
|
|
272
275
|
if (tm) {
|
|
273
276
|
const done = tm[1].charAt(1) !== " ";
|
|
274
|
-
return escapeHtml(kind.indent || "") + '<span class="
|
|
277
|
+
return escapeHtml(kind.indent || "") + '<span class="' + lmCls + '">' + escapeHtml(kind.mark) + '</span>' + escapeHtml(kind.space)
|
|
275
278
|
+ '<span class="dsh-cl-task' + (done ? " dsh-cl-task-done" : "") + '">' + escapeHtml(tm[1]) + '</span>' + escapeHtml(tm[2])
|
|
276
279
|
+ (done ? "<s>" + inlineParse(tm[3], noMono) + "</s>" : inlineParse(tm[3], noMono));
|
|
277
280
|
}
|
|
278
|
-
return escapeHtml(kind.indent || "") + '<span class="
|
|
281
|
+
return escapeHtml(kind.indent || "") + '<span class="' + lmCls + '">' + escapeHtml(kind.mark) + '</span>' + escapeHtml(kind.space) + inlineParse(kind.text, noMono);
|
|
279
282
|
}
|
|
280
283
|
if (kind.type === "table") return '<span class="dsh-cl-tmark">' + escapeHtml(kind.raw) + "</span>";
|
|
281
284
|
return inlineParse(line, noMono);
|
|
@@ -361,6 +364,53 @@ window.__ModuleLoader__.load({
|
|
|
361
364
|
return computeBlockStates(lines).map((st) => st.inCode);
|
|
362
365
|
}
|
|
363
366
|
|
|
367
|
+
// ---------- 焦点行(v0.3.0):光标/选区行=源码形态,其余行=阅读形态 ----------
|
|
368
|
+
// Obsidian「实时预览」式:编辑哪行哪行显示源码标记,其余行呈现阅读效果
|
|
369
|
+
//(星号隐身、列表圆点化、任务复选框化)。「隐身」只是渲染段 color:transparent,
|
|
370
|
+
// 字符占位天然保留——光标对齐零排版风险。
|
|
371
|
+
|
|
372
|
+
/** 投影 offset → 行号(行按 \n 切分;超尾回落最后一行)。 */
|
|
373
|
+
function lineIndexOfOffset(lines, off) {
|
|
374
|
+
let acc = 0;
|
|
375
|
+
for (let i = 0; i < lines.length; i++) {
|
|
376
|
+
const len = lines[i].length + 1;
|
|
377
|
+
if (off < acc + len) return i;
|
|
378
|
+
acc += len;
|
|
379
|
+
}
|
|
380
|
+
return lines.length - 1;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
/**
|
|
384
|
+
* 源码形态行集合:选区(anchor→focus 区间)覆盖的行。null = 无焦点 →
|
|
385
|
+
* 全部行阅读形态(输入框只是被看着,纯预览)。表格行/代码围栏行的恒源码
|
|
386
|
+
* 判定不在这里(与焦点无关,渲染行循环处判)。
|
|
387
|
+
*/
|
|
388
|
+
function computeEditLines(lines, caretA, caretF, focused) {
|
|
389
|
+
if (!focused || (caretA == null && caretF == null)) return null;
|
|
390
|
+
const a = caretA == null ? caretF : caretA;
|
|
391
|
+
const b = caretF == null ? caretA : caretF;
|
|
392
|
+
const lo = lineIndexOfOffset(lines, Math.min(a, b));
|
|
393
|
+
const hi = lineIndexOfOffset(lines, Math.max(a, b));
|
|
394
|
+
const set = new Set();
|
|
395
|
+
for (let i = lo; i <= hi; i++) set.add(i);
|
|
396
|
+
return set;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* 阅读形态的字符段样式变换:标记隐身 / 符号化(paint-only)。
|
|
401
|
+
* - mk / qmark / hmark → 隐身(阅读视图不显示 ** ` > ##)
|
|
402
|
+
* - 无序 lmark → 圆点图形;有序(含 dsh-cl-lnum)保留数字
|
|
403
|
+
* - task → 复选框图形(done 勾选)
|
|
404
|
+
* - tmark(表格)不经此函数——表格行恒源码
|
|
405
|
+
*/
|
|
406
|
+
function toReadingForm(cls) {
|
|
407
|
+
if (!cls || cls.indexOf("dsh-cl-") !== 0) return cls;
|
|
408
|
+
if (cls === "dsh-cl-mk" || cls === "dsh-cl-qmark" || cls === "dsh-cl-hmark") return cls + " dsh-cl-rd";
|
|
409
|
+
if (cls === "dsh-cl-lmark") return cls + " dsh-cl-rd dsh-cl-rd-bullet";
|
|
410
|
+
if (cls.indexOf("dsh-cl-task") === 0) return cls + " dsh-cl-rd dsh-cl-rd-check" + (cls.indexOf("dsh-cl-task-done") >= 0 ? " dsh-cl-rd-on" : "");
|
|
411
|
+
return cls;
|
|
412
|
+
}
|
|
413
|
+
|
|
364
414
|
// ---------- 字符锚定渲染(v0.2 根治架构) ----------
|
|
365
415
|
// 渲染层不再自己排版:逐字符测量编辑器的真实坐标(Range rect),渲染
|
|
366
416
|
// 字符绝对定位画在同一坐标上。字体/字重/断行/行结构/等宽打点时序/任何
|
|
@@ -486,7 +536,7 @@ window.__ModuleLoader__.load({
|
|
|
486
536
|
}
|
|
487
537
|
|
|
488
538
|
/** 字符锚定渲染主入口:清空 overlay,按测量坐标输出「整块背景 + 定位字符段」。 */
|
|
489
|
-
function renderCharOverlay(ov, input, anchors, lines, states, refs, cache, layoutGen) {
|
|
539
|
+
function renderCharOverlay(ov, input, anchors, lines, states, refs, cache, layoutGen, editSet) {
|
|
490
540
|
const ovRect = ov.getBoundingClientRect();
|
|
491
541
|
const ox = ovRect.left, oy = ovRect.top;
|
|
492
542
|
const segLineHeight = getComputedStyle(ov).lineHeight; // 段定位的 half-leading 修正用
|
|
@@ -559,6 +609,12 @@ window.__ModuleLoader__.load({
|
|
|
559
609
|
const tl = tk.text.length;
|
|
560
610
|
for (let k = 0; k < tl && ci < chars.length; k++, ci++) charCls[ci] = tk.cls;
|
|
561
611
|
}
|
|
612
|
+
// 焦点行(v0.3.0):非编辑行 → 阅读形态(标记隐身/符号化)。表格行与
|
|
613
|
+
// 代码围栏行恒源码(竖线/围栏是编辑结构,不随光标离开而阅读化)。
|
|
614
|
+
const alwaysSrc = (st.kind && st.kind.type === "table") || st.fenceOpen || st.fenceClose;
|
|
615
|
+
if (!alwaysSrc && !(editSet && editSet.has(li))) {
|
|
616
|
+
for (let k = 0; k < charCls.length; k++) charCls[k] = toReadingForm(charCls[k]);
|
|
617
|
+
}
|
|
562
618
|
// 官方文本引用装饰(/ 命令、技能名)→ 引用色。编辑器文字透明,官方给
|
|
563
619
|
// 装饰 span 的 color 看不见;按投影区间在渲染层补上同一主题色。
|
|
564
620
|
if (refs.length) {
|
|
@@ -910,18 +966,54 @@ window.__ModuleLoader__.load({
|
|
|
910
966
|
const lum = 0.299 * (+m[1]) + 0.587 * (+m[2]) + 0.114 * (+m[3]);
|
|
911
967
|
return lum < 128;
|
|
912
968
|
}
|
|
969
|
+
|
|
970
|
+
// v0.3.1 代码块派生用:沿祖先链找第一个「不透明」背景色(卡自身多不透明;
|
|
971
|
+
// 半透明卡(毛玻璃类皮肤)会跳到更外层的不透明底——极端皮肤下派生基准可能
|
|
972
|
+
// 与合成后的卡面色有出入,属可接受近似;主流皮肤卡为不透明,精确命中)。
|
|
973
|
+
function effectiveCardBg(el) {
|
|
974
|
+
let n = el;
|
|
975
|
+
while (n && n.nodeType === 1 && n !== document.documentElement) {
|
|
976
|
+
const c = getComputedStyle(n).backgroundColor;
|
|
977
|
+
const m = String(c).match(/^rgba?\(([^)]+)\)$/);
|
|
978
|
+
if (m) {
|
|
979
|
+
const parts = m[1].split(",").map((s) => parseFloat(s));
|
|
980
|
+
if (!(parts.length > 3 && parts[3] === 0)) return c;
|
|
981
|
+
} else if (c && c !== "transparent") {
|
|
982
|
+
return c;
|
|
983
|
+
}
|
|
984
|
+
n = n.parentElement;
|
|
985
|
+
}
|
|
986
|
+
return "rgb(255, 255, 255)";
|
|
987
|
+
}
|
|
913
988
|
//#endregion
|
|
914
989
|
|
|
915
990
|
//#region dsh-composer-live: injected styles
|
|
916
991
|
function styleText() {
|
|
917
992
|
return (
|
|
918
993
|
"#" + STYLE_ID + "{}" +
|
|
994
|
+
// 主题锚点(v0.3.0 跟随):所有颜色优先官方/皮肤变量(--dsw-alias-* /
|
|
995
|
+
// --shiki-token-*,与消息区渲染同源),缺失时回退内置两态(0.1.x 环境无
|
|
996
|
+
// 这套变量 = 维持既有观感)。定义在 body 级:工具栏/浮动条/toast 在滚动
|
|
997
|
+
// 容器外、渲染段在容器内,全部沿 DOM 继承拿到。dsh-cl-light 由 render()
|
|
998
|
+
// 按输入框底色切换;官方变量自身随主题/皮肤变 → 换肤零改码自动跟随。
|
|
999
|
+
"body{--dsh-cl-acc:var(--dsw-alias-link,#3b82f6);--dsh-cl-acc-soft:var(--dsw-alias-markdown-inline-code,rgba(59,130,246,.13));--dsh-cl-mkc:var(--dsw-alias-label-dimmed,rgba(127,127,127,.6));--dsh-cl-ok:var(--dsw-alias-state-success-primary,#16a34a);--dsh-cl-code-bg:var(--dsw-alias-markdown-code-block,rgba(13,17,23,.92));--dsh-cl-lang-bg:var(--dsw-alias-markdown-code-block-banner,rgba(127,127,127,.3));--dsh-cl-lang-fg:var(--dsw-alias-label-dimmed,rgba(249,250,251,.9));--dsh-cl-tok-kw:var(--shiki-token-keyword,#ff7b72);--dsh-cl-tok-str:var(--shiki-token-string,#a5d6ff);--dsh-cl-tok-com:var(--shiki-token-comment,#8b949e);--dsh-cl-tok-num:var(--shiki-token-constant,#79c0ff);--dsh-cl-tok-fn:var(--shiki-token-function,#d2a8ff);--dsh-cl-tok-lit:var(--shiki-token-constant,#79c0ff);--dsh-cl-tb-bg:var(--dsw-alias-bg-layer-3,rgba(28,30,36,.95));--dsh-cl-tb-fg:var(--dsw-alias-label-secondary,rgba(233,236,240,.9));--dsh-cl-tb-bd:rgba(255,255,255,.12);--dsh-cl-btn-hover:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.18));--dsh-cl-btn-active:rgba(59,130,246,.16);--dsh-cl-sel:rgba(103,160,254,.35);--dsh-cl-toast-bg:var(--dsw-alias-toast-bg,var(--dsw-alias-bg-layer-3,rgba(28,30,36,.93)));--dsh-cl-toast-fg:var(--dsw-alias-label-primary,rgba(240,242,246,.95));}" +
|
|
1000
|
+
"body.dsh-cl-light{--dsh-cl-acc:var(--dsw-alias-link,#3b82f6);--dsh-cl-acc-soft:var(--dsw-alias-markdown-inline-code,rgba(59,130,246,.13));--dsh-cl-mkc:var(--dsw-alias-label-dimmed,rgba(127,127,127,.5));--dsh-cl-ok:var(--dsw-alias-state-success-primary,#16a34a);--dsh-cl-code-bg:var(--dsw-alias-markdown-code-block,#f6f8fa);--dsh-cl-lang-bg:var(--dsw-alias-markdown-code-block-banner,rgba(127,127,127,.3));--dsh-cl-lang-fg:var(--dsw-alias-label-dimmed,rgba(31,35,40,.85));--dsh-cl-tok-kw:var(--shiki-token-keyword,#cf222e);--dsh-cl-tok-str:var(--shiki-token-string,#0a3069);--dsh-cl-tok-com:var(--shiki-token-comment,#6e7781);--dsh-cl-tok-num:var(--shiki-token-constant,#0550ae);--dsh-cl-tok-fn:var(--shiki-token-function,#8250df);--dsh-cl-tok-lit:var(--shiki-token-constant,#0550ae);--dsh-cl-tb-bg:var(--dsw-alias-bg-layer-1,rgba(250,251,253,.97));--dsh-cl-tb-fg:var(--dsw-alias-label-secondary,rgba(28,32,40,.85));--dsh-cl-tb-bd:rgba(61,55,48,.125);--dsh-cl-btn-hover:var(--dsw-alias-interactive-bg-hover,rgba(127,127,127,.18));--dsh-cl-btn-active:rgba(59,130,246,.16);--dsh-cl-sel:rgba(59,130,246,.28);--dsh-cl-toast-bg:var(--dsw-alias-toast-bg,var(--dsw-alias-bg-layer-1,rgba(250,251,253,.96)));--dsh-cl-toast-fg:var(--dsw-alias-label-primary,rgba(28,32,40,.92));}" +
|
|
1001
|
+
// v0.3.1 派生层(用户拍板方案 A):代码块/语言标签/胶囊底不再取消息区
|
|
1002
|
+
// 变量——onepage 类皮肤把 --dsw-alias-markdown-code-block 定义成「页面
|
|
1003
|
+
// 底色+透明」,在输入卡上叠加后与卡同色(深色实测 #211e1d 完全归零)。
|
|
1004
|
+
// 改从「输入卡实际底色」派生(render() 写 --dsh-cl-card-bg),跟随的
|
|
1005
|
+
// 正确语义=跟随所在容器;换肤/换主题自动保证层次。@supports 守卫:
|
|
1006
|
+
// 不支持 color-mix 的老内核回落基础层的 v0.3.0 观感。三个暖色源
|
|
1007
|
+
// (#b9a06e/#8c6923/#a07837) 为逐值还原预览页拍板色的最小组合。
|
|
1008
|
+
"@supports (background:color-mix(in srgb,red,blue)){" +
|
|
1009
|
+
"body{--dsh-cl-code-bg:color-mix(in srgb,var(--dsh-cl-card-bg,#211e1d) 73%,#000);--dsh-cl-lang-bg:color-mix(in srgb,var(--dsh-cl-card-bg,#211e1d) 60%,#000);--dsh-cl-lang-fg:#8f877c;--dsh-cl-acc-soft:color-mix(in srgb,var(--dsh-cl-card-bg,#211e1d) 82%,#8a7f70);}" +
|
|
1010
|
+
"body.dsh-cl-light{--dsh-cl-code-bg:color-mix(in srgb,var(--dsh-cl-card-bg,#ffffff) 80%,#b9a06e);--dsh-cl-lang-bg:color-mix(in srgb,var(--dsh-cl-card-bg,#ffffff) 80%,#8c6923);--dsh-cl-lang-fg:#8a8175;--dsh-cl-acc-soft:color-mix(in srgb,var(--dsh-cl-card-bg,#ffffff) 80%,#a07837);}" +
|
|
1011
|
+
"}" +
|
|
919
1012
|
// 常驻工具栏(v0.2.14:输入卡外、卡正上方的独立条):不再占输入框内部
|
|
920
1013
|
// 高度——编辑器 padding 让位(v0.2.8 的 BAR_RESERVE)随 sticky 体系整体
|
|
921
1014
|
// 退役;宽度由搬正逻辑从 card 同步(父容器内容宽 ≠ card 宽,width:100%
|
|
922
1015
|
// 会比卡突出)。背景不透明(沿用 v0.2.8 教训:透底会与后方内容混色)。
|
|
923
|
-
"." + TOOLBAR + "{display:flex;align-items:center;box-sizing:border-box;height:" + TB_HEIGHT + ";padding:0 12px;gap:2px;margin:0 0 6px;border-radius:12px;background:rgba(28,30,36,.95);box-shadow:rgba(0,0,0,.25) 0px 1px 8px 0px;}" +
|
|
924
|
-
"body.dsh-cl-light ." + TOOLBAR + "{background:rgba(250,251,253,.97);box-shadow:rgba(61,55,48,.125) 0px 0px 0px 0.5px,rgba(0,0,0,.04) 0px 1px 8px 0px;}" +
|
|
1016
|
+
"." + TOOLBAR + "{display:flex;align-items:center;box-sizing:border-box;height:" + TB_HEIGHT + ";padding:0 12px;gap:2px;margin:0 0 6px;border-radius:12px;background:var(--dsh-cl-tb-bg,rgba(28,30,36,.95));border:1px solid var(--dsh-cl-tb-bd,rgba(255,255,255,.12));box-shadow:rgba(0,0,0,.25) 0px 1px 8px 0px;}" +
|
|
925
1017
|
"." + TOOLBAR + " [data-cl=\"expand\"]{margin-left:auto;}" +
|
|
926
1018
|
// 透明化:只隐藏文字「绘制」(-webkit-text-fill-color),color 属性保留
|
|
927
1019
|
// ——caret 颜色、官方 hint ::after、chip 恢复全靠 color 不动。
|
|
@@ -929,15 +1021,14 @@ window.__ModuleLoader__.load({
|
|
|
929
1021
|
// 内容的一部分,随层自然盖在 overlay 上(caret 可见),而文字透明不遮挡
|
|
930
1022
|
// overlay 的渲染文字。不能用「overlay 压 z-index:-1」的思路:负 z 会掉到
|
|
931
1023
|
// 输入框背景之下,渲染文字整体不可见。
|
|
932
|
-
INPUT_SEL + "." + HOST + "{-webkit-text-fill-color:transparent;caret-color
|
|
1024
|
+
INPUT_SEL + "." + HOST + "{-webkit-text-fill-color:transparent;caret-color:var(--dsh-cl-acc,#67a0fe);position:relative;z-index:1;}" +
|
|
933
1025
|
// 选中态:Chromium 会用 ::selection 的默认反色把透明文字重绘出来(白字),
|
|
934
1026
|
// 与 overlay 渲染文字形成双影——选中文字保持隐形(color:transparent),
|
|
935
1027
|
// 但必须同时显式给 background:::selection 规则一旦匹配,未声明的属性
|
|
936
1028
|
// 取初始值(transparent),会把浏览器默认高亮一并洗掉(选中无色)。
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
INPUT_SEL + "." + HOST + "::selection{color:transparent;background:var(--dsh-cl-sel
|
|
940
|
-
INPUT_SEL + "." + HOST + " ::selection{color:transparent;background:var(--dsh-cl-sel-bg);}" +
|
|
1029
|
+
// v0.3.0:选区色跟随主题(--dsh-cl-sel 定义在 body 级锚点)。
|
|
1030
|
+
INPUT_SEL + "." + HOST + "::selection{color:transparent;background:var(--dsh-cl-sel,rgba(103,160,254,.35));}" +
|
|
1031
|
+
INPUT_SEL + "." + HOST + " ::selection{color:transparent;background:var(--dsh-cl-sel,rgba(103,160,254,.35));}" +
|
|
941
1032
|
// chip(@ 引用胶囊宿主)与热词装饰恢复显示;hint 的 ::after 恢复
|
|
942
1033
|
INPUT_SEL + "." + HOST + " " + CHIP_HOST_SEL + "{-webkit-text-fill-color:currentColor;}" +
|
|
943
1034
|
INPUT_SEL + "." + HOST + " p::after{-webkit-text-fill-color:currentColor;}" +
|
|
@@ -945,14 +1036,14 @@ window.__ModuleLoader__.load({
|
|
|
945
1036
|
INPUT_SEL + "." + HOST + " p." + KEEP + "{-webkit-text-fill-color:currentColor;}" +
|
|
946
1037
|
// 代码段(编辑器)等宽:整框切换,与 overlay 渲染段同字体变量
|
|
947
1038
|
INPUT_SEL + "." + MONO_ALL + "{font-family:var(--dsh-cl-code-font,var(--ds-font-family-code,monospace)) !important;}" +
|
|
948
|
-
//
|
|
1039
|
+
// 按钮(v0.3.0:hover/焦点环/激活色跟随主题锚点)
|
|
949
1040
|
".dsh-cl-btn{display:inline-flex;align-items:center;justify-content:center;width:27px;height:27px;border-radius:7px;border:1px solid transparent;background:transparent;color:inherit;cursor:pointer;padding:0;line-height:0;transition:background .15s ease,transform .1s ease;}" +
|
|
950
|
-
".dsh-cl-btn:hover{background:rgba(127,127,127,.18);}" +
|
|
1041
|
+
".dsh-cl-btn:hover{background:var(--dsh-cl-btn-hover,rgba(127,127,127,.18));}" +
|
|
951
1042
|
".dsh-cl-btn:active{transform:scale(.92);background:rgba(127,127,127,.28);}" +
|
|
952
|
-
".dsh-cl-btn:focus-visible{outline:2px solid
|
|
1043
|
+
".dsh-cl-btn:focus-visible{outline:2px solid var(--dsh-cl-acc,#3b82f6);outline-offset:1px;}" +
|
|
953
1044
|
".dsh-cl-btn svg{width:15px;height:15px;opacity:.85;}" +
|
|
954
1045
|
".dsh-cl-btn:hover svg{opacity:1;}" +
|
|
955
|
-
".dsh-cl-btn.dsh-cl-active{background:rgba(59,130,246,.16);color
|
|
1046
|
+
".dsh-cl-btn.dsh-cl-active{background:var(--dsh-cl-btn-active,rgba(59,130,246,.16));color:var(--dsh-cl-acc,#3b82f6);}" +
|
|
956
1047
|
// 展开态:滚动容器定高 70vh(只有 max-height 时高度仍由内容决定——
|
|
957
1048
|
// 内容少的瞬间点展开纹丝不动,用户感知「按钮失效」)
|
|
958
1049
|
"." + EXPANDED + "{max-height:70vh !important;height:70vh !important;}" +
|
|
@@ -967,29 +1058,29 @@ window.__ModuleLoader__.load({
|
|
|
967
1058
|
"." + LIVE + " strong{font-weight:inherit;-webkit-text-stroke:.45px currentColor;}" +
|
|
968
1059
|
"." + LIVE + " em{font-style:italic;}" +
|
|
969
1060
|
"." + LIVE + " del{text-decoration:line-through;opacity:.75;}" +
|
|
970
|
-
"." + LIVE + " a{color
|
|
971
|
-
"." + LIVE + " code{font-family:inherit;color
|
|
1061
|
+
"." + LIVE + " a{color:var(--dsh-cl-acc,#3b82f6);text-decoration:none;}" +
|
|
1062
|
+
"." + LIVE + " code{font-family:inherit;color:var(--dsh-cl-acc,#3b82f6);background:var(--dsh-cl-acc-soft,rgba(59,130,246,.13));border-radius:5px;padding:1px 5px;margin:0 -5px;}" +
|
|
972
1063
|
// 行内格式的标记字符(**、`、~~、[]()):淡化但保留占位(字符级对齐)
|
|
973
|
-
".dsh-cl-mk{color:rgba(127,127,127,.5);}" +
|
|
1064
|
+
".dsh-cl-mk{color:var(--dsh-cl-mkc,rgba(127,127,127,.5));}" +
|
|
974
1065
|
|
|
975
|
-
".dsh-cl-hmark{color
|
|
1066
|
+
".dsh-cl-hmark{color:var(--dsh-cl-acc,#3b82f6);font-weight:inherit;-webkit-text-stroke:.45px currentColor;}" +
|
|
976
1067
|
".dsh-cl-heading{font-weight:inherit;-webkit-text-stroke:.45px currentColor;}" +
|
|
977
|
-
".dsh-cl-qmark{color
|
|
1068
|
+
".dsh-cl-qmark{color:var(--dsh-cl-acc,#3b82f6);}" +
|
|
978
1069
|
".dsh-cl-quote{position:relative;z-index:0;}" +
|
|
979
|
-
".dsh-cl-quote::before{content:\"\";position:absolute;inset:0 -12px;background:rgba(127,127,127,.10);border-left:3px solid
|
|
980
|
-
".dsh-cl-lmark{color
|
|
981
|
-
".dsh-cl-tmark{color
|
|
982
|
-
".dsh-cl-img{background:rgba(59,130,246,.13);color
|
|
983
|
-
// 代码段 overlay 行:等宽 +
|
|
984
|
-
|
|
985
|
-
|
|
1070
|
+
".dsh-cl-quote::before{content:\"\";position:absolute;inset:0 -12px;background:rgba(127,127,127,.10);border-left:3px solid var(--dsh-cl-acc,#3b82f6);z-index:-1;}" +
|
|
1071
|
+
".dsh-cl-lmark{color:var(--dsh-cl-acc,#3b82f6);}" +
|
|
1072
|
+
".dsh-cl-tmark{color:var(--dsh-cl-mkc,#8b949e);}" +
|
|
1073
|
+
".dsh-cl-img{background:var(--dsh-cl-acc-soft,rgba(59,130,246,.13));color:var(--dsh-cl-acc,#3b82f6);border-radius:5px;padding:1px 5px;margin:0 -5px;}" +
|
|
1074
|
+
// 代码段 overlay 行:等宽 + 伪元素外扩背景。v0.3.0 起 token/底色/语言
|
|
1075
|
+
// 标签变量定义上移 body 级主题锚点(官方 shiki/alias 变量优先——与消息
|
|
1076
|
+
// 区代码块同源,自动跟随主题与皮肤;缺失回退内置 GitHub 两态)。
|
|
986
1077
|
".dsh-cl-cline{position:relative;z-index:0;}" +
|
|
987
1078
|
".dsh-cl-cline{font-family:var(--dsh-cl-code-font,var(--ds-font-family-code,monospace));}" +
|
|
988
1079
|
".dsh-cl-cline::before{content:\"\";position:absolute;inset:0 -12px;background:var(--dsh-cl-code-bg);border-radius:0;z-index:-1;}" +
|
|
989
1080
|
".dsh-cl-cline.dsh-cl-fence-open::before{border-radius:10px 10px 0 0;inset:2px -14px 0;}" +
|
|
990
1081
|
".dsh-cl-cline.dsh-cl-fence-close::before{border-radius:0 0 10px 10px;inset:0 -14px 2px;}" +
|
|
991
1082
|
".dsh-cl-fch{visibility:hidden;}" +
|
|
992
|
-
".dsh-cl-lang{position:absolute;right:26px;font-size:10px;line-height:1;padding:3px 7px;border-radius:5px;background:rgba(127,127,127,.3);border:1px solid rgba(255,255,255,.12);letter-spacing:.07em;text-transform:uppercase;color:var(--dsh-cl-lang-fg);pointer-events:none;}" +
|
|
1083
|
+
".dsh-cl-lang{position:absolute;right:26px;font-size:10px;line-height:1;padding:3px 7px;border-radius:5px;background:var(--dsh-cl-lang-bg,rgba(127,127,127,.3));border:1px solid rgba(255,255,255,.12);letter-spacing:.07em;text-transform:uppercase;color:var(--dsh-cl-lang-fg);pointer-events:none;}" +
|
|
993
1084
|
// ===== 字符锚定渲染(v0.2):定位字符段 + 背景块 =====
|
|
994
1085
|
// 字符段:绝对定位画在编辑器字符 rect 上;字体继承 overlay(syncMetrics
|
|
995
1086
|
// 复制官方度量);样式类只改 paint(伪粗/染色/胶囊背景外扩),零 advance 变化。
|
|
@@ -1006,18 +1097,27 @@ window.__ModuleLoader__.load({
|
|
|
1006
1097
|
// cd/img 胶囊背景外扩:横向 padding+负 margin 互相抵消(advance 零变化);
|
|
1007
1098
|
// 垂直同理必须 margin:-1px 抵消 padding-top:1px——段是绝对定位块,
|
|
1008
1099
|
// 只补横向会让段内文字整体下移 1px(E2E INV-3 实测 dy 恒 +1.00)。
|
|
1009
|
-
".dsh-cl-c.dsh-cl-cd{color
|
|
1100
|
+
".dsh-cl-c.dsh-cl-cd{color:var(--dsh-cl-acc,#3b82f6);background:var(--dsh-cl-acc-soft,rgba(59,130,246,.13));border-radius:5px;padding:1px 5px;margin:-1px -5px;}" +
|
|
1010
1101
|
".dsh-cl-c.dsh-cl-dl{text-decoration:line-through;opacity:.75;}" +
|
|
1011
|
-
".dsh-cl-c.dsh-cl-lk{color
|
|
1012
|
-
".dsh-cl-c.dsh-cl-mk{color:rgba(127,127,127,.5);}" +
|
|
1013
|
-
".dsh-cl-c.dsh-cl-hmark{color
|
|
1014
|
-
".dsh-cl-c.dsh-cl-qmark{color
|
|
1015
|
-
".dsh-cl-c.dsh-cl-lmark{color
|
|
1102
|
+
".dsh-cl-c.dsh-cl-lk{color:var(--dsh-cl-acc,#3b82f6);}" +
|
|
1103
|
+
".dsh-cl-c.dsh-cl-mk{color:var(--dsh-cl-mkc,rgba(127,127,127,.5));}" +
|
|
1104
|
+
".dsh-cl-c.dsh-cl-hmark{color:var(--dsh-cl-acc,#3b82f6);}" +
|
|
1105
|
+
".dsh-cl-c.dsh-cl-qmark{color:var(--dsh-cl-acc,#3b82f6);}" +
|
|
1106
|
+
".dsh-cl-c.dsh-cl-lmark{color:var(--dsh-cl-acc,#3b82f6);}" +
|
|
1016
1107
|
// 任务列表勾选标记([ ]/[x] 三字符胶囊;done 绿底+行内容划线由 dsh-cl-dl)
|
|
1017
|
-
".dsh-cl-c.dsh-cl-task{color:rgba(127,127,127,.55);background:rgba(59,130,246,.12);border-radius:4px;padding:1px 3px;margin:-1px -3px;}" +
|
|
1018
|
-
".dsh-cl-c.dsh-cl-task-done{color
|
|
1019
|
-
".dsh-cl-c.dsh-cl-tmark{color
|
|
1020
|
-
".dsh-cl-c.dsh-cl-img{color
|
|
1108
|
+
".dsh-cl-c.dsh-cl-task{color:var(--dsh-cl-mkc,rgba(127,127,127,.55));background:var(--dsh-cl-acc-soft,rgba(59,130,246,.12));border-radius:4px;padding:1px 3px;margin:-1px -3px;}" +
|
|
1109
|
+
".dsh-cl-c.dsh-cl-task-done{color:var(--dsh-cl-ok,#16a34a);background:rgba(34,197,94,.18);}" +
|
|
1110
|
+
".dsh-cl-c.dsh-cl-tmark{color:var(--dsh-cl-mkc,#8b949e);}" +
|
|
1111
|
+
".dsh-cl-c.dsh-cl-img{color:var(--dsh-cl-acc,#3b82f6);background:var(--dsh-cl-acc-soft,rgba(59,130,246,.13));border-radius:5px;padding:1px 5px;margin:-1px -5px;}" +
|
|
1112
|
+
// ===== 焦点行(v0.3.0)阅读形态:标记隐身 + 符号化(全部 paint-only) =====
|
|
1113
|
+
// 隐身 = color:transparent(占位保留、光标对齐零风险);圆点/复选框画在
|
|
1114
|
+
// 字符段的伪元素上(段是 absolute 定位,伪元素相对段居中——宽度即原
|
|
1115
|
+
// 标记字符宽度,无任何布局影响)。表格行/围栏行不经此形态(恒源码)。
|
|
1116
|
+
".dsh-cl-c.dsh-cl-rd{color:transparent;}" +
|
|
1117
|
+
".dsh-cl-c.dsh-cl-rd-bullet::after{content:\"\";position:absolute;left:50%;top:52%;transform:translate(-50%,-50%);width:.36em;height:.36em;border-radius:50%;background:var(--dsh-cl-mkc,#999);}" +
|
|
1118
|
+
".dsh-cl-c.dsh-cl-rd-check::before{content:\"\";position:absolute;left:50%;top:52%;transform:translate(-50%,-50%);width:.85em;height:.85em;border-radius:.24em;box-sizing:border-box;border:1.5px solid var(--dsh-cl-mkc,#999);}" +
|
|
1119
|
+
".dsh-cl-c.dsh-cl-rd-on::before{background:var(--dsh-cl-ok,#16a34a);border-color:var(--dsh-cl-ok,#16a34a);}" +
|
|
1120
|
+
".dsh-cl-c.dsh-cl-rd-on::after{content:\"\";position:absolute;left:50%;top:50%;transform:translate(-46%,-60%) rotate(40deg);width:.24em;height:.46em;border:solid #fff;border-width:0 .14em .14em 0;}" +
|
|
1021
1121
|
".dsh-cl-c.dsh-cl-tok-kw{color:var(--dsh-cl-tok-kw);}" +
|
|
1022
1122
|
".dsh-cl-c.dsh-cl-tok-str{color:var(--dsh-cl-tok-str);}" +
|
|
1023
1123
|
".dsh-cl-c.dsh-cl-tok-com{color:var(--dsh-cl-tok-com);}" +
|
|
@@ -1035,14 +1135,13 @@ window.__ModuleLoader__.load({
|
|
|
1035
1135
|
".dsh-cl-tok-num{color:var(--dsh-cl-tok-num);}" +
|
|
1036
1136
|
".dsh-cl-tok-fn{color:var(--dsh-cl-tok-fn);}" +
|
|
1037
1137
|
".dsh-cl-tok-lit{color:var(--dsh-cl-tok-lit);}" +
|
|
1038
|
-
// 选区浮动格式条:body 级 fixed(避免被输入卡 overflow
|
|
1039
|
-
|
|
1138
|
+
// 选区浮动格式条:body 级 fixed(避免被输入卡 overflow 裁剪)。v0.3.0
|
|
1139
|
+
// 底色/边框跟随主题锚点(与工具栏同源)。
|
|
1140
|
+
"." + FLOAT + "{position:fixed;z-index:80;display:none;align-items:center;gap:2px;padding:3px;border-radius:9px;background:var(--dsh-cl-tb-bg,rgba(28,30,36,.95));border:1px solid var(--dsh-cl-tb-bd,rgba(255,255,255,.12));box-shadow:0 4px 14px rgba(0,0,0,.28);}" +
|
|
1040
1141
|
"." + FLOAT + ".dsh-cl-float-on{display:flex;}" +
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
"." + TOAST + "{position:absolute;top:-40px;left:50%;transform:translateX(-50%);z-index:70;background:rgba(28,30,36,.93);color:rgba(240,242,246,.95);font-size:12px;line-height:1;padding:8px 14px;border-radius:8px;pointer-events:none;white-space:nowrap;box-shadow:0 4px 14px rgba(0,0,0,.28);border:1px solid rgba(255,255,255,.09);opacity:0;transition:opacity .18s ease;}" +
|
|
1142
|
+
// 轻提示(v0.3.0:底/字色跟随——皮肤下 toast 是品牌色底,如 onepage 青瓷)
|
|
1143
|
+
"." + TOAST + "{position:absolute;top:-40px;left:50%;transform:translateX(-50%);z-index:70;background:var(--dsh-cl-toast-bg,rgba(28,30,36,.93));color:var(--dsh-cl-toast-fg,rgba(240,242,246,.95));font-size:12px;line-height:1;padding:8px 14px;border-radius:8px;pointer-events:none;white-space:nowrap;box-shadow:0 4px 14px rgba(0,0,0,.28);border:1px solid rgba(255,255,255,.09);opacity:0;transition:opacity .18s ease;}" +
|
|
1044
1144
|
"." + TOAST + ".dsh-cl-toast-on{opacity:1;}" +
|
|
1045
|
-
SCROLL_SEL + ".dsh-cl-light ." + TOAST + "{background:rgba(250,251,253,.96);color:rgba(28,32,40,.92);border-color:rgba(0,0,0,.08);}" +
|
|
1046
1145
|
""
|
|
1047
1146
|
);
|
|
1048
1147
|
}
|
|
@@ -1305,8 +1404,14 @@ window.__ModuleLoader__.load({
|
|
|
1305
1404
|
const src = anchorsText(anchors);
|
|
1306
1405
|
const lines = src.split("\n");
|
|
1307
1406
|
const caret = domOffsetOf(input, anchors, true);
|
|
1407
|
+
const caretF = domOffsetOf(input, anchors, false);
|
|
1308
1408
|
const cursorLine = caret == null ? -1 : src.slice(0, caret).split("\n").length - 1;
|
|
1309
1409
|
|
|
1410
|
+
// 焦点行(v0.3.0):选区覆盖行=源码形态,其余行=阅读形态;无焦点全阅读。
|
|
1411
|
+
// states 上移到签名前(computeEditLines 需要;O(行数) 遍历,短路路径无感)。
|
|
1412
|
+
const states = computeBlockStates(lines);
|
|
1413
|
+
const editSet = computeEditLines(lines, caret, caretF, document.activeElement === input);
|
|
1414
|
+
|
|
1310
1415
|
// 合成字体栈(拉丁=代码等宽,中文=界面栈)写入 card 变量
|
|
1311
1416
|
const sentinel = card.__dshClSentinel;
|
|
1312
1417
|
if (sentinel && sentinel.isConnected) {
|
|
@@ -1326,6 +1431,15 @@ window.__ModuleLoader__.load({
|
|
|
1326
1431
|
document.body.classList.toggle("dsh-cl-light", isLightColor(color0));
|
|
1327
1432
|
}
|
|
1328
1433
|
|
|
1434
|
+
// v0.3.1 卡底实测 → --dsh-cl-card-bg(代码块/语言标签/胶囊底 color-mix
|
|
1435
|
+
// 派生的基准)。卡底只随主题/换肤变,签名守卫避免每键重写 body style;
|
|
1436
|
+
// 写在 body 级:工具栏在卡外(v0.2.14),沿 DOM 继承全可达。
|
|
1437
|
+
const cardBg = effectiveCardBg(card);
|
|
1438
|
+
if (document.body.__dshClCardBg !== cardBg) {
|
|
1439
|
+
document.body.__dshClCardBg = cardBg;
|
|
1440
|
+
document.body.style.setProperty("--dsh-cl-card-bg", cardBg);
|
|
1441
|
+
}
|
|
1442
|
+
|
|
1329
1443
|
// ===== 渲染签名短路(v0.2.17 性能优化的核心) =====
|
|
1330
1444
|
// 视觉输出只依赖:内容(src) + 光标行(围栏高亮) + 几何(相对 overlay——渲染
|
|
1331
1445
|
// 输出本身用相对坐标,滚动时字符与 overlay 视口坐标同步变化、差值不变,用
|
|
@@ -1335,7 +1449,10 @@ window.__ModuleLoader__.load({
|
|
|
1335
1449
|
// 文档空闲实测 16 次/秒全量 × ~60ms = 98% 主线程占用、打字 6fps)。
|
|
1336
1450
|
const irx = input.getBoundingClientRect();
|
|
1337
1451
|
const orx = ov.getBoundingClientRect();
|
|
1338
|
-
|
|
1452
|
+
// editSig:选区行集合的指纹(焦点行切换/拖选跨行/焦点进出都要重渲染——
|
|
1453
|
+
// cursorLine 只覆盖「光标所在行变化」,选区另一端变化与焦点态变化由它捕捉)
|
|
1454
|
+
const editSig = editSet ? "e" + Array.from(editSet).join(",") : "r";
|
|
1455
|
+
const renderSig = [src, cursorLine, editSig, Math.round(irx.left - orx.left), Math.round(irx.top - orx.top), Math.round(irx.width), card.__dshClFontSig || "", color0].join("\u0000");
|
|
1339
1456
|
if (card.__dshClRenderSig === renderSig) {
|
|
1340
1457
|
updateToolbarMarks(card, src, caret);
|
|
1341
1458
|
card.__dshClCaret = caret;
|
|
@@ -1353,7 +1470,6 @@ window.__ModuleLoader__.load({
|
|
|
1353
1470
|
// 大段粘贴是单文本锚跨全部行,class 只能打锚 parent(波及整锚),且打点
|
|
1354
1471
|
// 循环的行号推进对字面 \n 会全部落 0(v0.2.3 只修了测量侧)。整框两侧
|
|
1355
1472
|
// 恒同字体,测量 rect 自动跟随。
|
|
1356
|
-
const states = computeBlockStates(lines);
|
|
1357
1473
|
const ps = input.querySelectorAll(":scope > p");
|
|
1358
1474
|
const hasChip = lines.some(paraHasChip);
|
|
1359
1475
|
for (const p of ps) {
|
|
@@ -1385,7 +1501,7 @@ window.__ModuleLoader__.load({
|
|
|
1385
1501
|
fallbackToOfficial();
|
|
1386
1502
|
} else {
|
|
1387
1503
|
try {
|
|
1388
|
-
renderCharOverlay(ov, input, anchors, lines, states, anchors.refs || [], card.__dshClLineCache, layoutGen);
|
|
1504
|
+
renderCharOverlay(ov, input, anchors, lines, states, anchors.refs || [], card.__dshClLineCache, layoutGen, editSet);
|
|
1389
1505
|
if (hasContent && ov.querySelectorAll(".dsh-cl-c").length === 0) fallbackToOfficial();
|
|
1390
1506
|
} catch (err) {
|
|
1391
1507
|
fallbackToOfficial();
|
|
@@ -2044,6 +2160,8 @@ window.__ModuleLoader__.load({
|
|
|
2044
2160
|
document.removeEventListener("selectionchange", onSelChange);
|
|
2045
2161
|
document.removeEventListener("pointerdown", onDocDown, true);
|
|
2046
2162
|
document.body.classList.remove("dsh-cl-light");
|
|
2163
|
+
document.body.style.removeProperty("--dsh-cl-card-bg");
|
|
2164
|
+
delete document.body.__dshClCardBg;
|
|
2047
2165
|
const card = findCard();
|
|
2048
2166
|
if (card) {
|
|
2049
2167
|
if (card.__dshClDisposables) {
|
|
@@ -2090,6 +2208,7 @@ window.__ModuleLoader__.load({
|
|
|
2090
2208
|
exports._renderBlockLine = renderBlockLine;
|
|
2091
2209
|
exports._stateKey = stateKey;
|
|
2092
2210
|
exports._isLightColor = isLightColor;
|
|
2211
|
+
exports._effectiveCardBg = effectiveCardBg;
|
|
2093
2212
|
exports._decideActiveMarks = decideActiveMarks;
|
|
2094
2213
|
exports._decideKeyAction = decideKeyAction;
|
|
2095
2214
|
exports._decideTabBlock = decideTabBlock;
|
|
@@ -2101,6 +2220,9 @@ window.__ModuleLoader__.load({
|
|
|
2101
2220
|
exports._decidePasteWrap = decidePasteWrap;
|
|
2102
2221
|
exports._decideQuotePaste = decideQuotePaste;
|
|
2103
2222
|
exports._codeParaFlags = codeParaFlags;
|
|
2223
|
+
exports._lineIndexOfOffset = lineIndexOfOffset;
|
|
2224
|
+
exports._computeEditLines = computeEditLines;
|
|
2225
|
+
exports._toReadingForm = toReadingForm;
|
|
2104
2226
|
exports._paraHasChip = paraHasChip;
|
|
2105
2227
|
return module.exports;
|
|
2106
2228
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-composer-live",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Type Markdown, see it rendered live — Open-WebUI-style composer for DeepSeek Harness (DSH) web. Syntax-highlighted code blocks, task lists, format toolbars, smart paste. Pure browser-side, zero dependencies.",
|
|
5
5
|
"icon": "./assets/icon-180.png",
|
|
6
6
|
"type": "module",
|