-
Notifications
You must be signed in to change notification settings - Fork 207
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
iframe support #252
Comments
This looks great @bhaskarvk. One key question is what happens when you use it in Rmarkdown's standalone mode. How do the assets of the iframe get handled. Does pandoc inline those as well? |
So here are a few scenarios and how it works. library(leaflet)
library(widgetframe)
l <- leaflet() %>% addTiles() Scenario 1htmltools::saveWidget(frameableWidget(l),'leaflet.html') This will result in a Code: https://github.com/bhaskarvk/widgetframe/blob/master/R/widgetframe.R#L57 Scenario 2w <- frameWidget(l) This creates a new htmlwidget: 'widgetframe'. Scenario 2.1w This prints the widgetframe widget using the Method Code: https://github.com/bhaskarvk/widgetframe/blob/master/R/widgetframe.R#L146 Scenario 2.2saveWidgetframe(w,'leaflet.html') This will result in two files 'leaflet.html' which contains the Parent PymJS init code, and 'leaflet_widget/index.html' which contains the HTML code for the enclosed leaflet widget. Whether both these files are self-contained or not depends on the 'selfcontained' option passed to
Scenario 3Inside an R Markdown document if you have Code: https://github.com/bhaskarvk/widgetframe/blob/master/R/knitr_support.R#L1 We could change this behavior of generating independent parent/child HTMLs to generating a single HTML with the child HTML content passed in the 'srcdoc' attribute of the iframe element. But the only real use case of widgetframes inside R markdowns is inside R Markdown sites and bookdown, because in those two cases the CSS of the site/book interferes with the widget's CSS. And in both these cases there is really no need for a standalone single HTML. Thoughts/Comments? |
I've made some progress and now generate the child widget HTMLs more predictably, and it works fairly well for single R markdown files. I need to test this thoroughly in bookdown and R Markdown websites. No shiny support for now, and I may never support it in Shiny unless there is a convincing use case. |
widgetframe is now on CRAN. |
I know there are already quite a bit of issues/PRs that talk about iframe support.
This is not an issue per se, but request for comment on my new package https://github.com/bhaskarvk/widgetframe.
It allows embedding widgets inside responsive iframes using [PymJS}(http://blog.apps.npr.org/pym.js/).
It's still work in progress and the I'm almost certain the shiny part is not currently working (Not even sure why one would want a widget rendered in an iframe in a shiny env). But it works for embedding widgets inside R markdown / bookdown / CMS / static sites.
You can read the package documentation at https://bhaskarvk.github.io/widgetframe/.
I didn't use
srcdoc
coz I feel keeping the widget code in a separate HTML has certain advantages.My primary use cases were
a) Being able to produce a widget HTML which can be embedded in a responsive iframe of a CMS (blogger/wordpress) or a static HTML site that is built outside of R.
b) Being able to knit widgets in R Markdown sites and bookdown such that their CSS properties are not overridden by the site's global CSS properties.
If possible I would like some input/comments on my package. cc @jcheng5 @timelyportfolio.
The text was updated successfully, but these errors were encountered: