提交 8254b4ba authored 作者: 钟是志's avatar 钟是志

2021年2月4日 16:28:53 屏蔽 模版设计里面的富文本里面的 video(视频组件)

上级 adc2ca51
...@@ -84,11 +84,11 @@ export default class DraftEditorCom extends React.Component { ...@@ -84,11 +84,11 @@ export default class DraftEditorCom extends React.Component {
this.onChange = (editorState,callback) => { this.onChange = (editorState,callback) => {
this.setState({ editorState },()=>{ this.setState({ editorState },()=>{
if(callback)callback() if(callback)callback()
}); });
this.triggerChange({ editorState },()=>{ this.triggerChange({ editorState },()=>{
if(callback)callback() if(callback)callback()
}); });
...@@ -116,54 +116,54 @@ export default class DraftEditorCom extends React.Component { ...@@ -116,54 +116,54 @@ export default class DraftEditorCom extends React.Component {
const value = nextProps.value; const value = nextProps.value;
if(value instanceof Object){ if(value instanceof Object){
const editorState = changeToDraftState2(value) const editorState = changeToDraftState2(value)
this.setState({editorState}); } this.setState({editorState}); }
} }
} }
exchange=(data,editKey,callback)=>{ exchange=(data,editKey,callback)=>{
const blocks = changeFromDraftState2(this.state.editorState) const blocks = changeFromDraftState2(this.state.editorState)
const bs =blocks.blocks const bs =blocks.blocks
var b; var b;
for(var i=0;i<bs.length;i++){ for(var i=0;i<bs.length;i++){
if(bs[i].key==editKey){ if(bs[i].key==editKey){
b=bs[i]; b=bs[i];
break; break;
} }
} }
const entityKey=b.entityRanges[0].key+""; const entityKey=b.entityRanges[0].key+"";
blocks.entityMap[entityKey].data=data blocks.entityMap[entityKey].data=data
const editorState = changeToDraftState2(blocks) const editorState = changeToDraftState2(blocks)
this.onChange(editorState,callback) this.onChange(editorState,callback)
} }
extends=(data,type,text,callback)=>{ extends=(data,type,text,callback)=>{
var editorState = this.state.editorState var editorState = this.state.editorState
const contentState = editorState.getCurrentContent(); const contentState = editorState.getCurrentContent();
const contentStateWithEntity = contentState.createEntity(type, 'IMMUTABLE', data); const contentStateWithEntity = contentState.createEntity(type, 'IMMUTABLE', data);
const entityKey = contentStateWithEntity.getLastCreatedEntityKey(); const entityKey = contentStateWithEntity.getLastCreatedEntityKey();
const newEditorState = EditorState.set(editorState, { currentContent: contentStateWithEntity }); const newEditorState = EditorState.set(editorState, { currentContent: contentStateWithEntity });
const xx = AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, text); const xx = AtomicBlockUtils.insertAtomicBlock(newEditorState, entityKey, text);
this.setState({ editorState: xx }, () => { this.setState({ editorState: xx }, () => {
callback() callback()
}); });
this.triggerChange({ editorState: xx}, () => { this.triggerChange({ editorState: xx}, () => {
callback() callback()
}); });
} }
urlChange(event) { urlChange(event) {
const target = event.target; const target = event.target;
...@@ -192,7 +192,7 @@ export default class DraftEditorCom extends React.Component { ...@@ -192,7 +192,7 @@ export default class DraftEditorCom extends React.Component {
// Should be a controlled component. // Should be a controlled component.
if ('value' in nextProps) { if ('value' in nextProps) {
const value = nextProps.value; const value = nextProps.value;
} }
} */ } */
...@@ -202,27 +202,27 @@ export default class DraftEditorCom extends React.Component { ...@@ -202,27 +202,27 @@ export default class DraftEditorCom extends React.Component {
} }
insertAttr = () => { insertAttr = () => {
this.setState({ modalVisible: true, fnKey: "attr" }); this.setState({ modalVisible: true, fnKey: "attr" });
this.triggerChange({ modalVisible: true, fnKey: "attr" }); this.triggerChange({ modalVisible: true, fnKey: "attr" });
} }
insertPic = () => { insertPic = () => {
this.setState({ modalVisible: true, fnKey: "image" }); this.setState({ modalVisible: true, fnKey: "image" });
this.triggerChange({ modalVisible: true, fnKey: "image" }); this.triggerChange({ modalVisible: true, fnKey: "image" });
} }
insertFormula = () => { insertFormula = () => {
this.setState({ modalVisible: true, fnKey: "formula" }); this.setState({ modalVisible: true, fnKey: "formula" });
this.triggerChange({ modalVisible: true, fnKey: "formula" }); this.triggerChange({ modalVisible: true, fnKey: "formula" });
} }
insertVideo = () => { insertVideo = () => {
this.setState({ modalVisible: true, fnKey: "video" }); this.setState({ modalVisible: true, fnKey: "video" });
this.triggerChange({ modalVisible: true, fnKey: "video" }); this.triggerChange({ modalVisible: true, fnKey: "video" });
} }
insertLink = () => { insertLink = () => {
...@@ -232,9 +232,9 @@ export default class DraftEditorCom extends React.Component { ...@@ -232,9 +232,9 @@ export default class DraftEditorCom extends React.Component {
message.error("请选择需要插入链接的内容") message.error("请选择需要插入链接的内容")
return return
} }
this.setState({ modalVisible: true, fnKey: "link" }); this.setState({ modalVisible: true, fnKey: "link" });
this.triggerChange({ modalVisible: true, fnKey: "link" }); this.triggerChange({ modalVisible: true, fnKey: "link" });
} }
...@@ -255,9 +255,9 @@ export default class DraftEditorCom extends React.Component { ...@@ -255,9 +255,9 @@ export default class DraftEditorCom extends React.Component {
this.setState({ editorState: xx, modalVisible: false, }); this.setState({ editorState: xx, modalVisible: false, });
this.triggerChange({ editorState: xx, modalVisible: false, }); this.triggerChange({ editorState: xx, modalVisible: false, });
} }
...@@ -278,9 +278,9 @@ export default class DraftEditorCom extends React.Component { ...@@ -278,9 +278,9 @@ export default class DraftEditorCom extends React.Component {
this.setState({ editorState: xx, modalVisible: false, }); this.setState({ editorState: xx, modalVisible: false, });
this.triggerChange({ editorState: xx, modalVisible: false, }); this.triggerChange({ editorState: xx, modalVisible: false, });
} }
...@@ -298,7 +298,7 @@ export default class DraftEditorCom extends React.Component { ...@@ -298,7 +298,7 @@ export default class DraftEditorCom extends React.Component {
this.setState({ editorState: xx, modalVisible: false, }); this.setState({ editorState: xx, modalVisible: false, });
this.triggerChange({ editorState: xx, modalVisible: false, }); this.triggerChange({ editorState: xx, modalVisible: false, });
} }
...@@ -327,9 +327,9 @@ export default class DraftEditorCom extends React.Component { ...@@ -327,9 +327,9 @@ export default class DraftEditorCom extends React.Component {
entityKey entityKey
) )
this.setState({ editorState: xx, modalVisible: false}); this.setState({ editorState: xx, modalVisible: false});
this.triggerChange({ editorState: xx, modalVisible: false}); this.triggerChange({ editorState: xx, modalVisible: false});
} }
...@@ -344,18 +344,18 @@ export default class DraftEditorCom extends React.Component { ...@@ -344,18 +344,18 @@ export default class DraftEditorCom extends React.Component {
return <FormulaForm callback={this.callback2} /> return <FormulaForm callback={this.callback2} />
}else if (this.state.fnKey == "attr") { }else if (this.state.fnKey == "attr") {
return <AttrForm callback={this.callback4} /> return <AttrForm callback={this.callback4} />
} }
} }
deleteBlock=(editKey)=>{ deleteBlock=(editKey)=>{
const oldObj = changeFromDraftState2(this.state.editorState) const oldObj = changeFromDraftState2(this.state.editorState)
const blocks = JSON.parse(JSON.stringify(oldObj)); const blocks = JSON.parse(JSON.stringify(oldObj));
const bs =blocks.blocks const bs =blocks.blocks
var b; var b;
var j; var j;
for(var i=0;i<bs.length;i++){ for(var i=0;i<bs.length;i++){
if(bs[i].key==editKey){ if(bs[i].key==editKey){
b=bs[i]; b=bs[i];
j=i; j=i;
...@@ -367,9 +367,9 @@ export default class DraftEditorCom extends React.Component { ...@@ -367,9 +367,9 @@ export default class DraftEditorCom extends React.Component {
blocks.blocks.splice(j,1) blocks.blocks.splice(j,1)
const editorState = changeToDraftState2(blocks) const editorState = changeToDraftState2(blocks)
this.setState({ editorState }); this.setState({ editorState });
this.triggerChange({ editorState }); this.triggerChange({ editorState });
} }
...@@ -392,7 +392,7 @@ export default class DraftEditorCom extends React.Component { ...@@ -392,7 +392,7 @@ export default class DraftEditorCom extends React.Component {
{ label: 'line2', type: "line", icon: ii }, { label: 'line2', type: "line", icon: ii },
{ label: 'lk', type: "fn", icon: lk, fn: this.insertLink }, { label: 'lk', type: "fn", icon: lk, fn: this.insertLink },
{ label: 'pic', type: "fn", icon: pic, fn: this.insertPic }, { label: 'pic', type: "fn", icon: pic, fn: this.insertPic },
{ label: 'video', type: "fn", icon: video, fn: this.insertVideo }, /* { label: 'video', type: "fn", icon: video, fn: this.insertVideo },*/
/* { label: 'sum', type: "fn", icon: sum, fn: this.insertFormula }, */ /* { label: 'sum', type: "fn", icon: sum, fn: this.insertFormula }, */
{ label: 'att', type: "fn", icon: attrs, fn: this.insertAttr }, { label: 'att', type: "fn", icon: attrs, fn: this.insertAttr },
{ label: 'line3', type: "line", icon: ii }, { label: 'line3', type: "line", icon: ii },
...@@ -543,17 +543,17 @@ class AttrForm extends React.Component { ...@@ -543,17 +543,17 @@ class AttrForm extends React.Component {
} }
return e && e.fileList; return e && e.fileList;
} }
onChange=(info) =>{ onChange=(info) =>{
if (info.file.status === 'done') { if (info.file.status === 'done') {
message.success(`文件上传成功`); message.success(`文件上传成功`);
this.setState({url:info.file.response,name:info.file.name}) this.setState({url:info.file.response,name:info.file.name})
} else if (info.file.status === 'error') { } else if (info.file.status === 'error') {
message.error(`文件上传失败`); message.error(`文件上传失败`);
} }
}; };
render() { render() {
...@@ -561,7 +561,7 @@ class AttrForm extends React.Component { ...@@ -561,7 +561,7 @@ class AttrForm extends React.Component {
const {url,name} =this.state const {url,name} =this.state
return ( return (
<Form onSubmit={this.submit}> <Form onSubmit={this.submit}>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="上传附件"> <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="上传附件">
{form.getFieldDecorator('src', { {form.getFieldDecorator('src', {
valuePropName: 'fileList', valuePropName: 'fileList',
...@@ -622,21 +622,21 @@ class VideoForm extends React.Component { ...@@ -622,21 +622,21 @@ class VideoForm extends React.Component {
const isJPG = file.type === 'video/mp4'; const isJPG = file.type === 'video/mp4';
if (!isJPG) { if (!isJPG) {
message.error('请上传mp4格式文件!'); message.error('请上传mp4格式文件!');
} }
return isJPG ; return isJPG ;
} }
onChange=(info) =>{ onChange=(info) =>{
if (info.file.status === 'done') { if (info.file.status === 'done') {
message.success(`视频上传成功`); message.success(`视频上传成功`);
this.setState({url:info.file.response}) this.setState({url:info.file.response})
} else if (info.file.status === 'error') { } else if (info.file.status === 'error') {
message.error(`视频上传失败`); message.error(`视频上传失败`);
} }
}; };
render() { render() {
...@@ -644,7 +644,7 @@ class VideoForm extends React.Component { ...@@ -644,7 +644,7 @@ class VideoForm extends React.Component {
const {url} =this.state const {url} =this.state
return ( return (
<Form onSubmit={this.submit}> <Form onSubmit={this.submit}>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="上传视频"> <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="上传视频">
{form.getFieldDecorator('src', { {form.getFieldDecorator('src', {
valuePropName: 'fileList', valuePropName: 'fileList',
...@@ -681,7 +681,7 @@ class PicForm extends React.Component { ...@@ -681,7 +681,7 @@ class PicForm extends React.Component {
if (!isJPG) { if (!isJPG) {
message.error('请上传jpg或者png格式文件!'); message.error('请上传jpg或者png格式文件!');
} }
return isJPG ; return isJPG ;
} }
submit = (e) => { submit = (e) => {
...@@ -705,21 +705,21 @@ class PicForm extends React.Component { ...@@ -705,21 +705,21 @@ class PicForm extends React.Component {
}) })
} }
normFile = (e) => { normFile = (e) => {
if (Array.isArray(e)) { if (Array.isArray(e)) {
return e; return e;
} }
return e && e.fileList; return e && e.fileList;
} }
onChange=(info) =>{ onChange=(info) =>{
if (info.file.status === 'done') { if (info.file.status === 'done') {
message.success(`图片上传成功`); message.success(`图片上传成功`);
this.setState({url:info.file.response}) this.setState({url:info.file.response})
} else if (info.file.status === 'error') { } else if (info.file.status === 'error') {
message.error(`图片上传失败`); message.error(`图片上传失败`);
} }
}; };
render() { render() {
...@@ -727,7 +727,7 @@ class PicForm extends React.Component { ...@@ -727,7 +727,7 @@ class PicForm extends React.Component {
const {url} =this.state const {url} =this.state
return ( return (
<Form onSubmit={this.submit}> <Form onSubmit={this.submit}>
<FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="上传图片"> <FormItem labelCol={{ span: 5 }} wrapperCol={{ span: 15 }} label="上传图片">
{form.getFieldDecorator('src', { {form.getFieldDecorator('src', {
valuePropName: 'fileList', valuePropName: 'fileList',
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论