Skip to content

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

:bug: Sync number formats in database attribute panels https://github.com/siyuan-note/siyuan/issues/18321

Danielc2384c84fca7
diff --git a/app/src/protyle/render/av/attributePanel.ts b/app/src/protyle/render/av/attributePanel.ts
index 38322cfde7..4b1b03f2a0 100644
--- a/app/src/protyle/render/av/attributePanel.ts
+++ b/app/src/protyle/render/av/attributePanel.ts
@@ -13,6 +13,7 @@ const refreshActions = new Set<TOperation>([
"setAttrViewColIcon",
"setAttrViewColDesc",
"setAttrViewName",
+ "updateAttrViewColNumberFormat",
]);
export class AVAttributePanel {
diff --git a/app/src/protyle/render/av/number.ts b/app/src/protyle/render/av/number.ts
index 8fbeda8cdc..750cd4df1f 100644
--- a/app/src/protyle/render/av/number.ts
+++ b/app/src/protyle/render/av/number.ts
@@ -1,6 +1,23 @@
import {Menu} from "../../../plugin/Menu";
import {transaction} from "../../wysiwyg/transaction";
import {Constants} from "../../../constants";
+import {getAllEditor, getAllModels} from "../../../layout/getAll";
+
+const refreshDatabaseAttributePanels = (protyle: IProtyle, avID: string) => {
+ protyle.databaseAttributePanel?.refresh();
+ getAllEditor().forEach((editor) => {
+ if (editor.protyle !== protyle && editor.protyle.databaseAttributePanel?.hasDatabase(avID)) {
+ editor.protyle.databaseAttributePanel.refresh();
+ }
+ });
+ /// #if !MOBILE
+ getAllModels().custom.forEach((model) => {
+ if (model.type === "siyuan-database-row" && model.data.avID === avID) {
+ model.update?.();
+ }
+ });
+ /// #endif
+};
const addFormatItem = (options: {
menu: Menu,
@@ -27,7 +44,9 @@ const addFormatItem = (options: {
avID: options.avID,
format: options.oldFormat,
type: "number",
- }]);
+ }], {
+ callback: () => refreshDatabaseAttributePanels(options.protyle, options.avID),
+ });
options.avPanelElement.remove();
}
});