iink SDK on Device

Answered

Is it possible to add a formatted text block?

 I am trying to create a new Text block with formatted text. I tried doing so by setting the MimeType to HTML and using a HTML string for the content of the block. However I got the error "java.lang.IllegalStateException: unsupported mime type Text". 

This is an example of what I tried:

String htmlText = "<p style=\"color:rgb(255,0,0);\">Red</p>";
editor.addBlock(0, 0, "Text", MimeType.HTML, htmlText);

Am I doing something wrong? Or is only basic text supported when creating a Text part? Is there any other way to create a Text block with formatted text?

Thanks!


Best Answer

Dear Nicolas,


thank you for contacting us.


Currently, the reason is that only "Text" MimeType can be added when adding a Text block. You can call the following function: getSupportedAddBlockDataMimeTypes("Text");


Best regards,


Olivier


Answer

Dear Nicolas,


thank you for contacting us.


Currently, the reason is that only "Text" MimeType can be added when adding a Text block. You can call the following function: getSupportedAddBlockDataMimeTypes("Text");


Best regards,


Olivier


1 person likes this

Dear Nicolas,


At present, the styling is rather limited in our iink SDK, and it is not possible to change only a portion of text or block.


Best regards,


Olivier


1 person likes this

Thank you Olivier.

Does this mean that it is not possible to create a Text Block with formatted text?

We are trying to add keyboard support and would like to be able to restore the text formatting if, for example, the user taps an existing block and adds some text to it with the keyboard. We have styles with colors in the app so the initial block might contain text with letters in various colors. But as it is now, if the user wants to add to this text using the keyboard, all formatting will be lost when we recreate the block.

Dear Nicolas,


that's exactly it, only raw text can be added.


The only way to format text is via the styling reference you set to your editor: https://developer.myscript.com/docs/interactive-ink/1.4/reference/styling/#text-block


Best regards,


Olivier

Thanks Olivier.

Ultimately what I would like to be able to do is to take formatted text as shown in the attached image, append more text to it (the extra text would come from keyboard entry) and have the result in a TextBox where the original formatting would be preserved, so "red" would still be in red and "green" in green.

Is there some way to do this, other than simulating handwritten input using pointer events?

image


Dear Nicolas,


the iink SDK has a fairly limited styling capacity, and doesn't have the possibility to change the styling at worek level.


Best regards,


Olivier

Hello again,

Regarding this reply:

> The only way to format text is via the styling reference you set to your editor: https://developer.myscript.com/docs/interactive-ink/1.4/reference/styling/#text-block

I tried looking into how this could be used to set a single color to a newly created Text block and the only way I could think of was calling the following before creating the new Text block

 

editor.setTheme(".text { color: #00FF00FF;}");

However, this changes the color of every existing text block in our Text Document and not only newly added Text blocks.

So I would like to know if there is a way to create a new Text block with a specific color for its text without changing the color of the other blocks.

Thank you.