File tree Expand file tree Collapse file tree 5 files changed +22
-46
lines changed Expand file tree Collapse file tree 5 files changed +22
-46
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " draft-js-divider-plugin" ,
3
- "version" : " 0.2.0 " ,
3
+ "version" : " 0.2.1 " ,
4
4
"description" : " Divider Plugin for DraftJS" ,
5
5
"author" : {
6
6
"name" : " Ilkwon Sim" ,
35
35
"license" : " MIT" ,
36
36
"dependencies" : {
37
37
"decorate-component-with-props" : " ^1.0.2" ,
38
- "prop-types" : " ^15.5.8"
38
+ "prop-types" : " ^15.5.8" ,
39
+ "union-class-names" : " ^1.0.0"
39
40
},
40
41
"peerDependencies" : {
41
42
"draft-js" : " ^0.10.1" ,
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 1
1
import React , { Component } from 'react' ;
2
2
import PropTypes from 'prop-types' ;
3
3
4
+ import unionClassNames from 'union-class-names' ;
5
+
4
6
import { insertCustomBlock } from '../utils' ;
5
7
6
8
class DividerButton extends Component {
@@ -17,9 +19,20 @@ class DividerButton extends Component {
17
19
event . preventDefault ( ) ;
18
20
} ;
19
21
22
+ blockTypeIsActive = ( ) => {
23
+ const editorState = this . props . getEditorState ( ) ;
24
+ const type = editorState
25
+ . getCurrentContent ( )
26
+ . getBlockForKey ( editorState . getSelection ( ) . getStartKey ( ) )
27
+ . getType ( ) ;
28
+ return type === this . props . blockType ;
29
+ } ;
30
+
20
31
render ( ) {
21
32
const { theme } = this . props ;
22
- const className = theme . button ;
33
+ const className = this . blockTypeIsActive ( )
34
+ ? unionClassNames ( theme . button , theme . active )
35
+ : theme . button ;
23
36
24
37
return (
25
38
< div className = { theme . buttonWrapper } onMouseDown = { this . preventBubblingUp } >
Original file line number Diff line number Diff line change @@ -3,8 +3,6 @@ import React from 'react';
3
3
import DefaultDivider from './components/DefaultDivider' ;
4
4
import DividerButton from './components/DividerButton' ;
5
5
6
- import buttonStyles from './buttonStyles.css' ;
7
-
8
6
import addDivider from './modifiers/addDivider' ;
9
7
10
8
const createDividerPlugin = (
@@ -21,8 +19,8 @@ const createDividerPlugin = (
21
19
DividerButton : props => (
22
20
< DividerButton
23
21
{ ...props }
22
+ blockType = { blockType }
24
23
addDivider = { addDivider ( blockType ) }
25
- theme = { buttonStyles }
26
24
/>
27
25
) ,
28
26
addDivider : addDivider ( blockType ) ,
Original file line number Diff line number Diff line change @@ -103,6 +103,10 @@ ua-parser-js@^0.7.9:
103
103
version "0.7.14"
104
104
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.14.tgz#110d53fa4c3f326c121292bbeac904d2e03387ca"
105
105
106
+ union-class-names@^1.0.0 :
107
+ version "1.0.0"
108
+ resolved "https://registry.yarnpkg.com/union-class-names/-/union-class-names-1.0.0.tgz#9259608adacc39094a2b0cfe16c78e6200617847"
109
+
106
110
watch@^1.0.2 :
107
111
version "1.0.2"
108
112
resolved "https://registry.yarnpkg.com/watch/-/watch-1.0.2.tgz#340a717bde765726fa0aa07d721e0147a551df0c"
You can’t perform that action at this time.
0 commit comments