mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
ace2_inner: Consistently use outerWin
and outerDoc
This commit is contained in:
parent
98c1ba5808
commit
11c86e677a
1 changed files with 9 additions and 19 deletions
|
@ -3289,7 +3289,7 @@ function Ace2Inner(editorInfo, cssManagers) {
|
||||||
$(document).on('keyup', handleKeyEvent);
|
$(document).on('keyup', handleKeyEvent);
|
||||||
$(document).on('click', handleClick);
|
$(document).on('click', handleClick);
|
||||||
// dropdowns on edit bar need to be closed on clicks on both pad inner and pad outer
|
// dropdowns on edit bar need to be closed on clicks on both pad inner and pad outer
|
||||||
$(outerWin.document).on('click', hideEditBarDropdowns);
|
$(outerDoc).on('click', hideEditBarDropdowns);
|
||||||
|
|
||||||
// If non-nullish, pasting on a link should be suppressed.
|
// If non-nullish, pasting on a link should be suppressed.
|
||||||
let suppressPasteOnLink = null;
|
let suppressPasteOnLink = null;
|
||||||
|
@ -3414,11 +3414,7 @@ function Ace2Inner(editorInfo, cssManagers) {
|
||||||
};
|
};
|
||||||
|
|
||||||
const getInnerHeight = () => {
|
const getInnerHeight = () => {
|
||||||
const win = outerWin;
|
const h = browser.opera ? outerWin.innerHeight : outerDoc.documentElement.clientHeight;
|
||||||
const odoc = win.document;
|
|
||||||
let h;
|
|
||||||
if (browser.opera) h = win.innerHeight;
|
|
||||||
else h = odoc.documentElement.clientHeight;
|
|
||||||
if (h) return h;
|
if (h) return h;
|
||||||
|
|
||||||
// deal with case where iframe is hidden, hope that
|
// deal with case where iframe is hidden, hope that
|
||||||
|
@ -3426,20 +3422,15 @@ function Ace2Inner(editorInfo, cssManagers) {
|
||||||
return Number(editorInfo.frame.parentNode.style.height.replace(/[^0-9]/g, '') || 0);
|
return Number(editorInfo.frame.parentNode.style.height.replace(/[^0-9]/g, '') || 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getInnerWidth = () => {
|
const getInnerWidth = () => outerDoc.documentElement.clientWidth;
|
||||||
const win = outerWin;
|
|
||||||
const odoc = win.document;
|
|
||||||
return odoc.documentElement.clientWidth;
|
|
||||||
};
|
|
||||||
|
|
||||||
const scrollXHorizontallyIntoView = (pixelX) => {
|
const scrollXHorizontallyIntoView = (pixelX) => {
|
||||||
const win = outerWin;
|
const distInsideLeft = pixelX - outerWin.scrollX;
|
||||||
const distInsideLeft = pixelX - win.scrollX;
|
const distInsideRight = outerWin.scrollX + getInnerWidth() - pixelX;
|
||||||
const distInsideRight = win.scrollX + getInnerWidth() - pixelX;
|
|
||||||
if (distInsideLeft < 0) {
|
if (distInsideLeft < 0) {
|
||||||
win.scrollBy(distInsideLeft, 0);
|
outerWin.scrollBy(distInsideLeft, 0);
|
||||||
} else if (distInsideRight < 0) {
|
} else if (distInsideRight < 0) {
|
||||||
win.scrollBy(-distInsideRight + 1, 0);
|
outerWin.scrollBy(-distInsideRight + 1, 0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -3615,13 +3606,12 @@ function Ace2Inner(editorInfo, cssManagers) {
|
||||||
|
|
||||||
if (newNumLines !== lineNumbersShown) {
|
if (newNumLines !== lineNumbersShown) {
|
||||||
const container = sideDivInner;
|
const container = sideDivInner;
|
||||||
const odoc = outerWin.document;
|
const fragment = outerDoc.createDocumentFragment();
|
||||||
const fragment = odoc.createDocumentFragment();
|
|
||||||
|
|
||||||
// Create missing line and apply height
|
// Create missing line and apply height
|
||||||
while (lineNumbersShown < newNumLines) {
|
while (lineNumbersShown < newNumLines) {
|
||||||
lineNumbersShown++;
|
lineNumbersShown++;
|
||||||
const div = odoc.createElement('DIV');
|
const div = outerDoc.createElement('DIV');
|
||||||
if (lineOffsets[currentLine]) {
|
if (lineOffsets[currentLine]) {
|
||||||
div.style.height = `${lineOffsets[currentLine]}px`;
|
div.style.height = `${lineOffsets[currentLine]}px`;
|
||||||
div.style.lineHeight = `${lineHeights[currentLine]}px`;
|
div.style.lineHeight = `${lineHeights[currentLine]}px`;
|
||||||
|
|
Loading…
Reference in a new issue