Tinymce and removeformat option - tinymce

i'm using tinymce 4 and removeformat button. It works very well.
Now i need to remove only particular format (b, strong). I found
removeformat: [
{selector: 'b,strong,em,i,font,u,strike', remove : 'all', split : true, expand : false, block_expand: true, deep : true},
{selector: 'span', attributes : ['style', 'class'], remove : 'empty', split : true, expand : false, deep : true},
{selector: '*', attributes : ['style', 'class'], split : false, expand : false, deep : true}
],
Where is documentation about it? I need to understand every parameter (expand, deep...)
If i select an image and click on remove format, i will lose classes. How can i avoid this behaviour? I tried to remove * selector line but it doesn't work.
I tried also to attach original js to debug. I see my removeformat line is not considered. It considers only its default removeformat.
Thanks

the example in official document (https://www.tinymce.com/docs/configure/content-formatting/#removingaformat) is wrong. It should be:
tinymce.init({
selector: 'textarea', // change this value according to your HTML
format: {
removeformat: [
{selector: 'b,strong,em,i,font,u,strike', remove : 'all', split : true, expand : false, block_expand: true, deep : true},
{selector: 'span', attributes : ['style', 'class'], remove : 'empty', split : true, expand : false, deep : true},
{selector: '*', attributes : ['style', 'class'], split : false, expand : false, deep : true}
]
}
});

Related

add data into combobox using extjs

Hi I have a combo box which have a store that is based on rest call and populate data from data base, its working fine but i need a value 'All' with all the values coming from data base so how can i do this please suggest
var wardName = Ext.create('Ext.data.Store', {
id : 'visittype',
fields : [
{
name : 'id',
type : 'integer',
},
{
name : 'wardName',
}
],
remoteGroup : true,
remoteSort : true,
proxy : {
type : 'rest',
url : 'pmsRest/wards',
reader : {
root : "wardMaster",
idProperty : 'id'
}
},
autoLoad : true,
});
{
xtype : 'combo',
name : 'wardName',
labelStyle : 'color:black;font-weight:bold;width:250px;padding:10;',
labelSeparator : "",
id : 'wardName',
width:'33%',
fieldLabel : 'Ward',
triggerAction : 'all',
store : wardName,
displayField : 'wardName',
valueField : 'id',
multiSelect : false,
typeAhead : true,
//disabled: true,
listeners : {
change : function(combo) {
Ext.getCmp('bedName').bindStore(loadBedName());
}
},
allowBlank : false,
//enableKeyEvents : true,
},
Once the data from the proxy is loaded successfully you can use the insert method of store to add the static data in store.
insert method inserts Model instances into the Store at the given index.
The syntax is store.insert( index, records ) where index is the position at which you want to insert the instance, in this case it would be 0.
hope it helps you. :-)
Add a listener to the store and a load event. In that event you can add a new item to the store when the store is loaded.
listeners: {
load: function(){
this.add({
id: 0,
name: 'All'
});
}
}

why tiny mce doesn't work on an online server and it work fine on localhost?

Hi every one , i have a question about Tinymce,
why doesn't work on an online server and it work fine on localhost?
this is the code i used
<script type="text/javascript">
tinyMCE.init({
mode : "textareas",
theme : "advanced",
directionality: "rtl",
align:"right",
// Drop lists for link/image/media/template dialogs
template_external_list_url : "lists/template_list.js",
external_link_list_url : "lists/link_list.js",
external_image_list_url : "lists/image_list.js",
media_external_list_url : "lists/media_list.js",
// Style formats
style_formats : [
{title : 'Bold text', inline : 'b'},
{title : 'Red text', inline : 'span', styles : {color : '#ff0000'}},
{title : 'Red header', block : 'h1', styles : {color : '#ff0000'}},
{title : 'Example 1', inline : 'span', classes : 'example1'},
{title : 'Example 2', inline : 'span', classes : 'example2'},
{title : 'Table styles'},
{title : 'Table row 1', selector : 'tr', classes : 'tablerow1'}
],
});
</script>
thanks for help
I had same issue ...tried ALL solutions. But now i solve it. So,,, hope this piece of code help others.
To fix WordPress visual editor not showing, follow the steps below:-
FTP to your web server
Download your wp-config.php and add this line of code at the bottom of the file before the “require_once” line.
define('CONCATENATE_SCRIPTS', false );
enjoy sharing !! :)

"Sophisticated" filtering of an array-typed field in Mongo Aggregation framework?

I would like to $match by a field having an array, filled with only false values. The array can be of any size. How can I do that please?
Given data like:
> db.so.insert({data: [true, true, false, false], name: 'A'})
> db.so.insert({data: [false, false, false], name: 'B'})
> db.so.insert({data: [false, false, true], name: 'C'})
> db.so.insert({data: [false], name: 'D'})
You can use $nin:
> db.so.aggregate({$match: { data : { $nin: [true] }} })
{
"result" : [
{
"_id" : ObjectId("51c1f654e376a9016c5a9a6d"),
"data" : [
false,
false,
false
],
"name" : "B"
},
{
"_id" : ObjectId("51c1f65fe376a9016c5a9a6f"),
"data" : [
false
],
"name" : "D"
}
],
"ok" : 1
}
You could use $and to make sure that the array exists if you wanted as well.
If you could precalculate the value of this computation (onlyFalse=true), it might be faster to operate (depending on amount of data, etc.)

TinyMCE and BBCode plugin

I am trying to implement tinyMCE's BBCode plugin but not being able to make it work.
This is the init code:
$(textarea).tinymce({
script_url : '/js/tiny_mce/tiny_mce.js',
theme : "advanced",
plugins : "bbcode",
theme_advanced_buttons1 : "bold,italic,underline,forecolor,|,undo,redo,link,unlink,|,removeformat,cleanup",
theme_advanced_buttons2 : "",
theme_advanced_buttons3 : "",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
theme_advanced_styles : "Code=codeStyle;Quote=quoteStyle",
entity_encoding : "raw",
remove_linebreaks : false,
forced_root_block : false,
force_br_newlines : true,
force_p_newlines : false,
convert_newlines_to_brs : true,
remove_redundant_brs : false,
width: '700px',
height: '250px'
});
The thing is that when I submit the form, HTML tags are being posted instead of BBCode. If I try tinyMCE.activeEditor.getContent() on the console, it brings BBCode.
I'm using an input[type=submit] to send the form (without any JS attached to it).
Why am I not getting BBCode posted?
Try passing the textarea content by a htmlentities function before sending it to the file that will handle the data!

TinyMCE generating compact spaces (160 in ASCII) (0xA0 in HEX) instead of

does anyone know how to configure tinyMCE to utilize instead of the compact spaces? Storing the data in die db causes character encoding issues. We are currently utilizing tinyMCE to send emails and when these characters are sent they create a bunch of question marks, because the encoding we use in emailing cannot handle the compact spaces.
Any help would be greatly appreciated.
See below snippet for init code
tinyMCE.init({
// General options
mode : "textareas",
theme : "advanced",
skin : "o2k7",
plugins : "spellchecker,style,layer,table,advhr,inlinepopups,insertdatetime,print,contextmenu,fullscreen,noneditable,visualchars,xhtmlxtras,wordcount,advlist,paste,tabfocus",
// Theme options
theme_advanced_buttons1 : "newdocument,spellchecker,|,print,|,styleselect,formatselect,fontselect,fontsizeselect,|,fullscreen",
theme_advanced_buttons2 : "bold,italic,underline,strikethrough,sub,sup,|,backcolor,forecolor,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|,outdent,indent,|,insertdate,inserttime,|,code,|,showmorebuttons,",
theme_advanced_buttons3 : "tablecontrols,|,insertlayer,moveforward,movebackward,absolute,|,styleprops,hr,removeformat,visualaid,|,charmap,advhr,",
theme_advanced_toolbar_location : "top",
theme_advanced_toolbar_align : "left",
setup : function(ed) {
// Add a custom button
ed.addButton('showmorebuttons', {
title : 'Expand Advanced Toolbar',
image : '/img/email/toolbars.gif',
onclick : function() {
showMoreButtons(ed.id);
}
});
},
oninit : function(){
var tmpIdent = tinyMCE.activeEditor.id;
document.getElementById(tmpIdent + "_toolbar3").style.display = 'none';
var currentHeight = document.getElementById(tmpIdent+"_ifr").style.height;
currentHeight = currentHeight.substring(0, currentHeight.indexOf("px"));
currentHeight = (currentHeight*1)+15;
document.getElementById(tmpIdent+"_ifr").style.height=currentHeight+"px";
},
apply_source_formatting : false,
force_p_newlines : false,
remove_linebreaks : false,
forced_root_block : false,
force_br_newlines : true,
entity_encoding : "raw",
// Example content CSS (should be your site CSS)
content_css : "/tinymce/example/css/content.css",
relative_urls : false,
// Style formats
style_formats : [
{title : 'Word H1', block : 'h1', styles : {color : '#365f91', 'font-family' : 'cambria'}},
{title : 'Word H2', block : 'h2', styles : {color : '#4f81bd', 'font-family' : 'cambria'}},
{title : 'Word H3', block : 'h3', styles : {color : '#4f81bd', 'font-family' : 'cambria'}},
{title : 'Word H4', block : 'h4', styles : {color : '#4f81bd', 'font-family' : 'cambria', "font-style" : "italic"}}
]
});
Tinymce needs to insert protected spaces (U+00A0) because without them browsers would display only one single space (you may play around with the html in tinymce using the code plugin to see this behavior). This may lead to the problems you described. One solution to this could be to replace those protected spaces onSaveContent or before sending the content to the server. The second approach is to do the replace on server-side.