Jump to content

Remove (disable) invalid attributs of tables in CKEditor


Juergen
 Share

Recommended Posts

Hello @ all,

I want to disable some of the obsolent and unnecessary attributes ot tables that CKEditor offers, because they are not HTML5 compliant or not necessary. I am talking about the summary, the border and the other attributes that CKEditor offers. 

I want to disable them so that customers cannot be able to use them.

I am not talking about to clean up the html Markup - I can get rid of unwanted markup via a textformatter module, thats not the problem.

I am talking about the table plugin button in the editor itself.

If you click on that button you will be able to add borders, width, class, id and so on. I want to disable some of them, but I dont know if this is possible or not. 

Maybe someone can gave me a hint.

Best regards Jürgen

Link to comment
Share on other sites

This is the solution to remove unwanted table attributes from CKEditor.

Go to /wire/modules/Inputfield/InputfieldCKEditor/ckeditor-4.4.6/config.js and insert this piece of code into the config.js:

CKEDITOR.on( 'dialogDefinition', function( ev )
{
  var dialogName = ev.data.name;
  var dialogDefinition = ev.data.definition;

  if (dialogName == 'table') {

     // Get the advanced tab reference
     var infoTab2 = dialogDefinition.getContents('advanced');

     //Set the default

     // Remove the 'Advanced' tab completely
     dialogDefinition.removeContents('advanced');

     // Get the properties tab reference
     var infoTab = dialogDefinition.getContents('info');

     // Remove unnecessary bits from this tab
     infoTab.remove('txtBorder');
     infoTab.remove('cmbAlign');
     infoTab.remove('txtWidth');
     infoTab.remove('txtHeight');
     infoTab.remove('txtCellSpace');
     infoTab.remove('txtCellPad');
     infoTab.remove('txtCaption');
     infoTab.remove('txtSummary');
  }
});

After that you have only a few attributes left. This is the best way to prevent customers from filling out useless table attributes. This works for other plugins (images, links and so on) too.

A big thanks to Lostkobrakai for pointing me into the right direction.post-2257-0-61618200-1431408450_thumb.jp

  • Like 4
Link to comment
Share on other sites

If it works (can't test) it would be best to add those settings to the site/modules/InputfieldCKEditor dir.

Nice stuff, because the table plugin always bothered me.

  • Like 3
Link to comment
Share on other sites

  • 4 weeks later...

I use Table Tools plugin. The add-on has many tools such as adding, moving and deleting rows and columns, configuring styles of table, selected row or cell. Plugin is very simple in using.

Edited by Martijn Geerts
removed link (commercial interest)
Link to comment
Share on other sites

Table Tools plugin is another possibility, but you have to purchase it.

Another point to mention is that it could be confusing for customers. My experience is that the more possibilities you offer the more problems customers will have. I always tend to make it as simple as possible (ASAP). Dont offer to much settings or possibilities - every additional setting is often a challenge for them.

But for better experienced users it will be a very useful plugin to create really complex tables in a quick way.

So you have to decide depending on the pros and cons.

  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...