Skip to content

Commit

Permalink
take over enter
Browse files Browse the repository at this point in the history
  • Loading branch information
etcook committed Aug 20, 2014
1 parent 54f880c commit 723e638
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
23 changes: 21 additions & 2 deletions admin/assets/js/tinymce/aiview/plugin.js
Expand Up @@ -37,7 +37,7 @@ tinymce.PluginManager.add('aiview', function( editor ) {
function shortcode( match ){
var re_full = /<div.*?class="[^"]+aesop-component.*?aesop-sc="([^"]+)"[\s\S]*?aesop-component-content[^>]*?>(.*?)<\/div>[\s]*?<\/div>/g;
var re_short = /<div class="[^"]+aesop-component.*aesop-sc="([^"]+)"[\s\S]*?WcMgcq<\/div><\/div>/g;
var re_clean = /<\/div>[\s\S]?<div class="aesop-component-content aesop-content">/g;
//var re_clean = /<p> <\/p>\s*/g;

var parse = re_full.exec(match);

Expand All @@ -56,7 +56,8 @@ tinymce.PluginManager.add('aiview', function( editor ) {
// let's replace the shortcode content with any edits
var sc_filter = /\[[^\]]*\]([^\[]*)[^\]]*\]/;
var sc_filtered = sc_filter.exec(sc);
sc = sc.replace(sc_filtered[1], parse[2].replace(re_clean, ''));
//parse[2] = parse[2].replace(re_clean, '');
sc = sc.replace(sc_filtered[1], parse[2]);
return sc;
}
}
Expand Down Expand Up @@ -150,6 +151,24 @@ tinymce.PluginManager.add('aiview', function( editor ) {
}
});

// if they press enter while inside the editor, move to the next line
editor.onKeyDown.add(function(ed, e) {
if( e.keyCode==13 && !e.ctrlKey && !e.shiftKey && !e.altKey) {
var container = ed.selection.getNode();
var component = window.jQuery(container).parents('.aesop-component');
if ( window.jQuery(container).parents('.aesop-component') != '' ) {
e.preventDefault();
e.stopPropagation();
var insertion = window.jQuery('<p><br/></p>').insertAfter( component );
insertion.uniqueId();

var uniqueId = insertion.attr('id');
var element = ed.dom.select('#' + uniqueId)[0];
ed.selection.setCursorLocation(element);
};
}
});

editor.on( 'BeforeSetContent', function( event ) {
event.content = replaceAesopShortcodes( event.content );
});
Expand Down
2 changes: 1 addition & 1 deletion admin/assets/js/tinymce/aiview/plugin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion admin/assets/js/tinymce/aiview/plugin.min.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 723e638

Please sign in to comment.