Frontend: Description Edit Hotkeys #2265
No reviewers
Labels
No Label
dependencies
duplicate
help wanted
invalid
kind/bug
kind/feature
needs reproduction
question
security
wontfix
No Milestone
No Assignees
3 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: vikunja/vikunja#2265
Loading…
Reference in New Issue
No description provided.
Delete Branch "Elscrux/vikunja:feature/description-edit-hotkeys"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Adds two new hotkeys which make it much quicker and more intuitive to work with the description.
Double click on the description enters edit mode, and escape discards all current edits and exit edit mode.
Hi Elscrux!
Thank you for creating a PR!
I've deployed the frontend changes of this PR on a preview environment under this URL: https://2265-feature-description-edit-hotkeys--vikunja-frontend-preview.netlify.app
You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somewhere. The easiest to use is https://try.vikunja.io/.
This preview does not contain any changes made to the api, only the frontend.
Have a nice day!
@ -67,6 +67,7 @@
class="tiptap__editor"
:class="{'tiptap__editor-is-edit-enabled': isEditing}"
:editor="editor"
@dblclick="setEditIfApplicable()"
Where is this event defined?
It seems to be a native event, just like @click
@ -461,2 +477,3 @@
bubbleNow()
emit('save', editor.value?.getHTML())
lastSavedState = editor.value?.getHTML() ?? ''
emit('save', lastSavedState)
Why the extra variable?
For example when you type something in the editor, I didn't see anything (other than requesting the backend) to get the state before you typed something. This is what I store in this variable, the unmodified state of the editor which we want to return to when hitting escape and discard all changes.
If there is an easier way to do it, please let me know. I was just trying things out.
I was mainly talking about syntax here. What about inlining the variable like this:
As far as I see, the variable will only ever have the value you set it to here when it is emitted.
Oh, that is because
lastSavedState
is also used in exitEditMode.The save function updates this state and the exit function restores this state.
Okay, but isn't this duplicated then? Couldn't we call
bubbleSave
in that function?No, the idea is that the current edits are discarded and the previous state is returned.
bubbleSave
would save the current edits instead.Ahh gotcha!
The use of a variable instead of a ref here is a bit unsual but I'd say it's fine as long as it works.
Ok :) I wasn't sure how it's done properly, so I'm happy to refactor it if there is a better way to do it.
@ -467,1 +484,4 @@
function exitEditMode() {
editor.value?.commands.setContent(lastSavedState, false)
if (isEditing.value) {
How does this behave when editing a project description? There the editor is not used as a rendering engine, so it should not change the mode to preview.
Currently it changes it back to the preview mode, which is not what it should be.
I'll add an opt-in feature for this, or what do you think should be done for this?
Iirc there are props already controlling if it will allow rendering or editing, maybe use those? (Not on my pc right now, so I'm unable to check this in detail)
There is
isEditEnabled
, but it is enabled by default for something like editing the project description as well.I see that
showSave
is only used by the two editors, for comments and task description which should get this feature. So functionally the discard feature could be baked into this, but I'm not sure if that makes a lot of sense.Good point. Let's add a new prop
previewAfterExit
or something similar and then refactor it later.0c08db9195
to0e6fea95cb
@konrad Let me know if this works :)