提交 bb1ea15d authored 作者: 王鹏飞's avatar 王鹏飞

refactor: 优化代码格式,统一箭头函数语法

上级 c32d0b8d
...@@ -38,7 +38,7 @@ const ImageModal = (props, ref) => { ...@@ -38,7 +38,7 @@ const ImageModal = (props, ref) => {
maxCount: 1, maxCount: 1,
showUploadList: false, showUploadList: false,
accept: fileAccept.join(','), accept: fileAccept.join(','),
beforeUpload: file => { beforeUpload: (file) => {
const fileExt = file.name.substring(file.name.lastIndexOf('.')) const fileExt = file.name.substring(file.name.lastIndexOf('.'))
if (!fileAccept.includes(fileExt.toLowerCase())) { if (!fileAccept.includes(fileExt.toLowerCase())) {
message.error('请上传正确格式的图片') message.error('请上传正确格式的图片')
...@@ -52,7 +52,7 @@ const ImageModal = (props, ref) => { ...@@ -52,7 +52,7 @@ const ImageModal = (props, ref) => {
setImgUrl(url) setImgUrl(url)
form.setFieldsValue({ imgUrl: url }) form.setFieldsValue({ imgUrl: url })
setUploading(false) setUploading(false)
} },
} }
const clear = () => { const clear = () => {
...@@ -65,12 +65,12 @@ const ImageModal = (props, ref) => { ...@@ -65,12 +65,12 @@ const ImageModal = (props, ref) => {
setImageVisible(false) setImageVisible(false)
} }
const onFinish = values => { const onFinish = (values) => {
console.log(values) console.log(values)
editor.restoreSelection() editor.restoreSelection()
const nodeEntries = SlateEditor.nodes(editor, { const nodeEntries = SlateEditor.nodes(editor, {
match: node => { match: (node) => {
// JS syntax // JS syntax
if (SlateElement.isElement(node)) { if (SlateElement.isElement(node)) {
if (node.type === 'paragraph') { if (node.type === 'paragraph') {
...@@ -79,7 +79,7 @@ const ImageModal = (props, ref) => { ...@@ -79,7 +79,7 @@ const ImageModal = (props, ref) => {
} }
return false return false
}, },
universal: true universal: true,
}) })
for (let nodeEntry of nodeEntries) { for (let nodeEntry of nodeEntries) {
const [node] = nodeEntry const [node] = nodeEntry
...@@ -100,16 +100,16 @@ const ImageModal = (props, ref) => { ...@@ -100,16 +100,16 @@ const ImageModal = (props, ref) => {
children: [ children: [
{ {
// 该字段必须要 // 该字段必须要
text: '' text: '',
} },
] ],
} },
] ],
} }
const oP = { const oP = {
type: 'paragraph', type: 'paragraph',
textAlign: 'center', textAlign: 'center',
children: [{ text: values.imgTitle }] children: [{ text: values.imgTitle }],
} }
if (tempNodeInfo && Object.entries(tempNodeInfo).length > 0) { if (tempNodeInfo && Object.entries(tempNodeInfo).length > 0) {
...@@ -142,7 +142,7 @@ const ImageModal = (props, ref) => { ...@@ -142,7 +142,7 @@ const ImageModal = (props, ref) => {
clear() clear()
} }
const onOnlineImageChange = url => { const onOnlineImageChange = (url) => {
setImgUrl(url) setImgUrl(url)
form.setFieldsValue({ imgUrl: url }) form.setFieldsValue({ imgUrl: url })
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论