autumnnote 2.1.0 → 2.3.0
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/README.md +74 -6
- package/dist/autumnnote.cjs +27 -22
- package/dist/autumnnote.es.js +474 -591
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.min.js +27 -22
- package/dist/autumnnote.umd.js +27 -22
- package/dist/autumnnote.umd.js.map +1 -1
- package/dist/icon-data-V0Xqv-wX.js +255 -0
- package/dist/icon-data-V0Xqv-wX.js.map +1 -0
- package/package.json +12 -3
- package/types/index.d.ts +8 -0
- package/src/js/Context.js +0 -854
- package/src/js/core/detectLang.js +0 -98
- package/src/js/core/dom.js +0 -372
- package/src/js/core/env.js +0 -38
- package/src/js/core/key.js +0 -66
- package/src/js/core/lists.js +0 -121
- package/src/js/core/markdown.js +0 -695
- package/src/js/core/range.js +0 -194
- package/src/js/core/sanitise.js +0 -304
- package/src/js/editing/History.js +0 -266
- package/src/js/editing/Style.js +0 -812
- package/src/js/editing/Table.js +0 -105
- package/src/js/editing/Typing.js +0 -397
- package/src/js/index.js +0 -193
- package/src/js/index.umd.js +0 -17
- package/src/js/module/AutoSaveRestore.js +0 -125
- package/src/js/module/BaseDialog.js +0 -133
- package/src/js/module/BaseMediaTooltip.js +0 -142
- package/src/js/module/BaseResizer.js +0 -322
- package/src/js/module/BubbleToolbar.js +0 -483
- package/src/js/module/Buttons.js +0 -399
- package/src/js/module/Clipboard.js +0 -579
- package/src/js/module/CodeTooltip.js +0 -493
- package/src/js/module/Codeview.js +0 -125
- package/src/js/module/ContextMenu.js +0 -621
- package/src/js/module/Editor.js +0 -747
- package/src/js/module/EmojiDialog.js +0 -254
- package/src/js/module/FindReplace.js +0 -512
- package/src/js/module/Fullscreen.js +0 -80
- package/src/js/module/IconDialog.js +0 -618
- package/src/js/module/ImageCropOverlay.js +0 -586
- package/src/js/module/ImageDialog.js +0 -193
- package/src/js/module/ImageResizer.js +0 -42
- package/src/js/module/ImageTooltip.js +0 -285
- package/src/js/module/LinkDialog.js +0 -145
- package/src/js/module/LinkTooltip.js +0 -250
- package/src/js/module/MarkdownShortcuts.js +0 -250
- package/src/js/module/Mention.js +0 -365
- package/src/js/module/Placeholder.js +0 -51
- package/src/js/module/ShortcutsDialog.js +0 -111
- package/src/js/module/SlashMenu.js +0 -376
- package/src/js/module/Statusbar.js +0 -246
- package/src/js/module/TableTooltip.js +0 -1392
- package/src/js/module/Toolbar.js +0 -855
- package/src/js/module/VideoDialog.js +0 -193
- package/src/js/module/VideoResizer.js +0 -66
- package/src/js/module/VideoTooltip.js +0 -248
- package/src/js/module/emoji-data.js +0 -496
- package/src/js/module/table-grid.js +0 -102
- package/src/js/module/table-icons.js +0 -33
- package/src/js/renderer.js +0 -120
- package/src/js/settings.js +0 -214
- package/src/styles/_variables.scss +0 -48
- package/src/styles/autumnnote.scss +0 -2877
package/README.md
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
[](https://opensource.org/licenses/MIT)
|
|
12
12
|
[](#)
|
|
13
13
|
[](types/index.d.ts)
|
|
14
|
+
[](https://www.npmjs.com/package/autumnnote#provenance)
|
|
14
15
|
|
|
15
16
|
A **zero-dependency WYSIWYG rich-text editor** built with vanilla JavaScript (ES2022+) — no jQuery, no runtime dependencies. Lightweight alternative to Summernote, Quill, TinyMCE, Froala, CKEditor, ProseMirror, Trix, and Slate — with official React and Vue 3 wrappers.
|
|
16
17
|
|
|
@@ -105,7 +106,8 @@ Right-click inside the editor opens a context menu with: **Undo**, **Redo**, **C
|
|
|
105
106
|
- **Auto-save** — `autoSave: true` persists content to `localStorage` on every change; key configurable via `autoSaveKey`
|
|
106
107
|
- **Auto-save restore** — when `autoSave` and `autoSaveRestore` are both `true`, a dismissible banner prompts the user to restore or discard a previously saved draft on load; configurable age window via `autoSaveRestoreTimeout`
|
|
107
108
|
- **Bubble toolbar** — `bubbleToolbar: true` shows a compact floating toolbar above selected text; default buttons: bold, italic, underline, strikethrough, link, **text colour**, **highlight colour**, remove format, inline code; each colour button displays a live colour-strip indicator and opens an inline colour palette (matching the context menu); button set configurable via `bubbleToolbarItems`
|
|
108
|
-
- **Markdown shortcuts** — `markdownShortcuts: true` (default) converts Markdown syntax typed in the editor into HTML in real time: `# ` → H1–
|
|
109
|
+
- **Markdown shortcuts** — `markdownShortcuts: true` (default) converts Markdown syntax typed in the editor into HTML in real time: `# `–`###### ` → H1–H6, `> ` → blockquote, `- ` / `* ` / `+ ` → unordered list, `1. ` / `1) ` → ordered list, `[ ] ` / `[x] ` → checklist, `---` / `***` / `___` → HR, ` ``` ` / `~~~` → code block; inline: `**bold**`, `*italic*`, `~~strikethrough~~`, `` `code` ``. Rules are suppressed inside code blocks and code spans, where Markdown syntax is literal text
|
|
110
|
+
- **Markdown conversion** — `getMarkdown()` / `setMarkdown()` / `downloadMarkdown()` and `.md` file drop go through a CommonMark-leaning converter: fenced (` ``` ` and `~~~`, any fence length, indented) and 4-space indented code blocks, link and image titles, angle-bracket destinations, reference links, footnotes, GFM tables with or without outer pipes and with column alignment, task lists, character references, and a UTF-8 BOM. Markdown syntax appearing in ordinary prose is escaped on the way out, so text round-trips as text
|
|
109
111
|
- **Custom focus ring** — `focusColor` accepts any CSS colour string to override the default blue focus ring
|
|
110
112
|
- **Spellcheck** — browser spellcheck enabled by default (`spellcheck: true`)
|
|
111
113
|
|
|
@@ -118,13 +120,29 @@ Right-click inside the editor opens a context menu with: **Undo**, **Redo**, **C
|
|
|
118
120
|
- **TypeScript definitions** — bundled `types/index.d.ts` with full JSDoc coverage
|
|
119
121
|
- **@mention autocomplete** — type `@` (or any custom trigger) to open a floating dropdown backed by a user-supplied `onSearch` function (callback or `async`/Promise); inserts a non-editable mention chip; customisable chip HTML via `onInsert`
|
|
120
122
|
|
|
123
|
+
### Accessibility
|
|
124
|
+
- **Toolbar is a single tab stop** — it carries `role="toolbar"` and a roving tabindex, so keyboard users reach the text area with one Tab instead of stepping through every button. Left/Right move between controls and wrap at the ends, Home/End jump to the extremes, and the arrows reverse under `direction: 'rtl'`. Up/Down are left to `<select>` controls so they keep native value changing
|
|
125
|
+
- **Toggle state is announced** — buttons that track an active state (bold, italic, …) expose `aria-pressed`, not just a CSS class
|
|
126
|
+
- **Labelled controls** — every toolbar button carries a localised `aria-label`; the editable area is a `role="textbox"` with `aria-multiline`
|
|
127
|
+
- **Dialogs trap focus** — Tab and Shift+Tab cycle inside the open dialog, Escape closes it
|
|
128
|
+
- **Touch support** — image and video resize handles are driven by pointer events, so they work with mouse, touch and pen; handles get an enlarged transparent hit area
|
|
129
|
+
|
|
121
130
|
### Security
|
|
122
131
|
- All HTML (pasted content, `setHTML()`, or code-view output) passes through a DOM-based sanitiser that strips `<script>`, `<object>`, `<embed>`, and all `on*` event handler attributes
|
|
132
|
+
- **SVG animation elements are removed** (`<animate>`, `<set>`, `<animateTransform>`, `<animateMotion>`) — they can rewrite an attribute *after* sanitisation finishes, which otherwise lets `<svg><a><animate attributeName="href" values="javascript:…">` survive an attribute-level filter and still navigate on click
|
|
133
|
+
- **MathML HTML-integration points are removed** (`<mglyph>`, `<malignmark>`, `<annotation-xml>`) — they make the parser switch namespaces mid-tree, so a crafted fragment could re-parse into different markup than it serialised from (mXSS). Sanitising is a fixed point; ordinary formula markup is untouched
|
|
123
134
|
- `<iframe>` elements are permitted in `setHTML()` with src restricted to trusted CDN hosts; `srcdoc` is stripped
|
|
124
135
|
- Links use an HTTP(S)/`mailto:`/`tel:` allowlist; images additionally allow approved raster data URIs, while SVG data URIs are rejected
|
|
136
|
+
- **Every URL-bearing attribute is filtered**, not just `href`/`src`: `poster`, `background` and `srcset` are validated against the media allowlist (`srcset` candidate by candidate), and `ping` is stripped outright since its only effect is an outbound beacon
|
|
137
|
+
- **Inline styles are allowlisted by property**, and any value calling `url()`, `image-set()`, `src()`, `expression()` or `@import` is dropped so pasted content cannot phone home
|
|
125
138
|
- Clipboard paste sanitises rich content to remove XSS vectors before inserting
|
|
126
139
|
- `pasteStripAttributes` option strips `class`, `style`, and `data-*` from pasted HTML
|
|
127
140
|
|
|
141
|
+
Found a vulnerability? Please follow [SECURITY.md](SECURITY.md) rather than opening a public issue.
|
|
142
|
+
|
|
143
|
+
### Server-side rendering
|
|
144
|
+
The package is safe to `import` in a Node/SSR context — no module reads `document`, `window` or `navigator` at import time, so the React and Vue wrappers work under Next.js and Nuxt. Editors are only created when you call `create()` in the browser.
|
|
145
|
+
|
|
128
146
|
---
|
|
129
147
|
|
|
130
148
|
## Installation
|
|
@@ -402,7 +420,17 @@ See the [full Plugin API docs →](https://autumn.konexforge.com/docs.html#plugi
|
|
|
402
420
|
| `AutumnNote.create(selector, options?)` | Creates editor instance(s). `selector` can be a CSS string, `Element`, `NodeList`, or `Element[]`. Returns a `Context` or `Context[]`. |
|
|
403
421
|
| `AutumnNote.destroy(selector)` | Destroys editor(s) and restores the original element. |
|
|
404
422
|
| `AutumnNote.getInstance(selector)` | Returns the `Context` for a given element, or `null`. |
|
|
405
|
-
| `AutumnNote.defaults` |
|
|
423
|
+
| `AutumnNote.defaults` | Read-only snapshot of the current default options. |
|
|
424
|
+
| `AutumnNote.setDefaults(overrides)` | Merges options into the global defaults, applied to every future instance. |
|
|
425
|
+
| `AutumnNote.resetDefaults()` | Restores the global defaults to their factory values. |
|
|
426
|
+
| `AutumnNote.registerLocale(code, locale)` | Registers a locale so `lang: '<code>'` can select it. Only English ships in the ESM build — see [Languages](#languages). |
|
|
427
|
+
| `AutumnNote.registerModule(name, Class)` | Registers a custom module included in every future instance. |
|
|
428
|
+
| `AutumnNote.registerButton(btnDef)` | Adds a button to the global registry. Call `editor.invoke('toolbar.rebuild')` afterwards to render it on existing instances. |
|
|
429
|
+
| `AutumnNote.registerSlashCommand(command)` | Adds or replaces a slash-menu command for future instances. |
|
|
430
|
+
| `AutumnNote.use(plugin, options?)` | Installs a plugin globally — see [Plugin API](#plugin-api). |
|
|
431
|
+
| `AutumnNote.hasPlugin(name)` | Returns `true` if a plugin with that name is registered globally. |
|
|
432
|
+
| `AutumnNote.buttons` | All pre-built button definitions, reachable without named imports (UMD/CJS). |
|
|
433
|
+
| `AutumnNote.version` | The library version string. |
|
|
406
434
|
|
|
407
435
|
### Context (instance methods)
|
|
408
436
|
|
|
@@ -431,7 +459,8 @@ See the [full Plugin API docs →](https://autumn.konexforge.com/docs.html#plugi
|
|
|
431
459
|
| `editor.focus()` | Moves keyboard focus to the editable area. |
|
|
432
460
|
| `editor.blur()` | Removes keyboard focus from the editable area. |
|
|
433
461
|
| `editor.isFullscreen()` | Returns `true` if the editor is currently in fullscreen mode. |
|
|
434
|
-
| `editor.destroy()` | Removes the editor, disposes all modules, and restores the original element. |
|
|
462
|
+
| `editor.destroy()` | Removes the editor, disposes all modules, and restores the original element. Returns a promise that settles once the closing auto-save has finished, so `await editor.destroy()` is meaningful with an async `autoSaveAdapter`. |
|
|
463
|
+
| `editor.updateOptions(partial)` | Merges options into a live instance. Modules gated behind an option (`bubbleToolbar`, `mention`, `slashMenu`, `markdownShortcuts`, `autoSaveRestore`) are started or torn down to match. |
|
|
435
464
|
| `editor.on(event, fn)` | Subscribes to an editor event. Returns an unsubscribe function. |
|
|
436
465
|
| `editor.off(event, fn)` | Removes a previously registered listener. |
|
|
437
466
|
| `editor.invoke('module.method', ...args)` | Calls any registered module method by dot-separated name. |
|
|
@@ -471,6 +500,8 @@ See the [full Plugin API docs →](https://autumn.konexforge.com/docs.html#plugi
|
|
|
471
500
|
| `toolbarButtonClass` | `string` | `'btn btn-sm btn-light'` | CSS classes for toolbar buttons when `useBootstrap` is `true`. |
|
|
472
501
|
| `useFontAwesome` | `boolean` | `true` | Use FA icons when FontAwesome is detected on the page. |
|
|
473
502
|
| `fontAwesomeClass` | `string` | `'fas'` | FA prefix: `'fas'` for FA 5, `'fa-solid'` for FA 6. |
|
|
503
|
+
| `fontAwesomeAutoInject` | `boolean` | `true` | Let the icon dialog pull Font Awesome CSS from a CDN when the page has none. Set `false` under a strict CSP or offline. |
|
|
504
|
+
| `fontAwesomeCDN` | `string` | cdnjs FA 6.5.2 | Stylesheet URL for that injection — point it at a self-hosted copy to keep the request first-party. |
|
|
474
505
|
| `pasteAsPlainText` | `boolean` | `false` | Strip all formatting when pasting. |
|
|
475
506
|
| `pasteCleanHTML` | `boolean` | `true` | Sanitise HTML on paste. |
|
|
476
507
|
| `pasteStripAttributes` | `boolean` | `false` | Strip `class`, `style`, and `data-*` attributes from pasted HTML. |
|
|
@@ -684,7 +715,8 @@ src/
|
|
|
684
715
|
│ │ ├── func.js General helpers (mergeDeep, debounce, ...)
|
|
685
716
|
│ │ ├── key.js Keyboard key constants
|
|
686
717
|
│ │ ├── lists.js Array helpers
|
|
687
|
-
│ │ ├── env.js Browser/platform detection
|
|
718
|
+
│ │ ├── env.js Browser/platform detection (lazy — SSR-safe)
|
|
719
|
+
│ │ ├── detectLang.js Code-block language detection for Prism highlighting
|
|
688
720
|
│ │ ├── markdown.js Bidirectional HTML ↔ Markdown conversion (with GFM checklists)
|
|
689
721
|
│ │ └── sanitise.js DOM-based HTML and URL sanitiser
|
|
690
722
|
│ ├── editing/
|
|
@@ -693,6 +725,9 @@ src/
|
|
|
693
725
|
│ │ ├── Table.js Table creation and cell manipulation
|
|
694
726
|
│ │ └── Typing.js Tab/Enter/ArrowKey behaviour and FA icon caret handling
|
|
695
727
|
│ ├── module/
|
|
728
|
+
│ │ ├── BaseDialog.js Shared dialog shell (focus trap, drag, Escape)
|
|
729
|
+
│ │ ├── BaseResizer.js Shared pointer-driven resize overlay (image + video)
|
|
730
|
+
│ │ ├── BaseMediaTooltip.js Shared show/hide timing for media tooltips
|
|
696
731
|
│ │ ├── Editor.js Core editing commands, getHTML/setHTML, sanitiser
|
|
697
732
|
│ │ ├── Toolbar.js Toolbar UI, button rendering (SVG + FA), dropdowns, colour picker
|
|
698
733
|
│ │ ├── Buttons.js Button/dropdown/colorpicker definitions and defaultToolbar
|
|
@@ -712,15 +747,23 @@ src/
|
|
|
712
747
|
│ │ ├── VideoDialog.js Video embed dialog (YouTube, Vimeo, direct file)
|
|
713
748
|
│ │ ├── VideoTooltip.js Floating toolbar for video embeds (edit/delete)
|
|
714
749
|
│ │ ├── VideoResizer.js rAF-based drag handle to resize video embeds
|
|
715
|
-
│ │ ├── TableTooltip.js Floating toolbar for tables (row/col
|
|
750
|
+
│ │ ├── TableTooltip.js Floating toolbar for tables (row/col, merge, shade, sort, CSV)
|
|
751
|
+
│ │ ├── table-grid.js Colspan/rowspan geometry helpers (pure functions)
|
|
752
|
+
│ │ ├── table-icons.js Static SVG glyphs for the table tooltip
|
|
716
753
|
│ │ ├── CodeTooltip.js Floating toolbar for code blocks (copy/delete)
|
|
717
754
|
│ │ ├── EmojiDialog.js Unicode emoji picker (~380 emoji, 7 categories)
|
|
755
|
+
│ │ ├── emoji-data.js Emoji catalogue — a separate chunk, loaded on first open
|
|
718
756
|
│ │ ├── IconDialog.js FontAwesome icon picker (FA 6 Free Solid, 8 categories)
|
|
719
757
|
│ │ ├── ShortcutsDialog.js Keyboard shortcuts reference dialog (Shift+?)
|
|
720
758
|
│ │ ├── BubbleToolbar.js Mini floating toolbar above text selection
|
|
759
|
+
│ │ ├── SlashMenu.js Slash-command menu (`/` opens a block/insert palette)
|
|
721
760
|
│ │ ├── MarkdownShortcuts.js Inline Markdown-to-HTML input rules
|
|
722
761
|
│ │ ├── AutoSaveRestore.js Draft restore banner for localStorage drafts
|
|
723
762
|
│ │ └── Mention.js @mention autocomplete with floating dropdown
|
|
763
|
+
│ ├── i18n/
|
|
764
|
+
│ │ ├── index.js Locale registry (resolveLocale, registerLocale)
|
|
765
|
+
│ │ ├── all.js Registers all eight locales — imported by the UMD build only
|
|
766
|
+
│ │ └── en.js, vi.js, … One file per locale, importable as `autumnnote/i18n/<code>`
|
|
724
767
|
│ ├── Context.js Editor instance hub: module registry and event bus
|
|
725
768
|
│ ├── settings.js Default options (AsnOptions)
|
|
726
769
|
│ ├── renderer.js DOM layout builder
|
|
@@ -828,6 +871,8 @@ AutumnNote.create('#editor', { lang: { toolbar: { bold: 'Vet' } } });
|
|
|
828
871
|
|
|
829
872
|
The table below compares Autumn Note against popular WYSIWYG editors: **Summernote**, **Quill**, and **TinyMCE**. Comparison is based on publicly documented feature sets.
|
|
830
873
|
|
|
874
|
+
The last two rows were measured rather than read off documentation, against `summernote@0.9.1`, `quill@2.0.3` and `tinymce@8.8.2`: a bare `await import('<pkg>')` in Node throws `document is not defined`, `self is not defined` and `window is not defined` respectively, and `npm view <pkg> dist.attestations` returns nothing for all three.
|
|
875
|
+
|
|
831
876
|
| Feature | Summernote | Quill | TinyMCE | **Autumn Note** |
|
|
832
877
|
|---|---|---|---|---|
|
|
833
878
|
| jQuery dependency | Required | Required | Optional | **None** |
|
|
@@ -861,9 +906,32 @@ The table below compares Autumn Note against popular WYSIWYG editors: **Summerno
|
|
|
861
906
|
| Custom colour swatches | No | No | No | **Yes** |
|
|
862
907
|
| Code view (HTML source) | No | Yes | Yes | **Yes (sanitised)** |
|
|
863
908
|
| Syntax highlighting | No | No | Partial | **Yes (Prism.js via CDN)** |
|
|
909
|
+
| Keyboard-navigable toolbar | No | Partial | Yes | **Yes (ARIA toolbar pattern)** |
|
|
910
|
+
| Bare `import` under SSR | No | No | No | **Yes** |
|
|
911
|
+
| npm provenance attestation | No | No | No | **Yes (OIDC + SLSA)** |
|
|
912
|
+
|
|
913
|
+
---
|
|
914
|
+
|
|
915
|
+
## Contributing
|
|
916
|
+
|
|
917
|
+
Contributions are welcome. Please read [CONTRIBUTING.md](CONTRIBUTING.md) for the development setup, coding conventions and PR checklist, and note that this project follows a [Code of Conduct](CODE_OF_CONDUCT.md).
|
|
918
|
+
|
|
919
|
+
| I want to… | Where to go |
|
|
920
|
+
|---|---|
|
|
921
|
+
| Report a bug | [Open a bug report](https://github.com/cmm-cmm/Autumn-Note/issues/new?template=bug_report.md) |
|
|
922
|
+
| Request a feature | [Open a feature request](https://github.com/cmm-cmm/Autumn-Note/issues/new?template=feature_request.md) |
|
|
923
|
+
| Ask a question / show what you built | [Discussions](https://github.com/cmm-cmm/Autumn-Note/discussions) |
|
|
924
|
+
| Report a security vulnerability | [SECURITY.md](SECURITY.md) — **not** a public issue |
|
|
925
|
+
| See what changed | [CHANGELOG.md](CHANGELOG.md) |
|
|
926
|
+
|
|
927
|
+
Before opening a PR, run the full gate — it is what CI runs:
|
|
928
|
+
|
|
929
|
+
```bash
|
|
930
|
+
pnpm check # lint, typecheck, coverage, 4 builds, wrapper tests, bundle budget, demo build
|
|
931
|
+
```
|
|
864
932
|
|
|
865
933
|
---
|
|
866
934
|
|
|
867
935
|
## License
|
|
868
936
|
|
|
869
|
-
[MIT](LICENSE)
|
|
937
|
+
[MIT](LICENSE) © Minh Pham
|