Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#11507 closed New Feature (invalid)

[PR#78] Templates plugin does not play well with data filtering.

Reported by: Godefroid Chapelle Owned by: Marek Lewandowski
Priority: Normal Milestone:
Component: General Version:
Keywords: HasPullRequest Cc:

Description

There should be a way to register data filter rules when registering templates.

I made a pull request on github :

https://github.com/ckeditor/ckeditor-dev/pull/78

Current registration of templates work through hash tables like :

{
title: 'Image and Title',
image: 'template1.gif',
description: 'One main image with a title and text that surround the image.',
html: '<h3>' +
    // Use src=" " so image is not filtered out by the editor as incorrect (src is required).
    '<img src=" " alt="" style="margin-right: 10px" height="100" width="100" align="left" />' +
    'Type the title here' +
    '</h3>' +
    '<p>' +
    'Type the text here' +
    '</p>'
}

The patch looks for a new key in the template registration hash table : allowedContent

{
title: 'Image and Title',
image: 'template1.gif',
description: 'One main image with a title and text that surround the image.',
html: '<h3>' +
    // Use src=" " so image is not filtered out by the editor as incorrect (src is required).
    '<img src=" " alt="" style="margin-right: 10px" height="100" width="100" align="left" />' +
    'Type the title here' +
    '</h3>' +
    '<p>' +
    'Type the text here' +
    '</p>',
allowedContent: 'img{margin-right}'
}

The allowedContent is allowed through a call to editor.filter.allow()

Change History (6)

comment:1 Changed 11 years ago by Piotrek Koszuliński

Milestone: CKEditor 4.4
Status: newconfirmed
Summary: Templates plugin does not play well with data filtering.[PR#78] Templates plugin does not play well with data filtering.
Type: BugNew Feature

Thanks. We are considering introducing this in CKEditor 4.4. It's a good and simple idea.

comment:2 Changed 11 years ago by Jakub Ś

Keywords: HasPatch HasPullRequest removed

I believe that this bug makes #10390 a duplicate:)

comment:3 Changed 11 years ago by Jakub Ś

Keywords: HasPullRequest added

comment:4 Changed 11 years ago by Marek Lewandowski

Owner: set to Marek Lewandowski
Status: confirmedassigned

comment:5 Changed 11 years ago by Marek Lewandowski

Resolution: invalid
Status: assignedclosed

We've reviewed your code and we won't fix this issue.

The reason is that renderTemplatesList is called after the template button is clicked. At that point you're adding new ACF rules, and it seems to work fine.

But in real life you will save this content in order to edit it later, and custom ACF rules will not be added until you open the template dialog again. That will result in the markup being stripped.

The best way to do this would be to add extra rules inside the plugin’s init function, which isn't a case in current template plugin (because it's doing most logic after button click, rather than in plugin init funciton).

comment:6 Changed 11 years ago by Piotrek Koszuliński

Milestone: CKEditor 4.4
Note: See TracTickets for help on using tickets.
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy