canvas-lms/app/jsx/editor
Jacob Fugal 79861cf20d clean up RCE abstraction layer and service sidebar
refs CNVS-26704, CNVS-26707

RichContentEditor and RceCommandShim:

* move risk level management all to the server side; just one flag in JS
  is set contextually in the server response based on server chosen risk
  level for the page

* flatten the RichContentEditor and RceCommandShim modules to singleton
  method collections, rather than instances

* add RceCommandShim.focus and .destroy methods that more gracefully
  divide the implementations vs. just using send(target, 'focus') or
  send(target, 'destroy')

Editor Loading and Focus

* replace attachSidebarTo calls -- which always (see one exception
  below) paired with a loadNewEditor call -- are replaced with the
  focus:true option to loadNewEditor. when on, the editor is explicitly
  focused after load; it no longer turns on tinymce auto_focus

* on internal tinymce events that trigger 'editor_box_focus' events,
  explicitly focus the editor. this was an attachSidebarTo call (the
  exception) only registered for quizzes, but now more generally.

Editor Destruction

* replace callOnRCE(target, 'destroy') and target._removeEditor() calls
  with new RichContentEditor.destroyRCE(target). destroys the editor as
  before, but does so through new RceCommandShim.destroy and also hides
  sidebar (so no need for explicit hideSidebar calls, which only ever
  accompanied editor destruction)

Sidebar

* add remoteSidebar.show() and remoteSidebar.hide() polyfills

* separate sidebar abstraction into Sidebar module. public interface is
  still through RichContentEditor: initSidebar calls Sidebar.init and
  show/hide are only called from RichContentEditor implementation in
  response to editor focus and destruction.

* allow registering callbacks during initSidebar for when the sidebar is
  shown/hidden. so the desired action doesn't have to be coupled with
  individual calls to loadNewEditor and destroyRCE.

* ensure initSidebar, when present, precedes loadNewEditor. so if
  there's going to be a sidebar, it's initialized before the editor load
  tries to show it.

* add initSidebar calls to discussions/Reply.coffee and
  editor/EditorToggle.coffee so that they get automatic focus, sidebar
  show on editor load, and sidebar hide on editor destruction,
  previously provided by util/wikiSidebarWithMultipleEditors.coffee.

* cache wikiSidebar elements as soon as initSidebar is called, rather
  than waiting for domready, so that initSidebar doesn't have to be in a
  domready itself.

Miscellaneous

* replace calls of target._justGetCode() and target._setContentCode(...)
  with RichContentEditor.callOnRCE(target, 'get_code') and
  RichContentEditor.callonRCE(target, 'set_code', ...), respectively

* remove a dead legacy bundle and d dead module only used by that dead
  bundle

* clean up dependencies to remove unnecessary references to wikiSidebar,
  compiled/tinymce, and tinymce.editor_box outside of the abstraction
  layer or legacy-only code.

* fix idGenerator fragile spec bug

test-plan:
  there should not be significant changes in _what_ the RCE or sidebar
  does. but significant changes in _how_. so no new features to test,
  but a thorough regression on RCE and sidebar behaviors is probably in
  order (sorry)

Change-Id: I4e0cbcb3dcb28152750bf9267d795a179822a601
Reviewed-on: https://gerrit.instructure.com/75469
Tested-by: Jenkins
Reviewed-by: Ethan Vizitei <evizitei@instructure.com>
QA-Review: Jeremy Putnam <jeremyp@instructure.com>
Product-Review: Ethan Vizitei <evizitei@instructure.com>
2016-03-30 18:03:24 +00:00
..
SwitchEditorControl.jsx clean up RCE abstraction layer and service sidebar 2016-03-30 18:03:24 +00:00