pagekit / extension-tinymce

Use the TinyMCE as editor.
5 stars 9 forks source link

TinyMCE cleans HTML code and it can't be disabled #7

Open AhmedAtef opened 8 years ago

AhmedAtef commented 8 years ago

There are no editor settings to disable code cleaning

humantex commented 6 years ago

I came across this today, and was surprised that there's no built-in parameters to change the behaviour inside pagekit's system settings, I had no choice but to modify the core code and force the addition/editing of code to remain after saving. Adding in a CSS class to any appropriate HTML element certainly isn't invalid coding, but it was impossible to do without making these changes.

These edits were done to: /packages/pagekit/tinymce/app/components/editor-tinymce.js

The original code, beginning at line 46 is:

                entity_encoding: "raw",

                init_instance_callback: function (editor) {

The code after the 4 lines of modifications were inserted:

                entity_encoding: "raw",

                cleanup: false,

                verify_html: false,

                valid_elements: '*[*]',

                extended_valid_elements: '*[*]',

                init_instance_callback: function (editor) {

This may not be the best approach. Having some toggles within pagekit itself would certainly be the better solution, and not having to edit core files that would be overwritten on any updates. The modifications I made might also be overkill, and/or valid only for tinymce v3... but at least it solved my immediate problem.

humantex commented 5 years ago

After a recent update to Pagekit 1.0.15, I've had to retrace my steps for any previous edits I've made to core files, and redo them from scratch. It's been quite some time since I'd modified the TinyMCE files, and in order to have the changes work this time, it required unminifying the file (now) located as: /packages/pagekit/tinymce/app/bundle/tinymce.js, to get a more easily readable/editable file.

The line numbers will be different, and should be somewhere around line 36, where the entity_encoding: "raw", value-pair can be found to insert the same 4 lines below it, in order to modify the editor's behavior.