This commit is contained in:
Vanessa 2023-07-04 09:20:55 +08:00
parent ed258564e7
commit 6fa7364067
4 changed files with 16 additions and 16 deletions

View file

@ -46,11 +46,11 @@ export const hintSlash = (key: string, protyle: IProtyle) => {
filter: ["ai chat"], filter: ["ai chat"],
value: Constants.ZWSP + 5, value: Constants.ZWSP + 5,
html: '<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconSparkles"></use></svg><span class="b3-list-item__text">AI Chat</span></div>', html: '<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconSparkles"></use></svg><span class="b3-list-item__text">AI Chat</span></div>',
}, { }, /*{
filter: ["属性视图", "shuxingshitu", "sxst", "attribute view"], filter: ["属性视图", "shuxingshitu", "sxst", "attribute view"],
value: '<div data-type="NodeAttributeView" data-av-type="table"></div>', value: '<div data-type="NodeAttributeView" data-av-type="table"></div>',
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconDatabase"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.attributeView}</span></div>`, html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconDatabase"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.attributeView}</span></div>`,
}, { },*/ {
filter: ["文档", "子文档", "wendang", "wd", "ziwendang", "zwd", "xjwd"], filter: ["文档", "子文档", "wendang", "wd", "ziwendang", "zwd", "xjwd"],
value: Constants.ZWSP + 4, value: Constants.ZWSP + 4,
html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.newFile}</span><span class="b3-menu__accelerator">${updateHotkeyTip(window.siyuan.config.keymap.general.newFile.custom)}</span></div>`, html: `<div class="b3-list-item__first"><svg class="b3-list-item__graphic"><use xlink:href="#iconFile"></use></svg><span class="b3-list-item__text">${window.siyuan.languages.newFile}</span><span class="b3-menu__accelerator">${updateHotkeyTip(window.siyuan.config.keymap.general.newFile.custom)}</span></div>`,

View file

@ -249,6 +249,6 @@ export const updateAVName = (protyle: IProtyle, blockElement: Element) => {
data: { data: {
name: nameElement.dataset.title, name: nameElement.dataset.title,
} }
}]) }]);
nameElement.dataset.title = nameElement.textContent.trim(); nameElement.dataset.title = nameElement.textContent.trim();
} };

View file

@ -252,15 +252,15 @@ const getConfigHTML = (data: IAV) => {
const bindSortsEvent = (protyle: IProtyle, menuElement: HTMLElement, data: IAV) => { const bindSortsEvent = (protyle: IProtyle, menuElement: HTMLElement, data: IAV) => {
menuElement.querySelectorAll("select").forEach((item: HTMLSelectElement) => { menuElement.querySelectorAll("select").forEach((item: HTMLSelectElement) => {
item.addEventListener("change", (event) => { item.addEventListener("change", () => {
const colId = item.parentElement.getAttribute("data-id"); const colId = item.parentElement.getAttribute("data-id");
const oldSort = JSON.parse(JSON.stringify(data.sorts)); const oldSort = JSON.parse(JSON.stringify(data.sorts));
if (item.previousElementSibling.classList.contains("b3-menu__icon")) { if (item.previousElementSibling.classList.contains("b3-menu__icon")) {
data.sorts.find((sort: IAVSort) => { data.sorts.find((sort: IAVSort) => {
if (sort.column === colId) { if (sort.column === colId) {
sort.column = item.value sort.column = item.value;
item.parentElement.setAttribute("data-id", item.value); item.parentElement.setAttribute("data-id", item.value);
return true return true;
} }
}); });
} else { } else {
@ -281,17 +281,17 @@ const bindSortsEvent = (protyle: IProtyle, menuElement: HTMLElement, data: IAV)
}]); }]);
}); });
}); });
} };
const getSortsHTML = (data: IAV) => { const getSortsHTML = (data: IAV) => {
let html = ""; let html = "";
const genSortItem = (id: string) => { const genSortItem = (id: string) => {
let sortHTML = '' let sortHTML = "";
data.columns.forEach((item) => { data.columns.forEach((item) => {
sortHTML += `<option value="${item.id}" ${item.id === id ? "selected" : ""}>${item.name}</option>` sortHTML += `<option value="${item.id}" ${item.id === id ? "selected" : ""}>${item.name}</option>`;
}) });
return sortHTML; return sortHTML;
} };
data.sorts.forEach((item: IAVSort) => { data.sorts.forEach((item: IAVSort) => {
html += `<button class="b3-menu__item" data-id="${item.column}"> html += `<button class="b3-menu__item" data-id="${item.column}">
<svg class="b3-menu__icon"><use xlink:href="#iconDrag"></use></svg> <svg class="b3-menu__icon"><use xlink:href="#iconDrag"></use></svg>
@ -323,7 +323,7 @@ ${html}
<svg class="b3-menu__icon"><use xlink:href="#iconTrashcan"></use></svg> <svg class="b3-menu__icon"><use xlink:href="#iconTrashcan"></use></svg>
<span class="b3-menu__label">${window.siyuan.languages.delete}</span> <span class="b3-menu__label">${window.siyuan.languages.delete}</span>
</button>`; </button>`;
} };
const getPropertiesHTML = (data: IAV) => { const getPropertiesHTML = (data: IAV) => {
let showHTML = ""; let showHTML = "";
@ -435,5 +435,5 @@ const addSort = (options: {
x: options.rect.left, x: options.rect.left,
y: options.rect.bottom, y: options.rect.bottom,
h: options.rect.height, h: options.rect.height,
}) });
} };

View file

@ -137,7 +137,7 @@ export const refreshAV = (protyle: IProtyle, operation: IOperation) => {
} }
lastElement = protyle.contentElement; lastElement = protyle.contentElement;
lastParentID = operation.parentID; lastParentID = operation.parentID;
const avId = operation.action === "setAttrView" ? operation.id : operation.parentID const avId = operation.action === "setAttrView" ? operation.id : operation.parentID;
if (operation.action === "addAttrViewCol") { if (operation.action === "addAttrViewCol") {
Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${avId}"]`)).forEach((item: HTMLElement) => { Array.from(protyle.wysiwyg.element.querySelectorAll(`[data-av-id="${avId}"]`)).forEach((item: HTMLElement) => {
item.removeAttribute("data-render"); item.removeAttribute("data-render");