fix: stabilize local folder AI document workflow
- scope local-folder PageTree revision and document sidebar rendering to fileTreeScope - preserve projected table/image attrs for local Markdown aggregate fallback - avoid FileTree restore forced layouts on cold design open - add API ChatOnly provider runtime and local OCR task handling regressions
This commit is contained in:
@@ -208,6 +208,7 @@ import { createSidebarPageSettingsRuntime } from './sidebar-page-settings-runtim
|
||||
const openPageHistoryDrawer = (...args) => sidebarPageSettings.openPageHistoryDrawer(...args);
|
||||
const openPageShareDialog = (...args) => sidebarPageSettings.openPageShareDialog(...args);
|
||||
const pageOptionIsSupported = (...args) => sidebarPageSettings.pageOptionIsSupported(...args);
|
||||
const persistLocalOcrAutoPreference = (...args) => sidebarPageSettings.persistLocalOcrAutoPreference(...args);
|
||||
const persistPageOptionsPatch = (...args) => sidebarPageSettings.persistPageOptionsPatch(...args);
|
||||
const persistPageWidthPreference = (...args) => sidebarPageSettings.persistPageWidthPreference(...args);
|
||||
const recordPageHistorySnapshot = (...args) => sidebarPageSettings.recordPageHistorySnapshot(...args);
|
||||
@@ -441,6 +442,11 @@ import { createSidebarPageSettingsRuntime } from './sidebar-page-settings-runtim
|
||||
return title && title.textContent ? title.textContent.trim() : (fallback || '文件夹');
|
||||
}
|
||||
|
||||
function isLocalOcrMarkdownPath(relativePath) {
|
||||
var normalized = String(relativePath || '').trim().replace(/\\/g, '/').replace(/^\/+/, '');
|
||||
return /(^|\/)[^/]+\.ocr\/[^/]+\.ocr\.md$/i.test(normalized);
|
||||
}
|
||||
|
||||
function sidebarShortcutRows() {
|
||||
return Array.from(document.querySelectorAll('.wolai-starred-section [data-mnote-shortcut-kind]'));
|
||||
}
|
||||
@@ -1714,13 +1720,16 @@ import { createSidebarPageSettingsRuntime } from './sidebar-page-settings-runtim
|
||||
}
|
||||
var title = uploadedAssetTitle(asset);
|
||||
var markdownHref = uploadedAssetMarkdownHref(asset);
|
||||
var url = markdownHref || localAssetOpenUrl(asset, false) || uploadedAssetUrl(asset);
|
||||
var localOpenUrl = localAssetOpenUrl(asset, false);
|
||||
var fallbackUrl = uploadedAssetUrl(asset);
|
||||
var imageUrl = localOpenUrl || fallbackUrl || markdownHref;
|
||||
var url = markdownHref || localOpenUrl || fallbackUrl;
|
||||
var type = uploadedAssetType(asset);
|
||||
var assetId = String(asset && asset.id || '').trim();
|
||||
var sizeLabel = uploadedFileSize(asset);
|
||||
try {
|
||||
if (type === 'image' && url) {
|
||||
return editor.chain().focus().setImage({ src: url, alt: title, title: title }).run() === true;
|
||||
if (type === 'image' && imageUrl) {
|
||||
return editor.chain().focus().setImage({ src: imageUrl, alt: title, title: title }).run() === true;
|
||||
}
|
||||
var href = markdownHref || url;
|
||||
if (href) {
|
||||
@@ -2681,10 +2690,34 @@ import { createSidebarPageSettingsRuntime } from './sidebar-page-settings-runtim
|
||||
selectSidebarFileTreeRow(fileRow, { ctrlKey: e.ctrlKey, metaKey: e.metaKey, shiftKey: e.shiftKey });
|
||||
var objectIdentity = readFileTreeObjectIdentity(fileRow);
|
||||
var workspacePath = readWorkspacePathFromRow(fileRow);
|
||||
var localRelativePath = fileTreeRowLocalRelativePath(fileRow) || String(workspacePath && (workspacePath.relativePath || workspacePath.localRelativePath) || '').trim();
|
||||
dispatchSidebarEvent('tree.filetree.open', { rowId: rowId, rowKind: rowKind, documentId: ownerDocumentId || null, assetId: assetId || null, assetType: assetType || null, objectIdentity: objectIdentity, workspacePath: workspacePath, workspaceId: resolveWorkspaceId(fileRow) });
|
||||
if (e.shiftKey || e.ctrlKey || e.metaKey) {
|
||||
return;
|
||||
}
|
||||
if ((rowKind === 'document' || rowKind === 'index' || rowKind === 'markdown') && isLocalOcrMarkdownPath(localRelativePath)) {
|
||||
document.documentElement.setAttribute('data-mnote-local-ocr-filetree-open', 'resource-tab');
|
||||
var ocrResourceInput = {
|
||||
path: localRelativePath,
|
||||
title: fileTreeRowTitleForShortcut(fileRow, localRelativePath),
|
||||
kind: 'markdown',
|
||||
objectIdentity: 'local-ocr:' + localRelativePath,
|
||||
assetId: 'local-ocr:' + localRelativePath,
|
||||
documentId: documentId || ownerDocumentId || null,
|
||||
workspaceId: resolveWorkspaceId(fileRow),
|
||||
sourceKind: 'local_folder',
|
||||
rootUri: currentRootUri(),
|
||||
resourceKind: 'markdown',
|
||||
workspacePath: workspacePath,
|
||||
paneRole: 'primary'
|
||||
};
|
||||
if (typeof window.__mnoteDocumentPaneRuntime?.openResourceInActiveTab === 'function') {
|
||||
void window.__mnoteDocumentPaneRuntime.openResourceInActiveTab(ocrResourceInput);
|
||||
} else {
|
||||
void openLocalResourceInActiveTab(ocrResourceInput);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ((rowKind === 'document' || rowKind === 'index' || rowKind === 'markdown') && documentId) {
|
||||
void recordNavigationRecent({
|
||||
kind: 'page',
|
||||
@@ -2839,6 +2872,11 @@ import { createSidebarPageSettingsRuntime } from './sidebar-page-settings-runtim
|
||||
renderPageSettingsPopover();
|
||||
return;
|
||||
}
|
||||
var localOcrCheckbox = closestAction(event.target, '[data-local-ocr-option-checkbox="autoEnabled"]');
|
||||
if (localOcrCheckbox instanceof HTMLInputElement) {
|
||||
void persistLocalOcrAutoPreference(localOcrCheckbox.checked);
|
||||
return;
|
||||
}
|
||||
var checkbox = closestAction(event.target, '[data-page-option-checkbox]');
|
||||
if (checkbox instanceof HTMLInputElement) {
|
||||
var key = checkbox.getAttribute('data-page-option-checkbox') || '';
|
||||
|
||||
Reference in New Issue
Block a user