node.type.spec.toDOM is not a function

I am trying to define a spec for a code block and a command to insert that in the view. but whenever i run the command, I get this error “node.type.spec.toDOM is not a function”.

  template: {
    content: 'text*',
    marks: '',
    group: 'block',
    code: true,
    defining: true,
    parseDOM: [{tag: 'pre', preserveWhitespace: 'full'}],
    toDom: () => [
export const addCustomTemplate = (state, dispatch, view) => {
  const customTemplateNode = state.schema.nodes.template.create()
  const tr =


You have toDom instead of toDOM.

1 Like

that is very embarrassing.