File tree Expand file tree Collapse file tree 4 files changed +17
-12
lines changed
site/components/SuperheroEditor Expand file tree Collapse file tree 4 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -9,11 +9,12 @@ import stickers from './stickers';
9
9
import StatePreview from '../StatePreview' ;
10
10
import Hashtag from './Hashtag' ;
11
11
import Link from './Link' ;
12
- import Sticker from './Sticker' ;
13
12
13
+ // import Sticker from './Sticker';
14
+ // const stickerPluginInstance = stickerPlugin({ stickers, Sticker });
15
+ const stickerPluginInstance = stickerPlugin ( { stickers, hasRemove : false } ) ;
14
16
const hashtagPluginInstance = hashtagPlugin ( { Hashtag } ) ;
15
17
const linkifyPluginInstance = linkifyPlugin ( { Link } ) ;
16
- const stickerPluginInstance = stickerPlugin ( { stickers, Sticker } ) ;
17
18
const { StickerSelect } = stickerPluginInstance ;
18
19
19
20
const plugins = [
Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ import React, { Component } from 'react';
6
6
import styles from './styles' ;
7
7
import { Entity } from 'draft-js' ;
8
8
9
- export default ( stickers ) => {
9
+ export default ( stickers , hasRemove = true ) => {
10
10
class Sticker extends Component {
11
11
12
12
remove = ( event ) => {
@@ -18,18 +18,22 @@ export default (stickers) => {
18
18
} ;
19
19
20
20
render ( ) {
21
+ const removeButton = (
22
+ < span
23
+ style = { styles . removeButton }
24
+ onClick = { this . remove }
25
+ type = "button"
26
+ >
27
+ ✕
28
+ </ span >
29
+ ) ;
30
+
21
31
const { block } = this . props ;
22
32
const data = Entity . get ( block . getEntityAt ( 0 ) ) . getData ( ) ;
23
33
return (
24
34
< figure style = { styles . root } contentEditable = { false } data-offset-key = { `${ block . get ( 'key' ) } -0-0` } >
25
35
< img style = { styles . image } src = { stickers . getIn ( [ 'data' , data . id , 'url' ] ) } />
26
- < span
27
- style = { styles . removeButton }
28
- onClick = { this . remove }
29
- type = "button"
30
- >
31
- ✕
32
- </ span >
36
+ { hasRemove ? removeButton : null }
33
37
</ figure >
34
38
) ;
35
39
}
Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ export default (config) => (contentBlock, editor) => {
5
5
const type = contentBlock . getType ( ) ;
6
6
if ( type === 'sticker' ) {
7
7
return {
8
- component : ( config . Sticker !== undefined ? config . Sticker : sticker ( config . stickers ) ) ,
8
+ component : ( config . Sticker !== undefined ? config . Sticker : sticker ( config . stickers , config . hasRemove ) ) ,
9
9
props : {
10
10
onRemove : ( blockKey ) => {
11
11
editor . onChange ( removeSticker ( editor . props . editorState , blockKey ) ) ;
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ const stickerPlugin = (config) => ({
10
10
blockRendererFn : blockRendererFn ( config ) , // standard plugin callback
11
11
onChange : cleanupEmptyStickers , // standard plugin callback
12
12
remove : removeSticker ,
13
- Sticker : sticker ( config . stickers ) ,
13
+ Sticker : sticker ( config . stickers , config . hasRemove ) ,
14
14
StickerSelect : stickerSelect ( config . stickers ) ,
15
15
} ) ;
16
16
You can’t perform that action at this time.
0 commit comments