Align a line or a paragraph
Apply paragraph alignment at the current selection through the Formatting service. Alignment belongs to the document block rather than the native toolbar layout.
Use the selection and state APIs when your application provides its own formatting controls.

Use it in your application
Place the caret in the intended paragraph, or select the paragraphs to format, before applying alignment.
Await each operation. In Source mode, only supported source-formatting operations can act on the current literal selection; inspect the result before saving.
Use StateQuery to update an application-owned alignment indicator from the actual current view.
await editor.Formatting.AlignCenterAsync();
bool centered = await editor.StateQuery.IsJustifyCenterAsync();