diff options
author | Eric Bailey <git@esb.lol> | 2024-09-19 14:41:31 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-09-19 14:41:31 -0500 |
commit | 8a7fc9ad3f822ba77716a6eacb4c08ab2992c506 (patch) | |
tree | 283ea2d9b67da6ea0af2cff7b671b778d00f4297 /src/view/com/composer/text-input/TextInput.web.tsx | |
parent | 15231604679675633c72583879234402eea0fa2c (diff) | |
download | voidsky-8a7fc9ad3f822ba77716a6eacb4c08ab2992c506.tar.zst |
[Neue] Ligatures & composer (#5427)
* Disable contextual ligatures * Ensure new type styles are applied to the composer * Clean up using real devices * Feedback
Diffstat (limited to 'src/view/com/composer/text-input/TextInput.web.tsx')
-rw-r--r-- | src/view/com/composer/text-input/TextInput.web.tsx | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/src/view/com/composer/text-input/TextInput.web.tsx b/src/view/com/composer/text-input/TextInput.web.tsx index 3db25746f..acec61516 100644 --- a/src/view/com/composer/text-input/TextInput.web.tsx +++ b/src/view/com/composer/text-input/TextInput.web.tsx @@ -22,7 +22,9 @@ import { LinkFacetMatch, suggestLinkCardUri, } from 'view/com/composer/text-input/text-input-util' +import {atoms as a, useAlf} from '#/alf' import {Portal} from '#/components/Portal' +import {normalizeTextStyles} from '#/components/Typography' import {Text} from '../../util/text/Text' import {createSuggestion} from './web/Autocomplete' import {Emoji} from './web/EmojiPicker.web' @@ -58,6 +60,7 @@ export const TextInput = React.forwardRef(function TextInputImpl( TextInputProps, ref, ) { + const {theme: t, fonts} = useAlf() const autocomplete = useActorAutocompleteFn() const pal = usePalette('default') const modeClass = useColorSchemeStyle('ProseMirror-light', 'ProseMirror-dark') @@ -247,13 +250,32 @@ export const TextInput = React.forwardRef(function TextInputImpl( }, })) + const inputStyle = React.useMemo(() => { + const style = normalizeTextStyles( + [a.text_lg, a.leading_snug, t.atoms.text], + { + fontScale: fonts.scaleMultiplier, + fontFamily: fonts.family, + flags: {}, + }, + ) + /* + * TipTap component isn't a RN View and while it seems to convert + * `fontSize` to `px`, it doesn't convert `lineHeight`. + * + * `lineHeight` should always be defined here, this is defensive. + */ + style.lineHeight = style.lineHeight + ? ((style.lineHeight + 'px') as unknown as number) + : undefined + return style + }, [t, fonts]) + return ( <> <View style={styles.container}> - <EditorContent - editor={editor} - style={{color: pal.text.color as string}} - /> + {/* @ts-ignore inputStyle is fine */} + <EditorContent editor={editor} style={inputStyle} /> </View> {isDropping && ( |