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 system. It is developed to power our online editing platform [Substance](http://substance.io).

55 lines (46 loc) 1.21 kB
import forEach from '../util/forEach' import DocumentNode from './DocumentNode' import AnnotationMixin from './AnnotationMixin' /* Describes an annotation sticking on a container that can span over multiple nodes. @class @example ```js { "id": "subject_reference_1", "type": "subject_reference", "containerPath": ["body", "content"], "start": { "path": ["text_2", "content"], "offset": 100, }, "end": { "path": ["text_4", "content"], "offset": 40 } } ``` */ export default class ContainerAnnotation extends AnnotationMixin(DocumentNode) { setHighlighted (highlighted, scope) { if (this.highlighted !== highlighted) { this.highlighted = highlighted this.highlightedScope = scope this.emit('highlighted', highlighted, scope) forEach(this.fragments, function (frag) { frag.emit('highlighted', highlighted, scope) }) } } static isAnnotation () { return true } static isContainerAnnotation () { return true } define () { return { type: '@container-annotation', containerPath: { type: ['array', 'id'] }, start: 'coordinate', end: 'coordinate' } } }