Namespace: ContentEdit

Core. ContentEdit

The namespace for APIs dealing with document content editing

Extends

Members


<static> Events

Properties:
Name Type Description
TEXT_CONTENT_UPDATED string Core.ContentEdit.textContentUpdated

<static> Types

Content Edit types.
Properties:
Name Type Description
TEXT string Text type content.
OBJECT string Object type content.

Methods


<static> getDocumentContent(contentEditPlaceholderAnnotation)

Gets the content box data for the passed in annotation. The passed in annotation must be a content edit placeholder annotation.
Parameters:
Name Type Description
contentEditPlaceholderAnnotation Core.Annotations.RectangleAnnotation
Returns:
content The document content associated with this content edit placeholder annotation
Type
Promise.<string>
Example
const content = await instance.Core.ContentEdit.getDocumentContent(contentEditPlaceholderAnnotation);

<static> preloadWorker(documentViewer)

Preloads the content editing worker. If this function isn't called then the worker will be loaded when the content editing tool is enabled.
Parameters:
Name Type Description
documentViewer Core.DocumentViewer The DocumentViewer to use as context for the page editing
Returns:
Resolves after the worker has been loaded
Type
Promise.<void>

<static> updateDocumentContent(contentEditPlaceholderAnnotation, content)

Update the document with new content
Parameters:
Name Type Description
contentEditPlaceholderAnnotation Core.Annotations.RectangleAnnotation
content string The new content
Returns:
Resolves after the content has been updated
Type
Promise.<void>
Example
instance.Core.ContentEdit.updateDocumentContent(contentEditPlaceholderAnnotation, 'New content');

addEventListener(type, fn [, options])

Add a handler to the given event name
Parameters:
Name Type Argument Description
type string | number The name of the event to listen to
fn function The handler to be called when the event is triggered
options object <optional>
Optional options object for addEventListener
Properties
Name Type Description
once boolean If true then the handler will be called only once
Returns:
Returns the object that 'addEventListener' is being called on
Type
object
Example
Core.ContentEdit.addEventListener('textContentUpdated', (originalText, updatedText, boundingBoxCoordinates) => {
  ...
});

removeEventListener( [type] [, fn])

Remove a handler of the given event name
Parameters:
Name Type Argument Description
type string | number <optional>
The name of the event to remove the handler of. If type is undefined, all the handlers of the object will be removed
fn function <optional>
The handler associated with this event to be removed. If fn is undefined, all the handlers of the given event name will be removed
Returns:
Returns the object that 'removeEventListener' is being called on
Type
object
Example
Core.ContentEdit.removeEventListener();
Core.ContentEdit.removeEventListener('textContentUpdated');
Core.ContentEdit.removeEventListener('textContentUpdated', fn);

trigger(type [, data])

Calls the handlers of the event name with given data
Parameters:
Name Type Argument Description
type string | number event name of which the handlers will be called.
data * <optional>
data that will be passed to the handlers. If data is an array, it will be spread and then passed to the handlers
Returns:
Returns the object that 'trigger' is being called on
Type
object
Example
Core.ContentEdit.trigger('textContentUpdated', originalText, updatedText, boundingBoxCoordinates);

Events


editBoxesAvailable

Triggered any time edit boxes are drawn on the page.
Parameters:
Name Type Description
boxes object An array of Content Edit boxes.

textContentUpdated

Triggered when text content of the page is updated.
Parameters:
Name Type Description
originalText string The original text of the selected bounding box.
updatedText string The updated text of the selected bounding box.
boundingBoxCoordinates object The coordinates (top, left, bottom, right) of the bounding box.