@@ -39,23 +39,39 @@ export default class Dispatcher {
3939 * @method setup
4040 */
4141 setup ( ) {
42- // setup all events notifications
43- this . setupElementListeners ( )
42+ // setup all events listeners and keyboard handlers
4443 this . setupKeyboardEvents ( )
44+ this . setupEventListeners ( )
45+ }
46+
47+ unload ( ) {
48+ this . off ( )
49+ this . $document . off ( '.editable' )
50+ }
51+
52+ suspend ( ) {
53+ if ( this . suspended ) return
54+ this . suspended = true
55+ this . $document . off ( '.editable' )
56+ }
57+
58+ continue ( ) {
59+ if ( ! this . suspended ) return
60+ this . suspended = false
61+ this . setupEventListeners ( )
62+ }
63+
64+ setupEventListeners ( ) {
65+ this . setupElementListeners ( )
4566 this . setupKeydownListener ( )
4667
4768 if ( selectionchange ) {
4869 this . setupSelectionChangeListeners ( )
4970 } else {
50- this . setupSelectionChangeFallback ( )
71+ this . setupSelectionChangeFallbackListeners ( )
5172 }
5273 }
5374
54- unload ( ) {
55- this . off ( )
56- this . $document . off ( '.editable' )
57- }
58-
5975 /**
6076 * Sets up events that are triggered on modifying an element.
6177 *
@@ -300,16 +316,14 @@ export default class Dispatcher {
300316 * Fallback solution to support selection change events on browsers that don't
301317 * support selectionChange.
302318 *
303- * @method setupSelectionChangeFallback
304- * @param {HTMLElement } $document: The document element.
305- * @param {Function } notifier: The callback to be triggered when the event is caught.
319+ * @method setupSelectionChangeFallbackListeners
306320 */
307- setupSelectionChangeFallback ( ) {
321+ setupSelectionChangeFallbackListeners ( ) {
308322 const $document = this . $document
309323 const selectionWatcher = this . selectionWatcher
310324
311325 // listen for selection changes by mouse
312- $document . on ( 'mouseup.editableSelection ' , ( event ) => {
326+ $document . on ( 'mouseup.editable ' , ( event ) => {
313327 // In Opera when clicking outside of a block
314328 // it does not update the selection as it should
315329 // without the timeout
0 commit comments