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

Cannot assign HTML attributes to table in content #146

Closed
trafficonese opened this issue Nov 14, 2023 · 3 comments
Closed

Cannot assign HTML attributes to table in content #146

trafficonese opened this issue Nov 14, 2023 · 3 comments

Comments

@trafficonese
Copy link

In the content I would like to place a bigger table with some custom styling and custom classes. But somehow it always filters out HTML attributes:

Here is an example. The CSS classes for the table, tr and td are not respected.

library(timevis)

dataBasic <- data.frame(
  number = c("Item one", "Item two" ,"Ranged item", "Item four"),
  start   = c("2016-01-10", "2016-01-11", "2016-01-20", "2016-02-14"),
  end    = c(NA, NA, "2016-02-04", NA),
  os = sample(1:5, 4, T),
  cs = sample(1:5, 4, T)
)

dataBasic$content <- sprintf(
  '<table class="lsatimetbl"><tbody>
        <tr><td colspan="2"><em>Number %s</em></td></tr>
        <tr class="specialclass">
          <td class=\'os_%s\'>OS: %s</td>
          <td class="cs_%s">CY: %s</td>
        </tr>
      </tbody></table>',
  dataBasic$number, 
  dataBasic$os, dataBasic$os,
  dataBasic$cs, dataBasic$cs)

dataBasic <- dataBasic[,c("start","end","content")]

timevis(showZoom = FALSE, timezone = NULL) %>%
  timevis::addItems(dataBasic) %>%
  timevis::fitWindow(options = list(animation = TRUE))

@trafficonese
Copy link
Author

This visjs/vis-timeline#846 seems to be the issue..

@trafficonese
Copy link
Author

downgrading to v1.0.0 seems to work.

The template function looks like this with 1.0.0:
function(item)
and the newer timevis versions:
function(item, element, data)

@daattali
Copy link
Owner

Thanks for taking the time to trackd down the cause - you probably saved me an hour of my time. Unfortunately that "security fix" in vis-timeline a few years ago caused several issues, like this one #118

You're right that you can use v1 of the package if you want the older vis-timeline. I was also annoyed by the fact that upgrading caused a few new bugs, and for a while I considered trying to support different version of vis-timeline simultaneously, but I eventually decided against it as it would be a maintenance nightmare. Unfortunately you have to either use an old version that doesn't have all the newest features, or you have to use the newer version that has a few regression bugs.

I'm closing this issue as it seems you know what to do.

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

No branches or pull requests

2 participants