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

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

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