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