mirror of
https://github.com/lllin000/PaperForge.git
synced 2026-07-22 06:50:53 +00:00
fix(dashboard): add workspace path detection for paper mode routing
- Add _extractZoteroKeyFromPath: extract key from dirname pattern '{KEY} - {title}'
- Modify _resolveModeForFile: fallback to workspace detection for any file type
- Fixes fulltext.md and other workspace files dropping to global mode
This commit is contained in:
parent
36a8ba8400
commit
0475387c55
1 changed files with 18 additions and 5 deletions
|
|
@ -935,6 +935,15 @@ class PaperForgeStatusView extends ItemView {
|
|||
this._cachedItems = null;
|
||||
}
|
||||
|
||||
/* ── Extract zotero_key from workspace directory name ── */
|
||||
_extractZoteroKeyFromPath(filePath) {
|
||||
if (!filePath) return null;
|
||||
const dirname = path.dirname(filePath);
|
||||
const basename = path.basename(dirname);
|
||||
const match = basename.match(/^([A-Z0-9]{8})(?:\s*-\s*)/);
|
||||
return match ? match[1] : null;
|
||||
}
|
||||
|
||||
/* ── Pure Mode Resolution (D-07, Phase 32) ── */
|
||||
_resolveModeForFile(file) {
|
||||
if (!file) return { mode: 'global', filePath: null, key: null, domain: null };
|
||||
|
|
@ -947,13 +956,17 @@ class PaperForgeStatusView extends ItemView {
|
|||
}
|
||||
|
||||
if (ext === 'md') {
|
||||
// Standard .md — check for zotero_key in frontmatter.
|
||||
const cache = this.app.metadataCache.getFileCache(file);
|
||||
const key = cache && cache.frontmatter && cache.frontmatter.zotero_key;
|
||||
if (key) {
|
||||
return { mode: 'paper', filePath, key, domain: null };
|
||||
const fmKey = cache && cache.frontmatter && cache.frontmatter.zotero_key;
|
||||
if (fmKey) {
|
||||
return { mode: 'paper', filePath, key: fmKey, domain: null };
|
||||
}
|
||||
return { mode: 'global', filePath, key: null, domain: null };
|
||||
}
|
||||
|
||||
// Workspace path detection: any file inside a paper workspace directory
|
||||
const wsKey = this._extractZoteroKeyFromPath(filePath);
|
||||
if (wsKey && this._findEntry(wsKey)) {
|
||||
return { mode: 'paper', filePath, key: wsKey, domain: null };
|
||||
}
|
||||
|
||||
return { mode: 'global', filePath, key: null, domain: null };
|
||||
|
|
|
|||
Loading…
Reference in a new issue