jodit-react 5.2.41 → 5.3.14

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/examples/app.css DELETED
@@ -1,185 +0,0 @@
1
- html {
2
- -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
3
- }
4
-
5
- html, body {
6
- height: 100%;
7
- margin: 0;
8
- }
9
-
10
- body {
11
- font-family: 'Source Sans Pro', 'Helvetica Neue', Helvetica, Arial, sans-serif;
12
- font-size: 16px;
13
- -webkit-font-smoothing: antialiased;
14
- text-rendering: optimizelegibility;
15
- line-height: 1.5;
16
- font-weight: 300;
17
- }
18
-
19
- body {
20
- display: flex;
21
- flex-direction: column;
22
- }
23
-
24
- header,
25
- #main_container {
26
- flex: 1 0 auto;
27
- }
28
-
29
- .jodit_wysiwyg {
30
- color: #000;
31
- padding: 10px;
32
- overflow-x: auto;
33
- min-height: 40px;
34
- }
35
-
36
- * {
37
- -webkit-box-sizing: border-box;
38
- -moz-box-sizing: border-box;
39
- box-sizing: border-box;
40
- }
41
-
42
- .table, .p {
43
- margin: 0 0 16px 0;
44
- }
45
-
46
- .table {
47
- border: 0;
48
- border-collapse: collapse;
49
- empty-cells: show;
50
- max-width: 100%;
51
- border-spacing: 0;
52
- *border-collapse: collapse;
53
- }
54
-
55
- . table tr {
56
- user-select: none;
57
- -o-user-select: none;
58
- -moz-user-select: none;
59
- -khtml-user-select: none;
60
- -webkit-user-select: none;
61
- -ms-user-select: none;
62
- }
63
-
64
- . table td, . table th {
65
- user-select: text;
66
- -o-user-select: text;
67
- -moz-user-select: text;
68
- -khtml-user-select: text;
69
- -webkit-user-select: text;
70
- -ms-user-select: text;
71
- }
72
-
73
- . table th, . table td {
74
- box-sizing: border-box;
75
- padding: 2px 5px;
76
- vertical-align: top;
77
- }
78
-
79
- .table td, . table th {
80
- border: 1px solid #ddd;
81
- }
82
-
83
- .container {
84
- width: 1000px;
85
- margin: 0 auto;
86
- }
87
-
88
- nav {
89
- height: 30px;
90
- background: linear-gradient(to left, #28a5f5, #1e87f0);
91
- padding: 0;
92
- overflow: hidden;
93
- }
94
-
95
- footer nav {
96
- background: #f9f9f9;
97
- margin-top: 20px;
98
- }
99
-
100
- nav > ul {
101
- padding: 0;
102
- margin: 0;
103
- }
104
-
105
- nav > ul > li {
106
- list-style: none;
107
- display: inline-block;
108
- padding: 0;
109
- margin: 0;
110
- }
111
-
112
- nav > ul > li + li {
113
- margin-left: 23px;
114
- }
115
-
116
- nav ul li a {
117
- color: #ddd;
118
- text-decoration: none;
119
- text-transform: uppercase;
120
- font-size: 0.625rem;
121
- line-height: 30px;
122
- }
123
-
124
- nav ul li a:hover {
125
- color: #aaa;
126
- text-decoration: underline;
127
- }
128
-
129
- footer nav ul li a {
130
- color: #3f3f3f;
131
- }
132
-
133
- nav ul li ul {
134
- position: absolute;
135
- margin: 0;
136
- padding: 0;
137
- background-color: #208bf1;
138
- display: none;
139
- }
140
-
141
- nav > ul > li:hover > ul {
142
- display: block;
143
- }
144
-
145
- nav ul li ul li {
146
- list-style: none;
147
- display: block;
148
- padding: 0;
149
- margin: 0;
150
- }
151
-
152
- nav ul li ul li a {
153
- padding: 5px;
154
- }
155
-
156
- .layout {
157
- display: flex;
158
- flex-direction: row;
159
- }
160
-
161
- .layout > * {
162
-
163
- }
164
-
165
- .leftside {
166
- width: 20%;
167
- padding: 10px 10px 10px 0;
168
- }
169
-
170
- .rightside {
171
- width: 80%;
172
- padding: 10px 0 10px 10px;
173
-
174
- }
175
-
176
- pre {
177
- white-space: pre-wrap;
178
- background-color: #3f3f3f;
179
- color: #fff;
180
- padding: 10px;
181
- }
182
-
183
- h1, h2, h3, h4, h5, h6 {
184
- font-weight: 500;
185
- }
package/examples/app.tsx DELETED
@@ -1,17 +0,0 @@
1
- import './app.css';
2
-
3
- import React, { StrictMode } from 'react';
4
- import Form from './components/Form';
5
-
6
- // For React < 18
7
- // import ReactDOM from 'react-dom';
8
- // ReactDOM.render(<Form />, document.getElementById('editor'));
9
-
10
- import { createRoot } from 'react-dom/client';
11
- const container = document.getElementById('editor')!;
12
- const root = createRoot(container);
13
- root.render(
14
- <StrictMode>
15
- <Form />
16
- </StrictMode>
17
- );
@@ -1,5 +0,0 @@
1
- .simple-textarea {
2
- display: block;
3
- width: 100%;
4
- min-height: 100px;
5
- }
@@ -1,148 +0,0 @@
1
- import React, { type ChangeEvent, useCallback, useState } from 'react';
2
-
3
- import JoditEditor, { Jodit } from '../../src/';
4
- import './Form.css';
5
- import type { IJodit } from 'jodit/types/types/jodit';
6
-
7
- /**
8
- * @param {Jodit} jodit
9
- */
10
- function preparePaste(jodit: IJodit) {
11
- jodit.e.on(
12
- 'paste',
13
- e => {
14
- if (confirm('Change pasted content?')) {
15
- jodit.e.stopPropagation('paste');
16
- jodit.s.insertHTML(
17
- Jodit.modules.Helpers.getDataTransfer(e)!
18
- .getData(Jodit.constants.TEXT_HTML)
19
- ?.replace(/a/g, 'b') ?? ''
20
- );
21
- return false;
22
- }
23
- },
24
- { top: true }
25
- );
26
- }
27
- Jodit.plugins.add('preparePaste', preparePaste);
28
-
29
- const Form = () => {
30
- const [isSource, setSource] = useState(false);
31
-
32
- const [config, setConfig] = useState({
33
- toolbarAdaptive: false,
34
- readonly: false,
35
- toolbar: true
36
- });
37
-
38
- const [textAreaValue, setTextAreaValue] = useState('Test');
39
-
40
- const [inputValue, setInputValue] = useState('');
41
-
42
- const [spin, setSpin] = useState(1);
43
-
44
- const toggleToolbar = useCallback(
45
- () =>
46
- setConfig(config => ({
47
- ...config,
48
- toolbar: !config.toolbar
49
- })),
50
- []
51
- );
52
-
53
- const toggleReadOnly = useCallback(
54
- () =>
55
- setConfig(config => ({
56
- ...config,
57
- readonly: !config.readonly
58
- })),
59
- []
60
- );
61
-
62
- const handleBlurAreaChange = useCallback(
63
- (textAreaValue: string, event: MouseEvent) => {
64
- console.log('handleBlurAreaChange', textAreaValue, event);
65
- },
66
- []
67
- );
68
-
69
- const handleWYSIWYGChange = useCallback((newTextAreaValue: string) => {
70
- console.log('handleWYSIWYGChange', newTextAreaValue);
71
-
72
- setTextAreaValue(newTextAreaValue);
73
- setInputValue(newTextAreaValue);
74
-
75
- return setTextAreaValue(() => newTextAreaValue);
76
- }, []);
77
-
78
- const handleNativeTextAreaChange = useCallback((e: ChangeEvent) => {
79
- const value = (e.target as HTMLTextAreaElement).value;
80
- console.log('handleNativeTextAreaChange', value);
81
- setTextAreaValue(value);
82
- setInputValue(value);
83
- }, []);
84
-
85
- const handleInputChange = useCallback(
86
- (e: ChangeEvent) => {
87
- const { value } = e.target as HTMLInputElement;
88
- setInputValue(value);
89
- handleWYSIWYGChange(value);
90
- },
91
- [handleWYSIWYGChange]
92
- );
93
-
94
- const handleSpin = useCallback(() => setSpin(spin => ++spin), []);
95
-
96
- const onSourceChange = useCallback((e: ChangeEvent) => {
97
- setSource((e.target as HTMLInputElement).checked);
98
- }, []);
99
-
100
- return (
101
- <div>
102
- <label>
103
- <input
104
- type="checkbox"
105
- onChange={onSourceChange}
106
- checked={isSource}
107
- />{' '}
108
- Source
109
- </label>
110
-
111
- {!isSource ? (
112
- <JoditEditor
113
- config={config}
114
- onChange={handleWYSIWYGChange}
115
- onBlur={handleBlurAreaChange}
116
- value={textAreaValue}
117
- />
118
- ) : (
119
- <textarea
120
- className={'simple-textarea'}
121
- onChange={handleNativeTextAreaChange}
122
- value={textAreaValue}
123
- />
124
- )}
125
-
126
- <input
127
- onChange={handleInputChange}
128
- placeholder={'enter some text'}
129
- type={'text'}
130
- value={inputValue}
131
- />
132
-
133
- <button onClick={toggleReadOnly} type={'button'}>
134
- {'Toggle Read-Only'}
135
- </button>
136
-
137
- <button onClick={toggleToolbar} type={'button'}>
138
- {'Toggle Toolbar'}
139
- </button>
140
-
141
- <button type={'button'} onClick={handleSpin}>
142
- {`Spin ${spin}`}
143
- </button>
144
- </div>
145
- );
146
- };
147
-
148
- export default Form;
@@ -1,66 +0,0 @@
1
- <!doctype html>
2
- <!--
3
- * Jodit Editor (https://xdsoft.net/jodit/)
4
- * License https://xdsoft.net/jodit/license.html
5
- * Copyright 2013-2018 Valeriy Chupurnov https://xdsoft.net
6
- -->
7
- <html lang="en">
8
- <head>
9
- <meta charset="UTF-8"/>
10
- <meta name="viewport"
11
- content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
12
- <meta http-equiv="X-UA-Compatible" content="ie=edge"/>
13
- <title>Jodit React Example</title>
14
- </head>
15
- <body>
16
- <header>
17
- <nav>
18
- <ul class="container">
19
- <li><a href="https://xdsoft.net/jodit/">Jodit homepage</a></li>
20
- <li><a href="https://xdsoft.net/jodit/docs/">Documentation</a></li>
21
- <li><a href="https://github.com/xdan/jodit/">Github</a></li>
22
- <li><a href="https://github.com/xdan/jodit/releases">Changelog</a></li>
23
- <li style="float:right"><a href="https://github.com/xdan/jodit/releases/latest">Download</a></li>
24
- </ul>
25
- </nav>
26
- </header>
27
- <div id="main_container" class="container">
28
- <div id="introduction">
29
- <h3>JavaScript</h3>
30
- <pre>
31
- import './app.css';
32
-
33
- import React from 'react';
34
- import { createRoot } from 'react-dom/client';
35
-
36
- import JoditEditor from "../src/JoditEditor";
37
-
38
- const container = document.getElementById('editor')!;
39
- const root = createRoot(container);
40
- root.render(
41
- &lt;StrictMode&gt;
42
- &lt;Form /&gt;
43
- &lt;/StrictMode&gt;
44
- );
45
- </pre>
46
- </div>
47
- <div class="result">
48
- <div id="editor"></div>
49
- </div>
50
- </div>
51
- <footer>
52
- <nav>
53
- <ul class="container">
54
- <li><a href="https://xdsoft.net/jodit/">Jodit homepage</a></li>
55
- <li><a href="https://xdsoft.net/jodit/docs/">Documentation</a></li>
56
- <li><a href="https://github.com/xdan/jodit/">Github</a></li>
57
- <li><a href="https://github.com/xdan/jodit/releases">Changelog</a></li>
58
- <li style="float:right"><a href="https://github.com/xdan/jodit/releases/latest">Download</a></li>
59
- </ul>
60
- </nav>
61
- </footer>
62
- </body>
63
- <link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,300i,400,400i,700,700i" rel="stylesheet">
64
-
65
- <script src="build/app.js"></script>
66
- </html>
package/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import JoditEditor from './build/types/JoditEditor';
2
- import { Jodit } from './build/types/include.jodit';
3
- export default JoditEditor;
4
- export { Jodit };
@@ -1,165 +0,0 @@
1
- import React, { useEffect, useRef, forwardRef } from 'react';
2
- import type { IJodit } from 'jodit/esm/types/jodit';
3
- import type { Jodit as JoditBaseConstructor } from 'jodit/esm/index';
4
- import type { Config } from 'jodit/esm/config';
5
- import { Jodit } from './include.jodit';
6
- import type { DeepPartial } from 'jodit/esm/types';
7
-
8
- function usePrevious(value: string): string {
9
- const ref = useRef<string>('');
10
- useEffect(() => {
11
- ref.current = value;
12
- }, [value]);
13
- return ref.current;
14
- }
15
-
16
- interface Props<T extends typeof JoditBaseConstructor = typeof Jodit> {
17
- JoditConstructor?: T;
18
- config?: DeepPartial<Config>;
19
- className?: string;
20
- id?: string;
21
- name?: string;
22
- onBlur?: (value: string, event: MouseEvent) => void;
23
- onChange?: (value: string) => void;
24
- tabIndex?: number;
25
- value?: string;
26
- editorRef?: (editor: IJodit) => void;
27
- }
28
-
29
- const JoditEditor = forwardRef<IJodit, Props>(
30
- (
31
- {
32
- JoditConstructor = Jodit,
33
- className,
34
- config,
35
- id,
36
- name,
37
- onBlur,
38
- onChange,
39
- tabIndex,
40
- value,
41
- editorRef
42
- },
43
- ref
44
- ) => {
45
- const textAreaRef = useRef<HTMLTextAreaElement | null>(null);
46
- const joditRef = useRef<IJodit | null>(null);
47
-
48
- useEffect(() => {
49
- const element = textAreaRef.current!;
50
- const jodit = JoditConstructor.make(element, config);
51
- joditRef.current = jodit;
52
-
53
- if (typeof editorRef === 'function') {
54
- editorRef(jodit);
55
- }
56
-
57
- return () => {
58
- if (jodit.isReady) {
59
- jodit.destruct();
60
- } else {
61
- jodit
62
- .waitForReady()
63
- .then(joditInstance => joditInstance.destruct());
64
- }
65
- };
66
- }, [JoditConstructor, config, editorRef]);
67
-
68
- useEffect(() => {
69
- if (ref) {
70
- if (typeof ref === 'function') {
71
- ref(joditRef.current);
72
- } else {
73
- ref.current = joditRef.current;
74
- }
75
- }
76
- }, [textAreaRef, ref, joditRef]);
77
-
78
- const preClassName = usePrevious(className ?? '');
79
-
80
- useEffect(() => {
81
- const classList = joditRef.current?.container?.classList;
82
-
83
- if (
84
- preClassName !== className &&
85
- typeof preClassName === 'string'
86
- ) {
87
- preClassName
88
- .split(/\s+/)
89
- .filter(Boolean)
90
- .forEach(cl => classList?.remove(cl));
91
- }
92
-
93
- if (className && typeof className === 'string') {
94
- className
95
- .split(/\s+/)
96
- .filter(Boolean)
97
- .forEach(cl => classList?.add(cl));
98
- }
99
- }, [className, preClassName]);
100
-
101
- useEffect(() => {
102
- if (joditRef.current?.workplace) {
103
- joditRef.current.workplace.tabIndex = tabIndex || -1;
104
- }
105
- }, [tabIndex]);
106
-
107
- useEffect(() => {
108
- const jodit = joditRef.current;
109
- if (!jodit?.events || !(onBlur || onChange)) {
110
- return;
111
- }
112
-
113
- const onBlurHandler = (event: MouseEvent) =>
114
- onBlur && onBlur(joditRef?.current?.value ?? '', event);
115
-
116
- const onChangeHandler = (value: string) =>
117
- onChange && onChange(value);
118
-
119
- // adding event handlers
120
- jodit.events
121
- .on('blur', onBlurHandler)
122
- .on('change', onChangeHandler);
123
-
124
- return () => {
125
- // Remove event handlers
126
- jodit.events
127
- ?.off('blur', onBlurHandler)
128
- .off('change', onChangeHandler);
129
- };
130
- }, [onBlur, onChange]);
131
-
132
- useEffect(() => {
133
- const jodit = joditRef.current;
134
-
135
- const updateValue = () => {
136
- if (jodit && value !== undefined && jodit.value !== value) {
137
- jodit.value = value;
138
- }
139
- };
140
-
141
- if (jodit) {
142
- if (jodit.isReady) {
143
- updateValue();
144
- } else {
145
- jodit.waitForReady().then(updateValue);
146
- }
147
- }
148
- }, [value]);
149
-
150
- return (
151
- <div className={'jodit-react-container'}>
152
- <textarea
153
- defaultValue={value}
154
- name={name}
155
- id={id}
156
- ref={textAreaRef}
157
- />
158
- </div>
159
- );
160
- }
161
- );
162
-
163
- JoditEditor.displayName = 'JoditEditor';
164
-
165
- export default JoditEditor;
@@ -1,7 +0,0 @@
1
- import { Jodit as JoditES5 } from 'jodit/esm/index';
2
- import type { Jodit as JoditConstructorType } from 'jodit/esm/jodit';
3
- import 'jodit/es2021/jodit.min.css';
4
-
5
- import 'jodit/esm/plugins/all';
6
-
7
- export const Jodit: typeof JoditConstructorType = JoditES5;
package/src/index.ts DELETED
@@ -1,5 +0,0 @@
1
- import JoditEditor from './JoditEditor';
2
- import { Jodit } from './include.jodit';
3
-
4
- export default JoditEditor;
5
- export { Jodit };
package/tsconfig.json DELETED
@@ -1,20 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es2015",
4
- "module": "ESNext",
5
- "outDir": "./build",
6
- "declaration": true,
7
- "declarationDir": "./build/types",
8
- "strict": true,
9
- "skipLibCheck": true,
10
- "esModuleInterop": true,
11
- "moduleDetection": "force",
12
- "allowJs": true,
13
- "noUncheckedIndexedAccess": true,
14
- "allowSyntheticDefaultImports": true,
15
- "forceConsistentCasingInFileNames": true,
16
- "jsx": "react-jsx",
17
- "moduleResolution": "node",
18
- "noImplicitAny": true
19
- }
20
- }