wildcard
wildcard copied to clipboard
Initial stub: DOM formulas
This is a PR to serve as an initial demonstration of how we might put DOM elements in table cells in Wildcard. Not meant as a full implementation yet.
Code changes
It's a pretty minimal code change. Here's the overview.
There's a DOM Scraping Base adapter that's responsible for returning data from the page to the main WC system.
Previously, if the user-provided scraping code returned a DOM element, the Scraping Base adapter would extract the text contents and return that to WC as the cell value. Now, instead, we just return the DOM element directly.
We then have to deal with that new type of value downstream in the UI layer. Currently, here's what we do:
- for the table, extract and display text content
- for the formula bar, extract the outerHTML and display that
- add a little decoration to the column header
I've also added a new attribute type "element" to reflect the fact that a scraper can return an element directly.
Open questions
In general we need to consider a holistic UX that makes sense to users. Some specific questions:
- Should "element" be a distinct datatype like "text" or "number"? Or should it live alongside those datatypes -- i.e., I can specify that this is a number column, but it also includes an underlying DOM element
- Relatedly -- should DOM elements live in separate cells from their displayed output, or show up together as one cell? In this version they're combined into one because the text output shows up on the DOM element cell directly
- What other formulas to add?