diff --git a/app/src/protyle/toolbar/Font.ts b/app/src/protyle/toolbar/Font.ts index b5351df88..0604faa08 100644 --- a/app/src/protyle/toolbar/Font.ts +++ b/app/src/protyle/toolbar/Font.ts @@ -111,12 +111,19 @@ export const fontMenu = (protyle: IProtyle) => { -`; + +
+`; element.addEventListener(getEventName(), function (event: Event) { let target = event.target as HTMLElement; while (target && !target.isEqualNode(element)) { + const dataType = target.getAttribute("data-type") if (target.tagName === "BUTTON") { - fontEvent(protyle, target.getAttribute("data-type"), target.style.backgroundColor || target.textContent); + if (dataType === "clear") { + protyle.toolbar.setInlineMark(protyle, "clear", "range", {type:"text"}); + } else { + fontEvent(protyle, dataType, target.style.backgroundColor || target.textContent); + } break; } target = target.parentElement; @@ -282,4 +289,5 @@ export const hasSameTextStyle = (currentElement: HTMLElement, sideElement: HTMLE textObj.color === sideElement.style.fontSize && backgroundColor === sideElement.style.backgroundColor; } + return true; // 清除字体样式会使用 "text" 作为标识 }; diff --git a/app/src/protyle/toolbar/index.ts b/app/src/protyle/toolbar/index.ts index ed33b0855..f8ef15194 100644 --- a/app/src/protyle/toolbar/index.ts +++ b/app/src/protyle/toolbar/index.ts @@ -338,9 +338,16 @@ export class Toolbar { const types = item.getAttribute("data-type").split(" "); if (type === "clear") { for (let i = 0; i < types.length; i++) { - if (["kbd", "text", "strong", "em", "u", "s", "mark", "sup", "sub", "code"].includes(types[i])) { - types.splice(i, 1); - i--; + if (textObj.type === "text") { + if ("text" === types[i]) { + types.splice(i, 1); + i--; + } + } else { + if (["kbd", "text", "strong", "em", "u", "s", "mark", "sup", "sub", "code"].includes(types[i])) { + types.splice(i, 1); + i--; + } } } } else {