Skip to content

Render check boxes / checklist / todo [$50 awarded] #117

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

Closed
mogoh opened this issue Jul 26, 2017 · 24 comments
Closed

Render check boxes / checklist / todo [$50 awarded] #117

mogoh opened this issue Jul 26, 2017 · 24 comments
Labels
bounty There is a bounty for this issue enhancement New feature or request feature: SimpleMDE Realted to the formerly integrated SimpleMDE editor

Comments

@mogoh
Copy link

mogoh commented Jul 26, 2017

Hello,

can you copy the feature from google keep to add check boxes?

I could imagen it like this: A note contains at the beginning of there lines:
[ ] Lorem
[x] Ipsum

Then it gets rendered as a checkbox. So notes just needs to parse the first 4 Characters of every line.


The $50 bounty on this issue has been claimed at Bountysource.

@stefan-niedermann
Copy link
Member

Then it gets rendered as a checkbox. So notes just needs to parse the first 4 Characters of every line.

will not work if you have checkboxes in a ordered or an unordered (or nested) list

@mogoh
Copy link
Author

mogoh commented Jul 27, 2017

I am not sure if I understand what you mean. As far as I understand, a note is just a text file. What list are you talking about?

@stefan-niedermann
Copy link
Member

stefan-niedermann commented Jul 29, 2017

  • list item 1
  • list item 2
- [ ] list item 1
- [x] list item 2

@mogoh
Copy link
Author

mogoh commented Jul 29, 2017

Well, is it possible to use Github flavored markdown?

@MWin123
Copy link

MWin123 commented Aug 22, 2017

I would appreciate checkbox support like Google Keep has. You click on the "More" button of a note and then "Show checkboxes" which basically starts a list that has checkboxes as icons.

Nextcloud Notes already supports list with - or *. Couldn't we start a list with[ ] or [x] at the beginning of a new line and replace it with a checkbox icon? Then add an onClick that changes the empty to a full checkbox (or the opposite) if that's possible.

will not work if you have checkboxes in a ordered or an unordered (or nested) list

In my opinion you could just ignore cases like that. Nested lists don't work anyway at the moment unless I got the syntax wrong.

That's the feature I'm missing most from Google Keep. It was my favorite app for simple lists like shopping lists.

@korelstar korelstar added the enhancement New feature or request label Sep 24, 2017
@GLLM
Copy link

GLLM commented Oct 24, 2017

+1 for this one ....

I think this one would be on top of my list :)

@jancborchardt jancborchardt added help wanted Complex issue or we don't know how to fix it markdown labels Jun 5, 2018
@jancborchardt jancborchardt added this to the 2.5.0 – 🚀 New nice features milestone Jun 5, 2018
@jancborchardt jancborchardt mentioned this issue Jun 5, 2018
3 tasks
@jancborchardt
Copy link
Member

jancborchardt commented Jun 5, 2018

Yes, this would indeed be nice. We could for example render a browser checkbox over the [ ] brackets which would toggle the x inside.

@jancborchardt jancborchardt changed the title [Request] Add boxes for for checking Render check boxes / checklist / todo Jun 5, 2018
@natrius
Copy link

natrius commented Dec 3, 2018

Any update on this? Something like in github itself would be nice. I found this one

https://blog.github.com/2014-04-28-task-lists-in-all-markdown-documents/

@korelstar
Copy link
Member

No, sorry. That's indeed a nice feature, but nobody had time for implementing, yet. Some help is very appreciated though. On the other hand, it could be advantageous to wait for #204.

@Larsene
Copy link

Larsene commented Dec 5, 2018

#204 : Pen is a great alternative to simpleMDE (support for image, small popup toolbar if you need it), but it doesn't support checkbox either.

@sscholl
Copy link

sscholl commented Dec 18, 2018

+1
Same as on Google keep is appreciated

@korelstar korelstar removed this from the M2 – 🚀 New nice features milestone Dec 21, 2018
@Poikilos
Copy link

Poikilos commented Feb 5, 2019

If the Notes app for Nextcloud implements this feature, then a Nextcloud-based Notes app for Android/iOS could used the feature, and awesome functionality would ensue.

@jospoortvliet jospoortvliet changed the title Render check boxes / checklist / todo Render check boxes / checklist / todo [$50] Feb 5, 2019
@jospoortvliet jospoortvliet added the bounty There is a bounty for this issue label Feb 5, 2019
@pierlon
Copy link
Member

pierlon commented Feb 6, 2019

I'd like to take this on. One issue to note, however. The editor (SimpleMDE) doesn't support checkboxes, so I'm seeing several choices:

  • Extend SimpleMDE to support checkboxes
  • Switch SimpleMDE with another markdown editor that supports checkboxes

I'm not sure which one to make 🤷‍♂️.

@korelstar
Copy link
Member

Nice!

Please be aware that SimpleMDE isn't maintained anymore and we plan to switch to another editor due to this (see #204). Hence, extending SimpleMDE isn't that helpful. I think we should first switch to another editor and at best, that editor supports checkboxes. But if not, it would be nice if you could extend that editor with check boxes.

In the meanwhile, you could help analyzing existing alternative editors. We already collected some in #204, but we still need to test them and compare their functionality.

@tnyeanderson
Copy link
Contributor

tnyeanderson commented Apr 8, 2019

Here we go.... no click functionality yet, but a pure CSS solution that works for list items up to two levels!

Usage

- [ ] List 1
- [x] List 2
    - [ ] List 2.1
        - [ ] This list item will still render as text :(

CSS

.cm-formatting-task {
    position: relative;
    display: inline-block;
    width: 2em;
}

.cm-formatting-task.cm-meta::before {
    content: "\2610";
    font-size: 2em;
    background: white;
    position: absolute;
}

.cm-formatting-task.cm-property::before {
    content: "\2611";
    font-size: 2em;
    background: white;
    position: absolute;
}

Paste it in the inspector-stylesheet to test it out!

JS

Click functionality works now, but codemirror doesn't see it, so the checkbox doesn't reflect the change, and the changes aren't saved :( I have to look into editing the contents of the codemirror instance programatically....

function toggle_checkbox_state (el) {
	var $el = $(el);
	switch ( $el.text() ) {
		case "[x]":
			// CHANGE: Needs to actually edit the text in a way that CodeMirror sees it
			$el.text("[ ]");
			break;
		case "[ ]":
			// CHANGE: Needs to actually edit the text in a way that CodeMirror sees it
			$el.text("[x]");
			break;
	}
}

function initialize_checkboxes () {
	$('.cm-formatting-task').off("click.toggle_checkbox").on("click.toggle_checkbox", function (event) {
		event.stopPropagation();
		event.preventDefault();
		toggle_checkbox_state(event.target)
	});
};

// CHANGE: This is inefficient. Hook into when a new checkbox is created and only initialize that one if possible
setInterval(initialize_checkboxes, 3000);

ANY OF THIS CODE CAN BE USED FOR THE SOLUTION, AND THE BOUNTY WILL BELONG TO THE PERSON/PERSONS WHO IMPLEMENT IT. I RESERVE NO RIGHTS TO THIS CODE.

Let's get this one done :)

P.S. - This will work in EasyMDE too, if we decide to go with that!

EDIT: Formatting and clarification

@tnyeanderson
Copy link
Contributor

Unrelated, but this little bit of CSS increases tabsize to better differentiate list items:

.cm-tab {
    width: 2em;
}

@tnyeanderson
Copy link
Contributor

tnyeanderson commented Apr 12, 2019

Okay, fully working! I'm not familiar with the codebase, and I'm not sure where this code should go, but it will give you fully functioning checkboxes two levels deep... with click functionality!

CSS

.cm-formatting-task {
	position: relative;
	display: inline-block;
	width: 2em;
}

.cm-formatting-task.cm-meta::before {
  content: "\2610";
  font-size: 1.7em;
	background: white;
	position: absolute;
}

.cm-formatting-task.cm-property::before {
  content: "\2611";
	font-size: 1.7em;
	background: white;
	position: absolute;
}

/* Recommended tab size increase for readability */
.cm-tab {
    width: 2em;
}

JS

var cm = $('.CodeMirror')[0].CodeMirror;

function toggle_checkbox_state (el) {
	var $el = $(el);
	var doc = cm.getDoc();
	var index = $el.parents(".CodeMirror-line").index();
	var line = doc.getLineHandle(index);

	var newvalue = ( $el.text() == "[x]" ) ? "[ ]" : "[x]"

	// + 1 for some reason... not sure why
	doc.replaceRange(newvalue, {line: index, ch: line.text.indexOf('[')}, {line: index, ch: line.text.indexOf(']') + 1});

	cm.execCommand("goLineEnd");
}

function initialize_checkboxes () {
	$('.cm-formatting-task').off("click.toggle_checkbox").on("click.toggle_checkbox", function (event) {
		// Prevent double and triple clicks glitching
		$('.cm-formatting-task').off("click.toggle_checkbox");

		event.stopPropagation();
		event.preventDefault();
		
		toggle_checkbox_state(event.target)
	});
};


$(document).ready(function () {
	// Initialize on page load
	initialize_checkboxes();
	// Initialize when CodeMirror fires "changes" event (every time a letter is typed).
	cm.on("changes", initialize_checkboxes);
});

You can test it out in the JS console right now!

Known issues

Bugs

  • Click at the very bottom of a checkbox affects the box below it (Brave/Chrome, Firefox)

Missing

  • Doesn't have the "gray text/crossout line/completed items at bottom" paradigm that Keep has (though I do have some ideas)

EDIT: Again, this should be compatible with EasyMDE should we choose to use that

@iSpeeX
Copy link

iSpeeX commented Apr 15, 2019

Hello, you aklready did a pretty good work, nice mate !
Any news about the implementation ?

@tnyeanderson
Copy link
Contributor

All the features are there now, including mobile support, but I went to fix MORE indentation issues (really gotta figure out what Atom's problem is....) and did them directly through github, so I am not able to sign the commit :( I am at work without access to Git so I'll have to wait until I get home to sign off (unless there's a way to do that through Github)?

@iSpeeX
Copy link

iSpeeX commented Apr 15, 2019

You edited the files directly from GitHub ?
For the rest, I can say only one thing : thank you !

@tnyeanderson
Copy link
Contributor

There was one file that I edited in my last commit, because the indentation was off (don't want to mess up your pretty code!) So yes, I stupidly fixed that directly in Github, and now can't sign off until I get home...

Live and learn! Check back in about 5 hours for the signed commit :)

@korelstar
Copy link
Member

Fixed by @tnyeanderson in #303, thank you very much! Version 2.6.0 with this functionality is just released to the app store.

@tnyeanderson Please feel free to claim the bounty on bountysource

@korelstar korelstar added feature: SimpleMDE Realted to the formerly integrated SimpleMDE editor and removed help wanted Complex issue or we don't know how to fix it markdown labels May 24, 2019
@jospoortvliet jospoortvliet changed the title Render check boxes / checklist / todo [$50] Render check boxes / checklist / todo [$50 awarded] Mar 25, 2020
korelstar added a commit that referenced this issue Apr 24, 2020
* Improved presentation of errors if login (SettingsActivity) or synchronization fails.

* Show icon if a note is not synchronized (hint to a possible error)

* Refactoring: move common code to new private method getNotesRawQuery(String sql, String[] selectionArgs)
New method getLocalModifiedNotes() is a preparation for bugfixing #117

* last part from the previous refactoring

* use material design icon and remove old holo icon

* Refactoring NoteSQLiteOpenHelper and NoteServerSyncHelper in order to fix several bugs belonging concurrency and synchronization. Outstanding: documentation, testing, cosmetic changes

* Show icon if a note is not synchronized (hint to a possible error)

* Refactoring: move common code to new private method getNotesRawQuery(String sql, String[] selectionArgs)
New method getLocalModifiedNotes() is a preparation for bugfixing #117

* last part from the previous refactoring

* use material design icon and remove old holo icon

* Refactoring NoteSQLiteOpenHelper and NoteServerSyncHelper in order to fix several bugs belonging concurrency and synchronization. Outstanding: documentation, testing, cosmetic changes

* only pull remote changes if this was demanded by the caller

* restructure the communication between synchronization task and user interface using callbacks, only try to sync if not offline, otherwise show an error message.

* updateNoteAndSync(): only make database changes, if the content really changed (see #104)

* javadoc and cleanup

* Bugfix for EditNoteActivity: invoke callbacks directly if note wasn't changed in edit (before, callback was never invoked in this case)

* Make sure, that saveDataWithUI is not called, when the previous saveAndSync is still running. In addition, start next saveAndSync not before a small delay has passed.

* rename auto-sync method; adjust DELAYs

* Quick Bugfix: Toast in AsyncTask have to be in onPostExecute

* Bugfix: save edited note in offline mode, too

* Bugfix: Show error message in UI thread

* reduce writes to local storage

* reduce logging

* Refactor: remove recurrent code

* UI enhancement when editing notes (with no changes)
@vpelcak

This comment has been minimized.

@stefan-niedermann

This comment has been minimized.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bounty There is a bounty for this issue enhancement New feature or request feature: SimpleMDE Realted to the formerly integrated SimpleMDE editor
Projects
None yet
Development

No branches or pull requests