From dddc916082105fe38f9540f1b84f921fe7664a46 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Wed, 21 Mar 2018 22:47:27 +0530 Subject: [PATCH] More actions for comments editor on EM page --- imgsrc/srv/indent.svg | 13 ++++++++ imgsrc/srv/ol.svg | 17 +++++++++++ imgsrc/srv/outdent.svg | 13 ++++++++ imgsrc/srv/ul.svg | 14 +++++++++ src/pyj/book_list/comments_editor.pyj | 43 +++++++++++++++++++++++---- 5 files changed, 94 insertions(+), 6 deletions(-) create mode 100644 imgsrc/srv/indent.svg create mode 100644 imgsrc/srv/ol.svg create mode 100644 imgsrc/srv/outdent.svg create mode 100644 imgsrc/srv/ul.svg diff --git a/imgsrc/srv/indent.svg b/imgsrc/srv/indent.svg new file mode 100644 index 0000000000..436f0207c6 --- /dev/null +++ b/imgsrc/srv/indent.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/imgsrc/srv/ol.svg b/imgsrc/srv/ol.svg new file mode 100644 index 0000000000..7682e0031d --- /dev/null +++ b/imgsrc/srv/ol.svg @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + diff --git a/imgsrc/srv/outdent.svg b/imgsrc/srv/outdent.svg new file mode 100644 index 0000000000..62bbf89ed0 --- /dev/null +++ b/imgsrc/srv/outdent.svg @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/imgsrc/srv/ul.svg b/imgsrc/srv/ul.svg new file mode 100644 index 0000000000..2732745232 --- /dev/null +++ b/imgsrc/srv/ul.svg @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/src/pyj/book_list/comments_editor.pyj b/src/pyj/book_list/comments_editor.pyj index 21ee4d3e81..77af68b34b 100644 --- a/src/pyj/book_list/comments_editor.pyj +++ b/src/pyj/book_list/comments_editor.pyj @@ -130,10 +130,33 @@ def all_editor_actions(): # {{{ choose_block_style(def(cmd): if cmd: editor.exec_command('formatBlock', f'<{cmd}>') - editor.focus() + editor.focus() ) }, - + 'ul': { + 'icon': 'ul', + 'title': _('Unordered list'), + 'execute': def (editor, activated): + editor.exec_command('insertUnorderedList') + }, + 'ol': { + 'icon': 'ol', + 'title': _('Ordered list'), + 'execute': def (editor, activated): + editor.exec_command('insertOrderedList') + }, + 'indent': { + 'icon': 'indent', + 'title': _('Increase indentation'), + 'execute': def (editor, activated): + editor.exec_command('indent') + }, + 'outdent': { + 'icon': 'outdent', + 'title': _('Decrease indentation'), + 'execute': def (editor, activated): + editor.exec_command('outdent') + }, } return all_editor_actions.ans # }}} @@ -308,13 +331,21 @@ def create_comments_editor(container): iframe, editor = create_editor() toolbars = E.div(style='flex-grow: 0') toolbar1 = E.div(class_=TOOLBAR_CLASS) - toolbars.appendChild(toolbar1) + toolbar2 = E.div(class_=TOOLBAR_CLASS) + toolbars.appendChild(toolbar1), toolbars.appendChild(toolbar2) acmap = all_editor_actions() - for ac_name in 'undo redo select-all remove-format | bold italic underline strikethrough | hr superscript subscript format-block'.split(' '): + + def add(toolbar, ac_name): if acmap[ac_name]: - add_action(toolbar1, ac_name, acmap[ac_name], editor.id) + add_action(toolbar, ac_name, acmap[ac_name], editor.id) else: - toolbar1.appendChild(E.div(class_='sep')) + toolbar.appendChild(E.div(class_='sep')) + + for ac_name in 'undo redo select-all remove-format | bold italic underline strikethrough | hr superscript subscript format-block'.split(' '): + add(toolbar1, ac_name) + + for ac_name in 'ul ol indent outdent |'.split(' '): + add(toolbar2, ac_name) container.setAttribute('style', (container.getAttribute('style') or '') + ';display: flex; flex-direction: column; align-items: stretch') container.appendChild(toolbars)