jodit-react 1.3.18 → 1.3.19

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/CHANGELOG.md CHANGED
@@ -9,7 +9,68 @@
9
9
  > - :house: [Internal]
10
10
  > - :nail_care: [Polish]
11
11
 
12
- ## 1.3.17
12
+ ## 1.3.19
13
+
14
+ #### :rocket: New Feature
15
+
16
+ - The package now re-exports imperative Jodit, so you can write plugins and use all Jodit helpers
17
+
18
+ ```js
19
+ import JoditEditor, { Jodit } from '../../src/';
20
+
21
+ /**
22
+ * @param {Jodit} jodit
23
+ */
24
+ function preparePaste(jodit) {
25
+ jodit.e.on(
26
+ 'paste',
27
+ e => {
28
+ if (confirm('Change pasted content?')) {
29
+ jodit.e.stopPropagation('paste');
30
+ jodit.s.insertHTML(
31
+ Jodit.modules.Helpers.getDataTransfer(e)
32
+ .getData(Jodit.constants.TEXT_HTML)
33
+ .replace(/a/g, 'b')
34
+ );
35
+ return false;
36
+ }
37
+ },
38
+ { top: true }
39
+ );
40
+ }
41
+ Jodit.plugins.add('preparePaste', preparePaste);
42
+
43
+ //...
44
+ return <JoditEditor />;
45
+ ```
46
+
47
+ #### :house: Internal
48
+
49
+ - Update
50
+
51
+ ```
52
+ eslint-plugin-react-hooks ^4.5.0 → ^4.6.0
53
+ @babel/core ^7.16.0 → ^7.19.0
54
+ @babel/eslint-parser ^7.17.0 → ^7.18.9
55
+ @babel/preset-env ^7.16.0 → ^7.19.0
56
+ @babel/preset-react ^7.16.0 → ^7.18.6
57
+ @types/react ^16.14.2 → ^18.0.18
58
+ babel-loader ^8.2.2 → ^8.2.5
59
+ css-loader ^3.6.0 → ^6.7.1
60
+ eslint ^8.9.0 → ^8.23.0
61
+ eslint-config-prettier ^8.4.0 → ^8.5.0
62
+ eslint-plugin-prettier ^4.0.0 → ^4.2.1
63
+ eslint-plugin-react ^7.28.0 → ^7.31.8
64
+ husky ^7.0.4 → ^8.0.1
65
+ lint-staged ^12.3.4 → ^13.0.3
66
+ prettier ^2.5.1 → ^2.7.1
67
+ style-loader ^0.20.3 → ^3.3.1
68
+ webpack ^4.44.2 → ^5.74.0
69
+ webpack-cli ^3.3.12 → ^4.10.0
70
+ webpack-dev-server ^3.11.0 → ^4.11.0
71
+ ```
72
+
73
+ ## 1.3.18
13
74
 
14
75
  #### :bug: Bug Fix
15
76
 
package/README.md CHANGED
@@ -15,17 +15,20 @@ npm install jodit-react --save
15
15
  ```
16
16
 
17
17
  ## Update editor version
18
+
18
19
  ```bash
19
20
  npm update jodit-react
20
21
  ```
21
22
 
22
23
  ## Run demo
24
+
23
25
  ```bash
24
26
  npm install --dev
25
27
  npm run demo
26
28
  ```
27
29
 
28
30
  and open
31
+
29
32
  ```
30
33
  http://localhost:4000/
31
34
  ```
@@ -35,32 +38,65 @@ http://localhost:4000/
35
38
  ### 1. Require and use Jodit-react component inside your application.
36
39
 
37
40
  ```jsx
38
- import React, {useState, useRef, useMemo} from 'react';
39
- import JoditEditor from "jodit-react";
41
+ import React, { useState, useRef, useMemo } from 'react';
42
+ import JoditEditor from 'jodit-react';
40
43
 
41
- const Example = ({placeholder}) => {
42
- const editor = useRef(null)
43
- const [content, setContent] = useState('')
44
+ const Example = ({ placeholder }) => {
45
+ const editor = useRef(null);
46
+ const [content, setContent] = useState('');
44
47
 
45
- const config = useMemo({
46
- readonly: false // all options from https://xdsoft.net/jodit/doc/,
47
- placeholder: placeholder || 'Start typings...'
48
- }, [placeholder])
48
+ const config = useMemo(
49
+ {
50
+ readonly: false, // all options from https://xdsoft.net/jodit/doc/,
51
+ placeholder: placeholder || 'Start typings...'
52
+ },
53
+ [placeholder]
54
+ );
49
55
 
50
56
  return (
51
- <JoditEditor
52
- ref={editor}
53
- value={content}
54
- config={config}
55
- tabIndex={1} // tabIndex of textarea
56
- onBlur={newContent => setContent(newContent)} // preferred to use only this option to update the content for performance reasons
57
- onChange={newContent => {}}
58
- />
59
- );
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
+ );
66
+ };
67
+ ```
68
+
69
+ You can use all Jodit functinality
70
+
71
+ ```js
72
+ import JoditEditor, { Jodit } from '../../src/';
73
+
74
+ /**
75
+ * @param {Jodit} jodit
76
+ */
77
+ function preparePaste(jodit) {
78
+ jodit.e.on(
79
+ 'paste',
80
+ e => {
81
+ if (confirm('Change pasted content?')) {
82
+ jodit.e.stopPropagation('paste');
83
+ jodit.s.insertHTML(
84
+ Jodit.modules.Helpers.getDataTransfer(e)
85
+ .getData(Jodit.constants.TEXT_HTML)
86
+ .replace(/a/g, 'b')
87
+ );
88
+ return false;
89
+ }
90
+ },
91
+ { top: true }
92
+ );
60
93
  }
94
+ Jodit.plugins.add('preparePaste', preparePaste);
95
+
96
+ //...
97
+ return <JoditEditor/>;
61
98
  ```
62
99
 
100
+ ## License
63
101
 
64
- License
65
- -----
66
102
  This package is available under `MIT` License.