md-editor-v3 4.17.1 → 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.
@@ -1366,12 +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
- startEleOffetTop = ((_c = document.querySelector(`[data-line="${lineNumer}"]`)) == null ? void 0 : _c.offsetTop) || startEleOffetTop;
1375
+ const _startEle = document.querySelector(`[data-line="${lineNumer}"]`);
1376
+ if (startTop > 0 && _startEle) {
1377
+ startEleOffetTop = _startEle.offsetTop;
1378
+ }
1375
1379
  blockHeight = cMaxScrollLength - startEleOffetTop + getComputedStyleNum(cEle, "padding-top");
1376
1380
  }
1377
1381
  const scrollToTop = startEleOffetTop - cElePaddingTop + blockHeight * scale;
@@ -1380,7 +1384,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1380
1384
  });
1381
1385
  };
1382
1386
  const cEleHandler = () => {
1383
- var _a, _b, _c, _d, _e, _f, _g;
1387
+ var _a, _b, _c, _d, _e, _f;
1384
1388
  if (pLock !== 0) {
1385
1389
  return;
1386
1390
  }
@@ -1436,7 +1440,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1436
1440
  }
1437
1441
  }
1438
1442
  }
1439
- let eleStartOffsetTop = realEleStart === ((_e = cEle.firstElementChild) == null ? void 0 : _e.firstElementChild) ? 0 : realEleStart.offsetTop;
1443
+ let eleStartOffsetTop = realEleStart === ((_e = cEle.firstElementChild) == null ? void 0 : _e.firstElementChild) ? 0 : realEleStart.offsetTop - getComputedStyleNum(realEleStart, "margin-top");
1440
1444
  let eleEndOffsetTop = realEleEnd.offsetTop;
1441
1445
  let scale = 0;
1442
1446
  const { start, end } = blockMap[Number(realEleStart.dataset.line || 0)];
@@ -1447,11 +1451,12 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1447
1451
  let blockHeight = 0;
1448
1452
  if (endLineScrollTop > pMaxScrollLength || realEleEnd.offsetTop + realEleEnd.offsetHeight > cMaxScrollLength) {
1449
1453
  const lineNumer = getLineNumber(pMaxScrollLength, cMaxScrollLength);
1450
- eleStartOffsetTop = ((_f = document.querySelector(`[data-line="${lineNumer}"]`)) == null ? void 0 : _f.offsetTop) || eleStartOffsetTop;
1454
+ const _startEle = document.querySelector(`[data-line="${lineNumer}"]`);
1455
+ eleStartOffsetTop = _startEle ? _startEle.offsetTop - getComputedStyleNum(_startEle, "margin-top") : eleStartOffsetTop;
1451
1456
  firstLineScrollTop = getTopByLine(lineNumer);
1452
1457
  scale = (cScrollTop - eleStartOffsetTop) / (cMaxScrollLength - eleStartOffsetTop);
1453
1458
  blockHeight = pMaxScrollLength - firstLineScrollTop;
1454
- } else if (realEleStart === ((_g = cEle.firstElementChild) == null ? void 0 : _g.firstElementChild)) {
1459
+ } else if (realEleStart === ((_f = cEle.firstElementChild) == null ? void 0 : _f.firstElementChild)) {
1455
1460
  if (realEleStart === realEleEnd) {
1456
1461
  eleEndOffsetTop = realEleEnd.offsetTop + realEleEnd.offsetHeight + +getComputedStyle(realEleEnd).marginBottom.replace("px", "");
1457
1462
  blockHeight = endLineScrollTop;
@@ -1470,7 +1475,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1470
1475
  cLock--;
1471
1476
  });
1472
1477
  };
1473
- const scrollHandler = util.throttle((e) => {
1478
+ const scrollHandler = (e) => {
1474
1479
  var _a;
1475
1480
  const { scrollDOM, contentHeight } = view2;
1476
1481
  const scrollDomHeight = scrollDOM.clientHeight;
@@ -1485,7 +1490,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1485
1490
  } else {
1486
1491
  cEleHandler();
1487
1492
  }
1488
- }, 1);
1493
+ };
1489
1494
  return [
1490
1495
  () => {
1491
1496
  buildMap();
@@ -43,7 +43,9 @@ const userZoom = (props, html) => {
43
43
  });
44
44
  });
45
45
  vue.onMounted(() => {
46
- zoomHander();
46
+ if (!noImgZoomIn && props.setting.preview) {
47
+ zoomHander();
48
+ }
47
49
  });
48
50
  vue.watch([html, vue.toRef(props.setting, "preview")], () => {
49
51
  if (!noImgZoomIn && props.setting.preview) {
@@ -1365,12 +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
- startEleOffetTop = ((_c = document.querySelector(`[data-line="${lineNumer}"]`)) == null ? void 0 : _c.offsetTop) || startEleOffetTop;
1374
+ const _startEle = document.querySelector(`[data-line="${lineNumer}"]`);
1375
+ if (startTop > 0 && _startEle) {
1376
+ startEleOffetTop = _startEle.offsetTop;
1377
+ }
1374
1378
  blockHeight = cMaxScrollLength - startEleOffetTop + getComputedStyleNum(cEle, "padding-top");
1375
1379
  }
1376
1380
  const scrollToTop = startEleOffetTop - cElePaddingTop + blockHeight * scale;
@@ -1379,7 +1383,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1379
1383
  });
1380
1384
  };
1381
1385
  const cEleHandler = () => {
1382
- var _a, _b, _c, _d, _e, _f, _g;
1386
+ var _a, _b, _c, _d, _e, _f;
1383
1387
  if (pLock !== 0) {
1384
1388
  return;
1385
1389
  }
@@ -1435,7 +1439,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1435
1439
  }
1436
1440
  }
1437
1441
  }
1438
- let eleStartOffsetTop = realEleStart === ((_e = cEle.firstElementChild) == null ? void 0 : _e.firstElementChild) ? 0 : realEleStart.offsetTop;
1442
+ let eleStartOffsetTop = realEleStart === ((_e = cEle.firstElementChild) == null ? void 0 : _e.firstElementChild) ? 0 : realEleStart.offsetTop - getComputedStyleNum(realEleStart, "margin-top");
1439
1443
  let eleEndOffsetTop = realEleEnd.offsetTop;
1440
1444
  let scale = 0;
1441
1445
  const { start, end } = blockMap[Number(realEleStart.dataset.line || 0)];
@@ -1446,11 +1450,12 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1446
1450
  let blockHeight = 0;
1447
1451
  if (endLineScrollTop > pMaxScrollLength || realEleEnd.offsetTop + realEleEnd.offsetHeight > cMaxScrollLength) {
1448
1452
  const lineNumer = getLineNumber(pMaxScrollLength, cMaxScrollLength);
1449
- eleStartOffsetTop = ((_f = document.querySelector(`[data-line="${lineNumer}"]`)) == null ? void 0 : _f.offsetTop) || eleStartOffsetTop;
1453
+ const _startEle = document.querySelector(`[data-line="${lineNumer}"]`);
1454
+ eleStartOffsetTop = _startEle ? _startEle.offsetTop - getComputedStyleNum(_startEle, "margin-top") : eleStartOffsetTop;
1450
1455
  firstLineScrollTop = getTopByLine(lineNumer);
1451
1456
  scale = (cScrollTop - eleStartOffsetTop) / (cMaxScrollLength - eleStartOffsetTop);
1452
1457
  blockHeight = pMaxScrollLength - firstLineScrollTop;
1453
- } else if (realEleStart === ((_g = cEle.firstElementChild) == null ? void 0 : _g.firstElementChild)) {
1458
+ } else if (realEleStart === ((_f = cEle.firstElementChild) == null ? void 0 : _f.firstElementChild)) {
1454
1459
  if (realEleStart === realEleEnd) {
1455
1460
  eleEndOffsetTop = realEleEnd.offsetTop + realEleEnd.offsetHeight + +getComputedStyle(realEleEnd).marginBottom.replace("px", "");
1456
1461
  blockHeight = endLineScrollTop;
@@ -1469,7 +1474,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1469
1474
  cLock--;
1470
1475
  });
1471
1476
  };
1472
- const scrollHandler = throttle((e) => {
1477
+ const scrollHandler = (e) => {
1473
1478
  var _a;
1474
1479
  const { scrollDOM, contentHeight } = view;
1475
1480
  const scrollDomHeight = scrollDOM.clientHeight;
@@ -1484,7 +1489,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
1484
1489
  } else {
1485
1490
  cEleHandler();
1486
1491
  }
1487
- }, 1);
1492
+ };
1488
1493
  return [
1489
1494
  () => {
1490
1495
  buildMap();
@@ -42,7 +42,9 @@ const userZoom = (props, html) => {
42
42
  });
43
43
  });
44
44
  onMounted(() => {
45
- zoomHander();
45
+ if (!noImgZoomIn && props.setting.preview) {
46
+ zoomHander();
47
+ }
46
48
  });
47
49
  watch([html, toRef(props.setting, "preview")], () => {
48
50
  if (!noImgZoomIn && props.setting.preview) {