This commit is contained in:
Vanessa 2023-07-06 22:48:37 +08:00
parent a78c853d8d
commit cd6d1533ca
3 changed files with 14 additions and 14 deletions

View file

@ -151,7 +151,7 @@ const getLoginHTML = (deactivate = false) => {
</div> </div>
<div class="fn__hr--b"></div> <div class="fn__hr--b"></div>
<button id="login2" class="b3-button fn__block">${deactivate ? window.siyuan.languages.deactivateUser : window.siyuan.languages.login}</button> <button id="login2" class="b3-button fn__block">${deactivate ? window.siyuan.languages.deactivateUser : window.siyuan.languages.login}</button>
</div>` </div>`;
}; };
const afterLogin = (response: IWebSocketData, deactive = false) => { const afterLogin = (response: IWebSocketData, deactive = false) => {
@ -176,7 +176,7 @@ const afterLogin = (response: IWebSocketData, deactive = false) => {
processSync(); processSync();
}); });
} }
} };
const bindLoginEvent = (modelMainElement: HTMLElement, deactive = false) => { const bindLoginEvent = (modelMainElement: HTMLElement, deactive = false) => {
const agreeLoginElement = modelMainElement.querySelector("#agreeLogin") as HTMLInputElement; const agreeLoginElement = modelMainElement.querySelector("#agreeLogin") as HTMLInputElement;
@ -252,7 +252,7 @@ const bindLoginEvent = (modelMainElement: HTMLElement, deactive = false) => {
afterLogin(faResponse, deactive); afterLogin(faResponse, deactive);
}); });
}); });
} };
export const login = () => { export const login = () => {
openModel({ openModel({

View file

@ -434,13 +434,13 @@ const setFilter = (protyle: IProtyle, data: IAV, target: HTMLElement) => {
filters: oldFilters filters: oldFilters
} }
}]); }]);
const menuElement = hasClosestByClassName(target, "b3-menu") const menuElement = hasClosestByClassName(target, "b3-menu");
if (menuElement) { if (menuElement) {
menuElement.innerHTML = getFiltersHTML(data); menuElement.innerHTML = getFiltersHTML(data);
} }
}); });
let selectHTML = ""; let selectHTML = "";
const filterOperation = target.getAttribute("data-op") const filterOperation = target.getAttribute("data-op");
switch (colType) { switch (colType) {
case "text": case "text":
selectHTML = `<option ${"=" === filterOperation ? "selected" : ""} value="=">${window.siyuan.languages.filterOperatorIs}</option> selectHTML = `<option ${"=" === filterOperation ? "selected" : ""} value="=">${window.siyuan.languages.filterOperatorIs}</option>
@ -457,12 +457,12 @@ const setFilter = (protyle: IProtyle, data: IAV, target: HTMLElement) => {
menu.addItem({ menu.addItem({
iconHTML: "", iconHTML: "",
label: `<select class="b3-select fn__size200">${selectHTML}</select>` label: `<select class="b3-select fn__size200">${selectHTML}</select>`
}) });
menu.addItem({ menu.addItem({
iconHTML: "", iconHTML: "",
label: `<input value="${target.getAttribute("data-value")}" class="b3-text-field fn__size200">` label: `<input value="${target.getAttribute("data-value")}" class="b3-text-field fn__size200">`
}) });
const textElement = (window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement) const textElement = (window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement);
textElement.addEventListener("keydown", (event) => { textElement.addEventListener("keydown", (event) => {
if (event.isComposing) { if (event.isComposing) {
event.preventDefault(); event.preventDefault();
@ -472,11 +472,11 @@ const setFilter = (protyle: IProtyle, data: IAV, target: HTMLElement) => {
menu.close(); menu.close();
event.preventDefault(); event.preventDefault();
} }
}) });
const rectTarget = target.getBoundingClientRect(); const rectTarget = target.getBoundingClientRect();
menu.open({x: rectTarget.left, y: rectTarget.bottom}); menu.open({x: rectTarget.left, y: rectTarget.bottom});
textElement.select(); textElement.select();
} };
const addFilter = (options: { const addFilter = (options: {
data: IAV, data: IAV,
@ -535,7 +535,7 @@ const addFilter = (options: {
y: options.rect.bottom, y: options.rect.bottom,
h: options.rect.height, h: options.rect.height,
}); });
} };
const getFiltersHTML = (data: IAV) => { const getFiltersHTML = (data: IAV) => {
let html = ""; let html = "";
@ -548,7 +548,7 @@ const getFiltersHTML = (data: IAV) => {
<svg><use xlink:href="#${getColIconByType(item.type)}"></use></svg> <svg><use xlink:href="#${getColIconByType(item.type)}"></use></svg>
<span class="fn__ellipsis">${item.name}${filterValue ? ": " + filterValue : ""}</span> <span class="fn__ellipsis">${item.name}${filterValue ? ": " + filterValue : ""}</span>
</span>`; </span>`;
return true return true;
} }
}); });
return filterHTML; return filterHTML;

View file

@ -68,9 +68,9 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal
parentNodeElement = parentNodeElement.parentElement; parentNodeElement = parentNodeElement.parentElement;
} }
let contentTop = 0; let contentTop = 0;
let topElement = protyle.element.firstElementChild let topElement = protyle.element.firstElementChild;
while (topElement && !topElement.classList.contains("protyle-content")) { while (topElement && !topElement.classList.contains("protyle-content")) {
contentTop += topElement.clientHeight contentTop += topElement.clientHeight;
topElement = topElement.nextElementSibling; topElement = topElement.nextElementSibling;
} }
if (top) { if (top) {