Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
W
WebPublic
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
前端开发小组
WebPublic
Commits
8254b4ba
提交
8254b4ba
authored
2月 04, 2021
作者:
钟是志
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
2021年2月4日 16:28:53 屏蔽 模版设计里面的富文本里面的 video(视频组件)
上级
adc2ca51
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
56 行增加
和
56 行删除
+56
-56
DraftEditorCom.js
one_stop_public/App/DraftEditorCom.js
+56
-56
没有找到文件。
one_stop_public/App/DraftEditorCom.js
浏览文件 @
8254b4ba
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论