react-native-rich-editor icon indicating copy to clipboard operation
react-native-rich-editor copied to clipboard

Typescript for custom actions

Open gabrielbuzziv opened this issue 3 years ago • 1 comments

How can i handle RichToolbar component typescript when adding new actions?

The following is my custom component, typescript don't accept hideContent props, since it was not declared.

 <RichToolbar
  editor={richText}
  actions={[
    actions.setBold,
    actions.setItalic,
    actions.setUnderline,
    'hideContent',
  ]}
  iconMap={{
    hideContent: ({ tintColor }) => (
      <MaterialCommunityIcons name="eye" color={tintColor} />
    ),
  }}
  hideContent={() => richText.current.insertText('{{ HIDDEN }}')}
/>

gabrielbuzziv avatar Feb 10 '22 22:02 gabrielbuzziv

@gabrielbuzziv Do you want to fire new action when hideContent Icon pressed?

Then, how about trying onPress property in your custom iconMap.

...
iconMap={{
    hideContent: ({ tintColor }) => (
      <TouchableOpacity onPress={this.handleFunction}>
          <MaterialCommunityIcons name="eye" color={tintColor} />
      </TouchableOpacity>
    ),
  }}
...

I wanted to apply a function to handle new action, but customAction property which doc suggest is not working and even has not a type.

mauvpark avatar Jul 11 '22 09:07 mauvpark