Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/11302

Vanessa523d8d762bf6
diff --git a/app/src/constants.ts b/app/src/constants.ts
index 539f3e85eb..48ee9aaca2 100644
--- a/app/src/constants.ts
+++ b/app/src/constants.ts
@@ -93,6 +93,7 @@ export abstract class Constants {
public static readonly CB_GET_ROOTSCROLL = "cb-get-rootscroll"; // 如果为 rootID 就滚动到指定位置,必有 rootID
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"; // 编辑器只读后新建文件需为临时解锁状态
// localstorage
public static readonly LOCAL_ZOOM = "local-zoom";
diff --git a/app/src/protyle/hint/index.ts b/app/src/protyle/hint/index.ts
index ba7d9eae7c..1c56d1d23f 100644
--- a/app/src/protyle/hint/index.ts
+++ b/app/src/protyle/hint/index.ts
@@ -624,12 +624,12 @@ ${genHintItemHTML(item)}
}, () => {
insertHTML(`<span data-type="block-ref" data-id="${newSubDocId}" data-subtype="d">Untitled</span>`, protyle);
/// #if MOBILE
- openMobileFileById(protyle.app, newSubDocId, [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]);
+ openMobileFileById(protyle.app, newSubDocId, [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]);
/// #else
openFileById({
app: protyle.app,
id: newSubDocId,
- action: [Constants.CB_GET_HL, Constants.CB_GET_CONTEXT]
+ action: [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]
});
/// #endif
});
diff --git a/app/src/protyle/util/onGet.ts b/app/src/protyle/util/onGet.ts
index 691ce1098c..629fa6e0c2 100644
--- a/app/src/protyle/util/onGet.ts
+++ b/app/src/protyle/util/onGet.ts
@@ -18,6 +18,7 @@ import {showMessage} from "../../dialog/message";
import {avRender} from "../render/av/render";
import {hideTooltip} from "../../dialog/tooltip";
import {stickyRow} from "../render/av/row";
+import {updateReadonly as updateReadonlyMethod} from "../breadcrumb/action";
export const onGet = (options: {
data: IWebSocketData,
@@ -206,6 +207,9 @@ const setHTML = (options: {
}
protyle.element.removeAttribute("disabled-forever");
setReadonlyByConfig(protyle, updateReadonly);
+ if (options.action.includes(Constants.CB_GET_OPENNEW)) {
+ updateReadonlyMethod(protyle.breadcrumb.element.parentElement.querySelector('.block__icon[data-type="readonly"]'), protyle);
+ }
}
focusElementById(protyle, options.action, options.scrollAttr);
diff --git a/app/src/util/newFile.ts b/app/src/util/newFile.ts
index 31c587dbfc..9b3542d3f0 100644
--- a/app/src/util/newFile.ts
+++ b/app/src/util/newFile.ts
@@ -107,10 +107,10 @@ export const newFile = (optios: {
openFileById({
app: optios.app,
id: response.data,
- action: [Constants.CB_GET_CONTEXT]
+ action: [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]
});
/// #else
- openMobileFileById(optios.app, response.data, [Constants.CB_GET_CONTEXT]);
+ openMobileFileById(optios.app, response.data, [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]);
/// #endif
});
} else {
@@ -128,10 +128,10 @@ export const newFile = (optios: {
openFileById({
app: optios.app,
id: response.data,
- action: [Constants.CB_GET_CONTEXT]
+ action: [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]
});
/// #else
- openMobileFileById(optios.app, response.data, [Constants.CB_GET_CONTEXT]);
+ openMobileFileById(optios.app, response.data, [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]);
/// #endif
});
});
@@ -151,10 +151,10 @@ export const newFile = (optios: {
openFileById({
app: optios.app,
id: response.data,
- action: [Constants.CB_GET_CONTEXT]
+ action: [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]
});
/// #else
- openMobileFileById(optios.app, response.data, [Constants.CB_GET_CONTEXT]);
+ openMobileFileById(optios.app, response.data, [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]);
/// #endif
});
return;
@@ -173,9 +173,9 @@ export const newFile = (optios: {
sorts: optios.paths
}, () => {
/// #if !MOBILE
- openFileById({app: optios.app, id, action: [Constants.CB_GET_CONTEXT]});
+ openFileById({app: optios.app, id, action: [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]});
/// #else
- openMobileFileById(optios.app, id, [Constants.CB_GET_CONTEXT]);
+ openMobileFileById(optios.app, id, [Constants.CB_GET_CONTEXT, Constants.CB_GET_OPENNEW]);
/// #endif
});
}