Vanessa 2024-06-19 11:00:58 +08:00
parent 62f02d9c90
commit b3b641913f

View File

@ -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);
};