[FIX] web_editor: delete comment nodes on sanitize
During `to_inline` process, the document will be transformed to be email friendly. This can add some `<!-- mso -->` comment into the document. These comments nodes will create issues during future edition, if we keep them in the editable. So we add a sanitize step to remove all comments nodes. task-3222474 closes odoo/odoo#124020 X-original-commit: b85a29d9ba36aaaa90e514ba45d1054b693a26e2 Signed-off-by: David Monjoie (dmo) <dmo@odoo.com> Signed-off-by: Geelen Sébastien (sge) <sge@odoo.com>
This commit is contained in:
@@ -575,6 +575,7 @@ export class HtmlField extends Component {
|
||||
*/
|
||||
async _toInline() {
|
||||
const $editable = this.wysiwyg.getEditable();
|
||||
this.wysiwyg.odooEditor.sanitize(this.wysiwyg.odooEditor.editable);
|
||||
const html = this.wysiwyg.getValue();
|
||||
const $odooEditor = $editable.closest('.odoo-editor-editable');
|
||||
// Save correct nodes references.
|
||||
|
||||
@@ -149,6 +149,11 @@ class Sanitize {
|
||||
node = nodeP;
|
||||
}
|
||||
|
||||
// Remove comment nodes to avoid issues with mso comments.
|
||||
if (node.nodeType === Node.COMMENT_NODE) {
|
||||
node.remove();
|
||||
}
|
||||
|
||||
const selection = this.root.ownerDocument.getSelection();
|
||||
const anchor = selection && selection.anchorNode;
|
||||
const anchorEl = anchor && closestElement(anchor);
|
||||
|
||||
@@ -5778,6 +5778,15 @@ X[]
|
||||
});
|
||||
});
|
||||
|
||||
describe('comment node', () => {
|
||||
it('should remove comment node inside editable content during sanitize', async () => {
|
||||
await testEditor(BasicEditor, {
|
||||
contentBefore: '<p>ab<!-- comment -->cd</p>',
|
||||
contentAfter: '<p>abcd</p>',
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('markdown', () => {
|
||||
describe('inline code', () => {
|
||||
it('should convert text into inline code (start)', async () => {
|
||||
|
||||
Reference in New Issue
Block a user