Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/issue 575 data table independent tag #600

Merged
merged 3 commits into from
Jan 17, 2024
Merged
Show file tree
Hide file tree
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
15 changes: 14 additions & 1 deletion src/components/Article/ArticleCellDataTable.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { useEffect } from 'react'
import {
ChevronLeft,
ChevronsLeft,
Expand Down Expand Up @@ -78,6 +78,7 @@ const ArticleCellDataTable = ({
htmlContent = '',
allowFilterColumn = false,
allowSorting = true,
initialPageSize = -1,
}) => {
const { t } = useTranslation()
const [columnFilters, setColumnFilters] = React.useState([])
Expand Down Expand Up @@ -179,6 +180,18 @@ const ArticleCellDataTable = ({
)

console.debug('[ArticleCellDataTable] rendered \n - cellIdx:', cellIdx)
useEffect(() => {
if (initialPageSize === -1) return
console.debug(
'[ArticleCellDataTable] @useEffect \n - cellIdx:',
cellIdx,
'\n - initialPageSize:',
initialPageSize,
)
// get number out of page-size-10
table.setPageSize(Number(initialPageSize.match(/\d+/)[0]))
}, [initialPageSize])

return (
<div className="ArticleCellDataTable">
{/* Pagination */}
Expand Down
12 changes: 10 additions & 2 deletions src/components/Article/ArticleCellFigure.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,12 @@ const ArticleCellFigure = ({
// captions,
// )

const isDataTable = figure.refPrefix === DataTableRefPrefix && cellType === 'markdown'
const isDataTable =
(tags.includes('data-table') || figure.refPrefix === DataTableRefPrefix) &&
cellType === 'markdown'
let dataTableContent = ''
if (isDataTable) {
columnLayout = { md: 10, lg: 11 }
columnLayout = { md: 10, xxl: 11 }

if (htmlOutputs.length > 0) {
dataTableContent = htmlOutputs[0].data['text/html'].join('\n')
Expand Down Expand Up @@ -191,6 +193,12 @@ const ArticleCellFigure = ({
<ArticleCellDataTable
cellType={cellType}
cellIdx={figure.idx}
initialPageSize={
tags.find((d) => {
const m = d.match(/^page-size-(\d+)$/)
return m ? m[1] : false
}) || -1
}
htmlContent={dataTableContent}
/>
) : (
Expand Down