I'm trying to find out how to allow people to indent in Tiny MCE editor. Right now, whenever someone presses tab
they just move into the next field. Is there any piece of code that will allow them to actually hit tab
and have it create a tab for a new paragraph.
Insert anchors (sometimes referred to as a bookmarks).When a user clicks on the anchor button or menu item they will be prompted via a dialog box to enter a string. The string will be inserted into the HTML as an anchor id at the location of the cursor.
To disable the toolbar, the toolbar option should be provided a boolean value of false .
By default, it has basic markdown patterns. There are three types of patterns: inline , block , and replacement patterns. Inline patterns have a start and an end text pattern whereas the block and replacement patterns only have a start .
For newer versions of Tiny MCE editor the following solution worked for me:
setup: function(ed) {
ed.on('keydown', function(event) {
if (event.keyCode == 9) { // tab pressed
if (event.shiftKey) {
ed.execCommand('Outdent');
}
else {
ed.execCommand('Indent');
}
event.preventDefault();
return false;
}
});
}
It can be done via nonbreaking plugin available in tinymce
tinymce.init({
selector: "textarea", // change this value according to your HTML
plugins: "nonbreaking",
mewnubar: "insert",
toolbar: "nonbreaking",
nonbreaking_force_tab: true
});
details can be found on https://www.tinymce.com/docs/plugins/nonbreaking/
Thariama's solution didn't quite work for me. I agree with Jon Hulka's fix. This seems to work fine on Firefox (mac+pc), Chrome (mac+pc) and Internet Exploder. It's not perfect, but I find it very usable and acceptable. Thanks Jon
So, to wrap op Jon's solution:
tinyMCE.init({
...
setup : function(ed) {
ed.onKeyDown.add(function(ed, evt) {
if (evt.keyCode == 9){
ed.execCommand('mceInsertContent', false, '  ');
evt.preventDefault();
}
});
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With