substance
Version:
Substance is a JavaScript library for web-based content editing. It provides building blocks for realizing custom text editors and web-based publishing systems.
21 lines (17 loc) • 424 B
JavaScript
export default {
type: 'image',
tagName: 'img',
import: function(el, node, converter) {
let imageFile = converter.getDocument().create({
id: 'file-'+node.id,
type: 'file',
fileType: 'image',
url: el.attr('src')
})
node.imageFile = imageFile.id
},
export: function(node, el) {
let imageFile = node.document.get(node.imageFile)
el.attr('src', imageFile.getUrl())
}
}