viewer.js icon indicating copy to clipboard operation
viewer.js copied to clipboard

Stability of and documentation for linkclick event

Open spl opened this issue 11 years ago • 6 comments

I discovered the linkclick event here. I would like to use it.

  • Are the linkclick event and the structure of the link data considered stable parts of the API (i.e. unlikely to change)?
  • If so, can you document these?

spl avatar Jun 19 '14 19:06 spl

Nice find! :smile:

It's pretty stable at this point, so I'll add some details about it in the docs.

lakenen avatar Jun 19 '14 19:06 lakenen

Thanks, @lakenen.

spl avatar Jun 19 '14 19:06 spl

Hey @spl, I actually have to take that back. The event object will be changing slightly in the next couple releases. It won't change too much in functionality, but the naming of certain event data and methods will likely change.

How are you planning on using the event?

lakenen avatar Jun 19 '14 19:06 lakenen

I want to track which links are clicked on and capture the metadata (page, target, link text, etc.) upon clicking.

If it's just names that will change, that's fine; we can rename things on upgrading. (It would, of course, help if the changes are mentioned in the release notes. :smile: ) If it's functionality, that may be a different story.

While you're changing things, can you also put the link text in the event data? I didn't see that in my testing.

spl avatar Jun 19 '14 19:06 spl

Adding link text is an interesting problem. Right now, the info.json file only contains hit boxes (this is a limitation of our conversion process at the moment). I could see it being very useful to have that information available, though, so I'll talk to the conversion team and see what we can do! I opened up a separate issue for this (https://github.com/box/viewer.js/issues/65).

There is another issue where links that aren't actually links (e.g., a URL that was never converted to a link) aren't found by the conversion, and thus are not clickable in the viewer. Many PDF viewers will try to be smarter about this and turn them into links if they look like URLs, and I think we could probably do something similar in the conversion process. I created a separate issue for this as well (https://github.com/box/viewer.js/issues/66).

For now, feel free to use the event data that you find in the linkclick event object (e.g., data.uri and data.destination.pagenum), and I'll update this issue when I make changes and finally document the event, and I'll certainly add info about any changes in the release notes.

lakenen avatar Jun 19 '14 19:06 lakenen

Sounds great! Thanks!

spl avatar Jun 19 '14 20:06 spl