From f71e3333573abc7f5c0921f36047143156b32020 Mon Sep 17 00:00:00 2001 From: cahrens Date: Mon, 17 Mar 2014 15:26:20 -0400 Subject: [PATCH] Change how we detect that an image has been inserted. --- .../xmodule/xmodule/js/src/html/edit.coffee | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/common/lib/xmodule/xmodule/js/src/html/edit.coffee b/common/lib/xmodule/xmodule/js/src/html/edit.coffee index 886d82a65f..172a387d33 100644 --- a/common/lib/xmodule/xmodule/js/src/html/edit.coffee +++ b/common/lib/xmodule/xmodule/js/src/html/edit.coffee @@ -65,20 +65,14 @@ class @HTMLEditingDescriptor @visualEditor = ed - ed.on('change', @changeHandler) + ed.on('SaveImage', @imageAdded) ed.on('ShowCodeMirror', @showCodeEditor) ed.on('SaveCodeMirror', @saveCodeEditor) - # Intended to run after the "image" plugin is used so that static urls are set - # correctly in the Visual editor immediately after command use. - changeHandler: (e) => - # The fact that we have to listen to all change events and act on an event actually fired - # from undo (which is where the "level" comes from) is extremely ugly. However, plugins - # don't fire any events in TinyMCE version 4 that I can hook into (in particular, not ExecCommand). - debugger - if e.level and e.level.content and e.level.content.match(/ # Called with the CodeMirror Editor is displayed to convert links to show satic prefix. @@ -91,9 +85,12 @@ class @HTMLEditingDescriptor codeEditor.setValue(content) initInstanceCallback: (visualEditor) => - visualEditor.setContent(rewriteStaticLinks(visualEditor.getContent({no_events: 1}), '/static/', @base_asset_url)) + @rewriteLinksFromStatic(visualEditor) @focusVisualEditor(visualEditor) + rewriteLinksFromStatic: (visualEditor) => + visualEditor.setContent(rewriteStaticLinks(visualEditor.getContent({no_events: 1}), '/static/', @base_asset_url)) + focusVisualEditor: (visualEditor) => visualEditor.focus()