+ <% if items && items[:blocks] && items[:blocks].any? %>
+ <% has_table = items[:blocks].any? { |block| block[:type] == "table" && Array(block[:rows]).any? && block[:table_width].to_i.positive? } %>
+
">
+ <% if has_table %>
+
+
+ <% else %>
+
+
+ <% end %>
<% items[:blocks].each_with_index do |block, idx| %>
<%= render 'plugins/notion/shared/page_block', block: block, index: idx, current_layout: "quadrant", image_height: image_height %>
<% end %>
- <% else %>
+
+ <% else %>
+
<%= render 'plugins/notion/shared/error_section',
title_class: "title title--small",
title_text: "No Content",
description_text: "Check config" %>
- <% end %>
-
+
+ <% end %>
<% end %>
<%= render partial: 'plugins/notion/shared/title_bar', locals: { instance_name: instance_name } %>
diff --git a/lib/notion/views/shared/_page_block.html.erb b/lib/notion/views/shared/_page_block.html.erb
index ed4df8c..899f915 100644
--- a/lib/notion/views/shared/_page_block.html.erb
+++ b/lib/notion/views/shared/_page_block.html.erb
@@ -1,6 +1,8 @@
<% if block[:type] == "divider" %>
-<% elsif ["table_of_contents", "table", "unsupported", "synced_block", "breadcrumb", "column_list"].include?(block[:type]) %>
+<% elsif block[:type] == "table" %>
+ <%= render 'plugins/notion/shared/table', table: block, current_layout: current_layout %>
+<% elsif ["table_of_contents", "unsupported", "synced_block", "breadcrumb", "column_list"].include?(block[:type]) %>
<% return %>
<% else %>
diff --git a/lib/notion/views/shared/_table.html.erb b/lib/notion/views/shared/_table.html.erb
new file mode 100644
index 0000000..b8e6396
--- /dev/null
+++ b/lib/notion/views/shared/_table.html.erb
@@ -0,0 +1,204 @@
+<%
+ layout_limits = {
+ "full" => { rows: 12, columns: 8, lines: 3 },
+ "half_horizontal" => { rows: 6, columns: 8, lines: 2 },
+ "half_vertical" => { rows: 10, columns: 4, lines: 3 },
+ "quadrant" => { rows: 6, columns: 4, lines: 2 }
+ }
+ limits = layout_limits.fetch(current_layout, layout_limits["full"])
+
+ source_rows = Array(table[:rows]).map { |row| Array(row) }
+ source_column_count = table[:table_width].to_i
+ source_column_count = source_rows.map(&:length).max.to_i if source_column_count.zero?
+
+ hidden_column_count = source_column_count > limits[:columns] ? source_column_count - limits[:columns] + 1 : 0
+ visible_source_columns = hidden_column_count.positive? ? limits[:columns] - 1 : source_column_count
+ displayed_column_count = [source_column_count, limits[:columns]].min
+
+ row_results_truncated = table[:has_more_rows] == true
+ needs_row_summary = source_rows.length > limits[:rows] || row_results_truncated
+ visible_source_rows = needs_row_summary ? [limits[:rows] - 1, source_rows.length].min : source_rows.length
+ hidden_row_count = source_rows.length - visible_source_rows
+ hidden_row_label = row_results_truncated ? "+#{[hidden_row_count, 1].max}+ rows" : "+#{hidden_row_count} rows"
+
+ rows = source_rows.first(visible_source_rows).map.with_index do |row, row_index|
+ cells = row.first(visible_source_columns)
+ cells.fill("", cells.length...visible_source_columns)
+ cells << (row_index.zero? ? "+#{hidden_column_count} cols" : "…") if hidden_column_count.positive?
+ cells
+ end
+
+ if needs_row_summary
+ summary_row = Array.new(displayed_column_count, "…")
+ summary_row[0] = hidden_row_label
+ rows << summary_row
+ end
+
+ dense = rows.length > 8 || displayed_column_count > 6
+ line_limit = dense ? [limits[:lines], 2].min : limits[:lines]
+ line_limit = 1 if %w[half_horizontal quadrant].include?(current_layout) && rows.length == limits[:rows]
+%>
+
+<% if rows.any? && displayed_column_count.positive? %>
+
+
+ <% has_column_header = table[:has_column_header] && visible_source_rows.positive? %>
+
+
"
+ aria-rowcount="<%= source_rows.length %>"
+ aria-colcount="<%= source_column_count %>"
+ style="--notion-table-columns: <%= displayed_column_count %>; --notion-table-rows: <%= rows.length %>;">
+ <% rows.each_with_index do |row, row_index| %>
+ <% if has_column_header && row_index.zero? %><% elsif row_index == (has_column_header ? 1 : 0) %><% end %>
+
+ <% row.each_with_index do |cell, column_index| %>
+ <% summary = (needs_row_summary && row_index == rows.length - 1) || (hidden_column_count.positive? && column_index == row.length - 1) %>
+ <% header = (has_column_header && row_index.zero?) || (table[:has_row_header] && column_index.zero?) %>
+ <% important = !summary && cell.to_s.lines.any? { |line| line.lstrip.start_with?("!") } %>
+ <% cell_classes = ["notion-table__cell"] %>
+ <% cell_classes << "notion-table__cell--header" if header %>
+ <% cell_classes << "notion-table__cell--summary" if summary %>
+ <% cell_classes << "notion-table__cell--important" if important %>
+ <% tag_name = header ? "th" : "td" %>
+ <<%= tag_name %> class="<%= cell_classes.join(" ") %>"<% if header %> scope="<%= has_column_header && row_index.zero? ? "col" : "row" %>"<% end %>>
+ <%= cell %>
+ <%= tag_name %>>
+ <% end %>
+
+ <% if has_column_header && row_index.zero? %><% end %>
+ <% end %>
+ <% if rows.length > (has_column_header ? 1 : 0) %><% end %>
+
+
+<% end %>