Skip to content

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

:art:

Vanessad966e2e0877a
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index 94e0be456b..8a202d663e 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -103,26 +103,19 @@ const genCellValueByElement = (colType: TAVCol, cellElement: HTMLElement) => {
};
export const genCellValue = (colType: TAVCol, value: string | any) => {
- let cellValue: IAVCellValue;
- if (typeof value === "string") {
+ let cellValue: IAVCellValue = {
+ type: colType,
+ [colType === "select" ? "mSelect" : colType]: value as IAVCellDateValue
+ };
+ if (typeof value === "string" && value && colType !== "mAsset") {
if (colType === "number") {
- if (value) {
- cellValue = {
- type: colType,
- number: {
- content: parseFloat(value),
- isNotEmpty: true
- }
- };
- } else {
- cellValue = {
- type: colType,
- number: {
- content: 0,
- isNotEmpty: false
- }
- };
- }
+ cellValue = {
+ type: colType,
+ number: {
+ content: parseFloat(value) || 0,
+ isNotEmpty: true
+ }
+ };
} else if (["text", "block", "url", "phone", "email", "template"].includes(colType)) {
cellValue = {
type: colType,
@@ -135,72 +128,68 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {
type: colType,
mSelect: [{
content: value,
- color: value ? "1" : ""
+ color: "1"
}]
};
- } else if (["date", "created", "updated"].includes(colType) && value === "") {
- cellValue = {
- type: colType,
- [colType]: {
- content: null,
- isNotEmpty: false,
- content2: null,
- isNotEmpty2: false,
- hasEndDate: false,
- isNotTime: true,
- }
- };
} else if (colType === "checkbox") {
cellValue = {
type: colType,
checkbox: {
- checked: value ? true : false
+ checked: true
}
};
} else if (colType === "relation") {
cellValue = {
type: colType,
- relation: {blockIDs: [], contents: value ? [value] : []}
+ relation: {blockIDs: [], contents: [value]}
};
- } else if (colType === "mAsset") {
+ }
+ } else if (typeof value === "undefined" || !value) {
+ if (colType === "number") {
cellValue = {
type: colType,
- mAsset: []
+ number: {
+ content: 0,
+ isNotEmpty: true
+ }
};
- }
- } else if (typeof value !== "undefined") {
- if (colType === "mSelect" || colType === "select") {
+ } else if (["text", "block", "url", "phone", "email", "template"].includes(colType)) {
cellValue = {
type: colType,
- mSelect: value as IAVCellSelectValue[]
+ [colType]: {
+ content: ""
+ }
};
- } else if (["date", "created", "updated"].includes(colType)) {
+ } else if (colType === "mSelect" || colType === "select" || colType === "mAsset") {
cellValue = {
type: colType,
- [colType]: value as IAVCellDateValue
+ [colType === "select" ? "mSelect" : colType]: []
};
- } else if (colType === "mAsset") {
+ } else if (["date", "created", "updated"].includes(colType)) {
cellValue = {
type: colType,
- mAsset: value as IAVCellAssetValue[]
+ [colType]: {
+ content: null,
+ isNotEmpty: false,
+ content2: null,
+ isNotEmpty2: false,
+ hasEndDate: false,
+ isNotTime: true,
+ }
};
} else if (colType === "checkbox") {
cellValue = {
type: colType,
checkbox: {
- checked: value ? true : false
+ checked: false
}
};
} else if (colType === "relation") {
cellValue = {
type: colType,
- relation: value
+ relation: {blockIDs: [], contents: []}
};
}
- } else {
- cellValue = {
- type: colType,
- };
}
if (colType === "block") {
cellValue.isDetached = true;
diff --git a/app/src/protyle/render/av/select.ts b/app/src/protyle/render/av/select.ts
index 1d52989f69..8f9413bcba 100644
--- a/app/src/protyle/render/av/select.ts
+++ b/app/src/protyle/render/av/select.ts
@@ -6,6 +6,7 @@ import {upDownHint} from "../../../util/upDownHint";
import {bindEditEvent, getEditHTML} from "./col";
import {updateAttrViewCellAnimation} from "./action";
import {genAVValueHTML} from "./blockAttr";
+import {escapeAttr} from "../../../util/escape";
const filterSelectHTML = (key: string, options: { name: string, color: string }[]) => {
let html = "";
@@ -590,7 +591,7 @@ export const getSelectHTML = (data: IAVTable, cellElements: HTMLElement[]) => {
let selectedHTML = "";
allUniqueOptions.forEach((unique) => {
- selectedHTML += `<div class="b3-chip b3-chip--middle" data-content="${unique.content}" style="background-color:var(--b3-font-background${unique.color});color:var(--b3-font-color${unique.color})">${unique.content}<svg class="b3-chip__close" data-type="removeCellOption"><use xlink:href="#iconCloseRound"></use></svg></div>`;
+ selectedHTML += `<div class="b3-chip b3-chip--middle" data-content="${escapeAttr(unique.content)}" style="background-color:var(--b3-font-background${unique.color});color:var(--b3-font-color${unique.color})">${unique.content}<svg class="b3-chip__close" data-type="removeCellOption"><use xlink:href="#iconCloseRound"></use></svg></div>`;
});
return `<div class="b3-menu__items">