This commit is contained in:
Vanessa 2024-01-08 23:23:59 +08:00
parent 75a8ee13bd
commit 5f44965ef3
12 changed files with 28 additions and 28 deletions

View file

@ -485,10 +485,10 @@ export const openCardByData = async (app: App, cardsData: ICardData, cardType: T
dialog
});
dialog.editor = editor;
const focusElement = dialog.element.querySelector('.b3-button[data-type="-1"]') as HTMLButtonElement
const focusElement = dialog.element.querySelector('.b3-button[data-type="-1"]') as HTMLButtonElement;
focusElement.focus();
const range = document.createRange()
range.selectNodeContents(focusElement)
const range = document.createRange();
range.selectNodeContents(focusElement);
focusByRange(range);
};

View file

@ -161,7 +161,7 @@ export const showDiff = (app: App, data: { id: string, time: string }[]) => {
rightEditor = undefined;
}
});
dialog.element.setAttribute("data-key", Constants.DIALOG_HISTORYCOMPARE)
dialog.element.setAttribute("data-key", Constants.DIALOG_HISTORYCOMPARE);
dialog.element.addEventListener("click", (event) => {
if (typeof event.detail === "string") {
renderCompare(app, dialog.element.querySelector(".history__diff .b3-list-item--focus"));

View file

@ -1,8 +1,8 @@
import {Dialog} from "../dialog";
export const historyKeydown = (event: KeyboardEvent, dialog: Dialog) => {
let currentItem = dialog.element.querySelector(".history__diff .b3-list-item--focus")
const items = Array.from(dialog.element.querySelectorAll(".history__diff .b3-list-item[data-id]"))
let currentItem = dialog.element.querySelector(".history__diff .b3-list-item--focus");
const items = Array.from(dialog.element.querySelectorAll(".history__diff .b3-list-item[data-id]"));
if (items.length < 2) {
return;
}
@ -11,9 +11,9 @@ export const historyKeydown = (event: KeyboardEvent, dialog: Dialog) => {
} else {
currentItem.classList.remove("b3-list-item--focus");
if (event.key === "Home") {
currentItem = items[0]
currentItem = items[0];
} else if (event.key === "End") {
currentItem = items[items.length - 1]
currentItem = items[items.length - 1];
} else {
items.find((item, index) => {
if (item.isSameNode(currentItem)) {
@ -32,7 +32,7 @@ export const historyKeydown = (event: KeyboardEvent, dialog: Dialog) => {
}
return true;
}
})
});
}
}
currentItem.classList.add("b3-list-item--focus");
@ -44,9 +44,9 @@ export const historyKeydown = (event: KeyboardEvent, dialog: Dialog) => {
const historyDiffElement = dialog.element.querySelector(".history__diff");
const historyDiffRect = historyDiffElement.getBoundingClientRect();
if (currentItemRect.bottom > historyDiffRect.bottom) {
currentItem.scrollIntoView(false)
currentItem.scrollIntoView(false);
} else if (currentItemRect.top < historyDiffRect.top) {
currentItem.scrollIntoView()
currentItem.scrollIntoView();
}
dialog.element.dispatchEvent(new CustomEvent("click", {detail: event.key.toLowerCase()}));
}
};

View file

@ -875,7 +875,7 @@ export const adjustLayout = (layout: Layout = window.siyuan.layout.centerLayout.
item.element.style.minWidth = "";
}
});
let lastItem: HTMLElement
let lastItem: HTMLElement;
while (layout.element.scrollWidth > layout.element.clientWidth) {
layout.children.find((item: Layout | Wnd) => {
if (item.element.style.width && item.element.style.width !== "0px") {

View file

@ -20,7 +20,7 @@ export const showAccountInfo = () => {
});
userTitlesHTML += "</div>";
}
let subscriptionHTML = ""
let subscriptionHTML = "";
if (window.siyuan.user.userSiYuanProExpireTime === -1) {
// 终身会员
subscriptionHTML = `<div class="b3-chip b3-chip--secondary">${Constants.SIYUAN_IMAGE_VIP}${window.siyuan.languages.account12}</div>`;

View file

@ -58,7 +58,7 @@ export class Protyle {
if (item.protyleOptions) {
pluginsOptions = merge(pluginsOptions, item.protyleOptions);
}
})
});
const getOptions = new Options(pluginsOptions);
const mergedOptions = getOptions.merge();
this.protyle = {

View file

@ -103,12 +103,12 @@ export const updateAssetCell = (options: {
const colId = options.cellElements[0].dataset.colId;
const cellDoOperations: IOperation[] = [];
const cellUndoOperations: IOperation[] = [];
let mAssetValue: IAVCellAssetValue[]
let mAssetValue: IAVCellAssetValue[];
options.cellElements.forEach((item, elementIndex) => {
if (!options.blockElement.contains(item)) {
const rowElement = hasClosestByClassName(item, "av__row");
if (rowElement) {
item = options.cellElements[elementIndex] = options.blockElement.querySelector(`.av__row[data-id="${rowElement.dataset.id}"] .av__cell[data-col-id="${item.dataset.colId}"]`) as HTMLElement
item = options.cellElements[elementIndex] = options.blockElement.querySelector(`.av__row[data-id="${rowElement.dataset.id}"] .av__cell[data-col-id="${item.dataset.colId}"]`) as HTMLElement;
}
}
const cellValue = genCellValueByElement(getTypeByCellElement(item) || item.dataset.type as TAVCol, item);
@ -144,9 +144,9 @@ export const updateAssetCell = (options: {
} else {
cellValue.mAsset = options.replaceValue;
}
mAssetValue = cellValue.mAsset
mAssetValue = cellValue.mAsset;
} else {
cellValue.mAsset = mAssetValue
cellValue.mAsset = mAssetValue;
}
cellDoOperations.push({
action: "updateAttrViewCell",

View file

@ -209,7 +209,7 @@ export const cellScrollIntoView = (blockElement: HTMLElement, cellElement: Eleme
contentElement.scrollTop = contentElement.scrollTop + cellRect.top - avHeaderRect.bottom;
}
} else {
const footerElement = blockElement.querySelector(".av__row--footer")
const footerElement = blockElement.querySelector(".av__row--footer");
if (footerElement.querySelector(".av__calc--ashow")) {
const avFooterRect = footerElement.getBoundingClientRect();
if (avFooterRect.top < cellRect.bottom) {
@ -557,7 +557,7 @@ export const renderCell = (cellValue: IAVCellValue, wrap: boolean) => {
} else if (cellValue.type === "checkbox") {
text += `<svg class="av__checkbox"><use xlink:href="#icon${cellValue?.checkbox?.checked ? "Check" : "Uncheck"}"></use></svg>`;
} else if (cellValue.type === "rollup") {
cellValue?.rollup?.contents?.forEach((item, index) => {
cellValue?.rollup?.contents?.forEach((item) => {
const rollupText = ["select", "mSelect", "mAsset", "checkbox", "relation"].includes(item.type) ? renderCell(item, wrap) : renderRollup(item);
if (rollupText) {
text += rollupText + ", ";

View file

@ -1,7 +1,7 @@
import {fetchPost} from "../../../util/fetch";
import {getColIconByType} from "./col";
import {Constants} from "../../../constants";
import {popTextCell, renderCell} from "./cell";
import {renderCell} from "./cell";
import {unicode2Emoji} from "../../../emoji";
import {focusBlock} from "../../util/selection";
import {hasClosestBlock, hasClosestByClassName} from "../../util/hasClosest";
@ -264,7 +264,7 @@ ${cell.color ? `color:${cell.color};` : ""}">${renderCell(cell.value, data.colum
const refreshTimeouts: {
[key: string]: number;
} = {};
export const refreshAV = (protyle: IProtyle, operation: IOperation, isUndo: boolean) => {
export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
if (operation.action === "setAttrViewName") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${operation.id}"]`)).forEach((item: HTMLElement) => {
const titleElement = item.querySelector(".av__title") as HTMLElement;

View file

@ -108,14 +108,14 @@ export const insertAttrViewBlockAnimation = (protyle: IProtyle, blockElement: El
const sideRowCellElement = sideRow.querySelector(`.av__cell[data-col-id="${item.column}"]`) as HTMLElement;
currentRow.querySelector(`.av__cell[data-col-id="${item.column}"]`).innerHTML =
renderCell(genCellValueByElement(getTypeByCellElement(sideRowCellElement), sideRowCellElement), sideRowCellElement.dataset.wrap === "true");
})
});
response.data.sorts.forEach((item: IAVSort) => {
const sideRowCellElement = sideRow.querySelector(`.av__cell[data-col-id="${item.column}"]`) as HTMLElement;
currentRow.querySelector(`.av__cell[data-col-id="${item.column}"]`).innerHTML =
renderCell(genCellValueByElement(getTypeByCellElement(sideRowCellElement), sideRowCellElement), sideRowCellElement.dataset.wrap === "true");
})
});
popTextCell(protyle, [currentRow.querySelector('.av__cell[data-detached="true"]')], "block");
})
});
} else {
popTextCell(protyle, [currentRow.querySelector('.av__cell[data-detached="true"]')], "block");
}

View file

@ -1294,7 +1294,7 @@ export class Toolbar {
</div>`;
const listElement = this.subElement.querySelector(".b3-list");
const previewElement = this.subElement.firstElementChild.lastElementChild;
let previewPath: string
let previewPath: string;
listElement.addEventListener("mouseover", (event) => {
const target = event.target as HTMLElement;
const hoverItemElement = hasClosestByClassName(target, "b3-list-item");

View file

@ -725,7 +725,7 @@ export const onTransaction = (protyle: IProtyle, operation: IOperation, isUndo:
"replaceAttrViewBlock", "updateAttrViewColTemplate", "setAttrViewColPin", "addAttrViewView",
"removeAttrViewView", "setAttrViewViewName", "setAttrViewViewIcon", "duplicateAttrViewView", "sortAttrViewView",
"updateAttrViewColRelation", "setAttrViewPageSize", "updateAttrViewColRollup"].includes(operation.action)) {
refreshAV(protyle, operation, isUndo);
refreshAV(protyle, operation);
} else if (operation.action === "doUpdateUpdated") {
updateElements.forEach(item => {
item.setAttribute("updated", operation.data);