You need to be logged in to post in the forum - Log In
An active JCE Pro Subscription is required to post in the forum - Buy a Subscription
- Support
- Forum
- JCE Editor
- Auto add classes to pasted tables
Support is currently Offline
Official support hours:
Monday To Friday
From 09:00 To 17:00 Europe/London (BST)
From 09:00 To 17:00 Europe/London (BST)
Please post your question in the Forum and we will get back to you as soon as we can.
I have added in the pluginparameter with tables "table table-bordered table-hover". These are bootsrap classes. And that works great.
However, often people paste tables form textprocessors to the article.
Is it possible to add the classes automaticly to those pasted tables? Because to add them by hand is to complicated for my editors.
However, often people paste tables form textprocessors to the article.
Is it possible to add the classes automaticly to those pasted tables? Because to add them by hand is to complicated for my editors.
Travel the world with me !
Do this instead:
tinyMCE.onAddEditor.add(function (mgr, ed) {
ed.settings.paste_postprocess = function(pl, o) {
ed.dom.addClass(ed.dom.select('table', o.node), 'table table-bordered table-hover');
}
});
Just because you're not paranoid doesn't mean everybody isn't out to get you.
There is no option in the Clipboard parameters for this, so it would need to be done using javascript via an editor event, eg:
Create a file called editor.js in /media/jce/js/ containing the following code:
Create a file called editor.js in /media/jce/js/ containing the following code:
(function() {
tinyMCE.onAddEditor.add(function(mgr, ed) {
ed.onInit.add(function() {
ed.onAfterPaste.add(function() {
ed.dom.addClass(ed.dom.select('table'), 'table table-bordered table-hover');
});
});
});
})();
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Do this instead:
tinyMCE.onAddEditor.add(function (mgr, ed) {
ed.settings.paste_postprocess = function(pl, o) {
ed.dom.addClass(ed.dom.select('table', o.node), 'table table-bordered table-hover');
}
});
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Do this instead:
tinyMCE.onAddEditor.add(function (mgr, ed) {
ed.settings.paste_postprocess = function(pl, o) {
ed.dom.addClass(ed.dom.select('table', o.node), 'table table-bordered table-hover');
}
});
Wow, Your fast. And it works. Impressive!
Kuddo's and more. Thanks a lot. This will help me very much. Awesome!

Travel the world with me !
[*] Hu Ryan,
I'm working on a new site (J3.8 & JCEpro latest) but both solutions seems to not work (anymore?). Any idea how to solve this.?
I made stupid mistake, sorry. It still works.
Thanks.
I'm working on a new site (J3.8 & JCEpro latest) but both solutions seems to not work (anymore?). Any idea how to solve this.?
[*] Hu Ryan,
I'm working on a new site (J3.8 & JCEpro latest) but both solutions seems to not work (anymore?). Any idea how to solve this.?
I made stupid mistake, sorry. It still works.

Travel the world with me !
Please try:
tinyMCE.onAddEditor.add(function (mgr, ed) {
ed.onPreInit.add(function () {
ed.onPastePostProcess.add(function (pl, o) {
ed.dom.addClass(ed.dom.select('table', o.node), 'table table-bordered table-hover');
});
});
});
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Please try:
tinyMCE.onAddEditor.add(function (mgr, ed) {
ed.onPreInit.add(function () {
ed.onPastePostProcess.add(function (pl, o) {
ed.dom.addClass(ed.dom.select('table', o.node), 'table table-bordered table-hover');
});
});
});
Hi Ryan,
I put the file editor.js in /media/com_jce/js/
I deleted all cache and cookies. But it does not seem to work.
Any other suggestion maybe.
Thanks
Travel the world with me !
Please try (it might not look much different, but it is. Tested and working) :
tinyMCE.onAddEditor.add(function (mgr, ed) {
ed.onPreInit.add(function (ed) {
ed.onPastePostProcess.add(function (ed, o) {
ed.dom.addClass(ed.dom.select('table', o.node), 'table table-bordered table-hover');
});
});
});
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Please try (it might not look much different, but it is. Tested and working) :
tinyMCE.onAddEditor.add(function (mgr, ed) {
ed.onPreInit.add(function (ed) {
ed.onPastePostProcess.add(function (ed, o) {
ed.dom.addClass(ed.dom.select('table', o.node), 'table table-bordered table-hover');
});
});
});
Hi Ryan,
I tried several times and deleted cookies and cache. Also tried another browser.
Maybe I need to adjust a setting in Joomla/JCE?
I attached my JCE profile just to be sure.
Travel the world with me !
This will only work with content pasted in from outside the editor. Is the table code coming from an external source?
HI Ryan,
Maybe I'm doing something wrong somewhere?
If I paste a table from Libreoffice I get:
<table border="0">
If I copy table from a website I get:
<table>
I also don't understand, because it's working with you.
Travel the world with me !
Please send me a login - https://www.joomlacontenteditor.net/contact/site-login
Just because you're not paranoid doesn't mean everybody isn't out to get you.
Please send me a login - https://www.joomlacontenteditor.net/contact/site-login
Done
Travel the world with me !
Your editor.js file still contains the old code:
Sorry Ryan,
I made stupid mistake, I put it in media/com_jce/js instead of media/jce/js
It working now.
Thanks a lot, awesome support. Sorry for the inconvenience
Travel the world with me !
- Page :
- 1
There are no replies made for this post yet.
Be one of the first to reply to this post!
Be one of the first to reply to this post!