# Custom selection for leaf type node

**URL:** <https://discuss.prosemirror.net/t/custom-selection-for-leaf-type-node/4965>\
**Category:** Uncategorized\
**Created:** [October 19, 2022, 10:35am UTC](https://discuss.prosemirror.net/t/custom-selection-for-leaf-type-node/4965 "2022-10-19T10:35:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mustseesun](https://discuss.prosemirror.net/user_avatar/discuss.prosemirror.net/mustseesun/32/3121_2.png) [@mustseesun](https://discuss.prosemirror.net/u/mustseesun)\
**Post date:** [October 19, 2022, 10:35am UTC](https://discuss.prosemirror.net/t/custom-selection-for-leaf-type-node/4965/1 "2022-10-19T10:35:41Z")

</div>

I have a custom `nodeView` which `leaf` type node:

```auto
toDOM(node) {
      return [
        'span',
        {
          'data-type': 'fn_widget_container'
        },
        ['span', { 'data-type': 'example', label: node.attrs.label }],
        ['span', { 'data-type': 'outputContent' }, `${node.attrs.label}`]
      ];
    },
    parseDOM: [
      {
        tag: 'span[data-type=fn_widget_container]',
        getAttrs(dom) {
          const label = (dom as HTMLElement)
            ?.querySelector('span[data-type=example]')
            ?.getAttribute('label');
          return { label: label };
        }
      }
    ]

```

Also, I use angular elements to rerender `span` to my custom angular component. However prosemirror state is keep the original schema from `toDOM` function (I’m ok with it).

bold, italic, etc marks work well, but marks text\_color and text\_background\_color are not applicable for these leaf nodes. So I would like to make some custom handler for selection and select the second span (with attribute `outputContent`) to apply colors also. Is it possible to do? Or any other way to apply colors and bg-colors for leaf nodes?
