mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-13 10:44:20 +01:00
This commit is contained in:
parent
9729b72a9e
commit
bfecf5160a
2 changed files with 18 additions and 9 deletions
|
|
@ -368,7 +368,7 @@ export const setFontStyle = (textElement: HTMLElement, textOption: ITextOption)
|
|||
export const hasSameTextStyle = (currentElement: HTMLElement, sideElement: HTMLElement, textObj: ITextOption) => {
|
||||
if (!textObj) {
|
||||
// https://github.com/siyuan-note/siyuan/issues/14019
|
||||
if (currentElement.nodeType !== 3 && sideElement.nodeType !== 3 &&
|
||||
if (currentElement && currentElement.nodeType !== 3 && sideElement.nodeType !== 3 &&
|
||||
// 当为 span 时,都经过 isArrayEqual 判断
|
||||
sideElement.style.color === currentElement.style.color &&
|
||||
sideElement.style.webkitTextFillColor === currentElement.style.webkitTextFillColor &&
|
||||
|
|
@ -384,7 +384,7 @@ export const hasSameTextStyle = (currentElement: HTMLElement, sideElement: HTMLE
|
|||
return false;
|
||||
}
|
||||
if (textObj.type === "id") {
|
||||
if (currentElement.nodeType !== 3) {
|
||||
if (currentElement && currentElement.nodeType !== 3) {
|
||||
return currentElement.getAttribute("data-id") === sideElement.getAttribute("data-id") &&
|
||||
currentElement.getAttribute("data-subtype") === sideElement.getAttribute("data-subtype") &&
|
||||
currentElement.textContent === sideElement.textContent;
|
||||
|
|
@ -396,7 +396,7 @@ export const hasSameTextStyle = (currentElement: HTMLElement, sideElement: HTMLE
|
|||
}
|
||||
|
||||
if (textObj.type === "file-annotation-ref") {
|
||||
if (currentElement.nodeType !== 3) {
|
||||
if (currentElement && currentElement.nodeType !== 3) {
|
||||
return currentElement.getAttribute("data-id") === sideElement.getAttribute("data-id") &&
|
||||
currentElement.textContent === sideElement.textContent;
|
||||
}
|
||||
|
|
@ -409,7 +409,7 @@ export const hasSameTextStyle = (currentElement: HTMLElement, sideElement: HTMLE
|
|||
let textShadow = "";
|
||||
let backgroundColor = "";
|
||||
let fontSize = "";
|
||||
if (currentElement.nodeType !== 3) {
|
||||
if (currentElement && currentElement.nodeType !== 3) {
|
||||
color = currentElement.style.color;
|
||||
webkitTextFillColor = currentElement.style.webkitTextFillColor;
|
||||
webkitTextStroke = currentElement.style.webkitTextStroke;
|
||||
|
|
|
|||
|
|
@ -242,12 +242,21 @@ export class Toolbar {
|
|||
}
|
||||
const rangeTypes = this.getCurrentType(this.range);
|
||||
|
||||
// https://github.com/siyuan-note/siyuan/issues/6501
|
||||
// https://github.com/siyuan-note/siyuan/issues/12877
|
||||
if (rangeTypes.length === 1 &&
|
||||
["block-ref", "virtual-block-ref", "file-annotation-ref", "a", "inline-memo", "inline-math", "tag"].includes(rangeTypes[0]) && type === "clear") {
|
||||
return;
|
||||
if (rangeTypes.length === 1) {
|
||||
// https://github.com/siyuan-note/siyuan/issues/6501
|
||||
// https://github.com/siyuan-note/siyuan/issues/12877
|
||||
if (["block-ref", "virtual-block-ref", "file-annotation-ref", "a", "inline-memo", "inline-math", "tag"].includes(rangeTypes[0]) && type === "clear") {
|
||||
return;
|
||||
}
|
||||
// https://github.com/siyuan-note/siyuan/issues/14534
|
||||
if (rangeTypes[0] === "text" && type === "text" && textObj && this.range.startContainer.nodeType === 3 && this.range.startContainer.isSameNode(this.range.endContainer)) {
|
||||
const selectParentElement = this.range.startContainer.parentElement;
|
||||
if (selectParentElement && hasSameTextStyle(null, selectParentElement, textObj)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const selectText = this.range.toString();
|
||||
fixTableRange(this.range);
|
||||
let previousElement: HTMLElement;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue