autumnnote-react 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/dist/index.cjs +1 -1
- package/dist/index.js +42 -13
- package/index.d.ts +7 -1
- package/package.json +12 -9
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("react"),l=require("autumnnote");l=s(l,1);let u=require("react/jsx-runtime");var d=typeof window>`u`?c.useEffect:c.useLayoutEffect,f=(0,c.forwardRef)(function({options:e={},value:t,defaultValue:n,onChange:r,className:i,style:a},o){let s=(0,c.useRef)(null),f=(0,c.useRef)(null),p=(0,c.useRef)({onChange:r,optionOnChange:e.onChange}),m=(0,c.useRef)(null),h=(0,c.useRef)(null);return p.current={onChange:r,optionOnChange:e.onChange},h.current||=e=>{if(p.current.optionOnChange?.(e),e===m.current){m.current=null;return}p.current.onChange?.(e)},d(()=>{f.current=l.default.create(s.current,{...e,onChange:h.current});let r=t??n;return r!=null&&(t!=null&&(m.current=t),f.current.setHTML(r),f.current.clearHistory()),()=>{f.current?.destroy(),f.current=null}},[]),(0,c.useEffect)(()=>{f.current?.updateOptions({...e,onChange:h.current})},[e]),(0,c.useEffect)(()=>{let e=f.current;t==null||!e||e.getHTML()===t||(m.current=t,e.setHTML(t),e.clearHistory())},[t]),(0,c.useImperativeHandle)(o,()=>f.current,[]),(0,u.jsx)(`div`,{ref:s,className:i,style:a})});exports.AutumnNoteEditor=f,exports.default=f;
|
package/dist/index.js
CHANGED
|
@@ -1,14 +1,43 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { forwardRef as e, useEffect as t, useImperativeHandle as n, useLayoutEffect as r, useRef as i } from "react";
|
|
2
|
+
import a from "autumnnote";
|
|
3
|
+
import { jsx as o } from "react/jsx-runtime";
|
|
4
|
+
//#region src/index.jsx
|
|
5
|
+
var s = typeof window > "u" ? t : r, c = e(function({ options: e = {}, value: r, defaultValue: c, onChange: l, className: u, style: d }, f) {
|
|
6
|
+
let p = i(null), m = i(null), h = i({
|
|
7
|
+
onChange: l,
|
|
8
|
+
optionOnChange: e.onChange
|
|
9
|
+
}), g = i(null), _ = i(null);
|
|
10
|
+
return h.current = {
|
|
11
|
+
onChange: l,
|
|
12
|
+
optionOnChange: e.onChange
|
|
13
|
+
}, _.current ||= (e) => {
|
|
14
|
+
if (h.current.optionOnChange?.(e), e === g.current) {
|
|
15
|
+
g.current = null;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
h.current.onChange?.(e);
|
|
19
|
+
}, s(() => {
|
|
20
|
+
m.current = a.create(p.current, {
|
|
21
|
+
...e,
|
|
22
|
+
onChange: _.current
|
|
23
|
+
});
|
|
24
|
+
let t = r ?? c;
|
|
25
|
+
return t != null && (r != null && (g.current = r), m.current.setHTML(t), m.current.clearHistory()), () => {
|
|
26
|
+
m.current?.destroy(), m.current = null;
|
|
27
|
+
};
|
|
28
|
+
}, []), t(() => {
|
|
29
|
+
m.current?.updateOptions({
|
|
30
|
+
...e,
|
|
31
|
+
onChange: _.current
|
|
32
|
+
});
|
|
33
|
+
}, [e]), t(() => {
|
|
34
|
+
let e = m.current;
|
|
35
|
+
r == null || !e || e.getHTML() === r || (g.current = r, e.setHTML(r), e.clearHistory());
|
|
36
|
+
}, [r]), n(f, () => m.current, []), /* @__PURE__ */ o("div", {
|
|
37
|
+
ref: p,
|
|
38
|
+
className: u,
|
|
39
|
+
style: d
|
|
40
|
+
});
|
|
10
41
|
});
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
E as default
|
|
14
|
-
};
|
|
42
|
+
//#endregion
|
|
43
|
+
export { c as AutumnNoteEditor, c as default };
|
package/index.d.ts
CHANGED
|
@@ -4,6 +4,12 @@ import type { CSSProperties, ForwardRefExoticComponent, RefAttributes } from 're
|
|
|
4
4
|
export interface AutumnNoteEditorProps {
|
|
5
5
|
/** Editor configuration object. All AsnOptions fields are accepted. */
|
|
6
6
|
options?: AsnOptions;
|
|
7
|
+
/** Controlled HTML value. */
|
|
8
|
+
value?: string;
|
|
9
|
+
/** Initial HTML value for uncontrolled usage. */
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
/** Called when editor HTML changes. */
|
|
12
|
+
onChange?: (html: string) => void;
|
|
7
13
|
/** CSS class applied to the container <div>. */
|
|
8
14
|
className?: string;
|
|
9
15
|
/** Inline styles applied to the container <div>. */
|
|
@@ -19,7 +25,7 @@ export interface AutumnNoteEditorProps {
|
|
|
19
25
|
* <AutumnNoteEditor ref={editorRef} options={{ height: 300 }} />
|
|
20
26
|
* editorRef.current?.getHTML();
|
|
21
27
|
* ```
|
|
22
|
-
*
|
|
28
|
+
* Runtime-safe option changes are applied without remounting.
|
|
23
29
|
*/
|
|
24
30
|
declare const AutumnNoteEditor: ForwardRefExoticComponent<
|
|
25
31
|
AutumnNoteEditorProps & RefAttributes<Context>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "autumnnote-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.0",
|
|
4
4
|
"description": "Official React 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": [
|
|
@@ -53,17 +53,20 @@
|
|
|
53
53
|
"license": "MIT",
|
|
54
54
|
"peerDependencies": {
|
|
55
55
|
"autumnnote": ">=1.4.0",
|
|
56
|
-
"react": ">=
|
|
57
|
-
"react-dom": ">=
|
|
56
|
+
"react": ">=18.0.0",
|
|
57
|
+
"react-dom": ">=18.0.0"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@
|
|
60
|
+
"@types/react": "^18.3.0",
|
|
61
|
+
"@vitejs/plugin-react": "^6.0.3",
|
|
61
62
|
"react": "^18.0.0",
|
|
62
63
|
"react-dom": "^18.0.0",
|
|
63
|
-
"vite": "^
|
|
64
|
-
"autumnnote": "1.
|
|
64
|
+
"vite": "^8.1.5",
|
|
65
|
+
"autumnnote": "1.16.0"
|
|
65
66
|
},
|
|
66
67
|
"scripts": {
|
|
67
|
-
"build": "vite build"
|
|
68
|
+
"build": "vite build",
|
|
69
|
+
"test": "vitest run",
|
|
70
|
+
"typecheck": "tsc --project tsconfig.test.json"
|
|
68
71
|
}
|
|
69
72
|
}
|