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/12816
Vanessa94f303da501c
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.tsindex eb84692b48..7f6aea10d0 100644--- a/app/src/protyle/render/av/col.ts+++ b/app/src/protyle/render/av/col.ts@@ -3,7 +3,7 @@ import {transaction} from "../../wysiwyg/transaction";import {fetchPost} from "../../../util/fetch";import {getDefaultOperatorByType, setFilter} from "./filter";import {genCellValue} from "./cell";-import {openMenuPanel} from "./openMenuPanel";+import {getPropertiesHTML, openMenuPanel} from "./openMenuPanel";import {getLabelByNumberFormat} from "./number";import {removeAttrViewColAnimation, updateAttrViewCellAnimation} from "./action";import {openEmojiPanel, unicode2Emoji} from "../../../emoji";@@ -908,6 +908,54 @@ export const showColMenu = (protyle: IProtyle, blockElement: Element, cellElemen}};+export const removeCol = (options: {+ protyle: IProtyle,+ data: IAV,+ previousID: string,+ colData: IAVColumn,+ avID: string,+ blockID: string,+ isCustomAttr: boolean+ menuElement: HTMLElement,+ blockElement: Element+ avPanelElement: Element+ tabRect: DOMRect+}) => {+ const colId = options.menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id");+ const newUpdated = dayjs().format("YYYYMMDDHHmmss");+ transaction(options.protyle, [{+ action: "removeAttrViewCol",+ id: colId,+ avID: options.avID,+ }, {+ action: "doUpdateUpdated",+ id: options.blockID,+ data: newUpdated,+ }], [{+ action: "addAttrViewCol",+ name: options.colData.name,+ avID: options.avID,+ type: options.colData.type,+ id: colId,+ previousID:options.previousID+ }, {+ action: "doUpdateUpdated",+ id: options.blockID,+ data: options.blockElement.getAttribute("updated")+ }]);+ removeAttrViewColAnimation(options.blockElement, colId);+ options.blockElement.setAttribute("updated", newUpdated);++ if (options.isCustomAttr) {+ options.avPanelElement.remove();+ } else {+ options.menuElement.innerHTML = getPropertiesHTML(options.data.view);+ setPosition(options.menuElement,+ options.tabRect.right - options.menuElement.clientWidth, options.tabRect.bottom,+ options.tabRect.height);+ }+}+const genUpdateColItem = (type: TAVCol, oldType: TAVCol) => {return `<button class="b3-menu__item" data-type="updateColType" data-old-type="${oldType}" data-new-type="${type}"><svg class="b3-menu__icon"><use xlink:href="#${getColIconByType(type)}"></use></svg>diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.tsindex 2aba81f022..7ec66dac4b 100644--- a/app/src/protyle/render/av/openMenuPanel.ts+++ b/app/src/protyle/render/av/openMenuPanel.ts@@ -1,6 +1,6 @@import {transaction} from "../../wysiwyg/transaction";import {fetchPost} from "../../../util/fetch";-import {addCol, bindEditEvent, duplicateCol, getColIconByType, getEditHTML} from "./col";+import {addCol, bindEditEvent, duplicateCol, getColIconByType, getEditHTML, removeCol} from "./col";import {setPosition} from "../../../util/setPosition";import {hasClosestByAttribute, hasClosestByClassName} from "../../util/hasClosest";import {addColOptionOrCell, bindSelectEvent, getSelectHTML, removeCellOption, setColOption} from "./select";@@ -8,7 +8,7 @@ import {addFilter, getFiltersHTML, setFilter} from "./filter";import {addSort, bindSortsEvent, getSortsHTML} from "./sort";import {bindDateEvent, getDateHTML} from "./date";import {formatNumber} from "./number";-import {removeAttrViewColAnimation, updateAttrViewCellAnimation} from "./action";+import {updateAttrViewCellAnimation} from "./action";import {addAssetLink, bindAssetEvent, editAssetItem, getAssetHTML, updateAssetCell} from "./asset";import {Constants} from "../../../constants";import {hideElements} from "../../ui/hideElements";@@ -28,9 +28,8 @@ import {bindRelationEvent, getRelationHTML, openSearchAV, setRelationCell, updatimport {bindRollupData, getRollupHTML, goSearchRollupCol} from "./rollup";import {updateCellsValue} from "./cell";import {openCalcMenu} from "./calc";-import * as dayjs from "dayjs";-import {confirmDialog} from "../../../dialog/confirmDialog";import {escapeAttr} from "../../../util/escape";+import {Dialog} from "../../../dialog";export const openMenuPanel = (options: {protyle: IProtyle,@@ -1084,48 +1083,43 @@ export const openMenuPanel = (options: {event.stopPropagation();break;} else if (type === "removeCol") {- confirmDialog(isCustomAttr ? window.siyuan.languages.deleteOpConfirm : "", isCustomAttr ? window.siyuan.languages.removeCol.replace("${x}", menuElement.querySelector("input").value) : "", () => {- const colId = menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id");- let previousID: string;- const colData = data.view.columns.find((item: IAVColumn, index) => {- if (item.id === colId) {- previousID = data.view.columns[index - 1]?.id;- data.view.columns.splice(index, 1);- return true;- }- });- const newUpdated = dayjs().format("YYYYMMDDHHmmss");- transaction(options.protyle, [{- action: "removeAttrViewCol",- id: colId,- avID,- }, {- action: "doUpdateUpdated",- id: blockID,- data: newUpdated,- }], [{- action: "addAttrViewCol",- name: colData.name,- avID,- type: colData.type,- id: colId,- previousID- }, {- action: "doUpdateUpdated",- id: blockID,- data: options.blockElement.getAttribute("updated")- }]);- removeAttrViewColAnimation(options.blockElement, colId);- options.blockElement.setAttribute("updated", newUpdated);-- if (isCustomAttr) {- avPanelElement.remove();- } else {- tabRect = options.blockElement.querySelector(".av__views").getBoundingClientRect();- menuElement.innerHTML = getPropertiesHTML(data.view);- setPosition(menuElement, tabRect.right - menuElement.clientWidth, tabRect.bottom, tabRect.height);+ tabRect = options.blockElement.querySelector(".av__views").getBoundingClientRect();+ const colId = menuElement.querySelector(".b3-menu__item").getAttribute("data-col-id");+ let previousID = "";+ const colData = data.view.columns.find((item: IAVColumn, index) => {+ if (item.id === colId) {+ previousID = data.view.columns[index - 1]?.id;+ data.view.columns.splice(index, 1);+ return true;}});+ if (isCustomAttr || (colData.type === "relation" && colData.relation.isTwoWay)) {+ const dialog = new Dialog({+ title: window.siyuan.languages.removeCol.replace("${x}", menuElement.querySelector("input").value),+ content: `<div class="b3-dialog__content">+ ${window.siyuan.languages.confirmRemoveRelationField.replace("${x}", (menuElement.querySelector('.b3-text-field[data-type="colName"]') as HTMLInputElement).value)}+</div>+<div class="b3-dialog__action">+ <button class="b3-button b3-button--error">${window.siyuan.languages.delete}</button>+ <button class="b3-button b3-button--warning">${window.siyuan.languages.removeButKeepRelationField}</button>+ <button class="b3-button b3-button--cancel">${window.siyuan.languages.cancel}</button>+</div>`,+ });+ } else {+ removeCol({+ protyle: options.protyle,+ previousID,+ colData,+ data,+ avID,+ blockID,+ menuElement,+ isCustomAttr,+ blockElement: options.blockElement,+ avPanelElement,+ tabRect+ });+ }event.preventDefault();event.stopPropagation();break;diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.tsindex 5757335005..8e27a41f9c 100644--- a/app/src/types/index.d.ts+++ b/app/src/types/index.d.ts@@ -462,6 +462,7 @@ interface IOperation {type?: TAVCol // addAttrViewCol 专享deckID?: string // add/removeFlashcards 专享blockIDs?: string[] // add/removeFlashcards 专享+ removeDest?: boolean // removeAttrViewCol 专享}interface IOperationSrcs {