mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-09 08:44:20 +01:00
This commit is contained in:
parent
09f5569663
commit
385cc3b8e3
4 changed files with 17 additions and 6 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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, [{
|
||||
|
|
|
|||
|
|
@ -21,6 +21,9 @@ export class Options {
|
|||
classes: {
|
||||
preview: "",
|
||||
},
|
||||
click: {
|
||||
preventInsetEmptyBlock: false
|
||||
},
|
||||
hint: {
|
||||
delay: 200,
|
||||
emoji: {
|
||||
|
|
|
|||
9
app/src/types/protyle.d.ts
vendored
9
app/src/types/protyle.d.ts
vendored
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue