1 | var __extends = (this && this.__extends) || (function () {
|
2 | var extendStatics = function (d, b) {
|
3 | extendStatics = Object.setPrototypeOf ||
|
4 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
5 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
|
6 | return extendStatics(d, b);
|
7 | };
|
8 | return function (d, b) {
|
9 | extendStatics(d, b);
|
10 | function __() { this.constructor = d; }
|
11 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
12 | };
|
13 | })();
|
14 | import { DocNodeKind, DocNode } from './DocNode';
|
15 | import { DocExcerpt, ExcerptKind } from './DocExcerpt';
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 | var DocPlainText = (function (_super) {
|
25 | __extends(DocPlainText, _super);
|
26 | |
27 |
|
28 |
|
29 |
|
30 | function DocPlainText(parameters) {
|
31 | var _this = _super.call(this, parameters) || this;
|
32 | if (DocNode.isParsedParameters(parameters)) {
|
33 | _this._textExcerpt = new DocExcerpt({
|
34 | configuration: _this.configuration,
|
35 | excerptKind: ExcerptKind.PlainText,
|
36 | content: parameters.textExcerpt
|
37 | });
|
38 | }
|
39 | else {
|
40 | if (DocPlainText._newlineCharacterRegExp.test(parameters.text)) {
|
41 |
|
42 | throw new Error('The DocPlainText content must not contain newline characters');
|
43 | }
|
44 | _this._text = parameters.text;
|
45 | }
|
46 | return _this;
|
47 | }
|
48 | Object.defineProperty(DocPlainText.prototype, "kind", {
|
49 |
|
50 | get: function () {
|
51 | return DocNodeKind.PlainText;
|
52 | },
|
53 | enumerable: false,
|
54 | configurable: true
|
55 | });
|
56 | Object.defineProperty(DocPlainText.prototype, "text", {
|
57 | |
58 |
|
59 |
|
60 | get: function () {
|
61 | if (this._text === undefined) {
|
62 | this._text = this._textExcerpt.content.toString();
|
63 | }
|
64 | return this._text;
|
65 | },
|
66 | enumerable: false,
|
67 | configurable: true
|
68 | });
|
69 | Object.defineProperty(DocPlainText.prototype, "textExcerpt", {
|
70 | get: function () {
|
71 | if (this._textExcerpt) {
|
72 | return this._textExcerpt.content;
|
73 | }
|
74 | else {
|
75 | return undefined;
|
76 | }
|
77 | },
|
78 | enumerable: false,
|
79 | configurable: true
|
80 | });
|
81 |
|
82 | DocPlainText.prototype.onGetChildNodes = function () {
|
83 | return [this._textExcerpt];
|
84 | };
|
85 |
|
86 |
|
87 | DocPlainText._newlineCharacterRegExp = /[\n]/;
|
88 | return DocPlainText;
|
89 | }(DocNode));
|
90 | export { DocPlainText };
|
91 |
|
\ | No newline at end of file |