🎨 Clean code

This commit is contained in:
Daniel 2024-03-19 08:26:16 +08:00
parent 427bf25a88
commit b22a70cf65
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 12 additions and 10 deletions

View file

@ -2,11 +2,13 @@ import {Divider} from "./Divider";
import {Font, hasSameTextStyle, setFontStyle} from "./Font";
import {ToolbarItem} from "./ToolbarItem";
import {
fixTableRange, focusBlock,
fixTableRange,
focusBlock,
focusByRange,
focusByWbr,
getEditorRange,
getSelectionPosition, selectAll,
getSelectionPosition,
selectAll,
setFirstNodeRange,
setLastNodeRange
} from "../util/selection";
@ -1141,8 +1143,8 @@ export class Toolbar {
const editElement = getContenteditableElement(nodeElement);
if (Constants.SIYUAN_RENDER_CODE_LANGUAGES.includes(languageElement.textContent)) {
nodeElement.dataset.content = editElement.textContent.trim();
nodeElement.dataset.subtype = languageElement.textContent
nodeElement.className = "render-node"
nodeElement.dataset.subtype = languageElement.textContent;
nodeElement.className = "render-node";
nodeElement.innerHTML = `<div spin="1"></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div>`;
processRender(nodeElement);
} else {

View file

@ -1,5 +1,5 @@
import {genEmptyElement, insertEmptyBlock} from "../../block/util";
import {getSelectionOffset, focusByWbr, setLastNodeRange, focusBlock, focusByRange} from "../util/selection";
import {focusBlock, focusByRange, focusByWbr, getSelectionOffset, setLastNodeRange} from "../util/selection";
import {
getContenteditableElement,
getTopEmptyElement,
@ -84,9 +84,9 @@ export const enter = (blockElement: HTMLElement, range: Range, protyle: IProtyle
setStorageVal(Constants.LOCAL_CODELANG, window.siyuan.storage[Constants.LOCAL_CODELANG]);
}
if (Constants.SIYUAN_RENDER_CODE_LANGUAGES.includes(languageElement.textContent)) {
blockElement.dataset.content = ""
blockElement.dataset.subtype = languageElement.textContent
blockElement.className = "render-node"
blockElement.dataset.content = "";
blockElement.dataset.subtype = languageElement.textContent;
blockElement.className = "render-node";
blockElement.innerHTML = `<div spin="1"></div><div class="protyle-attr" contenteditable="false">${Constants.ZWSP}</div>`;
protyle.toolbar.showRender(protyle, blockElement);
processRender(blockElement);