Transactions happen at or with a certain Selection
. Which can either be a TextSelection
or a NodeSelection
.
It is possible to build a complex action from several subactions. I'm not sure if this is the correct/best-practice way to do it.
dispatch(state.tr .ensureMarks([]) .insertText(prefix) .insertText(username) .addMark( usernameFrom, usernameTo, schema.marks.link.create({ href: `mailto:${usermail}`, })) .insertText(timestring) .addMark( usernameFrom, signatureEnd, schema.marks.em.create()) .ensureMarks([]));