This commit is contained in:
Vanessa 2024-08-16 21:47:19 +08:00
parent 1a20840a2a
commit 347d4c7554
3 changed files with 6 additions and 6 deletions

View file

@ -89,7 +89,7 @@ export const highlightRender = (element: Element, cdn = Constants.PROTYLE_CDN) =
const codeText = block.textContent;
if (!isPreview && (lineNumber === "true" || (lineNumber !== "false" && window.siyuan.config.editor.codeSyntaxHighlightLineNum))) {
// 需要先添加 class 以防止抖动 https://ld246.com/article/1648116585443
block.firstElementChild.classList.add("protyle-linenumber__rows")
block.firstElementChild.classList.add("protyle-linenumber__rows");
lineNumberRender(block);
}

View file

@ -317,7 +317,7 @@ export const saveCriterion = (config: Config.IUILayoutTabSearchConfig,
saveDialog.destroy();
});
btnsElement[1].addEventListener("click", () => {
const inputElement = saveDialog.element.querySelector("input")
const inputElement = saveDialog.element.querySelector("input");
const value = inputElement.value.trim();
if (!value) {
showMessage(window.siyuan.languages["_kernel"]["142"]);

View file

@ -1,5 +1,5 @@
import {hasClosestBlock, hasClosestByAttribute} from "../protyle/util/hasClosest";
import {getEditorRange, getSelectionPosition} from "../protyle/util/selection";
import {getEditorRange} from "../protyle/util/selection";
export const bgFade = (element: Element) => {
element.classList.add("protyle-wysiwyg--hl");
@ -40,12 +40,12 @@ export const highlightById = (protyle: IProtyle, id: string, top = false) => {
export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = false, behavior: ScrollBehavior = "auto") => {
if (!protyle.disabled && !top && getSelection().rangeCount > 0) {
const range = getSelection().getRangeAt(0)
const range = getSelection().getRangeAt(0);
const blockElement = hasClosestBlock(range.startContainer);
if (blockElement) {
// https://github.com/siyuan-note/siyuan/issues/10769
if (blockElement.classList.contains("code-block")) {
const brElement = document.createElement('br');
const brElement = document.createElement("br");
range.insertNode(brElement);
brElement.scrollIntoView({block: "center", behavior});
brElement.remove();
@ -57,7 +57,7 @@ export const scrollCenter = (protyle: IProtyle, nodeElement?: Element, top = fal
return;
}
const br2Element = document.createElement('br');
const br2Element = document.createElement("br");
range.insertNode(br2Element);
const editorElement = protyle.contentElement;
const cursorTop = br2Element.getBoundingClientRect().top - editorElement.getBoundingClientRect().top;