Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: Add button to open missing asset blocks https://github.com/siyuan-note/siyuan/issues/8471

Daniel7699f30944fa
diff --git a/app/src/config/assets.ts b/app/src/config/assets.ts
index 72d467efc1..6d4ff82d65 100644
--- a/app/src/config/assets.ts
+++ b/app/src/config/assets.ts
@@ -17,6 +17,11 @@ import {App} from "../index";
import {disabledProtyle, onGet} from "../protyle/util/onGet";
import {removeLoading} from "../protyle/ui/initUI";
import {switchSettingPanelSubTab} from "./setting/mount";
+/// #if MOBILE
+import {openMobileFileById} from "../mobile/editor";
+/// #else
+import {BlockPanel} from "../block/Panel";
+/// #endif
/** 资源 Tab 侧栏 / 全局搜索索引文案 */
export const collectAssetsTabSearchStrings = (): string[] => [
@@ -204,6 +209,23 @@ const assets = {
event.preventDefault();
event.stopPropagation();
break;
+ } else if (type === "openFloat") {
+ const blockIDs = JSON.parse(target.getAttribute("data-id")) as string[];
+ if (blockIDs.length > 0) {
+ /// #if MOBILE
+ openMobileFileById(app, blockIDs[0], [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT, Constants.CB_GET_ROOTSCROLL]);
+ /// #else
+ window.siyuan.blockPanels.push(new BlockPanel({
+ app,
+ isBacklink: false,
+ targetElement: target,
+ refDefs: blockIDs.map(refID => ({refID})),
+ }));
+ /// #endif
+ }
+ event.preventDefault();
+ event.stopPropagation();
+ break;
} else if (type === "copy") {
if (target.parentElement.getAttribute("data-tab-type") === "unRefAV") {
writeText(`<div class="av" data-node-id="${Lute.NewNodeID()}" data-av-id="${target.parentElement.dataset.item}" data-type="NodeAttributeView" data-av-type="table"></div>`);
@@ -314,12 +336,14 @@ const assets = {
}
const mobile = isMobile();
data.forEach((item) => {
- const hasBlockPopover = type === "lostAssets" && item.blockIDs?.length > 0;
- const blockPopoverData = hasBlockPopover
- ? ` data-id="${escapeAttr(JSON.stringify(item.blockIDs))}"`
+ const blockPopoverHTML = type === "lostAssets" && item.blockIDs?.length > 0
+ ? `<span data-type="openFloat" data-id="${escapeAttr(JSON.stringify(item.blockIDs))}" class="ariaLabel b3-list-item__action" aria-label="${window.siyuan.languages.refPopover}">
+ <svg><use xlink:href="#iconPictureInPicture"></use></svg>
+ </span>`
: "";
html += `<li data-tab-type="${type}" data-item="${item.item}" class="b3-list-item${mobile ? "" : " b3-list-item--hide-action"}">
- <span class="b3-list-item__text${hasBlockPopover ? " popover__block" : ""}"${blockPopoverData}>${escapeHtml(item.name || item.item)}</span>
+ <span class="b3-list-item__text">${escapeHtml(item.name || item.item)}</span>
+ ${blockPopoverHTML}
<span data-type="copy" class="ariaLabel b3-list-item__action" aria-label="${type === "unRefAV" ? window.siyuan.languages.copyMirror : window.siyuan.languages.copy}">
<svg><use xlink:href="#iconCopy"></use></svg>
</span>