🎨 database

This commit is contained in:
Vanessa 2023-10-06 10:25:59 +08:00
parent 0df2bd7963
commit 61473eefbc
2 changed files with 13 additions and 4 deletions

View file

@ -14,7 +14,8 @@ export const duplicateCol = (options: {
type: TAVCol, type: TAVCol,
avID: string, avID: string,
colId: string, colId: string,
newValue: string newValue: string,
icon: string
}) => { }) => {
const id = Lute.NewNodeID(); const id = Lute.NewNodeID();
const nameMatch = options.newValue.match(/^(.*) \((\d+)\)$/); const nameMatch = options.newValue.match(/^(.*) \((\d+)\)$/);
@ -38,6 +39,7 @@ export const duplicateCol = (options: {
name: options.newValue, name: options.newValue,
avID: options.avID, avID: options.avID,
type: options.type, type: options.type,
data: options.icon,
id id
}, { }, {
action: "sortAttrViewCol", action: "sortAttrViewCol",
@ -61,6 +63,7 @@ export const duplicateCol = (options: {
name: options.newValue, name: options.newValue,
avID: options.avID, avID: options.avID,
type: options.type, type: options.type,
data: options.icon,
id id
}, { }, {
action: "sortAttrViewCol", action: "sortAttrViewCol",
@ -78,6 +81,7 @@ export const duplicateCol = (options: {
protyle: options.protyle, protyle: options.protyle,
type: options.type, type: options.type,
name: options.newValue, name: options.newValue,
icon: options.icon,
previousId: options.colId, previousId: options.colId,
id id
}); });
@ -334,7 +338,8 @@ export const addAttrViewColAnimation = (options: {
type: TAVCol, type: TAVCol,
name: string, name: string,
previousId?: string, previousId?: string,
id: string id: string,
icon?: string
}) => { }) => {
if (!options.blockElement) { if (!options.blockElement) {
return; return;
@ -350,7 +355,7 @@ export const addAttrViewColAnimation = (options: {
if (index === 0) { if (index === 0) {
html = `<div class="av__cell" data-col-id="${options.id}" data-dtype="${options.type}" style="width: 200px;white-space: nowrap;"> html = `<div class="av__cell" data-col-id="${options.id}" data-dtype="${options.type}" style="width: 200px;white-space: nowrap;">
<div draggable="true" class="av__cellheader"> <div draggable="true" class="av__cellheader">
<svg><use xlink:href="#${getColIconByType(options.type)}"></use></svg> ${options.icon ? unicode2Emoji(options.icon, "av__cellicon", true) : `<svg class="av__cellicon"><use xlink:href="#${getColIconByType(options.type)}"></use></svg>`}
<span class="av__celltext">${options.name}</span> <span class="av__celltext">${options.name}</span>
</div> </div>
<div class="av__widthdrag"></div> <div class="av__widthdrag"></div>
@ -394,7 +399,8 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
type: "readonly", type: "readonly",
label: `<input style="margin: 4px 0" class="b3-text-field" type="text" value="${oldValue}">`, label: `<input style="margin: 4px 0" class="b3-text-field" type="text" value="${oldValue}">`,
bind(element) { bind(element) {
const iconElement = element.querySelector(".block__icon") as HTMLElement const iconElement = element.querySelector(".block__icon") as HTMLElement;
iconElement.setAttribute("data-icon", iconElement.dataset.icon);
iconElement.addEventListener("click", (event) => { iconElement.addEventListener("click", (event) => {
const rect = iconElement.getBoundingClientRect(); const rect = iconElement.getBoundingClientRect();
openEmojiPanel("", "av", { openEmojiPanel("", "av", {
@ -414,6 +420,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
avID, avID,
data: cellElement.dataset.icon, data: cellElement.dataset.icon,
}]); }]);
iconElement.setAttribute("data-icon", unicode);
iconElement.innerHTML = unicode ? unicode2Emoji(unicode) : `<svg><use xlink:href="#${getColIconByType(type)}"></use></svg>` iconElement.innerHTML = unicode ? unicode2Emoji(unicode) : `<svg><use xlink:href="#${getColIconByType(type)}"></use></svg>`
updateAttrViewCellAnimation(cellElement); updateAttrViewCellAnimation(cellElement);
}); });
@ -555,6 +562,7 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen
type, type,
avID, avID,
colId, colId,
icon: menu.element.querySelector(".block__icon").getAttribute("data-icon"),
newValue: (window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement).value newValue: (window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement).value
}); });
} }

View file

@ -660,6 +660,7 @@ export const openMenuPanel = (options: {
type: colData.type, type: colData.type,
avID, avID,
colId, colId,
icon: colData.icon,
newValue: colData.name newValue: colData.name
}); });
avPanelElement.remove(); avPanelElement.remove();