{"version":3,"sources":["../src/index.ts","../src/superscript.ts"],"sourcesContent":["import { Superscript } from './superscript.js'\n\nexport * from './superscript.js'\n\nexport default Superscript\n","import { Mark, mergeAttributes } from '@tiptap/core'\nimport type { StyleParseRule } from '@tiptap/pm/model'\n\nexport interface SuperscriptExtensionOptions {\n  /**\n   * HTML attributes to add to the superscript element.\n   * @default {}\n   * @example { class: 'foo' }\n   */\n  HTMLAttributes: Record<string, any>\n}\n\ndeclare module '@tiptap/core' {\n  interface Commands<ReturnType> {\n    superscript: {\n      /**\n       * Set a superscript mark\n       * @example editor.commands.setSuperscript()\n       */\n      setSuperscript: () => ReturnType\n      /**\n       * Toggle a superscript mark\n       * @example editor.commands.toggleSuperscript()\n       */\n      toggleSuperscript: () => ReturnType\n      /**\n       * Unset a superscript mark\n       *  @example editor.commands.unsetSuperscript()\n       */\n      unsetSuperscript: () => ReturnType\n    }\n  }\n}\n\n/**\n * This extension allows you to create superscript text.\n * @see https://www.tiptap.dev/api/marks/superscript\n */\nexport const Superscript = Mark.create<SuperscriptExtensionOptions>({\n  name: 'superscript',\n\n  addOptions() {\n    return {\n      HTMLAttributes: {},\n    }\n  },\n\n  parseHTML() {\n    return [\n      {\n        tag: 'sup',\n      },\n      {\n        style: 'vertical-align',\n        getAttrs(value) {\n          // Don’t match this rule if the vertical align isn’t super.\n          if (value !== 'super') {\n            return false\n          }\n\n          // If it falls through we’ll match, and this mark will be applied.\n          return null\n        },\n      } as StyleParseRule,\n    ]\n  },\n\n  renderHTML({ HTMLAttributes }) {\n    return ['sup', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n  },\n\n  addCommands() {\n    return {\n      setSuperscript:\n        () =>\n        ({ commands }) => {\n          return commands.setMark(this.name)\n        },\n      toggleSuperscript:\n        () =>\n        ({ commands }) => {\n          return commands.toggleMark(this.name)\n        },\n      unsetSuperscript:\n        () =>\n        ({ commands }) => {\n          return commands.unsetMark(this.name)\n        },\n    }\n  },\n\n  addKeyboardShortcuts() {\n    return {\n      'Mod-.': () => this.editor.commands.toggleSuperscript(),\n    }\n  },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAsC;AAsC/B,IAAM,cAAc,iBAAK,OAAoC;AAAA,EAClE,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,YAAY;AACV,WAAO;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MACP;AAAA,MACA;AAAA,QACE,OAAO;AAAA,QACP,SAAS,OAAO;AAEd,cAAI,UAAU,SAAS;AACrB,mBAAO;AAAA,UACT;AAGA,iBAAO;AAAA,QACT;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,WAAO,6BAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EAChF;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,gBACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,SAAS,QAAQ,KAAK,IAAI;AAAA,MACnC;AAAA,MACF,mBACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,SAAS,WAAW,KAAK,IAAI;AAAA,MACtC;AAAA,MACF,kBACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,SAAS,UAAU,KAAK,IAAI;AAAA,MACrC;AAAA,IACJ;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,WAAO;AAAA,MACL,SAAS,MAAM,KAAK,OAAO,SAAS,kBAAkB;AAAA,IACxD;AAAA,EACF;AACF,CAAC;;;AD5FD,IAAO,gBAAQ;","names":[]}