This commit is contained in:
parent
95764092ec
commit
20e6445f86
2 changed files with 14 additions and 13 deletions
|
@ -351,14 +351,6 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran
|
|||
}
|
||||
return;
|
||||
}
|
||||
if (blockElement.getAttribute("data-type") === "NodeHeading") {
|
||||
turnsIntoTransaction({
|
||||
protyle: protyle,
|
||||
selectsElement: [blockElement],
|
||||
type: "Blocks2Ps",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!blockElement.previousElementSibling && blockElement.parentElement.getAttribute("data-type") === "NodeBlockquote") {
|
||||
range.insertNode(document.createElement("wbr"));
|
||||
const blockParentElement = blockElement.parentElement;
|
||||
|
@ -404,7 +396,15 @@ export const removeBlock = (protyle: IProtyle, blockElement: Element, range: Ran
|
|||
removeLi(protyle, blockElement, range, type === "Delete");
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockElement.getAttribute("data-type") === "NodeHeading") {
|
||||
turnsIntoTransaction({
|
||||
protyle: protyle,
|
||||
selectsElement: [blockElement],
|
||||
type: "Blocks2Ps",
|
||||
range: moveToPrevious(blockElement, range, type === "Delete")
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (blockElement.previousElementSibling && blockElement.previousElementSibling.classList.contains("protyle-breadcrumb__bar")) {
|
||||
return;
|
||||
}
|
||||
|
@ -558,14 +558,14 @@ export const moveToPrevious = (blockElement: Element, range: Range, isDelete: bo
|
|||
if (previousBlockElement) {
|
||||
const previousEditElement = getContenteditableElement(getLastBlock(previousBlockElement));
|
||||
if (previousEditElement) {
|
||||
setLastNodeRange(previousEditElement, range, false);
|
||||
return setLastNodeRange(previousEditElement, range, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// https://github.com/siyuan-note/siyuan/issues/10393
|
||||
export const removeImage = (imgSelectElement: Element, nodeElement:HTMLElement, range:Range, protyle:IProtyle) => {
|
||||
export const removeImage = (imgSelectElement: Element, nodeElement: HTMLElement, range: Range, protyle: IProtyle) => {
|
||||
const oldHTML = nodeElement.outerHTML;
|
||||
const imgPreviousSibling = hasPreviousSibling(imgSelectElement);
|
||||
if (imgPreviousSibling && imgPreviousSibling.textContent.endsWith(Constants.ZWSP)) {
|
||||
|
|
|
@ -856,6 +856,7 @@ export const turnsIntoTransaction = (options: {
|
|||
type: TTurnInto,
|
||||
level?: number,
|
||||
isContinue?: boolean,
|
||||
range?: Range
|
||||
}) => {
|
||||
let selectsElement: Element[] = options.selectsElement;
|
||||
let range: Range;
|
||||
|
@ -977,8 +978,8 @@ export const turnsIntoTransaction = (options: {
|
|||
highlightRender(options.protyle.wysiwyg.element);
|
||||
avRender(options.protyle.wysiwyg.element, options.protyle);
|
||||
blockRender(options.protyle, options.protyle.wysiwyg.element);
|
||||
if (range) {
|
||||
focusByWbr(options.protyle.wysiwyg.element, range);
|
||||
if (range || options.range) {
|
||||
focusByWbr(options.protyle.wysiwyg.element, range || options.range);
|
||||
} else {
|
||||
focusBlock(options.protyle.wysiwyg.element.querySelector(`[data-node-id="${selectsElement[0].getAttribute("data-node-id")}"]`));
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue