-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/editor key events #14
Conversation
Aha, make sense, let me test tomorrow and push updated code. Not sure even if editor is handling new line at the moment, so maybe you right to keep Enter for posting new post/reply. |
The line-break functionality would be good to preserve– it would be ideal if keyboard events of this sort could be handled by a custom tiptap extension or shortcut for consistency, but this works just fine for now. This looks great! thanks for contributing! :) |
src/main/ipc.ts
Outdated
const hours = String(currentDate.getHours()).padStart(2, '0'); | ||
const minutes = String(currentDate.getMinutes()).padStart(2, '0'); | ||
const seconds = String(currentDate.getSeconds()).padStart(2, '0'); | ||
const extension = 'png'; // Replace with the desired file extension |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is the extension always png
in the case of pasting from clipboard?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for pointing out. Fixed that, checking filename and determine which extension is posted:
const file = item.getAsFile();
const fileName = file.name; // Retrieve the filename
const fileExtension = fileName.split('.').pop(); // Extract the file extension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@UdaraJay I also updated the way to handle paste using editorProps and handlePaste instead of useEffect.
@@ -68,6 +68,7 @@ export default function Editor({ | |||
const [isDragging, setIsDragging] = useState(false); | |||
const [isAIResponding, setIsAiResponding] = useState(false); | |||
const [prevDragPos, setPrevDragPos] = useState(0); | |||
const [isActive, setIsActive] = useState(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can use editor.isFocused
instead of managing the active state yourself.
The fileExtension parameter is obtained from the file name of the pasted image using the `file.name` property.
thank you for leading the way, rewrote everything after reading tiptap documentation. handlePaste to handle pasting images and custom extension |
This looks good to go! I'll merge into the next release after some testing. |
Feature/editor key events
This commit adds handle ctrl+Enter (cmd+Enter) in the editor component (handleSubmit function is called) to save new post or reply.
Additionally, when the editor is active and an image is pasted from a buffer (cmd+V), the image file is handled by
attachToPost(attachToPost)
. Related to cmd + V for pasting images from clipboard (#8)