Skip to main content
Inspiring
Oct 25, 2023 3:38 PM UTC
Answered

Disable Auto-select when ussing addAnnotation method

Hi,
I want to be able to silently add annotations with out disturbing the user's workflow. Is there a way to not select an annotation when added using the addAnniotation method.

The update and delete methods work how I expect just not the add function.

 

Thanks

This topic is closed to new replies. Start a new post to keep the conversation going.
Andreas23315768po3yCorrect answer
Inspiring
Nov 23, 2023 12:45 PM UTC

Hi,

 

I was wondering about the same thing, but the workaround with adding multiple annotations wasn't really an option for me, since it would pollute the undo history if I added a second annotation and instantly deleted it afterwards.

 

So I looked up the piece of code, that adds the annotations and it turns out, you can actually add a second argument to the addAnnotations method.

 

// silently adds a single annotation
annotationManager.addAnnotations([template], {silent: true});

 

Maybe someone should mention this in the documentation? Or will this be removed in future releases?

3 replies

Andreas23315768po3yCorrect answer
Inspiring
Nov 23, 2023 12:45 PM UTC

Hi,

 

I was wondering about the same thing, but the workaround with adding multiple annotations wasn't really an option for me, since it would pollute the undo history if I added a second annotation and instantly deleted it afterwards.

 

So I looked up the piece of code, that adds the annotations and it turns out, you can actually add a second argument to the addAnnotations method.

 

// silently adds a single annotation
annotationManager.addAnnotations([template], {silent: true});

 

Maybe someone should mention this in the documentation? Or will this be removed in future releases?

Translate
Inspiring
Nov 23, 2023 1:06 PM UTC
Great find! I would love to hear if this will be deprecated also.

I’ve been working on my solution for a bit and found that if you add the
annotation you want to add and a “bad” annotation (like a reply to non
existent comment). It will add the real annotation correctly, throw an
error for the “bad”, and still silently add. I just added some logic to
ignore the error.
Translate
Inspiring
Nov 1, 2023 6:22 PM UTC

For anyone who may come across this in the future, adding multiple annotations in one call of addAnnotations had the behaviour I was looking for.

Translate