This commit is contained in:
Vanessa 2024-01-01 23:08:28 +08:00
parent e6a8abf004
commit 6f0c68f506
11 changed files with 29 additions and 31 deletions

View file

@ -6,7 +6,6 @@ import {pdfResize} from "../asset/renderAssets";
import {App} from "../index";
import {Model} from "./Model";
import {Editor} from "../editor";
import {saveScroll} from "../protyle/scroll/saveScroll";
import {Asset} from "../asset";
import {Graph} from "./dock/Graph";
import {Files} from "./dock/Files";

View file

@ -229,8 +229,8 @@ export const exportLayout = (options: {
};
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
getAllModels().editor.forEach(item => {
saveScroll(item.editor.protyle)
})
saveScroll(item.editor.protyle);
});
sessionStorage.setItem("layout", JSON.stringify(layoutJSON));
options.cb();
return;
@ -248,8 +248,8 @@ export const exportLayout = (options: {
};
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
getAllModels().editor.forEach(item => {
saveScroll(item.editor.protyle)
})
saveScroll(item.editor.protyle);
});
fetchPost("/api/system/setUILayout", {
layout: layoutJSON,
errorExit: options.errorExit // 后台不接受该参数,用于请求发生错误时退出程序
@ -268,7 +268,7 @@ export const getAllLayout = () => {
};
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
return layoutJSON;
}
};
const initInternalDock = (dockItem: IDockTab[]) => {
dockItem.forEach((existSubItem) => {

View file

@ -1100,7 +1100,7 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
const id = nodeElement.getAttribute("data-node-id");
let html = nodeElement.outerHTML;
const linkAddress = linkElement.getAttribute("data-href");
let inputElements: NodeListOf<HTMLTextAreaElement>
let inputElements: NodeListOf<HTMLTextAreaElement>;
window.siyuan.menus.menu.append(new MenuItem({
iconHTML: "",
type: "readonly",

View file

@ -61,7 +61,7 @@ export const openMobileFileById = (app: App, id: string, action = [Constants.CB_
preview: {
actions: ["mp-wechat", "zhihu"]
}
}
};
if (window.siyuan.mobile.editor) {
pushBack();
addLoading(window.siyuan.mobile.editor.protyle);

View file

@ -27,7 +27,6 @@ import {openDocHistory} from "../../history/doc";
import {openNewWindowById} from "../../window/openNewWindow";
import {genImportMenu} from "../../menus/navigation";
import {transferBlockRef} from "../../menus/block";
import {saveScroll} from "../scroll/saveScroll";
export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
hideTooltip();

View file

@ -33,7 +33,7 @@ const calcItem = (options: {
}
}]);
} else {
options.target.querySelector(".b3-menu__accelerator").textContent = getNameByOperator(options.operator, true)
options.target.querySelector(".b3-menu__accelerator").textContent = getNameByOperator(options.operator, true);
const colData = options.data.view.columns.find((item) => {
if (item.id === options.colId) {
if (!item.rollup) {
@ -440,6 +440,6 @@ export const getNameByOperator = (operator: string, isRollup: boolean) => {
case "Latest":
return window.siyuan.languages.calcOperatorLatest;
default:
return ""
return "";
}
}
};

View file

@ -667,7 +667,7 @@ export const renderCell = (cellValue: IAVCellValue, wrap: boolean) => {
};
const renderRollup = (cellValue: IAVCellValue) => {
let text = ""
let text = "";
if (["text"].includes(cellValue.type)) {
text = cellValue ? (cellValue[cellValue.type as "text"].content || "") : "";
} else if (["url", "email", "phone"].includes(cellValue.type)) {
@ -700,7 +700,7 @@ const renderRollup = (cellValue: IAVCellValue) => {
}
}
return text;
}
};
export const updateHeaderCell = (cellElement: HTMLElement, headerValue: {
icon?: string,

View file

@ -530,7 +530,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
icon: "iconEdit",
label: window.siyuan.languages.edit,
click() {
const colName = (menu.element.querySelector(".b3-text-field") as HTMLInputElement).value
const colName = (menu.element.querySelector(".b3-text-field") as HTMLInputElement).value;
openMenuPanel({
protyle,
blockElement,
@ -538,7 +538,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
colId,
cb(avElement) {
// 修改名字后点击编辑,需要更新名字
const editNameElement = avElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement
const editNameElement = avElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement;
editNameElement.value = colName;
editNameElement.select();
}

View file

@ -66,7 +66,7 @@ export const setFilter = async (options: {
}
const menu = new Menu("set-filter-" + options.filter.column, () => {
const oldFilters = JSON.parse(JSON.stringify(options.data.view.filters));
const selectElement = window.siyuan.menus.menu.element.querySelector(".b3-select") as HTMLSelectElement
const selectElement = window.siyuan.menus.menu.element.querySelector(".b3-select") as HTMLSelectElement;
if (!selectElement) {
return;
}
@ -162,10 +162,10 @@ export const setFilter = async (options: {
});
return;
}
let targetAVId = ""
let targetAVId = "";
options.data.view.columns.find((column) => {
if (column.id === colData.rollup.relationKeyID) {
targetAVId = column.relation.avID
targetAVId = column.relation.avID;
return true;
}
});
@ -180,10 +180,10 @@ export const setFilter = async (options: {
if (item.column === colData.id && item.type) {
item.operator = getDefaultOperatorByType(filterType);
item.value = genCellValue(filterType, "");
delete item.type
delete item.type;
return true;
}
})
});
}
switch (filterType) {
case "checkbox":

View file

@ -18,9 +18,9 @@ const updateCol = (options: {
isRelation: boolean,
}, itemElement: HTMLElement) => {
if (itemElement.classList.contains("b3-list--empty")) {
return
return;
}
options.target.querySelector(".b3-menu__accelerator").textContent = itemElement.querySelector(".b3-list-item__text").textContent
options.target.querySelector(".b3-menu__accelerator").textContent = itemElement.querySelector(".b3-list-item__text").textContent;
const colData = options.data.view.columns.find((item) => {
if (item.id === options.colId) {
@ -62,7 +62,7 @@ const updateCol = (options: {
const genSearchList = (element: Element, keyword: string, avId: string, isRelation: boolean, cb?: () => void) => {
if (!isRelation && !avId) {
showMessage(window.siyuan.languages.selectRelation);
return
return;
}
fetchPost(isRelation ? "/api/av/searchAttributeViewRelationKey" : "/api/av/searchAttributeViewNonRelationKey", {
avID: avId,
@ -172,8 +172,8 @@ export const getRollupHTML = (options: { data?: IAV, cellElements?: HTMLElement[
<span class="b3-menu__label">${window.siyuan.languages.calc}</span>
<span class="b3-menu__accelerator">${getNameByOperator(colData.rollup?.calc?.operator, true)}</span>
<svg class="b3-menu__icon b3-menu__icon--small"><use xlink:href="#iconRight"></use></svg>
</button>`
}
</button>`;
};
export const bindRollupEvent = (options: {
protyle: IProtyle,
@ -184,7 +184,7 @@ export const bindRollupEvent = (options: {
if (goSearchRollupColElement) {
const oldValue = JSON.parse(goSearchRollupColElement.dataset.oldValue) as IAVCellRollupValue;
const goSearchRollupTargetElement = options.menuElement.querySelector('[data-type="goSearchRollupTarget"]') as HTMLElement;
let targetKeyAVId = ""
let targetKeyAVId = "";
if (oldValue.relationKeyID) {
options.data.view.columns.find((item) => {
if (item.id === oldValue.relationKeyID) {
@ -193,13 +193,13 @@ export const bindRollupEvent = (options: {
goSearchRollupTargetElement.dataset.avId = targetKeyAVId;
return true;
}
})
});
}
if (oldValue.keyID && targetKeyAVId) {
fetchPost("/api/av/getAttributeView", {id: targetKeyAVId}, (response) => {
response.data.av.keyValues.find((item: { key: { id: string, name: string, type: TAVCol } }) => {
if (item.key.id === oldValue.keyID) {
goSearchRollupTargetElement.querySelector('.b3-menu__accelerator').textContent = item.key.name;
goSearchRollupTargetElement.querySelector(".b3-menu__accelerator").textContent = item.key.name;
const goSearchRollupCalcElement = options.menuElement.querySelector('[data-type="goSearchRollupCalc"]') as HTMLElement;
goSearchRollupCalcElement.dataset.colType = item.key.type;
goSearchRollupCalcElement.dataset.calc = oldValue.calc.operator;
@ -209,4 +209,4 @@ export const bindRollupEvent = (options: {
});
}
}
}
};

View file

@ -391,7 +391,7 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr
}
/// #endif
}
const hasScrollTop = scrollAttr && typeof scrollAttr.scrollTop === "number"
const hasScrollTop = scrollAttr && typeof scrollAttr.scrollTop === "number";
if (hasScrollTop) {
protyle.contentElement.scrollTop = scrollAttr.scrollTop;
}