This page depicts how selections and blocks are managed by the Editor object within iink SDK.

Selection and block objects

Selection and block contents are both subdivisions of the content part:

For the moment, the lasso selection is limited to “Diagram”, “Raw Content” and “Text Document” parts

When the captured strokes representing the lasso are sent to the editor, iink SDK analyzes what they surround to determine a selection. This selection is represented by a ContentSelection object. If you implement the Canvas setDropShadow method, your end-users will get an immediate visual feedback on the selection with a dropshadow added on the selected items.

Listening to the selectionChanged() event lets also you know that some selection changes have occurred and that you can retrieve the corresponding selection by calling getSelection on the editor.

The editor has a set of utility methods to then retrieve information about the current selection, like the blocks included in it or intersecting with it, or the list of possible actions on it. In addition, the API lets you programmatically set a selection.

For the full list of methods and how to use them, please refer to the API documentation.
Package “Text” part “Math” part “Text Document” part 0 1 2 get root block “Text” “Math” “Container”blocks “Math” “Text” get part “Diagram” Blockhierarchy Serialization

When diagram.enable-sub-blocks is set to true in the configuration, “Diagram” blocks contain sub blocks of type “Text”, “Node”, “Edge” or “Polyedge” describing the content of the diagram.

In iink SDK, a content block is represented by a ContentBlock object that inherits from the ContentSelection object.

To reduce the need for use/try-with-resources/close calls on your blocks, you can handle block IDs rather than ContentBlock objects to simplify your AutoCloseable object lifecycle

Operations common to blocks and selections

Some operations are possible at a finer granularity than the part, with either blocks or selections. The following sections list those main operations:

Retrieving possible actions

For an ease of integration, you can interrogate the editor to get the supported format/type/state related to the actions you intend to apply on the selection/block.

For further details, you can refer to the Demo example implementation of selection and block context menus.

Checking a block hierarchy or a selection validity

It is important to note that a block hierarchy or a content selection is only valid at a given point in time. For instance, in the case of a Text Document, inserting new blocks, removing some text using a gesture, are some examples of events that may invalidate the block hierarchy or the content selection you previously retrieved. So, to check an object validity, call its isValid() method. Alternatively, listening to contentChanged() and selectionChanged() events using an IEditorListener on your Editor object will provide hints that your blocks/selection may have become invalid.

Transformation operations

The editor lets you apply geometrical transformations like scaling or translation on selected content. Not all transformations are permitted on any block or selection. So, you can check whether a transformation is allowed with getTransformStatus() before actually applying it with the transform() method.

Other operations

Block specific operations

Any part you create contains a root block. The different blocks form a hierarchy, which root can be obtained by calling the getRootBlock() method on the parent part. Each block, in turn, has a getChildren() method that will return its own children, if any, and a getParent() one that will return its parent.

Block addition

The editor offers methods for adding blocks.

Placeholder block

A placeholder block is designed to provide integrators with a method to utilize the UI features of the iink SDK inside a “RawContent” part to manage content that is not inherently recognized by iink. It is essentially an image that can be accurately positioned and linked with specific metadata. So, this block is defined by its exact position, image, interactivity options, and custom metadata, allowing you to store relevant information within your document.

You should avoid mixing keyboard input with placeholders and converted text, as both will be edited differently

You can use the PlaceholderController object associated to the Editor to add and manipulate placeholders within a “Raw Content” part. The PlaceholderInteractivityOptions object specifies the capabilities for interacting with the placeholder.

Other block operation