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

🎉 Native gdocs tables #2827

Merged
merged 12 commits into from
Nov 1, 2023
Merged

🎉 Native gdocs tables #2827

merged 12 commits into from
Nov 1, 2023

Conversation

ikesau
Copy link
Member

@ikesau ikesau commented Oct 23, 2023

Adds support for tables in our articles via the Gdoc table element.

The template property determines which rows/columns get highlighted in the table. Its possible values are: header-column, header-row, and header-column-row.

This is the Gdoc content for the first table in the preview:

image

The inline table gets parsed and converted into an Archie representation:

{.table}
template: header-row
[.+rows]
    {.table-row}
        [.+cells]
            [.+table-cell]
                Deadhead
            []
            [.+table-cell]
                Danfan
            []
        []
    {}
    {.table-row}
        [.+cells]
            [.+table-cell]
                rectangular granny glasses
            []
            [.+table-cell]
                steely dan t-shirt
            []
        []
    {}
    {.table-row}
        [.+cells]
            [.+table-cell]
                sense of oneness
            []
            [.+table-cell]
                LA Eyeworks clipons
            []
        []
    {}
    {.table-row}
        [.+cells]
            [.+table-cell]
                beat poetry
            []
            [.+table-cell]
                MacMall catalog
            []
        []
    {}
[]
{}

And this then gets parsed as a regular archie component in our rawToEnriched pipeline.

tables

Known remaining work:

  • Fix list parsing
  • Design QA with Marwa

db/model/Gdoc/gdocToArchie.ts Outdated Show resolved Hide resolved
@ikesau ikesau marked this pull request as ready for review October 24, 2023 18:44
@ikesau ikesau requested review from mlbrgl and sophiamersmann and removed request for mlbrgl October 24, 2023 18:44
@larsyencken
Copy link
Contributor

Hey @ikesau, can you add a test article onto the staging server for this for quicker QA?

@danyx23 danyx23 self-requested a review October 31, 2023 08:00
@danyx23
Copy link
Contributor

danyx23 commented Oct 31, 2023

I added the env vars for gdocs to the staging server

http://staging-site-gdocs-table/admin
I'm playing around with this doc (which may at any time be broken :) )
http://staging-site-gdocs-table/admin/gdocs/1ImYJfRy_cXvsRTsI1lYgXmh1vG1mMtvnXWrGuDtrGLw/preview

Copy link
Contributor

@danyx23 danyx23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code and structure look good. When using it I found that any kind of archieml component breaks because apparently the properties are not preserved. Arguably we don't want too many kinds of blocks to appear there anyhow but I think the parsing issue should be resolved.

Of the block content types that we do support, I think lists are pretty likely to be legit and probably images as well. Using gdoc bullet points broke the rendering of the page.

I think once these issues are resolved it should be good to ship from my side.

@ikesau
Copy link
Member Author

ikesau commented Oct 31, 2023

Lists broke? They shouldn't! I'll do some more testing

Thanks 🙂

Copy link
Member

@sophiamersmann sophiamersmann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hello! thanks a lot for recording those videos. I had several aha moments watching it - I worked with gdocs a little bit to make narrative charts work, so I had some understanding of it, but you just really helped me to connect those dots :)

btw, I really appreciate how the types flow through the pipeline. I remember that to be incredibly helpful when I looked into narrative charts!

I focused on the low level stuff, and there is not much from my side:

  • tables don't seem to take up the full width for me (see screenshot below)
  • the scope attribute on th elements should be the other way around, no?

Screenshot:
Screenshot 2023-10-31 at 15 53 39

children: React.ReactNode
}) {
const { tag, scope, children } = props
return React.createElement(tag, { scope }, children)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recently learned that, if you have a custom Tag (must be uppercase), you can also just do <Tag /> which surprised me a bit, but it is possible. obvs no need to change, just a little fun fact :)

@ikesau
Copy link
Member Author

ikesau commented Oct 31, 2023

Thank you @sophiamersmann

I hadn't pushed up the min-width changes on this remote 🤦

Definitely had the scopes the wrong way around. Need to be more vigilant to stop automation blindness with copilot. 😱

@danyx23 the table issue should be fixed now. Usually paragraphToString takes care of closing tables because there's always a new line before the [.body] closing tag, but that wasn't the case inside the table context, so I needed to add a manual check to ensure it gets closed properly before moving onto the next cell.

i.e. we were effectively getting this:

{.table-row}
[.+cells]
[.+table-cell]

[.list]
* one

* two
[]
[]
{}

(A missing [])

And now we properly get

{.table-row}
[.+cells]
[.+table-cell]

[.list]
* one

* two
[]
[]
[]
{}

Copy link
Contributor

@danyx23 danyx23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@ikesau ikesau merged commit 6ba1911 into master Nov 1, 2023
13 checks passed
@ikesau ikesau deleted the gdocs-table branch November 1, 2023 14:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants