Press n or j to go to the next uncovered block, b, p or k for the previous block.
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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 | 1x 1x 1x 956x 834x 1782x 15x 1x 1x 1x 1x 1x 1x | /**
* @fileoverview Represents a single paragraph in a document.
* @author Dmytro Antonenko <dmitry.antonenko@pubwebkit.com>
*/
import {Content} from './content.js';
import {LeafNode} from './leaf_node.js';
import {NodeType} from './node_type.js';
import {Node} from './node.js';
goog.declareModuleId('pwk.content.Paragraph');
const TagName = goog.require('goog.dom.TagName');
const {NodeOffsetInfo} = goog.requireType('pwk.range.NodeOffsetInfo');
/**
* @extends {LeafNode}
*/
export class Paragraph extends LeafNode {
/**
* @param {!Content} content Paragraph text content.
*/
constructor(content) {
super(content);
}
/**
* Gets component default css class.
* @return {string} Base CSS class for this component.
* @override
*/
getCssClass() {
return Paragraph.CSS_CLASS;
}
/**
* Gets node type.
* @return {!NodeType}
* @override
*/
getNodeType() {
return NodeType.PARAGRAPH;
}
/**
* Splits node. Returns second part of node as a result.
* @param {!NodeOffsetInfo} nodeOffsetInfo
* @return {!Node} Node to render below current node.
* @override
*/
split(nodeOffsetInfo) {
return new Paragraph(this.cut(nodeOffsetInfo.getNodeOffset()));
}
/**
* Gets html representation of the node content in the offset.
* @param {number} startOffset The zero-based offset at which to begin extraction.
* @param {number=} opt_endOffset Optional zero-based offset before which to end extraction.
* @return {string} HTML string
* @override
*/
getOuterHtml(startOffset, opt_endOffset = this.getLength()) {
const element = this.dom_.createElement(TagName.P);
const contentRange = this.getContent().getContentAt(startOffset, opt_endOffset);
element.innerHTML = contentRange.toHtmlString();
this.setNodeStyles_(element);
return element.outerHTML;
}
}
/**
* Node default CSS class.
* @type {string}
* @override
*/
Paragraph.CSS_CLASS = 'pwk-paragraph';
|