mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-04-21 16:06:16 -04:00
ace2_inner: Factor out duplicate line height application
This commit is contained in:
parent
1b890e3d4d
commit
b238d9610a
1 changed files with 14 additions and 21 deletions
|
@ -3589,9 +3589,21 @@ function Ace2Inner(editorInfo, cssManagers) {
|
||||||
|
|
||||||
let newNumLines = rep.lines.length();
|
let newNumLines = rep.lines.length();
|
||||||
if (newNumLines < 1) newNumLines = 1;
|
if (newNumLines < 1) newNumLines = 1;
|
||||||
let sidebarLine = sideDivInner.firstChild;
|
|
||||||
|
|
||||||
// Apply height to existing sidediv lines
|
if (newNumLines !== sideDivInner.children.length) {
|
||||||
|
while (sideDivInner.children.length < newNumLines) {
|
||||||
|
const div = outerDoc.createElement('DIV');
|
||||||
|
sideDivInner.appendChild(div);
|
||||||
|
$(div).append($(`<span class='line-number'>${sideDivInner.children.length}</span>`));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove extra lines
|
||||||
|
while (sideDivInner.children.length > newNumLines) {
|
||||||
|
sideDivInner.removeChild(sideDivInner.lastChild);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let sidebarLine = sideDivInner.firstChild;
|
||||||
currentLine = 0;
|
currentLine = 0;
|
||||||
while (sidebarLine && currentLine <= sideDivInner.children.length) {
|
while (sidebarLine && currentLine <= sideDivInner.children.length) {
|
||||||
if (lineOffsets[currentLine] != null) {
|
if (lineOffsets[currentLine] != null) {
|
||||||
|
@ -3601,25 +3613,6 @@ function Ace2Inner(editorInfo, cssManagers) {
|
||||||
sidebarLine = sidebarLine.nextSibling;
|
sidebarLine = sidebarLine.nextSibling;
|
||||||
currentLine++;
|
currentLine++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newNumLines !== sideDivInner.children.length) {
|
|
||||||
// Create missing line and apply height
|
|
||||||
while (sideDivInner.children.length < newNumLines) {
|
|
||||||
const div = outerDoc.createElement('DIV');
|
|
||||||
sideDivInner.appendChild(div);
|
|
||||||
if (lineOffsets[currentLine]) {
|
|
||||||
div.style.height = `${lineOffsets[currentLine]}px`;
|
|
||||||
div.style.lineHeight = `${lineHeights[currentLine]}px`;
|
|
||||||
}
|
|
||||||
$(div).append($(`<span class='line-number'>${sideDivInner.children.length}</span>`));
|
|
||||||
currentLine++;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove extra lines
|
|
||||||
while (sideDivInner.children.length > newNumLines) {
|
|
||||||
sideDivInner.removeChild(sideDivInner.lastChild);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue