Disable paragraphStyles and inlineStyles buttons after editor intialization Froala 2.6.2 -
i use paragraphstyles , inlinestyles plugins allow users pre-defined css formatting. works well. however, have requirement multiple froala inputs on page , paragraph , inline styles vary across boxes , may entirely off in cases.
i therefore need manage values available , whether toolbar buttons appear or not.
for example,
- editor #1: 2 inline styles, 3 paragraph styles
- editor #2: 3 inline styles, 2 paragraph styles
- editor #3: 2 inline styles, 0 paragraph styles
- editor #4: 0 inline styles, 0 paragraph styles
in case of editor #3 want hide paragraph styles button, , case #4 need hide them both.
currently find if don't set initialisation options after adding plugins default css styles. same if set [''].
so - how can change values these plugins after initialisation, including removing buttons toolbar when not needed.
edit:
it may worth mentioning using packaged froala file.
from this question can see how influence paramstylelist after intitialization.
var inputbox = $('#yourtextareaid'); var editor = $('#inputbox.data').data('froala.editor');
if (mystylescount > 0) { // style object build elsewhere. var newopts={paragraphstyles: parastylelist} newopts = $.extend(editor.opts, newopts); inputbox.froalaeditor("destroy"); inputbox.froalaeditor(newopts); }
however, not override default style list, amd unable remove paragraphstyles button on toolbar. accept css solution hiding buttons long per-editor , not editors.
edit 2: here answer regarding hiding buttons:
var inputbox = $('#yourtextareaid'); inputbox.closest("div").find("button[data-cmd='inlinestyle']").hide(); this looks div enclosing froala controls, finds child button data('cmd) value = 'inlinestyle', hides. no guarantees work if froala developers change markup, sold seen. should work froala toolbar button - inspect html via f12 find target names etc.
Comments
Post a Comment