@@ -4,7 +4,7 @@ import modifyBlockData from './modifyBlockData';
4
4
import { readFiles } from '../utils/file' ;
5
5
import { getBlocksWhereEntityData } from '../utils/block' ;
6
6
7
- function defaultHandlePreview ( state , selection , data , defaultBlockType ) {
7
+ function defaultHandlePlaceholder ( state , selection , data , defaultBlockType ) {
8
8
return addBlock ( state , state . getSelection ( ) , defaultBlockType , data ) ;
9
9
}
10
10
@@ -15,7 +15,7 @@ function defaultHandleBlock(state, selection, data, defaultBlockType) {
15
15
export default function onDropFile ( config ) {
16
16
return function onDropFileInner ( selection , files , { getEditorState, setEditorState } ) {
17
17
// Get upload function from config or editor props
18
- const { handleUpload, handlePreview , handleBlock, defaultBlockType, handleProgress } = config ;
18
+ const { handleUpload, handlePlaceholder , handleBlock, defaultBlockType, handleProgress } = config ;
19
19
if ( handleUpload ) {
20
20
const formData = new FormData ( ) ;
21
21
@@ -31,13 +31,13 @@ export default function onDropFile(config) {
31
31
data . formData = data ;
32
32
33
33
// Read files on client side
34
- readFiles ( data . files ) . then ( previews => {
34
+ readFiles ( data . files ) . then ( placeholders => {
35
35
// Add blocks for each image before uploading
36
36
let state = getEditorState ( ) ;
37
- previews . forEach ( preview => {
38
- state = handlePreview
39
- ? handlePreview ( state , selection , { ...preview , progress : 1 } )
40
- : defaultHandlePreview ( state , selection , { ...preview , progress : 1 } , defaultBlockType ) ;
37
+ placeholders . forEach ( placeholder => {
38
+ state = handlePlaceholder
39
+ ? handlePlaceholder ( state , selection , { ...placeholder , progress : 1 } )
40
+ : defaultHandlePlaceholder ( state , selection , { ...placeholder , progress : 1 } , defaultBlockType ) ;
41
41
} ) ;
42
42
setEditorState ( state ) ;
43
43
@@ -64,8 +64,8 @@ export default function onDropFile(config) {
64
64
} , ( percent ) => {
65
65
// On progress, set entity data's progress field
66
66
let newEditorState = getEditorState ( ) ;
67
- previews . forEach ( preview => {
68
- const blocks = getBlocksWhereEntityData ( newEditorState , preview2 => preview2 . src === preview . src && preview2 . progress !== undefined ) ;
67
+ placeholders . forEach ( placeholder => {
68
+ const blocks = getBlocksWhereEntityData ( newEditorState , p => p . src === placeholder . src && p . progress !== undefined ) ;
69
69
if ( blocks . size ) {
70
70
newEditorState = modifyBlockData ( newEditorState , blocks . first ( ) . get ( 'key' ) , { progress : percent } ) ;
71
71
}
0 commit comments