md-editor-v3 4.16.1 → 4.16.4
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.
- package/lib/cjs/MdEditor.cjs +57 -37
- package/lib/cjs/chunks/index.cjs +3 -2
- package/lib/es/MdEditor.mjs +57 -37
- package/lib/es/chunks/index.mjs +3 -2
- package/lib/umd/index.js +45 -45
- package/package.json +1 -1
package/lib/cjs/MdEditor.cjs
CHANGED
|
@@ -1234,6 +1234,9 @@ const ToolBar = /* @__PURE__ */ vue.defineComponent({
|
|
|
1234
1234
|
}
|
|
1235
1235
|
});
|
|
1236
1236
|
const DATA_LINE_SELECTOR = `.${config.prefix}-preview > [data-line]`;
|
|
1237
|
+
const getComputedStyleNum = (ele, key) => {
|
|
1238
|
+
return +getComputedStyle(ele).getPropertyValue(key).replace("px", "");
|
|
1239
|
+
};
|
|
1237
1240
|
const scrollAutoWithScale = (pEle, cEle) => {
|
|
1238
1241
|
const addEvent = util.debounce(() => {
|
|
1239
1242
|
pEle.removeEventListener("scroll", scrollHandler);
|
|
@@ -1279,30 +1282,28 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
|
|
|
1279
1282
|
const { view: view2 } = codeMirrorUt;
|
|
1280
1283
|
const smoothScroll = util.createSmoothScroll();
|
|
1281
1284
|
const getTopByLine = (line) => {
|
|
1282
|
-
return view2.lineBlockAt(view2.state.doc.line(line).from).top;
|
|
1285
|
+
return view2.lineBlockAt(view2.state.doc.line(line + 1).from).top;
|
|
1283
1286
|
};
|
|
1284
|
-
const
|
|
1285
|
-
return view2.lineBlockAt(view2.state.doc.line(line).from).
|
|
1287
|
+
const getBottomByLine = (line) => {
|
|
1288
|
+
return view2.lineBlockAt(view2.state.doc.line(line + 1).from).bottom;
|
|
1286
1289
|
};
|
|
1287
1290
|
let blockMap = [];
|
|
1288
1291
|
let elesHasLineNumber = [];
|
|
1289
1292
|
let startLines = [];
|
|
1290
1293
|
const buildMap = () => {
|
|
1291
1294
|
blockMap = [];
|
|
1292
|
-
elesHasLineNumber =
|
|
1293
|
-
|
|
1294
|
-
elesHasLineNumber = elesHasLineNumber.concat(
|
|
1295
|
-
Array.from(cEle.querySelectorAll(DATA_LINE_SELECTOR))
|
|
1295
|
+
elesHasLineNumber = Array.from(
|
|
1296
|
+
cEle.querySelectorAll(DATA_LINE_SELECTOR)
|
|
1296
1297
|
);
|
|
1297
|
-
|
|
1298
|
-
|
|
1298
|
+
startLines = elesHasLineNumber.map((item) => Number(item.dataset.line));
|
|
1299
|
+
const tempStartLines = [...startLines];
|
|
1299
1300
|
const { lines } = view2.state.doc;
|
|
1300
|
-
let start =
|
|
1301
|
-
let end =
|
|
1302
|
-
for (let i =
|
|
1301
|
+
let start = tempStartLines.shift() || 0;
|
|
1302
|
+
let end = tempStartLines.shift() || lines;
|
|
1303
|
+
for (let i = 0; i < lines; i++) {
|
|
1303
1304
|
if (i === end) {
|
|
1304
1305
|
start = i;
|
|
1305
|
-
end =
|
|
1306
|
+
end = tempStartLines.shift() || lines;
|
|
1306
1307
|
}
|
|
1307
1308
|
blockMap.push({
|
|
1308
1309
|
start,
|
|
@@ -1313,44 +1314,61 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
|
|
|
1313
1314
|
let pLock = 0;
|
|
1314
1315
|
let cLock = 0;
|
|
1315
1316
|
const pEleHandler = () => {
|
|
1316
|
-
var _a, _b;
|
|
1317
|
+
var _a, _b, _c;
|
|
1317
1318
|
if (cLock !== 0) {
|
|
1318
1319
|
return false;
|
|
1319
1320
|
}
|
|
1320
1321
|
pLock++;
|
|
1321
1322
|
const { scrollDOM, contentHeight } = view2;
|
|
1322
|
-
let cElePaddingTop =
|
|
1323
|
+
let cElePaddingTop = getComputedStyleNum(cEle, "padding-top");
|
|
1323
1324
|
const blockInfo = view2.lineBlockAtHeight(scrollDOM.scrollTop);
|
|
1324
1325
|
const { number: currLine } = view2.state.doc.lineAt(blockInfo.from);
|
|
1325
1326
|
const blockData = blockMap[currLine - 1];
|
|
1326
1327
|
if (!blockData) {
|
|
1327
1328
|
return false;
|
|
1328
1329
|
}
|
|
1329
|
-
let
|
|
1330
|
-
|
|
1331
|
-
const
|
|
1332
|
-
const
|
|
1333
|
-
const
|
|
1334
|
-
let
|
|
1335
|
-
let
|
|
1330
|
+
let scale = 1;
|
|
1331
|
+
const startEle = cEle.querySelector(`[data-line="${blockData.start}"]`) || ((_a = cEle.firstElementChild) == null ? void 0 : _a.firstElementChild);
|
|
1332
|
+
const endEle = cEle.querySelector(`[data-line="${blockData.end + 1}"]`) || ((_b = cEle.lastElementChild) == null ? void 0 : _b.lastElementChild);
|
|
1333
|
+
const pMaxScrollLength = scrollDOM.scrollHeight - scrollDOM.clientHeight;
|
|
1334
|
+
const cMaxScrollLength = cEle.scrollHeight - cEle.clientHeight;
|
|
1335
|
+
let startTop = getTopByLine(blockData.start);
|
|
1336
|
+
let endBottom = getBottomByLine(blockData.end);
|
|
1337
|
+
let startEleOffetTop = startEle.offsetTop;
|
|
1338
|
+
let blockHeight = endEle.offsetTop - startEleOffetTop;
|
|
1336
1339
|
if (startTop === 0) {
|
|
1337
|
-
|
|
1340
|
+
startEleOffetTop = 0;
|
|
1338
1341
|
if (startEle === endEle) {
|
|
1339
1342
|
cElePaddingTop = 0;
|
|
1340
|
-
|
|
1341
|
-
blockHeight =
|
|
1343
|
+
endBottom = contentHeight - scrollDOM.offsetHeight;
|
|
1344
|
+
blockHeight = cMaxScrollLength;
|
|
1342
1345
|
} else {
|
|
1343
1346
|
blockHeight = endEle.offsetTop;
|
|
1344
1347
|
}
|
|
1345
|
-
} else {
|
|
1346
|
-
scale = (scrollDOM.scrollTop - startTop) / (endLinePosition - startTop);
|
|
1347
|
-
startEleOffetTop = startEle.offsetTop;
|
|
1348
|
-
blockHeight = endEle.offsetTop - startEleOffetTop;
|
|
1349
1348
|
}
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1349
|
+
scale = (scrollDOM.scrollTop - startTop + getComputedStyleNum(view2.contentDOM, "padding-bottom")) / (endBottom - startTop);
|
|
1350
|
+
if (startTop > 0 && (endBottom >= pMaxScrollLength || endEle.offsetTop + endEle.clientHeight > cMaxScrollLength)) {
|
|
1351
|
+
let lineNumer = 0;
|
|
1352
|
+
for (let i = elesHasLineNumber.length - 1; i >= 0; i--) {
|
|
1353
|
+
const curr = elesHasLineNumber[i];
|
|
1354
|
+
const sibling = elesHasLineNumber[i].previousElementSibling;
|
|
1355
|
+
if (curr.offsetTop + curr.offsetHeight > cMaxScrollLength && sibling.offsetTop < cMaxScrollLength) {
|
|
1356
|
+
lineNumer = Number(curr.dataset.line);
|
|
1357
|
+
break;
|
|
1358
|
+
}
|
|
1359
|
+
}
|
|
1360
|
+
for (let i = blockMap.length - 1; i >= 0; i--) {
|
|
1361
|
+
const itemBottom = getBottomByLine(blockMap[i].end);
|
|
1362
|
+
const itemTop = getTopByLine(blockMap[i].start);
|
|
1363
|
+
if (itemBottom > pMaxScrollLength && itemTop <= pMaxScrollLength) {
|
|
1364
|
+
lineNumer = lineNumer < blockMap[i].start ? lineNumer : blockMap[i].start;
|
|
1365
|
+
break;
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
startTop = getTopByLine(lineNumer);
|
|
1369
|
+
scale = (scrollDOM.scrollTop - startTop) / (pMaxScrollLength - startTop);
|
|
1370
|
+
startEleOffetTop = (_c = document.querySelector(`[data-line="${lineNumer}"]`)) == null ? void 0 : _c.offsetTop;
|
|
1371
|
+
blockHeight = cMaxScrollLength - startEleOffetTop + getComputedStyleNum(cEle, "padding-top");
|
|
1354
1372
|
}
|
|
1355
1373
|
const scrollToTop = startEleOffetTop - cElePaddingTop + blockHeight * scale;
|
|
1356
1374
|
smoothScroll(cEle, scrollToTop, () => {
|
|
@@ -1370,7 +1388,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
|
|
|
1370
1388
|
let realEleEnd = (_b = cEle.firstElementChild) == null ? void 0 : _b.lastElementChild;
|
|
1371
1389
|
if (startLines.length > 0) {
|
|
1372
1390
|
let virtualLine = Math.ceil(
|
|
1373
|
-
|
|
1391
|
+
startLines[startLines.length - 1] * (cScrollTop / cScrollHeight)
|
|
1374
1392
|
);
|
|
1375
1393
|
let startLineIndex = startLines.findLastIndex((value) => value <= virtualLine);
|
|
1376
1394
|
startLineIndex = startLineIndex === -1 ? 0 : startLineIndex;
|
|
@@ -1395,7 +1413,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
|
|
|
1395
1413
|
break;
|
|
1396
1414
|
}
|
|
1397
1415
|
}
|
|
1398
|
-
switch (
|
|
1416
|
+
switch (startLineIndex) {
|
|
1399
1417
|
case -1: {
|
|
1400
1418
|
realEleStart = (_c = cEle.firstElementChild) == null ? void 0 : _c.firstElementChild;
|
|
1401
1419
|
realEleEnd = elesHasLineNumber[startLineIndex];
|
|
@@ -1417,9 +1435,11 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
|
|
|
1417
1435
|
let scale = 0;
|
|
1418
1436
|
const { start, end } = blockMap[Number(realEleStart.dataset.line || 0)];
|
|
1419
1437
|
const firstLineScrollTop = getTopByLine(start);
|
|
1420
|
-
const endLineScrollTop = getTopByLine(
|
|
1438
|
+
const endLineScrollTop = getTopByLine(
|
|
1439
|
+
end + 1 === view2.state.doc.lines ? end : end + 1
|
|
1440
|
+
);
|
|
1421
1441
|
let blockHeight = 0;
|
|
1422
|
-
if (endLineScrollTop > scrollDOM.scrollHeight - scrollDOM.clientHeight || realEleEnd.
|
|
1442
|
+
if (endLineScrollTop > scrollDOM.scrollHeight - scrollDOM.clientHeight || realEleEnd.offsetTop + realEleEnd.offsetHeight > cEle.scrollHeight - cEle.clientHeight) {
|
|
1423
1443
|
scale = (cScrollTop + cEle.clientHeight - eleStartOffsetTop) / (cEle.scrollHeight - eleStartOffsetTop);
|
|
1424
1444
|
blockHeight = pEle.scrollHeight - firstLineScrollTop - pEle.clientHeight;
|
|
1425
1445
|
} else if (realEleStart === ((_f = cEle.firstElementChild) == null ? void 0 : _f.firstElementChild)) {
|
package/lib/cjs/chunks/index.cjs
CHANGED
|
@@ -641,6 +641,7 @@ const codetabs = (md, _opts) => {
|
|
|
641
641
|
const codeCodeText = (_a = _opts.usedLanguageTextRef.value) == null ? void 0 : _a.copyCode.text;
|
|
642
642
|
const copyBtnHtml = _opts.customIconRef.value.copy || codeCodeText;
|
|
643
643
|
const isIcon = !!_opts.customIconRef.value.copy;
|
|
644
|
+
const collapseTips = `<span class="${config.prefix}-collapse-tips">${StrIcon$1("collapse-tips", _opts.customIconRef.value)}</span>`;
|
|
644
645
|
const [GROUP] = getGroupAndTab(tokens[idx]);
|
|
645
646
|
if (GROUP === null) {
|
|
646
647
|
const { open: open2, tagContainer: tagContainer2, tagHeader: tagHeader2 } = getTagType(tokens[idx]);
|
|
@@ -657,7 +658,7 @@ const codetabs = (md, _opts) => {
|
|
|
657
658
|
<div class="${config.prefix}-code-action">
|
|
658
659
|
<span class="${config.prefix}-code-lang">${tokens[idx].info.trim()}</span>
|
|
659
660
|
<span class="${config.prefix}-copy-button" data-tips="${codeCodeText}"${isIcon ? " data-is-icon=true" : ""}">${copyBtnHtml}</span>
|
|
660
|
-
|
|
661
|
+
${tagContainer2 === "details" ? collapseTips : ""}
|
|
661
662
|
</div>
|
|
662
663
|
</${tagHeader2}>${codeRendered}</${tagContainer2}>`;
|
|
663
664
|
}
|
|
@@ -695,7 +696,7 @@ const codetabs = (md, _opts) => {
|
|
|
695
696
|
<div class="${config.prefix}-code-action">
|
|
696
697
|
<span class="${config.prefix}-codetab-lang">${langs}</span>
|
|
697
698
|
<span class="${config.prefix}-copy-button" data-tips="${codeCodeText}"${isIcon ? " data-is-icon=true" : ""}">${copyBtnHtml}</span>
|
|
698
|
-
|
|
699
|
+
${tagContainer === "details" ? collapseTips : ""}
|
|
699
700
|
</div>
|
|
700
701
|
</${tagHeader}>${pres}</${tagContainer}>`;
|
|
701
702
|
};
|
package/lib/es/MdEditor.mjs
CHANGED
|
@@ -1233,6 +1233,9 @@ const ToolBar = /* @__PURE__ */ defineComponent({
|
|
|
1233
1233
|
}
|
|
1234
1234
|
});
|
|
1235
1235
|
const DATA_LINE_SELECTOR = `.${prefix}-preview > [data-line]`;
|
|
1236
|
+
const getComputedStyleNum = (ele, key) => {
|
|
1237
|
+
return +getComputedStyle(ele).getPropertyValue(key).replace("px", "");
|
|
1238
|
+
};
|
|
1236
1239
|
const scrollAutoWithScale = (pEle, cEle) => {
|
|
1237
1240
|
const addEvent = debounce(() => {
|
|
1238
1241
|
pEle.removeEventListener("scroll", scrollHandler);
|
|
@@ -1278,30 +1281,28 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
|
|
|
1278
1281
|
const { view } = codeMirrorUt;
|
|
1279
1282
|
const smoothScroll = createSmoothScroll();
|
|
1280
1283
|
const getTopByLine = (line) => {
|
|
1281
|
-
return view.lineBlockAt(view.state.doc.line(line).from).top;
|
|
1284
|
+
return view.lineBlockAt(view.state.doc.line(line + 1).from).top;
|
|
1282
1285
|
};
|
|
1283
|
-
const
|
|
1284
|
-
return view.lineBlockAt(view.state.doc.line(line).from).
|
|
1286
|
+
const getBottomByLine = (line) => {
|
|
1287
|
+
return view.lineBlockAt(view.state.doc.line(line + 1).from).bottom;
|
|
1285
1288
|
};
|
|
1286
1289
|
let blockMap = [];
|
|
1287
1290
|
let elesHasLineNumber = [];
|
|
1288
1291
|
let startLines = [];
|
|
1289
1292
|
const buildMap = () => {
|
|
1290
1293
|
blockMap = [];
|
|
1291
|
-
elesHasLineNumber =
|
|
1292
|
-
|
|
1293
|
-
elesHasLineNumber = elesHasLineNumber.concat(
|
|
1294
|
-
Array.from(cEle.querySelectorAll(DATA_LINE_SELECTOR))
|
|
1294
|
+
elesHasLineNumber = Array.from(
|
|
1295
|
+
cEle.querySelectorAll(DATA_LINE_SELECTOR)
|
|
1295
1296
|
);
|
|
1296
|
-
|
|
1297
|
-
|
|
1297
|
+
startLines = elesHasLineNumber.map((item) => Number(item.dataset.line));
|
|
1298
|
+
const tempStartLines = [...startLines];
|
|
1298
1299
|
const { lines } = view.state.doc;
|
|
1299
|
-
let start =
|
|
1300
|
-
let end =
|
|
1301
|
-
for (let i =
|
|
1300
|
+
let start = tempStartLines.shift() || 0;
|
|
1301
|
+
let end = tempStartLines.shift() || lines;
|
|
1302
|
+
for (let i = 0; i < lines; i++) {
|
|
1302
1303
|
if (i === end) {
|
|
1303
1304
|
start = i;
|
|
1304
|
-
end =
|
|
1305
|
+
end = tempStartLines.shift() || lines;
|
|
1305
1306
|
}
|
|
1306
1307
|
blockMap.push({
|
|
1307
1308
|
start,
|
|
@@ -1312,44 +1313,61 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
|
|
|
1312
1313
|
let pLock = 0;
|
|
1313
1314
|
let cLock = 0;
|
|
1314
1315
|
const pEleHandler = () => {
|
|
1315
|
-
var _a, _b;
|
|
1316
|
+
var _a, _b, _c;
|
|
1316
1317
|
if (cLock !== 0) {
|
|
1317
1318
|
return false;
|
|
1318
1319
|
}
|
|
1319
1320
|
pLock++;
|
|
1320
1321
|
const { scrollDOM, contentHeight } = view;
|
|
1321
|
-
let cElePaddingTop =
|
|
1322
|
+
let cElePaddingTop = getComputedStyleNum(cEle, "padding-top");
|
|
1322
1323
|
const blockInfo = view.lineBlockAtHeight(scrollDOM.scrollTop);
|
|
1323
1324
|
const { number: currLine } = view.state.doc.lineAt(blockInfo.from);
|
|
1324
1325
|
const blockData = blockMap[currLine - 1];
|
|
1325
1326
|
if (!blockData) {
|
|
1326
1327
|
return false;
|
|
1327
1328
|
}
|
|
1328
|
-
let
|
|
1329
|
-
|
|
1330
|
-
const
|
|
1331
|
-
const
|
|
1332
|
-
const
|
|
1333
|
-
let
|
|
1334
|
-
let
|
|
1329
|
+
let scale = 1;
|
|
1330
|
+
const startEle = cEle.querySelector(`[data-line="${blockData.start}"]`) || ((_a = cEle.firstElementChild) == null ? void 0 : _a.firstElementChild);
|
|
1331
|
+
const endEle = cEle.querySelector(`[data-line="${blockData.end + 1}"]`) || ((_b = cEle.lastElementChild) == null ? void 0 : _b.lastElementChild);
|
|
1332
|
+
const pMaxScrollLength = scrollDOM.scrollHeight - scrollDOM.clientHeight;
|
|
1333
|
+
const cMaxScrollLength = cEle.scrollHeight - cEle.clientHeight;
|
|
1334
|
+
let startTop = getTopByLine(blockData.start);
|
|
1335
|
+
let endBottom = getBottomByLine(blockData.end);
|
|
1336
|
+
let startEleOffetTop = startEle.offsetTop;
|
|
1337
|
+
let blockHeight = endEle.offsetTop - startEleOffetTop;
|
|
1335
1338
|
if (startTop === 0) {
|
|
1336
|
-
|
|
1339
|
+
startEleOffetTop = 0;
|
|
1337
1340
|
if (startEle === endEle) {
|
|
1338
1341
|
cElePaddingTop = 0;
|
|
1339
|
-
|
|
1340
|
-
blockHeight =
|
|
1342
|
+
endBottom = contentHeight - scrollDOM.offsetHeight;
|
|
1343
|
+
blockHeight = cMaxScrollLength;
|
|
1341
1344
|
} else {
|
|
1342
1345
|
blockHeight = endEle.offsetTop;
|
|
1343
1346
|
}
|
|
1344
|
-
} else {
|
|
1345
|
-
scale = (scrollDOM.scrollTop - startTop) / (endLinePosition - startTop);
|
|
1346
|
-
startEleOffetTop = startEle.offsetTop;
|
|
1347
|
-
blockHeight = endEle.offsetTop - startEleOffetTop;
|
|
1348
1347
|
}
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1348
|
+
scale = (scrollDOM.scrollTop - startTop + getComputedStyleNum(view.contentDOM, "padding-bottom")) / (endBottom - startTop);
|
|
1349
|
+
if (startTop > 0 && (endBottom >= pMaxScrollLength || endEle.offsetTop + endEle.clientHeight > cMaxScrollLength)) {
|
|
1350
|
+
let lineNumer = 0;
|
|
1351
|
+
for (let i = elesHasLineNumber.length - 1; i >= 0; i--) {
|
|
1352
|
+
const curr = elesHasLineNumber[i];
|
|
1353
|
+
const sibling = elesHasLineNumber[i].previousElementSibling;
|
|
1354
|
+
if (curr.offsetTop + curr.offsetHeight > cMaxScrollLength && sibling.offsetTop < cMaxScrollLength) {
|
|
1355
|
+
lineNumer = Number(curr.dataset.line);
|
|
1356
|
+
break;
|
|
1357
|
+
}
|
|
1358
|
+
}
|
|
1359
|
+
for (let i = blockMap.length - 1; i >= 0; i--) {
|
|
1360
|
+
const itemBottom = getBottomByLine(blockMap[i].end);
|
|
1361
|
+
const itemTop = getTopByLine(blockMap[i].start);
|
|
1362
|
+
if (itemBottom > pMaxScrollLength && itemTop <= pMaxScrollLength) {
|
|
1363
|
+
lineNumer = lineNumer < blockMap[i].start ? lineNumer : blockMap[i].start;
|
|
1364
|
+
break;
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
startTop = getTopByLine(lineNumer);
|
|
1368
|
+
scale = (scrollDOM.scrollTop - startTop) / (pMaxScrollLength - startTop);
|
|
1369
|
+
startEleOffetTop = (_c = document.querySelector(`[data-line="${lineNumer}"]`)) == null ? void 0 : _c.offsetTop;
|
|
1370
|
+
blockHeight = cMaxScrollLength - startEleOffetTop + getComputedStyleNum(cEle, "padding-top");
|
|
1353
1371
|
}
|
|
1354
1372
|
const scrollToTop = startEleOffetTop - cElePaddingTop + blockHeight * scale;
|
|
1355
1373
|
smoothScroll(cEle, scrollToTop, () => {
|
|
@@ -1369,7 +1387,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
|
|
|
1369
1387
|
let realEleEnd = (_b = cEle.firstElementChild) == null ? void 0 : _b.lastElementChild;
|
|
1370
1388
|
if (startLines.length > 0) {
|
|
1371
1389
|
let virtualLine = Math.ceil(
|
|
1372
|
-
|
|
1390
|
+
startLines[startLines.length - 1] * (cScrollTop / cScrollHeight)
|
|
1373
1391
|
);
|
|
1374
1392
|
let startLineIndex = startLines.findLastIndex((value) => value <= virtualLine);
|
|
1375
1393
|
startLineIndex = startLineIndex === -1 ? 0 : startLineIndex;
|
|
@@ -1394,7 +1412,7 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
|
|
|
1394
1412
|
break;
|
|
1395
1413
|
}
|
|
1396
1414
|
}
|
|
1397
|
-
switch (
|
|
1415
|
+
switch (startLineIndex) {
|
|
1398
1416
|
case -1: {
|
|
1399
1417
|
realEleStart = (_c = cEle.firstElementChild) == null ? void 0 : _c.firstElementChild;
|
|
1400
1418
|
realEleEnd = elesHasLineNumber[startLineIndex];
|
|
@@ -1416,9 +1434,11 @@ const scrollAuto = (pEle, cEle, codeMirrorUt) => {
|
|
|
1416
1434
|
let scale = 0;
|
|
1417
1435
|
const { start, end } = blockMap[Number(realEleStart.dataset.line || 0)];
|
|
1418
1436
|
const firstLineScrollTop = getTopByLine(start);
|
|
1419
|
-
const endLineScrollTop = getTopByLine(
|
|
1437
|
+
const endLineScrollTop = getTopByLine(
|
|
1438
|
+
end + 1 === view.state.doc.lines ? end : end + 1
|
|
1439
|
+
);
|
|
1420
1440
|
let blockHeight = 0;
|
|
1421
|
-
if (endLineScrollTop > scrollDOM.scrollHeight - scrollDOM.clientHeight || realEleEnd.
|
|
1441
|
+
if (endLineScrollTop > scrollDOM.scrollHeight - scrollDOM.clientHeight || realEleEnd.offsetTop + realEleEnd.offsetHeight > cEle.scrollHeight - cEle.clientHeight) {
|
|
1422
1442
|
scale = (cScrollTop + cEle.clientHeight - eleStartOffsetTop) / (cEle.scrollHeight - eleStartOffsetTop);
|
|
1423
1443
|
blockHeight = pEle.scrollHeight - firstLineScrollTop - pEle.clientHeight;
|
|
1424
1444
|
} else if (realEleStart === ((_f = cEle.firstElementChild) == null ? void 0 : _f.firstElementChild)) {
|
package/lib/es/chunks/index.mjs
CHANGED
|
@@ -640,6 +640,7 @@ const codetabs = (md, _opts) => {
|
|
|
640
640
|
const codeCodeText = (_a = _opts.usedLanguageTextRef.value) == null ? void 0 : _a.copyCode.text;
|
|
641
641
|
const copyBtnHtml = _opts.customIconRef.value.copy || codeCodeText;
|
|
642
642
|
const isIcon = !!_opts.customIconRef.value.copy;
|
|
643
|
+
const collapseTips = `<span class="${prefix}-collapse-tips">${StrIcon$1("collapse-tips", _opts.customIconRef.value)}</span>`;
|
|
643
644
|
const [GROUP] = getGroupAndTab(tokens[idx]);
|
|
644
645
|
if (GROUP === null) {
|
|
645
646
|
const { open: open2, tagContainer: tagContainer2, tagHeader: tagHeader2 } = getTagType(tokens[idx]);
|
|
@@ -656,7 +657,7 @@ const codetabs = (md, _opts) => {
|
|
|
656
657
|
<div class="${prefix}-code-action">
|
|
657
658
|
<span class="${prefix}-code-lang">${tokens[idx].info.trim()}</span>
|
|
658
659
|
<span class="${prefix}-copy-button" data-tips="${codeCodeText}"${isIcon ? " data-is-icon=true" : ""}">${copyBtnHtml}</span>
|
|
659
|
-
|
|
660
|
+
${tagContainer2 === "details" ? collapseTips : ""}
|
|
660
661
|
</div>
|
|
661
662
|
</${tagHeader2}>${codeRendered}</${tagContainer2}>`;
|
|
662
663
|
}
|
|
@@ -694,7 +695,7 @@ const codetabs = (md, _opts) => {
|
|
|
694
695
|
<div class="${prefix}-code-action">
|
|
695
696
|
<span class="${prefix}-codetab-lang">${langs}</span>
|
|
696
697
|
<span class="${prefix}-copy-button" data-tips="${codeCodeText}"${isIcon ? " data-is-icon=true" : ""}">${copyBtnHtml}</span>
|
|
697
|
-
|
|
698
|
+
${tagContainer === "details" ? collapseTips : ""}
|
|
698
699
|
</div>
|
|
699
700
|
</${tagHeader}>${pres}</${tagContainer}>`;
|
|
700
701
|
};
|