You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And everywhere in the following code, only the TextAnnotation is hard-binded
Issue
When a user (me 😅) wants to extend the TextAnnotator with some plugin that might mutate the TextAnnotation with additional properties - I'm pretty much out of luck... Because the TextAnnotator, TextAnnotatorState, are strictly bound to the R6O TextAnnotation type.
The one option is to define the .d.ts file and override the TextAnnotation there. But it creates inconvenient indirectness and maintainers will have questions...
However, another better alternative is to make the TextAnnotator look something like this:
exportinterfaceTextAnnotator<IextendsTextAnnotation=TextAnnotation,Eextendsunknown=TextAnnotation>extendsAnnotator<I,E>{element: HTMLElement;// Returns true if successful (or false if the annotation is not currently rendered)scrollIntoView(annotation: I): boolean;state: TextAnnotatorState<I>;}
In that way - lib consumers can safely describe the extended internal types. And then simply use the typed useAnnotator and useAnnotatorStore hooks
The text was updated successfully, but these errors were encountered:
But I think that using the extends Annotator for the plugin that works with the TextAnnotator won't be a precise type depiction. Because the latter adds new props (element, scrollIntoView, etc.) and overrides some of the lifecycle methods of the store (addAnnotation, getAnnotationBounds, etc.). Unfortunately, the extended Annotator won't have any of those...
Instead, I would like to be able to use the TextAnnotator type directly with a slightly updated internal model. Which cannot be done at the moment 🤷🏻♂️
Current State
Currently, the
TextAnnotator
allows to provide a generic only for the external type:text-annotator-js/packages/text-annotator/src/TextAnnotator.ts
Line 13 in 3f587dd
And everywhere in the following code, only the
TextAnnotation
is hard-bindedIssue
When a user (me 😅) wants to extend the
TextAnnotator
with some plugin that might mutate theTextAnnotation
with additional properties - I'm pretty much out of luck... Because theTextAnnotator
,TextAnnotatorState
, are strictly bound to the R6OTextAnnotation
type.The one option is to define the
.d.ts
file and override theTextAnnotation
there. But it creates inconvenient indirectness and maintainers will have questions...However, another better alternative is to make the
TextAnnotator
look something like this:In that way - lib consumers can safely describe the extended internal types. And then simply use the typed
useAnnotator
anduseAnnotatorStore
hooksThe text was updated successfully, but these errors were encountered: