@tiptap/extension-mention 2.22.2 → 2.23.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.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.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 priority: 101,\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 // get reference to `window` object from editor element, to support cross-frame JS usage\n editor.view.dom.ownerDocument.defaultView?.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"],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E,MAAM,EAAE,GAAG,SAAS;gBAEnC,IAAI,CAAC,KAAK,EAAE;AACV,oBAAA,OAAO,KAAK;;AAGd,gBAAA,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,KAAI;oBACvD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;wBAChC,SAAS,GAAG,IAAI;AAChB,wBAAA,EAAE,CAAC,UAAU,CACX,IAAI,CAAC,OAAO,CAAC,0BAA0B,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,EACjF,GAAG,EACH,GAAG,GAAG,IAAI,CAAC,QAAQ,CACpB;AAED,wBAAA,OAAO,KAAK;;AAEhB,iBAAC,CAAC;AAEF,gBAAA,OAAO,SAAS;AAClB,aAAC,CAAC;SACH;KACF;IAED,qBAAqB,GAAA;QACnB,OAAO;AACL,YAAA,UAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;AACnB,gBAAA,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU;aAC3B,CAAC;SACH;KACF;AACF,CAAA;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/utils/get-default-suggestion-attributes.ts","../src/mention.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport { PluginKey } from '@tiptap/pm/state'\nimport type { SuggestionOptions } from '@tiptap/suggestion'\n\n/**\n * Arguments for the `getSuggestionOptions` function\n * @see getSuggestionOptions\n */\nexport interface GetSuggestionOptionsOptions {\n /**\n * The Tiptap editor instance.\n */\n editor: Editor\n /**\n * The suggestion options configuration provided to the\n * `Mention` extension.\n */\n overrideSuggestionOptions: Omit<SuggestionOptions, 'editor'>\n /**\n * The name of the Mention extension\n */\n extensionName: string\n /**\n * The character that triggers the suggestion.\n * @default '@'\n */\n char?: string\n}\n\n/**\n * Returns the suggestion options for a trigger of the Mention extension. These\n * options are used to create a `Suggestion` ProseMirror plugin. Each plugin lets\n * you define a different trigger that opens the Mention menu. For example,\n * you can define a `@` trigger to mention users and a `#` trigger to mention\n * tags.\n *\n * @param param0 The configured options for the suggestion\n * @returns\n */\nexport function getSuggestionOptions({\n editor: tiptapEditor,\n overrideSuggestionOptions,\n extensionName,\n char = '@',\n}: GetSuggestionOptionsOptions): SuggestionOptions {\n const pluginKey = new PluginKey()\n\n return {\n editor: tiptapEditor,\n char,\n pluginKey,\n command: ({ editor, range, props }: { editor: any; range: any; props: any }) => {\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: extensionName,\n attrs: { ...props, mentionSuggestionChar: char },\n },\n {\n type: 'text',\n text: ' ',\n },\n ])\n .run()\n\n // get reference to `window` object from editor element, to support cross-frame JS usage\n editor.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()\n },\n allow: ({ state, range }: { state: any; range: any }) => {\n const $from = state.doc.resolve(range.from)\n const type = state.schema.nodes[extensionName]\n const allow = !!$from.parent.type.contentMatch.matchType(type)\n\n return allow\n },\n ...overrideSuggestionOptions,\n }\n}\n","import { mergeAttributes, Node } from '@tiptap/core'\nimport type { DOMOutputSpec } from '@tiptap/pm/model'\nimport { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport type { SuggestionOptions } from '@tiptap/suggestion'\nimport Suggestion from '@tiptap/suggestion'\n\nimport { getSuggestionOptions } from './utils/get-default-suggestion-attributes.js'\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 * The character that triggers the suggestion, stored as\n * `data-mention-suggestion-char` attribute.\n */\n mentionSuggestionChar?: string\n}\n\nexport interface 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: {\n options: MentionOptions<SuggestionItem, Attrs>\n node: ProseMirrorNode\n suggestion: SuggestionOptions | null\n }) => 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: {\n options: MentionOptions<SuggestionItem, Attrs>\n node: ProseMirrorNode\n suggestion: SuggestionOptions | null\n }) => 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: {\n options: MentionOptions<SuggestionItem, Attrs>\n node: ProseMirrorNode\n suggestion: SuggestionOptions | null\n }) => 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, when you want to support multiple triggers.\n *\n * With this parameter, you can define multiple types of mention. For example, you can use the `@` character\n * to mention users and the `#` character to mention tags.\n *\n * @default [{ char: '@', pluginKey: MentionPluginKey }]\n * @example [{ char: '@', pluginKey: MentionPluginKey }, { char: '#', pluginKey: new PluginKey('hashtag') }]\n */\n suggestions: Array<Omit<SuggestionOptions<SuggestionItem, Attrs>, 'editor'>>\n\n /**\n * The suggestion options, when you want to support only one trigger. To support multiple triggers, use the\n * `suggestions` parameter instead.\n *\n * @default {}\n * @example { char: '@', pluginKey: MentionPluginKey, command: ({ editor, range, props }) => { ... } }\n */\n suggestion: Omit<SuggestionOptions<SuggestionItem, Attrs>, 'editor'>\n}\n\n/**\n * Storage properties or the Mention extension\n */\nexport interface MentionStorage<SuggestionItem = any, Attrs extends Record<string, any> = MentionNodeAttrs> {\n /**\n * The list of suggestions that will trigger the mention.\n */\n suggestions: Array<SuggestionOptions<SuggestionItem, Attrs>>\n\n /**\n * Returns the suggestion options of the mention that has a given character trigger. If not\n * found, it returns the first suggestion.\n *\n * @param char The character that triggers the mention\n * @returns The suggestion options\n */\n getSuggestionFromChar: (char: string) => SuggestionOptions<SuggestionItem, Attrs> | null\n}\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, MentionStorage>({\n name: 'mention',\n\n priority: 101,\n\n addStorage() {\n return {\n suggestions: [],\n getSuggestionFromChar: () => null,\n }\n },\n\n addOptions() {\n return {\n HTMLAttributes: {},\n renderText({ node, suggestion }) {\n return `${suggestion?.char}${node.attrs.label ?? node.attrs.id}`\n },\n deleteTriggerWithBackspace: false,\n renderHTML({ options, node, suggestion }) {\n return [\n 'span',\n mergeAttributes(this.HTMLAttributes, options.HTMLAttributes),\n `${suggestion?.char}${node.attrs.label ?? node.attrs.id}`,\n ]\n },\n suggestions: [],\n suggestion: {},\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 // When there are multiple types of mentions, this attribute helps distinguish them\n mentionSuggestionChar: {\n default: '@',\n parseHTML: element => element.getAttribute('data-mention-suggestion-char'),\n renderHTML: attributes => {\n return {\n 'data-mention-suggestion-char': attributes.mentionSuggestionChar,\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 // We cannot use the `this.storage` property here because, when accessed this method,\n // it returns the initial value of the extension storage\n const suggestion = (this.editor?.extensionStorage as unknown as Record<string, MentionStorage>)?.[\n this.name\n ]?.getSuggestionFromChar(node.attrs.mentionSuggestionChar)\n\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 suggestion,\n }),\n ]\n }\n const mergedOptions = { ...this.options }\n\n mergedOptions.HTMLAttributes = mergeAttributes(\n { 'data-type': this.name },\n this.options.HTMLAttributes,\n HTMLAttributes,\n )\n\n const html = this.options.renderHTML({\n options: mergedOptions,\n node,\n suggestion,\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 const args = {\n options: this.options,\n node,\n suggestion: (this.editor?.extensionStorage as unknown as Record<string, MentionStorage>)?.[\n this.name\n ]?.getSuggestionFromChar(node.attrs.mentionSuggestionChar),\n }\n\n if (this.options.renderLabel !== undefined) {\n console.warn('renderLabel is deprecated use renderText and renderHTML instead')\n return this.options.renderLabel(args)\n }\n\n return this.options.renderText(args)\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 // Store node and position for later use\n let mentionNode = new ProseMirrorNode()\n let mentionPos = 0\n\n state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {\n if (node.type.name === this.name) {\n isMention = true\n mentionNode = node\n mentionPos = pos\n return false\n }\n })\n\n if (isMention) {\n tr.insertText(\n this.options.deleteTriggerWithBackspace ? '' : mentionNode.attrs.mentionSuggestionChar,\n mentionPos,\n mentionPos + mentionNode.nodeSize,\n )\n }\n\n return isMention\n }),\n }\n },\n\n addProseMirrorPlugins() {\n // Create a plugin for each suggestion configuration\n return this.storage.suggestions.map(Suggestion)\n },\n\n onBeforeCreate() {\n this.storage.suggestions = (\n this.options.suggestions.length ? this.options.suggestions : [this.options.suggestion]\n ).map(suggestion => getSuggestionOptions({\n editor: this.editor,\n overrideSuggestionOptions: suggestion,\n extensionName: this.name,\n char: suggestion.char,\n }))\n\n this.storage.getSuggestionFromChar = char => {\n const suggestion = this.storage.suggestions.find(s => s.char === char)\n\n if (suggestion) {\n return suggestion\n }\n if (this.storage.suggestions.length) {\n return this.storage.suggestions[0]\n }\n\n return null\n }\n },\n})\n"],"names":["ProseMirrorNode"],"mappings":";;;;;AA6BA;;;;;;;;;AASG;AACa,SAAA,oBAAoB,CAAC,EACnC,MAAM,EAAE,YAAY,EACpB,yBAAyB,EACzB,aAAa,EACb,IAAI,GAAG,GAAG,GACkB,EAAA;AAC5B,IAAA,MAAM,SAAS,GAAG,IAAI,SAAS,EAAE;IAEjC,OAAO;AACL,QAAA,MAAM,EAAE,YAAY;QACpB,IAAI;QACJ,SAAS;QACT,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAA2C,KAAI;;;;AAG7E,YAAA,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,C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AAC,UAAU,CAAC,EACtF,GAAG,CAAC,UAAU,IAAI,oBAAoB,CAAC;YACvC,MAAM,EAAE,IAAI,CAAC,MAAM;AACnB,YAAA,yBAAyB,EAAE,UAAU;YACrC,aAAa,EAAE,IAAI,CAAC,IAAI;YACxB,IAAI,EAAE,UAAU,CAAC,IAAI;AACtB,SAAA,CAAC,CAAC;AAEH,QAAA,IAAI,CAAC,OAAO,CAAC,qBAAqB,GAAG,IAAI,IAAG;YAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;YAEtE,IAAI,UAAU,EAAE;AACd,gBAAA,OAAO,UAAU;;YAEnB,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE;gBACnC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;;AAGpC,YAAA,OAAO,IAAI;AACb,SAAC;KACF;AACF,CAAA;;;;"}
package/dist/index.umd.js CHANGED
@@ -1,14 +1,61 @@
1
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';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('@tiptap/pm/model'), require('@tiptap/suggestion'), require('@tiptap/pm/state')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', '@tiptap/pm/model', '@tiptap/suggestion', '@tiptap/pm/state'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-mention"] = {}, global.core, global.model, global.Suggestion, global.state));
5
+ })(this, (function (exports, core, model, Suggestion, state) { 'use strict';
6
6
 
7
7
  /**
8
- * The plugin key for the mention plugin.
9
- * @default 'mention'
8
+ * Returns the suggestion options for a trigger of the Mention extension. These
9
+ * options are used to create a `Suggestion` ProseMirror plugin. Each plugin lets
10
+ * you define a different trigger that opens the Mention menu. For example,
11
+ * you can define a `@` trigger to mention users and a `#` trigger to mention
12
+ * tags.
13
+ *
14
+ * @param param0 The configured options for the suggestion
15
+ * @returns
10
16
  */
11
- const MentionPluginKey = new state.PluginKey('mention');
17
+ function getSuggestionOptions({ editor: tiptapEditor, overrideSuggestionOptions, extensionName, char = '@', }) {
18
+ const pluginKey = new state.PluginKey();
19
+ return {
20
+ editor: tiptapEditor,
21
+ char,
22
+ pluginKey,
23
+ command: ({ editor, range, props }) => {
24
+ var _a, _b, _c;
25
+ // increase range.to by one when the next node is of type "text"
26
+ // and starts with a space character
27
+ const nodeAfter = editor.view.state.selection.$to.nodeAfter;
28
+ const overrideSpace = (_a = nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.text) === null || _a === void 0 ? void 0 : _a.startsWith(' ');
29
+ if (overrideSpace) {
30
+ range.to += 1;
31
+ }
32
+ editor
33
+ .chain()
34
+ .focus()
35
+ .insertContentAt(range, [
36
+ {
37
+ type: extensionName,
38
+ attrs: { ...props, mentionSuggestionChar: char },
39
+ },
40
+ {
41
+ type: 'text',
42
+ text: ' ',
43
+ },
44
+ ])
45
+ .run();
46
+ // get reference to `window` object from editor element, to support cross-frame JS usage
47
+ (_c = (_b = editor.view.dom.ownerDocument.defaultView) === null || _b === void 0 ? void 0 : _b.getSelection()) === null || _c === void 0 ? void 0 : _c.collapseToEnd();
48
+ },
49
+ allow: ({ state, range }) => {
50
+ const $from = state.doc.resolve(range.from);
51
+ const type = state.schema.nodes[extensionName];
52
+ const allow = !!$from.parent.type.contentMatch.matchType(type);
53
+ return allow;
54
+ },
55
+ ...overrideSuggestionOptions,
56
+ };
57
+ }
58
+
12
59
  /**
13
60
  * This extension allows you to insert mentions into the editor.
14
61
  * @see https://www.tiptap.dev/api/extensions/mention
@@ -16,58 +63,30 @@
16
63
  const Mention = core.Node.create({
17
64
  name: 'mention',
18
65
  priority: 101,
66
+ addStorage() {
67
+ return {
68
+ suggestions: [],
69
+ getSuggestionFromChar: () => null,
70
+ };
71
+ },
19
72
  addOptions() {
20
73
  return {
21
74
  HTMLAttributes: {},
22
- renderText({ options, node }) {
75
+ renderText({ node, suggestion }) {
23
76
  var _a;
24
- return `${options.suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`;
77
+ return `${suggestion === null || suggestion === void 0 ? void 0 : suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`;
25
78
  },
26
79
  deleteTriggerWithBackspace: false,
27
- renderHTML({ options, node }) {
80
+ renderHTML({ options, node, suggestion }) {
28
81
  var _a;
29
82
  return [
30
83
  'span',
31
84
  core.mergeAttributes(this.HTMLAttributes, options.HTMLAttributes),
32
- `${options.suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`,
85
+ `${suggestion === null || suggestion === void 0 ? void 0 : suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`,
33
86
  ];
34
87
  },
35
- suggestion: {
36
- char: '@',
37
- pluginKey: MentionPluginKey,
38
- command: ({ editor, range, props }) => {
39
- var _a, _b, _c;
40
- // increase range.to by one when the next node is of type "text"
41
- // and starts with a space character
42
- const nodeAfter = editor.view.state.selection.$to.nodeAfter;
43
- const overrideSpace = (_a = nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.text) === null || _a === void 0 ? void 0 : _a.startsWith(' ');
44
- if (overrideSpace) {
45
- range.to += 1;
46
- }
47
- editor
48
- .chain()
49
- .focus()
50
- .insertContentAt(range, [
51
- {
52
- type: this.name,
53
- attrs: props,
54
- },
55
- {
56
- type: 'text',
57
- text: ' ',
58
- },
59
- ])
60
- .run();
61
- // get reference to `window` object from editor element, to support cross-frame JS usage
62
- (_c = (_b = editor.view.dom.ownerDocument.defaultView) === null || _b === void 0 ? void 0 : _b.getSelection()) === null || _c === void 0 ? void 0 : _c.collapseToEnd();
63
- },
64
- allow: ({ state, range }) => {
65
- const $from = state.doc.resolve(range.from);
66
- const type = state.schema.nodes[this.name];
67
- const allow = !!$from.parent.type.contentMatch.matchType(type);
68
- return allow;
69
- },
70
- },
88
+ suggestions: [],
89
+ suggestion: {},
71
90
  };
72
91
  },
73
92
  group: 'inline',
@@ -100,6 +119,16 @@
100
119
  };
101
120
  },
102
121
  },
122
+ // When there are multiple types of mentions, this attribute helps distinguish them
123
+ mentionSuggestionChar: {
124
+ default: '@',
125
+ parseHTML: element => element.getAttribute('data-mention-suggestion-char'),
126
+ renderHTML: attributes => {
127
+ return {
128
+ 'data-mention-suggestion-char': attributes.mentionSuggestionChar,
129
+ };
130
+ },
131
+ },
103
132
  };
104
133
  },
105
134
  parseHTML() {
@@ -110,6 +139,10 @@
110
139
  ];
111
140
  },
112
141
  renderHTML({ node, HTMLAttributes }) {
142
+ var _a, _b, _c;
143
+ // We cannot use the `this.storage` property here because, when accessed this method,
144
+ // it returns the initial value of the extension storage
145
+ const suggestion = (_c = (_b = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.extensionStorage) === null || _b === void 0 ? void 0 : _b[this.name]) === null || _c === void 0 ? void 0 : _c.getSuggestionFromChar(node.attrs.mentionSuggestionChar);
113
146
  if (this.options.renderLabel !== undefined) {
114
147
  console.warn('renderLabel is deprecated use renderText and renderHTML instead');
115
148
  return [
@@ -118,6 +151,7 @@
118
151
  this.options.renderLabel({
119
152
  options: this.options,
120
153
  node,
154
+ suggestion,
121
155
  }),
122
156
  ];
123
157
  }
@@ -126,6 +160,7 @@
126
160
  const html = this.options.renderHTML({
127
161
  options: mergedOptions,
128
162
  node,
163
+ suggestion,
129
164
  });
130
165
  if (typeof html === 'string') {
131
166
  return [
@@ -137,17 +172,17 @@
137
172
  return html;
138
173
  },
139
174
  renderText({ node }) {
175
+ var _a, _b, _c;
176
+ const args = {
177
+ options: this.options,
178
+ node,
179
+ suggestion: (_c = (_b = (_a = this.editor) === null || _a === void 0 ? void 0 : _a.extensionStorage) === null || _b === void 0 ? void 0 : _b[this.name]) === null || _c === void 0 ? void 0 : _c.getSuggestionFromChar(node.attrs.mentionSuggestionChar),
180
+ };
140
181
  if (this.options.renderLabel !== undefined) {
141
182
  console.warn('renderLabel is deprecated use renderText and renderHTML instead');
142
- return this.options.renderLabel({
143
- options: this.options,
144
- node,
145
- });
183
+ return this.options.renderLabel(args);
146
184
  }
147
- return this.options.renderText({
148
- options: this.options,
149
- node,
150
- });
185
+ return this.options.renderText(args);
151
186
  },
152
187
  addKeyboardShortcuts() {
153
188
  return {
@@ -165,22 +200,49 @@
165
200
  return false;
166
201
  }
167
202
  });
203
+ // Store node and position for later use
204
+ let mentionNode = new model.Node();
205
+ let mentionPos = 0;
206
+ state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
207
+ if (node.type.name === this.name) {
208
+ isMention = true;
209
+ mentionNode = node;
210
+ mentionPos = pos;
211
+ return false;
212
+ }
213
+ });
214
+ if (isMention) {
215
+ tr.insertText(this.options.deleteTriggerWithBackspace ? '' : mentionNode.attrs.mentionSuggestionChar, mentionPos, mentionPos + mentionNode.nodeSize);
216
+ }
168
217
  return isMention;
169
218
  }),
170
219
  };
171
220
  },
172
221
  addProseMirrorPlugins() {
173
- return [
174
- Suggestion({
175
- editor: this.editor,
176
- ...this.options.suggestion,
177
- }),
178
- ];
222
+ // Create a plugin for each suggestion configuration
223
+ return this.storage.suggestions.map(Suggestion);
224
+ },
225
+ onBeforeCreate() {
226
+ this.storage.suggestions = (this.options.suggestions.length ? this.options.suggestions : [this.options.suggestion]).map(suggestion => getSuggestionOptions({
227
+ editor: this.editor,
228
+ overrideSuggestionOptions: suggestion,
229
+ extensionName: this.name,
230
+ char: suggestion.char,
231
+ }));
232
+ this.storage.getSuggestionFromChar = char => {
233
+ const suggestion = this.storage.suggestions.find(s => s.char === char);
234
+ if (suggestion) {
235
+ return suggestion;
236
+ }
237
+ if (this.storage.suggestions.length) {
238
+ return this.storage.suggestions[0];
239
+ }
240
+ return null;
241
+ };
179
242
  },
180
243
  });
181
244
 
182
245
  exports.Mention = Mention;
183
- exports.MentionPluginKey = MentionPluginKey;
184
246
  exports.default = Mention;
185
247
 
186
248
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -1 +1 @@
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 priority: 101,\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 // get reference to `window` object from editor element, to support cross-frame JS usage\n editor.view.dom.ownerDocument.defaultView?.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;EAEvD;;;EAGG;AACU,QAAA,OAAO,GAAGC,SAAI,CAAC,MAAM,CAAiB;EACjD,IAAA,IAAI,EAAE,SAAS;EAEf,IAAA,QAAQ,EAAE,GAAG;MAEb,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;eACxE;EACD,YAAA,0BAA0B,EAAE,KAAK;EACjC,YAAA,UAAU,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAA;;kBAC1B,OAAO;sBACL,MAAM;sBACNC,oBAAe,CAAC,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,cAAc,CAAC;EAC5D,oBAAA,CAAA,EAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAA,EAAG,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,IAAI,CAAC,KAAK,CAAC,EAAE,CAAE,CAAA;mBACjE;eACF;EACD,YAAA,UAAU,EAAE;EACV,gBAAA,IAAI,EAAE,GAAG;EACT,gBAAA,SAAS,EAAE,gBAAgB;kBAC3B,OAAO,EAAE,CA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A;UAClB,OAAO;EACL,YAAA,SAAS,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAI;kBAC9D,IAAI,SAAS,GAAG,KAAK;EACrB,gBAAA,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK;EAC3B,gBAAA,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS;kBAEnC,IAAI,CAAC,KAAK,EAAE;EACV,oBAAA,OAAO,KAAK;;EAGd,gBAAA,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG,KAAI;sBACvD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;0BAChC,SAAS,GAAG,IAAI;EAChB,wBAAA,EAAE,CAAC,UAAU,CACX,IAAI,CAAC,OAAO,CAAC,0BAA0B,GAAG,EAAE,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,EACjF,GAAG,EACH,GAAG,GAAG,IAAI,CAAC,QAAQ,CACpB;EAED,wBAAA,OAAO,KAAK;;EAEhB,iBAAC,CAAC;EAEF,gBAAA,OAAO,SAAS;EAClB,aAAC,CAAC;WACH;OACF;MAED,qBAAqB,GAAA;UACnB,OAAO;EACL,YAAA,UAAU,CAAC;kBACT,MAAM,EAAE,IAAI,CAAC,MAAM;EACnB,gBAAA,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU;eAC3B,CAAC;WACH;OACF;EACF,CAAA;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.umd.js","sources":["../src/utils/get-default-suggestion-attributes.ts","../src/mention.ts"],"sourcesContent":["import type { Editor } from '@tiptap/core'\nimport { PluginKey } from '@tiptap/pm/state'\nimport type { SuggestionOptions } from '@tiptap/suggestion'\n\n/**\n * Arguments for the `getSuggestionOptions` function\n * @see getSuggestionOptions\n */\nexport interface GetSuggestionOptionsOptions {\n /**\n * The Tiptap editor instance.\n */\n editor: Editor\n /**\n * The suggestion options configuration provided to the\n * `Mention` extension.\n */\n overrideSuggestionOptions: Omit<SuggestionOptions, 'editor'>\n /**\n * The name of the Mention extension\n */\n extensionName: string\n /**\n * The character that triggers the suggestion.\n * @default '@'\n */\n char?: string\n}\n\n/**\n * Returns the suggestion options for a trigger of the Mention extension. These\n * options are used to create a `Suggestion` ProseMirror plugin. Each plugin lets\n * you define a different trigger that opens the Mention menu. For example,\n * you can define a `@` trigger to mention users and a `#` trigger to mention\n * tags.\n *\n * @param param0 The configured options for the suggestion\n * @returns\n */\nexport function getSuggestionOptions({\n editor: tiptapEditor,\n overrideSuggestionOptions,\n extensionName,\n char = '@',\n}: GetSuggestionOptionsOptions): SuggestionOptions {\n const pluginKey = new PluginKey()\n\n return {\n editor: tiptapEditor,\n char,\n pluginKey,\n command: ({ editor, range, props }: { editor: any; range: any; props: any }) => {\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: extensionName,\n attrs: { ...props, mentionSuggestionChar: char },\n },\n {\n type: 'text',\n text: ' ',\n },\n ])\n .run()\n\n // get reference to `window` object from editor element, to support cross-frame JS usage\n editor.view.dom.ownerDocument.defaultView?.getSelection()?.collapseToEnd()\n },\n allow: ({ state, range }: { state: any; range: any }) => {\n const $from = state.doc.resolve(range.from)\n const type = state.schema.nodes[extensionName]\n const allow = !!$from.parent.type.contentMatch.matchType(type)\n\n return allow\n },\n ...overrideSuggestionOptions,\n }\n}\n","import { mergeAttributes, Node } from '@tiptap/core'\nimport type { DOMOutputSpec } from '@tiptap/pm/model'\nimport { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport type { SuggestionOptions } from '@tiptap/suggestion'\nimport Suggestion from '@tiptap/suggestion'\n\nimport { getSuggestionOptions } from './utils/get-default-suggestion-attributes.js'\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 * The character that triggers the suggestion, stored as\n * `data-mention-suggestion-char` attribute.\n */\n mentionSuggestionChar?: string\n}\n\nexport interface 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: {\n options: MentionOptions<SuggestionItem, Attrs>\n node: ProseMirrorNode\n suggestion: SuggestionOptions | null\n }) => 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: {\n options: MentionOptions<SuggestionItem, Attrs>\n node: ProseMirrorNode\n suggestion: SuggestionOptions | null\n }) => 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: {\n options: MentionOptions<SuggestionItem, Attrs>\n node: ProseMirrorNode\n suggestion: SuggestionOptions | null\n }) => 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, when you want to support multiple triggers.\n *\n * With this parameter, you can define multiple types of mention. For example, you can use the `@` character\n * to mention users and the `#` character to mention tags.\n *\n * @default [{ char: '@', pluginKey: MentionPluginKey }]\n * @example [{ char: '@', pluginKey: MentionPluginKey }, { char: '#', pluginKey: new PluginKey('hashtag') }]\n */\n suggestions: Array<Omit<SuggestionOptions<SuggestionItem, Attrs>, 'editor'>>\n\n /**\n * The suggestion options, when you want to support only one trigger. To support multiple triggers, use the\n * `suggestions` parameter instead.\n *\n * @default {}\n * @example { char: '@', pluginKey: MentionPluginKey, command: ({ editor, range, props }) => { ... } }\n */\n suggestion: Omit<SuggestionOptions<SuggestionItem, Attrs>, 'editor'>\n}\n\n/**\n * Storage properties or the Mention extension\n */\nexport interface MentionStorage<SuggestionItem = any, Attrs extends Record<string, any> = MentionNodeAttrs> {\n /**\n * The list of suggestions that will trigger the mention.\n */\n suggestions: Array<SuggestionOptions<SuggestionItem, Attrs>>\n\n /**\n * Returns the suggestion options of the mention that has a given character trigger. If not\n * found, it returns the first suggestion.\n *\n * @param char The character that triggers the mention\n * @returns The suggestion options\n */\n getSuggestionFromChar: (char: string) => SuggestionOptions<SuggestionItem, Attrs> | null\n}\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, MentionStorage>({\n name: 'mention',\n\n priority: 101,\n\n addStorage() {\n return {\n suggestions: [],\n getSuggestionFromChar: () => null,\n }\n },\n\n addOptions() {\n return {\n HTMLAttributes: {},\n renderText({ node, suggestion }) {\n return `${suggestion?.char}${node.attrs.label ?? node.attrs.id}`\n },\n deleteTriggerWithBackspace: false,\n renderHTML({ options, node, suggestion }) {\n return [\n 'span',\n mergeAttributes(this.HTMLAttributes, options.HTMLAttributes),\n `${suggestion?.char}${node.attrs.label ?? node.attrs.id}`,\n ]\n },\n suggestions: [],\n suggestion: {},\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 // When there are multiple types of mentions, this attribute helps distinguish them\n mentionSuggestionChar: {\n default: '@',\n parseHTML: element => element.getAttribute('data-mention-suggestion-char'),\n renderHTML: attributes => {\n return {\n 'data-mention-suggestion-char': attributes.mentionSuggestionChar,\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 // We cannot use the `this.storage` property here because, when accessed this method,\n // it returns the initial value of the extension storage\n const suggestion = (this.editor?.extensionStorage as unknown as Record<string, MentionStorage>)?.[\n this.name\n ]?.getSuggestionFromChar(node.attrs.mentionSuggestionChar)\n\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 suggestion,\n }),\n ]\n }\n const mergedOptions = { ...this.options }\n\n mergedOptions.HTMLAttributes = mergeAttributes(\n { 'data-type': this.name },\n this.options.HTMLAttributes,\n HTMLAttributes,\n )\n\n const html = this.options.renderHTML({\n options: mergedOptions,\n node,\n suggestion,\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 const args = {\n options: this.options,\n node,\n suggestion: (this.editor?.extensionStorage as unknown as Record<string, MentionStorage>)?.[\n this.name\n ]?.getSuggestionFromChar(node.attrs.mentionSuggestionChar),\n }\n\n if (this.options.renderLabel !== undefined) {\n console.warn('renderLabel is deprecated use renderText and renderHTML instead')\n return this.options.renderLabel(args)\n }\n\n return this.options.renderText(args)\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 // Store node and position for later use\n let mentionNode = new ProseMirrorNode()\n let mentionPos = 0\n\n state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {\n if (node.type.name === this.name) {\n isMention = true\n mentionNode = node\n mentionPos = pos\n return false\n }\n })\n\n if (isMention) {\n tr.insertText(\n this.options.deleteTriggerWithBackspace ? '' : mentionNode.attrs.mentionSuggestionChar,\n mentionPos,\n mentionPos + mentionNode.nodeSize,\n )\n }\n\n return isMention\n }),\n }\n },\n\n addProseMirrorPlugins() {\n // Create a plugin for each suggestion configuration\n return this.storage.suggestions.map(Suggestion)\n },\n\n onBeforeCreate() {\n this.storage.suggestions = (\n this.options.suggestions.length ? this.options.suggestions : [this.options.suggestion]\n ).map(suggestion => getSuggestionOptions({\n editor: this.editor,\n overrideSuggestionOptions: suggestion,\n extensionName: this.name,\n char: suggestion.char,\n }))\n\n this.storage.getSuggestionFromChar = char => {\n const suggestion = this.storage.suggestions.find(s => s.char === char)\n\n if (suggestion) {\n return suggestion\n }\n if (this.storage.suggestions.length) {\n return this.storage.suggestions[0]\n }\n\n return null\n }\n },\n})\n"],"names":["PluginKey","Node","mergeAttributes","ProseMirrorNode"],"mappings":";;;;;;EA6BA;;;;;;;;;EASG;EACa,SAAA,oBAAoB,CAAC,EACnC,MAAM,EAAE,YAAY,EACpB,yBAAyB,EACzB,aAAa,EACb,IAAI,GAAG,GAAG,GAC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AC,CAAC;WACH;OACF;MAED,qBAAqB,GAAA;;UAEnB,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,UAAU,CAAC;OAChD;MAED,cAAc,GAAA;EACZ,QAAA,IAAI,CAAC,OAAO,CAAC,WAAW,GAAG,CACzB,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EACtF,GAAG,CAAC,UAAU,IAAI,oBAAoB,CAAC;cACvC,MAAM,EAAE,IAAI,CAAC,MAAM;EACnB,YAAA,yBAAyB,EAAE,UAAU;cACrC,aAAa,EAAE,IAAI,CAAC,IAAI;cACxB,IAAI,EAAE,UAAU,CAAC,IAAI;EACtB,SAAA,CAAC,CAAC;EAEH,QAAA,IAAI,CAAC,OAAO,CAAC,qBAAqB,GAAG,IAAI,IAAG;cAC1C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC;cAEtE,IAAI,UAAU,EAAE;EACd,gBAAA,OAAO,UAAU;;cAEnB,IAAI,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,EAAE;kBACnC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;;EAGpC,YAAA,OAAO,IAAI;EACb,SAAC;OACF;EACF,CAAA;;;;;;;;;;;"}
package/dist/mention.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Node } from '@tiptap/core';
2
- import { DOMOutputSpec, Node as ProseMirrorNode } from '@tiptap/pm/model';
3
- import { PluginKey } from '@tiptap/pm/state';
4
- import { SuggestionOptions } from '@tiptap/suggestion';
2
+ import type { DOMOutputSpec } from '@tiptap/pm/model';
3
+ import { Node as ProseMirrorNode } from '@tiptap/pm/model';
4
+ import type { SuggestionOptions } from '@tiptap/suggestion';
5
5
  export interface MentionNodeAttrs {
6
6
  /**
7
7
  * The identifier for the selected item that was mentioned, stored as a `data-id`
@@ -13,8 +13,13 @@ export interface MentionNodeAttrs {
13
13
  * item, if provided. Stored as a `data-label` attribute. See `renderLabel`.
14
14
  */
15
15
  label?: string | null;
16
+ /**
17
+ * The character that triggers the suggestion, stored as
18
+ * `data-mention-suggestion-char` attribute.
19
+ */
20
+ mentionSuggestionChar?: string;
16
21
  }
17
- export type MentionOptions<SuggestionItem = any, Attrs extends Record<string, any> = MentionNodeAttrs> = {
22
+ export interface MentionOptions<SuggestionItem = any, Attrs extends Record<string, any> = MentionNodeAttrs> {
18
23
  /**
19
24
  * The HTML attributes for a mention node.
20
25
  * @default {}
@@ -31,6 +36,7 @@ export type MentionOptions<SuggestionItem = any, Attrs extends Record<string, an
31
36
  renderLabel?: (props: {
32
37
  options: MentionOptions<SuggestionItem, Attrs>;
33
38
  node: ProseMirrorNode;
39
+ suggestion: SuggestionOptions | null;
34
40
  }) => string;
35
41
  /**
36
42
  * A function to render the text of a mention.
@@ -41,6 +47,7 @@ export type MentionOptions<SuggestionItem = any, Attrs extends Record<string, an
41
47
  renderText: (props: {
42
48
  options: MentionOptions<SuggestionItem, Attrs>;
43
49
  node: ProseMirrorNode;
50
+ suggestion: SuggestionOptions | null;
44
51
  }) => string;
45
52
  /**
46
53
  * A function to render the HTML of a mention.
@@ -51,6 +58,7 @@ export type MentionOptions<SuggestionItem = any, Attrs extends Record<string, an
51
58
  renderHTML: (props: {
52
59
  options: MentionOptions<SuggestionItem, Attrs>;
53
60
  node: ProseMirrorNode;
61
+ suggestion: SuggestionOptions | null;
54
62
  }) => DOMOutputSpec;
55
63
  /**
56
64
  * Whether to delete the trigger character with backspace.
@@ -58,20 +66,44 @@ export type MentionOptions<SuggestionItem = any, Attrs extends Record<string, an
58
66
  */
59
67
  deleteTriggerWithBackspace: boolean;
60
68
  /**
61
- * The suggestion options.
69
+ * The suggestion options, when you want to support multiple triggers.
70
+ *
71
+ * With this parameter, you can define multiple types of mention. For example, you can use the `@` character
72
+ * to mention users and the `#` character to mention tags.
73
+ *
74
+ * @default [{ char: '@', pluginKey: MentionPluginKey }]
75
+ * @example [{ char: '@', pluginKey: MentionPluginKey }, { char: '#', pluginKey: new PluginKey('hashtag') }]
76
+ */
77
+ suggestions: Array<Omit<SuggestionOptions<SuggestionItem, Attrs>, 'editor'>>;
78
+ /**
79
+ * The suggestion options, when you want to support only one trigger. To support multiple triggers, use the
80
+ * `suggestions` parameter instead.
81
+ *
62
82
  * @default {}
63
83
  * @example { char: '@', pluginKey: MentionPluginKey, command: ({ editor, range, props }) => { ... } }
64
84
  */
65
85
  suggestion: Omit<SuggestionOptions<SuggestionItem, Attrs>, 'editor'>;
66
- };
86
+ }
67
87
  /**
68
- * The plugin key for the mention plugin.
69
- * @default 'mention'
88
+ * Storage properties or the Mention extension
70
89
  */
71
- export declare const MentionPluginKey: PluginKey<any>;
90
+ export interface MentionStorage<SuggestionItem = any, Attrs extends Record<string, any> = MentionNodeAttrs> {
91
+ /**
92
+ * The list of suggestions that will trigger the mention.
93
+ */
94
+ suggestions: Array<SuggestionOptions<SuggestionItem, Attrs>>;
95
+ /**
96
+ * Returns the suggestion options of the mention that has a given character trigger. If not
97
+ * found, it returns the first suggestion.
98
+ *
99
+ * @param char The character that triggers the mention
100
+ * @returns The suggestion options
101
+ */
102
+ getSuggestionFromChar: (char: string) => SuggestionOptions<SuggestionItem, Attrs> | null;
103
+ }
72
104
  /**
73
105
  * This extension allows you to insert mentions into the editor.
74
106
  * @see https://www.tiptap.dev/api/extensions/mention
75
107
  */
76
- export declare const Mention: Node<MentionOptions<any, MentionNodeAttrs>, any>;
108
+ export declare const Mention: Node<MentionOptions<any, MentionNodeAttrs>, MentionStorage<any, MentionNodeAttrs>>;
77
109
  //# sourceMappingURL=mention.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mention.d.ts","sourceRoot":"","sources":["../src/mention.ts"],"names":[],"mapp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;KACrC,KAAK,MAAM,CAAA;IAEZ;;;;;OAKG;IACH,UAAU,EAAE,CAAC,KAAK,EAAE;QAClB,OAAO,EAAE,cAAc,CAAC,cAAc,EAAE,KAAK,CAAC,CAAA;QAC9C,IAAI,EAAE,eAAe,CAAA;QACrB,UAAU,EAAE,iBAAiB,GAAG,IAAI,CAAA;KACrC,KAAK,aAAa,CAAA;IAEnB;;;OAGG;IACH,0BAA0B,EAAE,OAAO,CAAA;IAEnC;;;;;;;;OAQG;IACH,WAAW,EAAE,KAAK,CAAC,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAA;IAE5E;;;;;;OAMG;IACH,UAAU,EAAE,IAAI,CAAC,iBAAiB,CAAC,cAAc,EAAE,KAAK,CAAC,EAAE,QAAQ,CAAC,CAAA;CACrE;AAED;;GAEG;AACH,MAAM,WAAW,cAAc,CAAC,cAAc,GAAG,GAAG,EAAE,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,gBAAgB;IACxG;;OAEG;IACH,WAAW,EAAE,KAAK,CAAC,iBAAiB,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAAA;IAE5D;;;;;;OAMG;IACH,qBAAqB,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,iBAAiB,CAAC,cAAc,EAAE,KAAK,CAAC,GAAG,IAAI,CAAA;CACzF;AAED;;;GAGG;AACH,eAAO,MAAM,OAAO,oFAoOlB,CAAA"}
@@ -0,0 +1,38 @@
1
+ import type { Editor } from '@tiptap/core';
2
+ import type { SuggestionOptions } from '@tiptap/suggestion';
3
+ /**
4
+ * Arguments for the `getSuggestionOptions` function
5
+ * @see getSuggestionOptions
6
+ */
7
+ export interface GetSuggestionOptionsOptions {
8
+ /**
9
+ * The Tiptap editor instance.
10
+ */
11
+ editor: Editor;
12
+ /**
13
+ * The suggestion options configuration provided to the
14
+ * `Mention` extension.
15
+ */
16
+ overrideSuggestionOptions: Omit<SuggestionOptions, 'editor'>;
17
+ /**
18
+ * The name of the Mention extension
19
+ */
20
+ extensionName: string;
21
+ /**
22
+ * The character that triggers the suggestion.
23
+ * @default '@'
24
+ */
25
+ char?: string;
26
+ }
27
+ /**
28
+ * Returns the suggestion options for a trigger of the Mention extension. These
29
+ * options are used to create a `Suggestion` ProseMirror plugin. Each plugin lets
30
+ * you define a different trigger that opens the Mention menu. For example,
31
+ * you can define a `@` trigger to mention users and a `#` trigger to mention
32
+ * tags.
33
+ *
34
+ * @param param0 The configured options for the suggestion
35
+ * @returns
36
+ */
37
+ export declare function getSuggestionOptions({ editor: tiptapEditor, overrideSuggestionOptions, extensionName, char, }: GetSuggestionOptionsOptions): SuggestionOptions;
38
+ //# sourceMappingURL=get-default-suggestion-attributes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-default-suggestion-attributes.d.ts","sourceRoot":"","sources":["../../src/utils/get-default-suggestion-attributes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AAE1C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AAE3D;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;;OAGG;IACH,yBAAyB,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,CAAC,CAAA;IAC5D;;OAEG;IACH,aAAa,EAAE,MAAM,CAAA;IACrB;;;OAGG;IACH,IAAI,CAAC,EAAE,MAAM,CAAA;CACd;AAED;;;;;;;;;GASG;AACH,wBAAgB,oBAAoB,CAAC,EACnC,MAAM,EAAE,YAAY,EACpB,yBAAyB,EACzB,aAAa,EACb,IAAU,GACX,EAAE,2BAA2B,GAAG,iBAAiB,CA4CjD"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/extension-mention",
3
3
  "description": "mention extension for tiptap",
4
- "version": "2.22.2",
4
+ "version": "2.23.0",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -29,9 +29,9 @@
29
29
  "dist"
30
30
  ],
31
31
  "devDependencies": {
32
- "@tiptap/core": "^2.22.2",
33
- "@tiptap/pm": "^2.22.2",
34
- "@tiptap/suggestion": "^2.22.2"
32
+ "@tiptap/core": "^2.23.0",
33
+ "@tiptap/pm": "^2.23.0",
34
+ "@tiptap/suggestion": "^2.23.0"
35
35
  },
36
36
  "peerDependencies": {
37
37
  "@tiptap/core": "^2.7.0",