diff --git a/app/src/assets/scss/business/_av.scss b/app/src/assets/scss/business/_av.scss index 4934c6d56..88668f1a5 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 fa3b164c2..071dc0510 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 5a3f13e02..4f03f1921 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 = ``; } else if (type === "number") { html = ``; diff --git a/app/src/protyle/render/av/col.ts b/app/src/protyle/render/av/col.ts index 55a448cf4..558bb439a 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 43e7cbe6e..f8bdc56f3 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 = ` @@ -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: `` diff --git a/app/src/protyle/render/av/render.ts b/app/src/protyle/render/av/render.ts index 5e499a314..e9d8837c8 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) || '${cell.value?.text.content || ""}`; + } else if (cell.valueType === "url") { + text = `${cell.value?.url.content || ""}`; + if (cell.value?.url.content) { + text += `${window.siyuan.languages.openBy}`; + } } else if (cell.valueType === "block") { text = `${cell.value?.block.content || ""}`; if (cell.value?.block.id) {