From 951eda2d584b133c996161cf2a7edc82f2ed2eb7 Mon Sep 17 00:00:00 2001 From: Asad Ali Date: Wed, 26 Oct 2022 14:30:11 +0500 Subject: [PATCH] fix: retrieve raw content from TinyMCE editor During the upgrade to TinyMCE v5 we changed the content format to `text`. However, it ignores changes in HTML tags. This reverts the format to `raw`. --- common/lib/xmodule/xmodule/js/spec/html/edit_spec.js | 2 +- common/lib/xmodule/xmodule/js/src/html/edit.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/spec/html/edit_spec.js b/common/lib/xmodule/xmodule/js/spec/html/edit_spec.js index 6a78325da8ac..9ce8c06c4dbd 100644 --- a/common/lib/xmodule/xmodule/js/spec/html/edit_spec.js +++ b/common/lib/xmodule/xmodule/js/spec/html/edit_spec.js @@ -24,7 +24,7 @@ describe('HTMLEditingDescriptor', function() { }); it('Returns data from Raw Editor if text has not changed', function(done) { const visualEditorStub = - {getContent() { return 'original visual text' }}; + {getContent() { return '

original visual text

' }}; spyOn(this.descriptor, 'getVisualEditor').and.callFake(() => visualEditorStub); var self = this; diff --git a/common/lib/xmodule/xmodule/js/src/html/edit.js b/common/lib/xmodule/xmodule/js/src/html/edit.js index 267297e21688..bb92d8c848d9 100644 --- a/common/lib/xmodule/xmodule/js/src/html/edit.js +++ b/common/lib/xmodule/xmodule/js/src/html/edit.js @@ -1390,7 +1390,7 @@ haven't dirtied the Editor. Store the raw content so we can compare it later. */ this.starting_content = visualEditor.getContent({ - format: "text", + format: "raw", no_events: 1 }); return visualEditor.focus(); @@ -1410,7 +1410,7 @@ if (this.editor_choice === 'visual') { visualEditor = this.getVisualEditor(); raw_content = visualEditor.getContent({ - format: "text", + format: "raw", no_events: 1 }); if (this.starting_content !== raw_content) {