An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:art: https://github.com/siyuan-note/siyuan/issues/9888
Vanessa44773ab354f0
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.tsindex d1499feaf5..196822abce 100644--- a/app/src/protyle/render/av/cell.ts+++ b/app/src/protyle/render/av/cell.ts@@ -70,11 +70,12 @@ const genCellValueByElement = (colType: TAVCol, cellElement: HTMLElement) => {checked: cellElement.querySelector("use").getAttribute("xlink:href") === "#iconCheck" ? true : false}};- }else if (colType === "relation") {+ } else if (colType === "relation") {cellValue = {type: colType,relation: {blockIDs: Array.from(cellElement.querySelectorAll("span")).map((item: HTMLElement) => item.getAttribute("data-id")),+ contents: Array.from(cellElement.querySelectorAll("span")).map((item: HTMLElement) => item.textContent),}};}@@ -163,12 +164,10 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {checked: value ? true : false}};- }else if (colType === "relation") {+ } else if (colType === "relation") {cellValue = {type: colType,- relation: {- blockIDs: value as string[],- }+ relation: value};}}diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.tsindex e497a63657..a92e10cde8 100644--- a/app/src/protyle/render/av/openMenuPanel.ts+++ b/app/src/protyle/render/av/openMenuPanel.ts@@ -145,64 +145,10 @@ export const openMenuPanel = (options: {if (!targetElement) {return;}- let type = "columns";const isTop = targetElement.classList.contains("dragover__top");- if (targetElement.querySelector('[data-type="removeSort"]')) {- type = "sorts";- } else if (targetElement.querySelector('[data-type="removeFilter"]')) {- type = "filters";- } else if (targetElement.querySelector('[data-type="av-view-edit"]')) {- type = "switcher";- } else if (targetElement.querySelector('[data-type="editAssetItem"]')) {- type = "assets";- } else if (targetElement.querySelector('[data-type="setColOption"]')) {- const colId = options.cellElements ? options.cellElements[0].dataset.colId : menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id");- const changeData = data.view.columns.find((column) => column.id === colId).options;- const oldData = Object.assign([], changeData);- let targetOption: { name: string, color: string };- changeData.find((option, index: number) => {- if (option.name === sourceElement.dataset.name) {- targetOption = changeData.splice(index, 1)[0];- return true;- }- });- changeData.find((option, index: number) => {- if (option.name === targetElement.dataset.name) {- if (isTop) {- changeData.splice(index, 0, targetOption);- } else {- changeData.splice(index + 1, 0, targetOption);- }- return true;- }- });- transaction(options.protyle, [{- action: "updateAttrViewColOptions",- id: colId,- avID: data.id,- data: changeData,- }], [{- action: "updateAttrViewColOptions",- id: colId,- avID: data.id,- data: oldData,- }]);- if (options.cellElements) {- menuElement.innerHTML = getSelectHTML(data.view, options.cellElements);- bindSelectEvent(options.protyle, data, menuElement, options.cellElements);- } else {- menuElement.innerHTML = getEditHTML({- protyle: options.protyle,- data,- colId- });- bindEditEvent({protyle: options.protyle, data, menuElement});- }- return;- }const sourceId = sourceElement.dataset.id;const targetId = targetElement.dataset.id;- if (type === "sorts") {+ if (targetElement.querySelector('[data-type="removeSort"]')) {const changeData = data.view.sorts;const oldData = Object.assign([], changeData);let sortFilter: IAVSort;@@ -236,28 +182,7 @@ export const openMenuPanel = (options: {bindSortsEvent(options.protyle, menuElement, data);return;}- if (type === "switcher") {- transaction(options.protyle, [{- action: "sortAttrViewView",- avID,- id: sourceId,- previousID: isTop ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")- }], [{- action: "sortAttrViewView",- avID,- id: sourceId,- previousID: sourceElement.previousElementSibling?.getAttribute("data-id")- }]);- if (isTop) {- targetElement.before(sourceElement);- targetElement.classList.remove("dragover__top");- } else {- targetElement.after(sourceElement);- targetElement.classList.remove("dragover__bottom");- }- return;- }- if (type === "filters") {+ if (targetElement.querySelector('[data-type="removeFilter"]')) {const changeData = data.view.filters;const oldData = Object.assign([], changeData);let targetFilter: IAVFilter;@@ -290,7 +215,28 @@ export const openMenuPanel = (options: {menuElement.innerHTML = getFiltersHTML(data.view);return;}- if (type === "assets") {+ if (targetElement.querySelector('[data-type="av-view-edit"]')) {+ transaction(options.protyle, [{+ action: "sortAttrViewView",+ avID,+ id: sourceId,+ previousID: isTop ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")+ }], [{+ action: "sortAttrViewView",+ avID,+ id: sourceId,+ previousID: sourceElement.previousElementSibling?.getAttribute("data-id")+ }]);+ if (isTop) {+ targetElement.before(sourceElement);+ targetElement.classList.remove("dragover__top");+ } else {+ targetElement.after(sourceElement);+ targetElement.classList.remove("dragover__bottom");+ }+ return;+ }+ if (targetElement.querySelector('[data-type="editAssetItem"]')) {if (isTop) {targetElement.before(sourceElement);} else {@@ -315,6 +261,56 @@ export const openMenuPanel = (options: {});return;}+ if (targetElement.querySelector('[data-type="setColOption"]')) {+ const colId = options.cellElements ? options.cellElements[0].dataset.colId : menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id");+ const changeData = data.view.columns.find((column) => column.id === colId).options;+ const oldData = Object.assign([], changeData);+ let targetOption: { name: string, color: string };+ changeData.find((option, index: number) => {+ if (option.name === sourceElement.dataset.name) {+ targetOption = changeData.splice(index, 1)[0];+ return true;+ }+ });+ changeData.find((option, index: number) => {+ if (option.name === targetElement.dataset.name) {+ if (isTop) {+ changeData.splice(index, 0, targetOption);+ } else {+ changeData.splice(index + 1, 0, targetOption);+ }+ return true;+ }+ });+ transaction(options.protyle, [{+ action: "updateAttrViewColOptions",+ id: colId,+ avID: data.id,+ data: changeData,+ }], [{+ action: "updateAttrViewColOptions",+ id: colId,+ avID: data.id,+ data: oldData,+ }]);+ if (options.cellElements) {+ menuElement.innerHTML = getSelectHTML(data.view, options.cellElements);+ bindSelectEvent(options.protyle, data, menuElement, options.cellElements);+ } else {+ menuElement.innerHTML = getEditHTML({+ protyle: options.protyle,+ data,+ colId+ });+ bindEditEvent({protyle: options.protyle, data, menuElement});+ }+ return;+ }+ if (targetElement.getAttribute("data-type") === "setRelationCell") {++ return;+ }+transaction(options.protyle, [{action: "sortAttrViewCol",avID,diff --git a/app/src/protyle/render/av/relation.ts b/app/src/protyle/render/av/relation.tsindex 467f4cc8a0..84293027ad 100644--- a/app/src/protyle/render/av/relation.ts+++ b/app/src/protyle/render/av/relation.ts@@ -260,23 +260,29 @@ export const setRelationCell = (protyle: IProtyle, data: IAV, nodeElement: HTMLEif (!menuElement) {return}- const ids: string[] = [];+ const newValue: {+ blockIDs: string[]+ contents?: string[]+ } = {+ blockIDs: [],+ contents: []+ }Array.from(menuElement.children).forEach((item) => {const id = item.getAttribute("data-id")if (item.getAttribute("draggable") && id) {- ids.push(id);+ newValue.blockIDs.push(id);+ newValue.contents.push(item.textContent.trim());}})- const empty = `<button class="b3-menu__item">- <span class="b3-menu__label">${window.siyuan.languages.emptyContent}</span>-</button>`const targetId = target.getAttribute("data-id")const separatorElement = menuElement.querySelector(".b3-menu__separator");if (target.getAttribute("draggable")) {if (!separatorElement.nextElementSibling.getAttribute("data-id")) {separatorElement.nextElementSibling.remove();}- ids.splice(ids.indexOf(targetId), 1);+ const removeIndex = newValue.blockIDs.indexOf(targetId);+ newValue.blockIDs.splice(removeIndex, 1);+ newValue.contents.splice(removeIndex, 1);separatorElement.after(target);target.outerHTML = genSelectItemHTML("unselect", targetId, target.querySelector(".b3-menu__label").textContent);if (!separatorElement.previousElementSibling) {@@ -286,12 +292,13 @@ export const setRelationCell = (protyle: IProtyle, data: IAV, nodeElement: HTMLEif (!separatorElement.previousElementSibling.getAttribute("data-id")) {separatorElement.previousElementSibling.remove();}- ids.push(targetId);+ newValue.blockIDs.push(targetId);+ newValue.contents.push(target.textContent.trim());separatorElement.before(target);target.outerHTML = genSelectItemHTML("selected", targetId, target.querySelector(".b3-menu__label").textContent);if (!separatorElement.nextElementSibling) {separatorElement.insertAdjacentHTML("afterend", genSelectItemHTML("empty"));}}- updateCellsValue(protyle, nodeElement, ids);+ updateCellsValue(protyle, nodeElement, newValue);};