mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-06 07:31:48 +01:00
This commit is contained in:
parent
5784b0711c
commit
889641ff67
10 changed files with 168 additions and 153 deletions
|
|
@ -86,36 +86,6 @@ export const loadAssets = (data: IAppearance) => {
|
|||
}
|
||||
};
|
||||
|
||||
export const renderSnippet = () => {
|
||||
fetchPost("/api/snippet/getSnippet", {type: "all", enabled: 2}, (response) => {
|
||||
response.data.snippets.forEach((item: ISnippet) => {
|
||||
const id = `snippet${item.type === "css" ? "CSS" : "JS"}${item.id}`;
|
||||
let exitElement = document.getElementById(id) as HTMLScriptElement;
|
||||
if (!item.enabled) {
|
||||
if (exitElement) {
|
||||
exitElement.remove();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (exitElement) {
|
||||
if (exitElement.innerHTML === item.content) {
|
||||
return;
|
||||
}
|
||||
exitElement.remove();
|
||||
}
|
||||
if (item.type === "css") {
|
||||
document.head.insertAdjacentHTML("beforeend", `<style id="${id}">${item.content}</style>`);
|
||||
} else if (item.type === "js") {
|
||||
exitElement = document.createElement("script");
|
||||
exitElement.type = "text/javascript";
|
||||
exitElement.text = item.content;
|
||||
exitElement.id = id;
|
||||
document.head.appendChild(exitElement);
|
||||
}
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
export const initAssets = () => {
|
||||
const emojiElement = document.getElementById("emojiScript");
|
||||
const loadingElement = document.getElementById("loading");
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ import {globalShortcut} from "./globalShortcut";
|
|||
import {fetchPost} from "./fetch";
|
||||
import {mountHelp, newDailyNote} from "./mount";
|
||||
import {MenuItem} from "../menus/Menu";
|
||||
import {initAssets, loadAssets, renderSnippet, setInlineStyle, setMode} from "./assets";
|
||||
import {initAssets, loadAssets, setInlineStyle, setMode} from "./assets";
|
||||
import {renderSnippet} from "../config/util/snippets";
|
||||
import {getOpenNotebookCount} from "./pathName";
|
||||
import {openFileById} from "../editor/util";
|
||||
import {focusByRange} from "../protyle/util/selection";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue