@tiptap/extension-superscript 3.0.0 → 3.0.2-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (174) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +5 -1
  3. package/dist/index.cjs +78 -57
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/{packages/extension-superscript/src/superscript.d.ts → index.d.cts} +6 -3
  6. package/dist/index.d.ts +38 -0
  7. package/dist/index.js +53 -54
  8. package/dist/index.js.map +1 -1
  9. package/package.json +13 -9
  10. package/src/superscript.ts +20 -14
  11. package/dist/index.umd.js +0 -65
  12. package/dist/index.umd.js.map +0 -1
  13. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  14. package/dist/packages/core/src/Editor.d.ts +0 -161
  15. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  16. package/dist/packages/core/src/Extension.d.ts +0 -343
  17. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  18. package/dist/packages/core/src/InputRule.d.ts +0 -42
  19. package/dist/packages/core/src/Mark.d.ts +0 -451
  20. package/dist/packages/core/src/Node.d.ts +0 -611
  21. package/dist/packages/core/src/NodePos.d.ts +0 -44
  22. package/dist/packages/core/src/NodeView.d.ts +0 -31
  23. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  24. package/dist/packages/core/src/Tracker.d.ts +0 -11
  25. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  26. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  27. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  28. package/dist/packages/core/src/commands/command.d.ts +0 -18
  29. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  30. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  31. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  32. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  33. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  34. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  35. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  36. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  37. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  38. package/dist/packages/core/src/commands/first.d.ts +0 -14
  39. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  40. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  41. package/dist/packages/core/src/commands/index.d.ts +0 -55
  42. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  43. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  44. package/dist/packages/core/src/commands/join.d.ts +0 -41
  45. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  46. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  47. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  48. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  49. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  50. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  51. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  52. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  53. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  54. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  55. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  56. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  57. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  58. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  59. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  60. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  61. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  62. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  63. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  64. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  65. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  66. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  67. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  68. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  69. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  70. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  71. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  72. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  73. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  74. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  75. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  76. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  77. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  78. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  79. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  80. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  81. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  82. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  83. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  84. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  85. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  86. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  87. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  88. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  89. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  90. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  91. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  92. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  93. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  94. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  95. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  96. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  97. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  98. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  99. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  100. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  101. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  102. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  103. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  104. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  105. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  106. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  107. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  108. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  109. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  110. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  111. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  112. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  113. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  114. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  115. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  116. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  117. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  118. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  119. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  120. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  121. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  122. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  123. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  124. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  125. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  126. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  127. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  128. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  129. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  130. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  131. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  132. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
  133. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  134. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  135. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  136. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  137. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  138. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  139. package/dist/packages/core/src/index.d.ts +0 -24
  140. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  141. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  142. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  143. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  144. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  145. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  146. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  147. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  148. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  149. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  150. package/dist/packages/core/src/style.d.ts +0 -1
  151. package/dist/packages/core/src/types.d.ts +0 -255
  152. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  153. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  154. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  155. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  156. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  157. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  158. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  159. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  160. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  161. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  162. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  163. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  164. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  165. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  166. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  167. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  168. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  169. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  170. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  171. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  172. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  173. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  174. package/dist/packages/extension-superscript/src/index.d.ts +0 -3
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025, Tiptap GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,14 +1,18 @@
1
1
  # @tiptap/extension-superscript
2
+
2
3
  [![Version](https://img.shields.io/npm/v/@tiptap/extension-superscript.svg?label=version)](https://www.npmjs.com/package/@tiptap/extension-superscript)
3
4
  [![Downloads](https://img.shields.io/npm/dm/@tiptap/extension-superscript.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
4
5
  [![License](https://img.shields.io/npm/l/@tiptap/extension-superscript.svg)](https://www.npmjs.com/package/@tiptap/extension-superscript)
5
6
  [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
7
 
7
8
  ## Introduction
8
- Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
9
+
10
+ Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_.
9
11
 
10
12
  ## Official Documentation
13
+
11
14
  Documentation can be found on the [Tiptap website](https://tiptap.dev).
12
15
 
13
16
  ## License
17
+
14
18
  Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
package/dist/index.cjs CHANGED
@@ -1,61 +1,82 @@
1
- 'use strict';
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
2
19
 
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var core = require('@tiptap/core');
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ Superscript: () => Superscript,
24
+ default: () => index_default
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
6
27
 
7
- /**
8
- * This extension allows you to create superscript text.
9
- * @see https://www.tiptap.dev/api/marks/superscript
10
- */
11
- const Superscript = core.Mark.create({
12
- name: 'superscript',
13
- addOptions() {
14
- return {
15
- HTMLAttributes: {},
16
- };
17
- },
18
- parseHTML() {
19
- return [
20
- {
21
- tag: 'sup',
22
- },
23
- {
24
- style: 'vertical-align',
25
- getAttrs(value) {
26
- // Don’t match this rule if the vertical align isn’t super.
27
- if (value !== 'super') {
28
- return false;
29
- }
30
- // If it falls through we’ll match, and this mark will be applied.
31
- return null;
32
- },
33
- },
34
- ];
35
- },
36
- renderHTML({ HTMLAttributes }) {
37
- return ['sup', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
38
- },
39
- addCommands() {
40
- return {
41
- setSuperscript: () => ({ commands }) => {
42
- return commands.setMark(this.name);
43
- },
44
- toggleSuperscript: () => ({ commands }) => {
45
- return commands.toggleMark(this.name);
46
- },
47
- unsetSuperscript: () => ({ commands }) => {
48
- return commands.unsetMark(this.name);
49
- },
50
- };
51
- },
52
- addKeyboardShortcuts() {
53
- return {
54
- 'Mod-.': () => this.editor.commands.toggleSuperscript(),
55
- };
56
- },
28
+ // src/superscript.ts
29
+ var import_core = require("@tiptap/core");
30
+ var Superscript = import_core.Mark.create({
31
+ name: "superscript",
32
+ addOptions() {
33
+ return {
34
+ HTMLAttributes: {}
35
+ };
36
+ },
37
+ parseHTML() {
38
+ return [
39
+ {
40
+ tag: "sup"
41
+ },
42
+ {
43
+ style: "vertical-align",
44
+ getAttrs(value) {
45
+ if (value !== "super") {
46
+ return false;
47
+ }
48
+ return null;
49
+ }
50
+ }
51
+ ];
52
+ },
53
+ renderHTML({ HTMLAttributes }) {
54
+ return ["sup", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
55
+ },
56
+ addCommands() {
57
+ return {
58
+ setSuperscript: () => ({ commands }) => {
59
+ return commands.setMark(this.name);
60
+ },
61
+ toggleSuperscript: () => ({ commands }) => {
62
+ return commands.toggleMark(this.name);
63
+ },
64
+ unsetSuperscript: () => ({ commands }) => {
65
+ return commands.unsetMark(this.name);
66
+ }
67
+ };
68
+ },
69
+ addKeyboardShortcuts() {
70
+ return {
71
+ "Mod-.": () => this.editor.commands.toggleSuperscript()
72
+ };
73
+ }
57
74
  });
58
75
 
59
- exports.Superscript = Superscript;
60
- exports.default = Superscript;
61
- //# sourceMappingURL=index.cjs.map
76
+ // src/index.ts
77
+ var index_default = Superscript;
78
+ // Annotate the CommonJS export names for ESM import in node:
79
+ 0 && (module.exports = {
80
+ Superscript
81
+ });
82
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/superscript.ts"],"sourcesContent":["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: Object,\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 } satisfies StyleParseRule,\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['sup', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setSuperscript: () => ({ commands }) => {\n return commands.setMark(this.name)\n },\n toggleSuperscript: () => ({ commands }) => {\n return commands.toggleMark(this.name)\n },\n unsetSuperscript: () => ({ 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"],"names":["Mark","mergeAttributes"],"mappings":";;;;;;AAkCA;;;AAGG;AACU,MAAA,WAAW,GAAGA,SAAI,CAAC,MAAM,CAA8B;AAClE,IAAA,IAAI,EAAE,aAAa;IAEnB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,cAAc,EAAE,EAAE;SACnB,CAAA;KACF;IAED,SAAS,GAAA;QACP,OAAO;AACL,YAAA;AACE,gBAAA,GAAG,EAAE,KAAK;AACX,aAAA;AACD,YAAA;AACE,gBAAA,KAAK,EAAE,gBAAgB;AACvB,gBAAA,QAAQ,CAAC,KAAK,EAAA;;AAEZ,oBAAA,IAAI,KAAK,KAAK,OAAO,EAAE;AACrB,wBAAA,OAAO,KAAK,CAAA;qBACb;;AAGD,oBAAA,OAAO,IAAI,CAAA;iBACZ;AACuB,aAAA;SAC3B,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;AAC3B,QAAA,OAAO,CAAC,KAAK,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KAChF;IAED,WAAW,GAAA;QACT,OAAO;YACL,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;gBACrC,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACnC;YACD,iBAAiB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;gBACxC,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACtC;YACD,gBAAgB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;gBACvC,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACrC;SACF,CAAA;KACF;IAED,oBAAoB,GAAA;QAClB,OAAO;YACL,OAAO,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,EAAE;SACxD,CAAA;KACF;AACF,CAAA;;;;;"}
1
+ {"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":[]}
@@ -1,11 +1,12 @@
1
1
  import { Mark } from '@tiptap/core';
2
- export interface SuperscriptExtensionOptions {
2
+
3
+ interface SuperscriptExtensionOptions {
3
4
  /**
4
5
  * HTML attributes to add to the superscript element.
5
6
  * @default {}
6
7
  * @example { class: 'foo' }
7
8
  */
8
- HTMLAttributes: Object;
9
+ HTMLAttributes: Record<string, any>;
9
10
  }
10
11
  declare module '@tiptap/core' {
11
12
  interface Commands<ReturnType> {
@@ -32,4 +33,6 @@ declare module '@tiptap/core' {
32
33
  * This extension allows you to create superscript text.
33
34
  * @see https://www.tiptap.dev/api/marks/superscript
34
35
  */
35
- export declare const Superscript: Mark<SuperscriptExtensionOptions, any>;
36
+ declare const Superscript: Mark<SuperscriptExtensionOptions, any>;
37
+
38
+ export { Superscript, type SuperscriptExtensionOptions, Superscript as default };
@@ -0,0 +1,38 @@
1
+ import { Mark } from '@tiptap/core';
2
+
3
+ interface SuperscriptExtensionOptions {
4
+ /**
5
+ * HTML attributes to add to the superscript element.
6
+ * @default {}
7
+ * @example { class: 'foo' }
8
+ */
9
+ HTMLAttributes: Record<string, any>;
10
+ }
11
+ declare module '@tiptap/core' {
12
+ interface Commands<ReturnType> {
13
+ superscript: {
14
+ /**
15
+ * Set a superscript mark
16
+ * @example editor.commands.setSuperscript()
17
+ */
18
+ setSuperscript: () => ReturnType;
19
+ /**
20
+ * Toggle a superscript mark
21
+ * @example editor.commands.toggleSuperscript()
22
+ */
23
+ toggleSuperscript: () => ReturnType;
24
+ /**
25
+ * Unset a superscript mark
26
+ * @example editor.commands.unsetSuperscript()
27
+ */
28
+ unsetSuperscript: () => ReturnType;
29
+ };
30
+ }
31
+ }
32
+ /**
33
+ * This extension allows you to create superscript text.
34
+ * @see https://www.tiptap.dev/api/marks/superscript
35
+ */
36
+ declare const Superscript: Mark<SuperscriptExtensionOptions, any>;
37
+
38
+ export { Superscript, type SuperscriptExtensionOptions, Superscript as default };
package/dist/index.js CHANGED
@@ -1,56 +1,55 @@
1
- import { Mark, mergeAttributes } from '@tiptap/core';
2
-
3
- /**
4
- * This extension allows you to create superscript text.
5
- * @see https://www.tiptap.dev/api/marks/superscript
6
- */
7
- const Superscript = Mark.create({
8
- name: 'superscript',
9
- addOptions() {
10
- return {
11
- HTMLAttributes: {},
12
- };
13
- },
14
- parseHTML() {
15
- return [
16
- {
17
- tag: 'sup',
18
- },
19
- {
20
- style: 'vertical-align',
21
- getAttrs(value) {
22
- // Don’t match this rule if the vertical align isn’t super.
23
- if (value !== 'super') {
24
- return false;
25
- }
26
- // If it falls through we’ll match, and this mark will be applied.
27
- return null;
28
- },
29
- },
30
- ];
31
- },
32
- renderHTML({ HTMLAttributes }) {
33
- return ['sup', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
34
- },
35
- addCommands() {
36
- return {
37
- setSuperscript: () => ({ commands }) => {
38
- return commands.setMark(this.name);
39
- },
40
- toggleSuperscript: () => ({ commands }) => {
41
- return commands.toggleMark(this.name);
42
- },
43
- unsetSuperscript: () => ({ commands }) => {
44
- return commands.unsetMark(this.name);
45
- },
46
- };
47
- },
48
- addKeyboardShortcuts() {
49
- return {
50
- 'Mod-.': () => this.editor.commands.toggleSuperscript(),
51
- };
52
- },
1
+ // src/superscript.ts
2
+ import { Mark, mergeAttributes } from "@tiptap/core";
3
+ var Superscript = Mark.create({
4
+ name: "superscript",
5
+ addOptions() {
6
+ return {
7
+ HTMLAttributes: {}
8
+ };
9
+ },
10
+ parseHTML() {
11
+ return [
12
+ {
13
+ tag: "sup"
14
+ },
15
+ {
16
+ style: "vertical-align",
17
+ getAttrs(value) {
18
+ if (value !== "super") {
19
+ return false;
20
+ }
21
+ return null;
22
+ }
23
+ }
24
+ ];
25
+ },
26
+ renderHTML({ HTMLAttributes }) {
27
+ return ["sup", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
28
+ },
29
+ addCommands() {
30
+ return {
31
+ setSuperscript: () => ({ commands }) => {
32
+ return commands.setMark(this.name);
33
+ },
34
+ toggleSuperscript: () => ({ commands }) => {
35
+ return commands.toggleMark(this.name);
36
+ },
37
+ unsetSuperscript: () => ({ commands }) => {
38
+ return commands.unsetMark(this.name);
39
+ }
40
+ };
41
+ },
42
+ addKeyboardShortcuts() {
43
+ return {
44
+ "Mod-.": () => this.editor.commands.toggleSuperscript()
45
+ };
46
+ }
53
47
  });
54
48
 
55
- export { Superscript, Superscript as default };
56
- //# sourceMappingURL=index.js.map
49
+ // src/index.ts
50
+ var index_default = Superscript;
51
+ export {
52
+ Superscript,
53
+ index_default as default
54
+ };
55
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/superscript.ts"],"sourcesContent":["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: Object,\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 } satisfies StyleParseRule,\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['sup', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setSuperscript: () => ({ commands }) => {\n return commands.setMark(this.name)\n },\n toggleSuperscript: () => ({ commands }) => {\n return commands.toggleMark(this.name)\n },\n unsetSuperscript: () => ({ 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"],"names":[],"mappings":";;AAkCA;;;AAGG;AACU,MAAA,WAAW,GAAG,IAAI,CAAC,MAAM,CAA8B;AAClE,IAAA,IAAI,EAAE,aAAa;IAEnB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,cAAc,EAAE,EAAE;SACnB,CAAA;KACF;IAED,SAAS,GAAA;QACP,OAAO;AACL,YAAA;AACE,gBAAA,GAAG,EAAE,KAAK;AACX,aAAA;AACD,YAAA;AACE,gBAAA,KAAK,EAAE,gBAAgB;AACvB,gBAAA,QAAQ,CAAC,KAAK,EAAA;;AAEZ,oBAAA,IAAI,KAAK,KAAK,OAAO,EAAE;AACrB,wBAAA,OAAO,KAAK,CAAA;qBACb;;AAGD,oBAAA,OAAO,IAAI,CAAA;iBACZ;AACuB,aAAA;SAC3B,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;AAC3B,QAAA,OAAO,CAAC,KAAK,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KAChF;IAED,WAAW,GAAA;QACT,OAAO;YACL,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;gBACrC,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACnC;YACD,iBAAiB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;gBACxC,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACtC;YACD,gBAAgB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;gBACvC,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACrC;SACF,CAAA;KACF;IAED,oBAAoB,GAAA;QAClB,OAAO;YACL,OAAO,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,EAAE;SACxD,CAAA;KACF;AACF,CAAA;;;;"}
1
+ {"version":3,"sources":["../src/superscript.ts","../src/index.ts"],"sourcesContent":["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","import { Superscript } from './superscript.js'\n\nexport * from './superscript.js'\n\nexport default Superscript\n"],"mappings":";AAAA,SAAS,MAAM,uBAAuB;AAsC/B,IAAM,cAAc,KAAK,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,OAAO,gBAAgB,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;;;AC5FD,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-superscript",
3
3
  "description": "superscript extension for tiptap",
4
- "version": "3.0.0",
4
+ "version": "3.0.2-beta.0",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -15,24 +15,28 @@
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/packages/extension-superscript/src/index.d.ts",
18
+ "types": {
19
+ "import": "./dist/index.d.ts",
20
+ "require": "./dist/index.d.cts"
21
+ },
19
22
  "import": "./dist/index.js",
20
23
  "require": "./dist/index.cjs"
21
24
  }
22
25
  },
23
26
  "main": "dist/index.cjs",
24
27
  "module": "dist/index.js",
25
- "umd": "dist/index.umd.js",
26
- "types": "dist/packages/extension-superscript/src/index.d.ts",
28
+ "types": "dist/index.d.ts",
27
29
  "files": [
28
30
  "src",
29
31
  "dist"
30
32
  ],
31
33
  "devDependencies": {
32
- "@tiptap/core": "^3.0.0"
34
+ "@tiptap/core": "^3.0.2-beta.0",
35
+ "@tiptap/pm": "^3.0.2-beta.0"
33
36
  },
34
37
  "peerDependencies": {
35
- "@tiptap/core": "^3.0.0"
38
+ "@tiptap/core": "^3.0.2-beta.0",
39
+ "@tiptap/pm": "^3.0.2-beta.0"
36
40
  },
37
41
  "repository": {
38
42
  "type": "git",
@@ -40,7 +44,7 @@
40
44
  "directory": "packages/extension-superscript"
41
45
  },
42
46
  "scripts": {
43
- "clean": "rm -rf dist",
44
- "build": "npm run clean && rollup -c"
47
+ "build": "tsup",
48
+ "lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
45
49
  }
46
- }
50
+ }
@@ -7,7 +7,7 @@ export interface SuperscriptExtensionOptions {
7
7
  * @default {}
8
8
  * @example { class: 'foo' }
9
9
  */
10
- HTMLAttributes: Object,
10
+ HTMLAttributes: Record<string, any>
11
11
  }
12
12
 
13
13
  declare module '@tiptap/core' {
@@ -17,17 +17,17 @@ declare module '@tiptap/core' {
17
17
  * Set a superscript mark
18
18
  * @example editor.commands.setSuperscript()
19
19
  */
20
- setSuperscript: () => ReturnType,
20
+ setSuperscript: () => ReturnType
21
21
  /**
22
22
  * Toggle a superscript mark
23
23
  * @example editor.commands.toggleSuperscript()
24
24
  */
25
- toggleSuperscript: () => ReturnType,
25
+ toggleSuperscript: () => ReturnType
26
26
  /**
27
27
  * Unset a superscript mark
28
28
  * @example editor.commands.unsetSuperscript()
29
29
  */
30
- unsetSuperscript: () => ReturnType,
30
+ unsetSuperscript: () => ReturnType
31
31
  }
32
32
  }
33
33
  }
@@ -61,7 +61,7 @@ export const Superscript = Mark.create<SuperscriptExtensionOptions>({
61
61
  // If it falls through we’ll match, and this mark will be applied.
62
62
  return null
63
63
  },
64
- } satisfies StyleParseRule,
64
+ } as StyleParseRule,
65
65
  ]
66
66
  },
67
67
 
@@ -71,15 +71,21 @@ export const Superscript = Mark.create<SuperscriptExtensionOptions>({
71
71
 
72
72
  addCommands() {
73
73
  return {
74
- setSuperscript: () => ({ commands }) => {
75
- return commands.setMark(this.name)
76
- },
77
- toggleSuperscript: () => ({ commands }) => {
78
- return commands.toggleMark(this.name)
79
- },
80
- unsetSuperscript: () => ({ commands }) => {
81
- return commands.unsetMark(this.name)
82
- },
74
+ setSuperscript:
75
+ () =>
76
+ ({ commands }) => {
77
+ return commands.setMark(this.name)
78
+ },
79
+ toggleSuperscript:
80
+ () =>
81
+ ({ commands }) => {
82
+ return commands.toggleMark(this.name)
83
+ },
84
+ unsetSuperscript:
85
+ () =>
86
+ ({ commands }) => {
87
+ return commands.unsetMark(this.name)
88
+ },
83
89
  }
84
90
  },
85
91
 
package/dist/index.umd.js DELETED
@@ -1,65 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-superscript"] = {}, global.core));
5
- })(this, (function (exports, core) { 'use strict';
6
-
7
- /**
8
- * This extension allows you to create superscript text.
9
- * @see https://www.tiptap.dev/api/marks/superscript
10
- */
11
- const Superscript = core.Mark.create({
12
- name: 'superscript',
13
- addOptions() {
14
- return {
15
- HTMLAttributes: {},
16
- };
17
- },
18
- parseHTML() {
19
- return [
20
- {
21
- tag: 'sup',
22
- },
23
- {
24
- style: 'vertical-align',
25
- getAttrs(value) {
26
- // Don’t match this rule if the vertical align isn’t super.
27
- if (value !== 'super') {
28
- return false;
29
- }
30
- // If it falls through we’ll match, and this mark will be applied.
31
- return null;
32
- },
33
- },
34
- ];
35
- },
36
- renderHTML({ HTMLAttributes }) {
37
- return ['sup', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
38
- },
39
- addCommands() {
40
- return {
41
- setSuperscript: () => ({ commands }) => {
42
- return commands.setMark(this.name);
43
- },
44
- toggleSuperscript: () => ({ commands }) => {
45
- return commands.toggleMark(this.name);
46
- },
47
- unsetSuperscript: () => ({ commands }) => {
48
- return commands.unsetMark(this.name);
49
- },
50
- };
51
- },
52
- addKeyboardShortcuts() {
53
- return {
54
- 'Mod-.': () => this.editor.commands.toggleSuperscript(),
55
- };
56
- },
57
- });
58
-
59
- exports.Superscript = Superscript;
60
- exports.default = Superscript;
61
-
62
- Object.defineProperty(exports, '__esModule', { value: true });
63
-
64
- }));
65
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/superscript.ts"],"sourcesContent":["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: Object,\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 } satisfies StyleParseRule,\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['sup', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setSuperscript: () => ({ commands }) => {\n return commands.setMark(this.name)\n },\n toggleSuperscript: () => ({ commands }) => {\n return commands.toggleMark(this.name)\n },\n unsetSuperscript: () => ({ 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"],"names":["Mark","mergeAttributes"],"mappings":";;;;;;EAkCA;;;EAGG;AACU,QAAA,WAAW,GAAGA,SAAI,CAAC,MAAM,CAA8B;EAClE,IAAA,IAAI,EAAE,aAAa;MAEnB,UAAU,GAAA;UACR,OAAO;EACL,YAAA,cAAc,EAAE,EAAE;WACnB,CAAA;OACF;MAED,SAAS,GAAA;UACP,OAAO;EACL,YAAA;EACE,gBAAA,GAAG,EAAE,KAAK;EACX,aAAA;EACD,YAAA;EACE,gBAAA,KAAK,EAAE,gBAAgB;EACvB,gBAAA,QAAQ,CAAC,KAAK,EAAA;;EAEZ,oBAAA,IAAI,KAAK,KAAK,OAAO,EAAE;EACrB,wBAAA,OAAO,KAAK,CAAA;uBACb;;EAGD,oBAAA,OAAO,IAAI,CAAA;mBACZ;EACuB,aAAA;WAC3B,CAAA;OACF;MAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;EAC3B,QAAA,OAAO,CAAC,KAAK,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;OAChF;MAED,WAAW,GAAA;UACT,OAAO;cACL,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;kBACrC,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;eACnC;cACD,iBAAiB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;kBACxC,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;eACtC;cACD,gBAAgB,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;kBACvC,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;eACrC;WACF,CAAA;OACF;MAED,oBAAoB,GAAA;UAClB,OAAO;cACL,OAAO,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,iBAAiB,EAAE;WACxD,CAAA;OACF;EACF,CAAA;;;;;;;;;;;"}
@@ -1,20 +0,0 @@
1
- import { EditorState, Transaction } from '@tiptap/pm/state';
2
- import { Editor } from './Editor.js';
3
- import { AnyCommands, CanCommands, ChainedCommands, CommandProps, SingleCommands } from './types.js';
4
- export declare class CommandManager {
5
- editor: Editor;
6
- rawCommands: AnyCommands;
7
- customState?: EditorState;
8
- constructor(props: {
9
- editor: Editor;
10
- state?: EditorState;
11
- });
12
- get hasCustomState(): boolean;
13
- get state(): EditorState;
14
- get commands(): SingleCommands;
15
- get chain(): () => ChainedCommands;
16
- get can(): () => CanCommands;
17
- createChain(startTr?: Transaction, shouldDispatch?: boolean): ChainedCommands;
18
- createCan(startTr?: Transaction): CanCommands;
19
- buildProps(tr: Transaction, shouldDispatch?: boolean): CommandProps;
20
- }