{"version":3,"sources":["../src/footnotes/footnotes.ts","../src/footnotes/rules.ts","../src/footnotes/utils.ts","../src/footnotes/reference.ts","../src/footnotes/footnote.ts"],"sourcesContent":["import OrderedList from \"@tiptap/extension-ordered-list\";\nimport FootnoteRules from \"./rules\";\n\nconst Footnotes = OrderedList.extend({\n  name: \"footnotes\",\n  group: \"\", // removed the default group of the ordered list extension\n  isolating: true,\n  defining: true,\n  draggable: false,\n\n  content() {\n    return \"footnote*\";\n  },\n  addAttributes() {\n    return {\n      class: {\n        default: \"footnotes\",\n      },\n    };\n  },\n  parseHTML() {\n    return [\n      {\n        tag: \"ol.footnotes\",\n        priority: 1000,\n      },\n    ];\n  },\n\n  addKeyboardShortcuts() {\n    return {};\n  },\n  addCommands() {\n    return {};\n  },\n  addInputRules() {\n    return [];\n  },\n\n  addExtensions() {\n    return [FootnoteRules];\n  },\n});\n\nexport default Footnotes;\n","import { Plugin, PluginKey, TextSelection } from \"@tiptap/pm/state\";\nimport { ReplaceStep } from \"@tiptap/pm/transform\";\nimport { Extension, minMax } from \"@tiptap/core\";\nimport { updateFootnotesList } from \"./utils\";\n\nconst FootnoteRules = Extension.create({\n  name: \"footnoteRules\",\n  priority: 1000,\n  addProseMirrorPlugins() {\n    return [\n      new Plugin({\n        key: new PluginKey(\"footnoteRules\"),\n        filterTransaction(tr) {\n          const { from, to } = tr.selection;\n\n          // Allow full document selections (Mod-a/Ctrl-a)\n          if (from === 0 && to === tr.doc.content.size) return true;\n\n          let selectedFootnotes = false;\n          let selectedContent = false;\n          let footnoteCount = 0;\n          tr.doc.nodesBetween(from, to, (node, _, parent) => {\n            if (parent?.type.name == \"doc\" && node.type.name != \"footnotes\") {\n              selectedContent = true;\n            } else if (node.type.name == \"footnote\") {\n              footnoteCount += 1;\n            } else if (node.type.name == \"footnotes\") {\n              selectedFootnotes = true;\n            }\n          });\n          const overSelected = selectedContent && selectedFootnotes;\n          /*\n           * Here, we don't allow any transaction that spans between the \"content\" nodes and the \"footnotes\" node. This also rejects any transaction that spans between more than 1 footnote.\n           */\n          return !overSelected && footnoteCount <= 1;\n        },\n\n        // if there are some to the footnote references (added/deleted/dragged), append a transaction that updates the footnotes list accordingly\n        appendTransaction(transactions, oldState, newState) {\n          let newTr = newState.tr;\n          let refsChanged = false; // true if the footnote references have been changed, false otherwise\n          for (let tr of transactions) {\n            if (!tr.docChanged) continue;\n            if (refsChanged) break;\n\n            for (let step of tr.steps) {\n              if (!(step instanceof ReplaceStep)) continue;\n              if (refsChanged) break;\n\n              const isDelete = step.from != step.to; // the user deleted items from the document (from != to & the step is a replace step)\n              const isInsert = step.slice.size > 0;\n\n              // check if any footnote references have been inserted\n              if (isInsert) {\n                step.slice.content.descendants((node) => {\n                  if (node?.type.name == \"footnoteReference\") {\n                    refsChanged = true;\n                    return false;\n                  }\n                });\n              }\n              if (isDelete && !refsChanged) {\n                // check if any footnote references have been deleted\n                tr.before.nodesBetween(\n                  step.from,\n                  Math.min(tr.before.content.size, step.to), // make sure to not go over the old document's limit\n                  (node) => {\n                    if (node.type.name == \"footnoteReference\") {\n                      refsChanged = true;\n                      return false;\n                    }\n                  },\n                );\n              }\n            }\n          }\n\n          if (refsChanged) {\n            updateFootnotesList(newTr, newState);\n            return newTr;\n          }\n\n          return null;\n        },\n      }),\n    ];\n  },\n});\nexport default FootnoteRules;\n","import { EditorState, Transaction } from \"@tiptap/pm/state\";\nimport { Fragment, Node } from \"@tiptap/pm/model\";\n\n// update the reference number of all the footnote references in the document\nexport function updateFootnoteReferences(tr: Transaction) {\n  let count = 1;\n\n  const nodes: any[] = [];\n\n  tr.doc.descendants((node, pos) => {\n    if (node.type.name == \"footnoteReference\") {\n      tr.setNodeAttribute(pos, \"referenceNumber\", `${count}`);\n\n      nodes.push(node);\n      count += 1;\n    }\n  });\n  // return the updated footnote references (in the order that they appear in the document)\n  return nodes;\n}\n\nfunction getFootnotes(tr: Transaction) {\n  let footnotesRange: { from: number; to: number } | undefined;\n  const footnotes: Node[] = [];\n  tr.doc.descendants((node, pos) => {\n    if (node.type.name == \"footnote\") {\n      footnotes.push(node);\n    } else if (node.type.name == \"footnotes\") {\n      footnotesRange = { from: pos, to: pos + node.nodeSize };\n    } else {\n      return false;\n    }\n  });\n  return { footnotesRange, footnotes };\n}\n\n// update the \"footnotes\" ordered list based on the footnote references in the document\nexport function updateFootnotesList(tr: Transaction, state: EditorState) {\n  const footnoteReferences = updateFootnoteReferences(tr);\n\n  const footnoteType = state.schema.nodes.footnote;\n  const footnotesType = state.schema.nodes.footnotes;\n\n  const emptyParagraph = state.schema.nodeFromJSON({\n    type: \"paragraph\",\n    content: [],\n  });\n\n  const { footnotesRange, footnotes } = getFootnotes(tr);\n\n  // a mapping of footnote id -> footnote node\n  const footnoteIds: { [key: string]: Node } = footnotes.reduce(\n    (obj, footnote) => {\n      obj[footnote.attrs[\"data-id\"]] = footnote;\n      return obj;\n    },\n    {} as any,\n  );\n\n  const newFootnotes: Node[] = [];\n\n  let footnoteRefIds = new Set(\n    footnoteReferences.map((ref) => ref.attrs[\"data-id\"]),\n  );\n  const deleteFootnoteIds: Set<string> = new Set();\n  for (let footnote of footnotes) {\n    const id = footnote.attrs[\"data-id\"];\n    if (!footnoteRefIds.has(id) || deleteFootnoteIds.has(id)) {\n      deleteFootnoteIds.add(id);\n      // we traverse through this footnote's content because it may contain footnote references.\n      // we want to delete the footnotes associated with these references, so we add them to the delete set.\n      footnote.content.descendants((node) => {\n        if (node.type.name == \"footnoteReference\")\n          deleteFootnoteIds.add(node.attrs[\"data-id\"]);\n      });\n    }\n  }\n\n  for (let i = 0; i < footnoteReferences.length; i++) {\n    let refId = footnoteReferences[i].attrs[\"data-id\"];\n\n    if (deleteFootnoteIds.has(refId)) continue;\n    // if there is a footnote w/ the same id as this `ref`, we preserve its content and update its id attribute\n    if (refId in footnoteIds) {\n      let footnote = footnoteIds[refId];\n      newFootnotes.push(\n        footnoteType.create(\n          { ...footnote.attrs, id: `fn:${i + 1}` },\n          footnote.content,\n        ),\n      );\n    } else {\n      let newNode = footnoteType.create(\n        {\n          \"data-id\": refId,\n          id: `fn:${i + 1}`,\n        },\n        [emptyParagraph],\n      );\n      newFootnotes.push(newNode);\n    }\n  }\n\n  if (newFootnotes.length == 0) {\n    // no footnotes in the doc, delete the \"footnotes\" node\n    if (footnotesRange) {\n      tr.delete(footnotesRange.from, footnotesRange.to);\n    }\n  } else if (!footnotesRange) {\n    // there is no footnotes node present in the doc, add it\n    tr.insert(\n      tr.doc.content.size,\n      footnotesType.create(undefined, Fragment.from(newFootnotes)),\n    );\n  } else {\n    tr.replaceWith(\n      footnotesRange!.from + 1, // add 1 to point at the position after the opening ol tag\n      footnotesRange!.to - 1, // substract 1 to point to the position before the closing ol tag\n      Fragment.from(newFootnotes),\n    );\n  }\n}\n","import { mergeAttributes, Node } from \"@tiptap/core\";\nimport {\n  Fragment as PMFragment,\n  Node as PMNode,\n  Slice,\n} from \"@tiptap/pm/model\";\nimport { NodeSelection, Plugin, PluginKey } from \"@tiptap/pm/state\";\n\n\nconst REFNUM_ATTR = \"data-reference-number\";\nconst REF_CLASS = \"footnote-ref\";\n\ndeclare module \"@tiptap/core\" {\n  interface Commands<ReturnType> {\n    footnoteReference: {\n      /**\n       * add a new footnote reference\n       * @example editor.commands.addFootnote()\n       */\n      addFootnote: () => ReturnType;\n    };\n  }\n}\n\nconst FootnoteReference = Node.create({\n  name: \"footnoteReference\",\n  inline: true,\n  content: \"text*\",\n  group: \"inline\",\n  atom: true,\n  draggable: true,\n\n  parseHTML() {\n    return [\n      {\n        tag: `sup`,\n        priority: 1000,\n        getAttrs(node) {\n          const anchor = node.querySelector<HTMLAnchorElement>(\n            `a.${REF_CLASS}:first-child`\n          );\n\n          if (!anchor) {\n            return false;\n          }\n\n          const id = anchor.getAttribute(\"data-id\");\n          const ref = anchor.getAttribute(REFNUM_ATTR);\n\n          return {\n            \"data-id\": id ?? crypto.randomUUID(),\n            referenceNumber: ref ?? anchor.innerText,\n          };\n        },\n        contentElement(node) {\n          return node.firstChild as HTMLElement;\n        },\n      },\n    ];\n  },\n\n  addAttributes() {\n    return {\n      class: {\n        default: REF_CLASS,\n      },\n      \"data-id\": {\n        renderHTML(attributes) {\n          return {\n            \"data-id\": attributes[\"data-id\"] || crypto.randomUUID(),\n          };\n        },\n      },\n      referenceNumber: {},\n\n      href: {\n        renderHTML(attributes) {\n          return {\n            href: `#fn:${attributes[\"referenceNumber\"]}`,\n          };\n        },\n      },\n    };\n  },\n\n  renderHTML({ HTMLAttributes }) {\n    const { referenceNumber, ...attributes } = HTMLAttributes;\n    const attrs = mergeAttributes(this.options.HTMLAttributes, attributes);\n    attrs[REFNUM_ATTR] = referenceNumber;\n\n    return [\n      \"sup\",\n      { id: `fnref:${referenceNumber}` },\n      [\"a\", attrs, HTMLAttributes.referenceNumber],\n    ];\n  },\n\n  addProseMirrorPlugins() {\n    const { editor } = this;\n\n    // Ensures pasted footnote references get unique IDs.\n    const mapNode = (node: PMNode): PMNode => {\n      if (node.type.name === this.name) {\n        const newAttrs = { ...node.attrs, \"data-id\": crypto.randomUUID() };\n        return node.type.create(newAttrs, node.content, node.marks);\n      }\n\n      if (node.content && node.content.size > 0) {\n        const newChildren: PMNode[] = [];\n        let changed = false;\n\n        node.content.forEach((child) => {\n          const mapped = mapNode(child);\n          if (mapped !== child) {\n            changed = true;\n          }\n\n          newChildren.push(mapped);\n        });\n\n        if (changed) {\n          return node.copy(PMFragment.from(newChildren));\n        }\n      }\n\n      return node;\n    };\n\n    return [\n      new Plugin({\n        key: new PluginKey(\"footnotePasteHandler\"),\n        props: {\n          transformPasted(slice) {\n            const mappedNodes: PMNode[] = [];\n            let changed = false;\n\n            slice.content.forEach((node) => {\n              const mapped = mapNode(node);\n              if (mapped !== node) {\n                changed = true;\n              }\n              mappedNodes.push(mapped);\n            });\n\n            if (!changed) {\n              return slice;\n            }\n\n            return new Slice(\n              PMFragment.from(mappedNodes),\n              slice.openStart,\n              slice.openEnd\n            );\n          },\n        },\n      }),\n      new Plugin({\n        key: new PluginKey(\"footnoteRefClick\"),\n\n        props: {\n          // on double-click, focus on the footnote\n          handleDoubleClickOn(view, pos, node, nodePos, event) {\n            if (node.type.name != \"footnoteReference\") return false;\n            event.preventDefault();\n            const id = node.attrs[\"data-id\"];\n            return editor.commands.focusFootnote(id);\n          },\n          // click the footnote reference once to get focus, click twice to scroll to the footnote\n          handleClickOn(view, pos, node, nodePos, event) {\n            if (node.type.name != \"footnoteReference\") return false;\n            event.preventDefault();\n            const { selection } = editor.state.tr;\n            if (selection instanceof NodeSelection && selection.node.eq(node)) {\n              const id = node.attrs[\"data-id\"];\n              return editor.commands.focusFootnote(id);\n            } else {\n              editor.chain().setNodeSelection(nodePos).run();\n              return true;\n            }\n          },\n        },\n      }),\n    ];\n  },\n\n  addCommands() {\n    return {\n      addFootnote:\n        () =>\n        ({ state, tr }) => {\n          const node = this.type.create({\n            \"data-id\": crypto.randomUUID(),\n          });\n          tr.insert(state.selection.anchor, node);\n          return true;\n        },\n    };\n  },\n\n  addInputRules() {\n    // when a user types [^text], add a new footnote\n    return [\n      {\n        find: /\\[\\^(.*?)\\]/,\n        type: this.type,\n        undoable: true,\n        handler({ range, match, chain }) {\n          const start = range.from;\n          let end = range.to;\n          if (match[1]) {\n            chain().deleteRange({ from: start, to: end }).addFootnote().run();\n          }\n        },\n      },\n    ];\n  },\n});\n\nexport default FootnoteReference;\n","import { mergeAttributes } from \"@tiptap/core\";\nimport ListItem, { ListItemOptions } from \"@tiptap/extension-list-item\";\n\ndeclare module \"@tiptap/core\" {\n  interface Commands<ReturnType> {\n    footnote: {\n      /**\n       * scrolls to & sets the text selection at the end of the footnote with the given id\n       * @param id the id of the footote (i.e. the `data-id` attribute value of the footnote)\n       * @example editor.commands.focusFootnote(\"a43956c1-1ab8-462f-96e4-be3a4b27fd50\")\n       */\n      focusFootnote: (id: string) => ReturnType;\n    };\n  }\n}\n\nexport interface FootnoteOptions extends ListItemOptions {\n  /**\n   * Content expression for this node\n   * @default \"paragraph+\"\n   */\n  content: string;\n}\n\nconst Footnote = ListItem.extend<FootnoteOptions>({\n  name: \"footnote\",\n  content() {\n    return this.options.content;\n  },\n  isolating: true,\n  defining: true,\n  draggable: false,\n\n  addOptions() {\n    return {\n      HTMLAttributes: {},\n      bulletListTypeName: 'bulletList',\n      orderedListTypeName: 'orderedList',\n      ...this.parent?.(),\n      content: \"paragraph+\",\n    };\n  },\n\n  addAttributes() {\n    return {\n      id: {\n        isRequired: true,\n      },\n      // the data-id field should match the data-id field of a footnote reference.\n      // it's used to link footnotes and references together.\n      \"data-id\": {\n        isRequired: true,\n      },\n    };\n  },\n  parseHTML() {\n    return [\n      {\n        tag: \"li\",\n        getAttrs(node) {\n          const id = node.getAttribute(\"data-id\");\n          if (id) {\n            return {\n              \"data-id\": node.getAttribute(\"data-id\"),\n            };\n          }\n          return false;\n        },\n        priority: 1000,\n      },\n    ];\n  },\n  renderHTML({ HTMLAttributes }) {\n    return [\n      \"li\",\n      mergeAttributes(this.options.HTMLAttributes, HTMLAttributes),\n      0,\n    ];\n  },\n\n  addCommands() {\n    return {\n      focusFootnote:\n        (id: string) =>\n        ({ editor, chain }) => {\n          const matchedFootnote = editor.$node(\"footnote\", {\n            \"data-id\": id,\n          });\n          if (matchedFootnote) {\n            // sets the text selection to the end of the footnote definition and scroll to it.\n            chain()\n              .focus()\n              .setTextSelection(\n                matchedFootnote.from + matchedFootnote.content.size\n              )\n              .run();\n\n            matchedFootnote.element.scrollIntoView();\n            return true;\n          }\n          return false;\n        },\n    };\n  },\n  addKeyboardShortcuts() {\n    return {\n      // when inside a footnote, Mod-a should select only the footnote content\n      \"Mod-a\": ({ editor }) => {\n        try {\n          const { selection } = editor.state;\n          const { $from } = selection;\n          \n          for (let depth = $from.depth; depth >= 0; depth--) {\n            const node = $from.node(depth);\n            if (node.type.name === \"footnote\") {\n              const start = $from.start(depth);\n              const end = $from.end(depth);\n              \n              editor.commands.setTextSelection({\n                from: start + 1,\n                to: end - 1,\n              });\n              return true;\n            }\n          }\n          \n          return false;\n        } catch (e) {\n          return false;\n        }\n      },\n      // when the user presses tab, adjust the text selection to be at the end of the next footnote\n      Tab: ({ editor }) => {\n        try {\n          const { selection } = editor.state;\n          const pos = editor.$pos(selection.anchor);\n          if (!pos.after) return false;\n          // if the next node  is \"footnotes\", place the text selection at the end of the first footnote\n          if (pos.after.node.type.name == \"footnotes\") {\n            const firstChild = pos.after.node.child(0);\n            editor\n              .chain()\n              .setTextSelection(pos.after.from + firstChild.content.size)\n              .scrollIntoView()\n              .run();\n            return true;\n          } else {\n            const startPos = selection.$from.start(2);\n            if (Number.isNaN(startPos)) return false;\n            const parent = editor.$pos(startPos);\n            if (parent.node.type.name != \"footnote\" || !parent.after) {\n              return false;\n            }\n            // if the next node is a footnote, place the text selection at the end of it\n            editor\n              .chain()\n              .setTextSelection(parent.after.to - 1)\n              .scrollIntoView()\n              .run();\n            return true;\n          }\n        } catch {\n          return false;\n        }\n      },\n      // inverse of the tab command - place the text selection at the end of the previous footnote\n      \"Shift-Tab\": ({ editor }) => {\n        const { selection } = editor.state;\n        const startPos = selection.$from.start(2);\n        if (Number.isNaN(startPos)) return false;\n        const parent = editor.$pos(startPos);\n        if (parent.node.type.name != \"footnote\" || !parent.before) {\n          return false;\n        }\n\n        editor\n          .chain()\n          .setTextSelection(parent.before.to - 1)\n          .scrollIntoView()\n          .run();\n        return true;\n      },\n    };\n  },\n  \n});\n\nexport default Footnote;\n"],"mappings":";AAAA,OAAO,iBAAiB;;;ACAxB,SAAS,QAAQ,iBAAgC;AACjD,SAAS,mBAAmB;AAC5B,SAAS,iBAAyB;;;ACDlC,SAAS,gBAAsB;AAGxB,SAAS,yBAAyB,IAAiB;AACxD,MAAI,QAAQ;AAEZ,QAAM,QAAe,CAAC;AAEtB,KAAG,IAAI,YAAY,CAAC,MAAM,QAAQ;AAChC,QAAI,KAAK,KAAK,QAAQ,qBAAqB;AACzC,SAAG,iBAAiB,KAAK,mBAAmB,GAAG,KAAK,EAAE;AAEtD,YAAM,K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