Skip to content

Commit

Permalink
♻️ Refactor hasText() function
Browse files Browse the repository at this point in the history
Co-Authored-By: Pascal Birchler <pascal.birchler@gmail.com>
  • Loading branch information
AnuragVasanwala and swissspidy committed May 16, 2023
1 parent 2ea1c81 commit a2a96e8
Showing 1 changed file with 2 additions and 5 deletions.
Expand Up @@ -178,15 +178,12 @@ function useRichTextFormatting(selectedElements, pushUpdate) {
};
}, [hasCurrentEditor, selectionActions, push, clearEditing, queuePush]);

const hasText = useCallback(() => {
const texts = selectedElements.filter(({ type }) => type === 'text');
return texts.length > 0;
}, [selectedElements]);
const hasText = selectedElements.find(({ type }) => type === 'text');

useGlobalKeyDownEffect(
{ key: ['mod+b', 'mod+u', 'mod+i'] },
({ key }) => {
if (!hasText()) {
if (!hasText) {
return;
}
switch (key) {
Expand Down

0 comments on commit a2a96e8

Please sign in to comment.