mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-15 16:41:07 +08:00
This commit is contained in:
parent
62f02d9c90
commit
b3b641913f
@ -311,29 +311,7 @@ export const goEnd = (protyle: IProtyle) => {
|
|||||||
export const alignImgCenter = (protyle: IProtyle, nodeElement: Element, assetElements: Element[], id: string, html: string) => {
|
export const alignImgCenter = (protyle: IProtyle, nodeElement: Element, assetElements: Element[], id: string, html: string) => {
|
||||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||||
assetElements.forEach((item: HTMLElement) => {
|
assetElements.forEach((item: HTMLElement) => {
|
||||||
item.style.display = "block";
|
item.style.minWidth = "calc(100% - 0.1em)";
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
updateTransaction(protyle, id, nodeElement.outerHTML, html);
|
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) => {
|
export const alignImgLeft = (protyle: IProtyle, nodeElement: Element, assetElements: Element[], id: string, html: string) => {
|
||||||
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
nodeElement.setAttribute("updated", dayjs().format("YYYYMMDDHHmmss"));
|
||||||
assetElements.forEach((item: HTMLElement) => {
|
assetElements.forEach((item: HTMLElement) => {
|
||||||
|
item.style.minWidth = "";
|
||||||
item.style.display = "";
|
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);
|
updateTransaction(protyle, id, nodeElement.outerHTML, html);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user