dsh-happy-reader 0.3.0 → 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.
Files changed (2) hide show
  1. package/lib/client.js +7 -1
  2. package/package.json +1 -1
package/lib/client.js CHANGED
@@ -20,7 +20,7 @@ window.__ModuleLoader__.load({
20
20
  var exports = module.exports
21
21
 
22
22
  // ── 常量 ────────────────────────────────────────────────────────────
23
- const VERSION = '0.3.0'
23
+ const VERSION = '0.3.1'
24
24
  const INSTANCE_TOKEN = {}
25
25
  const GROUPS_VERSION = 3
26
26
  const STATE_KEY = 'dsh.reader-boost.v1'
@@ -2238,10 +2238,16 @@ window.__ModuleLoader__.load({
2238
2238
  anc = anc.parentElement
2239
2239
  }
2240
2240
  let topShell = -1
2241
+ let inlineShell = -1
2242
+ const INLINE_SHELL = new Set(['CODE', 'STRONG', 'B', 'EM', 'I', 'DEL', 'S', 'STRIKE', 'A'])
2241
2243
  for (let i = 0; i < ancShells.length; i++) {
2242
2244
  const ws = getComputedStyle(ancShells[i]).whiteSpace
2243
2245
  if (ws === 'pre' || ws === 'pre-wrap' || ws === 'pre-line' || ws === 'break-spaces') topShell = i
2246
+ // 行内语义元素同样会在克隆时丢外壳:<code> 补 `…`,粗体/斜体/
2247
+ // 删除线/链接补对应 Markdown;取最外层,嵌套格式才能完整保留。
2248
+ if (INLINE_SHELL.has(ancShells[i].tagName)) inlineShell = i
2244
2249
  }
2250
+ if (topShell < 0 && inlineShell >= 0) topShell = inlineShell
2245
2251
  let nestAt = box
2246
2252
  for (let i = topShell; i >= 0; i--) {
2247
2253
  const shell = ancShells[i].cloneNode(false)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-happy-reader",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Happy Reader(阅读增强):隐藏输入框 / 上边栏、全屏切换、字号 10–40px、行距/字距微调、面板可拖动可拉高、复制为 Markdown(公式→LaTeX)、内容宽度扩展、中英文分别选正文字体 + 官方代码/终端字体与字号(仅列本机已装)—— 与官方设置协同,不冲突",
5
5
  "type": "module",
6
6
  "license": "MIT",