An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作
TypeScript agentic-aiai-agentknowledge-baselocal-firstmarkdownmcpmindmapnote-takingself-hostedsiyuanworkspace
:bug: fix https://github.com/siyuan-note/siyuan/issues/10996
Vanessaf822e4d69e5e
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.tsindex 1214edfef8..5c4ca21cac 100644--- a/app/src/protyle/render/av/cell.ts+++ b/app/src/protyle/render/av/cell.ts@@ -12,6 +12,7 @@ import {getColIconByType} from "./col";import {genAVValueHTML} from "./blockAttr";import {Constants} from "../../../constants";import {hintRef} from "../../hint/extend";+import {pathPosix} from "../../../util/pathName";const renderCellURL = (urlContent: string) => {let host = urlContent;@@ -133,7 +134,7 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {type: colType,[colType === "select" ? "mSelect" : colType]: value as IAVCellDateValue};- if (typeof value === "string" && value && colType !== "mAsset") {+ if (typeof value === "string" && value) {if (colType === "number") {cellValue = {type: colType,@@ -181,6 +182,16 @@ export const genCellValue = (colType: TAVCol, value: string | any) => {type: colType,relation: {blockIDs: [value], contents: []}};+ } else if (colType === "mAsset") {+ const type = pathPosix().extname(value).toLowerCase();+ cellValue = {+ type: colType,+ mAsset: [{+ type: Constants.SIYUAN_ASSETS_IMAGE.includes(type) ? "image" : "file",+ content: value,+ name: "",+ }]+ };}} else if (typeof value === "undefined" || !value) {if (colType === "number") {diff --git a/app/src/protyle/render/av/keydown.ts b/app/src/protyle/render/av/keydown.tsindex afc052bb9a..d31b82b203 100644--- a/app/src/protyle/render/av/keydown.ts+++ b/app/src/protyle/render/av/keydown.ts@@ -23,19 +23,22 @@ export const avKeydown = (event: KeyboardEvent, nodeElement: HTMLElement, protylif (!rowElement) {return false;}- if (event.key === "Backspace" || event.key === "Delete") {- updateCellsValue(protyle, nodeElement, undefined, Array.from(nodeElement.querySelectorAll(".av__cell--active, .av__cell--select")));- event.preventDefault();- return true;- }const avPanelElement = document.querySelector(".av__panel");if (avPanelElement &&- (event.key === "Escape" || event.key.startsWith("ArrowLeft") || event.key === "Enter" || matchHotKey("⇥", event) || matchHotKey("⇧⇥", event))) {+ (event.key === "Backspace" || event.key === "Delete" || event.key === "Escape" ||+ event.key.startsWith("ArrowLeft") || event.key === "Enter" || matchHotKey("⇥", event) ||+ matchHotKey("⇧⇥", event))) {avPanelElement.remove();event.preventDefault();event.stopPropagation();return true;}+ // 需在 avPanelElement 之后,否则点击资源单元格后删除,资源面板不会更新+ if (event.key === "Backspace" || event.key === "Delete") {+ updateCellsValue(protyle, nodeElement, undefined, Array.from(nodeElement.querySelectorAll(".av__cell--active, .av__cell--select")));+ event.preventDefault();+ return true;+ }if (event.key === "Escape") {selectCellElement.classList.remove("av__cell--select", "av__cell--active");selectCellElement.querySelector(".av__drag-fill")?.remove();diff --git a/app/src/protyle/upload/index.ts b/app/src/protyle/upload/index.tsindex f62da2be8e..6b41340d10 100644--- a/app/src/protyle/upload/index.ts+++ b/app/src/protyle/upload/index.ts@@ -8,7 +8,7 @@ import {pathPosix} from "../../util/pathName";import {genAssetHTML} from "../../asset/renderAssets";import {hasClosestBlock} from "../util/hasClosest";import {getContenteditableElement} from "../wysiwyg/getBlock";-import {updateCellsValue} from "../render/av/cell";+import {getTypeByCellElement, updateCellsValue} from "../render/av/cell";export class Upload {public element: HTMLElement;@@ -143,16 +143,47 @@ const genUploadedLabel = (responseText: string, protyle: IProtyle) => {}}});+if ((nodeElement && nodeElement.classList.contains("av"))) {- updateCellsValue(protyle, nodeElement, avAssets);- document.querySelector(".av__panel")?.remove();- return;+ const cellElements: HTMLElement[] = []+ nodeElement.querySelectorAll(".av__row--select:not(.av__row--header)").forEach(item => {+ item.querySelectorAll(".av__cell").forEach((cellItem: HTMLElement) => {+ if (getTypeByCellElement(cellItem) === "mAsset") {+ cellElements.push(cellItem);+ }+ })+ })+ if (cellElements.length === 0) {+ protyle.wysiwyg.element.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => {+ if (getTypeByCellElement(item) === "mAsset") {+ cellElements.push(item);+ }+ })+ }+ if (cellElements.length > 0) {+ updateCellsValue(protyle, nodeElement, avAssets, cellElements);+ document.querySelector(".av__panel")?.remove();+ return;+ } else {+ return;+ }}+if (document.querySelector(".av__panel")) {- const blockElement = hasClosestBlock(protyle.wysiwyg.element.querySelector(".av__cell--select"));- if (blockElement) {- updateCellsValue(protyle, blockElement, avAssets);- document.querySelector(".av__panel")?.remove();+ const cellElements: HTMLElement[] = []+ protyle.wysiwyg.element.querySelectorAll(".av__cell--active").forEach((item: HTMLElement) => {+ if (getTypeByCellElement(item) === "mAsset") {+ cellElements.push(item);+ }+ })+ if (cellElements.length > 0) {+ const blockElement = hasClosestBlock(cellElements[0]);+ if (blockElement) {+ updateCellsValue(protyle, blockElement, avAssets, cellElements);+ document.querySelector(".av__panel")?.remove();+ return;+ }+ } else {return;}}