* * Creates a new `Document`. If `text` is included, the `Document` contains those strings; otherwise, it's empty. * @param {String | String[]} textOrLines text The starting text
(textOrLines)
| 23 | * @param {String | String[]} textOrLines text The starting text |
| 24 | **/ |
| 25 | constructor(textOrLines) { |
| 26 | /**@type {string[]}*/ |
| 27 | this.$lines = [""]; |
| 28 | |
| 29 | // There has to be one line at least in the document. If you pass an empty |
| 30 | // string to the insert function, nothing will happen. Workaround. |
| 31 | if (textOrLines.length === 0) { |
| 32 | this.$lines = [""]; |
| 33 | } else if (Array.isArray(textOrLines)) { |
| 34 | this.insertMergedLines({row: 0, column: 0}, textOrLines); |
| 35 | } else { |
| 36 | this.insert({row: 0, column:0}, textOrLines); |
| 37 | } |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Replaces all the lines in the current `Document` with the value of `text`. |
nothing calls this directly
no test coverage detected