Custom toolbar with Summernote - toolbar

How do I know which functions can be enabled for the toolbar of summernote, and how to do it?
In the API docs all I can find is "toolbar : Array (optional)" without further explanation.
I've managed to enable some features thanks to one of the examples, but how can I also enable: code, indent and outdent?
$(".summernote").summernote({
styleWithSpan: false,
toolbar: [
['style', ['bold', 'italic', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol']]
]
});

in settings.js You have basic setting (with all features on):
toolbar: [
['style', ['style']],
['font', ['bold', 'italic', 'underline', 'clear']],
['fontname', ['fontname']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['height', ['height']],
['table', ['table']],
['insert', ['link', 'picture', 'hr']],
['view', ['fullscreen', 'codeview']],
['help', ['help']]
],
indentation is in 'paragraph'

paragraph includes indent and outdent, codeview as it suggests does codeview.
$('.summernote').summernote({
toolbar: [
//[groupname, [button list]]
['style', ['bold', 'italic', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['view', ['codeview']],
]
});
If you look on the main Summernote website as opposed to the API docs you will see a clear example, that explains how to customise the toolbar. It is on the Deep Dive page and scroll down to Custom Toolbar. It also lists the available toolbar buttons.
http://summernote.org/#/deep-dive#custom-toolbar

Related

Summernote Get Code function not Storing text values

When I tried to put the final code view of summernote to firebase, It's only displaying HTML tags. not showing the texts
Here is the result of Firebase
Here is my code
$('#summernote').summernote({
placeholder: 'Start writing here...',
tabsize: 2,
height: 450,
toolbar: [
['style', ['style']],
['font', ['bold', 'underline', 'clear']],
['color', ['color']],
['para', ['ul', 'ol', 'paragraph']],
['table', ['table']],
['insert', ['link', 'picture', 'video']],
['view', ['fullscreen', 'codeview', 'help']]
]
});
const content = $('#summernote').summernote('code');
cosole.log("content")
<textarea id="summernote" class="article"></textarea>

TinyMCE - Customise CSS Styles Menu On Toolbar

I have set up a simple CSS file with a single .test class and have the following settings in TinyMCE I get two menus that both say 'Paragraph at the top. How do edit the CSS styles menu
tinymce.init({
selector: '#tiny',
menubar:false,
'content_css': 'my-styles.css',
importcss_append: false,
style_formats_merge: true,
plugins: ['importcss'],
toolbar: 'code| insertfile undo redo searchreplace | paste pastetext | formatselect | styleselect '
});
format menu
css styles menu
Here's a working example in case anyone else is looking:
content_style:
'.news-img-left { float: left;margin:1em 1em 1em 0;max-width:400px;height:auto }' +
'.news-img-right { float: right;margin:1em 0 1em 1em;max-width:400px;height:auto }' +
'.news-img-full { margin:1em 0;width:100%;max-width:100%;height:auto }',
style_formats: [
{ title: 'Text Formats' },
{ title: 'Paragraph', format: 'p' },
{ title: 'Heading 1', format: 'h1' },
{ title: 'Heading 2', format: 'h2' },
{ title: 'Heading 3', format: 'h3' },
{ title: 'Image Formats' },
{ title: 'Image Full Width', selector: 'img', classes: 'news-img-full' },
{ title: 'Image Left', selector: 'img', classes: 'news-img-left' },
{ title: 'Image Right', selector: 'img', classes: 'news-img-right' },
],
then in tool bar I added button 'styleselect'
This question was also asked in the TinyMCE Github issuetracker and I'll copy in the answer here for completeness.
Both formatselect and styleselect shows the currenly used format. The default format is the "Paragraph", matching the <p> tag basically.
The styleselect doesn't have anything to do with CSS style really, think of it more in terms of visual appearances. The differences between styleselect and formatselect are mainly in the config options available:
The formatselect button is configured by the block_formats option and is rather basic.
The styleselect button is configured through the style_formats option and is much more advanced. It can contain nested menus, have groups etc.

How to display multiple ckeditor-textarea in a component with different toolbar?

I have multiple ckeditor in a component and for some reason i want a textarea-ckeditor to be readonly with some toolbar enabled;
ie: 'print','preview','find', and 'maximize'.
How can i achieve this? i've tried removing the plugins but only success if i alter the config.js which will 'standardize' all my ckeditor.
What i can think is that i need to alter something from this code.
CKEDITOR.replace('header',{
width: '100%',
height: 570});
Thanks in adv..
I found the solution but instead of removing the toolbar buttons, i list all the desired buttons as following;
toolbar: [
{ name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: ['-','Preview', 'Print', '-' ] },
{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find','-','-' ] },
{ name: 'tools', items: [ 'Maximize'] }
]

fosckeditor bundle - cannot configure extra plugins

I downloaded the friendsofsymfony/ckeditor-bundle, added extraPlugins and their config is not being applied. My config:
# config/packages/fos_ck_editor.yaml
fos_ck_editor:
default_config: my_config
configs:
my_config:
toolbar: [ ['Bold', 'Italic', 'Underline', 'NumberedList', 'BulletedList', 'Outdent', 'Indent'] ]
extraPlugins: 'wordcount,notification'
wordcount:
showWordCount: false # disable this
showCharCount: true # enable this
plugins:
wordcount:
path: '/bundles/fosckeditor/plugins/wordcount/'
filename: 'plugin.js'
notification:
path: '/bundles/fosckeditor/plugins/notification/'
filename: 'plugin.js'

How to take heading (h1, h2, h3) directly on toolbar in tinymce 4

I wanna change heading (h1,h2,h3) directly on toolbar ( like tinymce version 3) because i use it very much when i create a new artical. I'm trying to search on internet but I didn't find any answers. Please help me. Thanks a lot
This answer arrives surely late, but maybe it can help others like me, people how are looking for answer for the same question. I read it here: http://blog.ionelmc.ro/2013/10/17/tinymce-formatting-toolbar-buttons/
First, you have to create the plugin:
tinyMCE.PluginManager.add('stylebuttons', function(editor, url) {
['pre', 'p', 'code', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6'].forEach(function(name){
editor.addButton("style-" + name, {
tooltip: "Toggle " + name,
text: name.toUpperCase(),
onClick: function() { editor.execCommand('mceToggleFormat', false, name); },
onPostRender: function() {
var self = this, setup = function() {
editor.formatter.formatChanged(name, function(state) {
self.active(state);
});
};
editor.formatter ? setup() : editor.on('init', setup);
}
})
});
});
And then use it in your toolbar:
tinyMCE.init({
selector: '#id',
toolbar: "undo redo | style-p style-h1 style-h2 style-h3 style-pre style-code",
plugins: "stylebuttons",
});
tinymce.init({
toolbar: 'undo redo | alignleft aligncenter alignright alignjustify | formatselect fontselect fontsizeselect | bullist numlist | outdent indent',
});
This is a quicker way to add H1, Paragraph and other options to your toolbar in TinyMCE 4.
For a full list see:
http://www.tinymce.com/wiki.php/Controls
Specificly the 'Core' section. That shows the most commonly used tools.
Using the following worked for me
tinymce.init({
toolbar: 'formatselect',
block_formats: 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;',
});
Editor will look like this:
Refering to this question on the TINYMCE forum:
http://www.tinymce.com/forum/viewtopic.php?id=32801
Use these params in the config.
style_formats: [
{title: 'Headers', items: [
{title: 'h1', block: 'h1'},
{title: 'h2', block: 'h2'},
{title: 'h3', block: 'h3'},
{title: 'h4', block: 'h4'},
{title: 'h5', block: 'h5'},
{title: 'h6', block: 'h6'}
]},
{title: 'Inline', items: [
{title: 'Bold', inline: 'b', icon: 'bold'},
{title: 'Italic', inline: 'i', icon: 'italic'},
{title: 'Underline', inline: 'span', styles : {textDecoration : 'underline'}, icon: 'underline'},
{title: 'Strikethrough', inline: 'span', styles : {textDecoration : 'line-through'}, icon: 'strikethrough'},
{title: 'Superscript', inline: 'sup', icon: 'superscript'},
{title: 'Subscript', inline: 'sub', icon: 'subscript'},
{title: 'Code', inline: 'code', icon: 'code'},
]},
{title: 'Blocks', items: [
{title: 'Paragraph', block: 'p'},
{title: 'Blockquote', block: 'blockquote'},
{title: 'Div', block: 'div'},
{title: 'Pre', block: 'pre'}
]},
{title: 'Alignment', items: [
{title: 'Left', block: 'div', styles : {textAlign : 'left'}, icon: 'alignleft'},
{title: 'Center', block: 'div', styles : {textAlign : 'center'}, icon: 'aligncenter'},
{title: 'Right', block: 'div', styles : {textAlign : 'right'}, icon: 'alignright'},
{title: 'Justify', block: 'div', styles : {textAlign : 'justify'}, icon: 'alignjustify'}
]}
]

Resources