Skip to content

Commit

Permalink
🎨 #13375
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Dec 9, 2024
1 parent 2040665 commit 0ae04cf
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 13 deletions.
1 change: 1 addition & 0 deletions app/appearance/langs/de_DE.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"removeAV": "Aus der Datenbank entfernen",
"empty": "Leer",
"newRowInRelation": "Erstellen Sie einen neuen Eintrag in ${x} <b class='ft__on-surface'>${y}</b>",
"copyKeyContent": "Primärschlüsseltext kopieren",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/en_US.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"removeAV": "Remove from database",
"empty": "Empty",
"newRowInRelation": "Create a new entry in ${x} <b class='ft__on-surface'>${y}</b>",
"copyKeyContent": "Copy primary key text",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/es_ES.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"removeAV": "Eliminar de la base de datos",
"empty": "Vacío",
"newRowInRelation": "Crear una nueva entrada en ${x} <b class='ft__on-surface'>${y}</b>",
"copyKeyContent": "Copiar texto de la clave principal",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/fr_FR.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"removeAV": "Supprimer de la base de données",
"empty": "Vide",
"newRowInRelation": "Créer une nouvelle entrée dans ${x} <b class='ft__on-surface'>${y}</b>",
"copyKeyContent": "Copier le texte de la clé principale",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/he_IL.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"removeAV": "הסר ממסד הנתונים",
"empty": "ריק",
"newRowInRelation": "צור ערך חדש ב-${x} <b class='ft__on-surface'>${y}</b>",
"copyKeyContent": "העתק טקסט מפתח ראשי",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/it_IT.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"removeAV": "Rimuovi dal database",
"empty": "Vuoto",
"newRowInRelation": "Crea una nuova voce in ${x} <b class='ft__on-surface'>${y}</b>",
"copyKeyContent": "Copia il testo della chiave primaria",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/ja_JP.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"removeAV": "データベースから削除",
"empty": "空白",
"newRowInRelation": "${x} に新しい項目を作成 <b class='ft__on-surface'>${y}</b>",
"copyKeyContent": "主キーのテキストをコピー",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/pl_PL.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"removeAV": "Usuń z bazy danych",
"empty": "Pusty",
"newRowInRelation": "Utwórz nowy wpis w ${x} <b class='ft__on-surface'>${y}</b>",
"copyKeyContent": "Skopiuj tekst klucza głównego",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/ru_RU.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"removeAV": "Удалить из базы данных",
"empty": "Пусто",
"newRowInRelation": "Создать новую запись в ${x} <b class='ft__on-surface'>${y}</b>",
"copyKeyContent": "Скопировать текст основного ключа",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/zh_CHT.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"removeAV": "從資料庫中移除",
"empty": "空白",
"newRowInRelation": "在 ${x} 中新建條目 <b class='ft__on-surface'>${y}</b>",
"copyKeyContent": "複製主鍵文本",
Expand Down
1 change: 1 addition & 0 deletions app/appearance/langs/zh_CN.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"removeAV": "从数据库中移除",
"empty": "空白",
"newRowInRelation": "在 ${x} 中新建条目 <b class='ft__on-surface'>${y}</b>",
"copyKeyContent": "复制主键文本",
Expand Down
22 changes: 14 additions & 8 deletions app/src/assets/scss/business/_custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,21 @@
}

&__avheader {
border-bottom: 1px solid var(--b3-border-color);
padding: 8px;
color: var(--b3-protyle-inline-blockref-color);
opacity: .86;
transition: var(--b3-transition);
cursor: pointer;
display: flex;
padding: 0 8px 0 32px;
align-items: center;
min-height: 42px;

&:hover {
opacity: 1;
.block__logo {
color: var(--b3-protyle-inline-blockref-color);
opacity: .86;
transition: var(--b3-transition);
flex: 1;

&:hover {
cursor: pointer;
opacity: 1;
}
}
}

Expand Down
35 changes: 30 additions & 5 deletions app/src/protyle/render/av/blockAttr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {previewImage} from "../../preview/image";
import {webUtils} from "electron";
/// #endif
import {isBrowser} from "../../../util/functions";
import {Constants} from "../../../constants";

const genAVRollupHTML = (value: IAVCellValue) => {
let html = "";
Expand Down Expand Up @@ -179,10 +180,12 @@ export const renderAVAttribute = (element: HTMLElement, id: string, protyle: IPr
avID: string
avName: string
}) => {
let innerHTML = `<div class="custom-attr__avheader block__logo popover__block" data-id='${JSON.stringify(table.blockIDs)}'>
<div class="fn__flex-1"></div>
<svg class="block__logoicon"><use xlink:href="#iconDatabase"></use></svg><span>${table.avName || window.siyuan.languages.database}</span>
<div class="fn__flex-1"></div>
let innerHTML = `<div class="custom-attr__avheader">
<div class="block__logo popover__block" data-id='${JSON.stringify(table.blockIDs)}'>
<svg class="block__logoicon"><use xlink:href="#iconDatabase"></use></svg><span>${table.avName || window.siyuan.languages.database}</span>
</div>
<span class="fn__space"></span>
<span data-type="remove" class="block__icon block__icon--show b3-tooltips__w b3-tooltips" aria-label="${window.siyuan.languages.removeAV}"><svg><use xlink:href="#iconTrashcan"></use></svg></span>
</div>`;
table.keyValues?.forEach(item => {
innerHTML += `<div class="block__icons av__row" data-id="${id}" data-col-id="${item.key.id}">
Expand All @@ -199,7 +202,7 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone"].includes
});
innerHTML += `<div class="fn__hr"></div>
<button data-type="addColumn" class="b3-button b3-button--cancel"><svg><use xlink:href="#iconAdd"></use></svg>${window.siyuan.languages.newCol}</button>
<div class="fn__hr--b"></div>`;
<div class="fn__hr--b"></div><div class="fn__hr--b"></div>`;
html += `<div data-av-id="${table.avID}" data-node-id="${id}" data-type="NodeAttributeView">${innerHTML}</div>`;

if (element.innerHTML) {
Expand Down Expand Up @@ -346,6 +349,28 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone"].includes
}
});
element.addEventListener("click", (event) => {
const removeElement = hasClosestByAttribute(event.target as HTMLElement, "data-type", "remove")
if (removeElement) {
const blockElement = hasClosestBlock(removeElement)
if (blockElement) {
transaction(protyle, [{
action: "removeAttrViewBlock",
srcIDs: [id],
avID: blockElement.dataset.avId,
}]);
blockElement.remove();
if (!element.innerHTML) {
window.siyuan.dialogs.find(item => {
if (item.element.getAttribute("data-key") === Constants.DIALOG_ATTR) {
item.destroy();
return true;
}
})
}
}
event.stopPropagation();
return;
}
openEdit(protyle, element, event);
});
element.addEventListener("contextmenu", (event) => {
Expand Down

0 comments on commit 0ae04cf

Please sign in to comment.