recogito / recogito-js

A JavaScript library for text annotation
BSD 3-Clause "New" or "Revised" License
369 stars 43 forks source link

Using Recogito JS with SVGS? #51

Closed SAHellauer closed 3 years ago

SAHellauer commented 3 years ago

Has anyone ever used this library with SVGs? When highlighting elements in an SVG, the highlighted span tag gets added within the element but the text disappears.

<text x="462.4" y="283.6" class="sd_20"><span class="r6o-annotation" data-id="#2a6141ed-da41-485e-975f-c2077b3f667c">Generally </span></text>

I tried changing the <span> tags to <tspan> tags dynamically after creating an annotation but still had the same issue.

rsimon commented 3 years ago

I don't think RecogitoJS could possibly work with SVG. It's generally not possible to insert HTML tags into SVG without breaking the spec. Making it SVG-native, so to speak, would probably be a major undertaking.

FWIW, RecogitoJS works pretty well with PDF rendered with Mozilla's PDF.js library, in case that helps in any way.

SAHellauer commented 3 years ago

@rsimon Thanks for the quick response. I figured that would be the answer but had to ask.