From c2a92ad67865057c25a54fe571cec3ffe267d787 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Thu, 22 Mar 2018 09:31:17 +0530 Subject: [PATCH] Justification actions for comments editor on EM page --- imgsrc/srv/justify-center.svg | 5 ++++ imgsrc/srv/justify-full.svg | 5 ++++ imgsrc/srv/justify-left.svg | 5 ++++ imgsrc/srv/justify-right.svg | 5 ++++ src/pyj/book_list/comments_editor.pyj | 36 +++++++++++++++++++++++---- 5 files changed, 51 insertions(+), 5 deletions(-) create mode 100644 imgsrc/srv/justify-center.svg create mode 100644 imgsrc/srv/justify-full.svg create mode 100644 imgsrc/srv/justify-left.svg create mode 100644 imgsrc/srv/justify-right.svg diff --git a/imgsrc/srv/justify-center.svg b/imgsrc/srv/justify-center.svg new file mode 100644 index 0000000000..2c20067e30 --- /dev/null +++ b/imgsrc/srv/justify-center.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/imgsrc/srv/justify-full.svg b/imgsrc/srv/justify-full.svg new file mode 100644 index 0000000000..5a4ac2e460 --- /dev/null +++ b/imgsrc/srv/justify-full.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/imgsrc/srv/justify-left.svg b/imgsrc/srv/justify-left.svg new file mode 100644 index 0000000000..78039f2b45 --- /dev/null +++ b/imgsrc/srv/justify-left.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/imgsrc/srv/justify-right.svg b/imgsrc/srv/justify-right.svg new file mode 100644 index 0000000000..713a1c9bad --- /dev/null +++ b/imgsrc/srv/justify-right.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/pyj/book_list/comments_editor.pyj b/src/pyj/book_list/comments_editor.pyj index 77af68b34b..99afc3d1c3 100644 --- a/src/pyj/book_list/comments_editor.pyj +++ b/src/pyj/book_list/comments_editor.pyj @@ -157,6 +157,31 @@ def all_editor_actions(): # {{{ 'execute': def (editor, activated): editor.exec_command('outdent') }, + 'justify-left': { + 'icon': 'justify-left', + 'title': _('Align left'), + 'execute': def (editor, activated): + editor.exec_command('justifyLeft') + }, + 'justify-full': { + 'icon': 'justify-full', + 'title': _('Align justified'), + 'execute': def (editor, activated): + editor.exec_command('justifyFull') + }, + 'justify-center': { + 'icon': 'justify-center', + 'title': _('Align center'), + 'execute': def (editor, activated): + editor.exec_command('justifyCenter') + }, + 'justify-right': { + 'icon': 'justify-right', + 'title': _('Align right'), + 'execute': def (editor, activated): + editor.exec_command('justifyRight') + }, + } return all_editor_actions.ans # }}} @@ -336,15 +361,16 @@ def create_comments_editor(container): acmap = all_editor_actions() def add(toolbar, ac_name): - if acmap[ac_name]: - add_action(toolbar, ac_name, acmap[ac_name], editor.id) - else: - toolbar.appendChild(E.div(class_='sep')) + if ac_name: + if acmap[ac_name]: + add_action(toolbar, ac_name, acmap[ac_name], editor.id) + else: + 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(' '): + for ac_name in 'ul ol indent outdent | justify-left justify-center justify-right justify-full |'.split(' '): add(toolbar2, ac_name) container.setAttribute('style', (container.getAttribute('style') or '') + ';display: flex; flex-direction: column; align-items: stretch')