Skip to content

Commit a7f63b8

Browse files
committed
refactor(editor): simplify font styling and component layouts
- replace custom font families with standard font weights - remove redundant styling and simplify component layouts - improve consistency in text formatting across editor components
1 parent 28b8a19 commit a7f63b8

File tree

10 files changed

+169
-427
lines changed

10 files changed

+169
-427
lines changed

app/editor.tsx

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import { Ionicons } from '@expo/vector-icons';
66
import * as Clipboard from 'expo-clipboard';
77
import * as Crypto from 'expo-crypto';
88
import { useLocalSearchParams, useRouter } from 'expo-router';
9-
import { CheckSquare, Code, Copy, FileText, Heading1, Heading2, Heading3, Lightbulb, List, ListOrdered, Minus, Plus, Quote, Redo2, Save, Type, Undo2, X } from 'lucide-react-native';
10-
import React, { useCallback, useEffect, useRef, useState } from 'react';
9+
import { CheckSquare, Code, Copy, Heading1, Heading2, Heading3, Lightbulb, List, ListOrdered, Minus, Plus, Quote, Redo2, Save, Type, Undo2, X } from 'lucide-react-native';
10+
import React, { StrictMode, useCallback, useEffect, useRef, useState } from 'react';
1111
import { ActivityIndicator, Alert, Animated, FlatList, Modal, StatusBar, StyleSheet, Text, TextInput, TouchableOpacity, View } from 'react-native';
1212
import { SafeAreaView } from 'react-native-safe-area-context';
1313
import MarkdownEditor from '../components/editor/MarkdownEditor';
@@ -279,7 +279,7 @@ export default function EditorScreen() {
279279
}
280280
hideBlockComponents();
281281
}, [hideBlockComponents]);
282-
282+
283283
// Handle block changes
284284
const handleBlockChange = useCallback((blocks: EditorBlock[]) => {
285285
setBlocks(blocks);
@@ -405,22 +405,22 @@ export default function EditorScreen() {
405405
await Clipboard.setStringAsync(isEditingMarkdown ? editedMarkdown : rawMarkdown);
406406
Alert.alert('Copied!', 'Markdown copied to clipboard');
407407
}, [rawMarkdown, editedMarkdown, isEditingMarkdown]);
408-
408+
409409
// Apply edited markdown
410410
const handleApplyMarkdown = useCallback(() => {
411411
if (editorRef.current && editedMarkdown !== rawMarkdown) {
412412
try {
413413
// Apply the markdown to the editor
414414
editorRef.current.setMarkdown(editedMarkdown);
415-
415+
416416
// Get the updated blocks from the editor after parsing
417417
setTimeout(() => {
418418
if (editorRef.current) {
419419
const updatedBlocks = editorRef.current.getBlocks();
420420
setBlocks(updatedBlocks);
421421
}
422422
}, 100);
423-
423+
424424
setRawMarkdown(editedMarkdown);
425425
setIsEditingMarkdown(false);
426426
markAsChanged();
@@ -433,13 +433,13 @@ export default function EditorScreen() {
433433
setIsEditingMarkdown(false);
434434
}
435435
}, [editedMarkdown, rawMarkdown, markAsChanged]);
436-
436+
437437
// Start editing markdown
438438
const handleEditMarkdown = useCallback(() => {
439439
setEditedMarkdown(rawMarkdown);
440440
setIsEditingMarkdown(true);
441441
}, [rawMarkdown]);
442-
442+
443443
// Cancel editing markdown
444444
const handleCancelEditMarkdown = useCallback(() => {
445445
setEditedMarkdown(rawMarkdown);
@@ -544,25 +544,27 @@ export default function EditorScreen() {
544544
</View>
545545
) : (
546546
<View style={styles.editorContainer}>
547-
<MarkdownEditor
548-
ref={editorRef}
549-
initialBlocks={blocks}
550-
placeholder="Start writing..."
551-
onBlocksChange={handleBlockChange}
552-
theme={getEditorTheme(colorScheme || 'light')}
553-
config={{
554-
toolbar: { enabled: false },
555-
theme: {
556-
colors: {
557-
background: colors.background,
558-
text: colors.text,
559-
border: colorScheme === 'dark' ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)',
560-
primary: colors.tint,
561-
secondary: colors.icon
547+
<StrictMode>
548+
<MarkdownEditor
549+
ref={editorRef}
550+
initialBlocks={blocks}
551+
placeholder="Start writing..."
552+
onBlocksChange={handleBlockChange}
553+
theme={getEditorTheme(colorScheme || 'light')}
554+
config={{
555+
toolbar: { enabled: false },
556+
theme: {
557+
colors: {
558+
background: colors.background,
559+
text: colors.text,
560+
border: colorScheme === 'dark' ? 'rgba(255, 255, 255, 0.1)' : 'rgba(0, 0, 0, 0.1)',
561+
primary: colors.tint,
562+
secondary: colors.icon
563+
}
562564
}
563-
}
564-
}}
565-
/>
565+
}}
566+
/>
567+
</StrictMode>
566568
</View>
567569
)}
568570

@@ -728,7 +730,7 @@ export default function EditorScreen() {
728730
<X size={24} color={colors.text} />
729731
</TouchableOpacity>
730732
</View>
731-
733+
732734
{isEditingMarkdown ? (
733735
<TextInput
734736
style={[styles.markdownInput, {
@@ -752,7 +754,7 @@ export default function EditorScreen() {
752754
<Text style={[styles.markdownText, { color: colors.text }]}>{rawMarkdown}</Text>
753755
</View>
754756
)}
755-
757+
756758
<View style={styles.markdownModalActions}>
757759
{isEditingMarkdown ? (
758760
<>

components/editor/components/FormattedText.tsx

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,25 +71,26 @@ const getSegmentStyle = (type: FormattedTextSegment['type'], styles: any) => {
7171

7272
const getStyles = (colorScheme: 'light' | 'dark') => {
7373
const colors = Colors[colorScheme];
74-
74+
7575
return StyleSheet.create({
7676
text: {
7777
fontSize: 16,
7878
lineHeight: 24,
7979
color: colors.text,
80+
// Use system font for formatted text to ensure bold/italic work properly
8081
},
8182
normal: {
82-
// fontWeight: 'normal',
83-
// fontStyle: 'normal',
83+
fontWeight: '400',
8484
},
8585
bold: {
86-
fontWeight: 'bold',
86+
fontWeight: '700',
8787
},
8888
italic: {
8989
fontStyle: 'italic',
90+
fontWeight: '400',
9091
},
9192
boldItalic: {
92-
fontWeight: 'bold',
93+
fontWeight: '700',
9394
fontStyle: 'italic',
9495
},
9596
code: {
@@ -100,6 +101,7 @@ const getStyles = (colorScheme: 'light' | 'dark') => {
100101
paddingVertical: 2,
101102
borderRadius: 3,
102103
fontSize: 14,
104+
fontWeight: '400',
103105
},
104106
});
105107
};

components/editor/components/FormattedTextInput.tsx

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export const FormattedTextInput = forwardRef<TextInput, FormattedTextInputProps>
121121
>
122122
{value ? (
123123
<FormattedText
124-
text={value}
124+
text={value}
125125
style={[styles.formattedText, style]}
126126
isEditing={false}
127127
/>
@@ -140,45 +140,37 @@ FormattedTextInput.displayName = 'FormattedTextInput';
140140

141141
const getStyles = (colorScheme: 'light' | 'dark') => {
142142
const colors = Colors[colorScheme];
143-
143+
144144
return StyleSheet.create({
145145
textInput: {
146146
fontSize: 16,
147-
fontFamily: 'AlbertSans_400Regular',
148147
lineHeight: 24,
149148
color: colors.text,
150149
minHeight: 40,
151-
borderRadius: 8,
152150
backgroundColor: 'transparent',
153-
paddingHorizontal: 4,
154-
paddingVertical: 4,
151+
paddingHorizontal: 0,
152+
paddingVertical: 0,
155153
},
156154
formattedContainer: {
157-
paddingHorizontal: 4,
158-
paddingVertical: 8,
155+
paddingHorizontal: 0,
156+
paddingVertical: 0,
159157
minHeight: 40,
160-
borderRadius: 8,
161158
backgroundColor: 'transparent',
162159
justifyContent: 'center',
163160
},
164161
formattedText: {
165162
fontSize: 16,
166-
fontFamily: 'AlbertSans_400Regular',
167163
lineHeight: 24,
168164
color: colors.text,
169165
},
170166
placeholder: {
171167
color: colors.textSecondary,
172168
},
173169
selected: {
174-
backgroundColor: colors.blue + '20',
175-
borderColor: colors.teal,
176-
borderWidth: 1,
170+
backgroundColor: 'transparent',
177171
},
178172
editing: {
179-
backgroundColor: colors.surface,
180-
borderWidth: 0,
181-
elevation: 0,
173+
backgroundColor: 'transparent',
182174
},
183175
});
184176
};

0 commit comments

Comments
 (0)