Comment changer les options de menu de formatage dans le rédacteur?
-
20-12-2019 - |
Question
Par défaut, dans le menu de formatage (lorsque vous cliquez sur le bouton), il existe ces options:
Normal Text
Quote
Code
Header 1
Header ...
Header 5
Je voudrais seulement avoir ces options:
Normal Text
Quote
Code
Y a-t-il un moyen de faire ça?J'ai récréré des options de configuration et je n'ai pas pu savoir comment le faire.
La solution
La réponse olivérs est fausse.
Vous pouvez facilement y parvenir en procédant comme suit:
$('#redactor').redactor({
formattingTags: ['p', 'blockquote', 'pre']
});
Autres conseils
Malheureusement, la seule façon d'y parvenir est de Décorer votre instance de redactor avant initet écrasez la barre d'outils par défaut dans le redresseur.
Vous pouvez voir un POC de travail ici: http://jsfiddle.net/zmetser/7m3f9/
et le code ci-dessous:
$(function() {
// Decorate redactor Object before init
$.Redactor.fn = (function () {
var toolbarInitOriginal = this.toolbarInit;
// Create a new toolbarInit method which suits our needs
this.toolbarInit = function (lang) {
// Grab the default toolbar...
var toolbar = toolbarInitOriginal(lang);
// ...and overwrite the formatting dropdown menu
toolbar.formatting.dropdown = {
p: {
title: lang.paragraph,
func: 'formatBlocks'
},
blockquote: {
title: lang.quote,
func: 'formatQuote',
className: 'redactor_format_blockquote'
},
pre: {
title: lang.code,
func: 'formatBlocks',
className: 'redactor_format_pre'
},
};
return toolbar;
};
return this;
}.call($.Redactor.fn));
// Init redactor
$('#redactor').redactor({
buttons: ['link', 'formatting', 'html']
});
});
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow