@jambotron/aria-markdown-editor 0.0.0-stage → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +100 -2
- package/fesm2022/jambotron-aria-markdown-editor.mjs +1122 -0
- package/fesm2022/jambotron-aria-markdown-editor.mjs.map +1 -0
- package/package.json +49 -3
- package/styles/aria-markdown-editor.scss +37 -0
- package/types/jambotron-aria-markdown-editor.d.ts +308 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Jambotron (https://jambotron.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,101 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @jambotron/aria-markdown-editor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Markdown editor for Angular, built on [Angular Aria](https://angular.dev/guide/aria/overview):
|
|
4
|
+
|
|
5
|
+
- source and live preview side by side; **Write / Preview tabs** on narrow screens (`ngTabs`)
|
|
6
|
+
- toolbar (`ngToolbar`, one Tab stop, arrow keys inside): heading, bold, italic, strikethrough, link, image, code,
|
|
7
|
+
code block, quote, bulleted / numbered / task lists, table, formula, horizontal line
|
|
8
|
+
- hotkeys Ctrl/⌘ + B, I, K, E; Enter continues a list, Enter on an empty item ends it; Ctrl+Z works (edits go
|
|
9
|
+
through the browser's undo)
|
|
10
|
+
- formulas `$…$` and `$$…$$` with **KaTeX loaded lazily** — not in your main bundle
|
|
11
|
+
- images: paste, drop or choose a file → your upload function → ``; or your own picker dialog
|
|
12
|
+
- forms: `[(value)]`, Signal Forms `[formField]`, `formControl`, `ngModel` (ControlValueAccessor)
|
|
13
|
+
- GitHub-flavoured Markdown (tables, task lists, strikethrough), HTML through Angular's sanitizer, SSR-safe
|
|
14
|
+
- `<jt-md-preview>` — the same rendering for read-only pages
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @jambotron/aria-markdown-editor @jambotron/aria-components marked katex
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Peer dependencies: Angular 22 (`core`, `common`, `forms`), `@angular/aria`, `@jambotron/aria-components` (icons; its theme fits too), `marked` ≥ 16. `katex` — only for formulas.
|
|
23
|
+
|
|
24
|
+
## Use
|
|
25
|
+
|
|
26
|
+
```ts
|
|
27
|
+
// app.config.ts
|
|
28
|
+
providers: [
|
|
29
|
+
provideJtMarkdown({ katex: () => import('katex').then(m => m.default) })
|
|
30
|
+
]
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
```scss
|
|
34
|
+
// styles.scss
|
|
35
|
+
@use '@jambotron/aria-markdown-editor/styles/aria-markdown-editor';
|
|
36
|
+
@use 'katex/dist/katex.min.css';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
@Component({
|
|
41
|
+
imports: [JtMdEditorComponent, JtMdPreviewComponent],
|
|
42
|
+
template: `
|
|
43
|
+
<jt-md-editor [(value)]="body" [uploadImage]="upload" placeholder="Write…" />
|
|
44
|
+
<jt-md-preview [markdown]="body()" />
|
|
45
|
+
`
|
|
46
|
+
})
|
|
47
|
+
export class ArticleEditor {
|
|
48
|
+
readonly body = signal('');
|
|
49
|
+
readonly upload = (file: File) => firstValueFrom(this.api.uploadImage(file)); // → url or { url, alt }
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
With Signal Forms: `<jt-md-editor [formField]="form.body" />`; reactive forms: `[formControl]`.
|
|
54
|
+
|
|
55
|
+
### Inputs of `jt-md-editor`
|
|
56
|
+
|
|
57
|
+
| Input | Default | |
|
|
58
|
+
| --- | --- | --- |
|
|
59
|
+
| `value` (model) | `''` | the Markdown text |
|
|
60
|
+
| `placeholder` | `''` | |
|
|
61
|
+
| `disabled`, `readonly` | `false` | readonly hides the toolbar |
|
|
62
|
+
| `label` | labels.editor | `aria-label` of the text area |
|
|
63
|
+
| `layout` | `'auto'` | `'split'`, `'tabs'`, or `'auto'` — tabs when the editor is narrower than 720px |
|
|
64
|
+
| `tools` | all | toolbar buttons in order, `'\|'` — separator |
|
|
65
|
+
| `uploadImage` | `null` | `(file: File) => Promise<string \| { url, alt? }>`; without it pasted / dropped files are ignored |
|
|
66
|
+
| `pickImage` | `null` | `() => Promise<{ url, alt? } \| null>` — the image button opens your dialog |
|
|
67
|
+
|
|
68
|
+
Height: CSS variable `--jt-md-editor-height` (420px).
|
|
69
|
+
|
|
70
|
+
### Markdown settings
|
|
71
|
+
|
|
72
|
+
`provideJtMarkdown({ katex, math, breaks, extensions })` — KaTeX loader, formulas on/off, single line breaks as
|
|
73
|
+
`<br>`, extra [marked extensions](https://marked.js.org/using_pro).
|
|
74
|
+
|
|
75
|
+
Text commands are exported as pure functions (`toggleWrap`, `toggleLines`, `insertLink`, `continueList`, …) —
|
|
76
|
+
usable with any `<textarea>`.
|
|
77
|
+
|
|
78
|
+
## Labels
|
|
79
|
+
|
|
80
|
+
English by default. Any language — a function, read on every change detection:
|
|
81
|
+
|
|
82
|
+
```ts
|
|
83
|
+
providers: [provideJtMdEditorLabels(() => ({ write: t('editor.write'), preview: t('editor.preview'), bold: t('editor.bold') }))]
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
## Theme
|
|
87
|
+
|
|
88
|
+
The same `--jt-*` tokens as `@jambotron/aria-grid` (defaults on `:where(:root)`, your values win), plus
|
|
89
|
+
`--jt-md-code-bg`, `--jt-md-hover-bg`, `--jt-md-editor-height`. See `styles/aria-markdown-editor.scss`.
|
|
90
|
+
|
|
91
|
+
## Develop
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
npm ci
|
|
95
|
+
npx ng test aria-markdown-editor --watch=false
|
|
96
|
+
npx ng serve playground # the editor on a page, library from source
|
|
97
|
+
npx ng build aria-markdown-editor # → dist/aria-markdown-editor
|
|
98
|
+
cd dist/aria-markdown-editor && npm publish
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
License: [MIT](LICENSE) © Jambotron. Made for and deployed on [jambotron.com](https://jambotron.com).
|