(text, undoable, dontProcess)
| 489 | const enforceEditability = () => setEditable(isEditable); |
| 490 | |
| 491 | const importText = (text, undoable, dontProcess) => { |
| 492 | let lines; |
| 493 | if (dontProcess) { |
| 494 | if (text.charAt(text.length - 1) !== '\n') { |
| 495 | throw new Error('new raw text must end with newline'); |
| 496 | } |
| 497 | if (/[\r\t]/.exec(text)) { |
| 498 | throw new Error('new raw text must not contain CR or tab'); |
| 499 | } |
| 500 | lines = text.substring(0, text.length - 1).split('\n'); |
| 501 | } else { |
| 502 | lines = text.split('\n').map(textify); |
| 503 | } |
| 504 | let newText = '\n'; |
| 505 | if (lines.length > 0) { |
| 506 | newText = `${lines.join('\n')}\n`; |
| 507 | } |
| 508 | |
| 509 | |
| 510 | inCallStackIfNecessary(`importText${undoable ? 'Undoable' : ''}`, () => { |
| 511 | setDocText(newText); |
| 512 | }); |
| 513 | |
| 514 | if (dontProcess && rep.alltext !== text) { |
| 515 | throw new Error('mismatch error setting raw text in importText'); |
| 516 | } |
| 517 | }; |
| 518 | |
| 519 | const importAText = (atext, apoolJsonObj, undoable) => { |
| 520 | atext = cloneAText(atext); |
nothing calls this directly
no test coverage detected