@tiptap/extension-highlight 3.0.0-next.0 → 3.0.0-next.1

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 (171) hide show
  1. package/dist/index.cjs +110 -91
  2. package/dist/index.cjs.map +1 -1
  3. package/dist/{packages/extension-highlight/src/highlight.d.ts → index.d.cts} +7 -4
  4. package/dist/index.d.ts +58 -0
  5. package/dist/index.js +88 -86
  6. package/dist/index.js.map +1 -1
  7. package/package.json +6 -8
  8. package/dist/index.umd.js +0 -101
  9. package/dist/index.umd.js.map +0 -1
  10. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  11. package/dist/packages/core/src/Editor.d.ts +0 -159
  12. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  13. package/dist/packages/core/src/Extension.d.ts +0 -343
  14. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  15. package/dist/packages/core/src/InputRule.d.ts +0 -42
  16. package/dist/packages/core/src/Mark.d.ts +0 -451
  17. package/dist/packages/core/src/Node.d.ts +0 -611
  18. package/dist/packages/core/src/NodePos.d.ts +0 -44
  19. package/dist/packages/core/src/NodeView.d.ts +0 -31
  20. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  21. package/dist/packages/core/src/Tracker.d.ts +0 -11
  22. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  23. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  24. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  25. package/dist/packages/core/src/commands/command.d.ts +0 -18
  26. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  27. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  28. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  29. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  30. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  31. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  32. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  33. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  34. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  35. package/dist/packages/core/src/commands/first.d.ts +0 -14
  36. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  37. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  38. package/dist/packages/core/src/commands/index.d.ts +0 -55
  39. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  40. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  41. package/dist/packages/core/src/commands/join.d.ts +0 -41
  42. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  43. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  44. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  45. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  46. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  47. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  48. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  49. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  50. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  51. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  52. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  53. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  54. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  55. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  56. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  57. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  58. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  59. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  60. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  61. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  62. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  63. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  64. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  65. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  66. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  67. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  68. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  69. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  70. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  71. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  72. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  73. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  74. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  75. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  76. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  77. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  78. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  79. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  80. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  81. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  82. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  83. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  84. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  85. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  86. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  87. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  88. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  89. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  90. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  91. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  92. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  93. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  94. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  95. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  96. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  97. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  98. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  99. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  100. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  101. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  102. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  103. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  104. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  105. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  106. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  107. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  108. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  109. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  110. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  111. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  112. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  113. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  114. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  115. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  116. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  117. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  118. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  119. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  120. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  121. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  122. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  123. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  124. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  125. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  126. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  127. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  128. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  129. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -8
  130. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  131. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  132. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  133. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  134. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  135. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  136. package/dist/packages/core/src/index.d.ts +0 -24
  137. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  138. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  139. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  140. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  141. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  142. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  143. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  144. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  145. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  146. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  147. package/dist/packages/core/src/style.d.ts +0 -1
  148. package/dist/packages/core/src/types.d.ts +0 -253
  149. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  150. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  151. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  152. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  153. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  154. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  155. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  156. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  157. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  158. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  159. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  160. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  161. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  162. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  163. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  164. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  165. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  166. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  167. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  168. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  169. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  170. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  171. package/dist/packages/extension-highlight/src/index.d.ts +0 -3
package/dist/index.cjs CHANGED
@@ -1,97 +1,116 @@
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 src_exports = {};
22
+ __export(src_exports, {
23
+ Highlight: () => Highlight,
24
+ default: () => src_default,
25
+ inputRegex: () => inputRegex,
26
+ pasteRegex: () => pasteRegex
27
+ });
28
+ module.exports = __toCommonJS(src_exports);
6
29
 
7
- /**
8
- * Matches a highlight to a ==highlight== on input.
9
- */
10
- const inputRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/;
11
- /**
12
- * Matches a highlight to a ==highlight== on paste.
13
- */
14
- const pasteRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;
15
- /**
16
- * This extension allows you to highlight text.
17
- * @see https://www.tiptap.dev/api/marks/highlight
18
- */
19
- const Highlight = core.Mark.create({
20
- name: 'highlight',
21
- addOptions() {
22
- return {
23
- multicolor: false,
24
- HTMLAttributes: {},
25
- };
26
- },
27
- addAttributes() {
28
- if (!this.options.multicolor) {
30
+ // src/highlight.ts
31
+ var import_core = require("@tiptap/core");
32
+ var inputRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/;
33
+ var pasteRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;
34
+ var Highlight = import_core.Mark.create({
35
+ name: "highlight",
36
+ addOptions() {
37
+ return {
38
+ multicolor: false,
39
+ HTMLAttributes: {}
40
+ };
41
+ },
42
+ addAttributes() {
43
+ if (!this.options.multicolor) {
44
+ return {};
45
+ }
46
+ return {
47
+ color: {
48
+ default: null,
49
+ parseHTML: (element) => element.getAttribute("data-color") || element.style.backgroundColor,
50
+ renderHTML: (attributes) => {
51
+ if (!attributes.color) {
29
52
  return {};
53
+ }
54
+ return {
55
+ "data-color": attributes.color,
56
+ style: `background-color: ${attributes.color}; color: inherit`
57
+ };
30
58
  }
31
- return {
32
- color: {
33
- default: null,
34
- parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,
35
- renderHTML: attributes => {
36
- if (!attributes.color) {
37
- return {};
38
- }
39
- return {
40
- 'data-color': attributes.color,
41
- style: `background-color: ${attributes.color}; color: inherit`,
42
- };
43
- },
44
- },
45
- };
46
- },
47
- parseHTML() {
48
- return [
49
- {
50
- tag: 'mark',
51
- },
52
- ];
53
- },
54
- renderHTML({ HTMLAttributes }) {
55
- return ['mark', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
56
- },
57
- addCommands() {
58
- return {
59
- setHighlight: attributes => ({ commands }) => {
60
- return commands.setMark(this.name, attributes);
61
- },
62
- toggleHighlight: attributes => ({ commands }) => {
63
- return commands.toggleMark(this.name, attributes);
64
- },
65
- unsetHighlight: () => ({ commands }) => {
66
- return commands.unsetMark(this.name);
67
- },
68
- };
69
- },
70
- addKeyboardShortcuts() {
71
- return {
72
- 'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),
73
- };
74
- },
75
- addInputRules() {
76
- return [
77
- core.markInputRule({
78
- find: inputRegex,
79
- type: this.type,
80
- }),
81
- ];
82
- },
83
- addPasteRules() {
84
- return [
85
- core.markPasteRule({
86
- find: pasteRegex,
87
- type: this.type,
88
- }),
89
- ];
90
- },
59
+ }
60
+ };
61
+ },
62
+ parseHTML() {
63
+ return [
64
+ {
65
+ tag: "mark"
66
+ }
67
+ ];
68
+ },
69
+ renderHTML({ HTMLAttributes }) {
70
+ return ["mark", (0, import_core.mergeAttributes)(this.options.HTMLAttributes, HTMLAttributes), 0];
71
+ },
72
+ addCommands() {
73
+ return {
74
+ setHighlight: (attributes) => ({ commands }) => {
75
+ return commands.setMark(this.name, attributes);
76
+ },
77
+ toggleHighlight: (attributes) => ({ commands }) => {
78
+ return commands.toggleMark(this.name, attributes);
79
+ },
80
+ unsetHighlight: () => ({ commands }) => {
81
+ return commands.unsetMark(this.name);
82
+ }
83
+ };
84
+ },
85
+ addKeyboardShortcuts() {
86
+ return {
87
+ "Mod-Shift-h": () => this.editor.commands.toggleHighlight()
88
+ };
89
+ },
90
+ addInputRules() {
91
+ return [
92
+ (0, import_core.markInputRule)({
93
+ find: inputRegex,
94
+ type: this.type
95
+ })
96
+ ];
97
+ },
98
+ addPasteRules() {
99
+ return [
100
+ (0, import_core.markPasteRule)({
101
+ find: pasteRegex,
102
+ type: this.type
103
+ })
104
+ ];
105
+ }
91
106
  });
92
107
 
93
- exports.Highlight = Highlight;
94
- exports.default = Highlight;
95
- exports.inputRegex = inputRegex;
96
- exports.pasteRegex = pasteRegex;
97
- //# sourceMappingURL=index.cjs.map
108
+ // src/index.ts
109
+ var src_default = Highlight;
110
+ // Annotate the CommonJS export names for ESM import in node:
111
+ 0 && (module.exports = {
112
+ Highlight,
113
+ inputRegex,
114
+ pasteRegex
115
+ });
116
+ //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/highlight.ts"],"sourcesContent":["import {\n Mark,\n markInputRule,\n markPasteRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface HighlightOptions {\n /**\n * Allow multiple highlight colors\n * @default false\n * @example true\n */\n multicolor: boolean,\n\n /**\n * HTML attributes to add to the highlight element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n highlight: {\n /**\n * Set a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.setHighlight({ color: 'red' })\n */\n setHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Toggle a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.toggleHighlight({ color: 'red' })\n */\n toggleHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Unset a highlight mark\n * @example editor.commands.unsetHighlight()\n */\n unsetHighlight: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a highlight to a ==highlight== on input.\n */\nexport const inputRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))$/\n\n/**\n * Matches a highlight to a ==highlight== on paste.\n */\nexport const pasteRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))/g\n\n/**\n * This extension allows you to highlight text.\n * @see https://www.tiptap.dev/api/marks/highlight\n */\nexport const Highlight = Mark.create<HighlightOptions>({\n name: 'highlight',\n\n addOptions() {\n return {\n multicolor: false,\n HTMLAttributes: {},\n }\n },\n\n addAttributes() {\n if (!this.options.multicolor) {\n return {}\n }\n\n return {\n color: {\n default: null,\n parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n 'data-color': attributes.color,\n style: `background-color: ${attributes.color}; color: inherit`,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'mark',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setHighlight: attributes => ({ commands }) => {\n return commands.setMark(this.name, attributes)\n },\n toggleHighlight: attributes => ({ commands }) => {\n return commands.toggleMark(this.name, attributes)\n },\n unsetHighlight: () => ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n"],"names":["Mark","mergeAttributes","markInputRule","markPasteRule"],"mappings":";;;;;;AA+CA;;AAEG;AACI,MAAM,UAAU,GAAG,+CAA8C;AAExE;;AAEG;AACI,MAAM,UAAU,GAAG,+CAA8C;AAExE;;;AAGG;AACU,MAAA,SAAS,GAAGA,SAAI,CAAC,MAAM,CAAmB;AACrD,IAAA,IAAI,EAAE,WAAW;IAEjB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,cAAc,EAAE,EAAE;SACnB,CAAA;KACF;IAED,aAAa,GAAA;AACX,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;AAC5B,YAAA,OAAO,EAAE,CAAA;SACV;QAED,OAAO;AACL,YAAA,KAAK,EAAE;AACL,gBAAA,OAAO,EAAE,IAAI;AACb,gBAAA,SAAS,EAAE,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe;gBACzF,UAAU,EAAE,UAAU,IAAG;AACvB,oBAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;AACrB,wBAAA,OAAO,EAAE,CAAA;qBACV;oBAED,OAAO;wBACL,YAAY,EAAE,UAAU,CAAC,KAAK;AAC9B,wBAAA,KAAK,EAAE,CAAA,kBAAA,EAAqB,UAAU,CAAC,KAAK,CAAkB,gBAAA,CAAA;qBAC/D,CAAA;iBACF;AACF,aAAA;SACF,CAAA;KACF;IAED,SAAS,GAAA;QACP,OAAO;AACL,YAAA;AACE,gBAAA,GAAG,EAAE,MAAM;AACZ,aAAA;SACF,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;AAC3B,QAAA,OAAO,CAAC,MAAM,EAAEC,oBAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KACjF;IAED,WAAW,GAAA;QACT,OAAO;YACL,YAAY,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAI;gBAC3C,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;aAC/C;YACD,eAAe,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAI;gBAC9C,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;aAClD;YACD,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;gBACrC,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACrC;SACF,CAAA;KACF;IAED,oBAAoB,GAAA;QAClB,OAAO;YACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE;SAC5D,CAAA;KACF;IAED,aAAa,GAAA;QACX,OAAO;AACL,YAAAC,kBAAa,CAAC;AACZ,gBAAA,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC;SACH,CAAA;KACF;IAED,aAAa,GAAA;QACX,OAAO;AACL,YAAAC,kBAAa,CAAC;AACZ,gBAAA,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC;SACH,CAAA;KACF;AACF,CAAA;;;;;;;"}
1
+ {"version":3,"sources":["../src/index.ts","../src/highlight.ts"],"sourcesContent":["import { Highlight } from './highlight.js'\n\nexport * from './highlight.js'\n\nexport default Highlight\n","import {\n Mark,\n markInputRule,\n markPasteRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface HighlightOptions {\n /**\n * Allow multiple highlight colors\n * @default false\n * @example true\n */\n multicolor: boolean,\n\n /**\n * HTML attributes to add to the highlight element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n highlight: {\n /**\n * Set a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.setHighlight({ color: 'red' })\n */\n setHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Toggle a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.toggleHighlight({ color: 'red' })\n */\n toggleHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Unset a highlight mark\n * @example editor.commands.unsetHighlight()\n */\n unsetHighlight: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a highlight to a ==highlight== on input.\n */\nexport const inputRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))$/\n\n/**\n * Matches a highlight to a ==highlight== on paste.\n */\nexport const pasteRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))/g\n\n/**\n * This extension allows you to highlight text.\n * @see https://www.tiptap.dev/api/marks/highlight\n */\nexport const Highlight = Mark.create<HighlightOptions>({\n name: 'highlight',\n\n addOptions() {\n return {\n multicolor: false,\n HTMLAttributes: {},\n }\n },\n\n addAttributes() {\n if (!this.options.multicolor) {\n return {}\n }\n\n return {\n color: {\n default: null,\n parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n 'data-color': attributes.color,\n style: `background-color: ${attributes.color}; color: inherit`,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'mark',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setHighlight: attributes => ({ commands }) => {\n return commands.setMark(this.name, attributes)\n },\n toggleHighlight: attributes => ({ commands }) => {\n return commands.toggleMark(this.name, attributes)\n },\n unsetHighlight: () => ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAKO;AA6CA,IAAM,aAAa;AAKnB,IAAM,aAAa;AAMnB,IAAM,YAAY,iBAAK,OAAyB;AAAA,EACrD,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,YAAY;AAAA,MACZ,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,QAAI,CAAC,KAAK,QAAQ,YAAY;AAC5B,aAAO,CAAC;AAAA,IACV;AAEA,WAAO;AAAA,MACL,OAAO;AAAA,QACL,SAAS;AAAA,QACT,WAAW,aAAW,QAAQ,aAAa,YAAY,KAAK,QAAQ,MAAM;AAAA,QAC1E,YAAY,gBAAc;AACxB,cAAI,CAAC,WAAW,OAAO;AACrB,mBAAO,CAAC;AAAA,UACV;AAEA,iBAAO;AAAA,YACL,cAAc,WAAW;AAAA,YACzB,OAAO,qBAAqB,WAAW,KAAK;AAAA,UAC9C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAY;AACV,WAAO;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,YAAQ,6BAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EACjF;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,cAAc,gBAAc,CAAC,EAAE,SAAS,MAAM;AAC5C,eAAO,SAAS,QAAQ,KAAK,MAAM,UAAU;AAAA,MAC/C;AAAA,MACA,iBAAiB,gBAAc,CAAC,EAAE,SAAS,MAAM;AAC/C,eAAO,SAAS,WAAW,KAAK,MAAM,UAAU;AAAA,MAClD;AAAA,MACA,gBAAgB,MAAM,CAAC,EAAE,SAAS,MAAM;AACtC,eAAO,SAAS,UAAU,KAAK,IAAI;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,WAAO;AAAA,MACL,eAAe,MAAM,KAAK,OAAO,SAAS,gBAAgB;AAAA,IAC5D;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,UACL,2BAAc;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,UACL,2BAAc;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;;;AD3ID,IAAO,cAAQ;","names":[]}
@@ -1,5 +1,6 @@
1
1
  import { Mark } from '@tiptap/core';
2
- export interface HighlightOptions {
2
+
3
+ interface HighlightOptions {
3
4
  /**
4
5
  * Allow multiple highlight colors
5
6
  * @default false
@@ -43,13 +44,15 @@ declare module '@tiptap/core' {
43
44
  /**
44
45
  * Matches a highlight to a ==highlight== on input.
45
46
  */
46
- export declare const inputRegex: RegExp;
47
+ declare const inputRegex: RegExp;
47
48
  /**
48
49
  * Matches a highlight to a ==highlight== on paste.
49
50
  */
50
- export declare const pasteRegex: RegExp;
51
+ declare const pasteRegex: RegExp;
51
52
  /**
52
53
  * This extension allows you to highlight text.
53
54
  * @see https://www.tiptap.dev/api/marks/highlight
54
55
  */
55
- export declare const Highlight: Mark<HighlightOptions, any>;
56
+ declare const Highlight: Mark<HighlightOptions, any>;
57
+
58
+ export { Highlight, type HighlightOptions, Highlight as default, inputRegex, pasteRegex };
@@ -0,0 +1,58 @@
1
+ import { Mark } from '@tiptap/core';
2
+
3
+ interface HighlightOptions {
4
+ /**
5
+ * Allow multiple highlight colors
6
+ * @default false
7
+ * @example true
8
+ */
9
+ multicolor: boolean;
10
+ /**
11
+ * HTML attributes to add to the highlight element.
12
+ * @default {}
13
+ * @example { class: 'foo' }
14
+ */
15
+ HTMLAttributes: Record<string, any>;
16
+ }
17
+ declare module '@tiptap/core' {
18
+ interface Commands<ReturnType> {
19
+ highlight: {
20
+ /**
21
+ * Set a highlight mark
22
+ * @param attributes The highlight attributes
23
+ * @example editor.commands.setHighlight({ color: 'red' })
24
+ */
25
+ setHighlight: (attributes?: {
26
+ color: string;
27
+ }) => ReturnType;
28
+ /**
29
+ * Toggle a highlight mark
30
+ * @param attributes The highlight attributes
31
+ * @example editor.commands.toggleHighlight({ color: 'red' })
32
+ */
33
+ toggleHighlight: (attributes?: {
34
+ color: string;
35
+ }) => ReturnType;
36
+ /**
37
+ * Unset a highlight mark
38
+ * @example editor.commands.unsetHighlight()
39
+ */
40
+ unsetHighlight: () => ReturnType;
41
+ };
42
+ }
43
+ }
44
+ /**
45
+ * Matches a highlight to a ==highlight== on input.
46
+ */
47
+ declare const inputRegex: RegExp;
48
+ /**
49
+ * Matches a highlight to a ==highlight== on paste.
50
+ */
51
+ declare const pasteRegex: RegExp;
52
+ /**
53
+ * This extension allows you to highlight text.
54
+ * @see https://www.tiptap.dev/api/marks/highlight
55
+ */
56
+ declare const Highlight: Mark<HighlightOptions, any>;
57
+
58
+ export { Highlight, type HighlightOptions, Highlight as default, inputRegex, pasteRegex };
package/dist/index.js CHANGED
@@ -1,90 +1,92 @@
1
- import { Mark, mergeAttributes, markInputRule, markPasteRule } from '@tiptap/core';
2
-
3
- /**
4
- * Matches a highlight to a ==highlight== on input.
5
- */
6
- const inputRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/;
7
- /**
8
- * Matches a highlight to a ==highlight== on paste.
9
- */
10
- const pasteRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;
11
- /**
12
- * This extension allows you to highlight text.
13
- * @see https://www.tiptap.dev/api/marks/highlight
14
- */
15
- const Highlight = Mark.create({
16
- name: 'highlight',
17
- addOptions() {
18
- return {
19
- multicolor: false,
20
- HTMLAttributes: {},
21
- };
22
- },
23
- addAttributes() {
24
- if (!this.options.multicolor) {
1
+ // src/highlight.ts
2
+ import {
3
+ Mark,
4
+ markInputRule,
5
+ markPasteRule,
6
+ mergeAttributes
7
+ } from "@tiptap/core";
8
+ var inputRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))$/;
9
+ var pasteRegex = /(?:^|\s)(==(?!\s+==)((?:[^=]+))==(?!\s+==))/g;
10
+ var Highlight = Mark.create({
11
+ name: "highlight",
12
+ addOptions() {
13
+ return {
14
+ multicolor: false,
15
+ HTMLAttributes: {}
16
+ };
17
+ },
18
+ addAttributes() {
19
+ if (!this.options.multicolor) {
20
+ return {};
21
+ }
22
+ return {
23
+ color: {
24
+ default: null,
25
+ parseHTML: (element) => element.getAttribute("data-color") || element.style.backgroundColor,
26
+ renderHTML: (attributes) => {
27
+ if (!attributes.color) {
25
28
  return {};
29
+ }
30
+ return {
31
+ "data-color": attributes.color,
32
+ style: `background-color: ${attributes.color}; color: inherit`
33
+ };
26
34
  }
27
- return {
28
- color: {
29
- default: null,
30
- parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,
31
- renderHTML: attributes => {
32
- if (!attributes.color) {
33
- return {};
34
- }
35
- return {
36
- 'data-color': attributes.color,
37
- style: `background-color: ${attributes.color}; color: inherit`,
38
- };
39
- },
40
- },
41
- };
42
- },
43
- parseHTML() {
44
- return [
45
- {
46
- tag: 'mark',
47
- },
48
- ];
49
- },
50
- renderHTML({ HTMLAttributes }) {
51
- return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
52
- },
53
- addCommands() {
54
- return {
55
- setHighlight: attributes => ({ commands }) => {
56
- return commands.setMark(this.name, attributes);
57
- },
58
- toggleHighlight: attributes => ({ commands }) => {
59
- return commands.toggleMark(this.name, attributes);
60
- },
61
- unsetHighlight: () => ({ commands }) => {
62
- return commands.unsetMark(this.name);
63
- },
64
- };
65
- },
66
- addKeyboardShortcuts() {
67
- return {
68
- 'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),
69
- };
70
- },
71
- addInputRules() {
72
- return [
73
- markInputRule({
74
- find: inputRegex,
75
- type: this.type,
76
- }),
77
- ];
78
- },
79
- addPasteRules() {
80
- return [
81
- markPasteRule({
82
- find: pasteRegex,
83
- type: this.type,
84
- }),
85
- ];
86
- },
35
+ }
36
+ };
37
+ },
38
+ parseHTML() {
39
+ return [
40
+ {
41
+ tag: "mark"
42
+ }
43
+ ];
44
+ },
45
+ renderHTML({ HTMLAttributes }) {
46
+ return ["mark", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
47
+ },
48
+ addCommands() {
49
+ return {
50
+ setHighlight: (attributes) => ({ commands }) => {
51
+ return commands.setMark(this.name, attributes);
52
+ },
53
+ toggleHighlight: (attributes) => ({ commands }) => {
54
+ return commands.toggleMark(this.name, attributes);
55
+ },
56
+ unsetHighlight: () => ({ commands }) => {
57
+ return commands.unsetMark(this.name);
58
+ }
59
+ };
60
+ },
61
+ addKeyboardShortcuts() {
62
+ return {
63
+ "Mod-Shift-h": () => this.editor.commands.toggleHighlight()
64
+ };
65
+ },
66
+ addInputRules() {
67
+ return [
68
+ markInputRule({
69
+ find: inputRegex,
70
+ type: this.type
71
+ })
72
+ ];
73
+ },
74
+ addPasteRules() {
75
+ return [
76
+ markPasteRule({
77
+ find: pasteRegex,
78
+ type: this.type
79
+ })
80
+ ];
81
+ }
87
82
  });
88
83
 
89
- export { Highlight, Highlight as default, inputRegex, pasteRegex };
90
- //# sourceMappingURL=index.js.map
84
+ // src/index.ts
85
+ var src_default = Highlight;
86
+ export {
87
+ Highlight,
88
+ src_default as default,
89
+ inputRegex,
90
+ pasteRegex
91
+ };
92
+ //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/highlight.ts"],"sourcesContent":["import {\n Mark,\n markInputRule,\n markPasteRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface HighlightOptions {\n /**\n * Allow multiple highlight colors\n * @default false\n * @example true\n */\n multicolor: boolean,\n\n /**\n * HTML attributes to add to the highlight element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n highlight: {\n /**\n * Set a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.setHighlight({ color: 'red' })\n */\n setHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Toggle a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.toggleHighlight({ color: 'red' })\n */\n toggleHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Unset a highlight mark\n * @example editor.commands.unsetHighlight()\n */\n unsetHighlight: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a highlight to a ==highlight== on input.\n */\nexport const inputRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))$/\n\n/**\n * Matches a highlight to a ==highlight== on paste.\n */\nexport const pasteRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))/g\n\n/**\n * This extension allows you to highlight text.\n * @see https://www.tiptap.dev/api/marks/highlight\n */\nexport const Highlight = Mark.create<HighlightOptions>({\n name: 'highlight',\n\n addOptions() {\n return {\n multicolor: false,\n HTMLAttributes: {},\n }\n },\n\n addAttributes() {\n if (!this.options.multicolor) {\n return {}\n }\n\n return {\n color: {\n default: null,\n parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n 'data-color': attributes.color,\n style: `background-color: ${attributes.color}; color: inherit`,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'mark',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setHighlight: attributes => ({ commands }) => {\n return commands.setMark(this.name, attributes)\n },\n toggleHighlight: attributes => ({ commands }) => {\n return commands.toggleMark(this.name, attributes)\n },\n unsetHighlight: () => ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n"],"names":[],"mappings":";;AA+CA;;AAEG;AACI,MAAM,UAAU,GAAG,+CAA8C;AAExE;;AAEG;AACI,MAAM,UAAU,GAAG,+CAA8C;AAExE;;;AAGG;AACU,MAAA,SAAS,GAAG,IAAI,CAAC,MAAM,CAAmB;AACrD,IAAA,IAAI,EAAE,WAAW;IAEjB,UAAU,GAAA;QACR,OAAO;AACL,YAAA,UAAU,EAAE,KAAK;AACjB,YAAA,cAAc,EAAE,EAAE;SACnB,CAAA;KACF;IAED,aAAa,GAAA;AACX,QAAA,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;AAC5B,YAAA,OAAO,EAAE,CAAA;SACV;QAED,OAAO;AACL,YAAA,KAAK,EAAE;AACL,gBAAA,OAAO,EAAE,IAAI;AACb,gBAAA,SAAS,EAAE,OAAO,IAAI,OAAO,CAAC,YAAY,CAAC,YAAY,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,eAAe;gBACzF,UAAU,EAAE,UAAU,IAAG;AACvB,oBAAA,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE;AACrB,wBAAA,OAAO,EAAE,CAAA;qBACV;oBAED,OAAO;wBACL,YAAY,EAAE,UAAU,CAAC,KAAK;AAC9B,wBAAA,KAAK,EAAE,CAAA,kBAAA,EAAqB,UAAU,CAAC,KAAK,CAAkB,gBAAA,CAAA;qBAC/D,CAAA;iBACF;AACF,aAAA;SACF,CAAA;KACF;IAED,SAAS,GAAA;QACP,OAAO;AACL,YAAA;AACE,gBAAA,GAAG,EAAE,MAAM;AACZ,aAAA;SACF,CAAA;KACF;IAED,UAAU,CAAC,EAAE,cAAc,EAAE,EAAA;AAC3B,QAAA,OAAO,CAAC,MAAM,EAAE,eAAe,CAAC,IAAI,CAAC,OAAO,CAAC,cAAc,EAAE,cAAc,CAAC,EAAE,CAAC,CAAC,CAAA;KACjF;IAED,WAAW,GAAA;QACT,OAAO;YACL,YAAY,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAI;gBAC3C,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;aAC/C;YACD,eAAe,EAAE,UAAU,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAI;gBAC9C,OAAO,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;aAClD;YACD,cAAc,EAAE,MAAM,CAAC,EAAE,QAAQ,EAAE,KAAI;gBACrC,OAAO,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;aACrC;SACF,CAAA;KACF;IAED,oBAAoB,GAAA;QAClB,OAAO;YACL,aAAa,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,eAAe,EAAE;SAC5D,CAAA;KACF;IAED,aAAa,GAAA;QACX,OAAO;AACL,YAAA,aAAa,CAAC;AACZ,gBAAA,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC;SACH,CAAA;KACF;IAED,aAAa,GAAA;QACX,OAAO;AACL,YAAA,aAAa,CAAC;AACZ,gBAAA,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,IAAI,CAAC,IAAI;aAChB,CAAC;SACH,CAAA;KACF;AACF,CAAA;;;;"}
1
+ {"version":3,"sources":["../src/highlight.ts","../src/index.ts"],"sourcesContent":["import {\n Mark,\n markInputRule,\n markPasteRule,\n mergeAttributes,\n} from '@tiptap/core'\n\nexport interface HighlightOptions {\n /**\n * Allow multiple highlight colors\n * @default false\n * @example true\n */\n multicolor: boolean,\n\n /**\n * HTML attributes to add to the highlight element.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>,\n}\n\ndeclare module '@tiptap/core' {\n interface Commands<ReturnType> {\n highlight: {\n /**\n * Set a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.setHighlight({ color: 'red' })\n */\n setHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Toggle a highlight mark\n * @param attributes The highlight attributes\n * @example editor.commands.toggleHighlight({ color: 'red' })\n */\n toggleHighlight: (attributes?: { color: string }) => ReturnType,\n /**\n * Unset a highlight mark\n * @example editor.commands.unsetHighlight()\n */\n unsetHighlight: () => ReturnType,\n }\n }\n}\n\n/**\n * Matches a highlight to a ==highlight== on input.\n */\nexport const inputRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))$/\n\n/**\n * Matches a highlight to a ==highlight== on paste.\n */\nexport const pasteRegex = /(?:^|\\s)(==(?!\\s+==)((?:[^=]+))==(?!\\s+==))/g\n\n/**\n * This extension allows you to highlight text.\n * @see https://www.tiptap.dev/api/marks/highlight\n */\nexport const Highlight = Mark.create<HighlightOptions>({\n name: 'highlight',\n\n addOptions() {\n return {\n multicolor: false,\n HTMLAttributes: {},\n }\n },\n\n addAttributes() {\n if (!this.options.multicolor) {\n return {}\n }\n\n return {\n color: {\n default: null,\n parseHTML: element => element.getAttribute('data-color') || element.style.backgroundColor,\n renderHTML: attributes => {\n if (!attributes.color) {\n return {}\n }\n\n return {\n 'data-color': attributes.color,\n style: `background-color: ${attributes.color}; color: inherit`,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'mark',\n },\n ]\n },\n\n renderHTML({ HTMLAttributes }) {\n return ['mark', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0]\n },\n\n addCommands() {\n return {\n setHighlight: attributes => ({ commands }) => {\n return commands.setMark(this.name, attributes)\n },\n toggleHighlight: attributes => ({ commands }) => {\n return commands.toggleMark(this.name, attributes)\n },\n unsetHighlight: () => ({ commands }) => {\n return commands.unsetMark(this.name)\n },\n }\n },\n\n addKeyboardShortcuts() {\n return {\n 'Mod-Shift-h': () => this.editor.commands.toggleHighlight(),\n }\n },\n\n addInputRules() {\n return [\n markInputRule({\n find: inputRegex,\n type: this.type,\n }),\n ]\n },\n\n addPasteRules() {\n return [\n markPasteRule({\n find: pasteRegex,\n type: this.type,\n }),\n ]\n },\n})\n","import { Highlight } from './highlight.js'\n\nexport * from './highlight.js'\n\nexport default Highlight\n"],"mappings":";AAAA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA6CA,IAAM,aAAa;AAKnB,IAAM,aAAa;AAMnB,IAAM,YAAY,KAAK,OAAyB;AAAA,EACrD,MAAM;AAAA,EAEN,aAAa;AACX,WAAO;AAAA,MACL,YAAY;AAAA,MACZ,gBAAgB,CAAC;AAAA,IACnB;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,QAAI,CAAC,KAAK,QAAQ,YAAY;AAC5B,aAAO,CAAC;AAAA,IACV;AAEA,WAAO;AAAA,MACL,OAAO;AAAA,QACL,SAAS;AAAA,QACT,WAAW,aAAW,QAAQ,aAAa,YAAY,KAAK,QAAQ,MAAM;AAAA,QAC1E,YAAY,gBAAc;AACxB,cAAI,CAAC,WAAW,OAAO;AACrB,mBAAO,CAAC;AAAA,UACV;AAEA,iBAAO;AAAA,YACL,cAAc,WAAW;AAAA,YACzB,OAAO,qBAAqB,WAAW,KAAK;AAAA,UAC9C;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA,EACF;AAAA,EAEA,YAAY;AACV,WAAO;AAAA,MACL;AAAA,QACE,KAAK;AAAA,MACP;AAAA,IACF;AAAA,EACF;AAAA,EAEA,WAAW,EAAE,eAAe,GAAG;AAC7B,WAAO,CAAC,QAAQ,gBAAgB,KAAK,QAAQ,gBAAgB,cAAc,GAAG,CAAC;AAAA,EACjF;AAAA,EAEA,cAAc;AACZ,WAAO;AAAA,MACL,cAAc,gBAAc,CAAC,EAAE,SAAS,MAAM;AAC5C,eAAO,SAAS,QAAQ,KAAK,MAAM,UAAU;AAAA,MAC/C;AAAA,MACA,iBAAiB,gBAAc,CAAC,EAAE,SAAS,MAAM;AAC/C,eAAO,SAAS,WAAW,KAAK,MAAM,UAAU;AAAA,MAClD;AAAA,MACA,gBAAgB,MAAM,CAAC,EAAE,SAAS,MAAM;AACtC,eAAO,SAAS,UAAU,KAAK,IAAI;AAAA,MACrC;AAAA,IACF;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,WAAO;AAAA,MACL,eAAe,MAAM,KAAK,OAAO,SAAS,gBAAgB;AAAA,IAC5D;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,MACL,cAAc;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AAAA,EAEA,gBAAgB;AACd,WAAO;AAAA,MACL,cAAc;AAAA,QACZ,MAAM;AAAA,QACN,MAAM,KAAK;AAAA,MACb,CAAC;AAAA,IACH;AAAA,EACF;AACF,CAAC;;;AC3ID,IAAO,cAAQ;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-highlight",
3
3
  "description": "highlight extension for tiptap",
4
- "version": "3.0.0-next.0",
4
+ "version": "3.0.0-next.1",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -15,24 +15,23 @@
15
15
  "type": "module",
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/packages/extension-highlight/src/index.d.ts",
18
+ "types": "./dist/index.d.ts",
19
19
  "import": "./dist/index.js",
20
20
  "require": "./dist/index.cjs"
21
21
  }
22
22
  },
23
23
  "main": "dist/index.cjs",
24
24
  "module": "dist/index.js",
25
- "umd": "dist/index.umd.js",
26
- "types": "dist/packages/extension-highlight/src/index.d.ts",
25
+ "types": "dist/index.d.ts",
27
26
  "files": [
28
27
  "src",
29
28
  "dist"
30
29
  ],
31
30
  "devDependencies": {
32
- "@tiptap/core": "^3.0.0-next.0"
31
+ "@tiptap/core": "^3.0.0-next.1"
33
32
  },
34
33
  "peerDependencies": {
35
- "@tiptap/core": "^3.0.0-next.0"
34
+ "@tiptap/core": "^3.0.0-next.1"
36
35
  },
37
36
  "repository": {
38
37
  "type": "git",
@@ -40,7 +39,6 @@
40
39
  "directory": "packages/extension-highlight"
41
40
  },
42
41
  "scripts": {
43
- "clean": "rm -rf dist",
44
- "build": "npm run clean && rollup -c"
42
+ "build": "tsup"
45
43
  }
46
44
  }