autumnnote-vue 1.13.0 → 1.15.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 CHANGED
@@ -4,7 +4,7 @@
4
4
  [![npm downloads](https://img.shields.io/npm/dm/autumnnote-vue?color=e8751a)](https://www.npmjs.com/package/autumnnote-vue)
5
5
  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
6
 
7
- Official **Vue 3 wrapper** for [AutumnNote](https://autumn.konexforge.com/) — the zero-dependency WYSIWYG rich-text editor built with vanilla JavaScript.
7
+ Official **Vue 3 wrapper** for [Autumn Note](https://autumn.konexforge.com/) — the zero-dependency WYSIWYG rich-text editor built with vanilla JavaScript.
8
8
 
9
9
  ## Installation
10
10
 
@@ -29,7 +29,7 @@ import 'autumnnote/dist/autumnnote.css';
29
29
  const editorRef = ref(null);
30
30
 
31
31
  function handleSave() {
32
- const html = editorRef.value.editor.value.getHTML();
32
+ const html = editorRef.value.editor?.getHTML();
33
33
  console.log(html);
34
34
  }
35
35
  </script>
@@ -55,17 +55,17 @@ function handleSave() {
55
55
 
56
56
  ## Accessing the editor instance
57
57
 
58
- The component uses `defineExpose({ editor })` where `editor` is a Vue `ref<Context | null>`. Access the instance via:
58
+ The component exposes the current `Context` as `editor`. Vue automatically unwraps the internal shallow ref on the public component instance:
59
59
 
60
60
  ```js
61
- editorRef.value.editor.value.getHTML();
62
- editorRef.value.editor.value.setHTML('<p>Hello <strong>world</strong></p>');
63
- editorRef.value.editor.value.getMarkdown();
64
- editorRef.value.editor.value.invoke('toolbar.rebuild');
65
- editorRef.value.editor.value.on('change', (html) => console.log(html));
61
+ editorRef.value.editor?.getHTML();
62
+ editorRef.value.editor?.setHTML('<p>Hello <strong>world</strong></p>');
63
+ editorRef.value.editor?.getMarkdown();
64
+ editorRef.value.editor?.invoke('toolbar.rebuild');
65
+ editorRef.value.editor?.on('change', (html) => console.log(html));
66
66
  ```
67
67
 
68
- The `editor` ref is `null` before mount — use it inside `onMounted` or after the component is mounted.
68
+ The exposed `editor` property is `null` before mount — use it inside `onMounted` or after the component is mounted.
69
69
 
70
70
  ## Reinitialising with new options
71
71
 
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),s=require("autumnnote"),u={__name:"AutumnNote",props:{options:{type:Object,default:()=>({})}},setup(r,{expose:l}){const c=r,n=e.ref(null),t=e.ref(null);return e.onMounted(()=>{t.value=s.create(n.value,c.options)}),e.onUnmounted(()=>{var o;(o=t.value)==null||o.destroy(),t.value=null}),l({editor:t}),(o,a)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"container",ref:n},null,512))}};exports.AutumnNoteEditor=u;exports.default=u;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let c=require("vue"),l=require("autumnnote");l=s(l);var u={__name:`AutumnNote`,props:{options:{type:Object,default:()=>({})}},setup(e,{expose:t}){let n=e,r=(0,c.ref)(null),i=(0,c.shallowRef)(null);return(0,c.onMounted)(()=>{i.value=l.default.create(r.value,n.options)}),(0,c.onUnmounted)(()=>{i.value?.destroy(),i.value=null}),t({editor:i}),(e,t)=>((0,c.openBlock)(),(0,c.createElementBlock)(`div`,{ref_key:`container`,ref:r},null,512))}};exports.AutumnNoteEditor=u,exports.default=u;
package/dist/index.js CHANGED
@@ -1,24 +1,23 @@
1
- import { ref as n, onMounted as a, onUnmounted as c, openBlock as s, createElementBlock as p } from "vue";
2
- import m from "autumnnote";
3
- const _ = {
4
- __name: "AutumnNote",
5
- props: {
6
- options: { type: Object, default: () => ({}) }
7
- },
8
- setup(r, { expose: u }) {
9
- const l = r, o = n(null), e = n(null);
10
- return a(() => {
11
- e.value = m.create(o.value, l.options);
12
- }), c(() => {
13
- var t;
14
- (t = e.value) == null || t.destroy(), e.value = null;
15
- }), u({ editor: e }), (t, i) => (s(), p("div", {
16
- ref_key: "container",
17
- ref: o
18
- }, null, 512));
19
- }
20
- };
21
- export {
22
- _ as AutumnNoteEditor,
23
- _ as default
1
+ import { createElementBlock as e, onMounted as t, onUnmounted as n, openBlock as r, ref as i, shallowRef as a } from "vue";
2
+ import o from "autumnnote";
3
+ //#region src/AutumnNote.vue
4
+ var s = {
5
+ __name: "AutumnNote",
6
+ props: { options: {
7
+ type: Object,
8
+ default: () => ({})
9
+ } },
10
+ setup(s, { expose: c }) {
11
+ let l = s, u = i(null), d = a(null);
12
+ return t(() => {
13
+ d.value = o.create(u.value, l.options);
14
+ }), n(() => {
15
+ d.value?.destroy(), d.value = null;
16
+ }), c({ editor: d }), (t, n) => (r(), e("div", {
17
+ ref_key: "container",
18
+ ref: u
19
+ }, null, 512));
20
+ }
24
21
  };
22
+ //#endregion
23
+ export { s as AutumnNoteEditor, s as default };
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { Context, AsnOptions } from 'autumnnote';
2
- import type { DefineComponent, Ref } from 'vue';
2
+ import type { DefineComponent } from 'vue';
3
3
 
4
4
  export interface AutumnNoteEditorProps {
5
5
  /** Editor configuration object. All AsnOptions fields are accepted. */
@@ -7,17 +7,17 @@ export interface AutumnNoteEditorProps {
7
7
  }
8
8
 
9
9
  export interface AutumnNoteEditorExpose {
10
- /** Reactive ref holding the AutumnNote Context instance (available after mount). */
11
- editor: Ref<Context | null>;
10
+ /** AutumnNote Context instance, or null before the component mounts. */
11
+ editor: Context | null;
12
12
  }
13
13
 
14
14
  /**
15
15
  * Vue 3 component that mounts an AutumnNote WYSIWYG editor.
16
16
  *
17
- * Access the editor instance via the exposed `editor` ref:
17
+ * Access the editor instance via the exposed `editor` property:
18
18
  * ```vue
19
19
  * <AutumnNoteEditor ref="editorRef" :options="{ height: 300 }" />
20
- * // editorRef.value.editor.value?.getHTML()
20
+ * // editorRef.value.editor?.getHTML()
21
21
  * ```
22
22
  * Use `v-if` to force remount on options change.
23
23
  */
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "autumnnote-vue",
3
- "version": "1.13.0",
4
- "description": "Official Vue 3 wrapper for AutumnNote — zero-dependency WYSIWYG editor. Mount the editor with a single component and access the full Context API via ref.",
3
+ "version": "1.15.0",
4
+ "description": "Official Vue 3 wrapper for Autumn Note — zero-dependency WYSIWYG editor. Mount the editor with a single component and access the full Context API via ref.",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
7
7
  "module": "dist/index.js",
8
8
  "types": "index.d.ts",
9
9
  "exports": {
10
10
  ".": {
11
+ "types": "./index.d.ts",
11
12
  "import": "./dist/index.js",
12
- "require": "./dist/index.cjs",
13
- "types": "./index.d.ts"
13
+ "require": "./dist/index.cjs"
14
14
  }
15
15
  },
16
16
  "files": [
@@ -57,12 +57,14 @@
57
57
  "vue": "^3.0.0"
58
58
  },
59
59
  "devDependencies": {
60
- "@vitejs/plugin-vue": "^5.0.0",
61
- "vite": "^6.0.0",
60
+ "@vitejs/plugin-vue": "^6.0.8",
61
+ "vite": "^8.1.4",
62
62
  "vue": "^3.4.0",
63
- "autumnnote": "1.13.0"
63
+ "autumnnote": "1.15.0"
64
64
  },
65
65
  "scripts": {
66
- "build": "vite build"
66
+ "build": "vite build",
67
+ "test": "vitest run",
68
+ "typecheck": "tsc --project tsconfig.test.json"
67
69
  }
68
70
  }