This commit is contained in:
Vanessa 2024-12-09 10:20:40 +08:00
parent 8f59465ca6
commit 553891defb
17 changed files with 46 additions and 46 deletions

View file

@ -1109,7 +1109,7 @@ app.whenReady().then(() => {
if (index === 0) {
globalShortcut.register(shortcut, () => {
let currentWorkspace;
const currentWebContentsId = (latestActiveWindow && !latestActiveWindow.isDestroyed()) ? latestActiveWindow.webContents.id : undefined
const currentWebContentsId = (latestActiveWindow && !latestActiveWindow.isDestroyed()) ? latestActiveWindow.webContents.id : undefined;
workspaces.find(workspaceItem => {
if ((currentWebContentsId || event.sender.id) === workspaceItem.browserWindow.webContents.id) {
currentWorkspace = workspaceItem;

View file

@ -393,21 +393,21 @@ const showToolbar = (element: HTMLElement, range: Range, target?: HTMLElement) =
};
const getTextNode = (element: HTMLElement, isFirst: boolean) => {
const spans = element.querySelectorAll(".markedContent span")
let index = isFirst ? 0 : spans.length - 1
const spans = element.querySelectorAll(".markedContent span");
let index = isFirst ? 0 : spans.length - 1;
while (spans[index]) {
if (spans[index].textContent) {
break
break;
} else {
if (isFirst) {
index++
index++;
} else {
index--
index--;
}
}
}
return spans[index]
}
return spans[index];
};
const getHightlightCoordsByRange = (pdf: any, color: string) => {
const range = window.getSelection().getRangeAt(0);

View file

@ -31,7 +31,7 @@ export const initBlockPopover = (app: App) => {
if (aElement.classList.contains("av__cell")) {
if (aElement.classList.contains("av__cell--header")) {
const textElement = aElement.querySelector(".av__celltext");
const desc = aElement.getAttribute("data-desc")
const desc = aElement.getAttribute("data-desc");
if (textElement.scrollWidth > textElement.clientWidth + 2 || desc) {
if (desc) {
tip = `${getCellText(aElement)}<div class='ft__on-surface'>${escapeAriaLabel(desc)}</div>`;
@ -56,7 +56,7 @@ export const initBlockPopover = (app: App) => {
}
} else if (aElement.parentElement.parentElement.classList.contains("av__views")) {
const textElement = aElement.querySelector(".item__text");
const desc = aElement.getAttribute("data-desc")
const desc = aElement.getAttribute("data-desc");
if (textElement.scrollWidth > textElement.clientWidth + 2 || desc) {
if (desc) {
tip = `${textElement.textContent}<div class='ft__on-surface'>${escapeAriaLabel(desc)}</div>`;

View file

@ -510,7 +510,7 @@ const editKeydown = (app: App, event: KeyboardEvent) => {
} else {
const ids = Array.from(protyle.wysiwyg.element.querySelectorAll(".protyle-wysiwyg--select")).map(item => item.getAttribute("data-node-id"));
if (ids.length === 0) {
ids.push(nodeElement.getAttribute("data-node-id"))
ids.push(nodeElement.getAttribute("data-node-id"));
}
copyTextByType(ids, "ref");
}

View file

@ -694,7 +694,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
assetElement.classList.remove("fn__none");
assetElement.innerHTML = renderAssetsPreview(dataPath);
} else if (type === "doc") {
const k = (firstPanelElement.querySelector(".b3-text-field") as HTMLInputElement).value
const k = (firstPanelElement.querySelector(".b3-text-field") as HTMLInputElement).value;
fetchPost("/api/history/getDocHistoryContent", {
historyPath: dataPath,
highlight: !isSupportCSSHL(),
@ -717,7 +717,7 @@ const bindEvent = (app: App, element: Element, dialog?: Dialog) => {
}
});
}
titleElement.classList.remove("fn__none")
titleElement.classList.remove("fn__none");
titleElement.textContent = target.querySelector(".b3-list-item__text").textContent;
let currentItem = hasClosestByClassName(target, "b3-list") as HTMLElement;
if (currentItem) {

View file

@ -136,13 +136,13 @@ export class Backlink extends Model {
item.addEventListener("blur", (event: KeyboardEvent) => {
const inputElement = event.target as HTMLInputElement;
inputElement.classList.add("fn__none");
const filterIconElement = inputElement.nextElementSibling
const filterIconElement = inputElement.nextElementSibling;
if (inputElement.value) {
filterIconElement.classList.add("block__icon--active")
filterIconElement.setAttribute("aria-label", window.siyuan.languages.filter + " " + inputElement.value)
filterIconElement.classList.add("block__icon--active");
filterIconElement.setAttribute("aria-label", window.siyuan.languages.filter + " " + inputElement.value);
} else {
filterIconElement.classList.remove("block__icon--active")
filterIconElement.setAttribute("aria-label", window.siyuan.languages.filter)
filterIconElement.classList.remove("block__icon--active");
filterIconElement.setAttribute("aria-label", window.siyuan.languages.filter);
}
});
item.addEventListener("keydown", (event: KeyboardEvent) => {
@ -442,7 +442,7 @@ export class Backlink extends Model {
});
svgElement.removeAttribute("disabled");
} else {
const keyword = isMention ? this.inputsElement[1].value : this.inputsElement[0].value
const keyword = isMention ? this.inputsElement[1].value : this.inputsElement[0].value;
fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {
defID: this.blockId,
refTreeID: docId,

View file

@ -542,7 +542,7 @@ export class Background {
this.addTags(inputElement.value, protyle);
}
inputElement.value = "";
inputElement.dispatchEvent(new CustomEvent("input"))
inputElement.dispatchEvent(new CustomEvent("input"));
} else if (event.key === "Escape") {
window.siyuan.menus.menu.remove();
}

View file

@ -385,7 +385,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
if (cellRect.bottom > contentRect.bottom) {
height = contentRect.bottom - cellRect.top;
}
const width = Math.min(Math.max(cellRect.width, 25), contentRect.width)
const width = Math.min(Math.max(cellRect.width, 25), contentRect.width);
style = `style="padding-top: 6.5px;position:absolute;left: ${(cellRect.left < contentRect.left || cellRect.left + width > contentRect.right) ? contentRect.left : cellRect.left}px;top: ${cellRect.top}px;width:${width}px;height: ${height}px"`;
} else {
style = `style="padding-top: 6.5px;position:absolute;left: ${cellRect.left}px;top: ${cellRect.top}px;width:${Math.max(cellRect.width, 25)}px;height: ${height}px"`;

View file

@ -120,7 +120,7 @@ export const getEditHTML = (options: {
colData.options = [];
}
colData.options.forEach(item => {
const airaLabel = item.desc ? `${escapeAriaLabel(item.name)}<div class='ft__on-surface'>${escapeAriaLabel(item.desc || "")}</div>` : ""
const airaLabel = item.desc ? `${escapeAriaLabel(item.name)}<div class='ft__on-surface'>${escapeAriaLabel(item.desc || "")}</div>` : "";
html += `<button class="b3-menu__item${html ? "" : " b3-menu__item--current"}" draggable="true" data-name="${escapeAttr(item.name)}" data-desc="${escapeAttr(item.desc || "")}" data-color="${item.color}">
<svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg>
<div class="fn__flex-1 ariaLabel" data-position="2parentW" aria-label="${airaLabel}">

View file

@ -29,9 +29,9 @@ export const getDateHTML = (data: IAVTable, cellElements: HTMLElement[]) => {
const currentDate = new Date().getTime();
if (cellValue?.value?.date?.isNotEmpty) {
value = dayjs(cellValue.value.date.content).format(isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm");
const year = value.split("-")[0]
const year = value.split("-")[0];
if (year.length !== 4) {
value = new Array(4 - year.length).fill(0).join("") + value
value = new Array(4 - year.length).fill(0).join("") + value;
}
} else {
value = dayjs(currentDate).format(isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm");
@ -39,9 +39,9 @@ export const getDateHTML = (data: IAVTable, cellElements: HTMLElement[]) => {
let value2 = "";
if (cellValue?.value?.date?.isNotEmpty2) {
value2 = dayjs(cellValue.value.date.content2).format(isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm");
const year = value.split("-")[0]
const year = value.split("-")[0];
if (year.length !== 4) {
value = new Array(4 - year.length).fill(0).join("") + value
value = new Array(4 - year.length).fill(0).join("") + value;
}
} else if (hasEndDate) {
value2 = dayjs(currentDate).format(isNotTime ? "YYYY-MM-DD" : "YYYY-MM-DD HH:mm");
@ -144,12 +144,12 @@ export const bindDateEvent = (options: {
};
const getFullYearTime = (dateStr: string) => {
const year = dateStr.split("-")[0]
const date = new Date(dateStr)
const year = dateStr.split("-")[0];
const date = new Date(dateStr);
if (year.startsWith("00") || year.startsWith("000") || year.length < 3) {
date.setFullYear(parseInt(year))
return date.getTime()
date.setFullYear(parseInt(year));
return date.getTime();
} else {
return date.getTime()
return date.getTime();
}
}
};

View file

@ -28,7 +28,7 @@ const filterSelectHTML = (key: string, options: {
if (!key ||
(key.toLowerCase().indexOf(item.name.toLowerCase()) > -1 ||
item.name.toLowerCase().indexOf(key.toLowerCase()) > -1)) {
const airaLabel = item.desc ? `${escapeAriaLabel(item.name)}<div class='ft__on-surface'>${escapeAriaLabel(item.desc || "")}</div>` : ""
const airaLabel = item.desc ? `${escapeAriaLabel(item.name)}<div class='ft__on-surface'>${escapeAriaLabel(item.desc || "")}</div>` : "";
html += `<button data-type="addColOptionOrCell" class="b3-menu__item" data-name="${escapeAttr(item.name)}" data-desc="${escapeAttr(item.desc || "")}" draggable="true" data-color="${item.color}">
<svg class="b3-menu__icon fn__grab"><use xlink:href="#iconDrag"></use></svg>
<div class="fn__flex-1 ariaLabel" data-position="2parentW" aria-label="${airaLabel}">

View file

@ -19,7 +19,7 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], isHL: boolea
let currentNode = treeWalker.nextNode();
while (currentNode) {
textNodes.push(currentNode);
currentSize += currentNode.textContent.length
currentSize += currentNode.textContent.length;
textNodesSize.push(currentSize);
currentNode = treeWalker.nextNode();
}
@ -45,9 +45,9 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], isHL: boolea
range.setStart(currentTextNode, startIndex - (currentNodeIndex ? textNodesSize[currentNodeIndex - 1] : 0));
while (currentNodeIndex < textNodes.length && textNodesSize[currentNodeIndex] < endIndex) {
currentNodeIndex++
currentNodeIndex++;
}
currentTextNode = textNodes[currentNodeIndex]
currentTextNode = textNodes[currentNodeIndex];
range.setEnd(currentTextNode, endIndex - (currentNodeIndex ? textNodesSize[currentNodeIndex - 1] : 0));
rangeIndexes.push({range, startIndex});
@ -56,13 +56,13 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], isHL: boolea
}
startIndex = endIndex;
}
})
});
rangeIndexes.sort((b, a) => {
if (a.startIndex > b.startIndex) {
return -1
return -1;
} else {
return 0
return 0;
}
}).forEach((item, index) => {
if (index === protyle.highlight.rangeIndex && isHL) {
@ -84,4 +84,4 @@ export const searchMarkRender = (protyle: IProtyle, keys: string[], isHL: boolea
export const isSupportCSSHL = () => {
return !!(CSS && CSS.highlights);
}
};

View file

@ -415,7 +415,7 @@ export const insertHTML = (html: string, protyle: IProtyle, isBlock = false,
(insertBefore ? Array.from(tempElement.content.children) : Array.from(tempElement.content.children).reverse()).forEach((item) => {
// https://github.com/siyuan-note/siyuan/issues/13232
if (item.getAttribute("data-type") === "NodeHeading" && item.getAttribute("fold") === "1") {
item.removeAttribute("fold")
item.removeAttribute("fold");
}
let addId = item.getAttribute("data-node-id");
if (addId === id) {

View file

@ -37,7 +37,7 @@ export const reloadProtyle = (protyle: IProtyle, focus: boolean, updateReadonly?
const tabElement = hasClosestByClassName(protyle.element, "sy__backlink");
if (tabElement) {
const inputsElement = tabElement.querySelectorAll(".b3-text-field") as NodeListOf<HTMLInputElement>;
const keyword = isMention ? inputsElement[1].value : inputsElement[0].value
const keyword = isMention ? inputsElement[1].value : inputsElement[0].value;
fetchPost(isMention ? "/api/ref/getBackmentionDoc" : "/api/ref/getBacklinkDoc", {
defID: protyle.element.getAttribute("data-defid"),
refTreeID: protyle.block.rootID,

View file

@ -743,4 +743,4 @@ export const clearTableCell = (protyle: IProtyle, tableBlockElement: HTMLElement
item.innerHTML = "";
});
updateTransaction(protyle, tableBlockElement.getAttribute("data-node-id"), tableBlockElement.outerHTML, oldHTML);
}
};

View file

@ -1298,7 +1298,7 @@ export class WYSIWYG {
icon: "iconTrashcan",
accelerator: "⌦",
click() {
clearTableCell(protyle, tableBlockElement as HTMLElement)
clearTableCell(protyle, tableBlockElement as HTMLElement);
}
}).element);
window.siyuan.menus.menu.append(new MenuItem({

View file

@ -1200,7 +1200,7 @@ const renderNextSearchMark = (options: {
}
};
let articleId: string
let articleId: string;
export const getArticle = (options: {
id: string,
@ -1208,7 +1208,7 @@ export const getArticle = (options: {
edit: Protyle
value?: string,
}) => {
articleId = options.id
articleId = options.id;
checkFold(options.id, (zoomIn) => {
if (articleId !== options.id) {
return;