jodit-react 4.1.2 → 5.0.0-beta.2
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/.nvmrc +1 -1
- package/README.md +24 -5
- package/build/jodit-react.js +1 -1
- package/build/jodit-react.js.LICENSE.txt +1 -1
- package/build/types/JoditEditor.d.ts +21 -0
- package/build/types/include.jodit.d.ts +3 -0
- package/build/types/index.d.ts +4 -0
- package/examples/{app.js → app.tsx} +1 -1
- package/examples/components/{Form.js → Form.tsx} +22 -17
- package/examples/index.html +9 -9
- package/index.d.ts +1 -27
- package/package.json +44 -45
- package/src/JoditEditor.tsx +159 -0
- package/src/include.jodit.ts +7 -0
- package/tsconfig.json +18 -0
- package/.github/ISSUE_TEMPLATE.md +0 -18
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -14
- package/.github/workflows/new-version.yml +0 -42
- package/.github/workflows/release.yml +0 -36
- package/babel.config.json +0 -12
- package/examples/.babelrc +0 -12
- package/examples/webpack.config.js +0 -45
- package/src/JoditEditor.js +0 -146
- package/src/include.jodit.js +0 -4
- package/webpack.config.js +0 -70
- /package/src/{index.js → index.ts} +0 -0
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
var path = require('path');
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
4
|
-
entry: './app.js',
|
|
5
|
-
devtool: 'eval',
|
|
6
|
-
module: {
|
|
7
|
-
rules: [
|
|
8
|
-
{
|
|
9
|
-
test: /\.js$/,
|
|
10
|
-
use: [
|
|
11
|
-
{
|
|
12
|
-
loader: 'babel-loader',
|
|
13
|
-
options: {
|
|
14
|
-
presets: [
|
|
15
|
-
'@babel/preset-env',
|
|
16
|
-
'@babel/preset-react'
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
]
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
test: /\.css$/,
|
|
24
|
-
use: ['style-loader', 'css-loader']
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
output: {
|
|
30
|
-
path: path.join(__dirname, '/build/'),
|
|
31
|
-
filename: 'app.js'
|
|
32
|
-
},
|
|
33
|
-
|
|
34
|
-
devServer: {
|
|
35
|
-
static: './',
|
|
36
|
-
open: true,
|
|
37
|
-
allowedHosts: 'all',
|
|
38
|
-
client: {
|
|
39
|
-
progress: true,
|
|
40
|
-
overlay: true
|
|
41
|
-
},
|
|
42
|
-
port: 4000,
|
|
43
|
-
hot: true
|
|
44
|
-
}
|
|
45
|
-
};
|
package/src/JoditEditor.js
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
import React, { useEffect, useRef, forwardRef, useLayoutEffect } from 'react';
|
|
2
|
-
import { func, number, object, string } from 'prop-types';
|
|
3
|
-
import { Jodit } from './include.jodit';
|
|
4
|
-
|
|
5
|
-
const { isFunction } = Jodit.modules.Helpers;
|
|
6
|
-
|
|
7
|
-
function usePrevious(value) {
|
|
8
|
-
const ref = useRef();
|
|
9
|
-
useEffect(() => {
|
|
10
|
-
ref.current = value;
|
|
11
|
-
}, [value]);
|
|
12
|
-
return ref.current;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const JoditEditor = forwardRef(
|
|
16
|
-
(
|
|
17
|
-
{
|
|
18
|
-
className,
|
|
19
|
-
config,
|
|
20
|
-
id,
|
|
21
|
-
name,
|
|
22
|
-
onBlur,
|
|
23
|
-
onChange,
|
|
24
|
-
tabIndex,
|
|
25
|
-
value,
|
|
26
|
-
editorRef
|
|
27
|
-
},
|
|
28
|
-
ref
|
|
29
|
-
) => {
|
|
30
|
-
const textArea = useRef(null);
|
|
31
|
-
|
|
32
|
-
useLayoutEffect(() => {
|
|
33
|
-
if (ref) {
|
|
34
|
-
if (isFunction(ref)) {
|
|
35
|
-
ref(textArea.current);
|
|
36
|
-
} else {
|
|
37
|
-
ref.current = textArea.current;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}, [textArea, ref]);
|
|
41
|
-
|
|
42
|
-
useEffect(() => {
|
|
43
|
-
const element = textArea.current;
|
|
44
|
-
const jodit = Jodit.make(element, config);
|
|
45
|
-
textArea.current = jodit;
|
|
46
|
-
|
|
47
|
-
if (isFunction(editorRef)) {
|
|
48
|
-
editorRef(jodit);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return () => {
|
|
52
|
-
if (jodit) {
|
|
53
|
-
jodit.destruct();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
textArea.current = element;
|
|
57
|
-
};
|
|
58
|
-
}, [config, editorRef]);
|
|
59
|
-
|
|
60
|
-
const preClassName = usePrevious(className);
|
|
61
|
-
|
|
62
|
-
useEffect(() => {
|
|
63
|
-
const classList = textArea.current?.container?.classList;
|
|
64
|
-
|
|
65
|
-
if (
|
|
66
|
-
preClassName !== className &&
|
|
67
|
-
typeof preClassName === 'string'
|
|
68
|
-
) {
|
|
69
|
-
preClassName.split(/\s+/).forEach(cl => classList?.remove(cl));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (className && typeof className === 'string') {
|
|
73
|
-
className.split(/\s+/).forEach(cl => classList?.add(cl));
|
|
74
|
-
}
|
|
75
|
-
}, [className, preClassName]);
|
|
76
|
-
|
|
77
|
-
useEffect(() => {
|
|
78
|
-
if (textArea.current.workplace) {
|
|
79
|
-
textArea.current.workplace.tabIndex = tabIndex || -1;
|
|
80
|
-
}
|
|
81
|
-
}, [tabIndex]);
|
|
82
|
-
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
if (!textArea.current.events || (!onBlur && !onChange)) {
|
|
85
|
-
return;
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
const onBlurHandler = e =>
|
|
89
|
-
onBlur && onBlur(textArea.current.value, e);
|
|
90
|
-
const onChangeHandler = value => onChange && onChange(value);
|
|
91
|
-
|
|
92
|
-
// adding event handlers
|
|
93
|
-
textArea.current.events
|
|
94
|
-
.on('blur', onBlurHandler)
|
|
95
|
-
.on('change', onChangeHandler);
|
|
96
|
-
|
|
97
|
-
return () => {
|
|
98
|
-
// Remove event handlers
|
|
99
|
-
textArea.current?.events
|
|
100
|
-
?.off('blur', onBlurHandler)
|
|
101
|
-
.off('change', onChangeHandler);
|
|
102
|
-
};
|
|
103
|
-
}, [onBlur, onChange]);
|
|
104
|
-
|
|
105
|
-
useEffect(() => {
|
|
106
|
-
const updateValue = () => {
|
|
107
|
-
if (textArea.current && textArea?.current?.value !== value) {
|
|
108
|
-
textArea.current.value = value;
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
if (textArea.current) {
|
|
113
|
-
textArea.current.isReady
|
|
114
|
-
? updateValue()
|
|
115
|
-
: textArea.current.waitForReady().then(updateValue);
|
|
116
|
-
}
|
|
117
|
-
}, [value]);
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
<div className={'jodit-react-container'}>
|
|
121
|
-
<textarea
|
|
122
|
-
defaultValue={value}
|
|
123
|
-
name={name}
|
|
124
|
-
id={id}
|
|
125
|
-
ref={textArea}
|
|
126
|
-
/>
|
|
127
|
-
</div>
|
|
128
|
-
);
|
|
129
|
-
}
|
|
130
|
-
);
|
|
131
|
-
|
|
132
|
-
JoditEditor.displayName = 'JoditEditor';
|
|
133
|
-
|
|
134
|
-
JoditEditor.propTypes = {
|
|
135
|
-
className: string,
|
|
136
|
-
config: object,
|
|
137
|
-
id: string,
|
|
138
|
-
name: string,
|
|
139
|
-
onBlur: func,
|
|
140
|
-
onChange: func,
|
|
141
|
-
editorRef: func,
|
|
142
|
-
tabIndex: number,
|
|
143
|
-
value: string
|
|
144
|
-
};
|
|
145
|
-
|
|
146
|
-
export default JoditEditor;
|
package/src/include.jodit.js
DELETED
package/webpack.config.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
const webpack = require('webpack');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
|
|
4
|
-
module.exports = (env, argv, dir = process.cwd()) => {
|
|
5
|
-
const debug = !argv || !argv.mode || !argv.mode.match(/production/);
|
|
6
|
-
|
|
7
|
-
return {
|
|
8
|
-
context: dir,
|
|
9
|
-
|
|
10
|
-
entry: './src/index.js',
|
|
11
|
-
devtool: debug ? 'inline-source-map' : false,
|
|
12
|
-
|
|
13
|
-
module: {
|
|
14
|
-
rules: [
|
|
15
|
-
{
|
|
16
|
-
test: /\.js$/,
|
|
17
|
-
use: {
|
|
18
|
-
loader: 'babel-loader',
|
|
19
|
-
options: require(path.join(dir, './babel.config.json'))
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
{
|
|
23
|
-
test: /\.css$/,
|
|
24
|
-
use: ['style-loader', 'css-loader']
|
|
25
|
-
}
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
|
-
|
|
29
|
-
resolve: {
|
|
30
|
-
alias: {
|
|
31
|
-
'jodit-react': path.join(__dirname, './src')
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
|
|
35
|
-
output: {
|
|
36
|
-
path: path.join(dir, './build/'),
|
|
37
|
-
filename: 'jodit-react.js',
|
|
38
|
-
library: ['JoditEditor', 'Jodit'],
|
|
39
|
-
libraryTarget: 'umd'
|
|
40
|
-
},
|
|
41
|
-
|
|
42
|
-
plugins: [
|
|
43
|
-
new webpack.DefinePlugin({
|
|
44
|
-
'process.env': {
|
|
45
|
-
NODE_ENV: JSON.stringify(
|
|
46
|
-
debug ? 'development' : 'production'
|
|
47
|
-
)
|
|
48
|
-
}
|
|
49
|
-
}),
|
|
50
|
-
new webpack.optimize.ModuleConcatenationPlugin()
|
|
51
|
-
],
|
|
52
|
-
|
|
53
|
-
externals: {
|
|
54
|
-
jodit: 'jodit',
|
|
55
|
-
Jodit: 'Jodit',
|
|
56
|
-
react: {
|
|
57
|
-
root: 'React',
|
|
58
|
-
commonjs2: 'react',
|
|
59
|
-
commonjs: 'react',
|
|
60
|
-
amd: 'react'
|
|
61
|
-
},
|
|
62
|
-
'react-dom': {
|
|
63
|
-
root: 'ReactDOM',
|
|
64
|
-
commonjs2: 'react-dom',
|
|
65
|
-
commonjs: 'react-dom',
|
|
66
|
-
amd: 'react-dom'
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
};
|
|
File without changes
|