md-editor-v3 4.17.2 → 4.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1334,7 +1334,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1334
1334
  let pLock = 0;
1335
1335
  let cLock = 0;
1336
1336
  const pEleHandler = () => {
1337
- var _a, _b;
1337
+ var _a, _b, _c;
1338
1338
  if (cLock !== 0) {
1339
1339
  return false;
1340
1340
  }
@@ -1354,7 +1354,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1354
1354
  const cMaxScrollLength = cEle.scrollHeight - cEle.clientHeight;
1355
1355
  let startTop = getTopByLine(blockData.start);
1356
1356
  let endBottom = getBottomByLine(blockData.end);
1357
- let startEleOffetTop = startEle.offsetTop - getComputedStyleNum(startEle, "margin-top");
1357
+ let startEleOffetTop = startEle.offsetTop;
1358
1358
  let blockHeight = endEle.offsetTop - startEleOffetTop;
1359
1359
  if (startTop === 0) {
1360
1360
  startEleOffetTop = 0;
@@ -1366,13 +1366,16 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1366
1366
  blockHeight = endEle.offsetTop;
1367
1367
  }
1368
1368
  }
1369
- scale = (scrollDOM.scrollTop - startTop + getComputedStyleNum(view2.contentDOM, "padding-bottom")) / (endBottom - startTop);
1370
- if (startTop >= 0 && (endBottom >= pMaxScrollLength || endEle.offsetTop + endEle.clientHeight > cMaxScrollLength)) {
1369
+ scale = (scrollDOM.scrollTop - startTop) / (endBottom - startTop);
1370
+ const endElePos = endEle == ((_c = cEle.lastElementChild) == null ? void 0 : _c.lastElementChild) ? endEle.offsetTop + endEle.clientHeight : endEle.offsetTop;
1371
+ if (endBottom >= pMaxScrollLength || endElePos > cMaxScrollLength) {
1371
1372
  const lineNumer = getLineNumber(pMaxScrollLength, cMaxScrollLength);
1372
1373
  startTop = getTopByLine(lineNumer);
1373
1374
  scale = (scrollDOM.scrollTop - startTop) / (pMaxScrollLength - startTop);
1374
1375
  const _startEle = document.querySelector(`[data-line="${lineNumer}"]`);
1375
- startEleOffetTop = _startEle ? _startEle.offsetTop - getComputedStyleNum(_startEle, "margin-top") : startEleOffetTop;
1376
+ if (startTop > 0 && _startEle) {
1377
+ startEleOffetTop = _startEle.offsetTop;
1378
+ }
1376
1379
  blockHeight = cMaxScrollLength - startEleOffetTop + getComputedStyleNum(cEle, "padding-top");
1377
1380
  }
1378
1381
  const scrollToTop = startEleOffetTop - cElePaddingTop + blockHeight * scale;
@@ -1333,7 +1333,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1333
1333
  let pLock = 0;
1334
1334
  let cLock = 0;
1335
1335
  const pEleHandler = () => {
1336
- var _a, _b;
1336
+ var _a, _b, _c;
1337
1337
  if (cLock !== 0) {
1338
1338
  return false;
1339
1339
  }
@@ -1353,7 +1353,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1353
1353
  const cMaxScrollLength = cEle.scrollHeight - cEle.clientHeight;
1354
1354
  let startTop = getTopByLine(blockData.start);
1355
1355
  let endBottom = getBottomByLine(blockData.end);
1356
- let startEleOffetTop = startEle.offsetTop - getComputedStyleNum(startEle, "margin-top");
1356
+ let startEleOffetTop = startEle.offsetTop;
1357
1357
  let blockHeight = endEle.offsetTop - startEleOffetTop;
1358
1358
  if (startTop === 0) {
1359
1359
  startEleOffetTop = 0;
@@ -1365,13 +1365,16 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1365
1365
  blockHeight = endEle.offsetTop;
1366
1366
  }
1367
1367
  }
1368
- scale = (scrollDOM.scrollTop - startTop + getComputedStyleNum(view.contentDOM, "padding-bottom")) / (endBottom - startTop);
1369
- if (startTop >= 0 && (endBottom >= pMaxScrollLength || endEle.offsetTop + endEle.clientHeight > cMaxScrollLength)) {
1368
+ scale = (scrollDOM.scrollTop - startTop) / (endBottom - startTop);
1369
+ const endElePos = endEle == ((_c = cEle.lastElementChild) == null ? void 0 : _c.lastElementChild) ? endEle.offsetTop + endEle.clientHeight : endEle.offsetTop;
1370
+ if (endBottom >= pMaxScrollLength || endElePos > cMaxScrollLength) {
1370
1371
  const lineNumer = getLineNumber(pMaxScrollLength, cMaxScrollLength);
1371
1372
  startTop = getTopByLine(lineNumer);
1372
1373
  scale = (scrollDOM.scrollTop - startTop) / (pMaxScrollLength - startTop);
1373
1374
  const _startEle = document.querySelector(`[data-line="${lineNumer}"]`);
1374
- startEleOffetTop = _startEle ? _startEle.offsetTop - getComputedStyleNum(_startEle, "margin-top") : startEleOffetTop;
1375
+ if (startTop > 0 && _startEle) {
1376
+ startEleOffetTop = _startEle.offsetTop;
1377
+ }
1375
1378
  blockHeight = cMaxScrollLength - startEleOffetTop + getComputedStyleNum(cEle, "padding-top");
1376
1379
  }
1377
1380
  const scrollToTop = startEleOffetTop - cElePaddingTop + blockHeight * scale;