InsertRtfCommand.execute(rtfText, position) Method
Executes the InsertRtfCommand command by applying the specified settings.
May result in taking no action if the command’s state does not allow command execution. Use the object’s getState method to check the command state.
Declaration
execute(
rtfText: string,
position: number,
subDocumentId?: number,
callback?: (arg1: Interval,
arg2: boolean) => void
): boolean
Parameters
Name | Type | Description |
---|---|---|
rtfText | string | A string representing the RTF formatted content to insert. |
position | number | A value specifying the position to insert in the specified sub-document. |
subDocumentId | number | A value identifying the target sub-document. |
callback | (arg1: Interval, arg2: boolean) => void | A callback function that passes the inserted content’s Interval object and the bool parameter that displays whether the RTF formatted string is valid. |
Returns
Type | Description |
---|---|
boolean | A Boolean value identifying whether method execution was successful or failed. |
Remarks
The execute method checks the command state (obtained using the getState method) before executing, and decides whether the action can be performed.
Usage example:
var insertPosition = 2;
var subDocumentId = richEdit.document.mainSubDocument.id;
var callbackFunc = function (interval, isRtfValid) {}
richEdit.commands.insertRtf.execute(RTFstring, insertPosition, subDocumentId, callbackFunc);