jodit-react 5.3.1 → 5.3.15
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/LICENSE +1 -1
- package/README.md +46 -37
- package/build/react-jodit.js +1 -1
- package/package.json +3 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -42,26 +42,27 @@ import React, { useState, useRef, useMemo } from 'react';
|
|
|
42
42
|
import JoditEditor from 'jodit-react';
|
|
43
43
|
|
|
44
44
|
const Example = ({ placeholder }) => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
45
|
+
const editor = useRef(null);
|
|
46
|
+
const [content, setContent] = useState('');
|
|
47
|
+
|
|
48
|
+
const config = useMemo(
|
|
49
|
+
() => ({
|
|
50
|
+
readonly: false, // all options from https://xdsoft.net/jodit/docs/,
|
|
51
|
+
placeholder: placeholder || 'Start typings...'
|
|
52
|
+
}),
|
|
53
|
+
[placeholder]
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
return (
|
|
57
|
+
<JoditEditor
|
|
58
|
+
ref={editor}
|
|
59
|
+
value={content}
|
|
60
|
+
config={config}
|
|
61
|
+
tabIndex={1} // tabIndex of textarea
|
|
62
|
+
onBlur={newContent => setContent(newContent)} // preferred to use only this option to update the content for performance reasons
|
|
63
|
+
onChange={newContent => {}}
|
|
64
|
+
/>
|
|
65
|
+
);
|
|
65
66
|
};
|
|
66
67
|
```
|
|
67
68
|
|
|
@@ -76,21 +77,21 @@ import JoditEditor, { Jodit } from 'jodit-react';
|
|
|
76
77
|
* @param {Jodit} jodit
|
|
77
78
|
*/
|
|
78
79
|
function preparePaste(jodit) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
80
|
+
jodit.e.on(
|
|
81
|
+
'paste',
|
|
82
|
+
e => {
|
|
83
|
+
if (confirm('Change pasted content?')) {
|
|
84
|
+
jodit.e.stopPropagation('paste');
|
|
85
|
+
jodit.s.insertHTML(
|
|
86
|
+
Jodit.modules.Helpers.getDataTransfer(e)
|
|
87
|
+
.getData(Jodit.constants.TEXT_HTML)
|
|
88
|
+
.replace(/a/g, 'b')
|
|
89
|
+
);
|
|
90
|
+
return false;
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{ top: true }
|
|
94
|
+
);
|
|
94
95
|
}
|
|
95
96
|
Jodit.plugins.add('preparePaste', preparePaste);
|
|
96
97
|
|
|
@@ -107,16 +108,24 @@ You can connect any Jodit constructor and set it as the `JoditConstructor` prope
|
|
|
107
108
|
```jsx
|
|
108
109
|
import React from 'react';
|
|
109
110
|
import JoditEditor from 'jodit-react';
|
|
110
|
-
import {Jodit} from 'jodit-pro';
|
|
111
|
+
import { Jodit } from 'jodit-pro';
|
|
111
112
|
import 'jodit-pro/es5/jodit.min.css';
|
|
112
113
|
// ...
|
|
113
114
|
|
|
114
115
|
function App() {
|
|
115
116
|
return <JoditEditor JoditConstructor={Jodit} />;
|
|
116
117
|
}
|
|
117
|
-
|
|
118
118
|
```
|
|
119
119
|
|
|
120
|
+
### Import and use Jodit-react inside your Next.js application
|
|
121
|
+
|
|
122
|
+
```js
|
|
123
|
+
import dynamic from 'next/dynamic';
|
|
124
|
+
|
|
125
|
+
const JoditEditor = dynamic(() => import('jodit-react'), {
|
|
126
|
+
ssr: false
|
|
127
|
+
});
|
|
128
|
+
```
|
|
120
129
|
|
|
121
130
|
## License
|
|
122
131
|
|