mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-01 22:38:49 +01:00
This commit is contained in:
parent
91edc8e254
commit
c03b24fc01
1 changed files with 5 additions and 2 deletions
|
|
@ -25,21 +25,24 @@ export class InlineMath extends ToolbarItem {
|
|||
}
|
||||
if (!mathElement && range.startOffset === range.startContainer.textContent.length && range.startContainer.nodeType === 3) {
|
||||
let isMath = true;
|
||||
let hasMath = false;
|
||||
// https://github.com/siyuan-note/siyuan/issues/6007
|
||||
range.cloneContents().childNodes.forEach((item: HTMLElement) => {
|
||||
if ((item.nodeType !== 3 && item.getAttribute("data-type").indexOf("inline-math") > -1) ||
|
||||
(item.nodeType == 3 && item.textContent === "")) {
|
||||
// 是否仅选中数学公式
|
||||
hasMath = true;
|
||||
} else {
|
||||
isMath = false;
|
||||
}
|
||||
});
|
||||
if (isMath) {
|
||||
if (isMath && hasMath) {
|
||||
const nextSibling = hasNextSibling(range.startContainer) as HTMLElement;
|
||||
if (nextSibling && nextSibling.nodeType !== 3 && nextSibling.getAttribute("data-type").indexOf("inline-math") > -1) {
|
||||
mathElement = nextSibling;
|
||||
} else {
|
||||
const previousSibling = hasPreviousSibling(range.startContainer) as HTMLElement;
|
||||
if (previousSibling && previousSibling.nodeType !== 3 && previousSibling.getAttribute("data-type").indexOf("inline-math") > -1) {
|
||||
if (range.startOffset === 0 && previousSibling && previousSibling.nodeType !== 3 && previousSibling.getAttribute("data-type").indexOf("inline-math") > -1) {
|
||||
mathElement = previousSibling;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue