Skip to content

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

:art: https://github.com/siyuan-note/siyuan/issues/9294

Vanessa725bc6c413b7
diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts
index 03f6a052eb..aadc19ca66 100644
--- a/app/src/protyle/render/av/action.ts
+++ b/app/src/protyle/render/av/action.ts
@@ -217,7 +217,8 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle
srcIDs,
avID,
}]);
- insertAttrViewBlockAnimation(blockElement, 1, previousID);
+ insertAttrViewBlockAnimation(blockElement, 1, previousID, avID);
+ popTextCell(protyle, [addRowElement.previousElementSibling.querySelector('[data-detached="true"]')], "block");
event.preventDefault();
event.stopPropagation();
return true;
@@ -359,16 +360,16 @@ export const removeAttrViewColAnimation = (blockElement: Element, id: string) =>
});
};
-export const insertAttrViewBlockAnimation = (blockElement: Element, size: number, previousId: string) => {
+export const insertAttrViewBlockAnimation = (blockElement: Element, size: number, previousId: string, avId?:string) => {
const previousElement = blockElement.querySelector(`.av__row[data-id="${previousId}"]`) || blockElement.querySelector(".av__row--header");
let colHTML = "";
previousElement.querySelectorAll(".av__cell").forEach((item: HTMLElement) => {
- colHTML += `<div class="av__cell" style="width: ${item.style.width}"><span class="av__pulse"></span></div>`;
+ colHTML += `<div class="av__cell" style="width: ${item.style.width}" ${item.getAttribute("data-block-id") ? ' data-detached="true"' : ""}><span class="av__pulse"></span></div>`;
});
let html = "";
new Array(size).fill(1).forEach(() => {
- html += `<div class="av__row">
+ html += `<div class="av__row" data-avid="${avId}">
<div style="width: 24px"></div>
${colHTML}
</div>`;
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts
index 90b4ae0efa..c28ce4973f 100644
--- a/app/src/protyle/render/av/cell.ts
+++ b/app/src/protyle/render/av/cell.ts
@@ -395,6 +395,14 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type
};
const updateCellValue = (protyle: IProtyle, type: TAVCol, cellElements: HTMLElement[]) => {
+ if (!document.contains(cellElements[0]) && cellElements.length === 1 && cellElements[0].dataset.detached === "true") {
+ // 新增行后弹出的输入框进行修改后,原始 cell 已被更新
+ const avid = cellElements[0].parentElement.dataset.avid;
+ cellElements[0] = protyle.wysiwyg.element.querySelector(`[data-av-id="${avid}"] .av__row--add`).previousElementSibling.querySelector('[data-detached="true"]')
+ }
+ if ( cellElements.length === 1 && cellElements[0].dataset.detached === "true" && !cellElements[0].parentElement.dataset.id) {
+ return;
+ }
const blockElement = hasClosestBlock(cellElements[0]);
if (!blockElement) {
return;