Class: Inkpen::Extensions::Table
- Defined in:
- lib/inkpen/extensions/table.rb
Overview
Table extension for TipTap.
Enables table functionality including headers, cells, row/column operations, and cell merging. Uses ProseMirror’s table system under the hood.
Constant Summary collapse
- DEFAULT_CELL_MIN_WIDTH =
Default minimum cell width in pixels.
25- DEFAULT_CELL_MAX_WIDTH =
Default maximum cell width in pixels.
500
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#allow_merge? ⇒ Boolean
Whether to allow cell merging.
-
#cell_backgrounds? ⇒ Boolean
Whether to allow cell background colors.
-
#cell_max_width ⇒ Integer?
Maximum cell width in pixels (optional).
-
#cell_min_width ⇒ Integer
Minimum cell width in pixels.
-
#default_cols ⇒ Integer
Default number of columns when inserting a new table.
-
#default_rows ⇒ Integer
Default number of rows when inserting a new table.
-
#header_column? ⇒ Boolean
Whether the first column is treated as a header column.
-
#header_row? ⇒ Boolean
Whether the first row is treated as a header row.
-
#name ⇒ Symbol
The unique name of this extension.
-
#resizable? ⇒ Boolean
Whether table columns can be resized.
-
#to_config ⇒ Hash
Convert to configuration hash for JavaScript.
-
#toolbar? ⇒ Boolean
Whether to show the table toolbar.
-
#with_header_row? ⇒ Boolean
Whether to include headers when inserting a new table.
Methods inherited from Base
#enabled?, #initialize, #to_h, #to_json
Constructor Details
This class inherits a constructor from Inkpen::Extensions::Base
Instance Method Details
#allow_merge? ⇒ Boolean
Whether to allow cell merging.
112 113 114 |
# File 'lib/inkpen/extensions/table.rb', line 112 def allow_merge? .fetch(:allow_merge, true) end |
#cell_backgrounds? ⇒ Boolean
Whether to allow cell background colors.
103 104 105 |
# File 'lib/inkpen/extensions/table.rb', line 103 def cell_backgrounds? .fetch(:cell_backgrounds, true) end |
#cell_max_width ⇒ Integer?
Maximum cell width in pixels (optional).
85 86 87 |
# File 'lib/inkpen/extensions/table.rb', line 85 def cell_max_width [:cell_max_width] end |
#cell_min_width ⇒ Integer
Minimum cell width in pixels.
76 77 78 |
# File 'lib/inkpen/extensions/table.rb', line 76 def cell_min_width .fetch(:cell_min_width, DEFAULT_CELL_MIN_WIDTH) end |
#default_cols ⇒ Integer
Default number of columns when inserting a new table.
130 131 132 |
# File 'lib/inkpen/extensions/table.rb', line 130 def default_cols .fetch(:default_cols, 3) end |
#default_rows ⇒ Integer
Default number of rows when inserting a new table.
121 122 123 |
# File 'lib/inkpen/extensions/table.rb', line 121 def default_rows .fetch(:default_rows, 3) end |
#header_column? ⇒ Boolean
Whether the first column is treated as a header column.
67 68 69 |
# File 'lib/inkpen/extensions/table.rb', line 67 def header_column? .fetch(:header_column, false) end |
#header_row? ⇒ Boolean
Whether the first row is treated as a header row.
58 59 60 |
# File 'lib/inkpen/extensions/table.rb', line 58 def header_row? .fetch(:header_row, true) end |
#name ⇒ Symbol
The unique name of this extension.
40 41 42 |
# File 'lib/inkpen/extensions/table.rb', line 40 def name :table end |
#resizable? ⇒ Boolean
Whether table columns can be resized.
49 50 51 |
# File 'lib/inkpen/extensions/table.rb', line 49 def resizable? .fetch(:resizable, true) end |
#to_config ⇒ Hash
Convert to configuration hash for JavaScript.
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/inkpen/extensions/table.rb', line 148 def to_config { resizable: resizable?, headerRow: header_row?, headerColumn: header_column?, cellMinWidth: cell_min_width, cellMaxWidth: cell_max_width, toolbar: , cellBackgrounds: cell_backgrounds?, allowMerge: allow_merge?, defaultRows: default_rows, defaultCols: default_cols, withHeaderRow: with_header_row? }.compact end |
#toolbar? ⇒ Boolean
Whether to show the table toolbar.
94 95 96 |
# File 'lib/inkpen/extensions/table.rb', line 94 def .fetch(:toolbar, true) end |
#with_header_row? ⇒ Boolean
Whether to include headers when inserting a new table.
139 140 141 |
# File 'lib/inkpen/extensions/table.rb', line 139 def with_header_row? .fetch(:with_header_row, true) end |