DS Server

Javascript: Selection.changeDirection Method

Method|Introduced in 24.0

Description

Changes the writing direction of all selected paragraphs. When the direction of a paragraph is changed, this paragraph's alignment is toggled from left to right or from right to left. The alignment of centered and justified paragraphs is not changed. Left and right tabulators are also toggled.

Syntax

<void> Selection.changeDirection(<Direction> direction, [<EmptyRequestCallback> callback], [<ErrorCallback> errorCallback])

Parameters

ParameterDescription
direction

Specifies the new writing direction of the selected paragraphs.

callback

Optional. Is called when the operation completed.

errorCallback

Optional. Is called when the operation failed with an error.

Examples

The following example demonstrates Selection.changeDirection in a practical document-editing workflow. It changes the writing direction of all selected paragraphs. When the direction of a paragraph is changed, this paragraph's alignment is toggled from left to right or from right to left. The alignment of centered and justified paragraphs is not changed. Left and right tabulators are also toggled.

function onTxError(error) {
    console.error("TX Text Control error:", error.msg);
    error.handled = true;
}

TXTextControl.selection.changeDirection(
    TXTextControl.Direction.LeftToRight,
    function() {
        console.log("change direction completed.");
    },
    onTxError
);