Skip to content

Commit

Permalink
Merge pull request #118 from WordPress/tinymce-logger
Browse files Browse the repository at this point in the history
Add logger to TinyMCE to test, learn and debug.
  • Loading branch information
ellatrix authored Feb 23, 2017
2 parents 70fe41f + b7d92df commit d15cb47
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
20 changes: 20 additions & 0 deletions shared/tinymce/logger.js
Original file line number Diff line number Diff line change
@@ -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 );
} );
} );
} );
1 change: 1 addition & 0 deletions tinymce/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
<p>Many entrepreneurs idolize Steve Jobs. He’s such a <a href="">perfectionist</a>, they say. Nothing leaves the doors of 1 Infinite Loop in Cupertino without a polish and finish that makes geeks everywhere drool. No compromise!</p>
</section>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.5.3/tinymce.min.js"></script>
<script src="../shared/tinymce/logger.js"></script>
<script src="tinymce-config.js"></script>
</body>
</html>
1 change: 1 addition & 0 deletions tinymce/tinymce-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit d15cb47

Please sign in to comment.