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