New to Kendo UI for Angular? Start a free 30-day trial

Obtain the Cursor Position of the Editor

Environment

ProductProgress® Kendo UI® for Angular Editor

Description

How to obtain the cursor position of the Editor component?

Solution

The Editor view exposes the ProseMirror EditorView instance. It provides access to the current Editor state and selection.

Use the selection $anchor that returns the resolved position if this is a cursor selection, or null otherwise. Then the position can be used to insert a specific HTML element or any other operation that will require the position of the cursor inside the Editor.

The following example demonstrates the Editor cursor position on button click.

Example
View Source
Change Theme:

In this article

Not finding the help you need?