ingenta-lens
Version:
A novel way of seeing content.
73 lines (57 loc) • 1.43 kB
JavaScript
;
var _ = require("underscore");
var Document = require('../../../substance/document');
var DocumentNode = Document.Node;
var Composite = Document.Composite;
var Paragraph = function(node, document) {
Composite.call(this, node, document);
};
Paragraph.type = {
"id": "paragraph",
"parent": "content",
"properties": {
"children": ["array", "content"]
}
};
// This is used for the auto-generated docs
// -----------------
//
Paragraph.description = {
"name": "Paragraph",
"remarks": [
"A Paragraph can have inline elements such as images."
],
"properties": {
"children": "An array of content node references",
}
};
// Example
// -------
//
Paragraph.example = {
"type": "paragraph",
"id": "paragraph_1",
"children ": [
"text_1",
"image_1",
"text_2"
]
};
Paragraph.Prototype = function() {
this.getLength = function() {
return this.properties.children.length;
};
this.getChildrenIds = function() {
return _.clone(this.properties.children);
};
this.getChildren = function() {
return _.map(this.properties.children, function(id) {
return this.document.get(id);
}, this);
};
};
Paragraph.Prototype.prototype = Composite.prototype;
Paragraph.prototype = new Paragraph.Prototype();
Paragraph.prototype.constructor = Paragraph;
DocumentNode.defineProperties(Paragraph.prototype, ["children"]);
module.exports = Paragraph;