mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-08 01:38:50 +01:00
This commit is contained in:
parent
a9651ad07e
commit
9117bf9ad1
4 changed files with 16 additions and 12 deletions
|
|
@ -88,7 +88,7 @@ export class Bookmark extends Model {
|
|||
},
|
||||
rightClick: (element: HTMLElement, event: MouseEvent) => {
|
||||
window.siyuan.menus.menu.remove();
|
||||
const id = element.getAttribute("data-node-id")
|
||||
const id = element.getAttribute("data-node-id");
|
||||
if (!id) {
|
||||
window.siyuan.menus.menu.append(new MenuItem({
|
||||
label: window.siyuan.languages.rename,
|
||||
|
|
@ -129,7 +129,7 @@ export class Bookmark extends Model {
|
|||
icon: "iconTrashcan",
|
||||
label: window.siyuan.languages.remove,
|
||||
click: () => {
|
||||
const bookmark = (id ? element.parentElement.previousElementSibling : element).querySelector(".b3-list-item__text").textContent
|
||||
const bookmark = (id ? element.parentElement.previousElementSibling : element).querySelector(".b3-list-item__text").textContent;
|
||||
confirmDialog(window.siyuan.languages.delete, `${window.siyuan.languages.confirmDelete} <b>${escapeHtml(bookmark)}</b>?`, () => {
|
||||
if (id) {
|
||||
fetchPost("/api/attr/setBlockAttrs", {id, attrs: {bookmark: ""}}, () => {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ import {code160to32} from "../util/code160to32";
|
|||
export class Title {
|
||||
public element: HTMLElement;
|
||||
public editElement: HTMLElement;
|
||||
private timeout: number
|
||||
private timeout: number;
|
||||
|
||||
constructor(protyle: IProtyle) {
|
||||
this.element = document.createElement("div");
|
||||
|
|
@ -229,7 +229,7 @@ export class Title {
|
|||
}
|
||||
|
||||
private rename(protyle: IProtyle) {
|
||||
clearTimeout(this.timeout)
|
||||
clearTimeout(this.timeout);
|
||||
if (!validateName(this.editElement.textContent)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -240,8 +240,8 @@ export class Title {
|
|||
path: protyle.path,
|
||||
title: fileName,
|
||||
});
|
||||
this.setTitle(fileName)
|
||||
}, Constants.TIMEOUT_INPUT)
|
||||
this.setTitle(fileName);
|
||||
}, Constants.TIMEOUT_INPUT);
|
||||
}
|
||||
|
||||
private renderMenu(protyle: IProtyle, iconElement: Element, position: { x: number, y: number }) {
|
||||
|
|
|
|||
|
|
@ -172,9 +172,9 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
} else if (previousElement) {
|
||||
// https://github.com/siyuan-note/siyuan/issues/3913
|
||||
const foldElement = hasTopClosestByAttribute(previousElement, "fold", "1")
|
||||
const foldElement = hasTopClosestByAttribute(previousElement, "fold", "1");
|
||||
if (foldElement && (foldElement.classList.contains("sb") || foldElement.classList.contains("bq"))) {
|
||||
previousElement = foldElement
|
||||
previousElement = foldElement;
|
||||
}
|
||||
}
|
||||
} else if (protyle.title && (protyle.wysiwyg.element.firstElementChild.getAttribute("data-eof") === "true" ||
|
||||
|
|
@ -485,7 +485,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
// https://github.com/siyuan-note/siyuan/issues/5185
|
||||
if (range.startOffset === 0 && range.startContainer.nodeType === 3) {
|
||||
const previousSibling = hasPreviousSibling(range.startContainer) as HTMLElement
|
||||
const previousSibling = hasPreviousSibling(range.startContainer) as HTMLElement;
|
||||
if (previousSibling && previousSibling.nodeType !== 3 && previousSibling.getAttribute("data-type") === "inline-math") {
|
||||
protyle.toolbar.showRender(protyle, previousSibling);
|
||||
return;
|
||||
|
|
@ -550,7 +550,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
if (previousElement) {
|
||||
previousElement = getLastBlock(previousElement) as HTMLElement;
|
||||
if (previousElement) {
|
||||
previousElement = hasClosestByAttribute(previousElement, "fold", "1") as HTMLElement
|
||||
previousElement = hasClosestByAttribute(previousElement, "fold", "1") as HTMLElement;
|
||||
if (previousElement && previousElement.getAttribute("data-type") !== "NodeListItem") {
|
||||
// 遇到折叠块
|
||||
focusBlock(previousElement, undefined, true);
|
||||
|
|
@ -581,7 +581,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
}
|
||||
}
|
||||
if (event.key === "ArrowDown") {
|
||||
const foldElement = hasClosestByAttribute(range.startContainer, "fold", "1")
|
||||
const foldElement = hasClosestByAttribute(range.startContainer, "fold", "1");
|
||||
if (foldElement) {
|
||||
let nextElement = getNextBlock(foldElement) as HTMLElement;
|
||||
if (nextElement) {
|
||||
|
|
@ -645,6 +645,10 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
} else if (position.end === editElement.textContent.length - 1 && nodeElement.getAttribute("data-type") === "NodeCodeBlock") {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
const currentNode = range.startContainer.childNodes[range.startOffset - 1] as HTMLElement;
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ export const breakList = (protyle: IProtyle, blockElement: Element, range: Range
|
|||
}
|
||||
});
|
||||
|
||||
const parentId = listItemElement.parentElement.getAttribute("data-node-id")
|
||||
const parentId = listItemElement.parentElement.getAttribute("data-node-id");
|
||||
if (listItemElement.parentElement.childElementCount === 2) {
|
||||
undoOperations.splice(0, 0, {
|
||||
id: parentId,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue