-
Notifications
You must be signed in to change notification settings - Fork 134
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/858/checkboxtoggle #861
Conversation
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
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.
Thanks for this PR! I really like it! Here are some remarks for improving it:
- Changing a checkbox only works once for me. After that, any other change is done visually, but not in the note. I have to reload to proceed.
- Please respect the read-only attribute. The checkboxes should not be editable if read-only mode is active.
- Could you please change the mouse cursor? Currently it is text selection, but I think it should be the default pointer.
- Would it be possible to use the same checkbox design like in edit mode?
Yes, but no. :D I have already changed the checkbox design in #790 to use rounded corners, so that the editor matches the preview. If you dont object, i would like to do it that way: |
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
How do i test the read-only attribute? I have passed it just like the editor so it 'should' be fine, but i have never encountered a read only note. Are those shared from other people? |
use regex for checking if todo Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
So, i fixed the single click only bug. Sadly i had to introduce a timeout function so that the v-html can render and the new content is actually found with the checkboxes. If you have a better idea please tell me. Also i found a very strange bug, but i think this is the issue with MarkdownIT.
This note will have 2 checkboxes, as expected, but the label of the second one extends to a second line. Can you confirm this behaviour on your end? |
src/components/EditorMarkdownIt.vue
Outdated
if (target.checked) { | ||
returnValue = returnValue.replace('[ ]', '[x]') | ||
returnValue = returnValue.replace('[\u00A0]', '[x]') | ||
} else { | ||
returnValue = returnValue.replace('[x]', '[ ]') | ||
returnValue = returnValue.replace('[X]', '[ ]') | ||
} |
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.
This does not work correctly if there is a [ ]
or [x]
in the item's text, e.g. - [x] this is an example [x] with checkbox
. In this case, the text is also changed. In order to fix this, it must be assured, that only a single replace is done.
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.
As far as i know the .replace() function only replaces the first occurence, when no regex is used. Even if a regex is applied, when the global-flag is missing it will also only chamge the first occurence. So this should be fine, did your test yield different results?
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.
Please try my example. It doesn't work correctly. But I did not found out why.
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.
It works just fine for me, have you cleared the cache? (I had problems when the developer console wasnt open, it was using some broken hybrid version from cache)
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.
It only has the behaviour you describe if we have both an uppercase and a lowercase X in the line. I will have to fix this particular issue though.
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.
I've found out that it happens on sub-items only, see the following example:
- [ ] check [ ] box (works)
- [ ] sub check [ ] box (does not work)
- [ ] check [ ] box (works)
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.
- check [ ] box (works)
- sub check [ ] box (does not work)
- check [ ] box (works)
I also cannot reproduce this. Is the sub-element supposed to be indented? Because on my build it behaves identical to the other two (including the checkbox behaviour)
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.
Co-authored-by: korelstar <korelstar@users.noreply.github.com>
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
I think it's fine, for now.
Yes, I can reproduce this. But I agree that this is caused by |
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.
How do i test the read-only attribute? I have passed it just like the editor so it 'should' be fine, but i have never encountered a read only note. Are those shared from other people?
Yes, that's the typical use case. But you could test this also by manually removing write permission to the note's file directly on the file system.
I've added a code change suggestion in order to improve this case: The checkboxes should be disabled if and only if the note is read-only.
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
Signed-off-by: Felix Nüsse <felix.nuesse@t-online.de>
@newhinton What's the state of this PR? As far as I can see, there is only one bug left: the issue with the sub-items (see #861 (comment)). Any ideas on how to fix this? |
Okay, I found a fix. It was because clicking on a sub-item triggers an event for the sub-item AND for the parent item. I had to stop event propagation. |
fixes #858