diff --git a/README.md b/README.md index c80df13..84b5f9c 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,11 @@ # Swarnam -A no-frills web code blocks plugin for Obsidian. +A no-frills web playground plugin for Obsidian. ## Usage Install the extension from Obsidian community plugins list (you need to enable this first from -Settings). +Settings), enable the plugin and then restart Obsidian. To create a new Swarnam block, you need to open a block code snippet and give it the `swarnam` tag like so: diff --git a/main.ts b/main.ts index 846b096..5130554 100644 --- a/main.ts +++ b/main.ts @@ -2,90 +2,6 @@ import { Plugin } from "obsidian"; const PREFIX = "swarnam"; -const SWARNAM_CSS = ` -.swarnam-root { - --${PREFIX}-html-color: #e34c26; - --${PREFIX}-css-color: #2965f1; - --${PREFIX}-js-color: #f0db4f; - --${PREFIX}-box-padding: var(--size-4-3) var(--size-4-4); - --${PREFIX}-border-color: var(--divider-color); - --${PREFIX}-border-radius: var(--code-radius); - --${PREFIX}-source-font: var(--font-monospace); - --${PREFIX}-source-font-size: var(--code-size); - - display: flex; - align-items: stretch; - width: 100%; -} - -.swarnam-root.error { - display: block; - padding: var(--${PREFIX}-box-padding); - background-color: var(--code-background); - text-align: center; - - .icon { - font-family: "Apple Emoji Color", sans-serif; - font-size: 1.5em; - } -} - -.swarnam-source-root { - flex: 1 1 0; - overflow-x: scroll; - display: flex; - align-items: stretch; - flex-direction: column; -} - -.swarnam-preview { - flex: 1 1 0; - border: 1px solid var(--${PREFIX}-border-color); - border-left: 0; - border-top-right-radius: var(--${PREFIX}-border-radius); - border-bottom-right-radius: var(--${PREFIX}-border-radius); - padding: var(--${PREFIX}-box-padding); -} - -.swarnam-source-container { - position: relative; - flex: 1 1 0; - - & + & { - border-top: 1px solid var(--${PREFIX}-border-color); - border-top-left-radius: 0; - border-top-right-radius: 0; - } -} - -.markdown-rendered .swarnam-source { - height: 100%; - margin: 0; - font-family: var(--${PREFIX}-source-font); - font-size: var(--${PREFIX}-source-font-size); - white-space: pre; -} - -.swarnam-badge { - position: absolute; - top: calc(var(--size-4-3) / 1.5); - right: calc(var(--size-4-3) / 1.5); - font-size: 0.65em; -} - -.swarnam-html-badge { - color: var(--${PREFIX}-html-color); -} - -.swarnam-css-badge { - color: var(--${PREFIX}-css-color); -} - -.swarnam-js-badge { - color: var(--${PREFIX}-js-color); -} -`; - function base64ToBytes(base64: string) { const binString = atob(base64); // @ts-expect-error @@ -118,7 +34,7 @@ function getIframeDoc(htmlSource: string, cssSource: string, jsSource: string) { -
+
${htmlSource}