mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-12 23:21:23 +08:00
This commit is contained in:
parent
c164b19f48
commit
081cb8b1cc
@ -111,12 +111,19 @@ export const fontMenu = (protyle: IProtyle) => {
|
|||||||
<option ${fontSize === "40px" ? "selected" : ""} value="40px">40px</option>
|
<option ${fontSize === "40px" ? "selected" : ""} value="40px">40px</option>
|
||||||
<option ${fontSize === "48px" ? "selected" : ""} value="48px">48px</option>
|
<option ${fontSize === "48px" ? "selected" : ""} value="48px">48px</option>
|
||||||
</select>
|
</select>
|
||||||
</div>`;
|
</div>
|
||||||
|
<div class="fn__hr"></div>
|
||||||
|
<button class="b3-button b3-button--cancel" data-type="clear"><svg><use xlink:href="#iconTrashcan"></use></svg>${window.siyuan.languages.clearFontStyle}</button>`;
|
||||||
element.addEventListener(getEventName(), function (event: Event) {
|
element.addEventListener(getEventName(), function (event: Event) {
|
||||||
let target = event.target as HTMLElement;
|
let target = event.target as HTMLElement;
|
||||||
while (target && !target.isEqualNode(element)) {
|
while (target && !target.isEqualNode(element)) {
|
||||||
|
const dataType = target.getAttribute("data-type")
|
||||||
if (target.tagName === "BUTTON") {
|
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;
|
break;
|
||||||
}
|
}
|
||||||
target = target.parentElement;
|
target = target.parentElement;
|
||||||
@ -282,4 +289,5 @@ export const hasSameTextStyle = (currentElement: HTMLElement, sideElement: HTMLE
|
|||||||
textObj.color === sideElement.style.fontSize &&
|
textObj.color === sideElement.style.fontSize &&
|
||||||
backgroundColor === sideElement.style.backgroundColor;
|
backgroundColor === sideElement.style.backgroundColor;
|
||||||
}
|
}
|
||||||
|
return true; // 清除字体样式会使用 "text" 作为标识
|
||||||
};
|
};
|
||||||
|
@ -338,11 +338,18 @@ export class Toolbar {
|
|||||||
const types = item.getAttribute("data-type").split(" ");
|
const types = item.getAttribute("data-type").split(" ");
|
||||||
if (type === "clear") {
|
if (type === "clear") {
|
||||||
for (let i = 0; i < types.length; i++) {
|
for (let i = 0; i < types.length; 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])) {
|
if (["kbd", "text", "strong", "em", "u", "s", "mark", "sup", "sub", "code"].includes(types[i])) {
|
||||||
types.splice(i, 1);
|
types.splice(i, 1);
|
||||||
i--;
|
i--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
types.find((itemType, typeIndex) => {
|
types.find((itemType, typeIndex) => {
|
||||||
if (type === itemType) {
|
if (type === itemType) {
|
||||||
|
Loading…
Reference in New Issue
Block a user