# Please confirm: Getting selected text range of Text / Area Text is unsupported

**URL:** <https://forums.creativeclouddeveloper.com/t/please-confirm-getting-selected-text-range-of-text-area-text-is-unsupported/1765>\
**Category:** UXP Plugin API\
**Tags:** text\
**Created:** [May 13, 2020, 12:10am UTC](https://forums.creativeclouddeveloper.com/t/please-confirm-getting-selected-text-range-of-text-area-text-is-unsupported/1765 "2020-05-13T00:10:21Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![abcd\_ca](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/abcd_ca/32/821_2.png) [@abcd\_ca](https://forums.creativeclouddeveloper.com/u/abcd_ca)\
**Post date:** [May 13, 2020, 12:10am UTC](https://forums.creativeclouddeveloper.com/t/please-confirm-getting-selected-text-range-of-text-area-text-is-unsupported/1765/1 "2020-05-13T00:10:21Z")

</div>

Say the end user has a Text (Area Text) node on the page with three paragraphs. Am I right that as a user I can’t select the middle paragraph and in my plugin, glean the start/end range numbers of that text in order to manipulate that substring of text?

Further, it doesn’t appear to be possible to format that text with HTML/CSS. Please confirm that HTML/CSS is only supported in UI provided by the plugin itself and not for styling the end user’s design content.

I’m interested in user being able to select a substring of text within a Text node and have my plugin indent by a user-specified amount but it would seem I’d have to do this with space characters and probably can’t for a sub-selection anyway but rather, only for the entire Text node.

Thank you for confirming my assessment of the latest API.

---

<div class="post-metadata">

**Author:** ![cpryland](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/cpryland/32/1172_2.png) [@cpryland](https://forums.creativeclouddeveloper.com/u/cpryland)\
**Post date:** [May 13, 2020, 3:04am UTC](https://forums.creativeclouddeveloper.com/t/please-confirm-getting-selected-text-range-of-text-area-text-is-unsupported/1765/2 "2020-05-13T03:04:14Z")

</div>

@peterflynn Good question: will we ever get text selection info in the API?

---

<div class="post-metadata">

**Author:** ![pklaschka](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/pklaschka/32/3162_2.png) [@pklaschka](https://forums.creativeclouddeveloper.com/u/pklaschka)\
**Post date:** [May 13, 2020, 11:04am UTC](https://forums.creativeclouddeveloper.com/t/please-confirm-getting-selected-text-range-of-text-area-text-is-unsupported/1765/3 "2020-05-13T11:04:45Z")

</div>

First of all: Welcome to the community 👋🙂

> [@abcd\_ca](#):
>
> Say the end-user has a Text (Area Text) node on the page with three paragraphs. Am I right that as a user I can’t select the middle paragraph and in my plugin, glean the start/end range numbers of that text in order to manipulate that substring of text?

Correct. The moment a user executes the plugin (e.g., by clicking on the plugin in the plugins panel), the “text editing mode” deactivates, i.e., the text node will be selected, but selections inside the node are no longer existent.

> [@abcd\_ca](#):
>
> Further, it doesn’t appear to be possible to format that text with HTML/CSS. Please confirm that HTML/CSS is only supported in UI provided by the plugin itself and not for styling the end user’s design content.

Correct. You could, of course, parse CSS and apply it, but given your use-case, that doesn’t seem applicable. Overall, XD’s text node styling isn’t as powerful as HTML/CSS, meaning a direct “translation” is impossible.

> [@abcd\_ca](#):
>
> I’m interested in the user being able to select a substring of text within a Text node and have my plugin indent by a user-specified amount but it would seem I’d have to do this with space characters and probably can’t for a sub-selection anyway but rather, only for the entire Text node.

I believe there are several options here. First of all, you could let the user select the text range inside your plugin UI.

After that, it might be easier to

1. split the text area into multiple ones (create new ones and update their content and position/size), surrounding the specified range
2. move and resize the text area containing the text to achieve the desired indention.

Using spaces, you’ll probably run into a lot of messy cases with line breaks you’ll have to fix, etc., meaning that this is probably not your desired outcome (that, however, is up to you, of course) 😉

---

<div class="post-metadata">

**Author:** ![cpryland](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/cpryland/32/1172_2.png) [@cpryland](https://forums.creativeclouddeveloper.com/u/cpryland)\
**Post date:** [May 13, 2020, 2:17pm UTC](https://forums.creativeclouddeveloper.com/t/please-confirm-getting-selected-text-range-of-text-area-text-is-unsupported/1765/4 "2020-05-13T14:17:46Z")

</div>

> [@pklaschka](#):
>
> Correct. The moment a user executes the plugin (e.g., by clicking on the plugin in the plugins panel), the “text editing mode” deactivates, i.e., the text node will be selected, but selections inside the node are no longer existent.

Yes, but if the panel is already open, then an `update()` could be issued after any selection change within the text, if we had a text-selection api.

---

<div class="post-metadata">

**Author:** ![abcd\_ca](https://sea1.discourse-cdn.com/flex015/user_avatar/forums.creativeclouddeveloper.com/abcd_ca/32/821_2.png) [@abcd\_ca](https://forums.creativeclouddeveloper.com/u/abcd_ca)\
**Post date:** [June 27, 2020, 12:38am UTC](https://forums.creativeclouddeveloper.com/t/please-confirm-getting-selected-text-range-of-text-area-text-is-unsupported/1765/5 "2020-06-27T00:38:07Z")

</div>

Thanks for your help and thoughtful responses!
