Skip to content

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

:art: fix https://github.com/siyuan-note/siyuan/issues/8854

Vanessaa316785f70d3
diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scss
index 4934c6d566..88668f1a55 100644
--- a/app/src/assets/scss/business/_av.scss
+++ b/app/src/assets/scss/business/_av.scss
@@ -183,12 +183,21 @@
flex-shrink: 0;
}
- [data-type="block-ref"] {
+ [data-type="block-ref"],
+ [data-type="a"] {
display: none;
position: absolute;
right: 5px;
font-size: 10px;
}
+
+ &:hover [data-type="a"] {
+ display: block;
+
+ &:hover {
+ border-bottom: 0 !important;
+ }
+ }
}
&__cellheader {
@@ -206,6 +215,10 @@
.b3-chip {
margin: 1px 2px;
}
+
+ &--url {
+ text-decoration: underline var(--b3-border-color);
+ }
}
&__firstcol {
diff --git a/app/src/protyle/render/av/addCol.ts b/app/src/protyle/render/av/addCol.ts
index fa3b164c22..071dc05105 100644
--- a/app/src/protyle/render/av/addCol.ts
+++ b/app/src/protyle/render/av/addCol.ts
@@ -94,5 +94,23 @@ export const addCol = (protyle: IProtyle, blockElement: HTMLElement) => {
}]);
}
});
+ menu.addItem({
+ icon: "iconLink",
+ label: window.siyuan.languages.link,
+ click() {
+ const id = Lute.NewNodeID();
+ transaction(protyle, [{
+ action: "addAttrViewCol",
+ name: "Link",
+ avID,
+ type: "url",
+ id
+ }], [{
+ action: "removeAttrViewCol",
+ id,
+ avID,
+ }]);
+ }
+ });
return menu;
};
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index 5a3f13e029..4f03f19216 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -343,7 +343,7 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[]) => {
let html = "";
const style = `style="position:absolute;left: ${cellRect.left}px;top: ${cellRect.top}px;width:${Math.max(cellRect.width, 200)}px;height: ${cellRect.height}px"`;
const blockElement = hasClosestBlock(cellElements[0]);
- if (type === "block" || type === "text") {
+ if (["block", "text", "url"].includes(type)) {
html = `<textarea ${style} class="b3-text-field">${cellElements[0].firstElementChild.textContent}</textarea>`;
} else if (type === "number") {
html = `<input type="number" value="${cellElements[0].textContent}" ${style} class="b3-text-field">`;
diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts
index 55a448cf41..558bb439a0 100644
--- a/app/src/protyle/render/av/col.ts
+++ b/app/src/protyle/render/av/col.ts
@@ -217,6 +217,8 @@ export const getColIconByType = (type: TAVCol) => {
return "iconList";
case "date":
return "iconCalendar";
+ case "url":
+ return "iconLink";
}
};
diff --git a/app/src/protyle/render/av/filter.ts b/app/src/protyle/render/av/filter.ts
index 43e7cbe6ef..f8bdc56f37 100644
--- a/app/src/protyle/render/av/filter.ts
+++ b/app/src/protyle/render/av/filter.ts
@@ -11,7 +11,7 @@ export const getDefaultOperatorByType = (type: TAVCol) => {
if (type === "number" || type === "select") {
return "=";
}
- if (type === "text" || type === "mSelect") {
+ if (type === "text" || type === "mSelect" || type === "url") {
return "Contains";
}
};
@@ -132,6 +132,7 @@ export const setFilter = (options: {
});
switch (colData.type) {
case "text":
+ case "url":
selectHTML = `<option ${"=" === options.filter.operator ? "selected" : ""} value="=">${window.siyuan.languages.filterOperatorIs}</option>
<option ${"!=" === options.filter.operator ? "selected" : ""} value="!=">${window.siyuan.languages.filterOperatorIsNot}</option>
<option ${"Contains" === options.filter.operator ? "selected" : ""} value="Contains">${window.siyuan.languages.filterOperatorContains}</option>
@@ -205,7 +206,7 @@ export const setFilter = (options: {
}
});
});
- } else if (colData.type === "text") {
+ } else if (colData.type === "text" || colData.type === "url") {
menu.addItem({
iconHTML: "",
label: `<input style="margin: 4px 0" value="${options.filter.value?.text.content || ""}" class="b3-text-field fn__size200">`
diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts
index 5e499a3148..e9d8837c85 100644
--- a/app/src/protyle/render/av/render.ts
+++ b/app/src/protyle/render/av/render.ts
@@ -61,6 +61,11 @@ style="width: ${column.width || "200px"}">${getCalcValue(column) || '<svg><use x
let text = "";
if (cell.valueType === "text") {
text = `<span class="av__celltext">${cell.value?.text.content || ""}</span>`;
+ } else if (cell.valueType === "url") {
+ text = `<span class="av__celltext av__celltext--url">${cell.value?.url.content || ""}</span>`;
+ if (cell.value?.url.content) {
+ text += `<span class="b3-chip b3-chip--info b3-chip--small" data-type="a" data-href="${cell.value.url.content}">${window.siyuan.languages.openBy}</span>`;
+ }
} else if (cell.valueType === "block") {
text = `<span class="av__celltext">${cell.value?.block.content || ""}</span>`;
if (cell.value?.block.id) {