This commit is contained in:
Vanessa 2022-09-27 00:13:11 +08:00
parent 4e5a195290
commit 36c69ef9fc
11 changed files with 19 additions and 30 deletions

View file

@ -214,7 +214,7 @@ export const appearance = {
_send: () => {
const themeLight = (appearance.element.querySelector("#themeLight") as HTMLSelectElement).value;
const themeDark = (appearance.element.querySelector("#themeDark") as HTMLSelectElement).value;
const modeElementValue = parseInt((appearance.element.querySelector("#mode") as HTMLSelectElement).value)
const modeElementValue = parseInt((appearance.element.querySelector("#mode") as HTMLSelectElement).value);
fetchPost("/api/setting/setAppearance", {
icon: (appearance.element.querySelector("#icon") as HTMLSelectElement).value,
mode: modeElementValue === 2 ? window.siyuan.config.appearance.mode : modeElementValue,
@ -320,15 +320,15 @@ export const appearance = {
}
const themeLightElement = appearance.element.querySelector("#themeLight") as HTMLSelectElement;
if (themeLightElement) {
themeLightElement.innerHTML = genOptions(window.siyuan.config.appearance.lightThemes, window.siyuan.config.appearance.themeLight)
themeLightElement.innerHTML = genOptions(window.siyuan.config.appearance.lightThemes, window.siyuan.config.appearance.themeLight);
}
const themeDarkElement = appearance.element.querySelector("#themeDark") as HTMLSelectElement;
if (themeDarkElement) {
themeDarkElement.innerHTML = genOptions(window.siyuan.config.appearance.darkThemes, window.siyuan.config.appearance.themeDark)
themeDarkElement.innerHTML = genOptions(window.siyuan.config.appearance.darkThemes, window.siyuan.config.appearance.themeDark);
}
const iconElement = appearance.element.querySelector("#icon") as HTMLSelectElement;
if (iconElement) {
iconElement.innerHTML = genOptions(window.siyuan.config.appearance.icons, window.siyuan.config.appearance.icon)
iconElement.innerHTML = genOptions(window.siyuan.config.appearance.icons, window.siyuan.config.appearance.icon);
}
if (data.customCSS) {
fetchPost("/api/setting/getCustomCSS", {

View file

@ -337,9 +337,9 @@ export const bazaar = {
const type = target.getAttribute("data-type");
if (type === "open") {
/// #if !BROWSER
const dirName = target.parentElement.parentElement.getAttribute("data-bazaar")
const dirName = target.parentElement.parentElement.getAttribute("data-bazaar");
if (dirName === "icons" || dirName === "themes") {
shell.openPath(path.join(window.siyuan.config.system.confDir, "appearance", dirName, target.parentElement.getAttribute("data-name")))
shell.openPath(path.join(window.siyuan.config.system.confDir, "appearance", dirName, target.parentElement.getAttribute("data-name")));
} else {
shell.openPath(path.join(window.siyuan.config.system.dataDir, dirName, target.parentElement.getAttribute("data-name")));
}

View file

@ -82,7 +82,7 @@ export const initConfigSearch = (element: HTMLElement) => {
configIndex.map((item, index) => {
item.map((subItem) => {
if (!subItem) {
console.warn("Search config miss language: ", item, index)
console.warn("Search config miss language: ", item, index);
}
if (subItem && (inputValue.toLowerCase().indexOf(subItem) > -1 || subItem.toLowerCase().indexOf(inputValue) > -1)) {
indexList.push(index);

View file

@ -383,7 +383,7 @@ const renderPDF = (id: string) => {
});
fetchPost("/api/export/exportTempContent", {content: html}, (response) => {
window.siyuan.printWin.loadURL(response.data.url);
})
});
};
const getExportPath = (option: { type: string, id: string }, removeAssets?: boolean) => {

View file

@ -379,7 +379,7 @@ ${unicode2Emoji(emoji.unicode, true)}</button>`;
if (nodeElement) {
id = nodeElement.getAttribute("data-node-id");
}
let html = nodeElement.outerHTML;
const html = nodeElement.outerHTML;
// 自顶向下法新建文档后光标定位问题 https://github.com/siyuan-note/siyuan/issues/299
// QQ 拼音输入法自动补全需移除补全内容 https://github.com/siyuan-note/siyuan/issues/320
// 前后有标记符的情况 https://github.com/siyuan-note/siyuan/issues/2511

View file

@ -156,7 +156,7 @@ export const setFontStyle = (textElement: HTMLElement, textOption: ITextOption)
textElement.setAttribute("data-id", blockRefData[0]);
textElement.setAttribute("data-subtype", blockRefData[1]);
textElement.innerText = blockRefData[2];
}
};
if (textOption) {
switch (textOption.type) {
@ -214,7 +214,7 @@ export const hasSameTextStyle = (currentElement: HTMLElement, sideElement: HTMLE
currentElement.getAttribute("data-subtype") === sideElement.getAttribute("data-subtype") &&
currentElement.textContent === sideElement.textContent;
}
const blockRefData = textObj.color.split(Constants.ZWSP)
const blockRefData = textObj.color.split(Constants.ZWSP);
return blockRefData[0] === sideElement.getAttribute("data-id") &&
blockRefData[1] === sideElement.getAttribute("data-subtype") &&
blockRefData[2] === sideElement.textContent;

View file

@ -1,10 +1,6 @@
import {ToolbarItem} from "./ToolbarItem";
import * as dayjs from "dayjs";
import {updateTransaction} from "../wysiwyg/transaction";
import {hasClosestBlock, hasClosestByAttribute} from "../util/hasClosest";
import {hasNextSibling, hasPreviousSibling} from "../wysiwyg/getBlock";
import {mathRender} from "../markdown/mathRender";
import {fixTableRange, focusByRange} from "../util/selection";
export class InlineMath extends ToolbarItem {
public element: HTMLElement;
@ -24,7 +20,7 @@ export class InlineMath extends ToolbarItem {
if (!mathElement && range.startContainer.nodeType !== 3) {
const previousSibling = hasPreviousSibling(range.startContainer.childNodes[range.startOffset]) as HTMLElement;
if (previousSibling && previousSibling.getAttribute("data-type").indexOf("inline-math") > -1) {
mathElement = previousSibling
mathElement = previousSibling;
}
}
if (!mathElement && range.startOffset === range.startContainer.textContent.length && range.startContainer.nodeType === 3) {
@ -34,9 +30,9 @@ export class InlineMath extends ToolbarItem {
(item.nodeType == 3 && item.textContent === "")) {
// 是否仅选中数学公式
} else {
isMath = false
isMath = false;
}
})
});
if (isMath) {
const nextSibling = hasNextSibling(range.startContainer) as HTMLElement;
if (nextSibling && nextSibling.nodeType !== 3 && nextSibling.getAttribute("data-type").indexOf("inline-math") > -1) {

View file

@ -1,8 +1,5 @@
import {ToolbarItem} from "./ToolbarItem";
import {hasClosestBlock, hasClosestByAttribute} from "../util/hasClosest";
import {hasNextSibling, hasPreviousSibling} from "../wysiwyg/getBlock";
import {fixTableRange} from "../util/selection";
import {isArrayEqual} from "../../util/functions";
export class InlineMemo extends ToolbarItem {
public element: HTMLElement;

View file

@ -1,11 +1,7 @@
import {ToolbarItem} from "./ToolbarItem";
import {linkMenu} from "../../menus/protyle";
import {Constants} from "../../constants";
import * as dayjs from "dayjs";
import {updateTransaction} from "../wysiwyg/transaction";
import {hasClosestBlock, hasClosestByAttribute} from "../util/hasClosest";
import {hasNextSibling, hasPreviousSibling} from "../wysiwyg/getBlock";
import {fixTableRange, focusByRange, focusByWbr} from "../util/selection";
import {focusByRange, focusByWbr} from "../util/selection";
export class Link extends ToolbarItem {
public element: HTMLElement;
@ -28,7 +24,7 @@ export class Link extends ToolbarItem {
return;
}
const rangeString = range.toString().trim()
const rangeString = range.toString().trim();
let dataHref = "";
try {
const clipText = await navigator.clipboard.readText();

View file

@ -486,7 +486,7 @@ export class Toolbar {
} else if (item.tagName !== "BR") {
item.setAttribute("data-type", types.join(" "));
item.querySelectorAll("span").forEach(backslashItem => {
backslashItem.remove()
backslashItem.remove();
});
setFontStyle(item, textObj);
newNodes.push(item);
@ -598,7 +598,7 @@ export class Toolbar {
} else if (type === "block-ref") {
this.range.collapse(false);
} else if (type === "a") {
const aElement = newNodes[0] as HTMLElement
const aElement = newNodes[0] as HTMLElement;
if (aElement.textContent.replace(Constants.ZWSP, "") === "" || !aElement.getAttribute("data-href")) {
linkMenu(protyle, aElement, aElement.getAttribute("data-href") ? true : false);
} else {

View file

@ -688,7 +688,7 @@ export const keydown = (protyle: IProtyle, editorElement: HTMLElement) => {
previousSibling.classList.add("img--select");
} else if (previousSibling.getAttribute("data-type")?.indexOf("inline-math") > -1) {
// 数学公式相邻中有 zwsp,无法删除
previousSibling.after(document.createElement("wbr"))
previousSibling.after(document.createElement("wbr"));
const oldHTML = nodeElement.outerHTML;
range.startContainer.textContent = "";
previousSibling.remove();