diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index 4655e10bb..705c0771c 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -214,7 +214,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle } const cellType = getTypeByCellElement(target); // TODO 点击单元格的时候, lineNumber 选中整行 - if (cellType === "updated" || cellType === "created" || cellType === "lineNumber" || (cellType === "block" && !target.getAttribute("data-detached"))) { + if (cellType === "updated" || cellType === "created" || cellType === "lineNumber") { selectRow(rowElement.querySelector(".av__firstcol"), "toggle"); } else { scrollElement.querySelectorAll(".av__row--select").forEach(item => { @@ -584,18 +584,9 @@ ${window.siyuan.languages.insertRowAfter.replace("${x}", ` { - let hideBlock = false; const selectElements: HTMLElement[] = Array.from(blockElement.querySelectorAll(`.av__row--select:not(.av__row--header) .av__cell[data-col-id="${cellElement.dataset.colId}"]`)); - if (cellElement.dataset.dtype === "block") { - selectElements.find(item => { - if (!item.dataset.detached) { - hideBlock = true; - return true; - } - }); - } const type = cellElement.getAttribute("data-dtype") as TAVCol; - if (!hideBlock && !["updated", "created"].includes(type)) { + if (!["updated", "created"].includes(type)) { const icon = cellElement.dataset.icon; editAttrSubmenu.push({ iconHTML: icon ? unicode2Emoji(icon, "b3-menu__icon", true) : ``, diff --git a/app/src/protyle/render/av/blockAttr.ts b/app/src/protyle/render/av/blockAttr.ts index 38ae9e9b1..6188102f8 100644 --- a/app/src/protyle/render/av/blockAttr.ts +++ b/app/src/protyle/render/av/blockAttr.ts @@ -61,7 +61,7 @@ export const genAVValueHTML = (value: IAVCellValue) => { let html = ""; switch (value.type) { case "block": - html = `
${value.block.content}
`; + html = ``; break; case "text": html = ``; @@ -198,7 +198,7 @@ export const renderAVAttribute = (element: HTMLElement, id: string, protyle: IPr
${genAVValueHTML(item.values[0])}
+class="fn__flex-1 fn__flex${["url", "text", "number", "email", "phone", "block"].includes(item.values[0].type) ? "" : " custom-attr__avvalue"}${["created", "updated"].includes(item.values[0].type) ? " custom-attr__avvalue--readonly" : ""}">${genAVValueHTML(item.values[0])} `; }); innerHTML += `
diff --git a/app/src/protyle/render/av/cell.ts b/app/src/protyle/render/av/cell.ts index 96d3e4c73..66155dded 100644 --- a/app/src/protyle/render/av/cell.ts +++ b/app/src/protyle/render/av/cell.ts @@ -275,7 +275,11 @@ export const genCellValue = (colType: TAVCol, value: string | any) => { } } if (colType === "block") { - cellValue.isDetached = true; + if (typeof value === "object" && value.id) { + cellValue.isDetached = false; + } else { + cellValue.isDetached = true; + } } return cellValue; }; @@ -365,9 +369,6 @@ export const popTextCell = (protyle: IProtyle, cellElements: HTMLElement[], type if (type === "updated" || type === "created" || document.querySelector(".av__mask")) { return; } - if (type === "block" && (cellElements.length > 1 || !cellElements[0].getAttribute("data-detached"))) { - return; - } const blockElement = hasClosestBlock(cellElements[0]); if (!blockElement) { return; @@ -688,6 +689,11 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va }); newValue = oldValue.mSelect.concat(newMSelectValue); } + } else if (type === "block" && typeof value === "string" && oldValue.block.id) { + newValue = { + content: value, + id: oldValue.block.id + }; } const cellValue = genCellValue(type, newValue); cellValue.id = cellId; @@ -703,26 +709,16 @@ export const updateCellsValue = (protyle: IProtyle, nodeElement: HTMLElement, va if (objEquals(cellValue, oldValue)) { return; } - if (type === "block" && !item.dataset.detached) { - const newId = Lute.NewNodeID(); - doOperations.push({ - action: "unbindAttrViewBlock", - id: rowID, - nextID: newId, - avID, - }); - rowElement.dataset.id = newId; - item.dataset.blockId = newId; - } else { - doOperations.push({ - action: "updateAttrViewCell", - id: cellId, - avID, - keyID: colId, - rowID, - data: cellValue - }); - } + + doOperations.push({ + action: "updateAttrViewCell", + id: cellId, + avID, + keyID: colId, + rowID, + data: cellValue + }); + undoOperations.push({ action: "updateAttrViewCell", id: cellId,