autumnnote 1.8.1 → 1.8.3

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 CHANGED
@@ -16,7 +16,7 @@ A **zero-dependency WYSIWYG rich-text editor** built with vanilla JavaScript (ES
16
16
 
17
17
  > **Fast. Lightweight. Reliable. Efficient.**
18
18
 
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)
19
+ [Live Demo](https://autumn.konexforge.com/) · [Docs](https://autumn.konexforge.com/docs.html) · [Playground](https://autumn.konexforge.com/playground.html)
20
20
 
21
21
  <p align="center"><img src="examples/Screenshot.png" alt="AutumnNote Screenshot"/></p>
22
22
 
@@ -177,6 +177,9 @@ Official React and Vue 3 wrappers are available as separate packages in this mon
177
177
 
178
178
  ```bash
179
179
  npm install autumnnote autumnnote-react
180
+ ```
181
+
182
+ ```js
180
183
  import 'autumnnote/dist/autumnnote.css';
181
184
  ```
182
185
 
@@ -206,6 +209,9 @@ The `ref` is forwarded to the underlying `Context` instance via `useImperativeHa
206
209
 
207
210
  ```bash
208
211
  npm install autumnnote autumnnote-vue
212
+ ```
213
+
214
+ ```js
209
215
  import 'autumnnote/dist/autumnnote.css';
210
216
  ```
211
217
 
@@ -260,7 +266,6 @@ const editor = AutumnNote.create('#my-editor', {
260
266
  ```js
261
267
  const editor = AutumnNote.create('#my-editor', {
262
268
  useBootstrap: true,
263
- bootstrapVersion: 5,
264
269
  toolbarButtonClass: 'btn btn-sm btn-light',
265
270
  });
266
271
  ```
@@ -296,7 +301,7 @@ const editor = AutumnNote.create('#my-editor', {
296
301
  fd.append('file', files[0]);
297
302
  fetch('/api/upload', { method: 'POST', body: fd })
298
303
  .then(r => r.json())
299
- .then(({ url }) => editor.insertImage(url, files[0].name));
304
+ .then(({ url }) => editor.invoke('editor.insertImage', url, files[0].name));
300
305
  },
301
306
  });
302
307
  ```
@@ -384,7 +389,7 @@ editor.invoke('toolbar.rebuild'); // re-render toolbar with new buttons
384
389
  | `context.use(plugin, opts?)` | Install on this instance only. |
385
390
  | `context.getPlugin<T>(name)` | Returns the public API from `plugin.install()`. |
386
391
 
387
- See the [full Plugin API docs →](https://cmm-cmm.github.io/Autumn-Note/docs.html#plugin-api)
392
+ See the [full Plugin API docs →](https://autumn.konexforge.com/docs.html#plugin-api)
388
393
 
389
394
  ---
390
395
 
@@ -462,7 +467,6 @@ See the [full Plugin API docs →](https://cmm-cmm.github.io/Autumn-Note/docs.ht
462
467
  | `toolbar` | `Array[]` | all buttons | Toolbar layout. See [Toolbar Customisation](#toolbar-customisation). |
463
468
  | `toolbarOverflow` | `string` | `'wrap'` | Toolbar overflow strategy: `'wrap'` or `'scroll'`. |
464
469
  | `useBootstrap` | `boolean` | `false` | Apply Bootstrap CSS classes to toolbar buttons. |
465
- | `bootstrapVersion` | `number` | `5` | Bootstrap major version (`4` or `5`). |
466
470
  | `toolbarButtonClass` | `string` | `'btn btn-sm btn-light'` | CSS classes for toolbar buttons when `useBootstrap` is `true`. |
467
471
  | `useFontAwesome` | `boolean` | `true` | Use FA icons when FontAwesome is detected on the page. |
468
472
  | `fontAwesomeClass` | `string` | `'fas'` | FA prefix: `'fas'` for FA 5, `'fa-solid'` for FA 6. |
@@ -479,7 +483,7 @@ See the [full Plugin API docs →](https://cmm-cmm.github.io/Autumn-Note/docs.ht
479
483
  | `fontFamilies` | `string[]` | 10 fonts | Font families available in the font-family dropdown. |
480
484
  | `stickyToolbar` | `boolean` | `false` | Pin the toolbar to the viewport top when the page is scrolled. |
481
485
  | `stickyToolbarOffset` | `number` | `0` | Top offset in pixels for the sticky toolbar (e.g. height of a fixed nav bar). |
482
- | `theme` | `string` | `'light'` | Colour theme: `'light'` or `'dark'`. |
486
+ | `theme` | `string` | `'light'` | Colour theme: `'light'`, `'dark'`, or `'auto'` (follows system preference). |
483
487
  | `readOnly` | `boolean` | `false` | Start the editor in non-editable (read-only) mode with toolbar hidden. |
484
488
  | `spellcheck` | `boolean` | `true` | Enable browser spellcheck in the editable area. |
485
489
  | `direction` | `string` | `'ltr'` | Text direction: `'ltr'` or `'rtl'`. |
@@ -495,10 +499,12 @@ See the [full Plugin API docs →](https://cmm-cmm.github.io/Autumn-Note/docs.ht
495
499
  | `lang` | `string \| object` | `'en'` | UI display language. Built-in codes: `'en'`, `'vi'`, `'ja'`, `'zh'`, `'fr'`, `'de'`, `'es'`, `'ko'`. Pass a partial locale object for custom overrides. |
496
500
  | `markdownShortcuts` | `boolean` | `true` | Convert Markdown-style syntax typed in the editor to HTML in real time (block and inline rules). |
497
501
  | `bubbleToolbar` | `boolean` | `false` | Show a mini floating toolbar above the text selection for quick formatting. |
498
- | `bubbleToolbarItems` | `string[]` | `['bold','italic','underline','link','foreColor','removeFormat']` | Buttons shown in the bubble toolbar. Available names: `'bold'`, `'italic'`, `'underline'`, `'strikethrough'`, `'link'`, `'foreColor'`, `'removeFormat'`, `'inlineCode'`. |
502
+ | `bubbleToolbarItems` | `string[]` | `['bold','italic','underline','link','foreColor','hiliteColor','removeFormat']` | Buttons shown in the bubble toolbar. Available names: `'bold'`, `'italic'`, `'underline'`, `'strikethrough'`, `'link'`, `'foreColor'`, `'hiliteColor'`, `'removeFormat'`, `'inlineCode'`. |
499
503
  | `autoSaveRestore` | `boolean` | `false` | When `autoSave` is also `true`, show a restore banner on load if a draft exists. |
500
504
  | `autoSaveRestoreTimeout` | `number` | `7` | Max draft age in days before it is auto-discarded. `0` = no expiry. |
501
505
  | `onAutoSaveRestore` | `Function` | `null` | `(html, context) => void` — called after the user restores a draft. |
506
+ | `maxPasteSize` | `number` | `5242880` | Maximum paste payload size in bytes (default 5 MB). Pastes larger than this are silently dropped. |
507
+ | `minImageSize` | `number` | `20` | Minimum image dimension in px during resize (width and height). |
502
508
  | `mention` | `object` | `null` | @mention configuration object. Set `mention.onSearch` to activate. See [Mentions](#mentions). |
503
509
  | `onChange` | `Function` | `null` | `(html: string) => void` — called on every content change. |
504
510
  | `onFocus` | `Function` | `null` | `(context) => void` — called when the editor gains focus. |
@@ -356,12 +356,6 @@
356
356
  padding: 12px 14px;
357
357
  min-height: 0;
358
358
  outline: none;
359
- }
360
- .an-editable:focus-visible {
361
- outline: 2px solid var(--an-focus-color, #3b82f6);
362
- outline-offset: -2px;
363
- }
364
- .an-editable {
365
359
  line-height: 1.6;
366
360
  color: #111827;
367
361
  overflow-y: auto;
@@ -1724,6 +1724,8 @@ var defaultOptions = {
1724
1724
  autoSaveRestoreTimeout: 7,
1725
1725
  onAutoSaveRestore: null,
1726
1726
  markdownShortcuts: true,
1727
+ maxPasteSize: 5 * 1024 * 1024,
1728
+ minImageSize: 20,
1727
1729
  bubbleToolbar: false,
1728
1730
  bubbleToolbarItems: [
1729
1731
  "bold",
@@ -7427,7 +7429,7 @@ var Clipboard = class {
7427
7429
  _compressImage(file) {
7428
7430
  const MAX_DIM = 1920;
7429
7431
  const QUALITY = .85;
7430
- return new Promise((resolve) => {
7432
+ return new Promise((resolve, reject) => {
7431
7433
  const objectUrl = URL.createObjectURL(file);
7432
7434
  const img = new Image();
7433
7435
  img.onload = () => {
@@ -7447,6 +7449,7 @@ var Clipboard = class {
7447
7449
  if (!ctx) {
7448
7450
  const reader = new FileReader();
7449
7451
  reader.onload = (e) => resolve(e.target.result);
7452
+ reader.onerror = () => reject(/* @__PURE__ */ new Error("FileReader failed"));
7450
7453
  reader.readAsDataURL(file);
7451
7454
  return;
7452
7455
  }
@@ -7458,6 +7461,7 @@ var Clipboard = class {
7458
7461
  URL.revokeObjectURL(objectUrl);
7459
7462
  const reader = new FileReader();
7460
7463
  reader.onload = (e) => resolve(e.target.result);
7464
+ reader.onerror = () => reject(/* @__PURE__ */ new Error("FileReader failed"));
7461
7465
  reader.readAsDataURL(file);
7462
7466
  };
7463
7467
  img.src = objectUrl;
@@ -14179,7 +14183,7 @@ var defaultItems = [
14179
14183
  };
14180
14184
  if (typeof navigator.clipboard.read === "function") navigator.clipboard.read().then((items) => {
14181
14185
  for (const item of items) if (item.types.includes("text/html")) {
14182
- item.getType("text/html").then((blob) => blob.text()).then((html) => doInsert(html, null));
14186
+ item.getType("text/html").then((blob) => blob.text()).then((html) => doInsert(html, null)).catch(() => {});
14183
14187
  return;
14184
14188
  }
14185
14189
  navigator.clipboard.readText().then((text) => doInsert(null, text)).catch(() => {});
@@ -15304,6 +15308,10 @@ function drawCropToCanvas(img, naturalRect, renderW, renderH) {
15304
15308
  canvas.width = Math.round(renderW);
15305
15309
  canvas.height = Math.round(renderH);
15306
15310
  const ctx = canvas.getContext("2d");
15311
+ if (!ctx) {
15312
+ resolve(null);
15313
+ return;
15314
+ }
15307
15315
  try {
15308
15316
  ctx.drawImage(source, naturalRect.x, naturalRect.y, naturalRect.width, naturalRect.height, 0, 0, canvas.width, canvas.height);
15309
15317
  ctx.getImageData(0, 0, 1, 1);
@@ -16563,6 +16571,7 @@ var Mention = class {
16563
16571
  debounce: cfg.debounce ?? 200,
16564
16572
  onSearch: cfg.onSearch,
16565
16573
  onInsert: cfg.onInsert || null,
16574
+ onError: cfg.onError || null,
16566
16575
  mentionClass: cfg.mentionClass || "an-mention",
16567
16576
  allowSpaces: cfg.allowSpaces || false
16568
16577
  };
@@ -17491,7 +17500,7 @@ var AutumnNote = {
17491
17500
  /** All pre-built button definitions — accessible in every module format including UMD/CJS. */
17492
17501
  buttons,
17493
17502
  /** Library version */
17494
- version: "1.8.0"
17503
+ version: "1.8.3"
17495
17504
  };
17496
17505
  /**
17497
17506
  * @param {string|Element|NodeList|Element[]} selector