|
72 | 72 | this.customConfig = false;
|
73 | 73 |
|
74 | 74 | // Add editor's default rules.
|
75 |
| - this.allow( 'p br', 1 ); |
76 |
| - this.allow( allowedContent, 1 ); |
77 |
| - this.allow( editor.config.extraAllowedContent, 1 ); |
| 75 | + this.allow( 'p br', 'default', 1 ); |
| 76 | + this.allow( allowedContent, 'config', 1 ); |
| 77 | + this.allow( editor.config.extraAllowedContent, 'extra', 1 ); |
78 | 78 |
|
79 | 79 | //
|
80 | 80 | // Add filter listeners to toHTML and toDataFormat events.
|
|
97 | 97 | // Rules object passed in editorOrRules argument - initialize standalone filter.
|
98 | 98 | else {
|
99 | 99 | this.customConfig = false;
|
100 |
| - this.allow( editorOrRules, 1 ); |
| 100 | + this.allow( editorOrRules, 'default', 1 ); |
101 | 101 | }
|
102 | 102 | };
|
103 | 103 |
|
|
106 | 106 | * Adds specified rules to the filter.
|
107 | 107 | *
|
108 | 108 | * @param {Object/String/CKEDITOR.style/Object[]/String[]/CKEDITOR.style[]} newRules
|
| 109 | + * @param {String} [featureName] Name of a feature that allows this content. |
109 | 110 | * @param {Boolean} [overrideCustom] By default this method will reject any rules
|
110 | 111 | * if default {@link CKEDITOR.config#allowedContent} is defined. Pass `true`
|
111 | 112 | * to force rules addition.
|
112 | 113 | * @returns {Boolean} Whether rules were accepted.
|
113 | 114 | */
|
114 |
| - allow: function( newRules, overrideCustom ) { |
| 115 | + allow: function( newRules, featureName, overrideCustom ) { |
115 | 116 | if ( this.disabled )
|
116 | 117 | return false;
|
117 | 118 |
|
|
133 | 134 | newRules = convertStyleToRules( newRules );
|
134 | 135 | else if ( CKEDITOR.tools.isArray( newRules ) ) {
|
135 | 136 | for ( i = 0; i < newRules.length; ++i )
|
136 |
| - ret = this.allow( newRules[ i ], overrideCustom ); |
| 137 | + ret = this.allow( newRules[ i ], featureName, overrideCustom ); |
137 | 138 | return ret; // Return last status.
|
138 | 139 | }
|
139 | 140 |
|
|
156 | 157 | if ( groupName.charAt( 0 ) != '$' )
|
157 | 158 | rule.elements = groupName;
|
158 | 159 |
|
| 160 | + if ( featureName ) |
| 161 | + rule.featureName = featureName.toLowerCase(); |
| 162 | + |
159 | 163 | // Save rule and remember to optimize it.
|
160 | 164 | this.allowedContent.push( rule );
|
161 | 165 | rulesToOptimize.push( rule );
|
|
297 | 301 | * @param feature.allowedContent HTML that can be generated by this feature.
|
298 | 302 | * @param feature.requiredContent Minimal HTML that this feature must be allowed to
|
299 | 303 | * generate for it to be able to function at all.
|
| 304 | + * @param {String} feature.name Name of this feature. |
300 | 305 | * @returns {Boolean} Whether this feature can be enabled.
|
301 | 306 | */
|
302 | 307 | addFeature: function( feature ) {
|
|
313 | 318 |
|
314 | 319 | // If default configuration (will be checked inside #allow()),
|
315 | 320 | // then add allowed content rules.
|
316 |
| - this.allow( feature.allowedContent ); |
| 321 | + this.allow( feature.allowedContent, feature.name ); |
317 | 322 |
|
318 | 323 | this.addTransformations( feature.contentTransformations );
|
319 | 324 | this.addContentForms( feature.contentForms );
|
|
0 commit comments