jodit-react 5.3.20 → 5.4.64

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.
@@ -18,6 +18,17 @@ const JoditEditor = forwardRef(({ JoditConstructor = Jodit, className, config, i
18
18
  if (typeof editorRef === 'function') {
19
19
  editorRef(jodit);
20
20
  }
21
+ // Keep the forwarded ref pointing at the live instance:
22
+ // when the editor is recreated (e.g. a new `config` identity),
23
+ // a stale ref would silently swallow all method calls (#301)
24
+ if (ref) {
25
+ if (typeof ref === 'function') {
26
+ ref(jodit);
27
+ }
28
+ else {
29
+ ref.current = jodit;
30
+ }
31
+ }
21
32
  return () => {
22
33
  if (jodit.isReady) {
23
34
  jodit.destruct();
@@ -28,17 +39,12 @@ const JoditEditor = forwardRef(({ JoditConstructor = Jodit, className, config, i
28
39
  .then(joditInstance => joditInstance.destruct());
29
40
  }
30
41
  };
42
+ // `ref` is intentionally omitted: react guarantees a stable
43
+ // identity for ref objects, and recreating the editor because
44
+ // the consumer passed an inline ref callback would be worse
45
+ // than a late ref update
46
+ // eslint-disable-next-line react-hooks/exhaustive-deps
31
47
  }, [JoditConstructor, config, editorRef]);
32
- useEffect(() => {
33
- if (ref) {
34
- if (typeof ref === 'function') {
35
- ref(joditRef.current);
36
- }
37
- else {
38
- ref.current = joditRef.current;
39
- }
40
- }
41
- }, [textAreaRef, ref, joditRef]);
42
48
  const preClassName = usePrevious(className ?? '');
43
49
  useEffect(() => {
44
50
  const classList = joditRef.current?.container?.classList;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jodit-react",
3
- "version": "5.3.20",
3
+ "version": "5.4.64",
4
4
  "description": "Jodit is awesome and usefully wysiwyg editor with filebrowser",
5
5
  "main": "build/jodit-react.js",
6
6
  "module": "./build/esm/index.mjs",
@@ -43,7 +43,7 @@
43
43
  "rte"
44
44
  ],
45
45
  "dependencies": {
46
- "jodit": "^4.8.10"
46
+ "jodit": "^4.13.12"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "react": "~0.14 || ^15 || ^16 || ^17 || ^18 || ^19",