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

Function domAndRepSplice

src/static/js/ace2_inner.ts:1419–1452  ·  view source on GitHub ↗
(startLine, deleteCount, newLineStrings)

Source from the content-addressed store, hash-verified

1417
1418 const performDocumentApplyChangeset = (changes, insertsAfterSelection) => {
1419 const domAndRepSplice = (startLine, deleteCount, newLineStrings) => {
1420 const keysToDelete = [];
1421 if (deleteCount > 0) {
1422 let entryToDelete = rep.lines.atIndex(startLine);
1423 for (let i = 0; i < deleteCount; i++) {
1424 keysToDelete.push(entryToDelete.key);
1425 entryToDelete = rep.lines.next(entryToDelete);
1426 }
1427 }
1428
1429 const lineEntries = newLineStrings.map(createDomLineEntry);
1430
1431 doRepLineSplice(startLine, deleteCount, lineEntries);
1432
1433 let nodeToAddAfter;
1434 if (startLine > 0) {
1435 nodeToAddAfter = getCleanNodeByKey(rep.lines.atIndex(startLine - 1).key);
1436 } else { nodeToAddAfter = null; }
1437
1438 insertDomLines(nodeToAddAfter, lineEntries.map((entry) => entry.domInfo));
1439
1440 for (const k of keysToDelete) {
1441 const n = targetDoc.getElementById(k);
1442 n.parentNode.removeChild(n);
1443 }
1444
1445 if (
1446 (rep.selStart &&
1447 rep.selStart[0] >= startLine &&
1448 rep.selStart[0] <= startLine + deleteCount) ||
1449 (rep.selEnd && rep.selEnd[0] >= startLine && rep.selEnd[0] <= startLine + deleteCount)) {
1450 currentCallStack.selectionAffected = true;
1451 }
1452 };
1453
1454 doRepApplyChangeset(changes, insertsAfterSelection);
1455

Callers 1

Calls 8

doRepLineSpliceFunction · 0.85
getCleanNodeByKeyFunction · 0.85
insertDomLinesFunction · 0.85
atIndexMethod · 0.80
pushMethod · 0.80
mapMethod · 0.80
removeChildMethod · 0.80
nextMethod · 0.45

Tested by

no test coverage detected