@morfira-dev/wysiwyg-react 1.5.0 → 1.5.1
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.js +1 -1
- package/dist/index.js.map +3 -3
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{forwardRef as s,useEffect as
|
|
1
|
+
import{forwardRef as s,useEffect as l,useImperativeHandle as y,useLayoutEffect as E,useRef as o}from"react";import{createEditor as m}from"@morfira-dev/wysiwyg-core";import{jsx as M}from"react/jsx-runtime";var d=typeof window>"u"?l:E,g=s((e,u)=>{let f=o(null),r=o(void 0),n=o(e);n.current=e;let i=o(!1);return y(u,()=>({getEditor:()=>r.current}),[]),d(()=>{let t=n.current,a=m(f.current,{...t,onChange:c=>{i.current||n.current.onChange?.(c)}});return r.current=a,n.current.onReady?.(a),()=>{a.destroy(),r.current=void 0}},[]),d(()=>{let t=r.current;if(!(!t||e.value===void 0||e.value===t.getHTML())){i.current=!0;try{t.setHTML(e.value)}finally{i.current=!1}}},[e.value]),d(()=>{r.current?.setReadOnly(e.readOnly??!1)},[e.readOnly]),M("div",{ref:f,className:e.className??"mw-host"})});export{g as MorfiraEditor};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import type { MorfiraEditorProps, MorfiraEditorHandle } from './types.js';\nexport type { MorfiraEditorProps, MorfiraEditorHandle } from './types.js';\nimport { forwardRef, useEffect, useImperativeHandle, useRef } from 'react';\nimport { createEditor } from '@morfira-dev/wysiwyg-core';\nimport type { Editor } from '@morfira-dev/wysiwyg-core';\n\nexport const MorfiraEditor = forwardRef<MorfiraEditorHandle, MorfiraEditorProps>((props, ref) => {\n const host = useRef<HTMLDivElement>(null);\n const instance = useRef<Editor | undefined>(undefined);\n const latest = useRef(props);\n latest.current = props;\n const applying = useRef(false);\n useImperativeHandle(ref, () => ({ getEditor: () => instance.current }), []);\n
|
|
5
|
-
"mappings": "AAEA,OAAS,cAAAA,EAAY,aAAAC,EAAW,uBAAAC,EAAqB,UAAAC,MAAc,
|
|
6
|
-
"names": ["forwardRef", "useEffect", "useImperativeHandle", "useRef", "createEditor", "jsx", "MorfiraEditor", "props", "ref", "host", "instance", "latest", "applying", "options", "editor", "change"]
|
|
4
|
+
"sourcesContent": ["import type { MorfiraEditorProps, MorfiraEditorHandle } from './types.js';\nexport type { MorfiraEditorProps, MorfiraEditorHandle } from './types.js';\nimport { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useRef } from 'react';\nimport { createEditor } from '@morfira-dev/wysiwyg-core';\nimport type { Editor } from '@morfira-dev/wysiwyg-core';\n\n// Synchronize before parent layout effects can issue another editor command.\n// Server rendering must not invoke React's browser-only layout effect.\nconst useEditorLayoutEffect = typeof window === 'undefined' ? useEffect : useLayoutEffect;\n\nexport const MorfiraEditor = forwardRef<MorfiraEditorHandle, MorfiraEditorProps>((props, ref) => {\n const host = useRef<HTMLDivElement>(null);\n const instance = useRef<Editor | undefined>(undefined);\n const latest = useRef(props);\n latest.current = props;\n const applying = useRef(false);\n useImperativeHandle(ref, () => ({ getEditor: () => instance.current }), []);\n useEditorLayoutEffect(() => {\n const options = latest.current;\n const editor = createEditor(host.current!, {\n ...options,\n onChange: (change) => {\n if (!applying.current) {\n latest.current.onChange?.(change);\n }\n },\n });\n instance.current = editor;\n latest.current.onReady?.(editor);\n return () => {\n editor.destroy();\n instance.current = undefined;\n };\n }, []);\n useEditorLayoutEffect(() => {\n const editor = instance.current;\n if (!editor || props.value === undefined || props.value === editor.getHTML())\n return;\n applying.current = true;\n try {\n editor.setHTML(props.value);\n }\n finally {\n applying.current = false;\n }\n }, [props.value]);\n useEditorLayoutEffect(() => {\n instance.current?.setReadOnly(props.readOnly ?? false);\n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AAKK,EAAM,UAAWF,EAAM,WAAa,UAAW,CAClE,CAAC",
|
|
6
|
+
"names": ["forwardRef", "useEffect", "useImperativeHandle", "useLayoutEffect", "useRef", "createEditor", "jsx", "useEditorLayoutEffect", "MorfiraEditor", "props", "ref", "host", "instance", "latest", "applying", "options", "editor", "change"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morfira-dev/wysiwyg-react",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"@morfira-dev/wysiwyg-core": "^1.5.
|
|
22
|
+
"@morfira-dev/wysiwyg-core": "^1.5.1",
|
|
23
23
|
"react": "^18.0.0 || ^19.0.0"
|
|
24
24
|
},
|
|
25
25
|
"peerDependenciesMeta": {
|