Compare commits

...

70 Commits
1.0.0 ... main

Author SHA1 Message Date
9dd05e2c2d
Update README.md 2024-04-10 21:06:14 +05:30
f00a020e4a
Update README 2024-04-10 21:03:59 +05:30
b817ad02d9
Update README 2024-04-10 20:57:24 +05:30
1c08b27e2e
Update minAppVersion 2024-04-10 20:34:22 +05:30
e22d203f7f
Updating funding url 2024-04-10 20:30:24 +05:30
98d096535c
Remove console.log 2024-04-10 20:29:33 +05:30
a8d46f559b
doc: add demo video 2024-04-05 05:19:51 +05:30
bc2903d34a doc: fix example snippet md 2024-04-05 05:13:02 +05:30
5eb0a1b5db ci: fix action permissions 2024-04-05 05:10:05 +05:30
1388b2dd53 chore: version bump 2024-04-05 05:04:57 +05:30
439fbee0c2 doc: center align? 2024-04-05 05:01:46 +05:30
bc2ab97b09 ci: add release action 2024-04-05 04:59:19 +05:30
be901f04b3 chore: add license 2024-04-05 04:45:36 +05:30
c8bf5ce49b doc: add icon credit 2024-04-05 04:41:46 +05:30
57596671f0 doc: add logo icon 2024-04-05 04:40:35 +05:30
d986e6b84f refactor: move styles out 2024-04-05 03:33:36 +05:30
bc89b3d9a2 feat: implement MVP version of Swarnam 2024-04-05 03:09:27 +05:30
Aleksey Rowan
e60294b950
Update manifest description (#77) 2023-11-15 12:17:04 -05:00
Lishid
7112f01bc6
Update README.md 2023-07-25 15:17:26 -04:00
Johannes Theiner
e8f03522bc
Adapt to plugin guidelines (#65)
- remove header in settings
- remove logging of changed settings value
2023-07-17 12:36:25 -04:00
Erica Xu
9be2b5d748
Update manifest.json 2023-07-11 11:37:36 -04:00
Alexander Pozdneev
2aee08d3d5
Remove old info about styles.css (#56) 2023-05-01 14:48:46 -04:00
Tim Rogers
0b5e5a2f6e
Upgrade esbuild to v0.17.x (#47) 2023-01-25 13:49:50 -05:00
INOUE Takuya
49fba8aa1f
fix .eslintignore (#48) 2023-01-19 10:06:51 -05:00
Erica Xu
747672e2f8
Merge pull request #42 from obsidianmd/funding-url
Add funding URL documentation
2022-12-05 15:57:04 -05:00
Erica Xu
d3bb1e6775
Update README.md 2022-12-05 15:55:39 -05:00
Erica Xu
b376f9c428
Add funding URL documentation 2022-12-05 15:49:16 -05:00
Erica Xu
97d84bc54b
Update manifest.json 2022-12-05 15:28:53 -05:00
lishid
866d3b8f0d Build: Target ES2018. 2022-08-20 20:25:17 -04:00
lishid
64e8649877 Update sample css file. 2022-08-09 13:39:02 -04:00
lishid
b46f6c9322 Update for 0.15 2022-08-09 13:38:50 -04:00
lishid
04432b2ebf Upgrade dependencies, add strictNullChecks. 2022-06-24 15:41:39 -04:00
Lishid
00967d9040
Update esbuild.config.mjs 2022-06-19 20:50:11 -04:00
Henré Botha
f85d2b74b5
Fix README headings (#29) 2022-05-07 11:15:23 -04:00
Xiao Meng
f690c04577
use LF instead of CRLF (#28) 2022-04-15 14:13:31 -04:00
Lishid
24918c946d
Update README.md 2022-04-04 22:20:58 -04:00
lishid
af0d47c19c Always use latest obsidian package. 2022-03-09 10:29:32 -05:00
Lishid
43a3b5eaeb
Update package.json 2022-02-24 00:17:16 -05:00
pseudometa
4b06e44f8f
Update .gitignore (#25) 2022-01-28 10:34:53 -05:00
aidenlx
f3286063d3
add version bump script (#10) 2022-01-22 16:13:50 -05:00
Federico Granata
4f502e92eb
Update README.md (#24) 2022-01-21 11:15:02 -05:00
Federico Granata
67e05fe677
remove package-lock.json from .gitignore (#23) 2022-01-21 11:14:49 -05:00
fyears
fe035a3008
add type check (#22) 2022-01-16 10:07:19 -05:00
lishid
a25092b586 Update esbuild script to include codemirror packages as external. 2022-01-10 09:01:38 -05:00
lishid
d006ed755a Update tsconfig. 2021-11-06 19:05:49 -04:00
lishid
db18a36e65 Update build script to include external node packages. 2021-11-01 15:18:11 -04:00
TfTHacker
6fdd374cb8
Adding eslint for code .\src\ (#17) 2021-10-30 14:04:07 -04:00
Phillip
02ac033b15
Use ESBuild API instead of passing command line arguments (#16) 2021-10-25 11:45:15 -04:00
lishid
e013825c21 Add comment for gitignore. 2021-10-23 04:58:40 -04:00
lishid
3afc9d78ab Update sample plugin to use ESBuild. 2021-10-19 13:34:58 -04:00
fyears
5f95bce9e1 preserve and load settings correctly 2021-10-10 11:11:02 -04:00
Tokuhiro Matsuno
c228a70223 Add data.json to .gitignore
Prevent unintended disclosure of data.json.
2021-04-28 11:54:41 -04:00
lishid
3b38a36a07 Upgrade dependencies. 2021-04-23 17:01:55 -04:00
GitMurf
26721337a7 Update README - Obsidian API update instructions
Add the following to the "First time developing plugins?" section:

For updates to the Obsidian API run `npm update` in the command line under your repo folder.
2021-04-23 16:59:52 -04:00
lishid
f3f000a6b2 Update dependencies. 2021-04-12 19:06:03 -04:00
lishid
e1efb17322 Rollup: Don't include source code in distribution. 2021-04-06 08:48:36 -04:00
Maciej Beimcik
123b00ca52 a note regarding "use this template" button
This button is not visible if you are not logged in to GitHub.
It may be a bit confusing for first-timers so I suggest the note to be added
2021-03-09 16:17:18 -05:00
Konstantin
5355e3337e Update README.md
fix one little misstype
2021-03-07 20:54:45 -05:00
Clemens Ertle
00cf028cc3 add banner to bundle 2021-03-04 16:18:09 -05:00
Lishid
ceb3837850
Update README.md 2021-03-01 12:59:44 -05:00
lishid
ed0e0a6e90 Target ES6. 2021-01-31 12:55:17 -05:00
lishid
ae30a5a418 Update best practice for settings. 2021-01-24 15:41:47 -05:00
lishid
cfe4d17ce7 Add example for settings. 2020-12-22 11:24:00 -05:00
lishid
318cb2b055 Added versions.json 2020-11-10 02:52:56 -05:00
lishid
9162f82010 Removed init. 2020-10-29 21:41:47 -04:00
lishid
6e8aab9616 Add more examples for hooks. 2020-10-29 18:02:57 -04:00
lishid
99f4035214 Add example for modifying CodeMirror. 2020-10-29 17:36:03 -04:00
lishid
2d6aebfe0a Update manifest.json 2020-10-28 21:33:32 -04:00
lishid
26d068d237 Update readme. 2020-10-28 21:13:03 -04:00
lishid
08add6702a Update readme. 2020-10-28 20:48:24 -04:00
19 changed files with 2805 additions and 176 deletions

10
.editorconfig Normal file
View File

@ -0,0 +1,10 @@
# top-most EditorConfig file
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
tab_width = 4

3
.eslintignore Normal file
View File

@ -0,0 +1,3 @@
node_modules/
main.js

23
.eslintrc Normal file
View File

@ -0,0 +1,23 @@
{
"root": true,
"parser": "@typescript-eslint/parser",
"env": { "node": true },
"plugins": [
"@typescript-eslint"
],
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/eslint-recommended",
"plugin:@typescript-eslint/recommended"
],
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-unused-vars": "off",
"@typescript-eslint/no-unused-vars": ["error", { "args": "none" }],
"@typescript-eslint/ban-ts-comment": "off",
"no-prototype-builtins": "off",
"@typescript-eslint/no-empty-function": "off"
}
}

84
.github/workflows/release.yml vendored Normal file
View File

@ -0,0 +1,84 @@
name: Build obsidian plugin
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- "*" # Push events to matching any tag format, i.e. 1.0, 20.15.10
env:
PLUGIN_NAME: swarnam # Change this to the name of your plugin-id folder
jobs:
build:
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: "20.x"
- name: Build
id: build
run: |
npm i
npm run build
mkdir ${{ env.PLUGIN_NAME }}
cp main.js manifest.json styles.css ${{ env.PLUGIN_NAME }}
zip -r ${{ env.PLUGIN_NAME }}.zip ${{ env.PLUGIN_NAME }}
ls
echo "::set-output name=tag_name::$(git tag --sort version:refname | tail -n 1)"
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ github.ref }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: false
prerelease: false
- name: Upload zip file
id: upload-zip
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./${{ env.PLUGIN_NAME }}.zip
asset_name: ${{ env.PLUGIN_NAME }}-${{ steps.build.outputs.tag_name }}.zip
asset_content_type: application/zip
- name: Upload main.js
id: upload-main
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./main.js
asset_name: main.js
asset_content_type: text/javascript
- name: Upload manifest.json
id: upload-manifest
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./manifest.json
asset_name: manifest.json
asset_content_type: application/json
- name: Upload styles.css
id: upload-css
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./styles.css
asset_name: styles.css
asset_content_type: text/css

17
.gitignore vendored
View File

@ -1,11 +1,22 @@
# vscode
.vscode
# Intellij
*.iml
.idea
# npm
node_modules
package-lock.json
# build
# Don't include the compiled main.js file in the repo.
# They should be uploaded to GitHub releases instead.
main.js
*.js.map
# Exclude sourcemaps
*.map
# obsidian
data.json
# Exclude macOS Finder (System Explorer) View States
.DS_Store

1
.npmrc Normal file
View File

@ -0,0 +1 @@
tag-version-prefix=""

BIN
3dicons-co-icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 403 KiB

20
LICENSE.md Normal file
View File

@ -0,0 +1,20 @@
Copyright (c) 2024 Sangeeth Sudheer
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

View File

@ -1,22 +1,76 @@
## Obsidian Sample Plugin
This is a sample plugin for Obsidian (https://obsidian.md).
This project uses Typescript to provide type checking and documentation.
The repo contains the latest plugin API (obsidian.d.ts) in Typescript Definition format, which contains TSDoc comments describing what it does.
**Note:** The Obsidian API is still in early alpha and is subject to change at any time!
### How to use
- Clone this repo.
- `npm i` or `yarn` to install dependencies
- `npm run dev` to start compilation in watch mode.
### How to install the plugin
- Copy over `main.js`, `styles.css`, `manifest.json` to your vault `vault/.obsidian/plugins/plugin-id/`.
### API Documentation
See https://github.com/obsidianmd/obsidian-api
<div align="center">
<img src="./3dicons-co-icon.png" height="60px">
# Swarnam
A no-frills web playground plugin for Obsidian. Inspired by [MDN playgrounds](https://developer.mozilla.org/en-US/docs/Web/CSS/grid).
<sup><i>Swarnam (സ്വർണം)</i> means <i>gold</i> in Malayalam.<br/></sup>
<sup>(icon credit: [3dicons](https://3dicons.co))</sup>
</div>
## Demo
https://github.com/runofthemillgeek/swarnam-obsidian/assets/2759499/333424b3-2f82-4c1e-9e50-68c837227433
## Usage
Install the extension from Obsidian community plugins list (you need to enable this first from
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:
```swarnam
<h1>Hello, world</h1>
```
When you preview this, it'll show the source and render the HTML side-by-side. You can hover on the
top-right and click the `</>` icon to edit the snippet to make some changes.
You can also add CSS and JS by separating them with `---*---` like so:
```swarnam
<h1 id="h1">Hello world</h1>
---*---
h1 {
font-family: "Manjari";
color: red;
animation: rainbow 5s ease infinite forwards;
}
@keyframes rainbow {
0% { filter: hue-rotate(0); }
100% { filter: hue-rotate(360deg); }
}
---*---
let i = 0;
setInterval(() => {
h1.textContent = `${["Hello", "Hola", "നമസ്കാരം"][i++ % 3]} Obsidian!`;
}, 1500)
```
This'll render the three snippets on the left side and show the preview of a web page that has all
these 3 blocks injected.
## How does it work
We split the code block snippet into 3 parts and form an HTML document string by injecting the CSS
and JS pieces into `<style>` and `<script>` tags. Once we have the final HTML document, we convert
this into Base64 and create a data URI. Finally, an `<iframe>` element is created and the data URI
is given as the `src`. Data URIs of mime type `text/html` and base64 enoding can be rendered by most
browsers including the Chromium renderer Obsidian is built on top of. There are no additional build
steps involved and thus, this is not a full-blown replacement for something like Sandpack.
## Contributing
Spot any issue? Have a feature request or idea? Feel free to create a new issue in GitHub to
discuss. (Pretty please do this before you spend your precious time on a PR that might not make into
this repo).

48
esbuild.config.mjs Normal file
View File

@ -0,0 +1,48 @@
import esbuild from "esbuild";
import process from "process";
import builtins from "builtin-modules";
const banner =
`/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
`;
const prod = (process.argv[2] === "production");
const context = await esbuild.context({
banner: {
js: banner,
},
entryPoints: ["main.ts"],
bundle: true,
external: [
"obsidian",
"electron",
"@codemirror/autocomplete",
"@codemirror/collab",
"@codemirror/commands",
"@codemirror/language",
"@codemirror/lint",
"@codemirror/search",
"@codemirror/state",
"@codemirror/view",
"@lezer/common",
"@lezer/highlight",
"@lezer/lr",
...builtins],
format: "cjs",
target: "es2018",
logLevel: "info",
sourcemap: prod ? false : "inline",
treeShaking: true,
outfile: "main.js",
});
if (prod) {
await context.rebuild();
process.exit(0);
} else {
await context.watch();
}

218
main.ts
View File

@ -1,77 +1,141 @@
import { App, Modal, Notice, Plugin, PluginSettingTab, Setting } from 'obsidian';
export default class MyPlugin extends Plugin {
onInit() {
}
onload() {
console.log('loading plugin');
this.addRibbonIcon('dice', 'Sample Plugin', () => {
new Notice('This is a notice!');
});
this.addStatusBarItem().setText('Status Bar Text');
this.addCommand({
id: 'open-sample-modal',
name: 'Open Sample Modal',
// callback: () => {
// console.log('Simple Callback');
// },
checkCallback: (checking: boolean) => {
let leaf = this.app.workspace.activeLeaf;
if (leaf) {
if (!checking) {
new SampleModal(this.app).open();
}
return true;
}
return false;
}
});
this.addSettingTab(new SampleSettingTab(this.app, this));
}
onunload() {
console.log('unloading plugin');
}
}
class SampleModal extends Modal {
constructor(app: App) {
super(app);
}
onOpen() {
let {contentEl} = this;
contentEl.setText('Woah!');
}
onClose() {
let {contentEl} = this;
contentEl.empty();
}
}
class SampleSettingTab extends PluginSettingTab {
display(): void {
let {containerEl} = this;
containerEl.empty();
containerEl.createEl('h2', {text: 'Settings for my awesome plugin.'});
new Setting(containerEl)
.setName('Setting #1')
.setDesc('It\'s a secret')
.addText(text => text.setPlaceholder('Enter your secret')
.setValue('')
.onChange((value) => {
console.log('Secret: ' + value);
}));
}
}
import { Plugin } from "obsidian";
const PREFIX = "swarnam";
function base64ToBytes(base64: string) {
const binString = atob(base64);
// @ts-expect-error
return Uint8Array.from(binString, (m) => m.codePointAt(0));
}
function bytesToBase64(bytes: Uint8Array) {
const binString = Array.from(bytes, (byte) =>
String.fromCodePoint(byte)
).join("");
return btoa(binString);
}
function asBase64(text: string) {
const b64 = bytesToBase64(new TextEncoder().encode(text));
return b64;
}
function getIframeDoc(htmlSource: string, cssSource: string, jsSource: string) {
const isDarkMode = window.matchMedia(
"(prefers-color-scheme: dark)"
).matches;
return `
<style>
body { font-family: sans-serif; color: ${isDarkMode ? "#fff" : "#000"} }
</style>
<style>
${cssSource}
</style>
<div class="${PREFIX}-html-container">
${htmlSource}
</div>
<script>
${jsSource}
</script>
`;
}
function showError(msg: string, root: HTMLElement) {
root.classList.add("error");
root.createEl("p", { cls: "icon", text: "⚠️" });
root.createEl("p", { text: msg });
}
export default class SwarnamPlugin extends Plugin {
async onload() {
this.registerMarkdownCodeBlockProcessor(
"swarnam",
(source, el, ctx) => {
const root = el.createDiv({ cls: `${PREFIX}-root` });
let [
htmlSource = "",
cssSource = "",
jsSource = "",
// eslint-disable-next-line prefer-const
...others
] = source.split(/^\s*---\*---\s*$/m);
if (others.length > 0) {
showError(
"Swarnam only supports HTML, CSS and JS blocks but your snippet has more than 3 blocks.",
root
);
return;
}
htmlSource = htmlSource.trim();
cssSource = cssSource.trim();
jsSource = jsSource.trim();
if (!htmlSource) {
showError(
"A Swarnam block must at least contain HTML",
root
);
return;
}
const sourceRoot = root.createDiv({
cls: `${PREFIX}-source-root`,
});
const htmlContainer = sourceRoot.createDiv({
cls: `${PREFIX}-source-container`,
});
const htmlEl = htmlContainer.createEl("pre", {
cls: `${PREFIX}-source ${PREFIX}-html-source`,
});
htmlContainer.createDiv({
text: "HTML",
cls: `${PREFIX}-badge ${PREFIX}-html-badge`,
});
htmlEl.setText(htmlSource);
if (cssSource) {
const cssContainer = sourceRoot.createDiv({
cls: `${PREFIX}-source-container`,
});
const cssEl = cssContainer.createEl("pre", {
cls: `${PREFIX}-source ${PREFIX}-css-source`,
});
cssContainer.createDiv({
text: "CSS",
cls: `${PREFIX}-badge ${PREFIX}-css-badge`,
});
cssEl.setText(cssSource);
}
if (jsSource) {
const jsContainer = sourceRoot.createDiv({
cls: `${PREFIX}-source-container`,
});
const jsEl = jsContainer.createEl("pre", {
cls: `${PREFIX}-source ${PREFIX}-js-source`,
});
jsContainer.createDiv({
text: "JS",
cls: `${PREFIX}-badge ${PREFIX}-js-badge`,
});
jsEl.setText(jsSource);
}
const iframeEl = root.createEl("iframe", {
cls: `${PREFIX}-preview`,
});
iframeEl.src = `data:text/html;base64;charset=UTF-8,${asBase64(
getIframeDoc(htmlSource, cssSource, jsSource)
)}`;
}
);
}
}

View File

@ -1,8 +1,11 @@
{
"id": "obsidian-sample-plugin",
"name": "Sample Plugin",
"version": "1.0.0",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"author": "Licat",
"isDesktopOnly": false
}
{
"id": "swarnam",
"name": "Swarnam",
"version": "1.0.1",
"minAppVersion": "1.5.12",
"description": "A no-frills web playground plugin for Obsidian.",
"author": "runofthemillgeek",
"authorUrl": "https://dg.sangeeth.dev",
"fundingUrl": "https://www.buymeacoffee.com/runofthemillgeek",
"isDesktopOnly": true
}

2229
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +1,24 @@
{
"name": "obsidian-sample-plugin",
"version": "0.9.7",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {
"dev": "rollup --config rollup.config.js -w",
"build": "rollup --config rollup.config.js"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"@rollup/plugin-commonjs": "^15.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"@rollup/plugin-typescript": "^6.0.0",
"@types/node": "^14.14.2",
"obsidian": "https://github.com/obsidianmd/obsidian-api/tarball/master",
"rollup": "^2.32.1",
"tslib": "^2.0.3",
"typescript": "^4.0.3"
}
"name": "obsidian-sample-plugin",
"version": "1.0.1",
"description": "This is a sample plugin for Obsidian (https://obsidian.md)",
"main": "main.js",
"scripts": {
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs && git add manifest.json versions.json"
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"@types/node": "^16.11.6",
"@typescript-eslint/eslint-plugin": "5.29.0",
"@typescript-eslint/parser": "5.29.0",
"builtin-modules": "3.3.0",
"esbuild": "0.17.3",
"obsidian": "latest",
"tslib": "2.4.0",
"typescript": "4.7.4"
}
}

View File

@ -1,19 +0,0 @@
import typescript from '@rollup/plugin-typescript';
import {nodeResolve} from '@rollup/plugin-node-resolve';
import commonjs from '@rollup/plugin-commonjs';
export default {
input: 'main.ts',
output: {
dir: '.',
sourcemap: 'inline',
format: 'cjs',
exports: 'default'
},
external: ['obsidian'],
plugins: [
typescript(),
nodeResolve({browser: true}),
commonjs(),
]
};

View File

@ -1,4 +1,81 @@
/* Sets all the text color to red! */
body {
color: red;
}
.swarnam-root {
--swarnam-html-color: #e34c26;
--swarnam-css-color: #2965f1;
--swarnam-js-color: #f0db4f;
--swarnam-box-padding: var(--size-4-3) var(--size-4-4);
--swarnam-border-color: var(--divider-color);
--swarnam-border-radius: var(--code-radius);
--swarnam-source-font: var(--font-monospace);
--swarnam-source-font-size: var(--code-size);
display: flex;
align-items: stretch;
width: 100%;
}
.swarnam-root.error {
display: block;
padding: var(--swarnam-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(--swarnam-border-color);
border-left: 0;
border-top-right-radius: var(--swarnam-border-radius);
border-bottom-right-radius: var(--swarnam-border-radius);
padding: var(--swarnam-box-padding);
}
.swarnam-source-container {
position: relative;
flex: 1 1 0;
& + & {
border-top: 1px solid var(--swarnam-border-color);
border-top-left-radius: 0;
border-top-right-radius: 0;
}
}
.markdown-rendered .swarnam-source {
height: 100%;
margin: 0;
font-family: var(--swarnam-source-font);
font-size: var(--swarnam-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(--swarnam-html-color);
}
.swarnam-css-badge {
color: var(--swarnam-css-color);
}
.swarnam-js-badge {
color: var(--swarnam-js-color);
}

View File

@ -1,22 +1,24 @@
{
"compilerOptions": {
"baseUrl": ".",
"inlineSourceMap": true,
"inlineSources": true,
"module": "ESNext",
"target": "es5",
"allowJs": true,
"noImplicitAny": true,
"moduleResolution": "node",
"importHelpers": true,
"lib": [
"dom",
"es5",
"scripthost",
"es2015"
]
},
"include": [
"**/*.ts"
]
}
{
"compilerOptions": {
"baseUrl": ".",
"inlineSourceMap": true,
"inlineSources": true,
"module": "ESNext",
"target": "ES6",
"allowJs": true,
"noImplicitAny": true,
"moduleResolution": "node",
"importHelpers": true,
"isolatedModules": true,
"strictNullChecks": true,
"lib": [
"DOM",
"ES5",
"ES6",
"ES7"
]
},
"include": [
"**/*.ts"
]
}

14
version-bump.mjs Normal file
View File

@ -0,0 +1,14 @@
import { readFileSync, writeFileSync } from "fs";
const targetVersion = process.env.npm_package_version;
// read minAppVersion from manifest.json and bump version to target version
let manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
const { minAppVersion } = manifest;
manifest.version = targetVersion;
writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t"));
// update versions.json with target version and minAppVersion from manifest.json
let versions = JSON.parse(readFileSync("versions.json", "utf8"));
versions[targetVersion] = minAppVersion;
writeFileSync("versions.json", JSON.stringify(versions, null, "\t"));

4
versions.json Normal file
View File

@ -0,0 +1,4 @@
{
"1.0.0": "0.15.0",
"1.0.1": "0.15.0"
}