Skip to content

Commit 127fee5

Browse files
committed
Allow multiple htmlsupport rules
1 parent a8ea170 commit 127fee5

2 files changed

Lines changed: 17 additions & 14 deletions

File tree

frontend/src/modules/scaffold/backboneFormsOverrides.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,14 +91,11 @@ define([
9191
enterMode: CKEDITOR[Origin.constants.ckEditorEnterMode],
9292
entities: false,
9393
htmlSupport: {
94-
allow: [
95-
{
96-
"name": new RegExp(Origin.constants.htmlSupportAllowed.name),
97-
"attributes": Origin.constants.htmlSupportAllowed.attributes,
98-
"classes": Origin.constants.htmlSupportAllowed.classes,
99-
"styles": Origin.constants.htmlSupportAllowed.styles
100-
}
101-
]
94+
// Convert all allow/disallow values to regexp, as config is json only
95+
allow: ((Origin.constants.ckEditorHtmlSupport && Origin.constants.ckEditorHtmlSupport.allow) || [])
96+
.map(obj => Object.fromEntries(Object.entries(obj).map(([name, value]) => ([name, new RegExp(value)])))),
97+
disallow: ((Origin.constants.ckEditorHtmlSupport && Origin.constants.ckEditorHtmlSupport.disallow) || [])
98+
.map(obj => Object.fromEntries(Object.entries(obj).map(([name, value]) => ([name, new RegExp(value)]))))
10299
},
103100
on: {
104101
change: function() {

lib/configuration.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var ALLOWED_CLIENT_SIDE_KEYS = [
3232
'useSmtp',
3333
'isProduction',
3434
'maxLoginAttempts',
35-
'htmlSupportAllowed',
35+
'ckEditorHtmlSupport',
3636
'ckEditorEnterMode',
3737
'maxFileUploadSize',
3838
'supportLink',
@@ -81,11 +81,17 @@ function Configuration() {
8181
this.conf = {
8282
root: this.serverRoot,
8383
maxLoginAttempts: 3,
84-
htmlSupportAllowed: {
85-
name: ".*",
86-
attributes: true,
87-
classes: true,
88-
styles: true
84+
ckEditorHtmlSupport: {
85+
allow: [{
86+
name: "^(blockquote|ul|ol|span)$"
87+
},{
88+
name: ".*",
89+
classes: ".*",
90+
styles: ".*"
91+
},{
92+
name: "^a$",
93+
attributes: "^target$"
94+
}]
8995
},
9096
maxFileUploadSize: '200MB',
9197
ckEditorEnterMode: 'ENTER_P'

0 commit comments

Comments
 (0)