Skip to content

Commit

Permalink
🎨 #9294
Browse files Browse the repository at this point in the history
  • Loading branch information
Vanessa219 committed Sep 27, 2023
1 parent 26db301 commit 725bc6c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
9 changes: 5 additions & 4 deletions app/src/protyle/render/av/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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>`;
Expand Down
8 changes: 8 additions & 0 deletions app/src/protyle/render/av/cell.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 725bc6c

Please sign in to comment.