This repository was archived by the owner on Dec 29, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +14
-2
lines changed
ReactNativeDraftjsExample Expand file tree Collapse file tree 2 files changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -65,10 +65,21 @@ const EditorToolBar = ({
6565 isActive = { blockType === "ordered-list-item" }
6666 action = { ( ) => toggleBlockType ( "ordered-list-item" ) }
6767 />
68+ < ControlButton
69+ text = { "--" }
70+ isActive = { activeStyles . includes ( "STRIKETHROUGH" ) }
71+ action = { ( ) => toggleStyle ( "STRIKETHROUGH" ) }
72+ />
6873 </ View >
6974 ) ;
7075} ;
7176
77+ const styleMap = {
78+ STRIKETHROUGH : {
79+ textDecoration : "line-through"
80+ }
81+ } ;
82+
7283const App = ( ) => {
7384 const _draftRef = React . createRef ( ) ;
7485 const [ activeStyles , setActiveStyles ] = useState ( [ ] ) ;
@@ -96,7 +107,7 @@ const App = () => {
96107 * Usually keep it in the submit or next action to get output after user has typed.
97108 */
98109 setEditorState ( _draftRef . current ? _draftRef . current . getEditorState ( ) : "" ) ;
99- } ) ;
110+ } , [ _draftRef ] ) ;
100111 console . log ( editorState ) ;
101112
102113 return (
@@ -109,6 +120,7 @@ const App = () => {
109120 ref = { _draftRef }
110121 onStyleChanged = { setActiveStyles }
111122 onBlockTypeChanged = { setActiveBlockType }
123+ styleMap = { styleMap }
112124 />
113125 < EditorToolBar
114126 activeStyles = { activeStyles }
Original file line number Diff line number Diff line change @@ -27,7 +27,7 @@ class RNDraftView extends Component {
2727 executeScript = ( functionName , parameter ) => {
2828 this . _webViewRef . current &&
2929 this . _webViewRef . current . injectJavaScript (
30- `window.${ functionName } (${ parameter ? `" ${ parameter } " ` : "" } );true;`
30+ `window.${ functionName } (${ parameter ? `' ${ parameter } ' ` : "" } );true;`
3131 ) ;
3232 } ;
3333
You can’t perform that action at this time.
0 commit comments