{"version":3,"sources":["../src/index.ts","../src/subscript.ts"],"sourcesContent":["import { Subscript } from './subscript.js'\n\nexport * from './subscript.js'\n\nexport default Subscript\n","import { Mark, mergeAttributes } from '@tiptap/core'\nimport type { StyleParseRule } from '@tiptap/pm/model'\n\nexport interface SubscriptExtensionOptions {\n  /**\n   * HTML attributes to add to the subscript element.\n   * @default {}\n   * @example { class: 'foo' }\n   */\n  HTMLAttributes: Record<string, any>\n}\n\ndeclare module '@tiptap/core' {\n  interface Commands<ReturnType> {\n    subscript: {\n      /**\n       * Set a subscript mark\n       * @example editor.commands.setSubscript()\n       */\n      setSubscript: () => ReturnType\n      /**\n       * Toggle a subscript mark\n       * @example editor.commands.toggleSubscript()\n       */\n      toggleSubscript: () => ReturnType\n      /**\n       * Unset a subscript mark\n       * @example editor.commands.unsetSubscript()\n       */\n      unsetSubscript: () => ReturnType\n    }\n  }\n}\n\n/**\n * This extension allows you to create subscript text.\n * @see https://www.tiptap.dev/api/marks/subscript\n */\nexport const Subscript = Mark.create<SubscriptExtensionOptions>({\n  name: 'subscript',\n\n  addOptions() {\n    return {\n      HTMLAttributes: {},\n    }\n  },\n\n  parseHTML() {\n    return [\n      {\n        tag: 'sub',\n      },\n      {\n        style: 'vertical-align',\n        getAttrs(value) {\n          // Don’t match this rule if the vertical align isn’t sub.\n          if (value !== 'sub') {\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 ['sub', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n  },\n\n  addCommands() {\n    return {\n      setSubscript:\n        () =>\n        ({ commands }) => {\n          return commands.setMark(this.name)\n        },\n      toggleSubscript:\n        () =>\n        ({ commands }) => {\n          return commands.toggleMark(this.name)\n        },\n      unsetSubscript:\n        () =>\n        ({ commands }) => {\n          return commands.unsetMark(this.name)\n        },\n    }\n  },\n\n  addKeyboardShortcuts() {\n    return {\n      'Mod-,': () => this.editor.commands.toggleSubscript(),\n    }\n  },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAsC;AAsC/B,IAAM,YAAY,iBAAK,OAAkC;AAAA,EAC9D,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,OAAO;AACnB,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,cACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,SAAS,QAAQ,KAAK,IAAI;AAAA,MACnC;AAAA,MACF,iBACE,MACA,CAAC,EAAE,SAAS,MAAM;AAChB,eAAO,SAAS,WAAW,KAAK,IAAI;AAAA,MACtC;AAAA,MACF,gBACE,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,gBAAgB;AAAA,IACtD;AAAA,EACF;AACF,CAAC;;;AD5FD,IAAO,gBAAQ;","names":[]}