Skip to content
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

CKEditor is stripping out attributes and styles #1619

Closed
liquidmelon opened this issue Apr 20, 2017 · 8 comments
Closed

CKEditor is stripping out attributes and styles #1619

liquidmelon opened this issue Apr 20, 2017 · 8 comments
Assignees
Labels
S: merged Completed, reviewed, and merged issues T: enhancement Adding additional functionality

Comments

@liquidmelon
Copy link

liquidmelon commented Apr 20, 2017

this issue is easy to replicate by adding the data attribute to a span in the source editor of a component, for example:
<span class="tidbit-trigger tidbit-color" data-bitnum="0">your text here</span>

if you edit anything in the component a second time, the data attribute will get stripped

based on the CKEditor documentation, CKEditor filters incoming HTML content by transforming and deleting disallowed elements, attributes, classes and styles.

taking what is already in the code and adding two things, i have a solution. change this line: https://github.com/adaptlearning/adapt_authoring/blob/master/frontend/src/core/scaffold/scaffoldOverrides.js#L125

to this:
extraAllowedContent: 'span(*)[*]{*}',

please note that this might only fix the span tag (see this post). there's another post in the forum that appears to be doing this to ordered list tags.

the editor documentation shows that specific things can be allowed or disallowed. there is also a way to allow everything... so maybe changing line 125 to this might also fix the ol tags? i haven't tested this theory, just putting it out there:
allowedContent = true

@lc-thomasberger
Copy link
Member

Also <button> tag's are stripped out when added as html markup. Plugins like glossary do use <a> links to reference Glossary Items from the content. Those should be converted to <button> to fix issues on iOS. This requires a way to add <button>'s through CKEditor.

@melmilloway
Copy link

melmilloway commented Apr 25, 2017

A callout in case anyone wants to put multiple items. Here's mine for svgs.

extraAllowedContent: ['svg(*)[*]{*}', 'path[*]', 'polyline[*]', 'g[*]', 'ellipse[*]'],

@lc-thomasberger
Copy link
Member

extraAllowedContent: 'span(*);*(*);button[name]',
for buttons and classes in general

@taylortom
Copy link
Member

Think we need to make this configurable somewhere, as it may be a security concern for some people (similarly,some may want it to be even more lenient).

@lc-thomasberger
Copy link
Member

Load a custom config file on installation + a set of default settings?
For instance: allow all, better styling, save mode, ...

@taylortom
Copy link
Member

taylortom commented Jun 28, 2018

I think the best solution to this is to expose the extraAllowedContent from the config.json (perhaps as ckEditorAllowedContent), and leave the behaviour as is -- this allows third-parties to modify the extras without any onus on us to officially support specific configurations.

@lc-thomasberger lc-thomasberger added the T: enhancement Adding additional functionality label Jun 28, 2018
@lc-thomasberger lc-thomasberger self-assigned this Jul 3, 2018
@taylortom taylortom added the S: merged Completed, reviewed, and merged issues label Aug 2, 2018
@ceplICT
Copy link

ceplICT commented Dec 12, 2019

Am I missing something? I tried changing my config/config.json to "ckEditorExtraAllowedContent": "span(*)[*]{*}" but adapt still removes tags added to elements (data-bitnum="0")

@chucklorenz
Copy link
Member

@ceplICT After changing the config file, did you attempt to rebuild and restart the authoring tool? If not, give that a shot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S: merged Completed, reviewed, and merged issues T: enhancement Adding additional functionality
Projects
None yet
Development

No branches or pull requests

6 participants