jodit-pro-react 5.4.1 → 5.4.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.
@@ -1,20 +0,0 @@
1
- import React from 'react';
2
- import type { IJodit } from 'jodit-pro/esm/types/jodit';
3
- import type { Jodit as JoditBaseConstructor } from 'jodit-pro/esm/index';
4
- import type { Config } from 'jodit-pro/esm/config';
5
- import { Jodit } from './include.jodit';
6
- import type { DeepPartial } from 'jodit-pro/esm/types';
7
- interface Props<T extends typeof JoditBaseConstructor = typeof Jodit> {
8
- JoditConstructor?: T;
9
- config?: DeepPartial<Config>;
10
- className?: string;
11
- id?: string;
12
- name?: string;
13
- onBlur?: (value: string, event: MouseEvent) => void;
14
- onChange?: (value: string) => void;
15
- tabIndex?: number;
16
- value?: string;
17
- editorRef?: (editor: IJodit) => void;
18
- }
19
- declare const JoditEditor: React.ForwardRefExoticComponent<Props<typeof JoditBaseConstructor> & React.RefAttributes<IJodit>>;
20
- export default JoditEditor;
@@ -1,101 +0,0 @@
1
- import React, { useEffect, useRef, forwardRef } from 'react';
2
- import { Jodit } from './include.jodit';
3
- function usePrevious(value) {
4
- const ref = useRef('');
5
- useEffect(() => {
6
- ref.current = value;
7
- }, [value]);
8
- return ref.current;
9
- }
10
- const JoditEditor = forwardRef(({ JoditConstructor = Jodit, className, config, id, name, onBlur, onChange, tabIndex, value, editorRef }, ref) => {
11
- const textAreaRef = useRef(null);
12
- const joditRef = useRef(null);
13
- useEffect(() => {
14
- const element = textAreaRef.current;
15
- const jodit = JoditConstructor.make(element, config);
16
- joditRef.current = jodit;
17
- if (typeof editorRef === 'function') {
18
- editorRef(jodit);
19
- }
20
- return () => {
21
- if (jodit.isReady) {
22
- jodit.destruct();
23
- }
24
- else {
25
- jodit
26
- .waitForReady()
27
- .then(joditInstance => joditInstance.destruct());
28
- }
29
- };
30
- }, [JoditConstructor, config, editorRef]);
31
- useEffect(() => {
32
- if (ref) {
33
- if (typeof ref === 'function') {
34
- ref(joditRef.current);
35
- }
36
- else {
37
- ref.current = joditRef.current;
38
- }
39
- }
40
- }, [textAreaRef, ref, joditRef]);
41
- const preClassName = usePrevious(className ?? '');
42
- useEffect(() => {
43
- const classList = joditRef.current?.container?.classList;
44
- if (preClassName !== className &&
45
- typeof preClassName === 'string') {
46
- preClassName
47
- .split(/\s+/)
48
- .filter(Boolean)
49
- .forEach(cl => classList?.remove(cl));
50
- }
51
- if (className && typeof className === 'string') {
52
- className
53
- .split(/\s+/)
54
- .filter(Boolean)
55
- .forEach(cl => classList?.add(cl));
56
- }
57
- }, [className, preClassName]);
58
- useEffect(() => {
59
- if (joditRef.current?.workplace) {
60
- joditRef.current.workplace.tabIndex = tabIndex || -1;
61
- }
62
- }, [tabIndex]);
63
- useEffect(() => {
64
- const jodit = joditRef.current;
65
- if (!jodit?.events || !(onBlur || onChange)) {
66
- return;
67
- }
68
- const onBlurHandler = (event) => onBlur && onBlur(joditRef?.current?.value ?? '', event);
69
- const onChangeHandler = (value) => onChange && onChange(value);
70
- // adding event handlers
71
- jodit.events
72
- .on('blur', onBlurHandler)
73
- .on('change', onChangeHandler);
74
- return () => {
75
- // Remove event handlers
76
- jodit.events
77
- ?.off('blur', onBlurHandler)
78
- .off('change', onChangeHandler);
79
- };
80
- }, [onBlur, onChange]);
81
- useEffect(() => {
82
- const jodit = joditRef.current;
83
- const updateValue = () => {
84
- if (jodit && value !== undefined && jodit.value !== value) {
85
- jodit.value = value;
86
- }
87
- };
88
- if (jodit) {
89
- if (jodit.isReady) {
90
- updateValue();
91
- }
92
- else {
93
- jodit.waitForReady().then(updateValue);
94
- }
95
- }
96
- }, [value]);
97
- return (React.createElement("div", { className: 'jodit-react-container' },
98
- React.createElement("textarea", { defaultValue: value, name: name, id: id, ref: textAreaRef })));
99
- });
100
- JoditEditor.displayName = 'JoditEditor';
101
- export default JoditEditor;
@@ -1,4 +0,0 @@
1
- import type { Jodit as JoditConstructorType } from 'jodit-pro/esm/jodit';
2
-
3
- import 'jodit-pro/esm/plugins/all';
4
- export declare const Jodit: typeof JoditConstructorType;
@@ -1,4 +0,0 @@
1
- import { Jodit as JoditES5 } from 'jodit-pro/esm/index';
2
- import 'jodit-pro/es2021/jodit.min.css';
3
- import 'jodit-pro/esm/plugins/all';
4
- export const Jodit = JoditES5;
package/types/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import JoditEditor from './JoditEditor';
2
- import { Jodit } from './include.jodit';
3
- export default JoditEditor;
4
- export { Jodit };
package/types/index.js DELETED
@@ -1,4 +0,0 @@
1
- import JoditEditor from './JoditEditor';
2
- import { Jodit } from './include.jodit';
3
- export default JoditEditor;
4
- export { Jodit };