Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: https://github.com/siyuan-note/siyuan/issues/8664

Vanessaebd399c0180c
diff --git a/app/src/protyle/render/av/addCol.ts b/app/src/protyle/render/av/addCol.ts
index 98c92c7f0c..fa3b164c22 100644
--- a/app/src/protyle/render/av/addCol.ts
+++ b/app/src/protyle/render/av/addCol.ts
@@ -4,7 +4,6 @@ import {transaction} from "../../wysiwyg/transaction";
export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
const menu = new Menu("av-header-add");
const avID = blockElement.getAttribute("data-av-id");
- const viewID = blockElement.querySelector(".item--focus").getAttribute("data-id");
menu.addItem({
icon: "iconAlignLeft",
label: window.siyuan.languages.text,
@@ -14,14 +13,12 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
action: "addAttrViewCol",
name: "Text",
avID,
- viewID,
type: "text",
id
}], [{
action: "removeAttrViewCol",
id,
avID,
- viewID,
}]);
}
});
@@ -34,14 +31,12 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
action: "addAttrViewCol",
name: "Number",
avID,
- viewID,
type: "number",
id
}], [{
action: "removeAttrViewCol",
id,
avID,
- viewID,
}]);
}
});
@@ -54,14 +49,12 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
action: "addAttrViewCol",
name: "Select",
avID,
- viewID,
type: "select",
id
}], [{
action: "removeAttrViewCol",
id,
avID,
- viewID,
}]);
}
});
@@ -74,14 +67,12 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
action: "addAttrViewCol",
name: "Multi-select",
avID,
- viewID,
type: "mSelect",
id
}], [{
action: "removeAttrViewCol",
id,
avID,
- viewID,
}]);
}
});
@@ -94,14 +85,12 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
action: "addAttrViewCol",
name: "Date",
avID,
- viewID,
type: "date",
id
}], [{
action: "removeAttrViewCol",
id,
avID,
- viewID,
}]);
}
});
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index 1f1bb07a81..168c1c4e8a 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -56,8 +56,8 @@ const updateCellValue = (protyle: IProtyle, cellElement: HTMLElement, type: TAVC
}
const avMaskElement = document.querySelector(".av__mask");
const cellId = cellElement.getAttribute("data-id");
- const avId = blockElement.getAttribute("data-av-id");
- const rowId = rowElement.getAttribute("data-id");
+ const colId = cellElement.getAttribute("data-col-id");
+ const avID = blockElement.getAttribute("data-av-id");
let inputValue: string | number = (avMaskElement.querySelector(".b3-text-field") as HTMLInputElement).value;
let oldValue: string | number = cellElement.textContent.trim();
if (type === "number") {
@@ -67,16 +67,16 @@ const updateCellValue = (protyle: IProtyle, cellElement: HTMLElement, type: TAVC
transaction(protyle, [{
action: "updateAttrViewCell",
id: cellId,
- rowID: rowId,
- parentID: avId,
+ avID,
+ keyID: colId,
data: {
[type]: {content: inputValue}
}
}], [{
action: "updateAttrViewCell",
id: cellId,
- rowID: rowId,
- parentID: avId,
+ avID,
+ keyID: colId,
data: {
[type]: {content: oldValue}
}
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts
index b2792e42d4..dce97edfe9 100644
--- a/app/src/protyle/render/av/col.ts
+++ b/app/src/protyle/render/av/col.ts
@@ -66,7 +66,6 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
const type = cellElement.getAttribute("data-dtype") as TAVCol;
const colId = cellElement.getAttribute("data-col-id");
const avId = blockElement.getAttribute("data-av-id");
- const viewId = blockElement.querySelector(".item--focus").getAttribute("data-id");
const menu = new Menu("av-header-cell", () => {
const newValue = (window.siyuan.menus.menu.element.querySelector(".b3-text-field") as HTMLInputElement).value;
if (newValue === cellElement.textContent.trim()) {
@@ -76,14 +75,12 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
action: "updateAttrViewCol",
id: colId,
avID: avId,
- viewID: viewId,
name: newValue,
type,
}], [{
action: "updateAttrViewCol",
id: colId,
avID: avId,
- viewID: viewId,
name: cellElement.textContent.trim(),
type,
}]);
@@ -110,7 +107,6 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
transaction(protyle, [{
action: "setAttrViewSorts",
avID: response.data.id,
- viewID: response.data.viewID,
data: [{
column: colId,
order: "ASC"
@@ -118,7 +114,6 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
}], [{
action: "setAttrViewSorts",
avID: response.data.id,
- viewID: response.data.viewID,
data: response.data.view.sorts
}]);
});
@@ -132,7 +127,6 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
transaction(protyle, [{
action: "setAttrViewSorts",
avID: response.data.id,
- viewID: response.data.viewID,
data: [{
column: colId,
order: "DESC"
@@ -140,7 +134,6 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
}], [{
action: "setAttrViewSorts",
avID: response.data.id,
- viewID: response.data.viewID,
data: response.data.view.sorts
}]);
});
@@ -169,12 +162,10 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
transaction(protyle, [{
action: "setAttrViewFilters",
avID: avId,
- viewID: avData.viewID,
data: [filter]
}], [{
action: "setAttrViewFilters",
avID: avId,
- viewID: avData.viewID,
data: []
}]);
}
@@ -197,13 +188,11 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
action: "setAttrViewColHidden",
id: colId,
avID: avId,
- viewID: viewId,
data: true
}], [{
action: "setAttrViewColHidden",
id: colId,
avID: avId,
- viewID: viewId,
data: false
}]);
}
@@ -223,12 +212,10 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
action: "removeAttrViewCol",
id: colId,
avID: avId,
- viewID: viewId,
}], [{
action: "addAttrViewCol",
name: cellElement.textContent.trim(),
avID: avId,
- viewID: viewId,
type: type,
id: colId
}]);
@@ -247,13 +234,11 @@ export const showColMenu = (protyle: IProtyle, blockElement: HTMLElement, cellEl
action: "setAttrViewColWrap",
id: colId,
avID: avId,
- viewID: viewId,
data: inputElement.checked
}], [{
action: "setAttrViewColWrap",
id: colId,
avID: avId,
- viewID: viewId,
data: !inputElement.checked
}]);
});
diff --git a/app/src/protyle/render/av/filter.ts b/app/src/protyle/render/av/filter.ts
index 1a3b4884f4..2e223fa938 100644
--- a/app/src/protyle/render/av/filter.ts
+++ b/app/src/protyle/render/av/filter.ts
@@ -75,12 +75,10 @@ export const setFilter = (options: {
transaction(options.protyle, [{
action: "setAttrViewFilters",
avID: options.data.id,
- viewID: options.data.viewID,
data: options.data.view.filters
}], [{
action: "setAttrViewFilters",
avID: options.data.id,
- viewID: options.data.viewID,
data: oldFilters
}]);
const menuElement = hasClosestByClassName(options.target, "b3-menu");
@@ -177,12 +175,10 @@ export const setFilter = (options: {
transaction(options.protyle, [{
action: "setAttrViewFilters",
avID: options.data.id,
- viewID: options.data.viewID,
data: options.data.view.filters
}], [{
action: "setAttrViewFilters",
avID: options.data.id,
- viewID: options.data.viewID,
data: oldFilters
}]);
const menuElement = hasClosestByClassName(options.target, "b3-menu");
@@ -255,12 +251,10 @@ export const addFilter = (options: {
transaction(options.protyle, [{
action: "setAttrViewFilters",
avID: options.data.id,
- viewID: options.data.viewID,
data: options.data.view.filters
}], [{
action: "setAttrViewFilters",
avID: options.data.id,
- viewID: options.data.viewID,
data: oldFilters
}]);
options.menuElement.innerHTML = getFiltersHTML(options.data.view);
diff --git a/app/src/protyle/render/av/openMenuPanel.ts b/app/src/protyle/render/av/openMenuPanel.ts
index 93b9464a45..8a37888094 100644
--- a/app/src/protyle/render/av/openMenuPanel.ts
+++ b/app/src/protyle/render/av/openMenuPanel.ts
@@ -139,12 +139,10 @@ export const openMenuPanel = (protyle: IProtyle,
transaction(protyle, [{
action: "setAttrViewSorts",
avID: avId,
- viewID: data.viewID,
data: changeData
}], [{
action: "setAttrViewSorts",
avID: avId,
- viewID: data.viewID,
data: oldData
}]);
menuElement.innerHTML = getSortsHTML(data.view.columns, data.view.sorts);
@@ -175,12 +173,10 @@ export const openMenuPanel = (protyle: IProtyle,
transaction(protyle, [{
action: "setAttrViewFilters",
avID: avId,
- viewID: data.viewID,
data: changeData
}], [{
action: "setAttrViewFilters",
avID: avId,
- viewID: data.viewID,
data: oldData
}]);
menuElement.innerHTML = getFiltersHTML(data.view);
@@ -189,13 +185,11 @@ export const openMenuPanel = (protyle: IProtyle,
transaction(protyle, [{
action: "sortAttrViewCol",
avID: avId,
- viewID: data.viewID,
previousID: (targetElement.classList.contains("dragover__top") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
id: sourceId,
}], [{
action: "sortAttrViewCol",
avID: avId,
- viewID: data.viewID,
previousID: sourceElement.previousElementSibling?.getAttribute("data-id") || "",
id: sourceId,
}]);
@@ -281,12 +275,10 @@ export const openMenuPanel = (protyle: IProtyle,
transaction(protyle, [{
action: "setAttrViewSorts",
avID: avId,
- viewID: data.viewID,
data: []
}], [{
action: "setAttrViewSorts",
avID: avId,
- viewID: data.viewID,
data: data.view.sorts
}]);
data.view.sorts = [];
@@ -310,12 +302,10 @@ export const openMenuPanel = (protyle: IProtyle,
transaction(protyle, [{
action: "setAttrViewSorts",
avID: avId,
- viewID: data.viewID,
data: data.view.sorts
}], [{
action: "setAttrViewSorts",
avID: avId,
- viewID: data.viewID,
data: oldSorts
}]);
menuElement.innerHTML = getSortsHTML(data.view.columns, data.view.sorts);
@@ -332,12 +322,10 @@ export const openMenuPanel = (protyle: IProtyle,
transaction(protyle, [{
action: "setAttrViewFilters",
avID: avId,
- viewID: data.viewID,
data: []
}], [{
action: "setAttrViewFilters",
avID: avId,
- viewID: data.viewID,
data: data.view.filters
}]);
data.view.filters = [];
@@ -361,12 +349,10 @@ export const openMenuPanel = (protyle: IProtyle,
transaction(protyle, [{
action: "setAttrViewFilters",
avID: avId,
- viewID: data.viewID,
data: data.view.filters
}], [{
action: "setAttrViewFilters",
avID: avId,
- viewID: data.viewID,
data: oldFilters
}]);
menuElement.innerHTML = getFiltersHTML(data.view);
@@ -407,14 +393,12 @@ export const openMenuPanel = (protyle: IProtyle,
action: "setAttrViewColHidden",
id: item.id,
avID: avId,
- viewID: data.viewID,
data: false
});
undoOperations.push({
action: "setAttrViewColHidden",
id: item.id,
avID: avId,
- viewID: data.viewID,
data: true
});
item.hidden = false;
@@ -436,14 +420,12 @@ export const openMenuPanel = (protyle: IProtyle,
action: "setAttrViewColHidden",
id: item.id,
avID: avId,
- viewID: data.viewID,
data: true
});
undoOperations.push({
action: "setAttrViewColHidden",
id: item.id,
avID: avId,
- viewID: data.viewID,
data: false
});
item.hidden = true;
@@ -462,13 +444,11 @@ export const openMenuPanel = (protyle: IProtyle,
action: "setAttrViewColHidden",
id: colId,
avID: avId,
- viewID: data.viewID,
data: true
}], [{
action: "setAttrViewColHidden",
id: colId,
avID: avId,
- viewID: data.viewID,
data: false
}]);
data.view.columns.find((item: IAVColumn) => item.id === colId).hidden = true;
@@ -482,13 +462,11 @@ export const openMenuPanel = (protyle: IProtyle,
action: "setAttrViewColHidden",
id: colId,
avID: avId,
- viewID: data.viewID,
data: false
}], [{
action: "setAttrViewColHidden",
id: colId,
avID: avId,
- viewID: data.viewID,
data: true
}]);
data.view.columns.find((item: IAVColumn) => item.id === colId).hidden = false;
diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.ts
index 302eeb2166..fd301de5bc 100644
--- a/app/src/protyle/render/av/select.ts
+++ b/app/src/protyle/render/av/select.ts
@@ -85,13 +85,13 @@ export const removeSelectCell = (protyle: IProtyle, data: IAVTable, options: {
transaction(protyle, [{
action: "updateAttrViewCell",
id: cellId,
- rowID: rowId,
+ keyID: colId,
parentID: data.id,
data: cellData.value
}], [{
action: "updateAttrViewCell",
id: cellId,
- rowID: rowId,
+ keyID: colId,
parentID: data.id,
data: {
[colData.type]: oldValue
@@ -403,7 +403,7 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAVTable, options:
}, {
action: "updateAttrViewCell",
id: cellId,
- rowID: rowId,
+ keyID: colId,
parentID: data.id,
data: cellData.value
}], [{
@@ -416,13 +416,13 @@ export const addSelectColAndCell = (protyle: IProtyle, data: IAVTable, options:
transaction(protyle, [{
action: "updateAttrViewCell",
id: cellId,
- rowID: rowId,
+ keyID: colId,
parentID: data.id,
data: cellData.value
}], [{
action: "updateAttrViewCell",
id: cellId,
- rowID: rowId,
+ keyID: colId,
parentID: data.id,
data: {
[colData.type]: oldValue
diff --git a/app/src/protyle/render/av/sort.ts b/app/src/protyle/render/av/sort.ts
index 7799576272..4bcb6e0e50 100644
--- a/app/src/protyle/render/av/sort.ts
+++ b/app/src/protyle/render/av/sort.ts
@@ -33,12 +33,10 @@ export const addSort = (options: {
transaction(options.protyle, [{
action: "setAttrViewSorts",
avID: options.data.id,
- viewID: options.data.viewID,
data: options.data.view.sorts
}], [{
action: "setAttrViewSorts",
avID: options.data.id,
- viewID: options.data.viewID,
data: oldSorts
}]);
options.menuElement.innerHTML = getSortsHTML(options.data.view.columns, options.data.view.sorts);
@@ -74,12 +72,10 @@ export const bindSortsEvent = (protyle: IProtyle, menuElement: HTMLElement, data
transaction(protyle, [{
action: "setAttrViewSorts",
avID: data.id,
- viewID: data.viewID,
data: data.view.sorts
}], [{
action: "setAttrViewSorts",
avID: data.id,
- viewID: data.viewID,
data: oldSort
}]);
});
diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts
index 77fc85c490..942cde70b8 100644
--- a/app/src/protyle/util/editorCommonEvent.ts
+++ b/app/src/protyle/util/editorCommonEvent.ts
@@ -824,17 +824,14 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
return;
}
const avID = blockElement.getAttribute("data-av-id");
- const viewID = blockElement.querySelector(".item--focus").getAttribute("data-av-id");
transaction(protyle, [{
action: "sortAttrViewCol",
avID,
- viewID,
previousID: (targetElement.classList.contains("dragover__left") ? targetElement.previousElementSibling?.getAttribute("data-id") : targetElement.getAttribute("data-id")) || "",
id: gutterTypes[2],
}], [{
action: "sortAttrViewCol",
avID,
- viewID,
previousID: targetElement.parentElement.querySelector(`[data-id="${gutterTypes[2]}"`).previousElementSibling?.getAttribute("data-id") || "",
id: gutterTypes[2],
}]);
@@ -853,7 +850,6 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
previousID = targetElement.previousElementSibling?.getAttribute("data-id") || "";
}
const avID = blockElement.getAttribute("data-av-id");
- const viewID = blockElement.querySelector(".item--focus").getAttribute("data-id");
if (gutterTypes[0] === "nodeattributeview" && gutterTypes[1] === "row") {
// 行内拖拽
const doOperations: IOperation[] = [];
@@ -863,14 +859,12 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => {
doOperations.push({
action: "sortAttrViewRow",
avID,
- viewID,
previousID,
id: item,
});
undoOperations.push({
action: "sortAttrViewRow",
avID,
- viewID,
previousID: undoPreviousId,
id: item,
});
diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts
index 9db42f0f96..8f71e4674a 100644
--- a/app/src/protyle/wysiwyg/index.ts
+++ b/app/src/protyle/wysiwyg/index.ts
@@ -353,7 +353,6 @@ export class WYSIWYG {
return;
}
const avId = nodeElement.getAttribute("data-av-id");
- const viewId = (nodeElement.querySelector(".item--focus") as HTMLElement).dataset.id;
const dragElement = target.parentElement;
const oldWidth = dragElement.clientWidth;
const dragColId = dragElement.getAttribute("data-col-id");
@@ -375,13 +374,11 @@ export class WYSIWYG {
action: "setAttrViewColWidth",
id: dragColId,
avID: avId,
- viewID: viewId,
data: newWidth
}], [{
action: "setAttrViewColWidth",
id: dragColId,
avID: avId,
- viewID: viewId,
data: oldWidth + "px"
}]);
};
diff --git a/app/src/search/util.ts b/app/src/search/util.ts
index 709c0400fc..4aa844dd88 100644
--- a/app/src/search/util.ts
+++ b/app/src/search/util.ts
@@ -13,7 +13,7 @@ import {addLoading, setPadding} from "../protyle/ui/initUI";
import {getIconByType} from "../editor/getIcon";
import {unicode2Emoji} from "../emoji";
import {hasClosestByClassName} from "../protyle/util/hasClosest";
-import {setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
+import {isCtrl, setStorageVal, updateHotkeyTip} from "../protyle/util/compatibility";
import {newFileByName} from "../util/newFile";
import {matchHotKey} from "../protyle/util/hotKey";
import {filterMenu, getKeyByLiElement, initCriteriaMenu, moreMenu, queryMenu, saveCriterion} from "./menu";
diff --git a/app/src/types/index.d.ts b/app/src/types/index.d.ts
index 8c7c95cf52..114592a806 100644
--- a/app/src/types/index.d.ts
+++ b/app/src/types/index.d.ts
@@ -308,7 +308,7 @@ interface IOperation {
action: TOperation, // move, delete 不需要传 data
id?: string,
avID?: string, // av
- viewID?: string, // av
+ keyID?: string // updateAttrViewCell 专享
data?: any, // updateAttr 时为 { old: IObject, new: IObject }, updateAttrViewCell 时为 {TAVCol: {content: string}}
parentID?: string
previousID?: string
@@ -317,7 +317,6 @@ interface IOperation {
srcIDs?: string[] // insertAttrViewBlock 专享
name?: string // addAttrViewCol 专享
type?: TAVCol // addAttrViewCol 专享
- rowID?: string // updateAttrViewCell 专享
deckID?: string // add/removeFlashcards 专享
blockIDs?: string[] // add/removeFlashcards 专享
}