From 290f39aed48c9baf911fb9ac35750da5ebc7cb45 Mon Sep 17 00:00:00 2001 From: Vanessa Date: Wed, 13 Dec 2023 17:21:24 +0800 Subject: [PATCH] :art: --- app/src/protyle/render/av/action.ts | 6 +++--- app/src/protyle/render/av/row.ts | 6 +++--- app/src/protyle/util/editorCommonEvent.ts | 4 ++-- app/src/protyle/wysiwyg/index.ts | 16 +++++++++------- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/app/src/protyle/render/av/action.ts b/app/src/protyle/render/av/action.ts index 4eb28d3af..78a4aa216 100644 --- a/app/src/protyle/render/av/action.ts +++ b/app/src/protyle/render/av/action.ts @@ -90,7 +90,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle srcIDs, avID, }]); - insertAttrViewBlockAnimation(blockElement, 1, undefined, avID); + insertAttrViewBlockAnimation(blockElement, srcIDs, undefined, avID); event.preventDefault(); event.stopPropagation(); return true; @@ -160,7 +160,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle srcIDs, avID, }]); - insertAttrViewBlockAnimation(blockElement, 1, previousID, avID); + insertAttrViewBlockAnimation(blockElement, srcIDs, previousID, avID); event.preventDefault(); event.stopPropagation(); return true; @@ -184,7 +184,7 @@ export const avClick = (protyle: IProtyle, event: MouseEvent & { target: HTMLEle srcIDs, avID, }]); - insertAttrViewBlockAnimation(blockElement, 1, previousID, avID); + insertAttrViewBlockAnimation(blockElement, srcIDs, previousID, avID); } else { const gutterRect = target.getBoundingClientRect(); avContextmenu(protyle, rowElement, { diff --git a/app/src/protyle/render/av/row.ts b/app/src/protyle/render/av/row.ts index e71034084..a36e06eff 100644 --- a/app/src/protyle/render/av/row.ts +++ b/app/src/protyle/render/av/row.ts @@ -69,7 +69,7 @@ export const updateHeader = (rowElement: HTMLElement) => { avHeadElement.style.position = "sticky"; }; -export const insertAttrViewBlockAnimation = (blockElement: Element, size: number, previousId: string, avId?: string) => { +export const insertAttrViewBlockAnimation = (blockElement: Element, srcIDs: string[], previousId: string, avId?: string,) => { const previousElement = blockElement.querySelector(`.av__row[data-id="${previousId}"]`) || blockElement.querySelector(".av__row--header"); let colHTML = '
'; const pinIndex = previousElement.querySelectorAll(".av__colsticky .av__cell").length - 1; @@ -84,8 +84,8 @@ export const insertAttrViewBlockAnimation = (blockElement: Element, size: number }); let html = ""; - new Array(size).fill(1).forEach(() => { - html += `
+ srcIDs.forEach((id) => { + html += `
${colHTML}
`; }); diff --git a/app/src/protyle/util/editorCommonEvent.ts b/app/src/protyle/util/editorCommonEvent.ts index 169961d23..46151bf9f 100644 --- a/app/src/protyle/util/editorCommonEvent.ts +++ b/app/src/protyle/util/editorCommonEvent.ts @@ -931,7 +931,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { srcIDs: sourceIds, avID, }]); - insertAttrViewBlockAnimation(blockElement, sourceIds.length, previousID); + insertAttrViewBlockAnimation(blockElement, sourceIds, previousID); } } } else if (sourceElements.length > 0) { @@ -990,7 +990,7 @@ export const dropEvent = (protyle: IProtyle, editorElement: HTMLElement) => { srcIDs: ids, avID, }]); - insertAttrViewBlockAnimation(blockElement, ids.length, previousID); + insertAttrViewBlockAnimation(blockElement, ids, previousID); } } else { for (let i = 0; i < ids.length; i++) { diff --git a/app/src/protyle/wysiwyg/index.ts b/app/src/protyle/wysiwyg/index.ts index 2088e91a7..a90f62286 100644 --- a/app/src/protyle/wysiwyg/index.ts +++ b/app/src/protyle/wysiwyg/index.ts @@ -1499,14 +1499,16 @@ export class WYSIWYG { const rowElement = hasClosestByClassName(event.target, "av__row"); if (rowElement && rowElement.dataset.id) { const guttersElement = rowElement.querySelector(".av__gutters"); - guttersElement.classList.remove("av__gutters--min"); - let guttersLeft = rowElement.parentElement.parentElement.getBoundingClientRect().left - guttersElement.clientWidth; - const contentLeft = protyle.contentElement.getBoundingClientRect().left; - if (guttersLeft < contentLeft) { - guttersLeft = contentLeft; - guttersElement.classList.add("av__gutters--min"); + if (guttersElement) { + guttersElement.classList.remove("av__gutters--min"); + let guttersLeft = rowElement.parentElement.parentElement.getBoundingClientRect().left - guttersElement.clientWidth; + const contentLeft = protyle.contentElement.getBoundingClientRect().left; + if (guttersLeft < contentLeft) { + guttersLeft = contentLeft; + guttersElement.classList.add("av__gutters--min"); + } + guttersElement.setAttribute("style", `left:${guttersLeft}px;top:${rowElement.getBoundingClientRect().top}px`); } - guttersElement.setAttribute("style", `left:${guttersLeft}px;top:${rowElement.getBoundingClientRect().top}px`); } protyle.gutter.render(protyle, nodeElement, this.element); }