From e58287c4504bbf2ce3de382f530076f9544f6485 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 14 Sep 2022 09:49:42 +0800 Subject: [PATCH] :sparkles: https://github.com/siyuan-note/siyuan/issues/2911 --- app/src/protyle/toolbar/index.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index 343441c5b..db67c297b 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -236,6 +236,7 @@ export class Toolbar { if (!nodeElement) { return; } + const rangeTypes = this.getCurrentType(); let previousElement: Element let nextElement: Element let previousIndex: number @@ -286,8 +287,11 @@ export class Toolbar { } const actionBtn = action === "toolbar" ? this.element.querySelector(`[data-type="${type}"]`) : undefined; const newNodes: Node[] = []; - if (action === "remove" || actionBtn?.classList.contains("protyle-toolbar__item--current")) { - actionBtn.classList.remove("protyle-toolbar__item--current"); + if (action === "remove" || actionBtn?.classList.contains("protyle-toolbar__item--current") || + (action === "range" && rangeTypes.length > 0 && rangeTypes.includes(type))) { + if (actionBtn) { + actionBtn.classList.remove("protyle-toolbar__item--current"); + } let removeIndex = 0 contents.childNodes.forEach((item: HTMLElement, index) => { if (item.tagName === "WBR") { @@ -322,7 +326,9 @@ export class Toolbar { removeIndex++ }); } else { - this.element.querySelector(`[data-type="${type}"]`).classList.add("protyle-toolbar__item--current"); + if (!this.element.classList.contains("fn__none")) { + this.element.querySelector(`[data-type="${type}"]`).classList.add("protyle-toolbar__item--current"); + } let addIndex = 0 contents.childNodes.forEach((item: HTMLElement, index) => { if (item.nodeType === 3) {