From 352fa37dda52ffd924b449675ea6c06482d851ad Mon Sep 17 00:00:00 2001 From: Samuel Mendes Date: Thu, 14 Mar 2019 16:29:17 +0100 Subject: [PATCH] Add documentation on supporting cell alignment --- docs/reference/contrib/table_block.rst | 37 +++++++++++++++++++ .../static/table_block/js/table.js | 1 - 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/docs/reference/contrib/table_block.rst b/docs/reference/contrib/table_block.rst index decb066d6c..01a241c96a 100644 --- a/docs/reference/contrib/table_block.rst +++ b/docs/reference/contrib/table_block.rst @@ -119,3 +119,40 @@ To change the default table options just pass a new table_options dictionary whe class DemoStreamBlock(StreamBlock): ... table = TableBlock(table_options=new_table_options) + + +Supporting cell alignement +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +You can activate the `alignment` option by setting a custom `contextMenu` which allows you to set the alignment on a cell selection. +HTML classes set by handsontable will be kept on the rendered block. You'll be then able to apply your own custom CSS rules to preserve the style. Those class names are: + + * Horizontal: ``htLeft``, ``htCenter``, ``htRight``, ``htJustify`` + * Vertical: ``htTop``, ``htMiddle``, ``htBottom`` + + .. code-block:: python + + new_table_options = { + 'contextMenu': [ + 'row_above', + 'row_below', + '---------', + 'col_left', + 'col_right', + '---------', + 'remove_row', + 'remove_col', + '---------', + 'undo', + 'redo', + '---------', + 'copy', + 'cut' + '---------', + 'alignment', + ], + } + + class DemoStreamBlock(StreamBlock): + ... + table = TableBlock(table_options=new_table_options) diff --git a/wagtail/contrib/table_block/static/table_block/js/table.js b/wagtail/contrib/table_block/static/table_block/js/table.js index d53568bc91..b98cb1da42 100644 --- a/wagtail/contrib/table_block/static/table_block/js/table.js +++ b/wagtail/contrib/table_block/static/table_block/js/table.js @@ -80,7 +80,6 @@ function initTable(id, tableOptions) { }); } } - console.log(cellsClassnames); return cellsClassnames; };