Upgrade handsontable to 6.2.2 and documentation

This commit is contained in:
Samuel Mendes 2019-03-14 15:28:12 +01:00 committed by Matt Westcott
parent 7402210f35
commit ba78df06bc
5 changed files with 74 additions and 55 deletions

View file

@ -2,7 +2,7 @@
TableBlock
==========
The TableBlock module provides an HTML table block type for StreamField. This module uses `handsontable <https://handsontable.com/>`_ to provide users with the ability to create and edit HTML tables in Wagtail.
The TableBlock module provides an HTML table block type for StreamField. This module uses `handsontable 6.2.2 <https://handsontable.com/>`_ to provide users with the ability to create and edit HTML tables in Wagtail.
.. image:: ../../_static/images/screen40_table_block.png
@ -51,7 +51,19 @@ When defining a TableBlock, Wagtail provides the ability to pass an optional ``t
'startCols': 3,
'colHeaders': False,
'rowHeaders': False,
'contextMenu': True,
'contextMenu': [
'row_above',
'row_below',
'---------',
'col_left',
'col_right',
'---------',
'remove_row',
'remove_col',
'---------',
'undo',
'redo'
],
'editor': 'text',
'stretchH': 'all',
'height': 108,
@ -66,20 +78,20 @@ Configuration Options
Every key in the ``table_options`` dictionary maps to a `handsontable <https://handsontable.com/>`_ option. These settings can be changed to alter the behaviour of tables in Wagtail. The following options are available:
* `minSpareRows <https://docs.handsontable.com/0.24.3/Options.html#minSpareRows>`_ - The number of rows to append to the end of an empty grid. The default setting is 0.
* `startRows <https://docs.handsontable.com/0.24.3/Options.html#startRows>`_ - The default number of rows for a new table.
* `startCols <https://docs.handsontable.com/0.24.3/Options.html#startCols>`_ - The default number of columns for new tables.
* `colHeaders <https://docs.handsontable.com/0.24.3/Options.html#colHeaders>`_ - Can be set to ``True`` or ``False``. This setting designates if new tables should be created with column headers. **Note:** this only sets the behaviour for newly created tables. Page editors can override this by checking the the “Column header” checkbox in the table editor in the Wagtail admin.
* `rowHeaders <https://docs.handsontable.com/0.24.3/Options.html#rowHeaders>`_ - Operates the same as ``colHeaders`` to designate if new tables should be created with the first column as a row header. Just like ``colHeaders`` this option can be overridden by the page editor in the Wagtail admin.
* `contextMenu <https://docs.handsontable.com/0.24.3/Options.html#contextMenu>`_ - Enables or disables the Handsontable right-click menu. By default this is set to ``True``.
* `editor <https://docs.handsontable.com/0.24.3/Options.html#editor>`_ - Defines the editor used for table cells. The default setting is text.
* `stretchH <https://docs.handsontable.com/0.24.3/Options.html#stretchH>`_ - Sets the default horizontal resizing of tables. Options include, 'none', 'last', and 'all'. By default TableBlock uses 'all' for the even resizing of columns.
* `height <https://docs.handsontable.com/0.24.3/Options.html#height>`_ - The default height of the grid. By default TableBlock sets the height to ``108`` for the optimal appearance of new tables in the editor. This is optimized for tables with ``startRows`` set to ``3``. If you change the number of ``startRows`` in the configuration, you might need to change the ``height`` setting to improve the default appearance in the editor.
* `language <https://docs.handsontable.com/0.24.3/Options.html#language>`_ - The default language setting. By default TableBlock tries to get the language from ``django.utils.translation.get_language``. If needed, this setting can be overridden here.
* `renderer <https://docs.handsontable.com/0.24.3/Options.html#renderer>`_ - The default setting Handsontable uses to render the content of table cells.
* `autoColumnSize <https://docs.handsontable.com/0.24.3/Options.html#autoColumnSize>`_ - Enables or disables the ``autoColumnSize`` plugin. The TableBlock default setting is ``False``.
* `minSpareRows <https://handsontable.com/docs/6.2.2/Options.html#minSpareRows>`_ - The number of rows to append to the end of an empty grid. The default setting is 0.
* `startRows <https://handsontable.com/docs/6.2.2/Options.html#startRows>`_ - The default number of rows for a new table.
* `startCols <https://handsontable.com/docs/6.2.2/Options.html#startCols>`_ - The default number of columns for new tables.
* `colHeaders <https://handsontable.com/docs/6.2.2/Options.html#colHeaders>`_ - Can be set to ``True`` or ``False``. This setting designates if new tables should be created with column headers. **Note:** this only sets the behaviour for newly created tables. Page editors can override this by checking the the “Column header” checkbox in the table editor in the Wagtail admin.
* `rowHeaders <https://handsontable.com/docs/6.2.2/Options.html#rowHeaders>`_ - Operates the same as ``colHeaders`` to designate if new tables should be created with the first column as a row header. Just like ``colHeaders`` this option can be overridden by the page editor in the Wagtail admin.
* `contextMenu <https://handsontable.com/docs/6.2.2/Options.html#contextMenu>`_ - Enables or disables the Handsontable right-click menu. By default this is set to ``True``. Alternatively you can provide a list or a dictionary with [specific options](https://handsontable.com/docs/6.2.2/demo-context-menu.html#page-specific).
* `editor <https://handsontable.com/docs/6.2.2/Options.html#editor>`_ - Defines the editor used for table cells. The default setting is text.
* `stretchH <https://handsontable.com/docs/6.2.2/Options.html#stretchH>`_ - Sets the default horizontal resizing of tables. Options include, 'none', 'last', and 'all'. By default TableBlock uses 'all' for the even resizing of columns.
* `height <https://handsontable.com/docs/6.2.2/Options.html#height>`_ - The default height of the grid. By default TableBlock sets the height to ``108`` for the optimal appearance of new tables in the editor. This is optimized for tables with ``startRows`` set to ``3``. If you change the number of ``startRows`` in the configuration, you might need to change the ``height`` setting to improve the default appearance in the editor.
* `language <https://handsontable.com/docs/6.2.2/Options.html#language>`_ - The default language setting. By default TableBlock tries to get the language from ``django.utils.translation.get_language``. If needed, this setting can be overridden here.
* `renderer <https://handsontable.com/docs/6.2.2/Options.html#renderer>`_ - The default setting Handsontable uses to render the content of table cells.
* `autoColumnSize <https://handsontable.com/docs/6.2.2/Options.html#autoColumnSize>`_ - Enables or disables the ``autoColumnSize`` plugin. The TableBlock default setting is ``False``.
A `complete list of handsontable options <https://docs.handsontable.com/0.24.3/Options.html>`_ can be found on the Handsontable website.
A `complete list of handsontable options <https://handsontable.com/docs/6.2.2/Options.html>`_ can be found on the Handsontable website.
Changing the default table_options

View file

@ -113,8 +113,8 @@ class TableBlock(FieldBlock):
@property
def media(self):
return forms.Media(
css={'all': ['table_block/css/vendor/handsontable-6.1.1.full.min.css']},
js=['table_block/js/vendor/handsontable-6.1.1.full.min.js', 'table_block/js/table.js']
css={'all': ['table_block/css/vendor/handsontable-6.2.2.full.min.css']},
js=['table_block/js/vendor/handsontable-6.2.2.full.min.js', 'table_block/js/table.js']
)
def get_table_options(self, table_options=None):
@ -122,7 +122,7 @@ class TableBlock(FieldBlock):
Return a dict of table options using the defaults unless custom options provided
table_options can contain any valid handsontable options:
http://docs.handsontable.com/0.18.0/Options.html
https://handsontable.com/docs/6.2.2/Options.html
contextMenu: if value from table_options is True, still use default
language: if value is not in table_options, attempt to get from envrionment
"""

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long