autumnnote-vue 1.14.0 → 1.16.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 +8 -8
- package/dist/index.cjs +1 -1
- package/dist/index.js +49 -23
- package/index.d.ts +10 -6
- package/package.json +10 -8
package/README.md
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
62
|
-
editorRef.value.editor
|
|
63
|
-
editorRef.value.editor
|
|
64
|
-
editorRef.value.editor
|
|
65
|
-
editorRef.value.editor
|
|
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`
|
|
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
|
-
|
|
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:()=>({})},modelValue:{type:String,default:void 0},defaultValue:{type:String,default:``}},emits:[`update:modelValue`,`change`],setup(e,{expose:t,emit:n}){let r=e,i=n,a=(0,c.ref)(null),o=(0,c.shallowRef)(null),s=null,u=e=>{if(r.options.onChange?.(e),i(`change`,e),e===s){s=null;return}i(`update:modelValue`,e)};return(0,c.onMounted)(()=>{o.value=l.default.create(a.value,{...r.options,onChange:u});let e=r.modelValue??r.defaultValue;e&&(r.modelValue!=null&&(s=r.modelValue),o.value.setHTML(e),o.value.clearHistory())}),(0,c.watch)(()=>r.options,e=>o.value?.updateOptions({...e,onChange:u}),{deep:!0}),(0,c.watch)(()=>r.modelValue,e=>{e==null||!o.value||o.value.getHTML()===e||(s=e,o.value.setHTML(e),o.value.clearHistory())}),(0,c.onUnmounted)(()=>{o.value?.destroy(),o.value=null}),t({editor:o}),(e,t)=>((0,c.openBlock)(),(0,c.createElementBlock)(`div`,{ref_key:`container`,ref:a},null,512))}};exports.AutumnNoteEditor=u,exports.default=u;
|
package/dist/index.js
CHANGED
|
@@ -1,24 +1,50 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import { createElementBlock as e, onMounted as t, onUnmounted as n, openBlock as r, ref as i, shallowRef as a, watch as o } from "vue";
|
|
2
|
+
import s from "autumnnote";
|
|
3
|
+
//#region src/AutumnNote.vue
|
|
4
|
+
var c = {
|
|
5
|
+
__name: "AutumnNote",
|
|
6
|
+
props: {
|
|
7
|
+
options: {
|
|
8
|
+
type: Object,
|
|
9
|
+
default: () => ({})
|
|
10
|
+
},
|
|
11
|
+
modelValue: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: void 0
|
|
14
|
+
},
|
|
15
|
+
defaultValue: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: ""
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
emits: ["update:modelValue", "change"],
|
|
21
|
+
setup(c, { expose: l, emit: u }) {
|
|
22
|
+
let d = c, f = u, p = i(null), m = a(null), h = null, g = (e) => {
|
|
23
|
+
if (d.options.onChange?.(e), f("change", e), e === h) {
|
|
24
|
+
h = null;
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
f("update:modelValue", e);
|
|
28
|
+
};
|
|
29
|
+
return t(() => {
|
|
30
|
+
m.value = s.create(p.value, {
|
|
31
|
+
...d.options,
|
|
32
|
+
onChange: g
|
|
33
|
+
});
|
|
34
|
+
let e = d.modelValue ?? d.defaultValue;
|
|
35
|
+
e && (d.modelValue != null && (h = d.modelValue), m.value.setHTML(e), m.value.clearHistory());
|
|
36
|
+
}), o(() => d.options, (e) => m.value?.updateOptions({
|
|
37
|
+
...e,
|
|
38
|
+
onChange: g
|
|
39
|
+
}), { deep: !0 }), o(() => d.modelValue, (e) => {
|
|
40
|
+
e == null || !m.value || m.value.getHTML() === e || (h = e, m.value.setHTML(e), m.value.clearHistory());
|
|
41
|
+
}), n(() => {
|
|
42
|
+
m.value?.destroy(), m.value = null;
|
|
43
|
+
}), l({ editor: m }), (t, n) => (r(), e("div", {
|
|
44
|
+
ref_key: "container",
|
|
45
|
+
ref: p
|
|
46
|
+
}, null, 512));
|
|
47
|
+
}
|
|
24
48
|
};
|
|
49
|
+
//#endregion
|
|
50
|
+
export { c as AutumnNoteEditor, c as default };
|
package/index.d.ts
CHANGED
|
@@ -1,25 +1,29 @@
|
|
|
1
1
|
import type { Context, AsnOptions } from 'autumnnote';
|
|
2
|
-
import type { DefineComponent
|
|
2
|
+
import type { DefineComponent } from 'vue';
|
|
3
3
|
|
|
4
4
|
export interface AutumnNoteEditorProps {
|
|
5
5
|
/** Editor configuration object. All AsnOptions fields are accepted. */
|
|
6
6
|
options?: AsnOptions;
|
|
7
|
+
/** Controlled HTML value used by v-model. */
|
|
8
|
+
modelValue?: string;
|
|
9
|
+
/** Initial HTML value for uncontrolled usage. */
|
|
10
|
+
defaultValue?: string;
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
export interface AutumnNoteEditorExpose {
|
|
10
|
-
/**
|
|
11
|
-
editor:
|
|
14
|
+
/** AutumnNote Context instance, or null before the component mounts. */
|
|
15
|
+
editor: Context | null;
|
|
12
16
|
}
|
|
13
17
|
|
|
14
18
|
/**
|
|
15
19
|
* Vue 3 component that mounts an AutumnNote WYSIWYG editor.
|
|
16
20
|
*
|
|
17
|
-
* Access the editor instance via the exposed `editor`
|
|
21
|
+
* Access the editor instance via the exposed `editor` property:
|
|
18
22
|
* ```vue
|
|
19
23
|
* <AutumnNoteEditor ref="editorRef" :options="{ height: 300 }" />
|
|
20
|
-
* // editorRef.value.editor
|
|
24
|
+
* // editorRef.value.editor?.getHTML()
|
|
21
25
|
* ```
|
|
22
|
-
*
|
|
26
|
+
* Supports `v-model` and applies runtime-safe option changes without remounting.
|
|
23
27
|
*/
|
|
24
28
|
declare const AutumnNoteEditor: DefineComponent<
|
|
25
29
|
AutumnNoteEditorProps,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autumnnote-vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
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",
|
|
@@ -8,9 +8,9 @@
|
|
|
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": [
|
|
@@ -54,15 +54,17 @@
|
|
|
54
54
|
"license": "MIT",
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"autumnnote": ">=1.4.0",
|
|
57
|
-
"vue": "
|
|
57
|
+
"vue": ">=3.4.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@vitejs/plugin-vue": "^
|
|
61
|
-
"vite": "^
|
|
60
|
+
"@vitejs/plugin-vue": "^6.0.8",
|
|
61
|
+
"vite": "^8.1.5",
|
|
62
62
|
"vue": "^3.4.0",
|
|
63
|
-
"autumnnote": "1.
|
|
63
|
+
"autumnnote": "1.16.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
|
}
|