Skip to content

Commit bac0050

Browse files
[IMP] mass_mailing: stop using HtmlMailField
1 parent 2064ff5 commit bac0050

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

addons/mail/static/src/views/web/fields/html_mail_field/convert_inline.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ export function formatTables(element) {
12561256
*/
12571257
export function getCSSRules(doc) {
12581258
const cssRules = [];
1259-
for (const sheet of doc.styleSheets) {
1259+
for (const sheet of [...doc.styleSheets, ...doc.adoptedStyleSheets]) {
12601260
// try...catch because browser may not able to enumerate rules for cross-domain sheets
12611261
let rules;
12621262
try {

addons/mass_mailing/static/src/fields/html_field/mass_mailing_html_field.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
import {
2-
HtmlMailField,
3-
htmlMailField,
4-
} from "@mail/views/web/fields/html_mail_field/html_mail_field";
51
import { registry } from "@web/core/registry";
62
import { LocalOverlayContainer } from "@html_editor/local_overlay_container";
73
import { MassMailingIframe } from "@mass_mailing/iframe/mass_mailing_iframe";
@@ -15,11 +11,12 @@ import { normalizeHTML, parseHTML } from "@html_editor/utils/html";
1511
import { Deferred, Race } from "@web/core/utils/concurrency";
1612
import { MAIN_PLUGINS as MAIN_EDITOR_PLUGINS } from "@html_editor/plugin_sets";
1713
import { DynamicPlaceholderPlugin } from "@html_editor/others/dynamic_placeholder_plugin";
14+
import { getCSSRules, toInline } from "@mail/views/web/fields/html_mail_field/convert_inline";
1815

19-
export class MassMailingHtmlField extends HtmlMailField {
16+
export class MassMailingHtmlField extends HtmlField {
2017
static template = "mass_mailing.HtmlField";
2118
static components = {
22-
...HtmlMailField.components,
19+
...HtmlField.components,
2320
LocalOverlayContainer,
2421
MassMailingIframe,
2522
ThemeSelector,
@@ -265,9 +262,9 @@ export class MassMailingHtmlField extends HtmlMailField {
265262
const processingEl = this.iframeRef.el.contentDocument.createElement("DIV");
266263
processingEl.append(parseHTML(this.iframeRef.el.contentDocument, value));
267264
this.insertForInlineProcessing(processingEl);
268-
const inlineValue = (
269-
await HtmlMailField.getInlineHTML(processingEl, this.iframeRef.el.contentDocument)
270-
).innerHTML;
265+
const cssRules = getCSSRules(this.iframeRef.el.contentDocument);
266+
await toInline(processingEl, cssRules);
267+
const inlineValue = processingEl.innerHTML;
271268
processingEl.remove();
272269
if (shouldRestoreDisplayNone) {
273270
this.iframeRef.el.classList.add("d-none");
@@ -283,7 +280,7 @@ export class MassMailingHtmlField extends HtmlMailField {
283280
}
284281

285282
export const massMailingHtmlField = {
286-
...htmlMailField,
283+
...htmlField,
287284
component: MassMailingHtmlField,
288285
// TODO EGGMAIL decide which options we want in extractProps?
289286
extractProps({ attrs, options }) {

0 commit comments

Comments
 (0)