Revert "Issue #2656278 by miteshmap, walangitan, empesan, ejb503, manmohandream, vaidehi bapat, gadaniels72, luca_cracco, swentel, malaimo29001, nileema.jadhav, sidharthap: Convert "Limit allowed HTML tags" input field to a textarea"
This reverts commit 537660254b
.
8.1.x
parent
537660254b
commit
1b5aefe848
|
@ -98,9 +98,6 @@
|
|||
that.$allowedHTMLFormItem.on('change.updateUserTags', function () {
|
||||
that.userTags = _.difference(that._parseSetting(this.value), that.autoTags);
|
||||
});
|
||||
}).on('keyup', function (e) {
|
||||
if (e.keyCode != 13) return;
|
||||
$(this).val($(this).val().replace(/\n/g, ""));
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -241,38 +238,36 @@
|
|||
var allowedTags = setting.match(/(<[^>]+>)/g);
|
||||
var sandbox = document.createElement('div');
|
||||
var rules = {};
|
||||
if (allowedTags) {
|
||||
for (var t = 0; t < allowedTags.length; t++) {
|
||||
// Let the browser do the parsing work for us.
|
||||
sandbox.innerHTML = allowedTags[t];
|
||||
node = sandbox.firstChild;
|
||||
tag = (node !== null) ? node.tagName.toLowerCase() : null;
|
||||
for (var t = 0; t < allowedTags.length; t++) {
|
||||
// Let the browser do the parsing work for us.
|
||||
sandbox.innerHTML = allowedTags[t];
|
||||
node = sandbox.firstChild;
|
||||
tag = node.tagName.toLowerCase();
|
||||
|
||||
// Build the Drupal.FilterHtmlRule object.
|
||||
rule = new Drupal.FilterHTMLRule();
|
||||
// We create one rule per allowed tag, so always one tag.
|
||||
rule.restrictedTags.tags = [tag];
|
||||
// Add the attribute restrictions.
|
||||
attributes = (node !== null) ? node.attributes : '';
|
||||
for (var i = 0; i < attributes.length; i++) {
|
||||
attribute = attributes.item(i);
|
||||
var attributeName = attribute.nodeName;
|
||||
// @todo Drupal.FilterHtmlRule does not allow for generic attribute
|
||||
// value restrictions, only for the "class" and "style" attribute's
|
||||
// values. The filter_html filter always disallows the "style"
|
||||
// attribute, so we only need to support "class" attribute value
|
||||
// restrictions. Fix once https://www.drupal.org/node/2567801 lands.
|
||||
if (attributeName === 'class') {
|
||||
var attributeValue = attribute.textContent;
|
||||
rule.restrictedTags.allowed.classes = attributeValue.split(' ');
|
||||
}
|
||||
else {
|
||||
rule.restrictedTags.allowed.attributes.push(attributeName);
|
||||
}
|
||||
// Build the Drupal.FilterHtmlRule object.
|
||||
rule = new Drupal.FilterHTMLRule();
|
||||
// We create one rule per allowed tag, so always one tag.
|
||||
rule.restrictedTags.tags = [tag];
|
||||
// Add the attribute restrictions.
|
||||
attributes = node.attributes;
|
||||
for (var i = 0; i < attributes.length; i++) {
|
||||
attribute = attributes.item(i);
|
||||
var attributeName = attribute.nodeName;
|
||||
// @todo Drupal.FilterHtmlRule does not allow for generic attribute
|
||||
// value restrictions, only for the "class" and "style" attribute's
|
||||
// values. The filter_html filter always disallows the "style"
|
||||
// attribute, so we only need to support "class" attribute value
|
||||
// restrictions. Fix once https://www.drupal.org/node/2567801 lands.
|
||||
if (attributeName === 'class') {
|
||||
var attributeValue = attribute.textContent;
|
||||
rule.restrictedTags.allowed.classes = attributeValue.split(' ');
|
||||
}
|
||||
else {
|
||||
rule.restrictedTags.allowed.attributes.push(attributeName);
|
||||
}
|
||||
|
||||
rules[tag] = rule;
|
||||
}
|
||||
|
||||
rules[tag] = rule;
|
||||
}
|
||||
return rules;
|
||||
},
|
||||
|
|
|
@ -46,10 +46,12 @@ class FilterHtml extends FilterBase {
|
|||
*/
|
||||
public function settingsForm(array $form, FormStateInterface $form_state) {
|
||||
$form['allowed_html'] = array(
|
||||
'#type' => 'textarea',
|
||||
'#type' => 'textfield',
|
||||
'#title' => $this->t('Allowed HTML tags'),
|
||||
'#default_value' => $this->settings['allowed_html'],
|
||||
'#maxlength' => 2048,
|
||||
'#description' => $this->t('A list of HTML tags that can be used. By default only the <em>lang</em> and <em>dir</em> attributes are allowed for all HTML tags. Each HTML tag may have attributes which are treated as allowed attribute names for that HTML tag. Each attribute may allow all values, or only allow specific values. Attribute names or values may be written as a prefix and wildcard like <em>jump-*</em>. JavaScript event attributes, JavaScript URLs, and CSS are always stripped.'),
|
||||
'#size' => 250,
|
||||
'#attached' => array(
|
||||
'library' => array(
|
||||
'filter/drupal.filter.filter_html.admin',
|
||||
|
|
Loading…
Reference in New Issue