src/ and dist/
This commit is contained in:
parent
24df99815f
commit
4069c345a0
3 changed files with 17 additions and 10 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -8,9 +8,9 @@
|
|||
# npm
|
||||
node_modules
|
||||
|
||||
# Don't include the compiled main.js file in the repo.
|
||||
# Don't include the compiled files in the repo.
|
||||
# They should be uploaded to GitHub releases instead.
|
||||
main.js
|
||||
dist/
|
||||
|
||||
# Exclude sourcemaps
|
||||
*.map
|
||||
|
|
|
@ -14,7 +14,7 @@ const context = await esbuild.context({
|
|||
banner: {
|
||||
js: banner,
|
||||
},
|
||||
entryPoints: ["main.ts"],
|
||||
entryPoints: ["src/main.ts"],
|
||||
bundle: true,
|
||||
external: [
|
||||
"obsidian",
|
||||
|
@ -37,7 +37,7 @@ const context = await esbuild.context({
|
|||
logLevel: "info",
|
||||
sourcemap: prod ? false : "inline",
|
||||
treeShaking: true,
|
||||
outfile: "main.js",
|
||||
outfile: "dist/main.js",
|
||||
});
|
||||
|
||||
if (prod) {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { Extension } from "@codemirror/state";
|
||||
import { Plugin } from "obsidian";
|
||||
|
||||
interface Color {
|
||||
|
@ -7,12 +8,17 @@ interface Color {
|
|||
}
|
||||
|
||||
export default class SVGView extends Plugin {
|
||||
private ext: Extension[];
|
||||
|
||||
async onload() {
|
||||
this.registerMarkdownPostProcessor((element, context) => {
|
||||
console.log("Loading SVG-Obsidian.");
|
||||
|
||||
this.registerMarkdownPostProcessor((element, _context) => {
|
||||
const images = element.querySelectorAll("img");
|
||||
|
||||
images.forEach((item) => {
|
||||
if (!item.src.startsWith("data:image/svg+xml")) {
|
||||
for (let index = 0; index < images.length; index++) {
|
||||
const item = images.item(index);
|
||||
if (!item.src.contains(".svg")) {
|
||||
// Exclude image who aren't SVG
|
||||
return;
|
||||
}
|
||||
|
@ -76,9 +82,10 @@ export default class SVGView extends Plugin {
|
|||
filter: "invert(1)",
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onunload() {}
|
||||
/* this.ext = ?? */
|
||||
this.registerEditorExtension([this.ext]);
|
||||
}
|
||||
}
|
Reference in a new issue