dsh-happy-reader 0.2.2 → 0.2.3
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/lib/client.js +26 -3
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -29,7 +29,7 @@ window.__ModuleLoader__.load({
|
|
|
29
29
|
var exports = module.exports
|
|
30
30
|
|
|
31
31
|
// ── 常量 ────────────────────────────────────────────────────────────
|
|
32
|
-
const VERSION = '0.2.
|
|
32
|
+
const VERSION = '0.2.3'
|
|
33
33
|
const STATE_KEY = 'dsh.reader-boost.v1'
|
|
34
34
|
const FAB_ID = 'dsrb-fab'
|
|
35
35
|
const PANEL_ID = 'dsrb-panel'
|
|
@@ -144,6 +144,8 @@ window.__ModuleLoader__.load({
|
|
|
144
144
|
// "开合/新对话"悬浮按钮与"应用/编辑"菜单的定位基准,归零会裁掉它们的上半截。
|
|
145
145
|
// 改为逐项覆盖:frame 顶部预留条清零、侧栏列自留该变量、收态归零内容圆角、
|
|
146
146
|
// 全屏隐藏菜单;规则由 html[data-dsrb-fullscreen] 门控,退出全屏即完全还原。
|
|
147
|
+
// 注:.BynINW_* 为应用构建期类名(随应用更新可能变;失效即表现为全屏残留,
|
|
148
|
+
// 按新构建重新对齐即可——无更稳定锚点可用,属原则②下已接受的取舍)。
|
|
147
149
|
const FS_CSS = [
|
|
148
150
|
// 镜像官方 html[data-windows-titlebar][data-fullscreen]:overlay 顶距 20px、chrome 顶距 0
|
|
149
151
|
'html[data-windows-titlebar][data-dsrb-fullscreen]{--dsh-frame-overlay-top:20px;--dsh-frame-chrome-top:0px}',
|
|
@@ -1224,7 +1226,7 @@ window.__ModuleLoader__.load({
|
|
|
1224
1226
|
if (Math.abs(dx) + Math.abs(dy) > 4) panelDrag.moved = true
|
|
1225
1227
|
if (!panelDrag.moved) return
|
|
1226
1228
|
const x = Math.min(Math.max(0, panelDrag.ox + dx), Math.max(0, window.innerWidth - panel.offsetWidth))
|
|
1227
|
-
const y = Math.min(Math.max(0, panelDrag.oy + dy), Math.max(0, window.innerHeight - 34))
|
|
1229
|
+
const y = Math.min(Math.max(0, panelDrag.oy + dy), Math.max(0, window.innerHeight - 34)) // 至少留 34px 在视口内(可抓回)
|
|
1228
1230
|
panel.style.left = x + 'px'
|
|
1229
1231
|
panel.style.top = y + 'px'
|
|
1230
1232
|
} else if (panelResize) {
|
|
@@ -1368,7 +1370,28 @@ window.__ModuleLoader__.load({
|
|
|
1368
1370
|
if (ka) work.setStartBefore(ka)
|
|
1369
1371
|
if (kf) work.setEndAfter(kf)
|
|
1370
1372
|
const box = document.createElement('div')
|
|
1371
|
-
|
|
1373
|
+
// 选区克隆丢掉共同祖先往上的层级(代码块外层的 <pre> 即如此丢的),转换器的
|
|
1374
|
+
// 空白折叠随即把换行折掉;按现场回收"预格式化"祖先链(判据=实际生效的
|
|
1375
|
+
// white-space)补壳还原层级——非预格式化选区零改动。
|
|
1376
|
+
const cac = work.commonAncestorContainer
|
|
1377
|
+
let anc = cac.nodeType === 1 ? cac : cac.parentElement
|
|
1378
|
+
const ancShells = []
|
|
1379
|
+
while (anc && anc !== document.body && !anc.matches('[data-chat-node-key]')) {
|
|
1380
|
+
ancShells.push(anc)
|
|
1381
|
+
anc = anc.parentElement
|
|
1382
|
+
}
|
|
1383
|
+
let topShell = -1
|
|
1384
|
+
for (let i = 0; i < ancShells.length; i++) {
|
|
1385
|
+
const ws = getComputedStyle(ancShells[i]).whiteSpace
|
|
1386
|
+
if (ws === 'pre' || ws === 'pre-wrap' || ws === 'pre-line' || ws === 'break-spaces') topShell = i
|
|
1387
|
+
}
|
|
1388
|
+
let nestAt = box
|
|
1389
|
+
for (let i = topShell; i >= 0; i--) {
|
|
1390
|
+
const shell = ancShells[i].cloneNode(false)
|
|
1391
|
+
nestAt.append(shell)
|
|
1392
|
+
nestAt = shell
|
|
1393
|
+
}
|
|
1394
|
+
nestAt.append(work.cloneContents())
|
|
1372
1395
|
// 公式场景先留存原始 HTML(含 <math>):粘进 Word 等富目标仍可显示公式
|
|
1373
1396
|
const html = box.querySelector('.katex') ? box.innerHTML : null
|
|
1374
1397
|
// 标签→Markdown 映射由标准库 turndown 承担(公式已由上面的 katex 规则还原为 LaTeX)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-happy-reader",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Happy Reader(阅读增强):隐藏输入框 / 上边栏、全屏切换、字号 10–40px、行距/字距微调、面板可拖动可拉高、复制为 Markdown(公式→LaTeX)、内容宽度扩展、中英文分别选正文字体 + 代码字体(仅列本机已装)—— 与官方设置协同,不冲突",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|