// import EditorMenu from '@/components/EditorMenu'; import { format } from 'date-fns'; // import { useRouter } from 'expo-router'; // import React, { useEffect, useState } from 'react'; // import { Keyboard, ScrollView, StyleSheet, TextInput } from 'react-native'; import { Appbar, useTheme } from 'react-native-paper'; // import { useSafeAreaInsets } from 'react-native-safe-area-context'; // import { EditorContent, useEditor } from 'rn-text-editor'; // export default function NewEntryScreen() { // const navigation = useRouter(); // const theme = useTheme(); // const entryDate = format(new Date(), 'LLL d, h:mm aaa'); // const editor = useEditor({ // enableCoreExtensions: true, // onUpdate(props) { // const newText = props.editor.getNativeText(); // // setEntryText(newText); // }, // }); // return ( // // // { // stats['characters'] === 0 ? // { // navigation.back(); // }} /> // : // { // navigation.back(); // }} /> // } // // { }} /> // { }} /> // // // {stats.words} words ยท {stats.characters} characters // // // {/* // */} // // // {/* // < IconButton // icon="format-bold" // size={24} accessible={false} // onPress={() => { // console.log('Bold button pressed'); inputRef.current?.focus(); // }} // /> // { // console.log('Italic button pressed'); // }} // /> // { // console.log('Underline button pressed'); // }} // /> // */} // // // ); // } // const styles = StyleSheet.create({ // container: { // flex: 1, // justifyContent: 'center', // paddingHorizontal: 1, // }, // editorContainer: { // paddingHorizontal: 5, // flex: 1 // }, // box: { // width: 60, // height: 60, // marginVertical: 20, // }, // }); import Wrapper from '@/components/ui/Wrapper'; import { CoreBridge, RichText, TenTapStartKit, Toolbar, useEditorBridge, useEditorContent } from '@10play/tentap-editor'; import { useRouter } from 'expo-router'; import React, { useEffect, useState } from 'react'; import { Keyboard, View } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; export default function NewEntryScreen() { const [entryText, setEntryText] = useState(''); const [stats, setStats] = useState<{ words: number; characters: number }>({ words: 0, characters: 0, }); useEffect(() => { const words = entryText.trim().split(/\s+/).filter(Boolean).length; const characters = entryText.length; setStats({ words, characters }); console.log('Entry text updated:', entryText); } , [entryText]); const navigation = useRouter(); const theme = useTheme(); const entryDate = format(new Date(), 'LLL d, h:mm aaa'); const insets = useSafeAreaInsets(); const [keyboardHeight, setKeyboardHeight] = useState(0); useEffect(() => { const keyboardDidShowListener = Keyboard.addListener('keyboardDidShow', () => { setKeyboardHeight(Keyboard.metrics()?.height || 0); }); const keyboardDidHideListener = Keyboard.addListener('keyboardDidHide', () => { setKeyboardHeight(0); }); return () => { keyboardDidShowListener.remove(); keyboardDidHideListener.remove(); }; }, []); const editor = useEditorBridge({ autofocus: true, avoidIosKeyboard: true, theme: { webviewContainer: { paddingLeft: 15, backgroundColor: theme.colors.surface, }, }, bridgeExtensions: [ ...TenTapStartKit, CoreBridge.configureCSS(` * { font-size: 12px; } `), // Custom font ], }); const content = { html: useEditorContent(editor, { type: 'html' }), text: useEditorContent(editor, { type: 'text' }), }; useEffect(() => { content && setEntryText(content.text ?? ''); }, [content]); return ( { stats['characters'] === 0 ? { navigation.back(); }} /> : { navigation.back(); }} /> } { }} /> { }} /> {/* */} {/* */} ); };