diff --git a/app/src/config/image.ts b/app/src/config/image.ts
index be2f9f662..8da9e862f 100644
--- a/app/src/config/image.ts
+++ b/app/src/config/image.ts
@@ -168,7 +168,7 @@ export const image = {
code: 0
},
protyle: editor.protyle,
- action: [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML],
+ action: [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML, Constants.CB_GET_AV_NO_CREATE],
});
event.preventDefault();
event.stopPropagation();
@@ -198,27 +198,30 @@ export const image = {
const liElement = target.parentElement;
confirmDialog(window.siyuan.languages.deleteOpConfirm, `${window.siyuan.languages.delete} ${liElement.querySelector(".b3-list-item__text").textContent}`, () => {
if (liElement.getAttribute("data-tab-type") === "unRefAV") {
+ const id = liElement.getAttribute("data-item");
fetchPost("/api/av/removeUnusedAttributeView", {
- id: liElement.getAttribute("data-item"),
+ id,
}, () => {
if (liElement.parentElement.querySelectorAll("li").length === 1) {
liElement.parentElement.innerHTML = `
${window.siyuan.languages.emptyContent}`;
} else {
liElement.remove();
}
- onGet({
- data: {
+ if (editor.protyle.element.querySelector(`.av[data-av-id="${id}"]`)) {
+ onGet({
data: {
- content: "",
- id: Lute.NewNodeID(),
- rootID: Lute.NewNodeID(),
+ data: {
+ content: "",
+ id: Lute.NewNodeID(),
+ rootID: Lute.NewNodeID(),
+ },
+ msg: "",
+ code: 0
},
- msg: "",
- code: 0
- },
- protyle: editor.protyle,
- action: [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML],
- });
+ protyle: editor.protyle,
+ action: [Constants.CB_GET_HISTORY, Constants.CB_GET_HTML],
+ });
+ }
});
} else {
fetchPost("/api/asset/removeUnusedAsset", {
@@ -281,7 +284,7 @@ export const image = {
data.forEach((item) => {
html += `
${escapeHtml(item.name || item.item)}
-
+
${boxOpenHTML}
diff --git a/app/src/constants.ts b/app/src/constants.ts
index dd0734ac6..e4e95f76a 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -139,6 +139,7 @@ export abstract class Constants {
public static readonly CB_GET_HTML = "cb-get-html"; // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位
public static readonly CB_GET_HISTORY = "cb-get-history"; // 历史渲染
public static readonly CB_GET_OPENNEW = "cb-get-opennew"; // 编辑器只读后新建文件需为临时解锁状态 & https://github.com/siyuan-note/siyuan/issues/12197
+ public static readonly CB_GET_AV_NO_CREATE = "cb-get-av-no-create"; // 属性视图不自动创建
// localstorage
public static readonly LOCAL_ZOOM = "local-zoom";
diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts
index 77156fd62..e13f657c2 100644
--- a/app/src/protyle/render/av/render.ts
+++ b/app/src/protyle/render/av/render.ts
@@ -569,6 +569,7 @@ export const avRender = async (element: Element, protyle: IProtyle, cb?: (data:
viewID: e.getAttribute(Constants.CUSTOM_SY_AV_VIEW) || "",
query: resetData.query.trim(),
blockID: e.getAttribute("data-node-id"),
+ createIfNotExist: !protyle.block.action?.includes(Constants.CB_GET_AV_NO_CREATE),
});
data = response.data;
} else {
diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.ts
index 411d3b8e2..c0974b41e 100644
--- a/app/src/types/protyle.d.ts
+++ b/app/src/types/protyle.d.ts
@@ -39,7 +39,8 @@ type TProtyleAction = "cb-get-append" | // 向下滚动加载
"cb-get-rootscroll" | // 如果为 rootID 就滚动到指定位置,必有 rootID
"cb-get-html" | // 直接渲染,不需要再 /api/block/getDocInfo,否则搜索表格无法定位
"cb-get-history" | // 历史渲染
- "cb-get-opennew" // 编辑器只读后新建文件需为临时解锁状态 & https://github.com/siyuan-note/siyuan/issues/12197
+ "cb-get-opennew" | // 编辑器只读后新建文件需为临时解锁状态 & https://github.com/siyuan-note/siyuan/issues/12197
+ "cb-get-av-no-create" // 属性视图不自动创建
/** @link https://ld246.com/article/1588412297062 */
interface ILuteRender {