How to replace autogenerated paragraph with span tag in ListItems


#1

Hi,

List items (LI tag) is wrapped in a paragraph. I understand that this is due to the block content as nodes require a child node.

I was wondering if I can change the LI tag to render a SPAN instead of a P tag ?

Any ideas are much appreciated.

Thanks, Johnson

This is how my ListItem looks like:

get schema() {
 return {
   content: 'block*',
   defining: true,
   draggable: false,
   parseDOM: [
     { tag: 'li' },
   ],
   toDOM: () => ['li', 0],
 }
}

I tried to change the schema like this but it doesn’t work:

get schema() {
 return {
   content: 'text*',
   defining: true,
   draggable: false,
   parseDOM: [
     { tag: 'li' },
   ],
   toDOM: () => ['li', ['span', 0]],
 }
}