Vanessa 2025-07-18 10:25:14 +08:00
parent 09f5569663
commit 385cc3b8e3
4 changed files with 17 additions and 6 deletions

View file

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

View file

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

View file

@ -21,6 +21,9 @@ export class Options {
classes: {
preview: "",
},
click: {
preventInsetEmptyBlock: false
},
hint: {
delay: 200,
emoji: {

View file

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