Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/15303

Vanessa385cc3b8e3ba
diff --git a/app/src/layout/dock/Backlink.ts b/app/src/layout/dock/Backlink.ts
index 04e4e1e486..5c29ffb128 100644
--- a/app/src/layout/dock/Backlink.ts
+++ b/app/src/layout/dock/Backlink.ts
@@ -458,6 +458,9 @@ export class Backlink extends Model {
liElement.after(editorElement);
const editor = new Protyle(this.app, editorElement, {
blockId: docId,
+ click: {
+ preventInsetEmptyBlock: true
+ },
backlinkData: isMention ? response.data.backmentions : response.data.backlinks,
render: {
background: false,
diff --git a/app/src/protyle/ui/initUI.ts b/app/src/protyle/ui/initUI.ts
index a994da9b7b..8e06c70fa1 100644
--- a/app/src/protyle/ui/initUI.ts
+++ b/app/src/protyle/ui/initUI.ts
@@ -141,9 +141,11 @@ export const initUI = (protyle: IProtyle) => {
const range = document.createRange();
if (event.y > lastRect.bottom) {
const lastEditElement = getContenteditableElement(getLastBlock(protyle.wysiwyg.element.lastElementChild));
- if (!lastEditElement ||
- (protyle.wysiwyg.element.lastElementChild.getAttribute("data-type") !== "NodeParagraph" && protyle.wysiwyg.element.getAttribute("data-doc-type") !== "NodeListItem" && !protyle.options.backlinkData) ||
- (protyle.wysiwyg.element.lastElementChild.getAttribute("data-type") === "NodeParagraph" && getContenteditableElement(lastEditElement).innerHTML !== "")) {
+ if (!protyle.options.click.preventInsetEmptyBlock && (
+ !lastEditElement ||
+ (protyle.wysiwyg.element.lastElementChild.getAttribute("data-type") !== "NodeParagraph" && protyle.wysiwyg.element.getAttribute("data-doc-type") !== "NodeListItem") ||
+ (protyle.wysiwyg.element.lastElementChild.getAttribute("data-type") === "NodeParagraph" && getContenteditableElement(lastEditElement).innerHTML !== ""))
+ ) {
const emptyElement = genEmptyElement(false, false);
protyle.wysiwyg.element.insertAdjacentElement("beforeend", emptyElement);
transaction(protyle, [{
diff --git a/app/src/protyle/util/Options.ts b/app/src/protyle/util/Options.ts
index 1ea754ea24..5b2c76724d 100644
--- a/app/src/protyle/util/Options.ts
+++ b/app/src/protyle/util/Options.ts
@@ -21,6 +21,9 @@ export class Options {
classes: {
preview: "",
},
+ click: {
+ preventInsetEmptyBlock: false
+ },
hint: {
delay: 200,
emoji: {
diff --git a/app/src/types/protyle.d.ts b/app/src/types/protyle.d.ts
index c4ebdea18b..333f438ee0 100644
--- a/app/src/types/protyle.d.ts
+++ b/app/src/types/protyle.d.ts
@@ -412,8 +412,8 @@ interface IHintData {
id?: string;
html: string;
value: string;
- filter?: string[]
- focus?: boolean
+ filter?: string[];
+ focus?: boolean;
}
interface IHintExtend {
@@ -478,7 +478,10 @@ interface IProtyleOptions {
classes?: {
preview?: string;
};
-
+ click?: {
+ /** 点击末尾是否阻止插入新块 */
+ preventInsetEmptyBlock?: boolean
+ }
/** 编辑器异步渲染完成后的回调方法 */
after?(protyle: import("../protyle").Protyle): void;
}