Skip to main content
dublove
Legend
Jul 27, 2026 6:03 AM UTC
Answered

How do I distinguish between selecting partial text or selecting the entire story?

Hi everyone.

If I select partial text, I will clear the preference for the selected text.
If all text (the whole story) is selected, priority will be given to clearing all objects under the story.
I found that I selected the entire story and only selected some of the text,
The results of alert (app. selection [0]. constructor. name) are all
Text.
How can I distinguish between these two states?

thank you.

    Manan JoshiCorrect answer
    Community Expert
    Jul 27, 2026 7:58 AM UTC

    app.selection[0].parentStory.contents.length would give you the length of the parentStory

    -Manan

    6 replies

    Community Expert
    Jul 27, 2026 6:50 AM UTC

    The 1st though that comes to mind is check the character count. Get the parentStory and its length and match it with the selection length. If it matches you have the story selected, else it is subset selection

    Translate
    -Manan
    dublove
    dubloveAuthor
    Legend
    Jul 27, 2026 7:53 AM UTC

    It seems like this.
    But I don't know how to obtain the content and length of the entire story.

    if (
    (app.selection[0].constructor.name == "Text")
    ) {
    var item = app.selection[0];
    var text = item
    curStory = text.parent;

    alert(text.length);
    alert(curStory.texts);
    //clear(text)
    }

     

    Translate
    Manan JoshiCommunity ExpertCorrect answer
    Community Expert
    Jul 27, 2026 7:58 AM UTC

    app.selection[0].parentStory.contents.length would give you the length of the parentStory

    Translate
    -Manan