Vanessa 2024-04-06 22:25:38 +08:00
parent 0f2c7fd418
commit 00f7439daf
7 changed files with 47 additions and 42 deletions

View File

@ -1,4 +1,5 @@
{ {
"showTitle": "Show database title",
"fillCreated": "Default fill created time", "fillCreated": "Default fill created time",
"removeCard": "Remove flashcard", "removeCard": "Remove flashcard",
"updateLayout": "Update layout", "updateLayout": "Update layout",

View File

@ -1,4 +1,5 @@
{ {
"showTitle": "Mostrar título de la base de datos",
"fillCreated": "Hora de creación del relleno predeterminado", "fillCreated": "Hora de creación del relleno predeterminado",
"removeCard": "Eliminar tarjeta flash", "removeCard": "Eliminar tarjeta flash",
"updateLayout": "Actualizar diseño", "updateLayout": "Actualizar diseño",

View File

@ -1,4 +1,5 @@
{ {
"showTitle": "Afficher le titre de la base de données",
"fillCreated": "Heure de création de remplissage par défaut", "fillCreated": "Heure de création de remplissage par défaut",
"removeCard": "Supprimer la flashcard", "removeCard": "Supprimer la flashcard",
"updateLayout": "Mettre à jour la mise en page", "updateLayout": "Mettre à jour la mise en page",

View File

@ -1,4 +1,5 @@
{ {
"showTitle": "顯示資料庫標題",
"fillCreated": "Default fill creation time", "fillCreated": "Default fill creation time",
"removeCard": "移除閃卡", "removeCard": "移除閃卡",
"updateLayout": "更新版面配置", "updateLayout": "更新版面配置",

View File

@ -1,4 +1,5 @@
{ {
"showTitle": "显示数据库标题",
"fillCreated": "默认填充创建时间", "fillCreated": "默认填充创建时间",
"removeCard": "移除闪卡", "removeCard": "移除闪卡",
"updateLayout": "更新布局", "updateLayout": "更新布局",

View File

@ -164,7 +164,7 @@ export const openMenuPanel = (options: {
} else if (options.type === "edit") { } else if (options.type === "edit") {
bindEditEvent({protyle: options.protyle, data, menuElement, isCustomAttr}); bindEditEvent({protyle: options.protyle, data, menuElement, isCustomAttr});
} else if (options.type === "config") { } else if (options.type === "config") {
bindViewEvent({protyle: options.protyle, data, menuElement}); bindViewEvent({protyle: options.protyle, data, menuElement, blockElement: options.blockElement});
} }
} }
if (options.cb) { if (options.cb) {
@ -479,7 +479,7 @@ export const openMenuPanel = (options: {
} else if (type === "go-config") { } else if (type === "go-config") {
menuElement.innerHTML = getViewHTML(data.view); menuElement.innerHTML = getViewHTML(data.view);
setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height); setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);
bindViewEvent({protyle: options.protyle, data, menuElement}); bindViewEvent({protyle: options.protyle, data, menuElement, blockElement: options.blockElement});
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
break; break;
@ -690,39 +690,6 @@ export const openMenuPanel = (options: {
event.preventDefault(); event.preventDefault();
event.stopPropagation(); event.stopPropagation();
break; break;
} else if (type === "toggle-view-title") {
if (target.firstElementChild.getAttribute("xlink:href") === "#iconEyeoff") {
// hide
transaction(options.protyle, [{
action: "hideAttrViewName",
avID,
blockID,
data: true
}], [{
action: "hideAttrViewName",
avID,
blockID,
data: false
}]);
options.blockElement.querySelector(".av__title").classList.add("av__title--hide");
} else {
transaction(options.protyle, [{
action: "hideAttrViewName",
avID,
blockID,
data: false
}], [{
action: "hideAttrViewName",
avID,
blockID,
data: true
}]);
options.blockElement.querySelector(".av__title").classList.remove("av__title--hide");
}
avPanelElement.remove();
event.preventDefault();
event.stopPropagation();
break;
} else if (type === "duplicate-view") { } else if (type === "duplicate-view") {
const id = Lute.NewNodeID(); const id = Lute.NewNodeID();
transaction(options.protyle, [{ transaction(options.protyle, [{

View File

@ -88,6 +88,7 @@ export const bindViewEvent = (options: {
protyle: IProtyle, protyle: IProtyle,
data: IAV, data: IAV,
menuElement: HTMLElement menuElement: HTMLElement
blockElement: Element
}) => { }) => {
const inputElement = options.menuElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement; const inputElement = options.menuElement.querySelector('.b3-text-field[data-type="name"]') as HTMLInputElement;
inputElement.addEventListener("blur", () => { inputElement.addEventListener("blur", () => {
@ -117,6 +118,39 @@ export const bindViewEvent = (options: {
} }
}); });
inputElement.select(); inputElement.select();
const toggleTitleElement = options.menuElement.querySelector('.b3-switch[data-type="toggle-view-title"]') as HTMLInputElement;
toggleTitleElement.addEventListener("change", () => {
const avID = options.blockElement.getAttribute("data-av-id");
const blockID = options.blockElement.getAttribute("data-node-id");
if (!toggleTitleElement.checked) {
// hide
transaction(options.protyle, [{
action: "hideAttrViewName",
avID,
blockID,
data: true
}], [{
action: "hideAttrViewName",
avID,
blockID,
data: false
}]);
options.blockElement.querySelector(".av__title").classList.add("av__title--hide");
} else {
transaction(options.protyle, [{
action: "hideAttrViewName",
avID,
blockID,
data: false
}], [{
action: "hideAttrViewName",
avID,
blockID,
data: true
}]);
options.blockElement.querySelector(".av__title").classList.remove("av__title--hide");
}
})
}; };
export const getViewHTML = (data: IAVTable) => { export const getViewHTML = (data: IAVTable) => {
@ -154,13 +188,12 @@ export const getViewHTML = (data: IAVTable) => {
<span class="b3-menu__accelerator">${data.pageSize}</span> <span class="b3-menu__accelerator">${data.pageSize}</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>
<button class="b3-menu__item"> <label class="b3-menu__item">
<div class="b3-menu__label fn__flex">
<svg class="b3-menu__icon"></svg> <svg class="b3-menu__icon"></svg>
<span class="b3-menu__label">${window.siyuan.languages.title}</span> <span class="fn__flex-center">${window.siyuan.languages.showTitle}</span>
</div> <span class="fn__space fn__flex-1"></span>
<svg class="b3-menu__action" data-type="toggle-view-title"><use xlink:href="#iconEye${data.hideAttrViewName ? "" : "off"}"></use></svg> <input data-type="toggle-view-title" type="checkbox" class="b3-switch b3-switch--menu" ${data.hideAttrViewName ? "" : "checked"}>
</button> </label>
<button class="b3-menu__separator"></button> <button class="b3-menu__separator"></button>
<button class="b3-menu__item" data-type="duplicate-view"> <button class="b3-menu__item" data-type="duplicate-view">
<svg class="b3-menu__icon"> <svg class="b3-menu__icon">