@tiptap/extension-mention 3.0.0 → 3.0.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 (178) hide show
  1. package/LICENSE.md +21 -0
  2. package/README.md +5 -1
  3. package/dist/index.cjs +250 -172
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/{packages/extension-mention/src/mention.d.ts → index.d.cts} +33 -16
  6. package/dist/index.d.ts +93 -0
  7. package/dist/index.js +215 -168
  8. package/dist/index.js.map +1 -1
  9. package/package.json +15 -13
  10. package/src/mention.ts +158 -95
  11. package/src/utils/get-default-suggestion-attributes.ts +89 -0
  12. package/dist/index.umd.js +0 -187
  13. package/dist/index.umd.js.map +0 -1
  14. package/dist/packages/core/src/CommandManager.d.ts +0 -20
  15. package/dist/packages/core/src/Editor.d.ts +0 -161
  16. package/dist/packages/core/src/EventEmitter.d.ts +0 -11
  17. package/dist/packages/core/src/Extension.d.ts +0 -343
  18. package/dist/packages/core/src/ExtensionManager.d.ts +0 -55
  19. package/dist/packages/core/src/InputRule.d.ts +0 -42
  20. package/dist/packages/core/src/Mark.d.ts +0 -451
  21. package/dist/packages/core/src/Node.d.ts +0 -611
  22. package/dist/packages/core/src/NodePos.d.ts +0 -44
  23. package/dist/packages/core/src/NodeView.d.ts +0 -31
  24. package/dist/packages/core/src/PasteRule.d.ts +0 -50
  25. package/dist/packages/core/src/Tracker.d.ts +0 -11
  26. package/dist/packages/core/src/commands/blur.d.ts +0 -13
  27. package/dist/packages/core/src/commands/clearContent.d.ts +0 -14
  28. package/dist/packages/core/src/commands/clearNodes.d.ts +0 -13
  29. package/dist/packages/core/src/commands/command.d.ts +0 -18
  30. package/dist/packages/core/src/commands/createParagraphNear.d.ts +0 -13
  31. package/dist/packages/core/src/commands/cut.d.ts +0 -20
  32. package/dist/packages/core/src/commands/deleteCurrentNode.d.ts +0 -13
  33. package/dist/packages/core/src/commands/deleteNode.d.ts +0 -15
  34. package/dist/packages/core/src/commands/deleteRange.d.ts +0 -14
  35. package/dist/packages/core/src/commands/deleteSelection.d.ts +0 -13
  36. package/dist/packages/core/src/commands/enter.d.ts +0 -13
  37. package/dist/packages/core/src/commands/exitCode.d.ts +0 -13
  38. package/dist/packages/core/src/commands/extendMarkRange.d.ts +0 -25
  39. package/dist/packages/core/src/commands/first.d.ts +0 -14
  40. package/dist/packages/core/src/commands/focus.d.ts +0 -27
  41. package/dist/packages/core/src/commands/forEach.d.ts +0 -14
  42. package/dist/packages/core/src/commands/index.d.ts +0 -55
  43. package/dist/packages/core/src/commands/insertContent.d.ts +0 -34
  44. package/dist/packages/core/src/commands/insertContentAt.d.ts +0 -47
  45. package/dist/packages/core/src/commands/join.d.ts +0 -41
  46. package/dist/packages/core/src/commands/joinItemBackward.d.ts +0 -13
  47. package/dist/packages/core/src/commands/joinItemForward.d.ts +0 -13
  48. package/dist/packages/core/src/commands/joinTextblockBackward.d.ts +0 -12
  49. package/dist/packages/core/src/commands/joinTextblockForward.d.ts +0 -12
  50. package/dist/packages/core/src/commands/keyboardShortcut.d.ts +0 -14
  51. package/dist/packages/core/src/commands/lift.d.ts +0 -17
  52. package/dist/packages/core/src/commands/liftEmptyBlock.d.ts +0 -13
  53. package/dist/packages/core/src/commands/liftListItem.d.ts +0 -15
  54. package/dist/packages/core/src/commands/newlineInCode.d.ts +0 -13
  55. package/dist/packages/core/src/commands/resetAttributes.d.ts +0 -16
  56. package/dist/packages/core/src/commands/scrollIntoView.d.ts +0 -13
  57. package/dist/packages/core/src/commands/selectAll.d.ts +0 -13
  58. package/dist/packages/core/src/commands/selectNodeBackward.d.ts +0 -13
  59. package/dist/packages/core/src/commands/selectNodeForward.d.ts +0 -13
  60. package/dist/packages/core/src/commands/selectParentNode.d.ts +0 -13
  61. package/dist/packages/core/src/commands/selectTextblockEnd.d.ts +0 -13
  62. package/dist/packages/core/src/commands/selectTextblockStart.d.ts +0 -13
  63. package/dist/packages/core/src/commands/setContent.d.ts +0 -40
  64. package/dist/packages/core/src/commands/setMark.d.ts +0 -15
  65. package/dist/packages/core/src/commands/setMeta.d.ts +0 -15
  66. package/dist/packages/core/src/commands/setNode.d.ts +0 -16
  67. package/dist/packages/core/src/commands/setNodeSelection.d.ts +0 -14
  68. package/dist/packages/core/src/commands/setTextSelection.d.ts +0 -14
  69. package/dist/packages/core/src/commands/sinkListItem.d.ts +0 -15
  70. package/dist/packages/core/src/commands/splitBlock.d.ts +0 -17
  71. package/dist/packages/core/src/commands/splitListItem.d.ts +0 -15
  72. package/dist/packages/core/src/commands/toggleList.d.ts +0 -18
  73. package/dist/packages/core/src/commands/toggleMark.d.ts +0 -30
  74. package/dist/packages/core/src/commands/toggleNode.d.ts +0 -17
  75. package/dist/packages/core/src/commands/toggleWrap.d.ts +0 -16
  76. package/dist/packages/core/src/commands/undoInputRule.d.ts +0 -13
  77. package/dist/packages/core/src/commands/unsetAllMarks.d.ts +0 -13
  78. package/dist/packages/core/src/commands/unsetMark.d.ts +0 -25
  79. package/dist/packages/core/src/commands/updateAttributes.d.ts +0 -24
  80. package/dist/packages/core/src/commands/wrapIn.d.ts +0 -16
  81. package/dist/packages/core/src/commands/wrapInList.d.ts +0 -16
  82. package/dist/packages/core/src/extensions/clipboardTextSerializer.d.ts +0 -5
  83. package/dist/packages/core/src/extensions/commands.d.ts +0 -3
  84. package/dist/packages/core/src/extensions/editable.d.ts +0 -2
  85. package/dist/packages/core/src/extensions/focusEvents.d.ts +0 -2
  86. package/dist/packages/core/src/extensions/index.d.ts +0 -6
  87. package/dist/packages/core/src/extensions/keymap.d.ts +0 -2
  88. package/dist/packages/core/src/extensions/tabindex.d.ts +0 -2
  89. package/dist/packages/core/src/helpers/combineTransactionSteps.d.ts +0 -10
  90. package/dist/packages/core/src/helpers/createChainableState.d.ts +0 -10
  91. package/dist/packages/core/src/helpers/createDocument.d.ts +0 -12
  92. package/dist/packages/core/src/helpers/createNodeFromContent.d.ts +0 -15
  93. package/dist/packages/core/src/helpers/defaultBlockAt.d.ts +0 -7
  94. package/dist/packages/core/src/helpers/findChildren.d.ts +0 -9
  95. package/dist/packages/core/src/helpers/findChildrenInRange.d.ts +0 -10
  96. package/dist/packages/core/src/helpers/findParentNode.d.ts +0 -16
  97. package/dist/packages/core/src/helpers/findParentNodeClosestToPos.d.ts +0 -17
  98. package/dist/packages/core/src/helpers/generateHTML.d.ts +0 -8
  99. package/dist/packages/core/src/helpers/generateJSON.d.ts +0 -8
  100. package/dist/packages/core/src/helpers/generateText.d.ts +0 -12
  101. package/dist/packages/core/src/helpers/getAttributes.d.ts +0 -9
  102. package/dist/packages/core/src/helpers/getAttributesFromExtensions.d.ts +0 -6
  103. package/dist/packages/core/src/helpers/getChangedRanges.d.ts +0 -11
  104. package/dist/packages/core/src/helpers/getDebugJSON.d.ts +0 -8
  105. package/dist/packages/core/src/helpers/getExtensionField.d.ts +0 -9
  106. package/dist/packages/core/src/helpers/getHTMLFromFragment.d.ts +0 -2
  107. package/dist/packages/core/src/helpers/getMarkAttributes.d.ts +0 -3
  108. package/dist/packages/core/src/helpers/getMarkRange.d.ts +0 -3
  109. package/dist/packages/core/src/helpers/getMarkType.d.ts +0 -2
  110. package/dist/packages/core/src/helpers/getMarksBetween.d.ts +0 -3
  111. package/dist/packages/core/src/helpers/getNodeAtPosition.d.ts +0 -11
  112. package/dist/packages/core/src/helpers/getNodeAttributes.d.ts +0 -3
  113. package/dist/packages/core/src/helpers/getNodeType.d.ts +0 -2
  114. package/dist/packages/core/src/helpers/getRenderedAttributes.d.ts +0 -3
  115. package/dist/packages/core/src/helpers/getSchema.d.ts +0 -4
  116. package/dist/packages/core/src/helpers/getSchemaByResolvedExtensions.d.ts +0 -10
  117. package/dist/packages/core/src/helpers/getSchemaTypeByName.d.ts +0 -8
  118. package/dist/packages/core/src/helpers/getSchemaTypeNameByName.d.ts +0 -8
  119. package/dist/packages/core/src/helpers/getSplittedAttributes.d.ts +0 -9
  120. package/dist/packages/core/src/helpers/getText.d.ts +0 -15
  121. package/dist/packages/core/src/helpers/getTextBetween.d.ts +0 -14
  122. package/dist/packages/core/src/helpers/getTextContentFromNodes.d.ts +0 -8
  123. package/dist/packages/core/src/helpers/getTextSerializersFromSchema.d.ts +0 -8
  124. package/dist/packages/core/src/helpers/index.d.ts +0 -50
  125. package/dist/packages/core/src/helpers/injectExtensionAttributesToParseRule.d.ts +0 -9
  126. package/dist/packages/core/src/helpers/isActive.d.ts +0 -2
  127. package/dist/packages/core/src/helpers/isAtEndOfNode.d.ts +0 -2
  128. package/dist/packages/core/src/helpers/isAtStartOfNode.d.ts +0 -2
  129. package/dist/packages/core/src/helpers/isExtensionRulesEnabled.d.ts +0 -2
  130. package/dist/packages/core/src/helpers/isList.d.ts +0 -2
  131. package/dist/packages/core/src/helpers/isMarkActive.d.ts +0 -3
  132. package/dist/packages/core/src/helpers/isNodeActive.d.ts +0 -3
  133. package/dist/packages/core/src/helpers/isNodeEmpty.d.ts +0 -2
  134. package/dist/packages/core/src/helpers/isNodeSelection.d.ts +0 -2
  135. package/dist/packages/core/src/helpers/isTextSelection.d.ts +0 -2
  136. package/dist/packages/core/src/helpers/posToDOMRect.d.ts +0 -2
  137. package/dist/packages/core/src/helpers/resolveFocusPosition.d.ts +0 -4
  138. package/dist/packages/core/src/helpers/selectionToInsertionEnd.d.ts +0 -2
  139. package/dist/packages/core/src/helpers/splitExtensions.d.ts +0 -9
  140. package/dist/packages/core/src/index.d.ts +0 -24
  141. package/dist/packages/core/src/inputRules/index.d.ts +0 -5
  142. package/dist/packages/core/src/inputRules/markInputRule.d.ts +0 -13
  143. package/dist/packages/core/src/inputRules/nodeInputRule.d.ts +0 -23
  144. package/dist/packages/core/src/inputRules/textInputRule.d.ts +0 -10
  145. package/dist/packages/core/src/inputRules/textblockTypeInputRule.d.ts +0 -15
  146. package/dist/packages/core/src/inputRules/wrappingInputRule.d.ts +0 -28
  147. package/dist/packages/core/src/pasteRules/index.d.ts +0 -3
  148. package/dist/packages/core/src/pasteRules/markPasteRule.d.ts +0 -13
  149. package/dist/packages/core/src/pasteRules/nodePasteRule.d.ts +0 -13
  150. package/dist/packages/core/src/pasteRules/textPasteRule.d.ts +0 -10
  151. package/dist/packages/core/src/style.d.ts +0 -1
  152. package/dist/packages/core/src/types.d.ts +0 -255
  153. package/dist/packages/core/src/utilities/callOrReturn.d.ts +0 -9
  154. package/dist/packages/core/src/utilities/createStyleTag.d.ts +0 -1
  155. package/dist/packages/core/src/utilities/deleteProps.d.ts +0 -6
  156. package/dist/packages/core/src/utilities/elementFromString.d.ts +0 -1
  157. package/dist/packages/core/src/utilities/escapeForRegEx.d.ts +0 -1
  158. package/dist/packages/core/src/utilities/findDuplicates.d.ts +0 -1
  159. package/dist/packages/core/src/utilities/fromString.d.ts +0 -1
  160. package/dist/packages/core/src/utilities/index.d.ts +0 -20
  161. package/dist/packages/core/src/utilities/isAndroid.d.ts +0 -1
  162. package/dist/packages/core/src/utilities/isEmptyObject.d.ts +0 -1
  163. package/dist/packages/core/src/utilities/isFunction.d.ts +0 -1
  164. package/dist/packages/core/src/utilities/isMacOS.d.ts +0 -1
  165. package/dist/packages/core/src/utilities/isNumber.d.ts +0 -1
  166. package/dist/packages/core/src/utilities/isPlainObject.d.ts +0 -1
  167. package/dist/packages/core/src/utilities/isRegExp.d.ts +0 -1
  168. package/dist/packages/core/src/utilities/isString.d.ts +0 -1
  169. package/dist/packages/core/src/utilities/isiOS.d.ts +0 -1
  170. package/dist/packages/core/src/utilities/mergeAttributes.d.ts +0 -1
  171. package/dist/packages/core/src/utilities/mergeDeep.d.ts +0 -1
  172. package/dist/packages/core/src/utilities/minMax.d.ts +0 -1
  173. package/dist/packages/core/src/utilities/objectIncludes.d.ts +0 -8
  174. package/dist/packages/core/src/utilities/removeDuplicates.d.ts +0 -8
  175. package/dist/packages/extension-mention/src/index.d.ts +0 -3
  176. package/dist/packages/suggestion/src/findSuggestionMatch.d.ts +0 -15
  177. package/dist/packages/suggestion/src/index.d.ts +0 -4
  178. package/dist/packages/suggestion/src/suggestion.d.ts +0 -153
package/src/mention.ts CHANGED
@@ -1,7 +1,11 @@
1
+ import type { Editor } from '@tiptap/core'
1
2
  import { mergeAttributes, Node } from '@tiptap/core'
2
- import { DOMOutputSpec, Node as ProseMirrorNode } from '@tiptap/pm/model'
3
- import { PluginKey } from '@tiptap/pm/state'
4
- import Suggestion, { SuggestionOptions } from '@tiptap/suggestion'
3
+ import type { DOMOutputSpec } from '@tiptap/pm/model'
4
+ import { Node as ProseMirrorNode } from '@tiptap/pm/model'
5
+ import type { SuggestionOptions } from '@tiptap/suggestion'
6
+ import Suggestion from '@tiptap/suggestion'
7
+
8
+ import { getSuggestionOptions } from './utils/get-default-suggestion-attributes.js'
5
9
 
6
10
  // See `addAttributes` below
7
11
  export interface MentionNodeAttrs {
@@ -9,15 +13,20 @@ export interface MentionNodeAttrs {
9
13
  * The identifier for the selected item that was mentioned, stored as a `data-id`
10
14
  * attribute.
11
15
  */
12
- id: string | null;
16
+ id: string | null
13
17
  /**
14
18
  * The label to be rendered by the editor as the displayed text for this mentioned
15
19
  * item, if provided. Stored as a `data-label` attribute. See `renderLabel`.
16
20
  */
17
- label?: string | null;
21
+ label?: string | null
22
+ /**
23
+ * The character that triggers the suggestion, stored as
24
+ * `data-mention-suggestion-char` attribute.
25
+ */
26
+ mentionSuggestionChar?: string
18
27
  }
19
28
 
20
- export type MentionOptions<SuggestionItem = any, Attrs extends Record<string, any> = MentionNodeAttrs> = {
29
+ export interface MentionOptions<SuggestionItem = any, Attrs extends Record<string, any> = MentionNodeAttrs> {
21
30
  /**
22
31
  * The HTML attributes for a mention node.
23
32
  * @default {}
@@ -32,7 +41,11 @@ export type MentionOptions<SuggestionItem = any, Attrs extends Record<string, an
32
41
  * @returns The label
33
42
  * @example ({ options, node }) => `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`
34
43
  */
35
- renderLabel?: (props: { options: MentionOptions<SuggestionItem, Attrs>; node: ProseMirrorNode }) => string
44
+ renderLabel?: (props: {
45
+ options: MentionOptions<SuggestionItem, Attrs>
46
+ node: ProseMirrorNode
47
+ suggestion: SuggestionOptions | null
48
+ }) => string
36
49
 
37
50
  /**
38
51
  * A function to render the text of a mention.
@@ -40,7 +53,11 @@ export type MentionOptions<SuggestionItem = any, Attrs extends Record<string, an
40
53
  * @returns The text
41
54
  * @example ({ options, node }) => `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`
42
55
  */
43
- renderText: (props: { options: MentionOptions<SuggestionItem, Attrs>; node: ProseMirrorNode }) => string
56
+ renderText: (props: {
57
+ options: MentionOptions<SuggestionItem, Attrs>
58
+ node: ProseMirrorNode
59
+ suggestion: SuggestionOptions | null
60
+ }) => string
44
61
 
45
62
  /**
46
63
  * A function to render the HTML of a mention.
@@ -48,7 +65,11 @@ export type MentionOptions<SuggestionItem = any, Attrs extends Record<string, an
48
65
  * @returns The HTML as a ProseMirror DOM Output Spec
49
66
  * @example ({ options, node }) => ['span', { 'data-type': 'mention' }, `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`]
50
67
  */
51
- renderHTML: (props: { options: MentionOptions<SuggestionItem, Attrs>; node: ProseMirrorNode }) => DOMOutputSpec
68
+ renderHTML: (props: {
69
+ options: MentionOptions<SuggestionItem, Attrs>
70
+ node: ProseMirrorNode
71
+ suggestion: SuggestionOptions | null
72
+ }) => DOMOutputSpec
52
73
 
53
74
  /**
54
75
  * Whether to delete the trigger character with backspace.
@@ -57,18 +78,73 @@ export type MentionOptions<SuggestionItem = any, Attrs extends Record<string, an
57
78
  deleteTriggerWithBackspace: boolean
58
79
 
59
80
  /**
60
- * The suggestion options.
81
+ * The suggestion options, when you want to support multiple triggers.
82
+ *
83
+ * With this parameter, you can define multiple types of mention. For example, you can use the `@` character
84
+ * to mention users and the `#` character to mention tags.
85
+ *
86
+ * @default [{ char: '@', pluginKey: MentionPluginKey }]
87
+ * @example [{ char: '@', pluginKey: MentionPluginKey }, { char: '#', pluginKey: new PluginKey('hashtag') }]
88
+ */
89
+ suggestions: Array<Omit<SuggestionOptions<SuggestionItem, Attrs>, 'editor'>>
90
+
91
+ /**
92
+ * The suggestion options, when you want to support only one trigger. To support multiple triggers, use the
93
+ * `suggestions` parameter instead.
94
+ *
61
95
  * @default {}
62
96
  * @example { char: '@', pluginKey: MentionPluginKey, command: ({ editor, range, props }) => { ... } }
63
97
  */
64
98
  suggestion: Omit<SuggestionOptions<SuggestionItem, Attrs>, 'editor'>
65
99
  }
66
100
 
101
+ interface GetSuggestionsOptions {
102
+ editor?: Editor
103
+ options: MentionOptions
104
+ name: string
105
+ }
106
+
67
107
  /**
68
- * The plugin key for the mention plugin.
69
- * @default 'mention'
108
+ * Returns the suggestions for the mention extension.
109
+ *
110
+ * @param options The extension options
111
+ * @returns the suggestions
70
112
  */
71
- export const MentionPluginKey = new PluginKey('mention')
113
+ function getSuggestions(options: GetSuggestionsOptions) {
114
+ return (options.options.suggestions.length ? options.options.suggestions : [options.options.suggestion]).map(
115
+ suggestion =>
116
+ getSuggestionOptions({
117
+ // @ts-ignore `editor` can be `undefined` when converting the document to HTML with the HTML utility
118
+ editor: options.editor,
119
+ overrideSuggestionOptions: suggestion,
120
+ extensionName: options.name,
121
+ char: suggestion.char,
122
+ }),
123
+ )
124
+ }
125
+
126
+ /**
127
+ * Returns the suggestion options of the mention that has a given character trigger. If not
128
+ * found, it returns the first suggestion.
129
+ *
130
+ * @param options The extension options
131
+ * @param char The character that triggers the mention
132
+ * @returns The suggestion options
133
+ */
134
+ function getSuggestionFromChar(options: GetSuggestionsOptions, char: string) {
135
+ const suggestions = getSuggestions(options)
136
+
137
+ const suggestion = suggestions.find(s => s.char === char)
138
+ if (suggestion) {
139
+ return suggestion
140
+ }
141
+
142
+ if (suggestions.length) {
143
+ return suggestions[0]
144
+ }
145
+
146
+ return null
147
+ }
72
148
 
73
149
  /**
74
150
  * This extension allows you to insert mentions into the editor.
@@ -77,58 +153,24 @@ export const MentionPluginKey = new PluginKey('mention')
77
153
  export const Mention = Node.create<MentionOptions>({
78
154
  name: 'mention',
79
155
 
156
+ priority: 101,
157
+
80
158
  addOptions() {
81
159
  return {
82
160
  HTMLAttributes: {},
83
- renderText({ options, node }) {
84
- return `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`
161
+ renderText({ node, suggestion }) {
162
+ return `${suggestion?.char ?? '@'}${node.attrs.label ?? node.attrs.id}`
85
163
  },
86
164
  deleteTriggerWithBackspace: false,
87
- renderHTML({ options, node }) {
165
+ renderHTML({ options, node, suggestion }) {
88
166
  return [
89
167
  'span',
90
168
  mergeAttributes(this.HTMLAttributes, options.HTMLAttributes),
91
- `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`,
169
+ `${suggestion?.char ?? '@'}${node.attrs.label ?? node.attrs.id}`,
92
170
  ]
93
171
  },
94
- suggestion: {
95
- char: '@',
96
- pluginKey: MentionPluginKey,
97
- command: ({ editor, range, props }) => {
98
- // increase range.to by one when the next node is of type "text"
99
- // and starts with a space character
100
- const nodeAfter = editor.view.state.selection.$to.nodeAfter
101
- const overrideSpace = nodeAfter?.text?.startsWith(' ')
102
-
103
- if (overrideSpace) {
104
- range.to += 1
105
- }
106
-
107
- editor
108
- .chain()
109
- .focus()
110
- .insertContentAt(range, [
111
- {
112
- type: this.name,
113
- attrs: props,
114
- },
115
- {
116
- type: 'text',
117
- text: ' ',
118
- },
119
- ])
120
- .run()
121
-
122
- window.getSelection()?.collapseToEnd()
123
- },
124
- allow: ({ state, range }) => {
125
- const $from = state.doc.resolve(range.from)
126
- const type = state.schema.nodes[this.name]
127
- const allow = !!$from.parent.type.contentMatch.matchType(type)
128
-
129
- return allow
130
- },
131
- },
172
+ suggestions: [],
173
+ suggestion: {},
132
174
  }
133
175
  },
134
176
 
@@ -169,6 +211,17 @@ export const Mention = Node.create<MentionOptions>({
169
211
  }
170
212
  },
171
213
  },
214
+
215
+ // When there are multiple types of mentions, this attribute helps distinguish them
216
+ mentionSuggestionChar: {
217
+ default: '@',
218
+ parseHTML: element => element.getAttribute('data-mention-suggestion-char'),
219
+ renderHTML: attributes => {
220
+ return {
221
+ 'data-mention-suggestion-char': attributes.mentionSuggestionChar,
222
+ }
223
+ },
224
+ },
172
225
  }
173
226
  },
174
227
 
@@ -181,6 +234,8 @@ export const Mention = Node.create<MentionOptions>({
181
234
  },
182
235
 
183
236
  renderHTML({ node, HTMLAttributes }) {
237
+ const suggestion = getSuggestionFromChar(this, node.attrs.mentionSuggestionChar)
238
+
184
239
  if (this.options.renderLabel !== undefined) {
185
240
  console.warn('renderLabel is deprecated use renderText and renderHTML instead')
186
241
  return [
@@ -189,76 +244,84 @@ export const Mention = Node.create<MentionOptions>({
189
244
  this.options.renderLabel({
190
245
  options: this.options,
191
246
  node,
247
+ suggestion,
192
248
  }),
193
249
  ]
194
250
  }
195
251
  const mergedOptions = { ...this.options }
196
252
 
197
- mergedOptions.HTMLAttributes = mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes)
253
+ mergedOptions.HTMLAttributes = mergeAttributes(
254
+ { 'data-type': this.name },
255
+ this.options.HTMLAttributes,
256
+ HTMLAttributes,
257
+ )
258
+
198
259
  const html = this.options.renderHTML({
199
260
  options: mergedOptions,
200
261
  node,
262
+ suggestion,
201
263
  })
202
264
 
203
265
  if (typeof html === 'string') {
204
- return [
205
- 'span',
206
- mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),
207
- html,
208
- ]
266
+ return ['span', mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes), html]
209
267
  }
210
268
  return html
211
269
  },
212
270
 
213
271
  renderText({ node }) {
272
+ const args = {
273
+ options: this.options,
274
+ node,
275
+ suggestion: getSuggestionFromChar(this, node.attrs.mentionSuggestionChar),
276
+ }
214
277
  if (this.options.renderLabel !== undefined) {
215
278
  console.warn('renderLabel is deprecated use renderText and renderHTML instead')
216
- return this.options.renderLabel({
217
- options: this.options,
218
- node,
219
- })
279
+ return this.options.renderLabel(args)
220
280
  }
221
- return this.options.renderText({
222
- options: this.options,
223
- node,
224
- })
281
+
282
+ return this.options.renderText(args)
225
283
  },
226
284
 
227
285
  addKeyboardShortcuts() {
228
286
  return {
229
- Backspace: () => this.editor.commands.command(({ tr, state }) => {
230
- let isMention = false
231
- const { selection } = state
232
- const { empty, anchor } = selection
233
-
234
- if (!empty) {
235
- return false
236
- }
237
-
238
- state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
239
- if (node.type.name === this.name) {
240
- isMention = true
241
- tr.insertText(
242
- this.options.deleteTriggerWithBackspace ? '' : this.options.suggestion.char || '',
243
- pos,
244
- pos + node.nodeSize,
245
- )
287
+ Backspace: () =>
288
+ this.editor.commands.command(({ tr, state }) => {
289
+ let isMention = false
290
+ const { selection } = state
291
+ const { empty, anchor } = selection
246
292
 
293
+ if (!empty) {
247
294
  return false
248
295
  }
249
- })
250
296
 
251
- return isMention
252
- }),
297
+ // Store node and position for later use
298
+ let mentionNode = new ProseMirrorNode()
299
+ let mentionPos = 0
300
+
301
+ state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
302
+ if (node.type.name === this.name) {
303
+ isMention = true
304
+ mentionNode = node
305
+ mentionPos = pos
306
+ return false
307
+ }
308
+ })
309
+
310
+ if (isMention) {
311
+ tr.insertText(
312
+ this.options.deleteTriggerWithBackspace ? '' : mentionNode.attrs.mentionSuggestionChar,
313
+ mentionPos,
314
+ mentionPos + mentionNode.nodeSize,
315
+ )
316
+ }
317
+
318
+ return isMention
319
+ }),
253
320
  }
254
321
  },
255
322
 
256
323
  addProseMirrorPlugins() {
257
- return [
258
- Suggestion({
259
- editor: this.editor,
260
- ...this.options.suggestion,
261
- }),
262
- ]
324
+ // Create a plugin for each suggestion configuration
325
+ return getSuggestions(this).map(Suggestion)
263
326
  },
264
327
  })
@@ -0,0 +1,89 @@
1
+ import type { Editor } from '@tiptap/core'
2
+ import { PluginKey } from '@tiptap/pm/state'
3
+ import type { SuggestionOptions } from '@tiptap/suggestion'
4
+
5
+ /**
6
+ * Arguments for the `getSuggestionOptions` function
7
+ * @see getSuggestionOptions
8
+ */
9
+ export interface GetSuggestionOptionsOptions {
10
+ /**
11
+ * The Tiptap editor instance.
12
+ */
13
+ editor: Editor
14
+ /**
15
+ * The suggestion options configuration provided to the
16
+ * `Mention` extension.
17
+ */
18
+ overrideSuggestionOptions: Omit<SuggestionOptions, 'editor'>
19
+ /**
20
+ * The name of the Mention extension
21
+ */
22
+ extensionName: string
23
+ /**
24
+ * The character that triggers the suggestion.
25
+ * @default '@'
26
+ */
27
+ char?: string
28
+ }
29
+
30
+ /**
31
+ * Returns the suggestion options for a trigger of the Mention extension. These
32
+ * options are used to create a `Suggestion` ProseMirror plugin. Each plugin lets
33
+ * you define a different trigger that opens the Mention menu. For example,
34
+ * you can define a `@` trigger to mention users and a `#` trigger to mention
35
+ * tags.
36
+ *
37
+ * @param param0 The configured options for the suggestion
38
+ * @returns
39
+ */
40
+ export function getSuggestionOptions({
41
+ editor: tiptapEditor,
42
+ overrideSuggestionOptions,
43
+ extensionName,
44
+ char = '@',
45
+ }: GetSuggestionOptionsOptions): SuggestionOptions {
46
+ const pluginKey = new PluginKey()
47
+
48
+ return {
49
+ editor: tiptapEditor,
50
+ char,
51
+ pluginKey,
52
+ command: ({ editor, range, props }: { editor: any; range: any; props: any }) => {
53
+ // increase range.to by one when the next node is of type "text"
54
+ // and starts with a space character
55
+ const nodeAfter = editor.view.state.selection.$to.nodeAfter
56
+ const overrideSpace = nodeAfter?.text?.startsWith(' ')
57
+
58
+ if (overrideSpace) {
59
+ range.to += 1
60
+ }
61
+
62
+ editor
63
+ .chain()
64
+ .focus()
65
+ .insertContentAt(range, [
66
+ {
67
+ type: extensionName,
68
+ attrs: { ...props, mentionSuggestionChar: char },
69
+ },
70
+ {
71
+ type: 'text',
72
+ text: ' ',
73
+ },
74
+ ])
75
+ .run()
76
+
77
+ // get reference to `window` object from editor element, to support cross-frame JS usage
78
+ editor.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()
79
+ },
80
+ allow: ({ state, range }: { state: any; range: any }) => {
81
+ const $from = state.doc.resolve(range.from)
82
+ const type = state.schema.nodes[extensionName]
83
+ const allow = !!$from.parent.type.contentMatch.matchType(type)
84
+
85
+ return allow
86
+ },
87
+ ...overrideSuggestionOptions,
88
+ }
89
+ }
package/dist/index.umd.js DELETED
@@ -1,187 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('@tiptap/pm/state'), require('@tiptap/suggestion')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', '@tiptap/pm/state', '@tiptap/suggestion'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-mention"] = {}, global.core, global.state, global.Suggestion));
5
- })(this, (function (exports, core, state, Suggestion) { 'use strict';
6
-
7
- /**
8
- * The plugin key for the mention plugin.
9
- * @default 'mention'
10
- */
11
- const MentionPluginKey = new state.PluginKey('mention');
12
- /**
13
- * This extension allows you to insert mentions into the editor.
14
- * @see https://www.tiptap.dev/api/extensions/mention
15
- */
16
- const Mention = core.Node.create({
17
- name: 'mention',
18
- addOptions() {
19
- return {
20
- HTMLAttributes: {},
21
- renderText({ options, node }) {
22
- var _a;
23
- return `${options.suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`;
24
- },
25
- deleteTriggerWithBackspace: false,
26
- renderHTML({ options, node }) {
27
- var _a;
28
- return [
29
- 'span',
30
- core.mergeAttributes(this.HTMLAttributes, options.HTMLAttributes),
31
- `${options.suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`,
32
- ];
33
- },
34
- suggestion: {
35
- char: '@',
36
- pluginKey: MentionPluginKey,
37
- command: ({ editor, range, props }) => {
38
- var _a, _b;
39
- // increase range.to by one when the next node is of type "text"
40
- // and starts with a space character
41
- const nodeAfter = editor.view.state.selection.$to.nodeAfter;
42
- const overrideSpace = (_a = nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.text) === null || _a === void 0 ? void 0 : _a.startsWith(' ');
43
- if (overrideSpace) {
44
- range.to += 1;
45
- }
46
- editor
47
- .chain()
48
- .focus()
49
- .insertContentAt(range, [
50
- {
51
- type: this.name,
52
- attrs: props,
53
- },
54
- {
55
- type: 'text',
56
- text: ' ',
57
- },
58
- ])
59
- .run();
60
- (_b = window.getSelection()) === null || _b === void 0 ? void 0 : _b.collapseToEnd();
61
- },
62
- allow: ({ state, range }) => {
63
- const $from = state.doc.resolve(range.from);
64
- const type = state.schema.nodes[this.name];
65
- const allow = !!$from.parent.type.contentMatch.matchType(type);
66
- return allow;
67
- },
68
- },
69
- };
70
- },
71
- group: 'inline',
72
- inline: true,
73
- selectable: false,
74
- atom: true,
75
- addAttributes() {
76
- return {
77
- id: {
78
- default: null,
79
- parseHTML: element => element.getAttribute('data-id'),
80
- renderHTML: attributes => {
81
- if (!attributes.id) {
82
- return {};
83
- }
84
- return {
85
- 'data-id': attributes.id,
86
- };
87
- },
88
- },
89
- label: {
90
- default: null,
91
- parseHTML: element => element.getAttribute('data-label'),
92
- renderHTML: attributes => {
93
- if (!attributes.label) {
94
- return {};
95
- }
96
- return {
97
- 'data-label': attributes.label,
98
- };
99
- },
100
- },
101
- };
102
- },
103
- parseHTML() {
104
- return [
105
- {
106
- tag: `span[data-type="${this.name}"]`,
107
- },
108
- ];
109
- },
110
- renderHTML({ node, HTMLAttributes }) {
111
- if (this.options.renderLabel !== undefined) {
112
- console.warn('renderLabel is deprecated use renderText and renderHTML instead');
113
- return [
114
- 'span',
115
- core.mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),
116
- this.options.renderLabel({
117
- options: this.options,
118
- node,
119
- }),
120
- ];
121
- }
122
- const mergedOptions = { ...this.options };
123
- mergedOptions.HTMLAttributes = core.mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes);
124
- const html = this.options.renderHTML({
125
- options: mergedOptions,
126
- node,
127
- });
128
- if (typeof html === 'string') {
129
- return [
130
- 'span',
131
- core.mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),
132
- html,
133
- ];
134
- }
135
- return html;
136
- },
137
- renderText({ node }) {
138
- if (this.options.renderLabel !== undefined) {
139
- console.warn('renderLabel is deprecated use renderText and renderHTML instead');
140
- return this.options.renderLabel({
141
- options: this.options,
142
- node,
143
- });
144
- }
145
- return this.options.renderText({
146
- options: this.options,
147
- node,
148
- });
149
- },
150
- addKeyboardShortcuts() {
151
- return {
152
- Backspace: () => this.editor.commands.command(({ tr, state }) => {
153
- let isMention = false;
154
- const { selection } = state;
155
- const { empty, anchor } = selection;
156
- if (!empty) {
157
- return false;
158
- }
159
- state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
160
- if (node.type.name === this.name) {
161
- isMention = true;
162
- tr.insertText(this.options.deleteTriggerWithBackspace ? '' : this.options.suggestion.char || '', pos, pos + node.nodeSize);
163
- return false;
164
- }
165
- });
166
- return isMention;
167
- }),
168
- };
169
- },
170
- addProseMirrorPlugins() {
171
- return [
172
- Suggestion({
173
- editor: this.editor,
174
- ...this.options.suggestion,
175
- }),
176
- ];
177
- },
178
- });
179
-
180
- exports.Mention = Mention;
181
- exports.MentionPluginKey = MentionPluginKey;
182
- exports.default = Mention;
183
-
184
- Object.defineProperty(exports, '__esModule', { value: true });
185
-
186
- }));
187
- //# sourceMappingURL=index.umd.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.umd.js","sources":["../src/mention.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\nimport { DOMOutputSpec, Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { PluginKey } from '@tiptap/pm/state'\nimport Suggestion, { SuggestionOptions } from '@tiptap/suggestion'\n\n// See `addAttributes` below\nexport interface MentionNodeAttrs {\n /**\n * The identifier for the selected item that was mentioned, stored as a `data-id`\n * attribute.\n */\n id: string | null;\n /**\n * The label to be rendered by the editor as the displayed text for this mentioned\n * item, if provided. Stored as a `data-label` attribute. See `renderLabel`.\n */\n label?: string | null;\n}\n\nexport type MentionOptions<SuggestionItem = any, Attrs extends Record<string, any> = MentionNodeAttrs> = {\n /**\n * The HTML attributes for a mention node.\n * @default {}\n * @example { class: 'foo' }\n */\n HTMLAttributes: Record<string, any>\n\n /**\n * A function to render the label of a mention.\n * @deprecated use renderText and renderHTML instead\n * @param props The render props\n * @returns The label\n * @example ({ options, node }) => `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`\n */\n renderLabel?: (props: { options: MentionOptions<SuggestionItem, Attrs>; node: ProseMirrorNode }) => string\n\n /**\n * A function to render the text of a mention.\n * @param props The render props\n * @returns The text\n * @example ({ options, node }) => `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`\n */\n renderText: (props: { options: MentionOptions<SuggestionItem, Attrs>; node: ProseMirrorNode }) => string\n\n /**\n * A function to render the HTML of a mention.\n * @param props The render props\n * @returns The HTML as a ProseMirror DOM Output Spec\n * @example ({ options, node }) => ['span', { 'data-type': 'mention' }, `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`]\n */\n renderHTML: (props: { options: MentionOptions<SuggestionItem, Attrs>; node: ProseMirrorNode }) => DOMOutputSpec\n\n /**\n * Whether to delete the trigger character with backspace.\n * @default false\n */\n deleteTriggerWithBackspace: boolean\n\n /**\n * The suggestion options.\n * @default {}\n * @example { char: '@', pluginKey: MentionPluginKey, command: ({ editor, range, props }) => { ... } }\n */\n suggestion: Omit<SuggestionOptions<SuggestionItem, Attrs>, 'editor'>\n}\n\n/**\n * The plugin key for the mention plugin.\n * @default 'mention'\n */\nexport const MentionPluginKey = new PluginKey('mention')\n\n/**\n * This extension allows you to insert mentions into the editor.\n * @see https://www.tiptap.dev/api/extensions/mention\n */\nexport const Mention = Node.create<MentionOptions>({\n name: 'mention',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n renderText({ options, node }) {\n return `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`\n },\n deleteTriggerWithBackspace: false,\n renderHTML({ options, node }) {\n return [\n 'span',\n mergeAttributes(this.HTMLAttributes, options.HTMLAttributes),\n `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`,\n ]\n },\n suggestion: {\n char: '@',\n pluginKey: MentionPluginKey,\n command: ({ editor, range, props }) => {\n // increase range.to by one when the next node is of type \"text\"\n // and starts with a space character\n const nodeAfter = editor.view.state.selection.$to.nodeAfter\n const overrideSpace = nodeAfter?.text?.startsWith(' ')\n\n if (overrideSpace) {\n range.to += 1\n }\n\n editor\n .chain()\n .focus()\n .insertContentAt(range, [\n {\n type: this.name,\n attrs: props,\n },\n {\n type: 'text',\n text: ' ',\n },\n ])\n .run()\n\n window.getSelection()?.collapseToEnd()\n },\n allow: ({ state, range }) => {\n const $from = state.doc.resolve(range.from)\n const type = state.schema.nodes[this.name]\n const allow = !!$from.parent.type.contentMatch.matchType(type)\n\n return allow\n },\n },\n }\n },\n\n group: 'inline',\n\n inline: true,\n\n selectable: false,\n\n atom: true,\n\n addAttributes() {\n return {\n id: {\n default: null,\n parseHTML: element => element.getAttribute('data-id'),\n renderHTML: attributes => {\n if (!attributes.id) {\n return {}\n }\n\n return {\n 'data-id': attributes.id,\n }\n },\n },\n\n label: {\n default: null,\n parseHTML: element => element.getAttribute('data-label'),\n renderHTML: attributes => {\n if (!attributes.label) {\n return {}\n }\n\n return {\n 'data-label': attributes.label,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: `span[data-type=\"${this.name}\"]`,\n },\n ]\n },\n\n renderHTML({ node, HTMLAttributes }) {\n if (this.options.renderLabel !== undefined) {\n console.warn('renderLabel is deprecated use renderText and renderHTML instead')\n return [\n 'span',\n mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),\n this.options.renderLabel({\n options: this.options,\n node,\n }),\n ]\n }\n const mergedOptions = { ...this.options }\n\n mergedOptions.HTMLAttributes = mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes)\n const html = this.options.renderHTML({\n options: mergedOptions,\n node,\n })\n\n if (typeof html === 'string') {\n return [\n 'span',\n mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),\n html,\n ]\n }\n return html\n },\n\n renderText({ node }) {\n if (this.options.renderLabel !== undefined) {\n console.warn('renderLabel is deprecated use renderText and renderHTML instead')\n return this.options.renderLabel({\n options: this.options,\n node,\n })\n }\n return this.options.renderText({\n options: this.options,\n node,\n })\n },\n\n addKeyboardShortcuts() {\n return {\n Backspace: () => this.editor.commands.command(({ tr, state }) => {\n let isMention = false\n const { selection } = state\n const { empty, anchor } = selection\n\n if (!empty) {\n return false\n }\n\n state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {\n if (node.type.name === this.name) {\n isMention = true\n tr.insertText(\n this.options.deleteTriggerWithBackspace ? '' : this.options.suggestion.char || '',\n pos,\n pos + node.nodeSize,\n )\n\n return false\n }\n })\n\n return isMention\n }),\n }\n },\n\n addProseMirrorPlugins() {\n return [\n Suggestion({\n editor: this.editor,\n ...this.options.suggestion,\n }),\n ]\n },\n})\n"],"names":["PluginKey","Node","mergeAttributes"],"mappings":";;;;;;EAkEA;;;EAGG;QACU,gBAAgB,GAAG,IAAIA,eAAS,CAAC,SAAS,EAAC;EAExD;;;EAGG;AACU,QAAA,OAAO,GAAGC,SAAI,CAAC,MAAM,CAAiB;EACjD,IAAA,IAAI,EAAE,SAAS;MAEf,UAAU,GAAA;UACR,OAAO;EACL,YAAA,cAAc,EAAE,EAAE;EAClB,YAAA,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAA;;kBAC1B,OAAO,CAAA,EAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAA,EAAG,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,mCAAI,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;eACxE;EACD,YAAA,0BAA0B,EAAE,KAAK;EACjC,YAAA,UAAU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