MCPcopy
hub / github.com/ether/etherpad / importText

Function importText

src/static/js/ace2_inner.ts:491–517  ·  view source on GitHub ↗
(text, undoable, dontProcess)

Source from the content-addressed store, hash-verified

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);

Callers

nothing calls this directly

Calls 3

inCallStackIfNecessaryFunction · 0.85
setDocTextFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected