@wagq/dsh-obsidian 1.1.0 → 1.1.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/README.en.md CHANGED
@@ -20,7 +20,7 @@ dsh plugin --profile web add @wagq/dsh-obsidian
20
20
  **From source**
21
21
 
22
22
  ```bash
23
- dsh plugin --profile web add github:sdmu-gaoqi/dsh-obsidian-kb
23
+ dsh plugin --profile web add github:sdmu-gaoqi/dsh-obsidian
24
24
  ```
25
25
 
26
26
  Refresh the page (or restart DSH) and a **Knowledge base** icon appears in the sidebar.
@@ -135,8 +135,8 @@ The vault switcher in the panel header moves between registered vaults without t
135
135
  ## Development
136
136
 
137
137
  ```bash
138
- git clone https://github.com/sdmu-gaoqi/dsh-obsidian-kb.git
139
- cd dsh-obsidian-kb
138
+ git clone https://github.com/sdmu-gaoqi/dsh-obsidian.git
139
+ cd dsh-obsidian
140
140
  dsh plugin --profile web add .
141
141
  ```
142
142
 
package/README.md CHANGED
@@ -20,7 +20,7 @@ dsh plugin --profile web add @wagq/dsh-obsidian
20
20
  **从源码安装**
21
21
 
22
22
  ```bash
23
- dsh plugin --profile web add github:sdmu-gaoqi/dsh-obsidian-kb
23
+ dsh plugin --profile web add github:sdmu-gaoqi/dsh-obsidian
24
24
  ```
25
25
 
26
26
  装完刷新页面(或重启 DSH)即可生效,左侧栏出现「知识库」图标。
@@ -135,8 +135,8 @@ dsh plugin --profile web add github:sdmu-gaoqi/dsh-obsidian-kb
135
135
  ## 开发
136
136
 
137
137
  ```bash
138
- git clone https://github.com/sdmu-gaoqi/dsh-obsidian-kb.git
139
- cd dsh-obsidian-kb
138
+ git clone https://github.com/sdmu-gaoqi/dsh-obsidian.git
139
+ cd dsh-obsidian
140
140
  dsh plugin --profile web add .
141
141
  ```
142
142
 
package/client.js CHANGED
@@ -369,12 +369,17 @@ window.__ModuleLoader__.load({
369
369
 
370
370
  const save = async () => {
371
371
  if (!note) return;
372
+ // DSH WebView 中 React 受控 textarea 的 onChange 偶发不更新 draft;
373
+ // 这里直接读 DOM 当前值兜底,保证「保存」一定能拿到用户看到的内容。
374
+ const el = rootRef.current?.querySelector?.('[data-kb-editor]');
375
+ const content = el && typeof el.value === 'string' ? el.value : draft;
372
376
  setBusy(true);
373
377
  try {
374
- const r = await api('save', { path: note.path, content: draft });
378
+ const r = await api('save', { path: note.path, content });
375
379
  if (r.ok) {
376
380
  const fresh = await api(`note?path=${encodeURIComponent(note.path)}`);
377
381
  if (fresh.ok) { setNote(fresh.note); setDraft(fresh.note.body); }
382
+ else setDraft(content);
378
383
  setMode('read');
379
384
  setNotice(t('saved')); loadTree();
380
385
  } else setNotice(r.error || 'save failed');
@@ -382,6 +387,12 @@ window.__ModuleLoader__.load({
382
387
  finally { setBusy(false); }
383
388
  };
384
389
 
390
+ const cancelEdit = () => {
391
+ setDraft(note?.body ?? '');
392
+ setMode('read');
393
+ setNotice('');
394
+ };
395
+
385
396
  // DSH 的 WebView 禁用了 window.prompt / window.confirm,
386
397
  // 所有需要输入的交互都走这里的内联对话框。
387
398
  // 用 ref 保存 resolve 与当前值,避免在闭包里读到过期的 state。
@@ -946,7 +957,12 @@ window.__ModuleLoader__.load({
946
957
  style: { ...S.iconBtn, ...(mode === 'edit' ? S.btnOn : {}) },
947
958
  onClick: () => setMode('edit'), title: t('edit'),
948
959
  }, t('edit')) : null,
949
- note && dirty ? h('button', { style: { ...S.btn, borderColor: C.brand, color: C.brand }, onClick: save, disabled: busy }, busy ? t('saving') : t('save')) : null,
960
+ note && (dirty || mode === 'edit') ? h('button', {
961
+ style: { ...S.btn, borderColor: C.brand, color: C.brand },
962
+ onClick: save,
963
+ onPointerDown: e => e.stopPropagation(),
964
+ disabled: busy,
965
+ }, busy ? t('saving') : t('save')) : null,
950
966
  note ? h('button', { style: S.iconBtn, title: t('rename'), onClick: renameNote }, h(Icon, { d: 'M12 20h9M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4z' })) : null,
951
967
  note ? h('button', { style: S.iconBtn, title: t('delete'), onClick: removeNote }, h(Icon, { d: 'M3 6h18M8 6V4h8v2M6 6l1 14h10l1-14', })) : null,
952
968
  h('button', {
@@ -978,7 +994,9 @@ window.__ModuleLoader__.load({
978
994
  mode === 'edit' && note.kind !== 'note' ? null : mode === 'edit'
979
995
  ? h('textarea', {
980
996
  style: S.textarea, value: draft ?? '', spellCheck: false,
997
+ 'data-kb-editor': '1',
981
998
  onChange: e => setDraft(e.target.value),
999
+ onInput: e => setDraft(e.target.value),
982
1000
  'aria-label': note.title,
983
1001
  })
984
1002
  : note.kind === 'image'
@@ -1005,8 +1023,18 @@ window.__ModuleLoader__.load({
1005
1023
  : h('div', null, ...renderMarkdown(note.body, jumpTo)),
1006
1024
  mode === 'edit'
1007
1025
  ? h('div', { style: { display: 'flex', gap: 8, justifyContent: 'flex-end', marginTop: 14 } },
1008
- h('button', { style: S.btn, onClick: () => { setDraft(note.body); setMode('read'); }, disabled: !dirty }, t('cancel')),
1009
- h('button', { style: { ...S.btn, borderColor: C.brand, color: C.brand }, onClick: save, disabled: busy || !dirty }, busy ? t('saving') : t('save')),
1026
+ h('button', {
1027
+ style: S.btn,
1028
+ onClick: cancelEdit,
1029
+ onPointerDown: e => e.stopPropagation(),
1030
+ disabled: busy,
1031
+ }, t('cancel')),
1032
+ h('button', {
1033
+ style: { ...S.btn, borderColor: C.brand, color: C.brand },
1034
+ onClick: save,
1035
+ onPointerDown: e => e.stopPropagation(),
1036
+ disabled: busy,
1037
+ }, busy ? t('saving') : t('save')),
1010
1038
  )
1011
1039
  : null,
1012
1040
  )
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@wagq/dsh-obsidian",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "Connect a local Obsidian vault to DeepSeek Harness: a three-column knowledge workspace in the sidebar (library / document / outline & related), with filters, search, rendered Markdown, in-place editing and right-click menus, plus kb_* agent tools that read and write the same vault in chat. 把本地 Obsidian 知识库接到 DSH 左侧栏,并在对话中让智能体读写同一个 vault。",
5
5
  "license": "MIT",
6
6
  "author": "sdmu-gaoqi",
7
7
  "repository": {
8
8
  "type": "git",
9
- "url": "git+https://github.com/sdmu-gaoqi/dsh-obsidian-kb.git"
9
+ "url": "git+https://github.com/sdmu-gaoqi/dsh-obsidian.git"
10
10
  },
11
- "homepage": "https://github.com/sdmu-gaoqi/dsh-obsidian-kb#readme",
11
+ "homepage": "https://github.com/sdmu-gaoqi/dsh-obsidian#readme",
12
12
  "bugs": {
13
- "url": "https://github.com/sdmu-gaoqi/dsh-obsidian-kb/issues"
13
+ "url": "https://github.com/sdmu-gaoqi/dsh-obsidian/issues"
14
14
  },
15
15
  "keywords": [
16
16
  "deepseek",