# Feedback request on Footnotes

**URL:** <https://discuss.prosemirror.net/t/feedback-request-on-footnotes/2585>\
**Category:** Uncategorized\
**Created:** [March 9, 2020, 2:37pm UTC](https://discuss.prosemirror.net/t/feedback-request-on-footnotes/2585 "2020-03-09T14:37:02Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![astevenson](https://discuss.prosemirror.net/letter_avatar_proxy/v4/letter/a/f19dbf/32.png) [@astevenson](https://discuss.prosemirror.net/u/astevenson)\
**Post date:** [March 10, 2020, 4:32pm UTC](https://discuss.prosemirror.net/t/feedback-request-on-footnotes/2585/6 "2020-03-10T16:32:34Z")

</div>

Ok, after a brief trip to the implementation described in [this thread](https://discuss.prosemirror.net/t/apply-decorations-directly-through-an-editor-method/2377/7) I’ve changed to a much simpler implementation

For counting and renumbering footnotes

```
let findTheFoot = (state) => {
  let footnotes = []
  let counter = 0;
  let transaction = null
  state.doc.descendants((node, pos) => {
    if(node.type.name != 'footnote') return true
    counter = counter + 1
    if (node.attrs.number != counter) {
      if(transaction == null) transaction = state.tr
      transaction.setNodeMarkup(pos, null, { number: counter })
    }
  })
  return transaction
}

export function createFootNotesPlugin() {
  return new Plugin({
    key: 'footnotes',
    appendTransaction: (transactions, oldState, newState) => {
      return findTheFoot(newState)
    }
  })
}

```

The view:

```
class FootnoteNodeView {
  constructor(node, view, getPos) {
    this.dom = window.document.createElement('footnote')

    let head = this.dom.appendChild(window.document.createElement('footnotehead'))
    head.innerText = `Footnote ${node.attrs.number}`
    head.contentEditable = false
    this.contentDOM = this.dom.appendChild(window.document.createElement('content'))
    head.addEventListener("click", e => {
      if (this.dom.classList.contains('expanded')) {
        this.dom.classList.remove('expanded')
      }
      else {
        this.dom.classList.add('expanded')
      }
    })
  }
  ignoreMutation(rec) {
    return rec.target.tagName == 'FOOTNOTE' && rec.type == 'attributes' && rec.attributeName == 'class'
  }
}

export default FootnoteNodeView

```

I think I’ll need to tweak the header for accessibility purposes, but so far this works a treat.

---

_[View the full topic](https://discuss.prosemirror.net/t/feedback-request-on-footnotes/2585)._
