upfront-editable
Version:
Friendly contenteditable API
79 lines (71 loc) • 2.22 kB
JavaScript
/**
* Defines all supported event types by Editable.JS and provides default
* implementations for them defined in {{#crossLink "Behavior"}}{{/crossLink}}
*
* @type {Object}
*/
export const log = false
export const logErrors = true
export const editableClass = 'js-editable'
export const editableDisabledClass = 'js-editable-disabled'
export const pastingAttribute = 'data-editable-is-pasting'
export const boldMarkup = {
type: 'tag',
name: 'strong',
attribs: {}
}
export const italicMarkup = {
type: 'tag',
name: 'em',
attribs: {}
}
export const underlineMarkup = {
type: 'tag',
name: 'u',
attribs: {}
}
export const linkMarkup = {
type: 'tag',
name: 'a',
attribs: {}
}
// Rules that are applied when filtering pasted content
export const 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
}