提交 6e0792ea authored 作者: 钟是志's avatar 钟是志

一站式wangEditor组件开发

上级 9fca5ac4
...@@ -55,7 +55,6 @@ export default class ZdyTable extends Component { ...@@ -55,7 +55,6 @@ export default class ZdyTable extends Component {
formDeafault = '', // 为二维码快捷发起默认值 formDeafault = '', // 为二维码快捷发起默认值
} = this.props; } = this.props;
// if(this.props.currentFormKey === 'aa20cdbd-2019-45ea-8cdf-715aa46e132e'){ // if(this.props.currentFormKey === 'aa20cdbd-2019-45ea-8cdf-715aa46e132e'){
// debugger;
// } // }
if (isPreview || isChild) { if (isPreview || isChild) {
this.initExcel({ datas: this.props.datas, trees: this.props.trees }, () => { this.initExcel({ datas: this.props.datas, trees: this.props.trees }, () => {
......
...@@ -55,7 +55,6 @@ export default class ZdyTable extends Component { ...@@ -55,7 +55,6 @@ export default class ZdyTable extends Component {
formDeafault = '', // 为二维码快捷发起默认值 formDeafault = '', // 为二维码快捷发起默认值
} = this.props; } = this.props;
// if(this.props.currentFormKey === 'aa20cdbd-2019-45ea-8cdf-715aa46e132e'){ // if(this.props.currentFormKey === 'aa20cdbd-2019-45ea-8cdf-715aa46e132e'){
// debugger;
// } // }
if (isPreview || isChild) { if (isPreview || isChild) {
this.initExcel({ datas: this.props.datas, trees: this.props.trees }, () => { this.initExcel({ datas: this.props.datas, trees: this.props.trees }, () => {
...@@ -650,7 +649,7 @@ export default class ZdyTable extends Component { ...@@ -650,7 +649,7 @@ export default class ZdyTable extends Component {
}; };
render() { render() {
const { const {
width, width,
isRowCol, isRowCol,
......
...@@ -60,6 +60,7 @@ import MobileItem from './MobileItem'; ...@@ -60,6 +60,7 @@ import MobileItem from './MobileItem';
import MobileCascader from './CascaderDiy/MobileCascader'; import MobileCascader from './CascaderDiy/MobileCascader';
import { equal, errorHandler, getBase64, getRender, isJSON } from './Split_Index/staticInfo'; import { equal, errorHandler, getBase64, getRender, isJSON } from './Split_Index/staticInfo';
import PictureSignature, { SignArray } from "@/webPublic/one_stop_public/libs/PictureSignature/PictureSignature"; import PictureSignature, { SignArray } from "@/webPublic/one_stop_public/libs/PictureSignature/PictureSignature";
import WangEditor from '@/webPublic/zyd_public/WangEditor/OnstopWang';
const { TextArea } = Input; const { TextArea } = Input;
const { Option } = Select; const { Option } = Select;
...@@ -1824,6 +1825,7 @@ export default class tableCom extends Component { ...@@ -1824,6 +1825,7 @@ export default class tableCom extends Component {
} }
} }
} }
// console.log(initValue, 'initValue');
// console.table({ // console.table({
// objinit, // objinit,
// fatherCode: this.props.fatherCode, // fatherCode: this.props.fatherCode,
...@@ -1862,6 +1864,11 @@ export default class tableCom extends Component { ...@@ -1862,6 +1864,11 @@ export default class tableCom extends Component {
/> />
); );
break; break;
case 'WangEditor':
cm = (<div dangerouslySetInnerHTML={{__html: obj[dataColumn.base52]}}>
</div>);
break;
case 'TextArea': case 'TextArea':
cm = ( cm = (
<span <span
...@@ -3060,8 +3067,20 @@ export default class tableCom extends Component { ...@@ -3060,8 +3067,20 @@ export default class tableCom extends Component {
); );
} }
break; break;
case 'WangEditor':
cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue,
rules:
json.vlds && json.vlds.length > 0
? json.vlds
: [{ required: required, message: '请输入' }],
})(<WangEditor json={json}
dataColumn={dataColumn}
disabled={disabled}
/>);
break;
case 'RichText': case 'RichText':
console.log(initValue, '22222222222222', dataColumn.base52, json);
cm = getFieldDecorator(dataColumn.base52, { cm = getFieldDecorator(dataColumn.base52, {
initialValue: initValue, initialValue: initValue,
rules: rules:
......
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import WangEditor from './includes/wangEditor.min'; import WangEditor from './includes/wangEditor.min';
import { uploadFile } from "@/webPublic/one_stop_public/libs/PictureSignature/ShowItem"; import { uploadFile } from "@/webPublic/one_stop_public/libs/PictureSignature/ShowItem";
import { queryApiActionPath } from '@/webPublic/one_stop_public/utils/queryConfig';
let editor = null; let editor = null;
export default function Index({ export default function Index({
...@@ -49,9 +50,9 @@ export default function Index({ ...@@ -49,9 +50,9 @@ export default function Index({
editor.config.customUploadImg = function(resultFiles, insertImgFn) { editor.config.customUploadImg = function(resultFiles, insertImgFn) {
// 重写上传图片的方法 // 重写上传图片的方法
uploadFile({ file: resultFiles[0] }).then((y) => { uploadFile(resultFiles[0]).then((y) => {
if (y && y.url) { if (y && y.length) {
insertImgFn(y.url); insertImgFn(queryApiActionPath() + y);
} }
}); });
// insertImgFn(imgUrl); // insertImgFn(imgUrl);
......
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, height, domKey }) { function Index({ onChange, value, otherProps, dataColumn, disabled }) {
const [ready, setReady] = useState(false);
const domKey = dataColumn.base52 || '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;
}
return ( return (
<WangEditor <WangEditor
key={'cmsContent'} key={'cmsContent'}
height={height} height={otherProps?.height || 450}
value={value} value={value || ''}
domKey={domKey} domKey={dataColumn.base52 || 'wang-editor-dom-content'}
onChangeValue={onChange} onChangeValue={onChange}
otherProps={otherProps}
/> />
); );
} }
export default forwardRef((props, _ref) => { export default forwardRef((props, _ref) => {
console.log(props); let otherProps = {};
return <Index {...props} />; if(!props.json || typeof props.json.initialValue === 'undefined'){
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}/>;
}); });
...@@ -147,7 +147,6 @@ export const zipImage = (file, fileSizeLimitMb = 3) => { ...@@ -147,7 +147,6 @@ export const zipImage = (file, fileSizeLimitMb = 3) => {
image.src = e.target.result; image.src = e.target.result;
return (image.onload = () => { return (image.onload = () => {
let canvas = document.createElement('canvas'); let canvas = document.createElement('canvas');
debugger;
let context = canvas.getContext('2d'); let context = canvas.getContext('2d');
let imageWidth = image.width * 0.3; //压缩后图片的大小 let imageWidth = image.width * 0.3; //压缩后图片的大小
let imageHeight = image.height * 0.3; let imageHeight = image.height * 0.3;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论