diff --git a/src/TextAnnotator.jsx b/src/TextAnnotator.jsx index 6672bbf..4f7aecd 100644 --- a/src/TextAnnotator.jsx +++ b/src/TextAnnotator.jsx @@ -183,10 +183,11 @@ export default class TextAnnotator extends Component { <> { this.state.selectedAnnotation && { + const applied = props.annotation.clone({ body: [{ ...props.autoApply }]}); + return applied.toAnnotation(); +} + /** * The popup editor component. * @@ -21,6 +26,15 @@ const Editor = props => { if (!currentAnnotation?.isEqual(props.annotation)) setCurrentAnnotation(props.annotation); + + + /** Experimental **/ + if (props.autoApply && props.annotation?.isSelection) + props.onAnnotationCreated(autoApply(props)); + /** Experimental **/ + + + if (element.current) setPosition(props.wrapperEl, element.current, props.bounds); }, [ props.bounds ]); @@ -63,7 +77,7 @@ const Editor = props => { else props.onAnnotationUpdated(undraft(currentAnnotation), props.annotation); } - }; + }; return (