autumnnote 1.2.1 → 1.4.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 +66 -10
- package/dist/autumnnote.es.js +463 -108
- package/dist/autumnnote.es.js.map +1 -1
- package/dist/autumnnote.umd.js +433 -91
- package/dist/autumnnote.umd.js.map +1 -1
- package/package.json +1 -1
- package/src/js/Context.js +64 -0
- package/src/js/core/dom.js +6 -3
- package/src/js/core/func.js +24 -13
- package/src/js/core/markdown.js +26 -8
- package/src/js/core/sanitise.js +57 -46
- package/src/js/editing/History.js +12 -1
- package/src/js/editing/Style.js +49 -21
- package/src/js/editing/Table.js +53 -13
- package/src/js/editing/Typing.js +9 -2
- package/src/js/i18n/de.js +1 -0
- package/src/js/i18n/en.js +1 -0
- package/src/js/i18n/es.js +1 -0
- package/src/js/i18n/fr.js +1 -0
- package/src/js/i18n/ja.js +1 -0
- package/src/js/i18n/ko.js +1 -0
- package/src/js/i18n/vi.js +1 -0
- package/src/js/i18n/zh.js +1 -0
- package/src/js/index.js +42 -2
- package/src/js/module/BubbleToolbar.js +26 -7
- package/src/js/module/Buttons.js +37 -0
- package/src/js/module/Clipboard.js +2 -2
- package/src/js/module/ContextMenu.js +1 -1
- package/src/js/module/FindReplace.js +6 -5
- package/src/js/module/ImageCropOverlay.js +46 -8
- package/src/js/module/ImageResizer.js +7 -0
- package/src/js/module/Mention.js +18 -4
- package/src/js/module/Statusbar.js +2 -1
- package/src/js/module/Toolbar.js +47 -2
- package/types/index.d.ts +54 -1
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ A modern, lightweight WYSIWYG rich-text editor built with vanilla JavaScript (ES
|
|
|
16
16
|
|
|
17
17
|
> Write rich text. No dependencies. No drama.
|
|
18
18
|
|
|
19
|
-
[Live Demo](https://cmm-cmm.github.io/Autumn-Note/)
|
|
19
|
+
[Live Demo](https://cmm-cmm.github.io/Autumn-Note/) · [Docs](https://cmm-cmm.github.io/Autumn-Note/docs.html) · [Playground](https://cmm-cmm.github.io/Autumn-Note/playground.html)
|
|
20
20
|
|
|
21
21
|
<p align="center"><img src="demo/Screenshot.png" alt="AutumnNote Screenshot"/></p>
|
|
22
22
|
|
|
@@ -27,14 +27,15 @@ A modern, lightweight WYSIWYG rich-text editor built with vanilla JavaScript (ES
|
|
|
27
27
|
1. [Features](#features)
|
|
28
28
|
2. [Installation](#installation)
|
|
29
29
|
3. [Quick Start](#quick-start)
|
|
30
|
-
4. [API](#api)
|
|
31
|
-
5. [
|
|
32
|
-
6. [
|
|
33
|
-
7. [
|
|
34
|
-
8. [
|
|
35
|
-
9. [
|
|
36
|
-
10. [
|
|
37
|
-
11. [
|
|
30
|
+
4. [Plugin API](#plugin-api)
|
|
31
|
+
5. [API](#api)
|
|
32
|
+
6. [Options](#options)
|
|
33
|
+
7. [Toolbar Customisation](#toolbar-customisation)
|
|
34
|
+
8. [Keyboard Shortcuts](#keyboard-shortcuts)
|
|
35
|
+
9. [Mentions](#mentions)
|
|
36
|
+
10. [Project Structure](#project-structure)
|
|
37
|
+
11. [Comparison](#comparison)
|
|
38
|
+
12. [License](#license)
|
|
38
39
|
|
|
39
40
|
---
|
|
40
41
|
|
|
@@ -109,7 +110,7 @@ Right-click inside the editor opens a context menu with: **Undo**, **Redo**, **C
|
|
|
109
110
|
- **No jQuery** — pure vanilla ES2022, zero runtime dependencies
|
|
110
111
|
- **Bootstrap friendly** — optional Bootstrap 4/5 styling (`useBootstrap: true`)
|
|
111
112
|
- **FontAwesome ready** — auto-detects FA on the page; falls back to built-in SVG icons
|
|
112
|
-
- **Plugin
|
|
113
|
+
- **Plugin API** — first-class plugin system: `AutumnNote.use(plugin)`, `context.getPlugin(name)`, global button registry (`registerButton`), per-instance installation, `AsnPlugin<T>` TypeScript interface
|
|
113
114
|
- **Tree-shakeable** — ES module build; all core utilities individually exported
|
|
114
115
|
- **TypeScript definitions** — bundled `types/index.d.ts` with full JSDoc coverage
|
|
115
116
|
- **@mention autocomplete** — type `@` (or any custom trigger) to open a floating dropdown backed by a user-supplied `onSearch` function; inserts a non-editable mention chip; customisable chip HTML via `onInsert`
|
|
@@ -269,6 +270,61 @@ const editor = AutumnNote.create('#my-editor', {
|
|
|
269
270
|
|
|
270
271
|
---
|
|
271
272
|
|
|
273
|
+
## Plugin API
|
|
274
|
+
|
|
275
|
+
Plugins package editor extensions — custom modules, toolbar buttons, and event handlers — into a reusable, distributable object.
|
|
276
|
+
|
|
277
|
+
```js
|
|
278
|
+
import AutumnNote from 'autumnnote';
|
|
279
|
+
|
|
280
|
+
const WordCountPlugin = {
|
|
281
|
+
name: 'word-count',
|
|
282
|
+
version: '1.0.0',
|
|
283
|
+
// Buttons registered BEFORE create() — usable by name in toolbar config
|
|
284
|
+
buttons: [{
|
|
285
|
+
name: 'wordCountBtn',
|
|
286
|
+
icon: 'hashtag',
|
|
287
|
+
tooltip: 'Word count',
|
|
288
|
+
action: (ctx) => alert(`${ctx.getWordCount()} words`),
|
|
289
|
+
}],
|
|
290
|
+
// Called after all built-in modules initialise
|
|
291
|
+
install(ctx, options) {
|
|
292
|
+
ctx.on('change', () => console.log('words:', ctx.getWordCount()));
|
|
293
|
+
return { getMax: () => options.maxWords };
|
|
294
|
+
},
|
|
295
|
+
uninstall(ctx) { /* cleanup */ },
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
// Global — applied to every future editor instance
|
|
299
|
+
AutumnNote.use(WordCountPlugin, { maxWords: 500 });
|
|
300
|
+
|
|
301
|
+
const editor = AutumnNote.create('#editor', {
|
|
302
|
+
toolbar: [['bold', 'italic', 'wordCountBtn']], // 'wordCountBtn' resolved from registry
|
|
303
|
+
});
|
|
304
|
+
|
|
305
|
+
editor.getPlugin('word-count').getMax(); // → 500
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
**Per-instance installation:**
|
|
309
|
+
|
|
310
|
+
```js
|
|
311
|
+
const editor = AutumnNote.create('#editor');
|
|
312
|
+
editor.use(WordCountPlugin, { maxWords: 200 });
|
|
313
|
+
editor.invoke('toolbar.rebuild'); // re-render toolbar with new buttons
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
| Method | Description |
|
|
317
|
+
|---|---|
|
|
318
|
+
| `AutumnNote.use(plugin, opts?)` | Install globally. Buttons registered immediately; `install()` called after modules init. |
|
|
319
|
+
| `AutumnNote.hasPlugin(name)` | Returns `true` if plugin registered globally. |
|
|
320
|
+
| `AutumnNote.registerButton(def)` | Register a single button globally by name. |
|
|
321
|
+
| `context.use(plugin, opts?)` | Install on this instance only. |
|
|
322
|
+
| `context.getPlugin<T>(name)` | Returns the public API from `plugin.install()`. |
|
|
323
|
+
|
|
324
|
+
See the [full Plugin API docs →](https://cmm-cmm.github.io/Autumn-Note/docs.html#plugin-api)
|
|
325
|
+
|
|
326
|
+
---
|
|
327
|
+
|
|
272
328
|
## API
|
|
273
329
|
|
|
274
330
|
### Factory
|