diff --git a/app/src/protyle/wysiwyg/commonHotkey.ts b/app/src/protyle/wysiwyg/commonHotkey.ts index 2a5d3e9ae..9af51bc75 100644 --- a/app/src/protyle/wysiwyg/commonHotkey.ts +++ b/app/src/protyle/wysiwyg/commonHotkey.ts @@ -311,29 +311,7 @@ export const goEnd = (protyle: IProtyle) => { export const alignImgCenter = (protyle: IProtyle, nodeElement: Element, assetElements: Element[], id: string, html: string) => { nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); assetElements.forEach((item: HTMLElement) => { - item.style.display = "block"; - let nextSibling = item.nextSibling; - while (nextSibling) { - if (nextSibling.textContent === "") { - nextSibling = nextSibling.nextSibling; - } else if (nextSibling.textContent === Constants.ZWSP) { - nextSibling.textContent = ""; - break; - } else { - break; - } - } - let previous = item.previousSibling; - while (previous) { - if (previous.textContent === "") { - previous = previous.previousSibling; - } else if (previous.textContent === Constants.ZWSP) { - previous.textContent = ""; - break; - } else { - break; - } - } + item.style.minWidth = "calc(100% - 0.1em)"; }); updateTransaction(protyle, id, nodeElement.outerHTML, html); }; @@ -341,13 +319,8 @@ export const alignImgCenter = (protyle: IProtyle, nodeElement: Element, assetEle export const alignImgLeft = (protyle: IProtyle, nodeElement: Element, assetElements: Element[], id: string, html: string) => { nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss")); assetElements.forEach((item: HTMLElement) => { + item.style.minWidth = ""; item.style.display = ""; - if (!hasNextSibling(item)) { - item.insertAdjacentText("afterend", Constants.ZWSP); - } - if (!hasPreviousSibling(item)) { - item.insertAdjacentText("beforebegin", Constants.ZWSP); - } }); updateTransaction(protyle, id, nodeElement.outerHTML, html); };