Paragraphs inside nodes inside paragraphs

I have done a–perhaps ill-advised–alternative implementation of footnotes as inline nodes with contents inside them. This works shockingly well until I try to transform text to a heading inside my footnote and the parent paragraph gets converted instead.

I’m trying to pull together a minimal example to reproduce, but I have difficulty using the various JS sandboxes due to some convoluted network security on my end. In the meanwhile I’ll include my basic node and nodeview in case someone sees something obvious I’ve goofed up.

// This node depends on a custom node view
const apmFootnoteNodeSpec = {
  type: 'apm_footnote',
  content: 'block+',
  group: 'inline',
  inline: true,
  defining: true,
  isolating: true,
  attrs: {
    number: { default: null }
  },
  parseDOM: [{
    contentElement: "content",
    getAttrs(dom) {
      return { number: parseInt(dom.dataset.number) }
    },
    tag: "footnote"
  }],
  toDOM: (node) => {
    return ["footnote", {contenteditable: true, draggable: true, "data-number": node.attrs.number }, ["footnotehead", {contenteditable: false}, `Footnote ${node.attrs.number}`],["content", {}, 0]]
  }
}

module.exports = apmFootnoteNodeSpec

After reading some of the suggested reading [1][2] I’ve tried also converting to the example implementation but that has a similar problem except there trying to apply a header deletes the footnote in addition to converting the parent to a header.

Any suggestions on what to try next are much appreciated.

UPDATE: As an addendum I am testing this in Firefox 74.0 on a Mac, though this was initially discovered by a colleague running the latest Chrome also on macOS.