-
Notifications
You must be signed in to change notification settings - Fork 535
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
genericcontenthandler is brutal #348
Comments
+1 for moving some functions from generic to word and sanitize (and/or new ones) is a good idea |
Removing comments is not always a good idea. For example, in WordPress, |
The "brutality" of the content handlers is well noted, @deliminator. @evo42 and I have discussed how the content handling approach needs to be It will be a good idea to put content handlers back into the roadmap. Here are some of things that need to be addressed:
|
Is there anyone who would like to take this on? |
What is the purpose of content handlers? To clean up pasted content. Anything else? |
moved to backlog for further discussion |
Hi! |
@Benew you can define your own settings for the (sanitize) contentHandler (Aloha.settings.contentHandler.allows): Aloha.settings.contentHandler: {
insertHtml: [ 'word', 'generic', 'oembed', 'sanitize' ],
initEditable: [ 'sanitize' ],
getContents: [ 'blockelement', 'sanitize', 'basic' ],
sanitize: 'relaxed' // relaxed, restricted, basic,
allows: {
elements: [
'strong', 'em', 'i', 'b', 'blockquote', 'br', 'cite', 'code', 'dd', 'div', 'dl', 'dt', 'em',
'i', 'li', 'ol', 'p', 'pre', 'q', 'small', 'strike', 'sub',
'sup', 'u', 'ul'],
attributes: {
'a' : ['href'],
'blockquote': ['cite'],
'q' : ['cite']
},
protocols: {
'a' : {'href': ['ftp', 'http', 'https', 'mailto', '__relative__']}, // Sanitize.RELATIVE
'blockquote': {'cite': ['http', 'https', '__relative__']},
'q' : {'cite': ['http', 'https', '__relative__']}
}
},
handler: {
generic: {
transformFormattings: false // this will disable the transformFormattings method in the generic content handler
}
}
} source: http://aloha-editor.org/guides/plugin_contenthandler.html You can use the default ("relaxed") config from the sanitize handler and add the attributes (eg style) for the elements where you want to use/allow the align plugin: default settings: https://github.com/alohaeditor/Aloha-Editor/blob/dev/src/plugins/common/contenthandler/lib/sanitizecontenthandler.js#L75 |
I notice above: transforms strong => b, em => i, s => del What if you want the inverse? I.e. |
@wimleers at the moment you'll need to deactivate the genericcontenthandler and use your own handler (eg. copy it and rename) -- it's not configurable (yet) here's the part which is doing the transformation: |
Thanks. Won't cause disabling (Your reply partially answers https://getsatisfaction.com/aloha_editor/topics/content_handler_to_convert_to_when_pasting_must_run_before_all_others, by the way. I've linked to your reply from there.) |
That's right, the genericcontenthandler is quite important. Not only disable it, but copy it, modify it to your needs, rename it and put it into your own plugin -- then define the order of / which contenthandler you'll want to use in what situation: Aloha.settings.contentHandler.insertHtml {used at paste}, Aloha.settings.contentHandler.initEditable and the undocumented one: Aloha.settings.contentHandler.getContents |
@wimleers you can also just deactivate the transformFormattings method in the generic CH with |
The genericcontenthandler does too much. It rougly does the following:
This is too much, since it is supposed to be generic. Only those clean-ups that are always a good idea should be done (I suppose removing comments is always a good idea).
Pasting from word (and probably other sources) do need the functionality above. So, the things the genriccontenthandler does are probably always a good idea when content is pasted. However, the genericcontenthandler can also be configured for cleaning up the content when the editable is initialized.
It may be possible to make the sanitize content handler handler do some of the things the genericcontenthandler does.
What would be interesting to have is a generic content handler, that can be activated by default and used for initializing editables without causing any undesired side-effects.
The text was updated successfully, but these errors were encountered: