Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions lib/editor_js/blocks/table_block.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ def schema
type: object
additionalProperties: false
properties:
withHeadings:
type: boolean
content:
type: array
items:
Expand All @@ -21,15 +23,20 @@ def schema
def render(_options = {})
content_tag(:div, class: css_name) do
content_tag(:table) do
data['content'].map do |row|
data['content'].map.with_index do |row, row_index|
col_tag = with_headings? && row_index.zero? ? :th : :td
content_tag(:tr) do
row.map { |col| content_tag :td, col.html_safe }.join().html_safe
row.map { |c| content_tag(col_tag, c.html_safe) }.join.html_safe
end
end.join().html_safe
end.join.html_safe
end
end
end

def with_headings?
!!data['withHeadings']
end

def safe_tags
{
'b' => nil,
Expand Down