This commit is contained in:
Vanessa 2024-11-14 23:21:55 +08:00
parent 4670092d22
commit cb2560ffda
6 changed files with 22 additions and 23 deletions

View file

@ -732,7 +732,7 @@ export abstract class Constants {
"tag", "tag",
"inline-math", "inline-math",
"inline-memo", "inline-memo",
] ];
// Google Analytics 事件 // Google Analytics 事件
public static readonly ANALYTICS_EVT_ON_GET_CONFIG: string = "siyuan.onGetConfig"; public static readonly ANALYTICS_EVT_ON_GET_CONFIG: string = "siyuan.onGetConfig";

View file

@ -201,7 +201,7 @@ const genWeekdayOptions = (lang: string, weekdayType: string) => {
"3": ["Sunday", "星期日", "星期日"], "3": ["Sunday", "星期日", "星期日"],
"4": ["SUNDAY", "星期天", "星期天"], "4": ["SUNDAY", "星期天", "星期天"],
}; };
let currentLang = 0 let currentLang = 0;
if (lang === "") { if (lang === "") {
lang = window.siyuan.config.lang; lang = window.siyuan.config.lang;
} }
@ -213,8 +213,8 @@ const genWeekdayOptions = (lang: string, weekdayType: string) => {
return `<option value="1" ${weekdayType === "1" ? " selected" : ""}>${dynamicWeekdayLang[1][currentLang]}</option> return `<option value="1" ${weekdayType === "1" ? " selected" : ""}>${dynamicWeekdayLang[1][currentLang]}</option>
<option value="2" ${weekdayType === "2" ? " selected" : ""}>${dynamicWeekdayLang[2][currentLang]}</option> <option value="2" ${weekdayType === "2" ? " selected" : ""}>${dynamicWeekdayLang[2][currentLang]}</option>
<option value="3" ${weekdayType === "3" ? " selected" : ""}>${dynamicWeekdayLang[3][currentLang]}</option> <option value="3" ${weekdayType === "3" ? " selected" : ""}>${dynamicWeekdayLang[3][currentLang]}</option>
<option value="4" ${weekdayType === "4" ? " selected" : ""}>${dynamicWeekdayLang[4][currentLang]}</option>` <option value="4" ${weekdayType === "4" ? " selected" : ""}>${dynamicWeekdayLang[4][currentLang]}</option>`;
} };
export const openEmojiPanel = (id: string, type: "doc" | "notebook" | "av", position: IPosition, avCB?: (emoji: string) => void, dynamicImgElement?: HTMLElement) => { export const openEmojiPanel = (id: string, type: "doc" | "notebook" | "av", position: IPosition, avCB?: (emoji: string) => void, dynamicImgElement?: HTMLElement) => {
if (type !== "av") { if (type !== "av") {
@ -235,7 +235,7 @@ export const openEmojiPanel = (id: string, type: "doc" | "notebook" | "av", posi
if (dynamicImgElement && dynamicImgElement.getAttribute("src").startsWith(dynamicURL)) { if (dynamicImgElement && dynamicImgElement.getAttribute("src").startsWith(dynamicURL)) {
const dynamicCurrentUrl = new URLSearchParams(dynamicImgElement.getAttribute("src").replace(dynamicURL, "")); const dynamicCurrentUrl = new URLSearchParams(dynamicImgElement.getAttribute("src").replace(dynamicURL, ""));
dynamicCurrentObj.color = dynamicCurrentUrl.get("color") || "#d23f31"; dynamicCurrentObj.color = dynamicCurrentUrl.get("color") || "#d23f31";
if (!dynamicCurrentObj.color.startsWith('#')) { if (!dynamicCurrentObj.color.startsWith("#")) {
dynamicCurrentObj.color = "#" + dynamicCurrentObj.color; dynamicCurrentObj.color = "#" + dynamicCurrentObj.color;
} }
dynamicCurrentObj.lang = dynamicCurrentUrl.get("lang") || ""; dynamicCurrentObj.lang = dynamicCurrentUrl.get("lang") || "";
@ -631,7 +631,7 @@ ${unicode2Emoji(emoji.unicode)}</button>`;
url.delete("lang"); url.delete("lang");
} }
item.setAttribute("src", dynamicURL + url.toString()); item.setAttribute("src", dynamicURL + url.toString());
dynamicLangElements[1].innerHTML = genWeekdayOptions(dynamicLangElements[0].value, dynamicLangElements[1].value) dynamicLangElements[1].innerHTML = genWeekdayOptions(dynamicLangElements[0].value, dynamicLangElements[1].value);
}); });
}); });
dynamicLangElements[1].addEventListener("change", () => { dynamicLangElements[1].addEventListener("change", () => {

View file

@ -1716,9 +1716,9 @@ export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {
label: window.siyuan.languages.copy, label: window.siyuan.languages.copy,
icon: "iconCopy", icon: "iconCopy",
click() { click() {
const range = document.createRange() const range = document.createRange();
range.selectNode(tagElement); range.selectNode(tagElement);
focusByRange(range) focusByRange(range);
document.execCommand("copy"); document.execCommand("copy");
} }
}).element); }).element);
@ -1726,9 +1726,9 @@ export const tagMenu = (protyle: IProtyle, tagElement: HTMLElement) => {
label: window.siyuan.languages.cut, label: window.siyuan.languages.cut,
icon: "iconCut", icon: "iconCut",
click() { click() {
const range = document.createRange() const range = document.createRange();
range.selectNode(tagElement); range.selectNode(tagElement);
focusByRange(range) focusByRange(range);
document.execCommand("cut"); document.execCommand("cut");
} }
}).element); }).element);
@ -1780,9 +1780,9 @@ export const inlineMathMenu = (protyle: IProtyle, element: Element) => {
label: window.siyuan.languages.copy, label: window.siyuan.languages.copy,
icon: "iconCopy", icon: "iconCopy",
click() { click() {
const range = document.createRange() const range = document.createRange();
range.selectNode(element); range.selectNode(element);
focusByRange(range) focusByRange(range);
document.execCommand("copy"); document.execCommand("copy");
} }
}).element); }).element);
@ -1791,9 +1791,9 @@ export const inlineMathMenu = (protyle: IProtyle, element: Element) => {
icon: "iconCut", icon: "iconCut",
label: window.siyuan.languages.cut, label: window.siyuan.languages.cut,
click() { click() {
const range = document.createRange() const range = document.createRange();
range.selectNode(element); range.selectNode(element);
focusByRange(range) focusByRange(range);
document.execCommand("cut"); document.execCommand("cut");
} }
}).element); }).element);

View file

@ -669,13 +669,13 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
if (!item) { if (!item) {
return; return;
} }
let hasSameContent = false let hasSameContent = false;
oldValue.mSelect.find((mSelectItem) => { oldValue.mSelect.find((mSelectItem) => {
if (mSelectItem.content === item) { if (mSelectItem.content === item) {
hasSameContent = true hasSameContent = true;
return true return true;
} }
}) });
if (hasSameContent) { if (hasSameContent) {
return; return;
} }
@ -683,8 +683,8 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va
newMSelectValue.push({ newMSelectValue.push({
content: item, content: item,
color: colorIndex.toString() color: colorIndex.toString()
}) });
}) });
value = oldValue.mSelect.concat(newMSelectValue); value = oldValue.mSelect.concat(newMSelectValue);
} }
} }

View file

@ -1,7 +1,6 @@
import {Constants} from "../../constants"; import {Constants} from "../../constants";
import {merge} from "./merge"; import {merge} from "./merge";
import {hintEmbed, hintRef, hintSlash, hintTag} from "../hint/extend"; import {hintEmbed, hintRef, hintSlash, hintTag} from "../hint/extend";
import {isMobile} from "../../util/functions";
import {toolbarKeyToMenu} from "../toolbar/util"; import {toolbarKeyToMenu} from "../toolbar/util";
export class Options { export class Options {

View file

@ -194,7 +194,7 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
} else if (cellsElement.length > 0) { } else if (cellsElement.length > 0) {
if (cellsElement.length > 1) { if (cellsElement.length > 1) {
// 选择多个单元格时,逐行填充 // 选择多个单元格时,逐行填充
let rowIndex = 0 let rowIndex = 0;
text.split("\n").find((row) => { text.split("\n").find((row) => {
if (!row) { if (!row) {
return false; return false;
@ -205,7 +205,7 @@ const processAV = (range: Range, html: string, protyle: IProtyle, blockElement:
} else { } else {
return true; return true;
} }
}) });
} else { } else {
updateCellsValue(protyle, blockElement as HTMLElement, text, cellsElement, columns, html); updateCellsValue(protyle, blockElement as HTMLElement, text, cellsElement, columns, html);
} }