-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated against ezsystems/ezpublish-legacy
- Loading branch information
1 parent
aec1e53
commit 0439521
Showing
3 changed files
with
86 additions
and
16 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
design/standard/javascript/plugins/breakoutspace/editor_plugin.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Break Out Space TinyMCE plugin. When you press CTRL+Enter in a custom tag you will get an empty paragraph outside the tag | ||
* | ||
* @author Peter Keung | ||
* @copyright Copyright 2014, Mugo Web | ||
*/ | ||
|
||
( function() | ||
{ | ||
tinymce.create('tinymce.plugins.breakoutspace', | ||
{ | ||
/** | ||
* Initializes the plugin, this will be executed after the plugin has been created. | ||
* This call is done before the editor instance has finished it's initialization so use the onInit event | ||
* of the editor instance to intercept that event. | ||
* | ||
* @param {tinymce.Editor} ed Editor instance that the plugin is initialized in. | ||
* @param {string} url Absolute URL to where the plugin is located. | ||
*/ | ||
init: function( ed, url ) | ||
{ | ||
ed.onKeyDown.add( function( ed, e ) | ||
{ | ||
// Capture CTRL+Enter | ||
if( ( ( e.keyCode == 13 ) || ( e.keyCode == 10 ) ) && ( e.ctrlKey == true ) ) | ||
{ | ||
var dom = ed.dom; | ||
|
||
var parents = dom.getParents( ed.selection.getNode() ); | ||
for( var i=0; i < parents.length; i++ ) | ||
{ | ||
currentNode = parents[i]; | ||
// Insert empty paragraph at the end of the parent of the closest custom tag | ||
if( currentNode.nodeName == 'DIV' && currentNode.getAttribute( 'type' ) == 'custom' ) | ||
{ | ||
// dom.insertAfter doesn't work reliably | ||
var uniqueID = dom.uniqueId(); | ||
jQuery( '<p id="' + uniqueID + '"><br /></p>' ).insertAfter( currentNode ); | ||
|
||
// Move to the new node | ||
var newParagraph = dom.select( 'p#' + uniqueID )[0]; | ||
ed.selection.setCursorLocation( newParagraph ); | ||
|
||
// Don't create an extra paragraph | ||
e.preventDefault(); | ||
break; | ||
} | ||
} | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
// Register plugin | ||
tinymce.PluginManager.add( 'breakoutspace', tinymce.plugins.breakoutspace ); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters