createStandardNodeValidator function

NodeValidatorBuilder createStandardNodeValidator(
  1. {bool svg = true,
  2. bool allowSvgForeignObject = false}
)

Implementation

NodeValidatorBuilder createStandardNodeValidator(
    {bool svg = true, bool allowSvgForeignObject = false}) {
  var validator = NodeValidatorBuilder()
    ..allowTextElements()
    ..allowHtml5()
    ..allowElement('a', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('nav', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('div', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('li', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('ul', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('ol', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('span', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('img', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('textarea', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('input', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('label', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('button', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('iframe', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('svg', attributes: _htmlElementsAllowedAttrs)
    ..allowElement('video', attributes: [
      ..._htmlElementsAllowedAttrs,
      'autoplay',
      'controls',
      'muted'
    ])
    ..allowElement('source', attributes: [..._htmlElementsAllowedAttrs, 'type'])
    ..allowImages(_anyUriPolicy)
    ..allowNavigation(_anyUriPolicy)
    ..allowInlineStyles();

  if (svg) {
    if (allowSvgForeignObject) {
      validator.add(_FullSvgNodeValidator());
    } else {
      validator.allowSvg();
    }
  }

  return validator;
}