dsh-markdown-studio 0.1.5 → 0.1.6

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 CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  All notable changes to `dsh-markdown-studio` are documented in this file.
4
4
 
5
+ ## [0.1.6] - 2026-11-21
6
+
7
+ ### Security
8
+ - **Custom CSS Remote Resource Bypass Hardening**: Stripped CSS comments and backslash newline continuations before URL sanitization (`src/domain/custom-css.ts`), and added post-`var()` external `url()` blocking inside the CSS inliner (`src/css-inliner.ts`) so remote tracking URLs cannot be smuggled through CSS custom properties or split tokens.
9
+ - **Host Desktop Origin Allowlist**: Restricted non-HTTP(S) `Origin` headers on the local asset and AI routes (`host/http/routes.ts`, `host/http/ai-route.ts`) to explicit desktop shell schemes (`dsh-app:`, `dsh:`, `app:`, `file:`) instead of accepting arbitrary custom protocols.
10
+
11
+ ### Fixed
12
+ - **Binary Image SHA-256 Hashing & Atomic Store Concurrency**: Fixed `ImageHostService` (`host/application/image-store.ts`) to hash raw PNG/JPEG `Buffer` bytes directly rather than UTF-8-corrupted strings, added random temp suffixes, cloned manifests immutably, and serialized all file writes/deletes through the manifest queue.
13
+ - **Drag-and-Drop `.md` Safety & Autosave Race Protection**: Dropping a `.md`/`.txt` file onto the editor (`src/app.ts`) now detaches any previously linked local file handle, resets active AI review state, and guards against article switches across async reads; debounced autosave tracks `(articleId, markdown)`, cancels cleanly on detach/switch, and syncs linked folder `assets/`.
14
+ - **Asset GC, Workspace & Archive Reliability**: Expanded `assetFilesInMarkdown` (`src/domain/images.ts`) to detect titled Markdown links, `./assets/`, `<img>`, and local server URLs; protected import-recovery snapshots, undo/redo history, and in-flight uploads from garbage collection; switched workspace open-file checks to async `isSameEntry` and blocked `.`/`..`; reconciled cross-`docs`/`trash` merge conflicts while guaranteeing non-empty `docs` after merge; and ensured switching articles preserves `updatedAt`.
15
+ - **Markdown Parser & CSS Inliner Edge Cases**: Fixed apostrophes/parentheses/currency inside table cells, currency `$100`/`$50` mixed with `$x+1$` formulas, intraword `C++17`/`a==1` guards with suffixed `==API==s`/`++UI++s`, nested `***` emphasis (`**a ***b*** c**`, `**bold and *italic***`, `**foo***`), apostrophes in link URLs, single-line editorial directives (`:::lead ...`) inside `:::scroll`, blockquote fenced code tracking, CSS `[attr$="..."]` selector splitting, `:is()`/`:not()`/`:where()` specificity, element-scoped CSS variables, and explicit `codeTheme` overriding custom theme `pre` colors.
16
+ - **Mermaid Concurrency & Dark Preview Lifecycle**: Fixed overlapping `ensure()` calls in `useMermaidAssets` so Mermaid diagrams never get stuck in `'loading'`; added CSS Color 4 `color(srgb ...)` parsing, `Darkmode.reset([])` cleanup with `data-plugin="dsh-markdown-studio"` tagging for leak-free repeated light/dark toggling, and full-width preview stage background alignment.
17
+ - **UI, Accessibility, Shortcuts & Mobile Polish**:
18
+ - Preserved AI word-diff colors and strikethrough inside immersive writing mode; restored editor focus after accepting/rejecting AI patches so immediate `⌘/Ctrl + Z` undo works.
19
+ - Raised WCAG 2 AA contrast for dark-mode danger confirmation buttons (`#dc2626`), `<del>` inside `:::tldr`/`blockquote` across all 8 built-in themes, and library search highlights/metadata.
20
+ - Eliminated compact-viewport clipping in the Skill Manager dialog (`720×680`), corrected the draft chip label (`新 Skill` / `Draft`), prevented search bar and outline/slash overlap, kept mobile (`<= 720px`) CSS Workbench drafts intact across preview toggles, increased mobile touch header/toolbar heights, added `Shift+Tab` outdent and shortcut modifier guards (`Ctrl+Tab`, `Shift+⌘/Ctrl+I`), made Settings Drawer tabs controlled, added workspace tree `ArrowLeft`/`ArrowRight` collapse/expand, started fresh documents scrolled at the top, and localized the cold-boot shell loading/error states.
21
+
5
22
  ## [0.1.5] - 2026-11-20
6
23
 
7
24
  ### Added
@@ -52,6 +69,7 @@ Initial public release.
52
69
  - Host-side content-addressed PNG/JPEG store (`$DSH_HOME/storages/dsh-markdown-studio/assets/`) with magic-byte validation, authenticated write routes, automatic reference-counted garbage collection on permanent article deletion, and a read-only loopback server (`127.0.0.1:4010-4019`) so Markdown stays portable as `assets/<hash>.png`.
53
70
  - Multi-article `localStorage` library with no artificial article/trash limits, future-schema overwrite protection, unreadable-payload preservation, keyword-highlighted search, conflict-aware merge dialog, `PK` magic-header `.zip` archive import/export (`4096` entries / `256 MiB` bounded decompression), and SHA-256 baseline conflict detection for local File System Access API `.md` / folder workspaces.
54
71
 
72
+ [0.1.6]: https://github.com/Geekhyt/dsh-markdown-studio/compare/v0.1.5...v0.1.6
55
73
  [0.1.5]: https://github.com/Geekhyt/dsh-markdown-studio/compare/v0.1.4...v0.1.5
56
74
  [0.1.4]: https://github.com/Geekhyt/dsh-markdown-studio/compare/v0.1.3...v0.1.4
57
75
  [0.1.3]: https://github.com/Geekhyt/dsh-markdown-studio/compare/v0.1.2...v0.1.3
package/README.en.md CHANGED
@@ -109,7 +109,7 @@ Manage multiple drafts and a recycle bin with keyword-highlighted title and exce
109
109
 
110
110
  ## Why `dsh-markdown-studio`
111
111
 
112
- - **Zero host patches, fast startup**: Built on official DeepSeek Harness plugin APIs with a `2.1 KiB` gzipped core shell; the editor, math, and diagram engines load only when needed so everyday chats pay zero overhead.
112
+ - **Zero host patches, fast startup**: Built on official DeepSeek Harness plugin APIs with a `2.3 KiB` gzipped core shell; the editor, math, and diagram engines load only when needed so everyday chats pay zero overhead.
113
113
  - **What you preview is what pastes into WeChat**: Eight high-contrast editorial themes compile cleanly into self-contained inline styles, collect external links into bottom references, preserve code indentation, and keep dark preview isolated from light clipboard output.
114
114
  - **100% local-first, your data stays yours**: Drafts, recycle bin entries, custom themes, and deduplicated local images remain on your machine. Unused images are cleaned up automatically on permanent deletion, linked files warn before overwriting external edits, and full `.zip` backups keep everything portable (see [storage and archive formats](./docs/schema.md)).
115
115
 
package/README.md CHANGED
@@ -109,7 +109,7 @@ dsh plugin --profile desktop add dsh-markdown-studio
109
109
 
110
110
  ## 为什么选择 `dsh-markdown-studio`
111
111
 
112
- - **官方接口实现,按需加载更轻快**:基于 DeepSeek Harness 官方插件接口构建,无任何宿主魔改;首屏核心包仅 `2.1 KiB`(gzip),编辑器、公式与流程图引擎仅在实际使用时按需加载,日常对话零负担。
112
+ - **官方接口实现,按需加载更轻快**:基于 DeepSeek Harness 官方插件接口构建,无任何宿主魔改;首屏核心包仅 `2.3 KiB`(gzip),编辑器、公式与流程图引擎仅在实际使用时按需加载,日常对话零负担。
113
113
  - **所见即所得,粘贴公众号不走样**:8 套高对比度原创排版体系自动内联全部样式,外链自动收拢为文末参考资料,代码缩进完整保留,深色预览与浅色剪贴板严格隔离。
114
114
  - **完全本地优先,数据主权归你**:草稿、回收站、自定义主题与自动去重的本地图片全部留在本机;彻底删除草稿时自动回收未引用图片,本地关联文件支持外部修改冲突提醒,并可随时导出完整 `.zip` 归档(详情见 [数据格式与容量](./docs/schema.md))。
115
115
 
package/dist/client.js CHANGED
@@ -1,7 +1,7 @@
1
1
  window.__ModuleLoader__.load({ id: "dsh-markdown-studio", factory: (require) => {
2
2
  var module = { exports: {} }; var exports = module.exports;
3
3
  (function (module, exports, require) {
4
- "use strict";var y=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var z=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var D=(e,n)=>{for(var t in n)y(e,t,{get:n[t],enumerable:!0})},I=(e,n,t,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of z(n))!_.call(e,i)&&i!==t&&y(e,i,{get:()=>n[i],enumerable:!(r=M(n,i))||r.enumerable});return e};var K=e=>I(y({},"__esModule",{value:!0}),e);var B={};D(B,{create:()=>W});module.exports=K(B);function v(e,n,t){let[,r]=e.useState(0),[i,s]=e.useState(null);return e.useEffect(function(){if(n())return;let a=!1;return t().then(function(){a||r(function(u){return u+1})},function(u){a||s(u instanceof Error?u.message:String(u))}),function(){a=!0}},[i]),{error:i,retry:function(){s(null)}}}function w(e){let n=e.React.createElement,t=e.size||16;return n("svg",{width:t,height:t,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:e.active?1.3:1,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},n("rect",{x:2,y:2,width:12,height:12,rx:2.6}),n("path",{d:"M5 10.8V5.6l3 2.9 3-2.9v5.2"}))}var g="dsh-markdown-studio",S=`__dshPluginCss__:${g}`;function k(){let e=globalThis,n=e[S];if(n)return n;let t={mounted:!1,sheets:new Map};return e[S]=t,t}function E(){let e=k();e.mounted=!0,!(typeof document>"u"||!document.head)&&e.sheets.forEach((n,t)=>{let r=`style[data-plugin-css=${JSON.stringify(t)}]`;if(document.querySelector(r))return;let i=document.createElement("style");i.dataset.plugin=g,i.dataset.pluginCss=t,i.textContent=n,document.head.appendChild(i)})}function x(){let e=k();if(e.mounted=!1,typeof document>"u")return;document.querySelectorAll(`style[data-plugin=${JSON.stringify(g)}]`).forEach(t=>{typeof t.remove=="function"&&t.remove()})}var C="dsh-markdown-studio",b="dsh-markdown-studio.shell",j={"panel.label":"Markdown Studio"};function A(e){let n=[],t=new Set(["en","zh","zh-CN"]);try{e.getSnapshot().locales.forEach(r=>{t.add(r.id)})}catch{}return t.forEach(r=>{try{let i=e.register(b,r,j);typeof i=="function"&&n.push(i)}catch{}}),()=>{n.forEach(r=>{try{r()}catch{}})}}function P(e,n,t){let r=null,i={get:s=>n.get(s),effect:s=>{let a=s();typeof a=="function"&&t.push(a)},slots:{inject:(s,a)=>(s==="main"&&a(),()=>{}),register:(s,a)=>(s.name==="main"&&(r=a),()=>{})}};return e.apply(i),r}function W(e,n,t){let r=e.createElement,i=t||(()=>Promise.reject(new Error("studio chunk loader missing"))),s=null,a=[],u=null,f=null,p=null;function h(o){if(f=o,s){let c=P(o,s,a);c&&(u=c)}if(!u)throw new Error("Markdown Studio chunk did not register a main view");return u}function R(){return u?Promise.resolve(u):f&&s?Promise.resolve(h(f)):(p||(p=i().then(o=>(p=null,h(o)),o=>{throw p=null,o})),p)}function L(o){return w({React:e,size:o&&o.size?o.size:16,active:!!(o&&o.active)})}function T(o){let{error:c,retry:l}=v(e,()=>!!u,()=>R());return u?r(u,o):c?r("div",{role:"alert",style:{padding:"32px",color:"var(--dsw-alias-label-primary, #1f2329)",fontSize:"14px"}},r("p",{style:{margin:"0 0 12px",fontWeight:600}},"Markdown Studio failed to load"),r("button",{type:"button",onClick:l,style:{padding:"6px 14px",borderRadius:"8px",cursor:"pointer"}},"Retry")):r("div",{role:"status","aria-live":"polite",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--dsw-alias-label-secondary, #646a73)",fontSize:"13px"}},"Loading Markdown Studio\u2026")}function N(o){s=o;let c=o.get("locale"),l=null;o.effect(()=>{E();let m=[];if(a=m,c){m.push(A(c));try{l=c.bind(b)}catch{l=null}}if(f){let d=P(f,o,m);d&&(u=d)}return()=>{for(a=[],s=null,u=null;m.length>0;){let d=m.pop();if(d)try{d()}catch{}}x()}}),o.slots.inject("sidebar.panellist",()=>o.slots.register({name:"sidebar.panellist",id:C,order:40,label:()=>l?l("panel.label"):"Markdown Studio"},L)),o.slots.inject("main",()=>o.slots.register({name:"main",key:C},T))}return{inject:["slots"],apply:N}}
4
+ "use strict";var h=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var K=Object.prototype.hasOwnProperty;var j=(e,t)=>{for(var o in t)h(e,o,{get:t[o],enumerable:!0})},A=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of I(t))!K.call(e,i)&&i!==o&&h(e,i,{get:()=>t[i],enumerable:!(r=D(t,i))||r.enumerable});return e};var W=e=>A(h({},"__esModule",{value:!0}),e);var V={};j(V,{create:()=>O});module.exports=W(V);function S(e,t,o){let[,r]=e.useState(0),[i,s]=e.useState(null);return e.useEffect(function(){if(t()||i!==null)return;let a=!1;return o().then(function(){a||r(function(u){return u+1})},function(u){a||s(u instanceof Error?u.message:String(u))}),function(){a=!0}},[i]),{error:i,retry:function(){s(null)}}}function k(e){let t=e.React.createElement,o=e.size||16;return t("svg",{width:o,height:o,viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:e.active?1.3:1,strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true"},t("rect",{x:2,y:2,width:12,height:12,rx:2.6}),t("path",{d:"M5 10.8V5.6l3 2.9 3-2.9v5.2"}))}var v="dsh-markdown-studio",E=`__dshPluginCss__:${v}`;function x(){let e=globalThis,t=e[E];if(t)return t;let o={mounted:!1,sheets:new Map};return e[E]=o,o}function C(){let e=x();e.mounted=!0,!(typeof document>"u"||!document.head)&&e.sheets.forEach((t,o)=>{let r=`style[data-plugin-css=${JSON.stringify(o)}]`;if(document.querySelector(r))return;let i=document.createElement("style");i.dataset.plugin=v,i.dataset.pluginCss=o,i.textContent=t,document.head.appendChild(i)})}function b(){let e=x();if(e.mounted=!1,typeof document>"u")return;document.querySelectorAll(`style[data-plugin=${JSON.stringify(v)}]`).forEach(o=>{typeof o.remove=="function"&&o.remove()})}var P="dsh-markdown-studio",L="dsh-markdown-studio.shell",T={"panel.label":"Markdown Studio","shell.loading":"Loading Markdown Studio\u2026","shell.failed":"Markdown Studio failed to load","shell.retry":"Retry"},B={"panel.label":"Markdown Studio","shell.loading":"\u6B63\u5728\u52A0\u8F7D Markdown Studio\u2026","shell.failed":"Markdown Studio \u52A0\u8F7D\u5931\u8D25","shell.retry":"\u91CD\u8BD5"};function H(e){let t=[],o=new Set(["en","zh","zh-CN"]);try{e.getSnapshot().locales.forEach(r=>{o.add(r.id)})}catch{}return o.forEach(r=>{try{let i=/^zh/i.test(r)?B:T,s=e.register(L,r,i);typeof s=="function"&&t.push(s)}catch{}}),()=>{t.forEach(r=>{try{r()}catch{}})}}function R(e,t,o){let r=null,i={get:s=>t.get(s),effect:s=>{let a=s();typeof a=="function"&&o.push(a)},slots:{inject:(s,a)=>(s==="main"&&a(),()=>{}),register:(s,a)=>(s.name==="main"&&(r=a),()=>{})}};return e.apply(i),r}function O(e,t,o){let r=e.createElement,i=o||(()=>Promise.reject(new Error("studio chunk loader missing"))),s=null,a=[],u=null,f=null,p=null,m=null;function g(n){if(m)try{let l=m(n);if(l&&l!==n)return l}catch{}return T[n]||n}function w(n){if(f=n,s){let l=R(n,s,a);l&&(u=l)}if(!u)throw new Error("Markdown Studio chunk did not register a main view");return u}function M(){return u?Promise.resolve(u):f&&s?Promise.resolve(w(f)):(p||(p=i().then(n=>(p=null,w(n)),n=>{throw p=null,n})),p)}function N(n){return k({React:e,size:n&&n.size?n.size:16,active:!!(n&&n.active)})}function _(n){let{error:l,retry:c}=S(e,()=>!!u,()=>M());return u?r(u,n):l?r("div",{role:"alert",style:{padding:"32px",color:"var(--dsw-alias-label-primary, #1f2329)",fontSize:"14px"}},r("p",{style:{margin:"0 0 12px",fontWeight:600}},g("shell.failed")),r("button",{type:"button",onClick:c,style:{padding:"6px 14px",borderRadius:"8px",border:"0.5px solid var(--dsw-alias-border-l2, rgba(15, 17, 21, 0.16))",background:"var(--dsw-alias-bg-layer-2, #f2f4f7)",color:"var(--dsw-alias-label-primary, #0f1115)",cursor:"pointer"}},g("shell.retry"))):r("div",{role:"status","aria-live":"polite",style:{display:"flex",alignItems:"center",justifyContent:"center",height:"100%",color:"var(--dsw-alias-label-secondary, #646a73)",fontSize:"13px"}},g("shell.loading"))}function z(n){s=n;let l=n.get("locale"),c=null;n.effect(()=>{C();let y=[];if(a=y,l){y.push(H(l));try{c=l.bind(L),m=c}catch{c=null,m=null}}if(f){let d=R(f,n,y);d&&(u=d)}return()=>{for(a=[],s=null,m=null,u=null;y.length>0;){let d=y.pop();if(d)try{d()}catch{}}b()}}),n.slots.inject("sidebar.panellist",()=>n.slots.register({name:"sidebar.panellist",id:P,order:40,label:()=>c?c("panel.label"):"Markdown Studio"},N)),n.slots.inject("main",()=>n.slots.register({name:"main",key:P},_))}return{inject:["slots"],apply:z}}
5
5
  })(module, exports, require);
6
6
  var primitives = null;
7
7
  try { primitives = require('@deepseek-ai/dsh-client-ui-primitives'); } catch (_e) {}