Skip to content

Commit

Permalink
feat: minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nevo-david committed Jan 6, 2025
1 parent 42f1f07 commit 0ac7d52
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 22 deletions.
9 changes: 8 additions & 1 deletion apps/frontend/src/components/launches/add.edit.model.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const AddEditModal: FC<{
const [customer, setCustomer] = useState('');
const [loading, setLoading] = useState(false);
const [uploading, setUploading] = useState(false);
const [canUseClose, setCanUseClose] = useState(true);

// selected integrations to allow edit
const [selectedIntegrations, setSelectedIntegrations] = useStateCallback<
Expand Down Expand Up @@ -251,6 +252,10 @@ export const AddEditModal: FC<{

// override the close modal to ask the user if he is sure to close
const askClose = useCallback(async () => {
if (!canUseClose) {
return;
}

if (
await deleteDialog(
'Are you sure you want to close this modal? (all data will be lost)',
Expand All @@ -259,7 +264,7 @@ export const AddEditModal: FC<{
) {
modal.closeAll();
}
}, []);
}, [canUseClose]);

// sometimes it's easier to click escape to close
useKeypress('Escape', askClose);
Expand Down Expand Up @@ -644,6 +649,8 @@ export const AddEditModal: FC<{
value={p.image}
name="image"
onChange={changeImage(index)}
onOpen={() => setCanUseClose(false)}
onClose={() => setCanUseClose(true)}
/>
</div>
<div className="flex bg-customColor20 rounded-br-[8px] text-customColor19">
Expand Down
14 changes: 9 additions & 5 deletions apps/frontend/src/components/launches/bold.text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,25 @@ const originalMap = {
'0': '𝟬',
};

const reverseMap = Object.fromEntries(
Object.entries(originalMap).map(([key, value]) => [value, key])
);

export const BoldText: FC<{ editor: any; currentValue: string }> = ({
editor,
}) => {
const mark = () => {
const selectedText = Editor.string(editor, editor.selection);

const newText = (
const newText = Array.from(
!selectedText ? prompt('What do you want to write?') || '' : selectedText
)
.split('')
// @ts-ignore
.map((char) => originalMap?.[char] || char)
.map((char) => {
// @ts-ignore
return originalMap?.[char] || reverseMap?.[char] || char;
})
.join('');


Transforms.insertText(editor, newText);
ReactEditor.focus(editor);
};
Expand Down
6 changes: 4 additions & 2 deletions apps/frontend/src/components/launches/editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,10 @@ export const Editor = forwardRef<

const addText = useCallback(
(emoji: string) => {
// @ts-ignore
Transforms.insertText(newRef?.current?.editor!, emoji);
setTimeout(() => {
// @ts-ignore
Transforms.insertText(newRef?.current?.editor!, emoji);
}, 10);
},
[props.value, id]
);
Expand Down
22 changes: 16 additions & 6 deletions apps/frontend/src/components/launches/u.text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,25 @@ const underlineMap = {
'9': '9̲',
'0': '0̲',
};

const reverseMap = Object.fromEntries(
Object.entries(underlineMap).map(([key, value]) => [value, key])
);

export const UText: FC<{ editor: any; currentValue: string }> = ({
editor,
}) => {
const mark = () => {
const selectedText = Editor.string(editor, editor.selection);

const newText = (
!selectedText ? prompt('What do you want to write?') || '' : selectedText
const setUnderline = selectedText.indexOf('̲') === -1;
const newText = Array.from(
!selectedText ? prompt('What do you want to write?') || '' : selectedText.replace(/̲/g, '')
)
.split('')
// @ts-ignore
.map((char) => underlineMap?.[char] || char)
.map((char) => {
// @ts-ignore
return (setUnderline ? underlineMap?.[char] : reverseMap?.[char]) || char;
})
.join('');

Transforms.insertText(editor, newText);
Expand All @@ -101,7 +108,10 @@ export const UText: FC<{ editor: any; currentValue: string }> = ({
d="M10.4119 6.47V12.77C10.4119 13.4 10.5669 13.885 10.8769 14.225C11.1869 14.565 11.6419 14.735 12.2419 14.735C12.8419 14.735 13.3019 14.565 13.6219 14.225C13.9419 13.885 14.1019 13.4 14.1019 12.77V6.47H16.6669V12.755C16.6669 13.695 16.4669 14.49 16.0669 15.14C15.6669 15.79 15.1269 16.28 14.4469 16.61C13.7769 16.94 13.0269 17.105 12.1969 17.105C11.3669 17.105 10.6219 16.945 9.96191 16.625C9.31191 16.295 8.79691 15.805 8.41691 15.155C8.03691 14.495 7.84691 13.695 7.84691 12.755V6.47H10.4119Z"
fill="currentColor"
/>
<path d="M6.96191 18.5H17.5369V19.25H6.96191V18.5Z" fill="currentColor" />
<path
d="M6.96191 18.5H17.5369V19.25H6.96191V18.5Z"
fill="currentColor"
/>
</g>
<defs>
<clipPath id="clip0_31_12620">
Expand Down
10 changes: 4 additions & 6 deletions apps/frontend/src/components/layout/click.outside.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,11 @@ export const useClickOutside = (callback: () => Promise<void>) => {
const selector = document.querySelector('#add-edit-modal');
const copilotkit = document.querySelector('.copilotKitPopup');
const emoji = document.querySelector('.EmojiPickerReact');

if (
selector &&
!selector.contains(event.target as HTMLElement) &&
copilotkit &&
!copilotkit.contains(event.target as HTMLElement) &&
emoji &&
!emoji.contains(event.target as HTMLElement)
!selector?.contains(event.target as HTMLElement) &&
!copilotkit?.contains(event.target as HTMLElement) &&
!emoji
) {
callback();
}
Expand Down
21 changes: 19 additions & 2 deletions apps/frontend/src/components/media/media.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -439,11 +439,21 @@ export const MultiMediaComponent: FC<{
text: string;
name: string;
error?: any;
onOpen?: () => void;
onClose?: () => void;
onChange: (event: {
target: { name: string; value?: Array<{ id: string; path: string }> };
}) => void;
}> = (props) => {
const { name, label, error, text, description, onChange, value } = props;
const {
onOpen,
onClose,
name,
error,
text,
onChange,
value,
} = props;
const user = useUser();

useEffect(() => {
Expand All @@ -469,10 +479,16 @@ export const MultiMediaComponent: FC<{
);

const showModal = useCallback(() => {
if (!modal) {
onOpen?.();
} else {
onClose?.();
}
setShowModal(!modal);
}, [modal]);
}, [modal, onOpen, onClose]);

const closeDesignModal = useCallback(() => {
onClose?.();
setMediaModal(false);
}, [modal]);

Expand All @@ -486,6 +502,7 @@ export const MultiMediaComponent: FC<{
);

const designMedia = useCallback(() => {
onOpen?.();
setMediaModal(true);
}, []);

Expand Down

0 comments on commit 0ac7d52

Please sign in to comment.