}
}
+function convertFloatingImages(div: HTMLElement): void {
+ div.querySelectorAll("img").forEach((img) => {
+ if (img.classList.contains("messageFloatObjectRight")) {
+ const paragraph = img.closest("p");
+ if (paragraph === null) {
+ return;
+ }
+
+ const figure = document.createElement("figure");
+ figure.classList.add("image", "image-style-side");
+ figure.append(img);
+
+ paragraph.insertAdjacentElement("beforebegin", figure);
+
+ if (paragraph.innerHTML === "") {
+ paragraph.remove();
+ }
+ }
+ });
+}
+
export function normalizeLegacyMessage(element: HTMLElement): void {
if (!(element instanceof HTMLTextAreaElement)) {
throw new TypeError("Expected the element to be a <textarea>.");
normalizeBr(div);
const paragraphs = getPossibleSpacerParagraphs(div);
reduceSpacerParagraphs(paragraphs);
+ convertFloatingImages(div);
element.value = div.innerHTML;
}
}
}
}
+ function convertFloatingImages(div) {
+ div.querySelectorAll("img").forEach((img) => {
+ if (img.classList.contains("messageFloatObjectRight")) {
+ const paragraph = img.closest("p");
+ if (paragraph === null) {
+ return;
+ }
+ const figure = document.createElement("figure");
+ figure.classList.add("image", "image-style-side");
+ figure.append(img);
+ paragraph.insertAdjacentElement("beforebegin", figure);
+ if (paragraph.innerHTML === "") {
+ paragraph.remove();
+ }
+ }
+ });
+ }
function normalizeLegacyMessage(element) {
if (!(element instanceof HTMLTextAreaElement)) {
throw new TypeError("Expected the element to be a <textarea>.");
normalizeBr(div);
const paragraphs = getPossibleSpacerParagraphs(div);
reduceSpacerParagraphs(paragraphs);
+ convertFloatingImages(div);
element.value = div.innerHTML;
}
exports.normalizeLegacyMessage = normalizeLegacyMessage;