jodit-pro-react 4.1.26 → 5.0.4

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.
@@ -1,9 +1,15 @@
1
+ /*!
2
+ * jodit - Jodit is an awesome and useful wysiwyg editor with filebrowser
3
+ * Author: Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/)
4
+ * Version: v4.2.49
5
+ * Url: https://xdsoft.net/jodit/
6
+ * License(s): MIT
7
+ */
8
+
1
9
  /*!
2
10
  * jodit-pro - PRO Version of Jodit Editor
3
11
  * Author: Chupurnov Valeriy <chupurnov@gmail.com>
4
- * Version: v4.2.53
12
+ * Version: v4.2.55
5
13
  * Url: https://xdsoft.net/jodit/pro/
6
14
  * License(s): SEE LICENSE IN LICENSE.md
7
15
  */
8
-
9
- /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jodit-pro-react",
3
- "version": "4.1.26",
3
+ "version": "5.0.4",
4
4
  "description": "Jodit PRO is awesome and usefully wysiwyg editor with filebrowser",
5
5
  "main": "jodit-react.js",
6
6
  "author": "Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/pro/)",
@@ -16,30 +16,29 @@
16
16
  "rte"
17
17
  ],
18
18
  "scripts": {
19
- "build": "webpack --mode=production --node-env=production",
20
- "watch": "webpack --watch",
21
- "start": "webpack serve"
19
+ "build": "node -r @swc-node/register ./node_modules/.bin/webpack --mode=production --node-env=production",
20
+ "watch": "node -r @swc-node/register ./node_modules/.bin/webpack --watch",
21
+ "start": "node -r @swc-node/register ./node_modules/.bin/webpack serve"
22
22
  },
23
23
  "devDependencies": {
24
- "@babel/core": "^7.22.5",
25
- "@babel/plugin-syntax-jsx": "^7.22.5",
26
- "@babel/preset-env": "^7.22.5",
27
- "@babel/preset-react": "^7.22.5",
28
- "@webpack-cli/generators": "^3.0.7",
29
- "babel-loader": "^9.1.2",
30
- "css-loader": "^6.8.1",
31
- "html-webpack-plugin": "^5.5.3",
32
- "jodit": "^4.2.47",
33
- "jodit-pro": "^4.2.53",
34
- "jodit-react": "^4.1.2",
35
- "style-loader": "^3.3.3",
36
- "webpack": "^5.88.1",
24
+ "@swc-node/register": "^1.10.9",
25
+ "css-loader": "^7.1.2",
26
+ "html-webpack-plugin": "^5.6.3",
27
+ "jodit": "^4.2.49",
28
+ "jodit-pro": "^4.2.55",
29
+ "jodit-react": "^5.0.10",
30
+ "replace": "^1.2.2",
31
+ "style-loader": "^4.0.0",
32
+ "swc-loader": "^0.2.6",
33
+ "ts-node": "^10.9.2",
34
+ "typescript": "^5.7.3",
35
+ "webpack": "^5.97.1",
37
36
  "webpack-cli": "^5.1.4",
38
- "webpack-dev-server": "^4.15.1"
37
+ "webpack-dev-server": "^5.1.0"
39
38
  },
40
39
  "peerDependencies": {
41
- "react": "~0.14 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0",
42
- "react-dom": "~0.14 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0"
40
+ "react": "~0.14 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
41
+ "react-dom": "~0.14 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
43
42
  },
44
43
  "repository": {
45
44
  "type": "git",
@@ -49,8 +48,5 @@
49
48
  "bugs": {
50
49
  "url": "https://xdsoft.net/jodit/pro/cab/issues/"
51
50
  },
52
- "homepage": "https://xdsoft.net/jodit/pro/",
53
- "dependencies": {
54
- "prop-types": "^15.8.1"
55
- }
51
+ "homepage": "https://xdsoft.net/jodit/pro/"
56
52
  }
@@ -0,0 +1,21 @@
1
+ import React from 'react';
2
+ import type { IJodit } from 'jodit/types/types/jodit';
3
+ import type { Jodit as JoditBaseConstructor } from 'jodit/types/index';
4
+ import type { Config as BaseConfig } from 'jodit/config';
5
+ import type { Config } from 'jodit/types/config';
6
+ import { Jodit } from './include.jodit';
7
+ import type { DeepPartial } from 'jodit/types/types';
8
+ interface Props<T extends typeof JoditBaseConstructor = typeof Jodit> {
9
+ JoditConstructor?: T;
10
+ config?: DeepPartial<Config & BaseConfig>;
11
+ className?: string;
12
+ id?: string;
13
+ name?: string;
14
+ onBlur?: (value: string, event: MouseEvent) => void;
15
+ onChange?: (value: string) => void;
16
+ tabIndex?: number;
17
+ value?: string;
18
+ editorRef?: (editor: IJodit) => void;
19
+ }
20
+ declare const JoditEditor: React.ForwardRefExoticComponent<Props<typeof JoditBaseConstructor> & React.RefAttributes<IJodit>>;
21
+ export default JoditEditor;
@@ -0,0 +1,101 @@
1
+ import React, { useEffect, useRef, forwardRef } from 'react';
2
+ import { Jodit } from './include.jodit';
3
+ function usePrevious(value) {
4
+ const ref = useRef('');
5
+ useEffect(() => {
6
+ ref.current = value;
7
+ }, [value]);
8
+ return ref.current;
9
+ }
10
+ const JoditEditor = forwardRef(({ JoditConstructor = Jodit, className, config, id, name, onBlur, onChange, tabIndex, value, editorRef }, ref) => {
11
+ const textAreaRef = useRef(null);
12
+ const joditRef = useRef(null);
13
+ useEffect(() => {
14
+ const element = textAreaRef.current;
15
+ const jodit = JoditConstructor.make(element, config);
16
+ joditRef.current = jodit;
17
+ if (typeof editorRef === 'function') {
18
+ editorRef(jodit);
19
+ }
20
+ return () => {
21
+ if (jodit.isReady) {
22
+ jodit.destruct();
23
+ }
24
+ else {
25
+ jodit
26
+ .waitForReady()
27
+ .then(joditInstance => joditInstance.destruct());
28
+ }
29
+ };
30
+ }, [JoditConstructor, config, editorRef]);
31
+ useEffect(() => {
32
+ if (ref) {
33
+ if (typeof ref === 'function') {
34
+ ref(joditRef.current);
35
+ }
36
+ else {
37
+ ref.current = joditRef.current;
38
+ }
39
+ }
40
+ }, [textAreaRef, ref, joditRef]);
41
+ const preClassName = usePrevious(className ?? '');
42
+ useEffect(() => {
43
+ const classList = joditRef.current?.container?.classList;
44
+ if (preClassName !== className &&
45
+ typeof preClassName === 'string') {
46
+ preClassName
47
+ .split(/\s+/)
48
+ .filter(Boolean)
49
+ .forEach(cl => classList?.remove(cl));
50
+ }
51
+ if (className && typeof className === 'string') {
52
+ className
53
+ .split(/\s+/)
54
+ .filter(Boolean)
55
+ .forEach(cl => classList?.add(cl));
56
+ }
57
+ }, [className, preClassName]);
58
+ useEffect(() => {
59
+ if (joditRef.current?.workplace) {
60
+ joditRef.current.workplace.tabIndex = tabIndex || -1;
61
+ }
62
+ }, [tabIndex]);
63
+ useEffect(() => {
64
+ const jodit = joditRef.current;
65
+ if (!jodit?.events || !(onBlur || onChange)) {
66
+ return;
67
+ }
68
+ const onBlurHandler = (event) => onBlur && onBlur(joditRef?.current?.value ?? '', event);
69
+ const onChangeHandler = (value) => onChange && onChange(value);
70
+ // adding event handlers
71
+ jodit.events
72
+ .on('blur', onBlurHandler)
73
+ .on('change', onChangeHandler);
74
+ return () => {
75
+ // Remove event handlers
76
+ jodit.events
77
+ ?.off('blur', onBlurHandler)
78
+ .off('change', onChangeHandler);
79
+ };
80
+ }, [onBlur, onChange]);
81
+ useEffect(() => {
82
+ const jodit = joditRef.current;
83
+ const updateValue = () => {
84
+ if (jodit && value !== undefined && jodit.value !== value) {
85
+ jodit.value = value;
86
+ }
87
+ };
88
+ if (jodit) {
89
+ if (jodit.isReady) {
90
+ updateValue();
91
+ }
92
+ else {
93
+ jodit.waitForReady().then(updateValue);
94
+ }
95
+ }
96
+ }, [value]);
97
+ return (React.createElement("div", { className: 'jodit-react-container' },
98
+ React.createElement("textarea", { defaultValue: value, name: name, id: id, ref: textAreaRef })));
99
+ });
100
+ JoditEditor.displayName = 'JoditEditor';
101
+ export default JoditEditor;
@@ -0,0 +1,3 @@
1
+ import type { Jodit as JoditConstructorType } from 'jodit';
2
+
3
+ export declare const Jodit: typeof JoditConstructorType;
@@ -0,0 +1,5 @@
1
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
2
+ // @ts-ignore - Jodit Editor (https://xdsoft.net/jodit/)
3
+ import { Jodit as JoditES5 } from 'jodit/es5/jodit.fat.min';
4
+ import 'jodit/es5/jodit.min.css';
5
+ export const Jodit = JoditES5;
@@ -0,0 +1,4 @@
1
+ import JoditEditor from './JoditEditor';
2
+ import { Jodit } from './include.jodit';
3
+ export default JoditEditor;
4
+ export { Jodit };
package/types/index.js ADDED
@@ -0,0 +1,4 @@
1
+ import JoditEditor from './JoditEditor';
2
+ import { Jodit } from './include.jodit';
3
+ export default JoditEditor;
4
+ export { Jodit };
package/index.d.ts DELETED
@@ -1,27 +0,0 @@
1
- import { Jodit } from 'jodit/esm/index';
2
- import * as React from 'react';
3
-
4
- type DeepPartial<T> = T extends object
5
- ? {
6
- [P in keyof T]?: DeepPartial<T[P]>;
7
- }
8
- : T;
9
-
10
- export interface IJoditEditorProps {
11
- value: string;
12
-
13
- className?: string;
14
-
15
- config?: DeepPartial<Jodit['options']>;
16
- // eslint-disable-next-line no-unused-vars
17
- onChange?: (newValue: string) => void;
18
- // eslint-disable-next-line no-unused-vars
19
- onBlur?: (newValue: string) => void;
20
- }
21
-
22
- declare const JoditEditor: React.ForwardRefExoticComponent<
23
- React.PropsWithoutRef<IJoditEditorProps> & React.RefAttributes<Jodit>
24
- >;
25
-
26
- export default JoditEditor;
27
- export { Jodit };