# Text in bullet list concatenates to single bullet

**URL:** <https://discuss.prosemirror.net/t/text-in-bullet-list-concatenates-to-single-bullet/4856>\
**Category:** Uncategorized\
**Created:** [August 24, 2022, 11:18am UTC](https://discuss.prosemirror.net/t/text-in-bullet-list-concatenates-to-single-bullet/4856 "2022-08-24T11:18:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![midnight-commits](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/midnight-commits/32/3033_2.png) [@midnight-commits](https://discuss.prosemirror.net/u/midnight-commits)\
**Post date:** [August 24, 2022, 11:18am UTC](https://discuss.prosemirror.net/t/text-in-bullet-list-concatenates-to-single-bullet/4856/1 "2022-08-24T11:18:24Z")

</div>

Hello there,

I’ve recently created a button that changes the case of some selected text i.e. lowercase to uppercase and vice versa. When used on a bullet list of text nodes however, it concatenates the text e.g. a bullet list of 3 'hi’s would be turned into a single bullet point of ‘HI’. Does anyone know how to ensure that this concatenation does not occur?

Here is my code:

```auto
export function caseCommand() : ProsemirrorCommand {
    return (state, dispatch) => {
        const { from, to } = state.selection;
        const text = state.doc.textBetween(from, to);
        if (text.length === 0) {
            return false;
        } else if (text.toLowerCase() === text) {
            const textNode = state.schema.text(text.toUpperCase());
            dispatch(state.tr.replaceWith(from, to, textNode));
        } else {
            const textNode = state.schema.text(text.toLowerCase());
            dispatch(state.tr.replaceWith(from, to, textNode));
        }
        return true;
    }
}

```

---

<div class="post-metadata">

**Author:** ![andrews](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/a/898d66/32.png) [@andrews](https://discuss.prosemirror.net/u/andrews)\
**Post date:** [August 24, 2022, 2:04pm UTC](https://discuss.prosemirror.net/t/text-in-bullet-list-concatenates-to-single-bullet/4856/2 "2022-08-24T14:04:09Z")

</div>

You are replacing the entire selection which may (and in your described scenario does) intersect and contain multiple nodes. So in your example you are replacing a selection of list items with a single text node so the result you describe is correct. Instead you should find the text nodes _within_ the selection and replace those. There’s a similar topic about changing the text case with an approach described [here](https://discuss.prosemirror.net/t/some-pointers-in-creating-a-casing-plugin/2805/3).

---

<div class="post-metadata">

**Author:** ![midnight-commits](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/midnight-commits/32/3033_2.png) [@midnight-commits](https://discuss.prosemirror.net/u/midnight-commits)\
**Post date:** [August 26, 2022, 9:18am UTC](https://discuss.prosemirror.net/t/text-in-bullet-list-concatenates-to-single-bullet/4856/3 "2022-08-26T09:18:44Z")

</div>

Thank you very much @andrews - your suggestions have been very helpful
