jodit-react 5.3.14 → 5.3.16
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/build/esm/JoditEditor-DBKuYyUu.d.mts +24 -0
- package/build/esm/JoditEditor.d.mts +7 -0
- package/build/esm/JoditEditor.mjs +6 -0
- package/build/esm/chunk-IWOD2W62.mjs +123 -0
- package/build/esm/index.d.mts +9 -21
- package/build/esm/index.mjs +4 -118
- package/build/types/JoditEditor.d.ts +2 -2
- package/build/types/index.d.ts +1 -0
- package/package.json +12 -2
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { IJodit } from 'jodit/esm/types/jodit';
|
|
3
|
+
import { Jodit as Jodit$2 } from 'jodit/esm/index';
|
|
4
|
+
import { Config } from 'jodit/esm/config';
|
|
5
|
+
import { Jodit as Jodit$1 } from 'jodit/esm/jodit';
|
|
6
|
+
import { DeepPartial } from 'jodit/esm/types';
|
|
7
|
+
|
|
8
|
+
declare const Jodit: typeof Jodit$1;
|
|
9
|
+
|
|
10
|
+
interface JoditEditorProps<T extends typeof Jodit$2 = typeof Jodit> {
|
|
11
|
+
JoditConstructor?: T;
|
|
12
|
+
config?: DeepPartial<Config>;
|
|
13
|
+
className?: string;
|
|
14
|
+
id?: string;
|
|
15
|
+
name?: string;
|
|
16
|
+
onBlur?: (value: string, event: MouseEvent) => void;
|
|
17
|
+
onChange?: (value: string) => void;
|
|
18
|
+
tabIndex?: number;
|
|
19
|
+
value?: string;
|
|
20
|
+
editorRef?: (editor: IJodit) => void;
|
|
21
|
+
}
|
|
22
|
+
declare const JoditEditor: React.ForwardRefExoticComponent<JoditEditorProps<typeof Jodit$2> & React.RefAttributes<IJodit>>;
|
|
23
|
+
|
|
24
|
+
export { JoditEditor as J, Jodit as a, type JoditEditorProps as b };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
// src/JoditEditor.tsx
|
|
2
|
+
import { useEffect, useRef, forwardRef } from "react";
|
|
3
|
+
|
|
4
|
+
// src/include.jodit.ts
|
|
5
|
+
import { Jodit as JoditES5 } from "jodit/esm/index";
|
|
6
|
+
import "jodit/es2021/jodit.min.css";
|
|
7
|
+
import "jodit/esm/plugins/all";
|
|
8
|
+
var Jodit = JoditES5;
|
|
9
|
+
|
|
10
|
+
// src/JoditEditor.tsx
|
|
11
|
+
import { jsx } from "react/jsx-runtime";
|
|
12
|
+
function usePrevious(value) {
|
|
13
|
+
const ref = useRef("");
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
ref.current = value;
|
|
16
|
+
}, [value]);
|
|
17
|
+
return ref.current;
|
|
18
|
+
}
|
|
19
|
+
var JoditEditor = forwardRef(
|
|
20
|
+
({
|
|
21
|
+
JoditConstructor = Jodit,
|
|
22
|
+
className,
|
|
23
|
+
config,
|
|
24
|
+
id,
|
|
25
|
+
name,
|
|
26
|
+
onBlur,
|
|
27
|
+
onChange,
|
|
28
|
+
tabIndex,
|
|
29
|
+
value,
|
|
30
|
+
editorRef
|
|
31
|
+
}, ref) => {
|
|
32
|
+
const textAreaRef = useRef(null);
|
|
33
|
+
const joditRef = useRef(null);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const element = textAreaRef.current;
|
|
36
|
+
const jodit = JoditConstructor.make(element, config);
|
|
37
|
+
joditRef.current = jodit;
|
|
38
|
+
if (typeof editorRef === "function") {
|
|
39
|
+
editorRef(jodit);
|
|
40
|
+
}
|
|
41
|
+
return () => {
|
|
42
|
+
if (jodit.isReady) {
|
|
43
|
+
jodit.destruct();
|
|
44
|
+
} else {
|
|
45
|
+
jodit.waitForReady().then((joditInstance) => joditInstance.destruct());
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}, [JoditConstructor, config, editorRef]);
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (ref) {
|
|
51
|
+
if (typeof ref === "function") {
|
|
52
|
+
ref(joditRef.current);
|
|
53
|
+
} else {
|
|
54
|
+
ref.current = joditRef.current;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}, [textAreaRef, ref, joditRef]);
|
|
58
|
+
const preClassName = usePrevious(className != null ? className : "");
|
|
59
|
+
useEffect(() => {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
const classList = (_b = (_a = joditRef.current) == null ? void 0 : _a.container) == null ? void 0 : _b.classList;
|
|
62
|
+
if (preClassName !== className && typeof preClassName === "string") {
|
|
63
|
+
preClassName.split(/\s+/).filter(Boolean).forEach((cl) => classList == null ? void 0 : classList.remove(cl));
|
|
64
|
+
}
|
|
65
|
+
if (className && typeof className === "string") {
|
|
66
|
+
className.split(/\s+/).filter(Boolean).forEach((cl) => classList == null ? void 0 : classList.add(cl));
|
|
67
|
+
}
|
|
68
|
+
}, [className, preClassName]);
|
|
69
|
+
useEffect(() => {
|
|
70
|
+
var _a;
|
|
71
|
+
if ((_a = joditRef.current) == null ? void 0 : _a.workplace) {
|
|
72
|
+
joditRef.current.workplace.tabIndex = tabIndex || -1;
|
|
73
|
+
}
|
|
74
|
+
}, [tabIndex]);
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
const jodit = joditRef.current;
|
|
77
|
+
if (!(jodit == null ? void 0 : jodit.events) || !(onBlur || onChange)) {
|
|
78
|
+
return;
|
|
79
|
+
}
|
|
80
|
+
const onBlurHandler = (event) => {
|
|
81
|
+
var _a, _b;
|
|
82
|
+
return onBlur && onBlur((_b = (_a = joditRef == null ? void 0 : joditRef.current) == null ? void 0 : _a.value) != null ? _b : "", event);
|
|
83
|
+
};
|
|
84
|
+
const onChangeHandler = (value2) => onChange && onChange(value2);
|
|
85
|
+
jodit.events.on("blur", onBlurHandler).on("change", onChangeHandler);
|
|
86
|
+
return () => {
|
|
87
|
+
var _a;
|
|
88
|
+
(_a = jodit.events) == null ? void 0 : _a.off("blur", onBlurHandler).off("change", onChangeHandler);
|
|
89
|
+
};
|
|
90
|
+
}, [onBlur, onChange]);
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
const jodit = joditRef.current;
|
|
93
|
+
const updateValue = () => {
|
|
94
|
+
if (jodit && value !== void 0 && jodit.value !== value) {
|
|
95
|
+
jodit.value = value;
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
if (jodit) {
|
|
99
|
+
if (jodit.isReady) {
|
|
100
|
+
updateValue();
|
|
101
|
+
} else {
|
|
102
|
+
jodit.waitForReady().then(updateValue);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}, [value]);
|
|
106
|
+
return /* @__PURE__ */ jsx("div", { className: "jodit-react-container", children: /* @__PURE__ */ jsx(
|
|
107
|
+
"textarea",
|
|
108
|
+
{
|
|
109
|
+
defaultValue: value,
|
|
110
|
+
name,
|
|
111
|
+
id,
|
|
112
|
+
ref: textAreaRef
|
|
113
|
+
}
|
|
114
|
+
) });
|
|
115
|
+
}
|
|
116
|
+
);
|
|
117
|
+
JoditEditor.displayName = "JoditEditor";
|
|
118
|
+
var JoditEditor_default = JoditEditor;
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
Jodit,
|
|
122
|
+
JoditEditor_default
|
|
123
|
+
};
|
package/build/esm/index.d.mts
CHANGED
|
@@ -1,24 +1,12 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
1
|
+
import { J as JoditEditor } from './JoditEditor-DBKuYyUu.mjs';
|
|
2
|
+
export { a as Jodit, b as JoditEditorProps } from './JoditEditor-DBKuYyUu.mjs';
|
|
3
|
+
import 'react';
|
|
4
|
+
import 'jodit/esm/types/jodit';
|
|
5
|
+
import 'jodit/esm/index';
|
|
6
|
+
import 'jodit/esm/config';
|
|
7
|
+
import 'jodit/esm/jodit';
|
|
8
|
+
import 'jodit/esm/types';
|
|
7
9
|
|
|
8
|
-
declare const Jodit: typeof Jodit$1;
|
|
9
10
|
|
|
10
|
-
interface Props<T extends typeof Jodit$2 = typeof Jodit> {
|
|
11
|
-
JoditConstructor?: T;
|
|
12
|
-
config?: DeepPartial<Config>;
|
|
13
|
-
className?: string;
|
|
14
|
-
id?: string;
|
|
15
|
-
name?: string;
|
|
16
|
-
onBlur?: (value: string, event: MouseEvent) => void;
|
|
17
|
-
onChange?: (value: string) => void;
|
|
18
|
-
tabIndex?: number;
|
|
19
|
-
value?: string;
|
|
20
|
-
editorRef?: (editor: IJodit) => void;
|
|
21
|
-
}
|
|
22
|
-
declare const JoditEditor: React.ForwardRefExoticComponent<Props<typeof Jodit$2> & React.RefAttributes<IJodit>>;
|
|
23
11
|
|
|
24
|
-
export {
|
|
12
|
+
export { JoditEditor as default };
|
package/build/esm/index.mjs
CHANGED
|
@@ -1,121 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import { Jodit as JoditES5 } from "jodit/esm/index";
|
|
6
|
-
import "jodit/es2021/jodit.min.css";
|
|
7
|
-
import "jodit/esm/plugins/all";
|
|
8
|
-
var Jodit = JoditES5;
|
|
9
|
-
|
|
10
|
-
// src/JoditEditor.tsx
|
|
11
|
-
import { jsx } from "react/jsx-runtime";
|
|
12
|
-
function usePrevious(value) {
|
|
13
|
-
const ref = useRef("");
|
|
14
|
-
useEffect(() => {
|
|
15
|
-
ref.current = value;
|
|
16
|
-
}, [value]);
|
|
17
|
-
return ref.current;
|
|
18
|
-
}
|
|
19
|
-
var JoditEditor = forwardRef(
|
|
20
|
-
({
|
|
21
|
-
JoditConstructor = Jodit,
|
|
22
|
-
className,
|
|
23
|
-
config,
|
|
24
|
-
id,
|
|
25
|
-
name,
|
|
26
|
-
onBlur,
|
|
27
|
-
onChange,
|
|
28
|
-
tabIndex,
|
|
29
|
-
value,
|
|
30
|
-
editorRef
|
|
31
|
-
}, ref) => {
|
|
32
|
-
const textAreaRef = useRef(null);
|
|
33
|
-
const joditRef = useRef(null);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const element = textAreaRef.current;
|
|
36
|
-
const jodit = JoditConstructor.make(element, config);
|
|
37
|
-
joditRef.current = jodit;
|
|
38
|
-
if (typeof editorRef === "function") {
|
|
39
|
-
editorRef(jodit);
|
|
40
|
-
}
|
|
41
|
-
return () => {
|
|
42
|
-
if (jodit.isReady) {
|
|
43
|
-
jodit.destruct();
|
|
44
|
-
} else {
|
|
45
|
-
jodit.waitForReady().then((joditInstance) => joditInstance.destruct());
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}, [JoditConstructor, config, editorRef]);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (ref) {
|
|
51
|
-
if (typeof ref === "function") {
|
|
52
|
-
ref(joditRef.current);
|
|
53
|
-
} else {
|
|
54
|
-
ref.current = joditRef.current;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
}, [textAreaRef, ref, joditRef]);
|
|
58
|
-
const preClassName = usePrevious(className != null ? className : "");
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
var _a, _b;
|
|
61
|
-
const classList = (_b = (_a = joditRef.current) == null ? void 0 : _a.container) == null ? void 0 : _b.classList;
|
|
62
|
-
if (preClassName !== className && typeof preClassName === "string") {
|
|
63
|
-
preClassName.split(/\s+/).filter(Boolean).forEach((cl) => classList == null ? void 0 : classList.remove(cl));
|
|
64
|
-
}
|
|
65
|
-
if (className && typeof className === "string") {
|
|
66
|
-
className.split(/\s+/).filter(Boolean).forEach((cl) => classList == null ? void 0 : classList.add(cl));
|
|
67
|
-
}
|
|
68
|
-
}, [className, preClassName]);
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
var _a;
|
|
71
|
-
if ((_a = joditRef.current) == null ? void 0 : _a.workplace) {
|
|
72
|
-
joditRef.current.workplace.tabIndex = tabIndex || -1;
|
|
73
|
-
}
|
|
74
|
-
}, [tabIndex]);
|
|
75
|
-
useEffect(() => {
|
|
76
|
-
const jodit = joditRef.current;
|
|
77
|
-
if (!(jodit == null ? void 0 : jodit.events) || !(onBlur || onChange)) {
|
|
78
|
-
return;
|
|
79
|
-
}
|
|
80
|
-
const onBlurHandler = (event) => {
|
|
81
|
-
var _a, _b;
|
|
82
|
-
return onBlur && onBlur((_b = (_a = joditRef == null ? void 0 : joditRef.current) == null ? void 0 : _a.value) != null ? _b : "", event);
|
|
83
|
-
};
|
|
84
|
-
const onChangeHandler = (value2) => onChange && onChange(value2);
|
|
85
|
-
jodit.events.on("blur", onBlurHandler).on("change", onChangeHandler);
|
|
86
|
-
return () => {
|
|
87
|
-
var _a;
|
|
88
|
-
(_a = jodit.events) == null ? void 0 : _a.off("blur", onBlurHandler).off("change", onChangeHandler);
|
|
89
|
-
};
|
|
90
|
-
}, [onBlur, onChange]);
|
|
91
|
-
useEffect(() => {
|
|
92
|
-
const jodit = joditRef.current;
|
|
93
|
-
const updateValue = () => {
|
|
94
|
-
if (jodit && value !== void 0 && jodit.value !== value) {
|
|
95
|
-
jodit.value = value;
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
if (jodit) {
|
|
99
|
-
if (jodit.isReady) {
|
|
100
|
-
updateValue();
|
|
101
|
-
} else {
|
|
102
|
-
jodit.waitForReady().then(updateValue);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}, [value]);
|
|
106
|
-
return /* @__PURE__ */ jsx("div", { className: "jodit-react-container", children: /* @__PURE__ */ jsx(
|
|
107
|
-
"textarea",
|
|
108
|
-
{
|
|
109
|
-
defaultValue: value,
|
|
110
|
-
name,
|
|
111
|
-
id,
|
|
112
|
-
ref: textAreaRef
|
|
113
|
-
}
|
|
114
|
-
) });
|
|
115
|
-
}
|
|
116
|
-
);
|
|
117
|
-
JoditEditor.displayName = "JoditEditor";
|
|
118
|
-
var JoditEditor_default = JoditEditor;
|
|
1
|
+
import {
|
|
2
|
+
Jodit,
|
|
3
|
+
JoditEditor_default
|
|
4
|
+
} from "./chunk-IWOD2W62.mjs";
|
|
119
5
|
|
|
120
6
|
// src/index.ts
|
|
121
7
|
var index_default = JoditEditor_default;
|
|
@@ -4,7 +4,7 @@ import type { Jodit as JoditBaseConstructor } from 'jodit/esm/index';
|
|
|
4
4
|
import type { Config } from 'jodit/esm/config';
|
|
5
5
|
import { Jodit } from './include.jodit';
|
|
6
6
|
import type { DeepPartial } from 'jodit/esm/types';
|
|
7
|
-
interface
|
|
7
|
+
export interface JoditEditorProps<T extends typeof JoditBaseConstructor = typeof Jodit> {
|
|
8
8
|
JoditConstructor?: T;
|
|
9
9
|
config?: DeepPartial<Config>;
|
|
10
10
|
className?: string;
|
|
@@ -16,5 +16,5 @@ interface Props<T extends typeof JoditBaseConstructor = typeof Jodit> {
|
|
|
16
16
|
value?: string;
|
|
17
17
|
editorRef?: (editor: IJodit) => void;
|
|
18
18
|
}
|
|
19
|
-
declare const JoditEditor: React.ForwardRefExoticComponent<
|
|
19
|
+
declare const JoditEditor: React.ForwardRefExoticComponent<JoditEditorProps<typeof JoditBaseConstructor> & React.RefAttributes<IJodit>>;
|
|
20
20
|
export default JoditEditor;
|
package/build/types/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jodit-react",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.16",
|
|
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",
|
|
@@ -15,6 +15,16 @@
|
|
|
15
15
|
"types": "./build/types/index.d.ts",
|
|
16
16
|
"default": "./build/react-jodit.js"
|
|
17
17
|
}
|
|
18
|
+
},
|
|
19
|
+
"./types/JoditEditor": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./build/esm/JoditEditor.d.mts",
|
|
22
|
+
"default": "./build/esm/JoditEditor.mjs"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./build/types/JoditEditor.d.ts",
|
|
26
|
+
"default": "./build/types/JoditEditor.js"
|
|
27
|
+
}
|
|
18
28
|
}
|
|
19
29
|
},
|
|
20
30
|
"files": [
|
|
@@ -84,7 +94,7 @@
|
|
|
84
94
|
"build": "npm run build:react && npm run build:types && npm run build:esm",
|
|
85
95
|
"build:react": "cross-env NODE_ENV=production node -r @swc-node/register ./node_modules/.bin/webpack --mode production",
|
|
86
96
|
"build:types": "rm -rf ./build/types && tsc --project tsconfig.types.json && npm run remove-css",
|
|
87
|
-
"build:esm": "tsup src/index.ts --dts --format esm -d ./build/esm --clean",
|
|
97
|
+
"build:esm": "tsup src/index.ts src/JoditEditor.tsx --dts --format esm -d ./build/esm --clean",
|
|
88
98
|
"remove-css": "replace \"import '[^']+.css';\" ''./build/**/*.ts",
|
|
89
99
|
"github": "npm run git && git push --tags origin HEAD:main",
|
|
90
100
|
"git": "git add --all && git commit -m \"New version $npm_package_version. Read more https://github.com/jodit/jodit-react/releases/tag/$npm_package_version \" && git tag $npm_package_version",
|