- 只有删除当前预览的数据库时才清空预览区
- 渲染数据库始终不创建新的 JSON 文件
This commit is contained in:
Jeffrey Chen 2026-03-09 11:18:05 +08:00 committed by GitHub
parent 3289aecb7a
commit 39c3cea763
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 21 additions and 15 deletions

View file

@ -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} <b>${liElement.querySelector(".b3-list-item__text").textContent}</b>`, () => {
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 = `<li class="b3-list--empty">${window.siyuan.languages.emptyContent}</li>`;
} 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 += `<li data-tab-type="${type}" data-item="${item.item}" class="b3-list-item${isM ? "" : " b3-list-item--hide-action"}">
<span class="b3-list-item__text">${escapeHtml(item.name || item.item)}</span>
<span data-type="copy" class="ariaLabel b3-list-item__action" aria-label="${window.siyuan.languages[type === "unRefAV" ? "copyMirror" : "copy"]}">
<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>
${boxOpenHTML}

View file

@ -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";

View file

@ -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 {

View file

@ -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 {