dsh-happy-reader 0.2.1 → 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/README.md CHANGED
@@ -97,14 +97,14 @@
97
97
 
98
98
  **官方插件页**(设置 → 插件)的安装框里输入:
99
99
 
100
- - git 地址(推荐):
101
- `git+https://github.com/Richardwongyk/dsh-happy-reader.git`
100
+ - npm 包名(推荐,最省事):`dsh-happy-reader`
101
+ - 或 git 地址:`git+https://github.com/Richardwongyk/dsh-happy-reader.git`
102
102
  - 或本地目录(已下载到本机时):`file:C:/path/to/dsh-happy-reader`
103
103
 
104
104
  **或命令行**:
105
105
 
106
106
  ```sh
107
- dsh plugin --profile <profile> add "git+https://github.com/Richardwongyk/dsh-happy-reader.git"
107
+ dsh plugin --profile <profile> add dsh-happy-reader
108
108
  ```
109
109
 
110
110
  ## 卸载
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.1'
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'
@@ -72,12 +72,13 @@ window.__ModuleLoader__.load({
72
72
  justify-content:center;cursor:grab;user-select:none;-webkit-user-select:none;
73
73
  box-shadow:0 4px 14px rgba(0,0,0,.28);backdrop-filter:blur(6px)}
74
74
  .dsrb-fab:active{cursor:grabbing}
75
- .dsrb-panel{position:fixed;z-index:9999;width:${PANEL_WIDTH}px;padding:0 14px;border-radius:12px;
75
+ .dsrb-panel{position:fixed;z-index:9999;width:${PANEL_WIDTH}px;padding:0;border-radius:12px;
76
76
  max-height:calc(100vh - 18px);display:flex;flex-direction:column;overflow:hidden;
77
77
  border:1px solid rgba(128,128,128,.3);background:rgba(28,28,30,.96);color:#ececec;
78
78
  font:13px/1.5 system-ui,-apple-system,"Segoe UI",sans-serif;
79
79
  box-shadow:0 8px 28px rgba(0,0,0,.38);backdrop-filter:blur(8px)}
80
- .dsrb-body{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:12px 0}
80
+ /* 横向内边距放在滚动区:面板零内边距,滚动条才能贴住面板右缘 */
81
+ .dsrb-body{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:12px 14px}
81
82
  .dsrb-body::-webkit-scrollbar{width:8px}
82
83
  .dsrb-body::-webkit-scrollbar-thumb{background:rgba(128,128,128,0);border-radius:4px;transition:background .15s}
83
84
  .dsrb-body:hover::-webkit-scrollbar-thumb{background:rgba(128,128,128,.45)}
@@ -143,6 +144,8 @@ window.__ModuleLoader__.load({
143
144
  // "开合/新对话"悬浮按钮与"应用/编辑"菜单的定位基准,归零会裁掉它们的上半截。
144
145
  // 改为逐项覆盖:frame 顶部预留条清零、侧栏列自留该变量、收态归零内容圆角、
145
146
  // 全屏隐藏菜单;规则由 html[data-dsrb-fullscreen] 门控,退出全屏即完全还原。
147
+ // 注:.BynINW_* 为应用构建期类名(随应用更新可能变;失效即表现为全屏残留,
148
+ // 按新构建重新对齐即可——无更稳定锚点可用,属原则②下已接受的取舍)。
146
149
  const FS_CSS = [
147
150
  // 镜像官方 html[data-windows-titlebar][data-fullscreen]:overlay 顶距 20px、chrome 顶距 0
148
151
  'html[data-windows-titlebar][data-dsrb-fullscreen]{--dsh-frame-overlay-top:20px;--dsh-frame-chrome-top:0px}',
@@ -1223,7 +1226,7 @@ window.__ModuleLoader__.load({
1223
1226
  if (Math.abs(dx) + Math.abs(dy) > 4) panelDrag.moved = true
1224
1227
  if (!panelDrag.moved) return
1225
1228
  const x = Math.min(Math.max(0, panelDrag.ox + dx), Math.max(0, window.innerWidth - panel.offsetWidth))
1226
- 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 在视口内(可抓回)
1227
1230
  panel.style.left = x + 'px'
1228
1231
  panel.style.top = y + 'px'
1229
1232
  } else if (panelResize) {
@@ -1367,7 +1370,28 @@ window.__ModuleLoader__.load({
1367
1370
  if (ka) work.setStartBefore(ka)
1368
1371
  if (kf) work.setEndAfter(kf)
1369
1372
  const box = document.createElement('div')
1370
- box.append(work.cloneContents())
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())
1371
1395
  // 公式场景先留存原始 HTML(含 <math>):粘进 Word 等富目标仍可显示公式
1372
1396
  const html = box.querySelector('.katex') ? box.innerHTML : null
1373
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.1",
3
+ "version": "0.2.3",
4
4
  "description": "Happy Reader(阅读增强):隐藏输入框 / 上边栏、全屏切换、字号 10–40px、行距/字距微调、面板可拖动可拉高、复制为 Markdown(公式→LaTeX)、内容宽度扩展、中英文分别选正文字体 + 代码字体(仅列本机已装)—— 与官方设置协同,不冲突",
5
5
  "type": "module",
6
6
  "license": "MIT",