mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 09:00:12 +01:00
This commit is contained in:
parent
1a3d67f281
commit
777c844537
2 changed files with 7 additions and 14 deletions
|
|
@ -263,6 +263,8 @@
|
||||||
position: relative;
|
position: relative;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin: 1em 0;
|
margin: 1em 0;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row-reverse;
|
||||||
|
|
||||||
.protyle-action {
|
.protyle-action {
|
||||||
left: 4px;
|
left: 4px;
|
||||||
|
|
@ -304,11 +306,7 @@
|
||||||
min-height: 22px !important;
|
min-height: 22px !important;
|
||||||
overflow-x: overlay;
|
overflow-x: overlay;
|
||||||
tab-size: 4;
|
tab-size: 4;
|
||||||
|
flex: 1;
|
||||||
&.protyle-linenumber {
|
|
||||||
border-top-left-radius: 0;
|
|
||||||
border-bottom-left-radius: 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[data-subtype="echarts"],
|
[data-subtype="echarts"],
|
||||||
|
|
@ -535,14 +533,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
&-linenumber {
|
&-linenumber {
|
||||||
margin-left: calc(3.6em);
|
border-top-left-radius: 0 !important;
|
||||||
position: relative;
|
border-bottom-left-radius: 0 !important;
|
||||||
|
|
||||||
&__rows {
|
&__rows {
|
||||||
position: absolute;
|
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
top: 0;
|
|
||||||
left: 0;
|
|
||||||
user-select: none;
|
user-select: none;
|
||||||
counter-reset: linenumber;
|
counter-reset: linenumber;
|
||||||
font-size: 85%;
|
font-size: 85%;
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ export const lineNumberRender = (block: HTMLElement) => {
|
||||||
block.parentElement.style.lineHeight = `${((parseInt(block.parentElement.style.fontSize) || window.siyuan.config.editor.fontSize) * 1.625 * 0.85).toFixed(0)}px`;
|
block.parentElement.style.lineHeight = `${((parseInt(block.parentElement.style.fontSize) || window.siyuan.config.editor.fontSize) * 1.625 * 0.85).toFixed(0)}px`;
|
||||||
const lineNumberTemp = document.createElement("div");
|
const lineNumberTemp = document.createElement("div");
|
||||||
lineNumberTemp.className = "hljs protyle-linenumber";
|
lineNumberTemp.className = "hljs protyle-linenumber";
|
||||||
lineNumberTemp.setAttribute("style", `padding-top:0 !important;padding-bottom:0 !important;min-height:auto !important;white-space:${block.style.whiteSpace};word-break:${block.style.wordBreak};font-variant-ligatures:${block.style.fontVariantLigatures};`);
|
lineNumberTemp.setAttribute("style", `box-sizing: border-box;width: calc(100% - 3.6em);position: absolute;padding-top:0 !important;padding-bottom:0 !important;min-height:auto !important;white-space:${block.style.whiteSpace};word-break:${block.style.wordBreak};font-variant-ligatures:${block.style.fontVariantLigatures};`);
|
||||||
lineNumberTemp.setAttribute("contenteditable", "true");
|
lineNumberTemp.setAttribute("contenteditable", "true");
|
||||||
block.insertAdjacentElement("afterend", lineNumberTemp);
|
block.insertAdjacentElement("afterend", lineNumberTemp);
|
||||||
|
|
||||||
|
|
@ -160,11 +160,9 @@ export const lineNumberRender = (block: HTMLElement) => {
|
||||||
});
|
});
|
||||||
|
|
||||||
lineNumberTemp.remove();
|
lineNumberTemp.remove();
|
||||||
const height = block.offsetHeight;
|
|
||||||
if (block.nextElementSibling?.classList.contains("protyle-linenumber__rows")) {
|
if (block.nextElementSibling?.classList.contains("protyle-linenumber__rows")) {
|
||||||
block.nextElementSibling.innerHTML = lineNumberHTML;
|
block.nextElementSibling.innerHTML = lineNumberHTML;
|
||||||
(block.nextElementSibling as HTMLElement).style.height = height + "px";
|
|
||||||
} else {
|
} else {
|
||||||
block.insertAdjacentHTML("afterend", `<span contenteditable="false" style="height:${height}px" class="protyle-linenumber__rows">${lineNumberHTML}</span>`);
|
block.insertAdjacentHTML("afterend", `<span contenteditable="false" class="protyle-linenumber__rows">${lineNumberHTML}</span>`);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue