提交 3333b5da authored 作者: 钟是志's avatar 钟是志

一站式wangEditor组件开发

上级 c93df65a
...@@ -3077,6 +3077,7 @@ export default class tableCom extends Component { ...@@ -3077,6 +3077,7 @@ export default class tableCom extends Component {
})(<WangEditor json={json} })(<WangEditor json={json}
dataColumn={dataColumn} dataColumn={dataColumn}
disabled={disabled} disabled={disabled}
uuid={this.props.uuid}
/>); />);
break; break;
......
import React, { useState, useEffect, forwardRef } from 'react'; import React, { useState, useEffect, forwardRef } from 'react';
import WangEditor from './OneStopWangEditor'; import WangEditor from './OneStopWangEditor';
function Index({ onChange, value, otherProps, dataColumn, disabled, json }) { function Index({ onChange, value, otherProps, dataColumn, disabled, json, uuid }) {
const [ready, setReady] = useState(false); const [ready, setReady] = useState(false);
const domKey = dataColumn.base52 || 'wang-editor-dom-content'; const domKey = uuid || 'wang-editor-dom-content';
useEffect(() => { useEffect(() => {
let dom = document.getElementById(`wangEditor${domKey}`); let dom = document.getElementById(`wangEditor-${domKey}`);
if(dom && dom.parentNode){ if(dom && dom.parentNode){
dom.parentNode.removeChild(dom); dom.parentNode.removeChild(dom);
} }
...@@ -15,6 +15,10 @@ function Index({ onChange, value, otherProps, dataColumn, disabled, json }) { ...@@ -15,6 +15,10 @@ function Index({ onChange, value, otherProps, dataColumn, disabled, json }) {
if(!ready){ if(!ready){
return null; return null;
} }
if(disabled){
return <div dangerouslySetInnerHTML={{__html: value}}></div>
}
return ( return (
<WangEditor <WangEditor
key={'cmsContent'} key={'cmsContent'}
...@@ -23,7 +27,7 @@ function Index({ onChange, value, otherProps, dataColumn, disabled, json }) { ...@@ -23,7 +27,7 @@ function Index({ onChange, value, otherProps, dataColumn, disabled, json }) {
placeholder={json.placeholder || ''} placeholder={json.placeholder || ''}
height={otherProps?.height || 450} height={otherProps?.height || 450}
value={value || ''} value={value || ''}
domKey={dataColumn.base52 || 'wang-editor-dom-content'} domKey={domKey}
onChangeValue={onChange} onChangeValue={onChange}
/> />
); );
...@@ -31,7 +35,8 @@ function Index({ onChange, value, otherProps, dataColumn, disabled, json }) { ...@@ -31,7 +35,8 @@ function Index({ onChange, value, otherProps, dataColumn, disabled, json }) {
export default forwardRef((props, _ref) => { export default forwardRef((props, _ref) => {
let otherProps = {}; let otherProps = {};
if(!props.json || typeof props.json.initialValue === 'undefined'){ // console.log(props);
if(!props.uuid){
return <div></div>; return <div></div>;
} }
if (props.json?.otherProps) { if (props.json?.otherProps) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论