mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-16 13:45:29 +01:00
This commit is contained in:
parent
9e2a0f59bc
commit
e92628d455
3 changed files with 8 additions and 3 deletions
|
|
@ -3,6 +3,7 @@ import {
|
|||
getNextBlock,
|
||||
getPreviousBlock,
|
||||
hasPreviousSibling,
|
||||
isContainerBlock,
|
||||
isNotEditBlock
|
||||
} from "../wysiwyg/getBlock";
|
||||
import {hasClosestBlock, hasClosestByAttribute, hasClosestByTag} from "./hasClosest";
|
||||
|
|
@ -725,7 +726,7 @@ export const focusBlock = (element: Element, parentElement?: HTMLElement, toStar
|
|||
parentElement.focus();
|
||||
} else {
|
||||
// li 下面为 hr、嵌入块、数学公式、iframe、音频、视频、图表渲染块等时递归处理
|
||||
if (element.classList.contains("li") || element.classList.contains("sb") || element.classList.contains("bq") || element.classList.contains("callout")) {
|
||||
if (isContainerBlock(element)) {
|
||||
return focusBlock(element.querySelector("[data-node-id]"), parentElement, toStart);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -110,8 +110,12 @@ export const getContenteditableElement = (element: Element): Element => {
|
|||
return undefined;
|
||||
};
|
||||
|
||||
export const isContainerBlock = (element: Element) => {
|
||||
return element.classList.contains("list") || element.classList.contains("li") || element.classList.contains("sb") || element.classList.contains("bq") || element.classList.contains("callout");
|
||||
};
|
||||
|
||||
export const isNotEditBlock = (element: Element) => {
|
||||
if (element.classList.contains("li") || element.classList.contains("sb") || element.classList.contains("bq") || element.classList.contains("callout")) {
|
||||
if (isContainerBlock(element)) {
|
||||
let hasEditable = false;
|
||||
Array.from(element.querySelectorAll("[data-node-id]")).find(item => {
|
||||
if (!isNotEditBlock(item)) {
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ export const removeBlock = async (protyle: IProtyle, blockElement: Element, rang
|
|||
}
|
||||
const blockType = blockElement.getAttribute("data-type");
|
||||
// 空代码块直接删除
|
||||
if (blockType === "NodeCodeBlock" && getContenteditableElement(blockElement).textContent.trim() === "") {
|
||||
if (blockType === "NodeCodeBlock" && getContenteditableElement(blockElement)?.textContent.trim() === "") {
|
||||
blockElement.classList.add("protyle-wysiwyg--select");
|
||||
removeBlock(protyle, blockElement, range, type);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue