Status | Assigned | Task | ||
---|---|---|---|---|
Open | None | T6384 A better text editor for the composer | ||
Resolved | cmollekopf | T6967 html mail composer |
Note that we can't use TextEdit.textDocument to modify the content: https://doc.qt.io/qt-5/qquicktextdocument.html
That's how to do it probably:
http://doc.qt.io/qt-5/qtquickcontrols-texteditor-example.html
The TextEdit is of course entirely unsuitable for an HTML editor. It literally just listens for a textchange and then copies whatever format it finds (https://code.woboq.org/qt5/qtdeclarative/src/quick/items/qquicktextcontrol.cpp.html#273), which means the only way to change the format is to insert some text, which of course falls flat on it's face if you try to e.g. toggle bold and then continue writing without selecting something first.
The only proper way would be if we could get a hold of the internal cursor and set it's text formatting. But of course we cant.
Options we have:
- Try to use the TextEdit read-only and insert all text via our own cursor (this could actually lead to something useful). This means we'll have to capture all keyboard input and somehow deal with the cursor position.
- Try some unknown hack to make this work.
- Somehow implement an html editor in a webview
- implement an editor component from scratch.
The format caching approach works somewhat, but unfortunately unreliably. The html composer is hidden until this is resolved.
WebEngineView gained support for editing with Qt 5.10, see WebEngineView.InsertOrderedList and related. This may or may not be an easier way to create a somewhat fully featured html composer.
We'll stick to 5.9 for now. I just stumbled over this and we'll have to evaluate what the best approach is when we improve the editor. So this was just a note, not a concrete plan.
We already have a basic editor and support for lists is doable on top of what we have.