class from customized template for text alignment not put in text area
See original GitHub issueHi I followed your instructions (https://github.com/bootstrap-wysiwyg/bootstrap3-wysiwyg/wiki/Custom-Templates) as best as I could to add text alignment to my toolbar, and it looked as though it was working however, when I pressed submit on my form, the classes which the data-wysihtml5-command=‘justifyLeft’ command was putting in (‘class = “wysiwyg-text-align-left”’) were not in the submitted value for the text area so the data was lost. Actually I think it puts the text in a div with that class. The div was coming through but not the class.
Have I missed something?
I did not understand what the ‘data-wysihtml5-command-value’ was for so I guessed here - it has the same problem when I remove these attributes.
var myCustomTemplates = {
textAlign: function(context) {
return "<li><div class='btn-group'>" +
"<a class='btn btn-default' data-wysihtml5-command='justifyLeft' data-wysihtml5-command-value='&justifyLeft;' title= 'Align text left'>" +
"<span class='glyphicon glyphicon-align-left'></span></a>" +
"<a class='btn btn-default' data-wysihtml5-command='justifyCenter' data-wysihtml5-command-value='&justifyCenter;' title= 'Align text center'>" +
"<span class='glyphicon glyphicon-align-center'></span></a>" +
"<a class='btn btn-default' data-wysihtml5-command='justifyRight' data-wysihtml5-command-value='&justifyRight;' title= 'Align text right'>" +
"<span class='glyphicon glyphicon-align-right'></span></a>" +
"</li>";
}
};
editor.wysihtml5({
stylesheets: [colorCssPath],
"toolbar": {
"font-styles": true, //Font styling, e.g. h1, h2, etc. Default true
"emphasis": true, //Italics, bold, etc. Default true
"lists": true, //(Un)ordered lists, e.g. Bullet"s, Numbers. Default true
"html": false, //Button which allows you to edit the generated HTML. Default false
"link": true, //Button to insert a link. Default true
"image": true, //Button to insert an image. Default true,
"color": true, //Button to change color of font
'textAlign': true // custom defined buttons to align text see myCustomTemplates variable above
},
customTemplates: myCustomTemplates
});
Issue Analytics
- State:
- Created 9 years ago
- Comments:5
Top Results From Across the Web
Set text alignment inside the TextArea using css is not ...
My current code is simple, for the center method I use this inside the method: textArea.setStyle("-fx-text-alignment: center"); But this changes ...
Read more >text-align - CSS: Cascading Style Sheets - MDN Web Docs
The text-align CSS property sets the horizontal alignment of the inline-level content inside a block element or table-cell box.
Read more >class from customized template for text alignment not put in ...
Actually I think it puts the text in a div with that class. The div was coming through but not the class. Have...
Read more >Bootstrap Textarea input free examples, templates & tutorial
A Bootstrap Textarea is an input dedicated to a large volume of text. It may be used in a variety of components like...
Read more >TextBox Class (Windows.UI.Xaml.Controls) - UWP
TextBox supports copy and paste by default. You can provide custom handling of the Paste event on editable text controls in your app....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
HI @AnaxAndrade, There are 2 things i had to do.
so for 1:
I add a css file - as you can see in the code I supplied above, there is this line here
stylesheets: [colorCssPath]
the colorCssPath variable is a string path to a css file in my asset pipeline that includes colors and text-alignment (because colors were not working for me either) here is my css file calledapp/assets/stylesheets/custom-bootstrap3-wysiwyg5.css:3
notice how I map the .wysiwyg-text-align-* classes to real text-align css - same with the color classes. How do I get the colorCssPath in the javascript? In my view(which is in haml) I have this line:
and in the javascript I have this line:
for 2
I use a helper that I call before saving the data from wysihtml5 (or before sending it elsewhere). I will just supply my entire helper here.
app/helpers/wysihtml5_helper.rb
there may be some methods you do not need likefix_for_custom_segment_tags
andremove_auto_added_br
Hope this helps. Let me know if you have any questions. I don’t know but maybe these problems are fixed in a more recent gem.
p.s. I use the bootstrap-wysihtml5-rails gem which makes use of this project so in my last comment I was assuming that you were using ruby on rails (hence the asset-pipeline and Helper module stuff) but you may not be.