mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
🎨 属性面板数据库关联设置
This commit is contained in:
parent
c2075e6387
commit
ab32bb9027
5 changed files with 13 additions and 6 deletions
|
|
@ -846,6 +846,7 @@
|
||||||
|
|
||||||
&__label {
|
&__label {
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
min-height: 30px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__icon.fn__grab {
|
&__icon.fn__grab {
|
||||||
|
|
|
||||||
|
|
@ -130,4 +130,8 @@
|
||||||
.av__row.dragover__top::after {
|
.av__row.dragover__top::after {
|
||||||
top: -1.5px;
|
top: -1.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.av__cell--relation {
|
||||||
|
display: inline-flex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -129,12 +129,14 @@ export const genAVValueHTML = (value: IAVCellValue) => {
|
||||||
<a ${value.email.content ? `href="mailto:${value.email.content}"` : ""} target="_blank" aria-label="${window.siyuan.languages.openBy}" class="block__icon block__icon--show fn__flex-center b3-tooltips__w b3-tooltips"><svg><use xlink:href="#iconEmail"></use></svg></a>`;
|
<a ${value.email.content ? `href="mailto:${value.email.content}"` : ""} target="_blank" aria-label="${window.siyuan.languages.openBy}" class="block__icon block__icon--show fn__flex-center b3-tooltips__w b3-tooltips"><svg><use xlink:href="#iconEmail"></use></svg></a>`;
|
||||||
break;
|
break;
|
||||||
case "relation":
|
case "relation":
|
||||||
value?.relation?.contents?.forEach((item) => {
|
value?.relation?.contents?.forEach((item, index) => {
|
||||||
if (item && item.block) {
|
if (item && item.block) {
|
||||||
|
const rowID = value.relation.blockIDs[index];
|
||||||
if (item?.isDetached) {
|
if (item?.isDetached) {
|
||||||
html += `<span class="av__cell--relation"><span>➖ </span><span class="av__celltext">${Lute.EscapeHTMLStr(item.block.content || window.siyuan.languages.untitled)}</span></span>`;
|
html += `<span data-row-id="${rowID}" class="av__cell--relation"><span class="b3-menu__avemoji">➖</span><span class="av__celltext">${Lute.EscapeHTMLStr(item.block.content || window.siyuan.languages.untitled)}</span></span>`;
|
||||||
} else {
|
} else {
|
||||||
html += `<span class="av__cell--relation"><span data-unicode="${item.block.icon || ""}">${unicode2Emoji(item.block.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].file)} </span><span data-type="block-ref" data-id="${item.block.id}" data-subtype="s" class="av__celltext av__celltext--ref">${Lute.EscapeHTMLStr(item.block.content || window.siyuan.languages.untitled)}</span></span>`;
|
// data-block-id 用于更新 emoji
|
||||||
|
html += `<span data-row-id="${rowID}" class="av__cell--relation" data-block-id="${item.block.id}"><span class="b3-menu__avemoji" data-unicode="${item.block.icon || ""}">${unicode2Emoji(item.block.icon || window.siyuan.storage[Constants.LOCAL_IMAGES].file)}</span><span data-type="block-ref" data-id="${item.block.id}" data-subtype="s" class="av__celltext av__celltext--ref">${Lute.EscapeHTMLStr(item.block.content || window.siyuan.languages.untitled)}</span></span>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -212,7 +214,7 @@ class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "block"]
|
||||||
|
|
||||||
if (element.innerHTML) {
|
if (element.innerHTML) {
|
||||||
// 防止 blockElement 找不到
|
// 防止 blockElement 找不到
|
||||||
element.querySelector(`.av[data-node-id="${id}"][data-av-id="${table.avID}"]`).innerHTML = innerHTML;
|
element.querySelector(`[data-node-id="${id}"][data-av-id="${table.avID}"]`).innerHTML = innerHTML;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (element.innerHTML === "") {
|
if (element.innerHTML === "") {
|
||||||
|
|
|
||||||
|
|
@ -759,7 +759,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
avRender(item, protyle, () => {
|
avRender(item, protyle, () => {
|
||||||
const attrElement = document.querySelector(`.b3-dialog--open[data-key="${Constants.DIALOG_ATTR}"] .av[data-av-id="${avID}"]`) as HTMLElement;
|
const attrElement = document.querySelector(`.b3-dialog--open[data-key="${Constants.DIALOG_ATTR}"] .custom-attr > [data-av-id="${avID}"]`) as HTMLElement;
|
||||||
if (attrElement) {
|
if (attrElement) {
|
||||||
// 更新属性面板
|
// 更新属性面板
|
||||||
renderAVAttribute(attrElement.parentElement, attrElement.dataset.nodeId, protyle);
|
renderAVAttribute(attrElement.parentElement, attrElement.dataset.nodeId, protyle);
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import {clearSelect} from "../../util/clearSelect";
|
||||||
|
|
||||||
export const getFieldIdByCellElement = (cellElement: Element, viewType: TAVView): string => {
|
export const getFieldIdByCellElement = (cellElement: Element, viewType: TAVView): string => {
|
||||||
if (hasClosestByClassName(cellElement, "custom-attr")) {
|
if (hasClosestByClassName(cellElement, "custom-attr")) {
|
||||||
return (hasClosestByClassName(cellElement, "av__row") as HTMLElement).dataset.id;
|
return cellElement.getAttribute("data-row-id");
|
||||||
}
|
}
|
||||||
return (hasClosestByClassName(cellElement, viewType === "table" ? "av__row" : "av__gallery-item") as HTMLElement).dataset.id;
|
return (hasClosestByClassName(cellElement, viewType === "table" ? "av__row" : "av__gallery-item") as HTMLElement).dataset.id;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue