-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
94 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import type { NativeStackScreenProps } from '@react-navigation/native-stack'; | ||
import React from 'react'; | ||
import { SafeAreaView, View, StyleSheet, Button } from 'react-native'; | ||
import { | ||
LinkBridge, | ||
PlaceholderBridge, | ||
RichText, | ||
TenTapStartKit, | ||
useEditorBridge, | ||
} from '@10play/tentap-editor'; | ||
|
||
export const ConfigureExtensions = ({}: NativeStackScreenProps< | ||
any, | ||
any, | ||
any | ||
>) => { | ||
const editor = useEditorBridge({ | ||
autofocus: true, | ||
avoidIosKeyboard: true, | ||
bridgeExtensions: [ | ||
...TenTapStartKit, | ||
PlaceholderBridge.configureExtension({ | ||
placeholder: 'Hey there! Start typing...', | ||
}), | ||
LinkBridge.configureExtension({ openOnClick: false }), | ||
], | ||
}); | ||
|
||
return ( | ||
<SafeAreaView style={exampleStyles.fullScreen}> | ||
<View style={exampleStyles.fullScreen}> | ||
<RichText editor={editor} /> | ||
</View> | ||
<View style={exampleStyles.fullScreen}> | ||
<Button | ||
title="Click Me To Add Link" | ||
onPress={() => { | ||
editor.setContent( | ||
'<a href="https://10play.github.io/10tap-editor">Link To TenTap!</a>' | ||
); | ||
}} | ||
/> | ||
<Button | ||
title="Click Me To Show PlaceHolder" | ||
onPress={() => { | ||
editor.setContent(''); | ||
}} | ||
/> | ||
</View> | ||
</SafeAreaView> | ||
); | ||
}; | ||
|
||
const exampleStyles = StyleSheet.create({ | ||
fullScreen: { | ||
flex: 1, | ||
}, | ||
keyboardAvoidingView: { | ||
position: 'absolute', | ||
width: '100%', | ||
bottom: 0, | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
sidebar_position: 3 | ||
sidebar_position: 4 | ||
--- | ||
|
||
# Using The ColorKeyboard | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
sidebar_position: 3 | ||
--- | ||
|
||
# Configure Extensions | ||
|
||
In this example we will configure some extensions. Each bridge comes with the `configureExtension` function, that configures it's underline tiptap extension. | ||
|
||
## Configuring Placeholder and Link | ||
|
||
First we can check which options are available to extend on the tiptap docs. | ||
In our case let's extent the placeholder to show custom text, and the link extension to not open links when clicking them | ||
|
||
```tsx | ||
const editor = useEditorBridge({ | ||
bridgeExtensions: [ | ||
..., | ||
PlaceholderBridge.configureExtension({ | ||
placeholder: 'Type something...', | ||
}), | ||
LinkBridge.configureExtension({ openOnClick: false }), | ||
], | ||
}); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters