Skip to content

Commit 71a98ac

Browse files
author
Benjamin Kniffler
committed
rename 'Preview' to 'Placeholder'
1 parent 8f99f68 commit 71a98ac

File tree

4 files changed

+13
-13
lines changed

4 files changed

+13
-13
lines changed

docs/client/components/pages/Dnd/SimpleDndEditor/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ const dndPlugin = createDndPlugin({
1515
allowDrop: true,
1616
handleUpload: (data, success, failed, progress) =>
1717
mockUpload(data, success, failed, progress),
18-
handlePreview: (state, selection, data) => {
18+
handlePlaceholder: (state, selection, data) => {
1919
const { type } = data;
2020
if (type.indexOf('image/') === 0) {
2121
return addBlock(state, state.getSelection(), 'block-image', data);

docs/client/components/pages/Dnd/components/block-text.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ class BlockText extends Component {
1818
}
1919

2020
export default Draggable(BlockText, {
21-
useDiv: true
21+
useDiv: true,
2222
});

docs/client/components/pages/Dnd/components/preview-github.js renamed to docs/client/components/pages/Dnd/components/placeholder-github.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React, { Component } from 'react';
22

3-
class PreviewGithub extends Component {
3+
class PlaceholderGithub extends Component {
44
render() {
55
const { blockProps, block } = this.props;
66

@@ -12,4 +12,4 @@ class PreviewGithub extends Component {
1212
}
1313
}
1414

15-
export default PreviewGithub;
15+
export default PlaceholderGithub;

draft-js-dnd-plugin/src/modifiers/onDropFile.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import modifyBlockData from './modifyBlockData';
44
import { readFiles } from '../utils/file';
55
import { getBlocksWhereEntityData } from '../utils/block';
66

7-
function defaultHandlePreview(state, selection, data, defaultBlockType) {
7+
function defaultHandlePlaceholder(state, selection, data, defaultBlockType) {
88
return addBlock(state, state.getSelection(), defaultBlockType, data);
99
}
1010

@@ -15,7 +15,7 @@ function defaultHandleBlock(state, selection, data, defaultBlockType) {
1515
export default function onDropFile(config) {
1616
return function onDropFileInner(selection, files, { getEditorState, setEditorState }) {
1717
// Get upload function from config or editor props
18-
const { handleUpload, handlePreview, handleBlock, defaultBlockType, handleProgress } = config;
18+
const { handleUpload, handlePlaceholder, handleBlock, defaultBlockType, handleProgress } = config;
1919
if (handleUpload) {
2020
const formData = new FormData();
2121

@@ -31,13 +31,13 @@ export default function onDropFile(config) {
3131
data.formData = data;
3232

3333
// Read files on client side
34-
readFiles(data.files).then(previews => {
34+
readFiles(data.files).then(placeholders => {
3535
// Add blocks for each image before uploading
3636
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);
4141
});
4242
setEditorState(state);
4343

@@ -64,8 +64,8 @@ export default function onDropFile(config) {
6464
}, (percent) => {
6565
// On progress, set entity data's progress field
6666
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);
6969
if (blocks.size) {
7070
newEditorState = modifyBlockData(newEditorState, blocks.first().get('key'), { progress: percent });
7171
}

0 commit comments

Comments
 (0)