upfront-editable
Version:
Friendly contenteditable API
79 lines (71 loc) • 2.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
/**
* Defines all supported event types by Editable.JS and provides default
* implementations for them defined in {{#crossLink "Behavior"}}{{/crossLink}}
*
* @type {Object}
*/
var log = exports.log = false;
var logErrors = exports.logErrors = true;
var editableClass = exports.editableClass = 'js-editable';
var editableDisabledClass = exports.editableDisabledClass = 'js-editable-disabled';
var pastingAttribute = exports.pastingAttribute = 'data-editable-is-pasting';
var boldMarkup = exports.boldMarkup = {
type: 'tag',
name: 'strong',
attribs: {}
};
var italicMarkup = exports.italicMarkup = {
type: 'tag',
name: 'em',
attribs: {}
};
var underlineMarkup = exports.underlineMarkup = {
type: 'tag',
name: 'u',
attribs: {}
};
var linkMarkup = exports.linkMarkup = {
type: 'tag',
name: 'a',
attribs: {}
// Rules that are applied when filtering pasted content
};var pastedHtmlRules = exports.pastedHtmlRules = {
// Elements and their attributes to keep in pasted text
// Note that elements not explicitly allowed here will not be removed, their
// tags will get stripped but their content will be kept. Use `blacklistedElements`
// to get rid of a whole element (tag+content)
allowedElements: {
'a': {
'href': true,
'rel': true,
'target': true
},
'strong': {},
'em': {},
'br': {}
},
// Elements that have required attributes.
// If these are not present the elements are filtered out.
// Required attributes have to be present in the 'allowed' object
// as well if they should not be filtered out.
requiredAttributes: {
'a': ['href']
},
// Elements that should be transformed into other elements
transformElements: {
'b': 'strong',
'i': 'em'
},
// A list of elements which should be split into paragraphs.
splitIntoBlocks: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'blockquote'],
// A list of HTML block level elements.
blockLevelElements: ['h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'div', 'p', 'pre', 'hr', 'blockquote', 'article', 'figure', 'header', 'footer', 'ul', 'ol', 'li', 'section', 'table', 'video'],
// A list of elements that will get completly removed when pasted. Their tags
// and content (text content and child elements) will get removed.
blacklistedElements: ['style', 'script'],
keepInternalRelativeLinks: false
};