mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
This commit is contained in:
parent
9fc6f91654
commit
59169d0479
10 changed files with 28 additions and 6 deletions
|
@ -584,6 +584,7 @@
|
|||
"closeTab": "Close current Tab",
|
||||
"keymap": "Keymap",
|
||||
"clearFontStyle": "Clear Style",
|
||||
"clearInline": "Clear inline elements",
|
||||
"fontStyle": "Font Effects",
|
||||
"font": "Font",
|
||||
"folder": "Folder",
|
||||
|
|
|
@ -584,6 +584,7 @@
|
|||
"closeTab": "Cerrar pestaña actual",
|
||||
"keymap": "Mapa de teclas",
|
||||
"clearFontStyle": "Limpiar estilo",
|
||||
"clearInline": "Borrar elementos en línea",
|
||||
"fontStyle": "Efectos de fuentes",
|
||||
"font": "Fuente",
|
||||
"folder": "Carpeta",
|
||||
|
|
|
@ -584,6 +584,7 @@
|
|||
"closeTab": "Fermer l'onglet actuel",
|
||||
"keymap": "Raccourci",
|
||||
"clearFontStyle": "Effacer Styles",
|
||||
"clearInline": "Effacer les éléments en ligne",
|
||||
"fontStyle": "Effets de fonte",
|
||||
"font": "Police",
|
||||
"folder": "Dossier",
|
||||
|
|
|
@ -584,6 +584,7 @@
|
|||
"closeTab": "關閉當前分頁",
|
||||
"keymap": "快速鍵",
|
||||
"clearFontStyle": "清除樣式",
|
||||
"clearInline": "清除行內元素",
|
||||
"fontStyle": "字體效果",
|
||||
"font": "字體",
|
||||
"folder": "資料夾",
|
||||
|
|
|
@ -584,6 +584,7 @@
|
|||
"closeTab": "关闭当前页签",
|
||||
"keymap": "快捷键",
|
||||
"clearFontStyle": "清除样式",
|
||||
"clearInline": "清除行内元素",
|
||||
"fontStyle": "字体效果",
|
||||
"font": "字体",
|
||||
"folder": "文件夹",
|
||||
|
|
|
@ -217,7 +217,7 @@ export abstract class Constants {
|
|||
check: {default: "⌘L", custom: "⌘L"},
|
||||
table: {default: "⌘O", custom: "⌘O"},
|
||||
code: {default: "⇧⌘K", custom: "⇧⌘K"},
|
||||
clearFontStyle: {default: "⌘\\", custom: "⌘\\"},
|
||||
clearInline: {default: "⌘\\", custom: "⌘\\"},
|
||||
},
|
||||
heading: {
|
||||
paragraph: {default: "⌥⌘0", custom: "⌥⌘0"},
|
||||
|
|
|
@ -232,7 +232,7 @@ export const fontEvent = (protyle: IProtyle, nodeElements: Element[], type?: str
|
|||
e.style.fontSize = color;
|
||||
}
|
||||
});
|
||||
focusBlock(nodeElements[0]);
|
||||
focusByRange(protyle.toolbar.range);
|
||||
} else {
|
||||
if (type === "clear") {
|
||||
protyle.toolbar.setInlineMark(protyle, "clear", "range", {type: "text"});
|
||||
|
@ -359,6 +359,15 @@ export const hasSameTextStyle = (currentElement: HTMLElement, sideElement: HTMLE
|
|||
backgroundColor = currentElement.style.backgroundColor;
|
||||
fontSize = currentElement.style.fontSize;
|
||||
}
|
||||
if (textObj.type === "text") {
|
||||
// 清除样式
|
||||
return color === sideElement.style.color &&
|
||||
webkitTextFillColor === sideElement.style.webkitTextFillColor &&
|
||||
webkitTextStroke === sideElement.style.webkitTextStroke &&
|
||||
textShadow === sideElement.style.textShadow &&
|
||||
fontSize === sideElement.style.fontSize &&
|
||||
backgroundColor === sideElement.style.backgroundColor;
|
||||
}
|
||||
if (textObj.type === "color") {
|
||||
return textObj.color === sideElement.style.color &&
|
||||
webkitTextFillColor === sideElement.style.webkitTextFillColor &&
|
||||
|
|
|
@ -344,7 +344,7 @@ export class Toolbar {
|
|||
return true;
|
||||
}
|
||||
});
|
||||
if (rangeTypes.length === 0) {
|
||||
if (rangeTypes.length === 0 || type === "clear") {
|
||||
newNodes.push(document.createTextNode(Constants.ZWSP));
|
||||
} else {
|
||||
// 遇到以下类型结尾不应继承 https://github.com/siyuan-note/siyuan/issues/7200
|
||||
|
@ -393,6 +393,14 @@ export class Toolbar {
|
|||
}
|
||||
newNodes.push(document.createTextNode(item.textContent));
|
||||
} else {
|
||||
if (selectText && type === "clear" && textObj && textObj.type === "text") {
|
||||
// 选中内容中没有样式需要清除时直接返回,否则清除粗体中部分内容会报错
|
||||
if (item.style.color === "" && item.style.webkitTextFillColor === "" && item.style.webkitTextStroke === "" && item.style.textShadow === "" && item.style.backgroundColor === "" && item.style.fontSize === "") {
|
||||
item.setAttribute("data-type", types.join(" "));
|
||||
newNodes.push(item);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (type === "clear") {
|
||||
item.style.color = "";
|
||||
item.style.webkitTextFillColor = "";
|
||||
|
|
|
@ -235,8 +235,8 @@ export class Options {
|
|||
tipPosition: "n",
|
||||
}, {
|
||||
name: "clear",
|
||||
lang: "clearFontStyle",
|
||||
hotkey: window.siyuan.config.keymap.editor.insert.clearFontStyle.custom,
|
||||
lang: "clearInline",
|
||||
hotkey: window.siyuan.config.keymap.editor.insert.clearInline.custom,
|
||||
icon: "iconClear",
|
||||
tipPosition: "n",
|
||||
}, {
|
||||
|
|
|
@ -1290,7 +1290,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
|
|||
if (matchHotKey(window.siyuan.config.keymap.editor.insert.lastUsed.custom, event)) {
|
||||
protyle.toolbar.range = range;
|
||||
let selectElements: Element[] = [];
|
||||
if (selectText === "") {
|
||||
if (selectText === "" && protyle.toolbar.getCurrentType(range).length === 0) {
|
||||
selectElements = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select"));
|
||||
if (selectElements.length === 0) {
|
||||
selectElements = [nodeElement];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue