@ohos-ports/jodit-pro-react 0.0.0-stage → 5.9.0-beta.1
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.md +3 -0
- package/README.md +62 -2
- package/build/esm/JoditEditor.css +10531 -0
- package/build/esm/JoditEditor.d.mts +26 -0
- package/build/esm/JoditEditor.mjs +6 -0
- package/build/esm/chunk-HINFXUP4.mjs +62114 -0
- package/build/esm/index.css +10531 -0
- package/build/esm/index.d.mts +14 -0
- package/build/esm/index.mjs +18 -0
- package/build/jodit-react.js +2 -0
- package/build/jodit-react.js.LICENSE.txt +40 -0
- package/build/types/JoditEditor.d.ts +22 -0
- package/build/types/JoditEditor.js +101 -0
- package/build/types/include.jodit.d.ts +10 -0
- package/build/types/include.jodit.js +9 -0
- package/build/types/index.d.ts +10 -0
- package/build/types/index.js +9 -0
- package/package.json +85 -5
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor (https://xdsoft.net/jodit/)
|
|
3
|
+
* Released under MIT see LICENSE.txt in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/*!
|
|
8
|
+
* Jodit Editor PRO (https://xdsoft.net/jodit/)
|
|
9
|
+
* See LICENSE.md in the project root for license information.
|
|
10
|
+
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/*!
|
|
14
|
+
* a-color-picker
|
|
15
|
+
* https://github.com/narsenico/a-color-picker
|
|
16
|
+
*
|
|
17
|
+
* Copyright (c) 2017-2019, Gianfranco Caldi.
|
|
18
|
+
* Released under the MIT License.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/*!
|
|
22
|
+
* a-color-picker (https://github.com/narsenico/a-color-picker)
|
|
23
|
+
*
|
|
24
|
+
* Copyright (c) 2017-2018, Gianfranco Caldi.
|
|
25
|
+
* Released under the MIT License.
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
/*!
|
|
29
|
+
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
30
|
+
*
|
|
31
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
32
|
+
* Released under the MIT License.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/*!
|
|
36
|
+
* isobject <https://github.com/jonschlinkert/isobject>
|
|
37
|
+
*
|
|
38
|
+
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
39
|
+
* Released under the MIT License.
|
|
40
|
+
*/
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor PRO (https://xdsoft.net/jodit/)
|
|
3
|
+
* See LICENSE.md in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/
|
|
5
|
+
*/
|
|
6
|
+
import type { DeepPartial } from 'jodit/esm/types';
|
|
7
|
+
import { type Config, Jodit as JoditBaseConstructor } from './include.jodit';
|
|
8
|
+
import React from 'react';
|
|
9
|
+
export interface JoditEditorProps<T extends typeof JoditBaseConstructor = typeof JoditBaseConstructor> {
|
|
10
|
+
JoditConstructor?: T;
|
|
11
|
+
config?: DeepPartial<Config>;
|
|
12
|
+
className?: string;
|
|
13
|
+
id?: string;
|
|
14
|
+
name?: string;
|
|
15
|
+
onBlur?: (value: string, event: MouseEvent) => void;
|
|
16
|
+
onChange?: (value: string) => void;
|
|
17
|
+
tabIndex?: number;
|
|
18
|
+
value?: string;
|
|
19
|
+
editorRef?: (editor: JoditBaseConstructor) => void;
|
|
20
|
+
}
|
|
21
|
+
declare const JoditEditor: React.ForwardRefExoticComponent<JoditEditorProps<typeof JoditBaseConstructor> & React.RefAttributes<JoditBaseConstructor>>;
|
|
22
|
+
export default JoditEditor;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Jodit as JoditBaseConstructor } from './include.jodit';
|
|
2
|
+
import React, { forwardRef, useEffect, useRef } from 'react';
|
|
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 = JoditBaseConstructor, 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;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor PRO (https://xdsoft.net/jodit/)
|
|
3
|
+
* See LICENSE.md in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/
|
|
5
|
+
*/
|
|
6
|
+
import 'jodit-pro/esm/plugins/all.js';
|
|
7
|
+
|
|
8
|
+
import { Jodit as JoditConstructor } from 'jodit-pro/esm/index.js';
|
|
9
|
+
export { Config } from 'jodit-pro/esm/config';
|
|
10
|
+
export { JoditConstructor as Jodit };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor PRO (https://xdsoft.net/jodit/)
|
|
3
|
+
* See LICENSE.md in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/
|
|
5
|
+
*/
|
|
6
|
+
import 'jodit-pro/esm/plugins/all.js';
|
|
7
|
+
import 'jodit-pro/es2021/jodit.fat.min.css';
|
|
8
|
+
import { Jodit as JoditConstructor } from 'jodit-pro/esm/index.js';
|
|
9
|
+
export { JoditConstructor as Jodit };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor PRO (https://xdsoft.net/jodit/)
|
|
3
|
+
* See LICENSE.md in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/
|
|
5
|
+
*/
|
|
6
|
+
import { Config, Jodit } from './include.jodit';
|
|
7
|
+
import JoditEditor from './JoditEditor';
|
|
8
|
+
export default JoditEditor;
|
|
9
|
+
export { Config, Jodit };
|
|
10
|
+
export type { JoditEditorProps } from './JoditEditor';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Jodit Editor PRO (https://xdsoft.net/jodit/)
|
|
3
|
+
* See LICENSE.md in the project root for license information.
|
|
4
|
+
* Copyright (c) 2013-2026 Valerii Chupurnov. All rights reserved. https://xdsoft.net/jodit/pro/
|
|
5
|
+
*/
|
|
6
|
+
import { Jodit } from './include.jodit';
|
|
7
|
+
import JoditEditor from './JoditEditor';
|
|
8
|
+
export default JoditEditor;
|
|
9
|
+
export { Jodit };
|
package/package.json
CHANGED
|
@@ -1,6 +1,86 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@ohos-ports/jodit-pro-react",
|
|
3
|
+
"version": "5.9.0-beta.1",
|
|
4
|
+
"description": "Jodit PRO is awesome and usefully wysiwyg editor with filebrowser",
|
|
5
|
+
"main": "build/jodit-react.js",
|
|
6
|
+
"module": "./build/esm/index.mjs",
|
|
7
|
+
"types": "./build/types/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"import": {
|
|
11
|
+
"types": "./build/esm/index.d.mts",
|
|
12
|
+
"default": "./build/esm/index.mjs"
|
|
13
|
+
},
|
|
14
|
+
"require": {
|
|
15
|
+
"types": "./build/types/index.d.ts",
|
|
16
|
+
"default": "./build/jodit-react.js"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"./build/types/JoditEditor": {
|
|
20
|
+
"import": {
|
|
21
|
+
"types": "./build/esm/JoditEditor.d.mts",
|
|
22
|
+
"default": "./build/esm/JoditEditor.mjs"
|
|
23
|
+
},
|
|
24
|
+
"require": {
|
|
25
|
+
"types": "./build/types/JoditEditor.d.ts",
|
|
26
|
+
"default": "./build/types/JoditEditor.js"
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"build"
|
|
32
|
+
],
|
|
33
|
+
"author": "Chupurnov <chupurnov@gmail.com> (https://xdsoft.net/jodit/pro/)",
|
|
34
|
+
"keywords": [
|
|
35
|
+
"react",
|
|
36
|
+
"jodit",
|
|
37
|
+
"html",
|
|
38
|
+
"text",
|
|
39
|
+
"editor",
|
|
40
|
+
"wysisyg",
|
|
41
|
+
"rich editor",
|
|
42
|
+
"rich text editor",
|
|
43
|
+
"rte"
|
|
44
|
+
],
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "npm run build:react && npm run build:types && npm run build:esm",
|
|
47
|
+
"build:react": "cross-env NODE_ENV=production node -r @swc-node/register ./node_modules/.bin/webpack --mode production",
|
|
48
|
+
"build:types": "rm -rf ./build/types && tsc --project tsconfig.types.json && npm run remove-css",
|
|
49
|
+
"build:esm": "tsup src/index.ts src/JoditEditor.tsx --dts --format esm -d ./build/esm --clean",
|
|
50
|
+
"remove-css": "replace \"import '[^']+.css';\" \"\" ./build/**/*.ts",
|
|
51
|
+
"watch": "node -r @swc-node/register ./node_modules/.bin/webpack --watch",
|
|
52
|
+
"start": "node -r @swc-node/register ./node_modules/.bin/webpack serve"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@swc-node/register": "^1.10.9",
|
|
56
|
+
"@types/react": "^19.2.10",
|
|
57
|
+
"cross-env": "^10.1.0",
|
|
58
|
+
"css-loader": "^7.1.2",
|
|
59
|
+
"html-webpack-plugin": "^5.6.3",
|
|
60
|
+
"jodit": "^4.14.0",
|
|
61
|
+
"jodit-pro": "^4.8.10",
|
|
62
|
+
"jodit-react": "^5.3.18",
|
|
63
|
+
"replace": "^1.2.2",
|
|
64
|
+
"style-loader": "^4.0.0",
|
|
65
|
+
"swc-loader": "^0.2.6",
|
|
66
|
+
"ts-node": "^10.9.2",
|
|
67
|
+
"tsup": "^8.5.1",
|
|
68
|
+
"typescript": "^5.7.3",
|
|
69
|
+
"webpack": "^5.97.1",
|
|
70
|
+
"webpack-cli": "^5.1.4",
|
|
71
|
+
"webpack-dev-server": "^5.1.0"
|
|
72
|
+
},
|
|
73
|
+
"peerDependencies": {
|
|
74
|
+
"react": "~0.14 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
75
|
+
"react-dom": "~0.14 || ^15.0.0 || ^16.0.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
|
76
|
+
},
|
|
77
|
+
"repository": {
|
|
78
|
+
"type": "git",
|
|
79
|
+
"url": "git+https://github.com/jodit/jodit-pro.git"
|
|
80
|
+
},
|
|
81
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
82
|
+
"bugs": {
|
|
83
|
+
"url": "https://xdsoft.net/jodit/pro/cab/issues/"
|
|
84
|
+
},
|
|
85
|
+
"homepage": "https://xdsoft.net/jodit/pro/"
|
|
86
|
+
}
|