autumnnote-vue 1.15.0 → 2.0.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/dist/index.cjs +1 -1
- package/dist/index.js +41 -14
- package/index.d.ts +5 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -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:()=>({})}},setup(e,{expose:t}){let
|
|
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,23 +1,50 @@
|
|
|
1
|
-
import { createElementBlock as e, onMounted as t, onUnmounted as n, openBlock as r, ref as i, shallowRef as a } from "vue";
|
|
2
|
-
import
|
|
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
3
|
//#region src/AutumnNote.vue
|
|
4
|
-
var
|
|
4
|
+
var c = {
|
|
5
5
|
__name: "AutumnNote",
|
|
6
|
-
props: {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
+
};
|
|
12
29
|
return t(() => {
|
|
13
|
-
|
|
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());
|
|
14
41
|
}), n(() => {
|
|
15
|
-
|
|
16
|
-
}),
|
|
42
|
+
m.value?.destroy(), m.value = null;
|
|
43
|
+
}), l({ editor: m }), (t, n) => (r(), e("div", {
|
|
17
44
|
ref_key: "container",
|
|
18
|
-
ref:
|
|
45
|
+
ref: p
|
|
19
46
|
}, null, 512));
|
|
20
47
|
}
|
|
21
48
|
};
|
|
22
49
|
//#endregion
|
|
23
|
-
export {
|
|
50
|
+
export { c as AutumnNoteEditor, c as default };
|
package/index.d.ts
CHANGED
|
@@ -4,6 +4,10 @@ import type { DefineComponent } from 'vue';
|
|
|
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 {
|
|
@@ -19,7 +23,7 @@ export interface AutumnNoteEditorExpose {
|
|
|
19
23
|
* <AutumnNoteEditor ref="editorRef" :options="{ height: 300 }" />
|
|
20
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": "
|
|
3
|
+
"version": "2.0.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",
|
|
@@ -54,13 +54,13 @@
|
|
|
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
60
|
"@vitejs/plugin-vue": "^6.0.8",
|
|
61
|
-
"vite": "^8.1.
|
|
61
|
+
"vite": "^8.1.5",
|
|
62
62
|
"vue": "^3.4.0",
|
|
63
|
-
"autumnnote": "
|
|
63
|
+
"autumnnote": "2.0.0"
|
|
64
64
|
},
|
|
65
65
|
"scripts": {
|
|
66
66
|
"build": "vite build",
|