A) change initial text (possibly from custom drop-down selection)
B) It automatically goes to edit more, how can I programatically come out of edit more since I will be changing the text programatically
C) Upon coming out of edit mode, it shows context menu. I do not want to show context menu after the text is edited. Only when user clicks on this annotation, I want to show the context menu, like in all other annotations.
I tried following to change initial text, but it did not work
var Tools = this.wvInstance.Tools;
var Annotations = this.wvInstance.Annotations
var freeTextMouseUp = Tools.FreeTextCreateTool.prototype.mouseLeftUp;
Tools.FreeTextCreateTool.initialText = 'REDACTED'
Tools.FreeTextCreateTool.prototype.mouseLeftUp = function() {
if (this.annotation) {
this.text = 'REDACTED'
instance.docViewer.getAnnotationManager().redrawAnnotation(this.annotation);
}
freeTextMouseUp.apply(this, arguments);
}
B)
You can listen to the editorFocus event of editboxManager and in the event callback you can grab the editor element inside the page container and then call the blur method of it. The id of an editor element looks like freetext-editor-${annotation.Id}.
C)
You can listen to the editorBlur event and then use this.wvInstance.annotManager to deselect all the annotaitons.
That did not work as well. The event is not getting triggered even with
this.wvInstance.docViewer.getAnnotationManager().getEditBoxManager().on(‘editorFocused’, (editor, annotation) =>
Also, following has not changed initial text
Tools.FreeTextCreateTool.prototype.initialText = ‘REDACTED’
After more investigation I was actually able to find an API that disables freetext editing, and is probably what you want. Regarding initialText, it seems that the viewer is overwriting the value, so we need to wait for some time before calling it. Here’s the code you can try.