mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-19 02:21:38 +08:00
This commit is contained in:
parent
7dd4fd9260
commit
56ee07f703
@ -17,7 +17,7 @@ import {isIPad, setStorageVal} from "../util/compatibility";
|
|||||||
import {mathRender} from "../render/mathRender";
|
import {mathRender} from "../render/mathRender";
|
||||||
import {isMobile} from "../../util/functions";
|
import {isMobile} from "../../util/functions";
|
||||||
import {processRender} from "../util/processCode";
|
import {processRender} from "../util/processCode";
|
||||||
import {hasClosestByClassName} from "../util/hasClosest";
|
import {hasClosestByAttribute, hasClosestByClassName} from "../util/hasClosest";
|
||||||
|
|
||||||
export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle) => {
|
export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle) => {
|
||||||
if (hasClosestByClassName(blockElement, "protyle-wysiwyg__embed")) {
|
if (hasClosestByClassName(blockElement, "protyle-wysiwyg__embed")) {
|
||||||
@ -198,7 +198,19 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
|
|||||||
range.insertNode(wbrElement);
|
range.insertNode(wbrElement);
|
||||||
const html = blockElement.outerHTML;
|
const html = blockElement.outerHTML;
|
||||||
wbrElement.remove();
|
wbrElement.remove();
|
||||||
|
|
||||||
if (range.toString() !== "") {
|
if (range.toString() !== "") {
|
||||||
|
// 选中数学公式后回车取消选中 https://github.com/siyuan-note/siyuan/issues/12637#issuecomment-2381106949
|
||||||
|
const mathElement = hasClosestByAttribute(range.startContainer, "data-type", "inline-math")
|
||||||
|
if (mathElement) {
|
||||||
|
const nextSibling = hasNextSibling(mathElement);
|
||||||
|
if (nextSibling) {
|
||||||
|
range = getSelection().getRangeAt(0)
|
||||||
|
range.setEnd(nextSibling, nextSibling.textContent.startsWith(Constants.ZWSP) ? 1 : 0);
|
||||||
|
range.collapse(false);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
range.extractContents();
|
range.extractContents();
|
||||||
}
|
}
|
||||||
if (editableElement.lastChild) {
|
if (editableElement.lastChild) {
|
||||||
|
Loading…
Reference in New Issue
Block a user