Skip to content

Commit

Permalink
Merge pull request #9 from 10play/guy353/rnr-21-placeholder-bridge
Browse files Browse the repository at this point in the history
feat: add placeholder
  • Loading branch information
GuySerfaty authored Feb 6, 2024
2 parents e9d8fb8 + 582977d commit d771669
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 3 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ jobs:
with:
path: |
**/ios/Pods
key: ${{ runner.os }}-cocoapods-${{ hashFiles('example/ios/Podfile.lock') }}
key: ${{ runner.os }}-cocoapods-v2-${{ hashFiles('example/ios/Podfile.lock') }}
restore-keys: |
${{ runner.os }}-cocoapods-
${{ runner.os }}-cocoapods-v2-
- name: Install cocoapods
if: env.turbo_cache_hit != 1 && steps.cocoapods-cache.outputs.cache-hit != 'true'
Expand Down
4 changes: 3 additions & 1 deletion example/src/Examples/Basic.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
HighlightBridge,
ImageBridge,
LinkBridge,
PlaceholderBridge,
RichText,
TaskListBridge,
TenTapStartKit,
Expand Down Expand Up @@ -44,6 +45,7 @@ export const Basic = ({}: NativeStackScreenProps<any, any, any>) => {
UnderlineBridge,
ImageBridge,
TaskListBridge,
PlaceholderBridge.configure({ placeholder: 'Type something...' }),
LinkBridge.configure({ openOnClick: false }),
ColorBridge,
HighlightBridge,
Expand All @@ -55,7 +57,7 @@ export const Basic = ({}: NativeStackScreenProps<any, any, any>) => {
return (
<SafeAreaView style={exampleStyles.fullScreen} ref={TapRef}>
<View style={exampleStyles.fullScreen}>
<RichText avoidIosKeyboard editor={editor} autofocus />
<RichText avoidIosKeyboard editor={editor} DEV autofocus />
</View>
<KeyboardAvoidingView
behavior={Platform.OS === 'ios' ? 'padding' : 'height'}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@
"@tiptap/extension-highlight": "^2.1.16",
"@tiptap/extension-image": "^2.2.1",
"@tiptap/extension-link": "^2.1.16",
"@tiptap/extension-placeholder": "^2.2.1",
"@tiptap/extension-task-item": "^2.1.16",
"@tiptap/extension-task-list": "^2.1.16",
"@tiptap/extension-text-style": "^2.1.16",
Expand Down
27 changes: 27 additions & 0 deletions src/bridges/placeholder.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import Placeholder from '@tiptap/extension-placeholder';
import TenTapBridge from './base';

type PlaceholderEditorState = {};

type PlaceholderEditorInstance = {};

declare module '../types/EditorNativeState' {
interface EditorNativeState extends PlaceholderEditorState {}
interface EditorInstance extends PlaceholderEditorInstance {}
}

export const PlaceholderBridge = new TenTapBridge<
PlaceholderEditorState,
PlaceholderEditorInstance
>({
tiptapExtension: Placeholder,
extendCSS: `
.is-editor-empty:first-child::before {
color: #adb5bd;
content: attr(data-placeholder);
float: left;
height: 0;
pointer-events: none;
}
`,
});
1 change: 1 addition & 0 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export * from './bridges/tasklist';
export * from './bridges/link';
export * from './bridges/color';
export * from './bridges/highlight';
export * from './bridges/placeholder';
export * from './bridges/core';
export * from './bridges/image';
export * from './types';
Expand Down
2 changes: 2 additions & 0 deletions src/simpleWebEditor/Tiptap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ColorBridge } from '../bridges/color';
import { HighlightBridge } from '../bridges/highlight';
import { CoreBridge } from '../bridges/core';
import { ImageBridge } from '../bridges/image';
import { PlaceholderBridge } from '../bridges/placeholder';

let tenTapExtensions = [
TenTapStartKit,
Expand All @@ -19,6 +20,7 @@ let tenTapExtensions = [
ColorBridge,
HighlightBridge,
CoreBridge,
PlaceholderBridge,
].filter(
(e) => !window.whiteListPlugins || window.whiteListPlugins.includes(e.name)
);
Expand Down
11 changes: 11 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4813,6 +4813,16 @@ __metadata:
languageName: node
linkType: hard

"@tiptap/extension-placeholder@npm:^2.2.1":
version: 2.2.1
resolution: "@tiptap/extension-placeholder@npm:2.2.1"
peerDependencies:
"@tiptap/core": ^2.0.0
"@tiptap/pm": ^2.0.0
checksum: cec29ec2a6d94800ec00e42e89cae8d18facc6fb4a2029c95f3c5bf78cccfca65c6eac7f366bc13c8e52a5192fd8afa412a6db73ca35adf136260870e8d73046
languageName: node
linkType: hard

"@tiptap/extension-strike@npm:^2.1.16":
version: 2.1.16
resolution: "@tiptap/extension-strike@npm:2.1.16"
Expand Down Expand Up @@ -19551,6 +19561,7 @@ __metadata:
"@tiptap/extension-highlight": ^2.1.16
"@tiptap/extension-image": ^2.2.1
"@tiptap/extension-link": ^2.1.16
"@tiptap/extension-placeholder": ^2.2.1
"@tiptap/extension-task-item": ^2.1.16
"@tiptap/extension-task-list": ^2.1.16
"@tiptap/extension-text-style": ^2.1.16
Expand Down

0 comments on commit d771669

Please sign in to comment.