From b7d92df2bb7c4459040f18899b195b9c436f9706 Mon Sep 17 00:00:00 2001 From: iseulde Date: Thu, 23 Feb 2017 11:32:20 +0100 Subject: [PATCH] Add logger to TinyMCE to test, learn and debug. --- shared/tinymce/logger.js | 20 ++++++++++++++++++++ tinymce/index.html | 1 + tinymce/tinymce-config.js | 1 + 3 files changed, 22 insertions(+) create mode 100644 shared/tinymce/logger.js diff --git a/shared/tinymce/logger.js b/shared/tinymce/logger.js new file mode 100644 index 0000000000000..c88644de68ca2 --- /dev/null +++ b/shared/tinymce/logger.js @@ -0,0 +1,20 @@ +// For testing, learning and debugging. Feel free to add. +// See https://www.tinymce.com/docs/advanced/events/ +window.tinymce.PluginManager.add( 'logger', function( editor ) { + var types = { + selectionChange: 'fires when the selection changes.', + nodeChange: 'fires when the selection and the node changes. Use `event.element`.', + beforePastePreProcess: 'gives raw paste content before processing.', + pastePostProcess: 'gives paste content after processing. Use `event.node.innerHTML`.', + beforeSetContent: 'fires before content is set in the editor. Can be used for manipulation.', + setContent: 'fires after content is set in the editor.', + beforeExecCommand: 'fires before commands are executed.', + execCommand: 'fires after commands are executed.' + }; + + window.tinymce.each( types, function( info, type ) { + editor.on( type, function( event ) { + console.log( type, info, event ); + } ); + } ); +} ); diff --git a/tinymce/index.html b/tinymce/index.html index e6fea2551dcc5..477938cb69f99 100644 --- a/tinymce/index.html +++ b/tinymce/index.html @@ -11,6 +11,7 @@

Many entrepreneurs idolize Steve Jobs. He’s such a perfectionist, they say. Nothing leaves the doors of 1 Infinite Loop in Cupertino without a polish and finish that makes geeks everywhere drool. No compromise!

+ diff --git a/tinymce/tinymce-config.js b/tinymce/tinymce-config.js index 0ae1fe163427d..332385a27b52e 100644 --- a/tinymce/tinymce-config.js +++ b/tinymce/tinymce-config.js @@ -7,6 +7,7 @@ window.tinymce.init( { keep_styles: false, menubar: false, object_resizing: false, + plugins: [ 'logger', 'paste' ], schema: 'html5-strict', selector: 'section', theme: false,