1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import React, { useState, useEffect, forwardRef } from 'react';
import WangEditor from './OneStopWangEditor';
function Index({ onChange, value, otherProps, dataColumn, disabled, json, uuid }) {
const [ready, setReady] = useState(false);
const domKey = uuid || 'wang-editor-dom-content';
useEffect(() => {
let dom = document.getElementById(`wangEditor-${domKey}`);
if(dom && dom.parentNode){
dom.parentNode.removeChild(dom);
}
setReady(true);
}, []);
if(!ready){
return null;
}
if(disabled){
if(!value || value === 'null'){
return <div></div>
}
return <div dangerouslySetInnerHTML={{__html: `<div class="wangEditorHtml">${value}</div>`}}>
</div>
}
return (
<WangEditor
key={'cmsContent'}
zIndex={otherProps?.zIndex || undefined}
menus={otherProps?.menus || undefined}
placeholder={json.placeholder || ''}
height={otherProps?.height || 450}
value={value || ''}
domKey={domKey}
onChangeValue={onChange}
/>
);
}
export default forwardRef((props, _ref) => {
let otherProps = {};
// console.log(props);
if(!props.uuid){
return <div></div>;
}
if (props.json?.otherProps) {
otherProps = props.json?.otherProps;
try {
otherProps = new Function(otherProps)();
// console.log(this.otherProps);
} catch (e) {
}
}
return <Index {...props} otherProps={otherProps}/>;
});