Skip to content

Commit

Permalink
v0.0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
LucaRickli committed Aug 25, 2023
1 parent fb9efc1 commit c0d67c8
Show file tree
Hide file tree
Showing 11 changed files with 297 additions and 190 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ name: Build & Deploy static content to Pages
on:
# Runs on pushes targeting the default branch
push:
branches: ["main"]
branches: ['main']
paths-ignore:
- "README.md"
- ".github/**"
- 'README.md'
- '.github/**'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -21,7 +21,7 @@ permissions:
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
group: 'pages'
cancel-in-progress: false

jobs:
Expand All @@ -44,16 +44,16 @@ jobs:
run: |
npm ci
npm run build:pages
- name: Setup Pages
uses: actions/configure-pages@v3

- name: Upload artifact
uses: actions/upload-pages-artifact@v2
with:
# Upload entire repository
path: './dist'

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node.js emvironment
uses: actions/setup-node@v3
with:
node-version: 18.x
registry-url: 'https://registry.npmjs.org'

- name: Install dependencies
run: npm ci

- name: Build package
run: npm run build

- name: Publish package
run: npm publish --access=public
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ node_modules
dist
dist-ssr
*.local
docs

# Editor directories and files
.vscode/*
Expand Down
8 changes: 8 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"semi": false,
"tabWidth": 2,
"singleQuote": true,
"printWidth": 100,
"trailingComma": "none"
}
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,29 +32,29 @@ declare class InlineEditor {
constructor({
target,
markdown,
parse,
parse
}: {
target: HTMLElement | Element | Document | ShadowRoot;
markdown: string;
parse: (md: string) => string;
});
target: HTMLElement | Element | Document | ShadowRoot
markdown: string
parse: (md: string) => string
})

get changesMade(): boolean;
get changesMade(): boolean

get markdown(): string;
get markdown(): string

cleanup(save?: boolean): void;
cleanup(save?: boolean): void
}
```

### Example

```ts
import { InlineEditor } from "@lucarickli/mdie";
import { InlineEditor } from '@lucarickli/mdie'

const editor = new InlineEditor({
target: document.body,
markdown: `# Hello world`,
parse: (md) => marked.parse(md), // 3rd party library
});
parse: (md) => marked.parse(md) // 3rd party library
})
```
17 changes: 9 additions & 8 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
Expand All @@ -25,17 +25,18 @@
<body>
<div id="app"></div>
<script type="module">
import { InlineEditor } from "./src/main.ts";
import { marked } from "marked";
import Mdie from './src/main.ts'
import { marked } from 'marked'

try {
const editor = new InlineEditor({
target: document.querySelector("#app"),
const editor = new Mdie({
target: document.querySelector('#app'),
parse: (md) => marked.parse(md), // 3rd party library
markdown: `# MDIE *Markdown inline editor*\n\nHere is a sample of some basic Markdown syntax.\n \n## Headings\n\nThe following HTML \`<h1>\`—\`<h6>\` elements represent six levels of section headings. \`<h1>\` is the highest section level while \`<h6>\` is the lowest.\n\n# H1\n\n## H2\n\n### H3\n\n#### H4\n\n##### H5\n\n###### H6\n\n## Paragraph\n\nXerum, quo qui aut unt expliquam qui dolut labo. Aque venitatiusda cum, voluptionse latur sitiae dolessi aut parist aut dollo enim qui voluptate ma dolestendit peritin re plis aut quas inctum laceat est volestemque commosa as cus endigna tectur, offic to cor sequas etum rerum idem sintibus eiur? Quianimin porecus evelectur, cum que nis nust voloribus ratem aut omnimi, sitatur? Quiatem. Nam, omnis sum am facea corem alique molestrunt et eos evelece arcillit ut aut eos eos nus, sin conecerem erum fuga. Ri oditatquam, ad quibus unda veliamenimin cusam et facea ipsamus es exerum sitate dolores editium rerore eost, temped molorro ratiae volorro te reribus dolorer sperchicium faceata tiustia prat.\n\nItatur? Quiatae cullecum rem ent aut odis in re eossequodi nonsequ idebis ne sapicia is sinveli squiatum, core et que aut hariosam ex eat.\n\n## Images\n\n![This is a placeholder image description](/example.jpg)\n\n## Blockquotes\n\nThe blockquote element represents content that is quoted from another source, optionally with a citation which must be within a \`footer\` or \`cite\` element, and optionally with in-line changes such as annotations and abbreviations.\n\n#### Blockquote without attribution\n\n> Tiam, ad mint andaepu dandae nostion secatur sequo quae. \n> **Note** that you can use _Markdown syntax_ within a blockquote.\n\n#### Blockquote with attribution\n\n> Don't communicate by sharing memory, share memory by communicating.<br>\n> — <cite>Rob Pike[^1]</cite>\n\n[^1]: The above quote is excerpted from Rob Pike's [talk](https://www.youtube.com/watch?v=PAAkCSZUG1c) during Gopherfest, November 18, 2015.\n\n## Tables\n\n| Italics | Bold | Code |\n| --------- | -------- | ------ |\n| _italics_ | **bold** | \`code\` |\n\n## Code Blocks\n\n\`\`\`html\n<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <title>Example HTML5 Document</title>\n </head>\n <body>\n <p>Test</p>\n </body>\n</html>\n\`\`\`\n\n## List Types\n\n#### Ordered List\n\n1. First item\n2. Second item\n3. Third item\n\n#### Unordered List\n\n- List item\n- Another item\n- And another item\n\n#### Nested list\n\n- Fruit\n - Apple\n - Orange\n - Banana\n- Dairy\n - Milk\n - Cheese\n\n## Other Elements — abbr, sub, sup, kbd, mark\n\n<abbr title="Graphics Interchange Format">GIF</abbr> is a bitmap image format.\n\nH<sub>2</sub>O\n\nX<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup>\n\nPress <kbd><kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>Delete</kbd></kbd> to end the session.\n\nMost <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures.\n`,
});
markdown: `# MDIE *Markdown inline editor*\n\nHere is a sample of some basic Markdown syntax.\n \n## Headings\n\nThe following HTML \`<h1>\`—\`<h6>\` elements represent six levels of section headings. \`<h1>\` is the highest section level while \`<h6>\` is the lowest.\n\n# H1\n\n## H2\n\n### H3\n\n#### H4\n\n##### H5\n\n###### H6\n\n## Paragraph\n\nXerum, quo qui aut unt expliquam qui dolut labo. Aque venitatiusda cum, voluptionse latur sitiae dolessi aut parist aut dollo enim qui voluptate ma dolestendit peritin re plis aut quas inctum laceat est volestemque commosa as cus endigna tectur, offic to cor sequas etum rerum idem sintibus eiur? Quianimin porecus evelectur, cum que nis nust voloribus ratem aut omnimi, sitatur? Quiatem. Nam, omnis sum am facea corem alique molestrunt et eos evelece arcillit ut aut eos eos nus, sin conecerem erum fuga. Ri oditatquam, ad quibus unda veliamenimin cusam et facea ipsamus es exerum sitate dolores editium rerore eost, temped molorro ratiae volorro te reribus dolorer sperchicium faceata tiustia prat.\n\nItatur? Quiatae cullecum rem ent aut odis in re eossequodi nonsequ idebis ne sapicia is sinveli squiatum, core et que aut hariosam ex eat.\n\n## Images\n\n![This is a placeholder image description](/example.jpg)\n\n## Blockquotes\n\nThe blockquote element represents content that is quoted from another source, optionally with a citation which must be within a \`footer\` or \`cite\` element, and optionally with in-line changes such as annotations and abbreviations.\n\n#### Blockquote without attribution\n\n> Tiam, ad mint andaepu dandae nostion secatur sequo quae. \n> **Note** that you can use _Markdown syntax_ within a blockquote.\n\n#### Blockquote with attribution\n\n> Don't communicate by sharing memory, share memory by communicating.<br>\n> — <cite>Rob Pike[^1]</cite>\n\n[^1]: The above quote is excerpted from Rob Pike's [talk](https://www.youtube.com/watch?v=PAAkCSZUG1c) during Gopherfest, November 18, 2015.\n\n## Tables\n\n| Italics | Bold | Code |\n| --------- | -------- | ------ |\n| _italics_ | **bold** | \`code\` |\n\n## Code Blocks\n\n\`\`\`html\n<!DOCTYPE html>\n<html lang="en">\n <head>\n <meta charset="utf-8" />\n <title>Example HTML5 Document</title>\n </head>\n <body>\n <p>Test</p>\n </body>\n</html>\n\`\`\`\n\n## List Types\n\n#### Ordered List\n\n1. First item\n2. Second item\n3. Third item\n\n#### Unordered List\n\n- List item\n- Another item\n- And another item\n\n#### Nested list\n\n- Fruit\n - Apple\n - Orange\n - Banana\n- Dairy\n - Milk\n - Cheese\n\n## Other Elements — abbr, sub, sup, kbd, mark\n\n<abbr title="Graphics Interchange Format">GIF</abbr> is a bitmap image format.\n\nH<sub>2</sub>O\n\nX<sup>n</sup> + Y<sup>n</sup> = Z<sup>n</sup>\n\nPress <kbd><kbd>CTRL</kbd>+<kbd>ALT</kbd>+<kbd>Delete</kbd></kbd> to end the session.\n\nMost <mark>salamanders</mark> are nocturnal, and hunt for insects, worms, and other small creatures.\n`
})
} catch (err) {
alert(err);
alert(err)
throw err
}
</script>
</body>
Expand Down
96 changes: 94 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@
"dev": "vite",
"build": "tsc && vite build",
"build:pages": "tsc && vite build --config pages.vite.config.js",
"preview": "vite preview"
"typedoc": "typedoc src/main.ts",
"format": "prettier --write ."
},
"devDependencies": {
"marked": "^7.0.3",
"prettier": "^3.0.2",
"typedoc": "^0.24.8",
"typescript": "^5.0.2",
"vite": "^4.4.5",
"vite-plugin-dts": "^3.5.2"
Expand Down
6 changes: 3 additions & 3 deletions pages.vite.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from "vite";
import { defineConfig } from 'vite'

export default defineConfig({
base: "/mdie/",
});
base: '/mdie/'
})
Loading

0 comments on commit c0d67c8

Please sign in to comment.