nuttyartist / notes

Fast and beautiful note-taking app written in C++. Write down your thoughts.
https://www.get-notes.com
Mozilla Public License 2.0
3.68k stars 319 forks source link

Revamp editor - Active widgets in QTextEdit #560

Open nuttyartist opened 1 year ago

nuttyartist commented 1 year ago

This issue is part of #317.

Active widgets in QTextEdit

Say we want to add checkboxes (QCheckBox), images, or any other custom or non custom widgets, we'll need to implement support for active widgets inside QTextEdit.

Proof-of-concept

First proof-of-concept was done in PyQt here: http://blog.rfox.eu/en/Programming/Python/Active_widget_in_PyQT5_-_QTextEdit.html. I asked GPT-4 to convert the code to C++, but its output didn't work well. Then, @bjorn took the code and made it work, thus creating the proof-of-concept: https://gist.github.com/bjorn/35a8b1290731d1f82dd7ddbb5d81272c

This will require quite a bit of work. We'll need to support

  1. Back Ctrl + z / forward Ctrl + y
  2. Drag and drop.
  3. Copying the editor content should copy the underline markdown. So, selecting and copying CheckBox and some text should result in - [ ] and some text

It will work by the editor rendering whatever markdown is written. It should be done like Bear's Panda (https://bear.app/alpha/) here:

test

Since all we're doing is just rendering the underline markdown, nothing much changes in the way notes are represented in the database.