mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-18 15:40:12 +01:00
🚨
This commit is contained in:
parent
e6a8abf004
commit
6f0c68f506
11 changed files with 29 additions and 31 deletions
|
|
@ -6,7 +6,6 @@ import {pdfResize} from "../asset/renderAssets";
|
||||||
import {App} from "../index";
|
import {App} from "../index";
|
||||||
import {Model} from "./Model";
|
import {Model} from "./Model";
|
||||||
import {Editor} from "../editor";
|
import {Editor} from "../editor";
|
||||||
import {saveScroll} from "../protyle/scroll/saveScroll";
|
|
||||||
import {Asset} from "../asset";
|
import {Asset} from "../asset";
|
||||||
import {Graph} from "./dock/Graph";
|
import {Graph} from "./dock/Graph";
|
||||||
import {Files} from "./dock/Files";
|
import {Files} from "./dock/Files";
|
||||||
|
|
|
||||||
|
|
@ -229,8 +229,8 @@ export const exportLayout = (options: {
|
||||||
};
|
};
|
||||||
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
||||||
getAllModels().editor.forEach(item => {
|
getAllModels().editor.forEach(item => {
|
||||||
saveScroll(item.editor.protyle)
|
saveScroll(item.editor.protyle);
|
||||||
})
|
});
|
||||||
sessionStorage.setItem("layout", JSON.stringify(layoutJSON));
|
sessionStorage.setItem("layout", JSON.stringify(layoutJSON));
|
||||||
options.cb();
|
options.cb();
|
||||||
return;
|
return;
|
||||||
|
|
@ -248,8 +248,8 @@ export const exportLayout = (options: {
|
||||||
};
|
};
|
||||||
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
||||||
getAllModels().editor.forEach(item => {
|
getAllModels().editor.forEach(item => {
|
||||||
saveScroll(item.editor.protyle)
|
saveScroll(item.editor.protyle);
|
||||||
})
|
});
|
||||||
fetchPost("/api/system/setUILayout", {
|
fetchPost("/api/system/setUILayout", {
|
||||||
layout: layoutJSON,
|
layout: layoutJSON,
|
||||||
errorExit: options.errorExit // 后台不接受该参数,用于请求发生错误时退出程序
|
errorExit: options.errorExit // 后台不接受该参数,用于请求发生错误时退出程序
|
||||||
|
|
@ -268,7 +268,7 @@ export const getAllLayout = () => {
|
||||||
};
|
};
|
||||||
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
layoutToJSON(window.siyuan.layout.layout, layoutJSON.layout);
|
||||||
return layoutJSON;
|
return layoutJSON;
|
||||||
}
|
};
|
||||||
|
|
||||||
const initInternalDock = (dockItem: IDockTab[]) => {
|
const initInternalDock = (dockItem: IDockTab[]) => {
|
||||||
dockItem.forEach((existSubItem) => {
|
dockItem.forEach((existSubItem) => {
|
||||||
|
|
|
||||||
|
|
@ -1100,7 +1100,7 @@ export const linkMenu = (protyle: IProtyle, linkElement: HTMLElement, focusText
|
||||||
const id = nodeElement.getAttribute("data-node-id");
|
const id = nodeElement.getAttribute("data-node-id");
|
||||||
let html = nodeElement.outerHTML;
|
let html = nodeElement.outerHTML;
|
||||||
const linkAddress = linkElement.getAttribute("data-href");
|
const linkAddress = linkElement.getAttribute("data-href");
|
||||||
let inputElements: NodeListOf<HTMLTextAreaElement>
|
let inputElements: NodeListOf<HTMLTextAreaElement>;
|
||||||
window.siyuan.menus.menu.append(new MenuItem({
|
window.siyuan.menus.menu.append(new MenuItem({
|
||||||
iconHTML: "",
|
iconHTML: "",
|
||||||
type: "readonly",
|
type: "readonly",
|
||||||
|
|
|
||||||
|
|
@ -61,7 +61,7 @@ export const openMobileFileById = (app: App, id: string, action = [Constants.CB_
|
||||||
preview: {
|
preview: {
|
||||||
actions: ["mp-wechat", "zhihu"]
|
actions: ["mp-wechat", "zhihu"]
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
if (window.siyuan.mobile.editor) {
|
if (window.siyuan.mobile.editor) {
|
||||||
pushBack();
|
pushBack();
|
||||||
addLoading(window.siyuan.mobile.editor.protyle);
|
addLoading(window.siyuan.mobile.editor.protyle);
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@ import {openDocHistory} from "../../history/doc";
|
||||||
import {openNewWindowById} from "../../window/openNewWindow";
|
import {openNewWindowById} from "../../window/openNewWindow";
|
||||||
import {genImportMenu} from "../../menus/navigation";
|
import {genImportMenu} from "../../menus/navigation";
|
||||||
import {transferBlockRef} from "../../menus/block";
|
import {transferBlockRef} from "../../menus/block";
|
||||||
import {saveScroll} from "../scroll/saveScroll";
|
|
||||||
|
|
||||||
export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
export const openTitleMenu = (protyle: IProtyle, position: IPosition) => {
|
||||||
hideTooltip();
|
hideTooltip();
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ const calcItem = (options: {
|
||||||
}
|
}
|
||||||
}]);
|
}]);
|
||||||
} else {
|
} 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) => {
|
const colData = options.data.view.columns.find((item) => {
|
||||||
if (item.id === options.colId) {
|
if (item.id === options.colId) {
|
||||||
if (!item.rollup) {
|
if (!item.rollup) {
|
||||||
|
|
@ -440,6 +440,6 @@ export const getNameByOperator = (operator: string, isRollup: boolean) => {
|
||||||
case "Latest":
|
case "Latest":
|
||||||
return window.siyuan.languages.calcOperatorLatest;
|
return window.siyuan.languages.calcOperatorLatest;
|
||||||
default:
|
default:
|
||||||
return ""
|
return "";
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -667,7 +667,7 @@ export const renderCell = (cellValue: IAVCellValue, wrap: boolean) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderRollup = (cellValue: IAVCellValue) => {
|
const renderRollup = (cellValue: IAVCellValue) => {
|
||||||
let text = ""
|
let text = "";
|
||||||
if (["text"].includes(cellValue.type)) {
|
if (["text"].includes(cellValue.type)) {
|
||||||
text = cellValue ? (cellValue[cellValue.type as "text"].content || "") : "";
|
text = cellValue ? (cellValue[cellValue.type as "text"].content || "") : "";
|
||||||
} else if (["url", "email", "phone"].includes(cellValue.type)) {
|
} else if (["url", "email", "phone"].includes(cellValue.type)) {
|
||||||
|
|
@ -700,7 +700,7 @@ const renderRollup = (cellValue: IAVCellValue) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return text;
|
return text;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const updateHeaderCell = (cellElement: HTMLElement, headerValue: {
|
export const updateHeaderCell = (cellElement: HTMLElement, headerValue: {
|
||||||
icon?: string,
|
icon?: string,
|
||||||
|
|
|
||||||
|
|
@ -530,7 +530,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
|
||||||
icon: "iconEdit",
|
icon: "iconEdit",
|
||||||
label: window.siyuan.languages.edit,
|
label: window.siyuan.languages.edit,
|
||||||
click() {
|
click() {
|
||||||
const colName = (menu.element.querySelector(".b3-text-field") as HTMLInputElement).value
|
const colName = (menu.element.querySelector(".b3-text-field") as HTMLInputElement).value;
|
||||||
openMenuPanel({
|
openMenuPanel({
|
||||||
protyle,
|
protyle,
|
||||||
blockElement,
|
blockElement,
|
||||||
|
|
@ -538,7 +538,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
|
||||||
colId,
|
colId,
|
||||||
cb(avElement) {
|
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.value = colName;
|
||||||
editNameElement.select();
|
editNameElement.select();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ export const setFilter = async (options: {
|
||||||
}
|
}
|
||||||
const menu = new Menu("set-filter-" + options.filter.column, () => {
|
const menu = new Menu("set-filter-" + options.filter.column, () => {
|
||||||
const oldFilters = JSON.parse(JSON.stringify(options.data.view.filters));
|
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) {
|
if (!selectElement) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -162,10 +162,10 @@ export const setFilter = async (options: {
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let targetAVId = ""
|
let targetAVId = "";
|
||||||
options.data.view.columns.find((column) => {
|
options.data.view.columns.find((column) => {
|
||||||
if (column.id === colData.rollup.relationKeyID) {
|
if (column.id === colData.rollup.relationKeyID) {
|
||||||
targetAVId = column.relation.avID
|
targetAVId = column.relation.avID;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -180,10 +180,10 @@ export const setFilter = async (options: {
|
||||||
if (item.column === colData.id && item.type) {
|
if (item.column === colData.id && item.type) {
|
||||||
item.operator = getDefaultOperatorByType(filterType);
|
item.operator = getDefaultOperatorByType(filterType);
|
||||||
item.value = genCellValue(filterType, "");
|
item.value = genCellValue(filterType, "");
|
||||||
delete item.type
|
delete item.type;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
switch (filterType) {
|
switch (filterType) {
|
||||||
case "checkbox":
|
case "checkbox":
|
||||||
|
|
|
||||||
|
|
@ -18,9 +18,9 @@ const updateCol = (options: {
|
||||||
isRelation: boolean,
|
isRelation: boolean,
|
||||||
}, itemElement: HTMLElement) => {
|
}, itemElement: HTMLElement) => {
|
||||||
if (itemElement.classList.contains("b3-list--empty")) {
|
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) => {
|
const colData = options.data.view.columns.find((item) => {
|
||||||
if (item.id === options.colId) {
|
if (item.id === options.colId) {
|
||||||
|
|
@ -62,7 +62,7 @@ const updateCol = (options: {
|
||||||
const genSearchList = (element: Element, keyword: string, avId: string, isRelation: boolean, cb?: () => void) => {
|
const genSearchList = (element: Element, keyword: string, avId: string, isRelation: boolean, cb?: () => void) => {
|
||||||
if (!isRelation && !avId) {
|
if (!isRelation && !avId) {
|
||||||
showMessage(window.siyuan.languages.selectRelation);
|
showMessage(window.siyuan.languages.selectRelation);
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
fetchPost(isRelation ? "/api/av/searchAttributeViewRelationKey" : "/api/av/searchAttributeViewNonRelationKey", {
|
fetchPost(isRelation ? "/api/av/searchAttributeViewRelationKey" : "/api/av/searchAttributeViewNonRelationKey", {
|
||||||
avID: avId,
|
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__label">${window.siyuan.languages.calc}</span>
|
||||||
<span class="b3-menu__accelerator">${getNameByOperator(colData.rollup?.calc?.operator, true)}</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>
|
<svg class="b3-menu__icon b3-menu__icon--small"><use xlink:href="#iconRight"></use></svg>
|
||||||
</button>`
|
</button>`;
|
||||||
}
|
};
|
||||||
|
|
||||||
export const bindRollupEvent = (options: {
|
export const bindRollupEvent = (options: {
|
||||||
protyle: IProtyle,
|
protyle: IProtyle,
|
||||||
|
|
@ -184,7 +184,7 @@ export const bindRollupEvent = (options: {
|
||||||
if (goSearchRollupColElement) {
|
if (goSearchRollupColElement) {
|
||||||
const oldValue = JSON.parse(goSearchRollupColElement.dataset.oldValue) as IAVCellRollupValue;
|
const oldValue = JSON.parse(goSearchRollupColElement.dataset.oldValue) as IAVCellRollupValue;
|
||||||
const goSearchRollupTargetElement = options.menuElement.querySelector('[data-type="goSearchRollupTarget"]') as HTMLElement;
|
const goSearchRollupTargetElement = options.menuElement.querySelector('[data-type="goSearchRollupTarget"]') as HTMLElement;
|
||||||
let targetKeyAVId = ""
|
let targetKeyAVId = "";
|
||||||
if (oldValue.relationKeyID) {
|
if (oldValue.relationKeyID) {
|
||||||
options.data.view.columns.find((item) => {
|
options.data.view.columns.find((item) => {
|
||||||
if (item.id === oldValue.relationKeyID) {
|
if (item.id === oldValue.relationKeyID) {
|
||||||
|
|
@ -193,13 +193,13 @@ export const bindRollupEvent = (options: {
|
||||||
goSearchRollupTargetElement.dataset.avId = targetKeyAVId;
|
goSearchRollupTargetElement.dataset.avId = targetKeyAVId;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
if (oldValue.keyID && targetKeyAVId) {
|
if (oldValue.keyID && targetKeyAVId) {
|
||||||
fetchPost("/api/av/getAttributeView", {id: targetKeyAVId}, (response) => {
|
fetchPost("/api/av/getAttributeView", {id: targetKeyAVId}, (response) => {
|
||||||
response.data.av.keyValues.find((item: { key: { id: string, name: string, type: TAVCol } }) => {
|
response.data.av.keyValues.find((item: { key: { id: string, name: string, type: TAVCol } }) => {
|
||||||
if (item.key.id === oldValue.keyID) {
|
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;
|
const goSearchRollupCalcElement = options.menuElement.querySelector('[data-type="goSearchRollupCalc"]') as HTMLElement;
|
||||||
goSearchRollupCalcElement.dataset.colType = item.key.type;
|
goSearchRollupCalcElement.dataset.colType = item.key.type;
|
||||||
goSearchRollupCalcElement.dataset.calc = oldValue.calc.operator;
|
goSearchRollupCalcElement.dataset.calc = oldValue.calc.operator;
|
||||||
|
|
@ -209,4 +209,4 @@ export const bindRollupEvent = (options: {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
|
||||||
|
|
@ -391,7 +391,7 @@ const focusElementById = (protyle: IProtyle, action: string[], scrollAttr?: IScr
|
||||||
}
|
}
|
||||||
/// #endif
|
/// #endif
|
||||||
}
|
}
|
||||||
const hasScrollTop = scrollAttr && typeof scrollAttr.scrollTop === "number"
|
const hasScrollTop = scrollAttr && typeof scrollAttr.scrollTop === "number";
|
||||||
if (hasScrollTop) {
|
if (hasScrollTop) {
|
||||||
protyle.contentElement.scrollTop = scrollAttr.scrollTop;
|
protyle.contentElement.scrollTop = scrollAttr.scrollTop;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue