https://github.com/leo-editor/snippets/blob/master/rich_text_editor.py

paste the above (click the Raw button) into a node and run it (Ctrl-B).

Then you can Alt-X rich-text-open to switch to rich text mode (that
command could be bound to a key in @settings, there's also
rich-text-close).

Rich text is stored in the body as HTML, so once you edit a node in
rich text mode, it's hard to edit / view it in normal mode (although
the view render pane will render the HTML nicely).

Whenever you edit the rich text, you have to save the changes when
selecting another node, by:
  - pressing Ctrl-Enter before selecting another node
  - saying yes when it asks, as it does if you select another
    node without saving
  - checking the Auto checkbox, which saves automatically when you
    select another node

You can automate the running of the code by including it in a @script
node (with @setting @bool scripting-at-script-nodes = True), but I
guess it should be packaged as a plugin for convenience.

There are supposed to be shortcuts for the styles:
            ['Clr', 'clear', QtConst.Key_Space],
            ['B', 'bold', QtConst.Key_B],
            ['I', 'italic', QtConst.Key_I],
            ['U', 'underline', QtConst.Key_U],
            ['---', 'strikeout', QtConst.Key_Underscore],
            ['FG', 'foreground', None],
            ['BG', 'background', None],
            ['+', 'larger', QtConst.Key_Plus],
            ['-', 'smaller', QtConst.Key_Minus],
but Leo's key handling eats some of them.  The shortcut is the key
above + Ctrl.

The intent would be to not expand the functionality of this editor much
beyond the above, except perhaps for the addition of a pulldown list of
named styles (Heading 1 etc.).

If we want a full featured rich text editor, we could look at the
WebKit CKEditor approach.

Cheers -Terry

-- 
You received this message because you are subscribed to the Google Groups 
"leo-editor" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/leo-editor.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to