UNPKG

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.

37 lines (25 loc) 741 B
import { AnnotationComponent } from '../../ui' class LinkComponent extends AnnotationComponent { didMount(...args) { super.didMount(...args) let node = this.props.node this.context.editorSession.onRender('document', this.rerender, this, { path: [node.id, 'url'] }) } dispose(...args) { super.dispose(...args) this.context.editorSession.off(this) } render($$) { // eslint-disable-line let el = super.render($$) el.tagName = 'a' el.attr('href', this.props.node.url) let titleComps = [this.props.node.url] if (this.props.node.title) { titleComps.push(this.props.node.title) } return el.attr("title", titleComps.join(' | ')) } } export default LinkComponent