List with custom styles on items

Hi, I’m trying to get my head around prose mirror since a few days. There is a lot of documentation and examples to start but I still feel unsure of what I can or can’t do.

I would like to create a schema for a kind of todo list where each item in the list can have a kind of flag (todo, note, appointment etc). In order to do that I wonder if I define a class in the attrs can the class be different for each element and define say a keymap to set the flag on a particular element ?

I also have another question, when starting implementing this I was unable to use a schema with list. When I did so, I was able to input in the header but pressing enter didn’t send me to the ul content. I was only able to do this while using paragraph for my items. (see both schema below)

const notWorkingSchema = new Schema({
  nodes: {
    text: {},
    date: {
      content: "text*",
      toDOM() { return ["h3", 0] },
      parseDOM: [{tag: "h3"}]
    },
    bulletlist: {
      content: "bullet+",
      toDOM() { return ["ul", 0] },
      parseDOM: [{tag: "ul"}]
    },
    bullet: {
      content: "text*",
      toDOM() { return ["li", 0] },
      parseDOM: [{tag: "li"}]
    },
    doc: {
      content: "date bulletlist*"
    }
  }
})

const workingSchema = new Schema({
  nodes: {
    text: {},
    date: {
      content: "text*",
      toDOM() { return ["h3", 0] },
      parseDOM: [{tag: "h3"}]
    },
    bullet: {
      content: "text*",
      toDOM() { return ["p", 0] },
      parseDOM: [{tag: "p"}]
    },
    doc: {
      content: "date bullet*"
    }
  }
})

Thanks for any input :slight_smile:

Hi. I think that what you’re trying to do should be doable with ProseMirror, though it will require some custom code to render your document elements and wire up the key handling.

The default command for enter, splitParagraph, won’t send your cursor to the next node if the current node can’t be split (which your schema forbids). It’ll simply fail in that case, and you should bind a separate command (with lower priority) to handle that situation.