@tiptap/extension-mention 2.0.0-beta.9 → 2.0.0-beta.90

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/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2020, überdosis GbR
3
+ Copyright (c) 2021, überdosis GbR
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -7,8 +7,8 @@
7
7
  ## Introduction
8
8
  tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
9
9
 
10
- ## Offical Documentation
10
+ ## Official Documentation
11
11
  Documentation can be found on the [tiptap website](https://tiptap.dev).
12
12
 
13
13
  ## License
14
- tiptap is open-sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap-next/blob/main/LICENSE.md).
14
+ tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
@@ -1,9 +1,14 @@
1
1
  import { Node } from '@tiptap/core';
2
+ import { Node as ProseMirrorNode } from 'prosemirror-model';
3
+ import { PluginKey } from 'prosemirror-state';
2
4
  import { SuggestionOptions } from '@tiptap/suggestion';
3
5
  export declare type MentionOptions = {
4
- HTMLAttributes: {
5
- [key: string]: any;
6
- };
6
+ HTMLAttributes: Record<string, any>;
7
+ renderLabel: (props: {
8
+ options: MentionOptions;
9
+ node: ProseMirrorNode;
10
+ }) => string;
7
11
  suggestion: Omit<SuggestionOptions, 'editor'>;
8
12
  };
9
- export declare const Mention: Node<MentionOptions>;
13
+ export declare const MentionPluginKey: PluginKey<any, any>;
14
+ export declare const Mention: Node<MentionOptions, any>;
@@ -3,30 +3,58 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var core = require('@tiptap/core');
6
+ var prosemirrorState = require('prosemirror-state');
6
7
  var Suggestion = require('@tiptap/suggestion');
7
8
 
8
9
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
9
10
 
10
11
  var Suggestion__default = /*#__PURE__*/_interopDefaultLegacy(Suggestion);
11
12
 
13
+ const MentionPluginKey = new prosemirrorState.PluginKey('mention');
12
14
  const Mention = core.Node.create({
13
15
  name: 'mention',
14
- defaultOptions: {
15
- HTMLAttributes: {},
16
- suggestion: {
17
- char: '@',
18
- command: ({ editor, range, props }) => {
19
- editor
20
- .chain()
21
- .focus()
22
- .replaceRange(range, 'mention', props)
23
- .insertText(' ')
24
- .run();
16
+ addOptions() {
17
+ return {
18
+ HTMLAttributes: {},
19
+ renderLabel({ options, node }) {
20
+ var _a;
21
+ return `${options.suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`;
25
22
  },
26
- allow: ({ editor, range }) => {
27
- return editor.can().replaceRange(range, 'mention');
23
+ suggestion: {
24
+ char: '@',
25
+ pluginKey: MentionPluginKey,
26
+ command: ({ editor, range, props }) => {
27
+ var _a;
28
+ // increase range.to by one when the next node is of type "text"
29
+ // and starts with a space character
30
+ const nodeAfter = editor.view.state.selection.$to.nodeAfter;
31
+ const overrideSpace = (_a = nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.text) === null || _a === void 0 ? void 0 : _a.startsWith(' ');
32
+ if (overrideSpace) {
33
+ range.to += 1;
34
+ }
35
+ editor
36
+ .chain()
37
+ .focus()
38
+ .insertContentAt(range, [
39
+ {
40
+ type: this.name,
41
+ attrs: props,
42
+ },
43
+ {
44
+ type: 'text',
45
+ text: ' ',
46
+ },
47
+ ])
48
+ .run();
49
+ },
50
+ allow: ({ editor, range }) => {
51
+ const $from = editor.state.doc.resolve(range.from);
52
+ const type = editor.schema.nodes[this.name];
53
+ const allow = !!$from.parent.type.contentMatch.matchType(type);
54
+ return allow;
55
+ },
28
56
  },
29
- },
57
+ };
30
58
  },
31
59
  group: 'inline',
32
60
  inline: true,
@@ -36,17 +64,25 @@ const Mention = core.Node.create({
36
64
  return {
37
65
  id: {
38
66
  default: null,
39
- parseHTML: element => {
67
+ parseHTML: element => element.getAttribute('data-id'),
68
+ renderHTML: attributes => {
69
+ if (!attributes.id) {
70
+ return {};
71
+ }
40
72
  return {
41
- id: element.getAttribute('data-mention'),
73
+ 'data-id': attributes.id,
42
74
  };
43
75
  },
76
+ },
77
+ label: {
78
+ default: null,
79
+ parseHTML: element => element.getAttribute('data-label'),
44
80
  renderHTML: attributes => {
45
- if (!attributes.id) {
81
+ if (!attributes.label) {
46
82
  return {};
47
83
  }
48
84
  return {
49
- 'data-mention': attributes.id,
85
+ 'data-label': attributes.label,
50
86
  };
51
87
  },
52
88
  },
@@ -55,15 +91,25 @@ const Mention = core.Node.create({
55
91
  parseHTML() {
56
92
  return [
57
93
  {
58
- tag: 'span[data-mention]',
94
+ tag: `span[data-type="${this.name}"]`,
59
95
  },
60
96
  ];
61
97
  },
62
98
  renderHTML({ node, HTMLAttributes }) {
63
- return ['span', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id}`];
99
+ return [
100
+ 'span',
101
+ core.mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),
102
+ this.options.renderLabel({
103
+ options: this.options,
104
+ node,
105
+ }),
106
+ ];
64
107
  },
65
108
  renderText({ node }) {
66
- return `@${node.attrs.id}`;
109
+ return this.options.renderLabel({
110
+ options: this.options,
111
+ node,
112
+ });
67
113
  },
68
114
  addKeyboardShortcuts() {
69
115
  return {
@@ -75,7 +121,7 @@ const Mention = core.Node.create({
75
121
  return false;
76
122
  }
77
123
  state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
78
- if (node.type.name === 'mention') {
124
+ if (node.type.name === this.name) {
79
125
  isMention = true;
80
126
  tr.insertText(this.options.suggestion.char || '', pos, pos + node.nodeSize);
81
127
  return false;
@@ -87,7 +133,7 @@ const Mention = core.Node.create({
87
133
  },
88
134
  addProseMirrorPlugins() {
89
135
  return [
90
- Suggestion__default['default']({
136
+ Suggestion__default["default"]({
91
137
  editor: this.editor,
92
138
  ...this.options.suggestion,
93
139
  }),
@@ -96,5 +142,6 @@ const Mention = core.Node.create({
96
142
  });
97
143
 
98
144
  exports.Mention = Mention;
99
- exports.default = Mention;
145
+ exports.MentionPluginKey = MentionPluginKey;
146
+ exports["default"] = Mention;
100
147
  //# sourceMappingURL=tiptap-extension-mention.cjs.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-extension-mention.cjs.js","sources":["../src/mention.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core'\nimport Suggestion, { SuggestionOptions } from '@tiptap/suggestion'\n\nexport type MentionOptions = {\n HTMLAttributes: {\n [key: string]: any,\n },\n suggestion: Omit<SuggestionOptions, 'editor'>,\n}\n\nexport const Mention = Node.create<MentionOptions>({\n name: 'mention',\n\n defaultOptions: {\n HTMLAttributes: {},\n suggestion: {\n char: '@',\n command: ({ editor, range, props }) => {\n editor\n .chain()\n .focus()\n .replaceRange(range, 'mention', props)\n .insertText(' ')\n .run()\n },\n allow: ({ editor, range }) => {\n return editor.can().replaceRange(range, 'mention')\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 => {\n return {\n id: element.getAttribute('data-mention'),\n }\n },\n renderHTML: attributes => {\n if (!attributes.id) {\n return {}\n }\n\n return {\n 'data-mention': attributes.id,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'span[data-mention]',\n },\n ]\n },\n\n renderHTML({ node, HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id}`]\n },\n\n renderText({ node }) {\n return `@${node.attrs.id}`\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 === 'mention') {\n isMention = true\n tr.insertText(this.options.suggestion.char || '', pos, pos + node.nodeSize)\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":["Node","mergeAttributes","Suggestion"],"mappings":";;;;;;;;;;;MAUa,OAAO,GAAGA,SAAI,CAAC,MAAM,CAAiB;IACjD,IAAI,EAAE,SAAS;IAEf,cAAc,EAAE;QACd,cAAc,EAAE,EAAE;QAClB,UAAU,EAAE;YACV,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE;gBAChC,MAAM;qBACH,KAAK,EAAE;qBACP,KAAK,EAAE;qBACP,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC;qBACrC,UAAU,CAAC,GAAG,CAAC;qBACf,GAAG,EAAE,CAAA;aACT;YACD,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE;gBACvB,OAAO,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,SAAS,CAAC,CAAA;aACnD;SACF;KACF;IAED,KAAK,EAAE,QAAQ;IAEf,MAAM,EAAE,IAAI;IAEZ,UAAU,EAAE,KAAK;IAEjB,IAAI,EAAE,IAAI;IAEV,aAAa;QACX,OAAO;YACL,EAAE,EAAE;gBACF,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,OAAO;oBAChB,OAAO;wBACL,EAAE,EAAE,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC;qBACzC,CAAA;iBACF;gBACD,UAAU,EAAE,UAAU;oBACpB,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE;wBAClB,OAA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gBAEF,OAAO,SAAS,CAAA;aACjB,CAAC;SACH,CAAA;KACF;IAED,qBAAqB;QACnB,OAAO;YACLC,8BAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU;aAC3B,CAAC;SACH,CAAA;KACF;CACF;;;;;"}
1
+ {"version":3,"file":"tiptap-extension-mention.cjs.js","sources":["../src/mention.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core'\nimport { Node as ProseMirrorNode } from 'prosemirror-model'\nimport { PluginKey } from 'prosemirror-state'\nimport Suggestion, { SuggestionOptions } from '@tiptap/suggestion'\n\nexport type MentionOptions = {\n HTMLAttributes: Record<string, any>,\n renderLabel: (props: {\n options: MentionOptions,\n node: ProseMirrorNode,\n }) => string,\n suggestion: Omit<SuggestionOptions, 'editor'>,\n}\n\nexport const MentionPluginKey = new PluginKey('mention')\n\nexport const Mention = Node.create<MentionOptions>({\n name: 'mention',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n renderLabel({ options, node }) {\n return `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`\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 allow: ({ editor, range }) => {\n const $from = editor.state.doc.resolve(range.from)\n const type = editor.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 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\n renderText({ node }) {\n return this.options.renderLabel({\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(this.options.suggestion.char || '', pos, pos + node.nodeSize)\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","Suggestion"],"mappings":";;;;;;;;;;;;MAca,gBAAgB,GAAG,IAAIA,0BAAS,CAAC,SAAS,EAAC;MAE3C,OAAO,GAAGC,SAAI,CAAC,MAAM,CAAiB;IACjD,IAAI,EAAE,SAAS;IAEf,UAAU;QACR,OAAO;YACL,cAAc,EAAE,EAAE;YAClB,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;;gBAC3B,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,mCAAI,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;aACxE;Y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AAE,EAAE,KAAK,EAAE;gBAC1D,IAAI,SAAS,GAAG,KAAK,CAAA;gBACrB,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAA;gBAC3B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;gBAEnC,IAAI,CAAC,KAAK,EAAE;oBACV,OAAO,KAAK,CAAA;iBACb;gBAED,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG;oBACnD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC,IAAI,EAAE;wBAChC,SAAS,GAAG,IAAI,CAAA;wBAChB,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAA;wBAE3E,OAAO,KAAK,CAAA;qBACb;iBACF,CAAC,CAAA;gBAEF,OAAO,SAAS,CAAA;aACjB,CAAC;SACH,CAAA;KACF;IAED,qBAAqB;QACnB,OAAO;YACLC,8BAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU;aAC3B,CAAC;SACH,CAAA;KACF;CACF;;;;;;"}
@@ -1,24 +1,52 @@
1
1
  import { Node, mergeAttributes } from '@tiptap/core';
2
+ import { PluginKey } from 'prosemirror-state';
2
3
  import Suggestion from '@tiptap/suggestion';
3
4
 
5
+ const MentionPluginKey = new PluginKey('mention');
4
6
  const Mention = Node.create({
5
7
  name: 'mention',
6
- defaultOptions: {
7
- HTMLAttributes: {},
8
- suggestion: {
9
- char: '@',
10
- command: ({ editor, range, props }) => {
11
- editor
12
- .chain()
13
- .focus()
14
- .replaceRange(range, 'mention', props)
15
- .insertText(' ')
16
- .run();
8
+ addOptions() {
9
+ return {
10
+ HTMLAttributes: {},
11
+ renderLabel({ options, node }) {
12
+ var _a;
13
+ return `${options.suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`;
17
14
  },
18
- allow: ({ editor, range }) => {
19
- return editor.can().replaceRange(range, 'mention');
15
+ suggestion: {
16
+ char: '@',
17
+ pluginKey: MentionPluginKey,
18
+ command: ({ editor, range, props }) => {
19
+ var _a;
20
+ // increase range.to by one when the next node is of type "text"
21
+ // and starts with a space character
22
+ const nodeAfter = editor.view.state.selection.$to.nodeAfter;
23
+ const overrideSpace = (_a = nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.text) === null || _a === void 0 ? void 0 : _a.startsWith(' ');
24
+ if (overrideSpace) {
25
+ range.to += 1;
26
+ }
27
+ editor
28
+ .chain()
29
+ .focus()
30
+ .insertContentAt(range, [
31
+ {
32
+ type: this.name,
33
+ attrs: props,
34
+ },
35
+ {
36
+ type: 'text',
37
+ text: ' ',
38
+ },
39
+ ])
40
+ .run();
41
+ },
42
+ allow: ({ editor, range }) => {
43
+ const $from = editor.state.doc.resolve(range.from);
44
+ const type = editor.schema.nodes[this.name];
45
+ const allow = !!$from.parent.type.contentMatch.matchType(type);
46
+ return allow;
47
+ },
20
48
  },
21
- },
49
+ };
22
50
  },
23
51
  group: 'inline',
24
52
  inline: true,
@@ -28,17 +56,25 @@ const Mention = Node.create({
28
56
  return {
29
57
  id: {
30
58
  default: null,
31
- parseHTML: element => {
59
+ parseHTML: element => element.getAttribute('data-id'),
60
+ renderHTML: attributes => {
61
+ if (!attributes.id) {
62
+ return {};
63
+ }
32
64
  return {
33
- id: element.getAttribute('data-mention'),
65
+ 'data-id': attributes.id,
34
66
  };
35
67
  },
68
+ },
69
+ label: {
70
+ default: null,
71
+ parseHTML: element => element.getAttribute('data-label'),
36
72
  renderHTML: attributes => {
37
- if (!attributes.id) {
73
+ if (!attributes.label) {
38
74
  return {};
39
75
  }
40
76
  return {
41
- 'data-mention': attributes.id,
77
+ 'data-label': attributes.label,
42
78
  };
43
79
  },
44
80
  },
@@ -47,15 +83,25 @@ const Mention = Node.create({
47
83
  parseHTML() {
48
84
  return [
49
85
  {
50
- tag: 'span[data-mention]',
86
+ tag: `span[data-type="${this.name}"]`,
51
87
  },
52
88
  ];
53
89
  },
54
90
  renderHTML({ node, HTMLAttributes }) {
55
- return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id}`];
91
+ return [
92
+ 'span',
93
+ mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),
94
+ this.options.renderLabel({
95
+ options: this.options,
96
+ node,
97
+ }),
98
+ ];
56
99
  },
57
100
  renderText({ node }) {
58
- return `@${node.attrs.id}`;
101
+ return this.options.renderLabel({
102
+ options: this.options,
103
+ node,
104
+ });
59
105
  },
60
106
  addKeyboardShortcuts() {
61
107
  return {
@@ -67,7 +113,7 @@ const Mention = Node.create({
67
113
  return false;
68
114
  }
69
115
  state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
70
- if (node.type.name === 'mention') {
116
+ if (node.type.name === this.name) {
71
117
  isMention = true;
72
118
  tr.insertText(this.options.suggestion.char || '', pos, pos + node.nodeSize);
73
119
  return false;
@@ -87,6 +133,5 @@ const Mention = Node.create({
87
133
  },
88
134
  });
89
135
 
90
- export default Mention;
91
- export { Mention };
136
+ export { Mention, MentionPluginKey, Mention as default };
92
137
  //# sourceMappingURL=tiptap-extension-mention.esm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-extension-mention.esm.js","sources":["../src/mention.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core'\nimport Suggestion, { SuggestionOptions } from '@tiptap/suggestion'\n\nexport type MentionOptions = {\n HTMLAttributes: {\n [key: string]: any,\n },\n suggestion: Omit<SuggestionOptions, 'editor'>,\n}\n\nexport const Mention = Node.create<MentionOptions>({\n name: 'mention',\n\n defaultOptions: {\n HTMLAttributes: {},\n suggestion: {\n char: '@',\n command: ({ editor, range, props }) => {\n editor\n .chain()\n .focus()\n .replaceRange(range, 'mention', props)\n .insertText(' ')\n .run()\n },\n allow: ({ editor, range }) => {\n return editor.can().replaceRange(range, 'mention')\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 => {\n return {\n id: element.getAttribute('data-mention'),\n }\n },\n renderHTML: attributes => {\n if (!attributes.id) {\n return {}\n }\n\n return {\n 'data-mention': attributes.id,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'span[data-mention]',\n },\n ]\n },\n\n renderHTML({ node, HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id}`]\n },\n\n renderText({ node }) {\n return `@${node.attrs.id}`\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 === 'mention') {\n isMention = true\n tr.insertText(this.options.suggestion.char || '', pos, pos + node.nodeSize)\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":[],"mappings":";;;MAUa,OAAO,GAAG,IAAI,CAAC,MAAM,CAAiB;IACjD,IAAI,EAAE,SAAS;IAEf,cAAc,EAAE;QACd,cAAc,EAAE,EAAE;QAClB,UAAU,EAAE;YACV,IAAI,EAAE,GAAG;YACT,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE;gBAChC,MAAM;qBACH,KAAK,EAAE;qBACP,KAAK,EAAE;qBACP,YAAY,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC;qBACrC,UAAU,CAAC,GAAG,CAA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AAG,KAAK,CAAA;gBAC3B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;gBAEnC,IAAI,CAAC,KAAK,EAAE;oBACV,OAAO,KAAK,CAAA;iBACb;gBAED,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG;oBACnD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;wBAChC,SAAS,GAAG,IAAI,CAAA;wBAChB,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAA;wBAE3E,OAAO,KAAK,CAAA;qBACb;iBACF,CAAC,CAAA;gBAEF,OAAO,SAAS,CAAA;aACjB,CAAC;SACH,CAAA;KACF;IAED,qBAAqB;QACnB,OAAO;YACL,UAAU,CAAC;gBACT,MAAM,EAAE,IAAI,CAAC,MAAM;gBACnB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU;aAC3B,CAAC;SACH,CAAA;KACF;CACF;;;;;"}
1
+ {"version":3,"file":"tiptap-extension-mention.esm.js","sources":["../src/mention.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core'\nimport { Node as ProseMirrorNode } from 'prosemirror-model'\nimport { PluginKey } from 'prosemirror-state'\nimport Suggestion, { SuggestionOptions } from '@tiptap/suggestion'\n\nexport type MentionOptions = {\n HTMLAttributes: Record<string, any>,\n renderLabel: (props: {\n options: MentionOptions,\n node: ProseMirrorNode,\n }) => string,\n suggestion: Omit<SuggestionOptions, 'editor'>,\n}\n\nexport const MentionPluginKey = new PluginKey('mention')\n\nexport const Mention = Node.create<MentionOptions>({\n name: 'mention',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n renderLabel({ options, node }) {\n return `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`\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 allow: ({ editor, range }) => {\n const $from = editor.state.doc.resolve(range.from)\n const type = editor.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 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\n renderText({ node }) {\n return this.options.renderLabel({\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(this.options.suggestion.char || '', pos, pos + node.nodeSize)\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":[],"mappings":";;;;MAca,gBAAgB,GAAG,IAAI,SAAS,CAAC,SAAS,EAAC;MAE3C,OAAO,GAAG,IAAI,CAAC,MAAM,CAAiB;IACjD,IAAI,EAAE,SAAS;IAEf,UAAU;QACR,OAAO;YACL,cAAc,EAAE,EAAE;YAClB,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;;gBAC3B,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,mCAAI,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;aACxE;YACD,UAAU,EAAE;gBACV,IAAI,EAAE,GAAG;gBACT,SAAS,EAAE,gBAAgB;gBAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE;;;;oBAGhC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAA;oBAC3D,MAAM,aAAa,GAAG,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,0CAAE,UAAU,CAAC,GAAG,CAAC,CAAA;oBAEtD,IAAI,aAAa,EAAE;wBACjB,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;qBACd;oBAED,MAAM;yBACH,KAAK,EAAE;yBACP,KAAK,EAAE;yBACP,eAAe,CAAC,KAAK,EAAE;wBACtB;4BACE,IAAI,EAAE,IAAI,CAAC,IAAI;4BACf,KAAK,EAAE,KAAK;yBACb;wBACD;4BACE,IAAI,EAAE,MAAM;4BACZ,IAAI,EAAE,GAAG;yBACV;qBACF,CAAC;yBACD,GAAG,EAAE,CAAA;iBACT;gBACD,KAAK,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE;oBACvB,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M,EAAE,IAAI,CAAC,MAAM;gBACnB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU;aAC3B,CAAC;SACH,CAAA;KACF;CACF;;;;"}
@@ -1,31 +1,58 @@
1
1
  (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('@tiptap/suggestion')) :
3
- typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', '@tiptap/suggestion'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global['@tiptap/extension-mention'] = {}, global.core, global.Suggestion));
5
- }(this, (function (exports, core, Suggestion) { 'use strict';
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('prosemirror-state'), require('@tiptap/suggestion')) :
3
+ typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', 'prosemirror-state', '@tiptap/suggestion'], factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-mention"] = {}, global.core, global.prosemirrorState, global.Suggestion));
5
+ })(this, (function (exports, core, prosemirrorState, Suggestion) { 'use strict';
6
6
 
7
7
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
8
 
9
9
  var Suggestion__default = /*#__PURE__*/_interopDefaultLegacy(Suggestion);
10
10
 
11
+ const MentionPluginKey = new prosemirrorState.PluginKey('mention');
11
12
  const Mention = core.Node.create({
12
13
  name: 'mention',
13
- defaultOptions: {
14
- HTMLAttributes: {},
15
- suggestion: {
16
- char: '@',
17
- command: ({ editor, range, props }) => {
18
- editor
19
- .chain()
20
- .focus()
21
- .replaceRange(range, 'mention', props)
22
- .insertText(' ')
23
- .run();
14
+ addOptions() {
15
+ return {
16
+ HTMLAttributes: {},
17
+ renderLabel({ options, node }) {
18
+ var _a;
19
+ return `${options.suggestion.char}${(_a = node.attrs.label) !== null && _a !== void 0 ? _a : node.attrs.id}`;
24
20
  },
25
- allow: ({ editor, range }) => {
26
- return editor.can().replaceRange(range, 'mention');
21
+ suggestion: {
22
+ char: '@',
23
+ pluginKey: MentionPluginKey,
24
+ command: ({ editor, range, props }) => {
25
+ var _a;
26
+ // increase range.to by one when the next node is of type "text"
27
+ // and starts with a space character
28
+ const nodeAfter = editor.view.state.selection.$to.nodeAfter;
29
+ const overrideSpace = (_a = nodeAfter === null || nodeAfter === void 0 ? void 0 : nodeAfter.text) === null || _a === void 0 ? void 0 : _a.startsWith(' ');
30
+ if (overrideSpace) {
31
+ range.to += 1;
32
+ }
33
+ editor
34
+ .chain()
35
+ .focus()
36
+ .insertContentAt(range, [
37
+ {
38
+ type: this.name,
39
+ attrs: props,
40
+ },
41
+ {
42
+ type: 'text',
43
+ text: ' ',
44
+ },
45
+ ])
46
+ .run();
47
+ },
48
+ allow: ({ editor, range }) => {
49
+ const $from = editor.state.doc.resolve(range.from);
50
+ const type = editor.schema.nodes[this.name];
51
+ const allow = !!$from.parent.type.contentMatch.matchType(type);
52
+ return allow;
53
+ },
27
54
  },
28
- },
55
+ };
29
56
  },
30
57
  group: 'inline',
31
58
  inline: true,
@@ -35,17 +62,25 @@
35
62
  return {
36
63
  id: {
37
64
  default: null,
38
- parseHTML: element => {
65
+ parseHTML: element => element.getAttribute('data-id'),
66
+ renderHTML: attributes => {
67
+ if (!attributes.id) {
68
+ return {};
69
+ }
39
70
  return {
40
- id: element.getAttribute('data-mention'),
71
+ 'data-id': attributes.id,
41
72
  };
42
73
  },
74
+ },
75
+ label: {
76
+ default: null,
77
+ parseHTML: element => element.getAttribute('data-label'),
43
78
  renderHTML: attributes => {
44
- if (!attributes.id) {
79
+ if (!attributes.label) {
45
80
  return {};
46
81
  }
47
82
  return {
48
- 'data-mention': attributes.id,
83
+ 'data-label': attributes.label,
49
84
  };
50
85
  },
51
86
  },
@@ -54,15 +89,25 @@
54
89
  parseHTML() {
55
90
  return [
56
91
  {
57
- tag: 'span[data-mention]',
92
+ tag: `span[data-type="${this.name}"]`,
58
93
  },
59
94
  ];
60
95
  },
61
96
  renderHTML({ node, HTMLAttributes }) {
62
- return ['span', core.mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id}`];
97
+ return [
98
+ 'span',
99
+ core.mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),
100
+ this.options.renderLabel({
101
+ options: this.options,
102
+ node,
103
+ }),
104
+ ];
63
105
  },
64
106
  renderText({ node }) {
65
- return `@${node.attrs.id}`;
107
+ return this.options.renderLabel({
108
+ options: this.options,
109
+ node,
110
+ });
66
111
  },
67
112
  addKeyboardShortcuts() {
68
113
  return {
@@ -74,7 +119,7 @@
74
119
  return false;
75
120
  }
76
121
  state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
77
- if (node.type.name === 'mention') {
122
+ if (node.type.name === this.name) {
78
123
  isMention = true;
79
124
  tr.insertText(this.options.suggestion.char || '', pos, pos + node.nodeSize);
80
125
  return false;
@@ -86,7 +131,7 @@
86
131
  },
87
132
  addProseMirrorPlugins() {
88
133
  return [
89
- Suggestion__default['default']({
134
+ Suggestion__default["default"]({
90
135
  editor: this.editor,
91
136
  ...this.options.suggestion,
92
137
  }),
@@ -95,9 +140,10 @@
95
140
  });
96
141
 
97
142
  exports.Mention = Mention;
98
- exports.default = Mention;
143
+ exports.MentionPluginKey = MentionPluginKey;
144
+ exports["default"] = Mention;
99
145
 
100
146
  Object.defineProperty(exports, '__esModule', { value: true });
101
147
 
102
- })));
148
+ }));
103
149
  //# sourceMappingURL=tiptap-extension-mention.umd.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tiptap-extension-mention.umd.js","sources":["../src/mention.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core'\nimport Suggestion, { SuggestionOptions } from '@tiptap/suggestion'\n\nexport type MentionOptions = {\n HTMLAttributes: {\n [key: string]: any,\n },\n suggestion: Omit<SuggestionOptions, 'editor'>,\n}\n\nexport const Mention = Node.create<MentionOptions>({\n name: 'mention',\n\n defaultOptions: {\n HTMLAttributes: {},\n suggestion: {\n char: '@',\n command: ({ editor, range, props }) => {\n editor\n .chain()\n .focus()\n .replaceRange(range, 'mention', props)\n .insertText(' ')\n .run()\n },\n allow: ({ editor, range }) => {\n return editor.can().replaceRange(range, 'mention')\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 => {\n return {\n id: element.getAttribute('data-mention'),\n }\n },\n renderHTML: attributes => {\n if (!attributes.id) {\n return {}\n }\n\n return {\n 'data-mention': attributes.id,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: 'span[data-mention]',\n },\n ]\n },\n\n renderHTML({ node, HTMLAttributes }) {\n return ['span', mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), `@${node.attrs.id}`]\n },\n\n renderText({ node }) {\n return `@${node.attrs.id}`\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 === 'mention') {\n isMention = true\n tr.insertText(this.options.suggestion.char || '', pos, pos + node.nodeSize)\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":["Node","mergeAttributes","Suggestion"],"mappings":";;;;;;;;;;QAUa,OAAO,GAAGA,SAAI,CAAC,MAAM,CAAiB;MACjD,IAAI,EAAE,SAAS;MAEf,cAAc,EAAE;UACd,cAAc,EAAE,EAAE;UAClB,UAAU,EAAE;cACV,IAAI,EAAE,GAAG;cACT,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE;kBAChC,MAAM;uBACH,KAAK,EAAE;uBACP,KAAK,E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,EAAE,KAAK,EAAE;kBAC1D,IAAI,SAAS,GAAG,KAAK,CAAA;kBACrB,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAA;kBAC3B,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;kBAEnC,IAAI,CAAC,KAAK,EAAE;sBACV,OAAO,KAAK,CAAA;mBACb;kBAED,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,MAAM,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,GAAG;sBACnD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS,EAAE;0BAChC,SAAS,GAAG,IAAI,CAAA;0BAChB,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,IAAI,EAAE,EAAE,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAA;0BAE3E,OAAO,KAAK,CAAA;uBACb;mBACF,CAAC,CAAA;kBAEF,OAAO,SAAS,CAAA;eACjB,CAAC;WACH,CAAA;OACF;MAED,qBAAqB;UACnB,OAAO;cACLC,8BAAU,CAAC;kBACT,MAAM,EAAE,IAAI,CAAC,MAAM;kBACnB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU;eAC3B,CAAC;WACH,CAAA;OACF;GACF;;;;;;;;;;;"}
1
+ {"version":3,"file":"tiptap-extension-mention.umd.js","sources":["../src/mention.ts"],"sourcesContent":["import { Node, mergeAttributes } from '@tiptap/core'\nimport { Node as ProseMirrorNode } from 'prosemirror-model'\nimport { PluginKey } from 'prosemirror-state'\nimport Suggestion, { SuggestionOptions } from '@tiptap/suggestion'\n\nexport type MentionOptions = {\n HTMLAttributes: Record<string, any>,\n renderLabel: (props: {\n options: MentionOptions,\n node: ProseMirrorNode,\n }) => string,\n suggestion: Omit<SuggestionOptions, 'editor'>,\n}\n\nexport const MentionPluginKey = new PluginKey('mention')\n\nexport const Mention = Node.create<MentionOptions>({\n name: 'mention',\n\n addOptions() {\n return {\n HTMLAttributes: {},\n renderLabel({ options, node }) {\n return `${options.suggestion.char}${node.attrs.label ?? node.attrs.id}`\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 allow: ({ editor, range }) => {\n const $from = editor.state.doc.resolve(range.from)\n const type = editor.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 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\n renderText({ node }) {\n return this.options.renderLabel({\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(this.options.suggestion.char || '', pos, pos + node.nodeSize)\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","Suggestion"],"mappings":";;;;;;;;;;QAca,gBAAgB,GAAG,IAAIA,0BAAS,CAAC,SAAS,EAAC;QAE3C,OAAO,GAAGC,SAAI,CAAC,MAAM,CAAiB;MACjD,IAAI,EAAE,SAAS;MAEf,UAAU;UACR,OAAO;cACL,cAAc,EAAE,EAAE;cAClB,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;;kBAC3B,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,IAAI,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,mCAAI,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;eACxE;cACD,UAAU,EAAE;kBACV,IAAI,EAAE,GAAG;kBACT,SAAS,EAAE,gBAAgB;kBAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE;;;;sBAGhC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAA;sBAC3D,MAAM,aAAa,GAAG,MAAA,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,IAAI,0CAAE,UAAU,CAAC,GAAG,CAAC,CAAA;sBAEtD,IAAI,aAAa,EAAE;0BACjB,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;uBACd;sBAED,MAAM;2BACH,KAAK,EAAE;2BACP,KAAK,EAAE;2BACP,eAAe,CAAC,KAAK,EAAE;0BACtB;8BACE,IAAI,EAAE,IAAI,CAAC,IAAI;8BACf,KAAK,EAAE,KAAK;2BACb;0BACD;8BACE,IAAI,EAAE,MA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KAAK,CAAA;uBACb;mBACF,CAAC,CAAA;kBAEF,OAAO,SAAS,CAAA;eACjB,CAAC;WACH,CAAA;OACF;MAED,qBAAqB;UACnB,OAAO;cACLC,8BAAU,CAAC;kBACT,MAAM,EAAE,IAAI,CAAC,MAAM;kBACnB,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU;eAC3B,CAAC;WACH,CAAA;OACF;GACF;;;;;;;;;;;;"}
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.0.0-beta.9",
4
+ "version": "2.0.0-beta.90",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -15,7 +15,6 @@
15
15
  "main": "dist/tiptap-extension-mention.cjs.js",
16
16
  "umd": "dist/tiptap-extension-mention.umd.js",
17
17
  "module": "dist/tiptap-extension-mention.esm.js",
18
- "unpkg": "dist/tiptap-extension-mention.bundle.umd.min.js",
19
18
  "types": "dist/packages/extension-mention/src/index.d.ts",
20
19
  "files": [
21
20
  "src",
@@ -25,7 +24,14 @@
25
24
  "@tiptap/core": "^2.0.0-beta.1"
26
25
  },
27
26
  "dependencies": {
28
- "@tiptap/suggestion": "^2.0.0-beta.9"
27
+ "@tiptap/suggestion": "^2.0.0-beta.85",
28
+ "prosemirror-model": "^1.15.0",
29
+ "prosemirror-state": "^1.3.4"
29
30
  },
30
- "gitHead": "1a7288eb3ba9fda08e8c85e8e9bdb3f9ad84de69"
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/ueberdosis/tiptap",
34
+ "directory": "packages/extension-mention"
35
+ },
36
+ "gitHead": "8347f58167e3dc9a78bf6b834af999f86d3bc5bd"
31
37
  }