Krang::BulkEdit::Xinha::Config - Class to configure Xinha-based bulk editing
Krang::BulkEdit::Xinha::Config - Class to configure for Xinha-based bulk editing
This module represents the default configuration of Xinha-based bulk editing as implemented in pkg('BulkEdit::Xinha').
You may modify this configuration by subclassing this module.
The default configuration is
[
"bold", "italic", "underline", "separator",
"insertorderedlist", "insertunorderedlist", "separator",
"inserthorizontalrule", "createlink", "separator",
"subscript", "superscript", "separator",
"copy", "cut", "paste", "separator",
"htmlmode", "separator",
"undo", "redo"
]
If 'formatblock' is true
"formatblock", "space",
will be prepended.
The default is to disallow all HTMLElements and to disallow all attributes of allowed HTMLElements (no typo!).
Some HTMLElements are allowed:
The allow list contains:
@block_elements = ( qw(p h1 h2 h3 h4 h5 h6 ol ul hr li) );
and
@inline_elements = ( qw(a br em strong strike u sub sup) );
Attributes of these allowed elements are stripped out because of the default rule to disallow all attributes.
If you want to allow certain attributes on certain HTMLElements, you'll have to use HTML::Scrubber's rules configuration key. The default is to allow certain attributes on HTMLAnchorElement and HTMLImageElement:
rules => [
a => {
'*' => 0, # deny all attribs on A tags
href => 1, # allow some attribs
name => 1,
title => 1,
target => 1
},
img => {
'*' => 0, # deny all attribs on IMG tags
src => 1, # allow some attribs
alt => 1,
title => 1,
width => 1,
height => 1,
},
]
Note that by the time the incoming HTML is passed to
html_scrubber() the browser-specific markup (e.g. Gecko's BOLD tag)
has already been normalized (e.g. to STRONG). So there's no need to
include B, EM or SPAN in the list of inline elements. See
Krang::Markup, Krang::Markup::IE, Krang::Markup::Gecko and
Krang::Markup::WebKit.
Be careful with your legacy data. It may contain, say,
HTMLTableElements coded into some textarea 'paragraph' element. If
you pass this through the default configuration of html_scrubber(),
you will see the table in Xinha, but when done bulk editing,
html_scrubber() will happily strip away the TABLE tags, leaving you
with the bare text content of all table cells concatenated without
whitespace!
Know Your Data!
Also, nothing prevents users from typing a HTML table into a 'paragraph' textarea. They will be surprised to see the TABLE tags gone when passing this textarea's data through Xinha's bulk edit.
Why are tables disallowed? Because the available Xinha ignores a decent way to handle tables.
Consider that the configuration or Xinha's toolbar and the set of allowed HTMLElements are somewhat interdependent. No automagic is provided to keep them streamlined. E.g., if you configure Xinha's toolbar to not show the button for 'Ordered List', the 'ol' tag should be disallowed - although users might of course paste ordered lists in...