all files / model/ TextNode.js

100% Statements 7/7
100% Branches 0/0
100% Functions 5/5
100% Lines 7/7
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42                      1510×       1536×       214×       16×       500×                        
import DocumentNode from './DocumentNode'
 
/**
  A base class for all text-ish nodes, such as Paragraphs, Headings,
  Prerendered, etc.
*/
class TextNode extends DocumentNode {
 
  getTextPath() {
    // TODO: deprecate this
    // console.warn('DEPRECATED: use node.getPath()')
    return this.getPath()
  }
 
  getPath() {
    return [this.id, 'content']
  }
 
  getText() {
    return this.content
  }
 
  isEmpty() {
    return !this.content
  }
 
  getLength() {
    return this.content.length
  }
 
}
 
TextNode.isText = true
 
TextNode.schema = {
  type: "text",
  content: "text",
  direction: { type: "string", optional: true }
}
 
export default TextNode