@tiptap/extension-mention 2.0.0-beta.213 → 2.0.0-beta.215
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.cjs +143 -132
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +136 -135
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +150 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/packages/extension-mention/src/index.d.ts +3 -0
- package/dist/packages/extension-mention/src/mention.d.ts +14 -0
- package/package.json +9 -18
- package/dist/index.d.ts +0 -17
package/dist/index.cjs
CHANGED
|
@@ -1,137 +1,148 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var _suggestion = require('@tiptap/suggestion'); var _suggestion2 = _interopRequireDefault(_suggestion);
|
|
5
|
-
var MentionPluginKey = new (0, _state.PluginKey)("mention");
|
|
6
|
-
var Mention = _core.Node.create({
|
|
7
|
-
name: "mention",
|
|
8
|
-
addOptions() {
|
|
9
|
-
return {
|
|
10
|
-
HTMLAttributes: {},
|
|
11
|
-
renderLabel({ options, node }) {
|
|
12
|
-
var _a;
|
|
13
|
-
return `${options.suggestion.char}${(_a = node.attrs.label) != null ? _a : node.attrs.id}`;
|
|
14
|
-
},
|
|
15
|
-
suggestion: {
|
|
16
|
-
char: "@",
|
|
17
|
-
pluginKey: MentionPluginKey,
|
|
18
|
-
command: ({ editor, range, props }) => {
|
|
19
|
-
var _a, _b;
|
|
20
|
-
const nodeAfter = editor.view.state.selection.$to.nodeAfter;
|
|
21
|
-
const overrideSpace = (_a = nodeAfter == null ? void 0 : nodeAfter.text) == null ? void 0 : _a.startsWith(" ");
|
|
22
|
-
if (overrideSpace) {
|
|
23
|
-
range.to += 1;
|
|
24
|
-
}
|
|
25
|
-
editor.chain().focus().insertContentAt(range, [
|
|
26
|
-
{
|
|
27
|
-
type: this.name,
|
|
28
|
-
attrs: props
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
type: "text",
|
|
32
|
-
text: " "
|
|
33
|
-
}
|
|
34
|
-
]).run();
|
|
35
|
-
(_b = window.getSelection()) == null ? void 0 : _b.collapseToEnd();
|
|
36
|
-
},
|
|
37
|
-
allow: ({ state, range }) => {
|
|
38
|
-
const $from = state.doc.resolve(range.from);
|
|
39
|
-
const type = state.schema.nodes[this.name];
|
|
40
|
-
const allow = !!$from.parent.type.contentMatch.matchType(type);
|
|
41
|
-
return allow;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
},
|
|
46
|
-
group: "inline",
|
|
47
|
-
inline: true,
|
|
48
|
-
selectable: false,
|
|
49
|
-
atom: true,
|
|
50
|
-
addAttributes() {
|
|
51
|
-
return {
|
|
52
|
-
id: {
|
|
53
|
-
default: null,
|
|
54
|
-
parseHTML: (element) => element.getAttribute("data-id"),
|
|
55
|
-
renderHTML: (attributes) => {
|
|
56
|
-
if (!attributes.id) {
|
|
57
|
-
return {};
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
"data-id": attributes.id
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
},
|
|
64
|
-
label: {
|
|
65
|
-
default: null,
|
|
66
|
-
parseHTML: (element) => element.getAttribute("data-label"),
|
|
67
|
-
renderHTML: (attributes) => {
|
|
68
|
-
if (!attributes.label) {
|
|
69
|
-
return {};
|
|
70
|
-
}
|
|
71
|
-
return {
|
|
72
|
-
"data-label": attributes.label
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
},
|
|
78
|
-
parseHTML() {
|
|
79
|
-
return [
|
|
80
|
-
{
|
|
81
|
-
tag: `span[data-type="${this.name}"]`
|
|
82
|
-
}
|
|
83
|
-
];
|
|
84
|
-
},
|
|
85
|
-
renderHTML({ node, HTMLAttributes }) {
|
|
86
|
-
return [
|
|
87
|
-
"span",
|
|
88
|
-
_core.mergeAttributes.call(void 0, { "data-type": this.name }, this.options.HTMLAttributes, HTMLAttributes),
|
|
89
|
-
this.options.renderLabel({
|
|
90
|
-
options: this.options,
|
|
91
|
-
node
|
|
92
|
-
})
|
|
93
|
-
];
|
|
94
|
-
},
|
|
95
|
-
renderText({ node }) {
|
|
96
|
-
return this.options.renderLabel({
|
|
97
|
-
options: this.options,
|
|
98
|
-
node
|
|
99
|
-
});
|
|
100
|
-
},
|
|
101
|
-
addKeyboardShortcuts() {
|
|
102
|
-
return {
|
|
103
|
-
Backspace: () => this.editor.commands.command(({ tr, state }) => {
|
|
104
|
-
let isMention = false;
|
|
105
|
-
const { selection } = state;
|
|
106
|
-
const { empty, anchor } = selection;
|
|
107
|
-
if (!empty) {
|
|
108
|
-
return false;
|
|
109
|
-
}
|
|
110
|
-
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
111
|
-
if (node.type.name === this.name) {
|
|
112
|
-
isMention = true;
|
|
113
|
-
tr.insertText(this.options.suggestion.char || "", pos, pos + node.nodeSize);
|
|
114
|
-
return false;
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
return isMention;
|
|
118
|
-
})
|
|
119
|
-
};
|
|
120
|
-
},
|
|
121
|
-
addProseMirrorPlugins() {
|
|
122
|
-
return [
|
|
123
|
-
_suggestion2.default.call(void 0, {
|
|
124
|
-
editor: this.editor,
|
|
125
|
-
...this.options.suggestion
|
|
126
|
-
})
|
|
127
|
-
];
|
|
128
|
-
}
|
|
129
|
-
});
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
130
4
|
|
|
131
|
-
|
|
132
|
-
var
|
|
5
|
+
var core = require('@tiptap/core');
|
|
6
|
+
var state = require('@tiptap/pm/state');
|
|
7
|
+
var Suggestion = require('@tiptap/suggestion');
|
|
133
8
|
|
|
9
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
134
10
|
|
|
11
|
+
var Suggestion__default = /*#__PURE__*/_interopDefaultLegacy(Suggestion);
|
|
135
12
|
|
|
13
|
+
const MentionPluginKey = new state.PluginKey('mention');
|
|
14
|
+
const Mention = core.Node.create({
|
|
15
|
+
name: 'mention',
|
|
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}`;
|
|
22
|
+
},
|
|
23
|
+
suggestion: {
|
|
24
|
+
char: '@',
|
|
25
|
+
pluginKey: MentionPluginKey,
|
|
26
|
+
command: ({ editor, range, props }) => {
|
|
27
|
+
var _a, _b;
|
|
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
|
+
(_b = window.getSelection()) === null || _b === void 0 ? void 0 : _b.collapseToEnd();
|
|
50
|
+
},
|
|
51
|
+
allow: ({ state, range }) => {
|
|
52
|
+
const $from = state.doc.resolve(range.from);
|
|
53
|
+
const type = state.schema.nodes[this.name];
|
|
54
|
+
const allow = !!$from.parent.type.contentMatch.matchType(type);
|
|
55
|
+
return allow;
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
group: 'inline',
|
|
61
|
+
inline: true,
|
|
62
|
+
selectable: false,
|
|
63
|
+
atom: true,
|
|
64
|
+
addAttributes() {
|
|
65
|
+
return {
|
|
66
|
+
id: {
|
|
67
|
+
default: null,
|
|
68
|
+
parseHTML: element => element.getAttribute('data-id'),
|
|
69
|
+
renderHTML: attributes => {
|
|
70
|
+
if (!attributes.id) {
|
|
71
|
+
return {};
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
'data-id': attributes.id,
|
|
75
|
+
};
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
label: {
|
|
79
|
+
default: null,
|
|
80
|
+
parseHTML: element => element.getAttribute('data-label'),
|
|
81
|
+
renderHTML: attributes => {
|
|
82
|
+
if (!attributes.label) {
|
|
83
|
+
return {};
|
|
84
|
+
}
|
|
85
|
+
return {
|
|
86
|
+
'data-label': attributes.label,
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
};
|
|
91
|
+
},
|
|
92
|
+
parseHTML() {
|
|
93
|
+
return [
|
|
94
|
+
{
|
|
95
|
+
tag: `span[data-type="${this.name}"]`,
|
|
96
|
+
},
|
|
97
|
+
];
|
|
98
|
+
},
|
|
99
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
100
|
+
return [
|
|
101
|
+
'span',
|
|
102
|
+
core.mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),
|
|
103
|
+
this.options.renderLabel({
|
|
104
|
+
options: this.options,
|
|
105
|
+
node,
|
|
106
|
+
}),
|
|
107
|
+
];
|
|
108
|
+
},
|
|
109
|
+
renderText({ node }) {
|
|
110
|
+
return this.options.renderLabel({
|
|
111
|
+
options: this.options,
|
|
112
|
+
node,
|
|
113
|
+
});
|
|
114
|
+
},
|
|
115
|
+
addKeyboardShortcuts() {
|
|
116
|
+
return {
|
|
117
|
+
Backspace: () => this.editor.commands.command(({ tr, state }) => {
|
|
118
|
+
let isMention = false;
|
|
119
|
+
const { selection } = state;
|
|
120
|
+
const { empty, anchor } = selection;
|
|
121
|
+
if (!empty) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
125
|
+
if (node.type.name === this.name) {
|
|
126
|
+
isMention = true;
|
|
127
|
+
tr.insertText(this.options.suggestion.char || '', pos, pos + node.nodeSize);
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return isMention;
|
|
132
|
+
}),
|
|
133
|
+
};
|
|
134
|
+
},
|
|
135
|
+
addProseMirrorPlugins() {
|
|
136
|
+
return [
|
|
137
|
+
Suggestion__default["default"]({
|
|
138
|
+
editor: this.editor,
|
|
139
|
+
...this.options.suggestion,
|
|
140
|
+
}),
|
|
141
|
+
];
|
|
142
|
+
},
|
|
143
|
+
});
|
|
136
144
|
|
|
137
|
-
exports.Mention = Mention;
|
|
145
|
+
exports.Mention = Mention;
|
|
146
|
+
exports.MentionPluginKey = MentionPluginKey;
|
|
147
|
+
exports["default"] = Mention;
|
|
148
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.cjs","sources":["../src/mention.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\nimport { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { PluginKey } from '@tiptap/pm/state'\nimport Suggestion, { SuggestionOptions } from '@tiptap/suggestion'\n\nexport type MentionOptions = {\n HTMLAttributes: Record<string, any>\n renderLabel: (props: { options: MentionOptions; node: ProseMirrorNode }) => 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 window.getSelection()?.collapseToEnd()\n },\n allow: ({ state, range }) => {\n const $from = state.doc.resolve(range.from)\n const type = state.schema.nodes[this.name]\n const allow = !!$from.parent.type.contentMatch.matchType(type)\n\n return allow\n },\n },\n }\n },\n\n group: 'inline',\n\n inline: true,\n\n selectable: false,\n\n atom: true,\n\n addAttributes() {\n return {\n id: {\n default: null,\n parseHTML: element => element.getAttribute('data-id'),\n renderHTML: attributes => {\n if (!attributes.id) {\n return {}\n }\n\n return {\n 'data-id': attributes.id,\n }\n },\n },\n\n label: {\n default: null,\n parseHTML: element => element.getAttribute('data-label'),\n renderHTML: attributes => {\n if (!attributes.label) {\n return {}\n }\n\n return {\n 'data-label': attributes.label,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: `span[data-type=\"${this.name}\"]`,\n },\n ]\n },\n\n renderHTML({ node, HTMLAttributes }) {\n 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":";;;;;;;;;;;;MAWa,gBAAgB,GAAG,IAAIA,eAAS,CAAC,SAAS,EAAC;AAE3C,MAAA,OAAO,GAAGC,SAAI,CAAC,MAAM,CAAiB;AACjD,IAAA,IAAI,EAAE,SAAS;IAEf,UAAU,GAAA;QACR,OAAO;AACL,YAAA,cAAc,EAAE,EAAE;AAClB,YAAA,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAA;;gBAC3B,OAAO,CAAA,EAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAA,EAAG,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,mCAAI,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;aACxE;AACD,YAAA,UAAU,EAAE;AACV,gBAAA,IAAI,EAAE,GAAG;AACT,gBAAA,SAAS,EAAE,gBAAgB;gBAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAI;;;;AAGpC,oBAAA,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAA;AAC3D,oBAAA,MAAM,aAAa,GAAG,CAAA,EAAA,GAAA,SAAS,aAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,IAAI,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,UAAU,CAAC,GAAG,CAAC,CAAA;AAEtD,oBAAA,IAAI,aAAa,EAAE;AACjB,wBAAA,KAAK,CAAC,EAAE,IAAI,CAAC,CAAA;AACd,qBAAA;oBAED,MAAM;AACH,yBAAA,KAAK,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-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
1
|
+
import { Node, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
import { PluginKey } from '@tiptap/pm/state';
|
|
3
|
+
import Suggestion from '@tiptap/suggestion';
|
|
4
|
+
|
|
5
|
+
const MentionPluginKey = new PluginKey('mention');
|
|
6
|
+
const Mention = Node.create({
|
|
7
|
+
name: 'mention',
|
|
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}`;
|
|
14
|
+
},
|
|
15
|
+
suggestion: {
|
|
16
|
+
char: '@',
|
|
17
|
+
pluginKey: MentionPluginKey,
|
|
18
|
+
command: ({ editor, range, props }) => {
|
|
19
|
+
var _a, _b;
|
|
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
|
+
(_b = window.getSelection()) === null || _b === void 0 ? void 0 : _b.collapseToEnd();
|
|
42
|
+
},
|
|
43
|
+
allow: ({ state, range }) => {
|
|
44
|
+
const $from = state.doc.resolve(range.from);
|
|
45
|
+
const type = state.schema.nodes[this.name];
|
|
46
|
+
const allow = !!$from.parent.type.contentMatch.matchType(type);
|
|
47
|
+
return allow;
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
},
|
|
52
|
+
group: 'inline',
|
|
53
|
+
inline: true,
|
|
54
|
+
selectable: false,
|
|
55
|
+
atom: true,
|
|
56
|
+
addAttributes() {
|
|
57
|
+
return {
|
|
58
|
+
id: {
|
|
59
|
+
default: null,
|
|
60
|
+
parseHTML: element => element.getAttribute('data-id'),
|
|
61
|
+
renderHTML: attributes => {
|
|
62
|
+
if (!attributes.id) {
|
|
63
|
+
return {};
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
'data-id': attributes.id,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
label: {
|
|
71
|
+
default: null,
|
|
72
|
+
parseHTML: element => element.getAttribute('data-label'),
|
|
73
|
+
renderHTML: attributes => {
|
|
74
|
+
if (!attributes.label) {
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
'data-label': attributes.label,
|
|
79
|
+
};
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
};
|
|
83
|
+
},
|
|
84
|
+
parseHTML() {
|
|
85
|
+
return [
|
|
86
|
+
{
|
|
87
|
+
tag: `span[data-type="${this.name}"]`,
|
|
88
|
+
},
|
|
89
|
+
];
|
|
90
|
+
},
|
|
91
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
92
|
+
return [
|
|
93
|
+
'span',
|
|
94
|
+
mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),
|
|
95
|
+
this.options.renderLabel({
|
|
96
|
+
options: this.options,
|
|
97
|
+
node,
|
|
98
|
+
}),
|
|
99
|
+
];
|
|
100
|
+
},
|
|
101
|
+
renderText({ node }) {
|
|
102
|
+
return this.options.renderLabel({
|
|
103
|
+
options: this.options,
|
|
104
|
+
node,
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
addKeyboardShortcuts() {
|
|
108
|
+
return {
|
|
109
|
+
Backspace: () => this.editor.commands.command(({ tr, state }) => {
|
|
110
|
+
let isMention = false;
|
|
111
|
+
const { selection } = state;
|
|
112
|
+
const { empty, anchor } = selection;
|
|
113
|
+
if (!empty) {
|
|
114
|
+
return false;
|
|
115
|
+
}
|
|
116
|
+
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
117
|
+
if (node.type.name === this.name) {
|
|
118
|
+
isMention = true;
|
|
119
|
+
tr.insertText(this.options.suggestion.char || '', pos, pos + node.nodeSize);
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
return isMention;
|
|
124
|
+
}),
|
|
125
|
+
};
|
|
126
|
+
},
|
|
127
|
+
addProseMirrorPlugins() {
|
|
128
|
+
return [
|
|
129
|
+
Suggestion({
|
|
130
|
+
editor: this.editor,
|
|
131
|
+
...this.options.suggestion,
|
|
132
|
+
}),
|
|
133
|
+
];
|
|
134
|
+
},
|
|
129
135
|
});
|
|
130
136
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
export {
|
|
134
|
-
Mention,
|
|
135
|
-
MentionPluginKey,
|
|
136
|
-
src_default as default
|
|
137
|
-
};
|
|
137
|
+
export { Mention, MentionPluginKey, Mention as default };
|
|
138
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../src/mention.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\nimport { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { PluginKey } from '@tiptap/pm/state'\nimport Suggestion, { SuggestionOptions } from '@tiptap/suggestion'\n\nexport type MentionOptions = {\n HTMLAttributes: Record<string, any>\n renderLabel: (props: { options: MentionOptions; node: ProseMirrorNode }) => 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 window.getSelection()?.collapseToEnd()\n },\n allow: ({ state, range }) => {\n const $from = state.doc.resolve(range.from)\n const type = state.schema.nodes[this.name]\n const allow = !!$from.parent.type.contentMatch.matchType(type)\n\n return allow\n },\n },\n }\n },\n\n group: 'inline',\n\n inline: true,\n\n selectable: false,\n\n atom: true,\n\n addAttributes() {\n return {\n id: {\n default: null,\n parseHTML: element => element.getAttribute('data-id'),\n renderHTML: attributes => {\n if (!attributes.id) {\n return {}\n }\n\n return {\n 'data-id': attributes.id,\n }\n },\n },\n\n label: {\n default: null,\n parseHTML: element => element.getAttribute('data-label'),\n renderHTML: attributes => {\n if (!attributes.label) {\n return {}\n }\n\n return {\n 'data-label': attributes.label,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: `span[data-type=\"${this.name}\"]`,\n },\n ]\n },\n\n renderHTML({ node, HTMLAttributes }) {\n 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":";;;;MAWa,gBAAgB,GAAG,IAAI,SAAS,CAAC,SAAS,EAAC;AAE3C,MAAA,OAAO,GAAG,IAAI,CAAC,MAAM,CAAiB;AACjD,IAAA,IAAI,EAAE,SAAS;IAEf,UAAU,GAAA;QACR,OAAO;AACL,YAAA,cAAc,EAAE,EAAE;AAClB,YAAA,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAA;;gBAC3B,OAAO,CAAA,EAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAA,EAAG,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,mCAAI,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;aACxE;AACD,YAAA,UAAU,EAAE;AACV,gBAAA,IAAI,EAAE,GAAG;AACT,gBAAA,SAAS,EAAE,gBAAgB;gBAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAI;;;;AAGpC,oBAAA,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAA;AAC3D,oBAAA,MAAM,aAAa,GAAG,CAAA,EAAA,GAAA,SAAS,aAAT,SAAS,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAT,SAAS,CAAE,IAAI,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,UAAU,CAA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,CAAC,CAAA;KACH;IAED,oBAAoB,GAAA;QAClB,OAAO;AACL,YAAA,SAAS,EAAE,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAI;gBAC9D,IAAI,SAAS,GAAG,KAAK,CAAA;AACrB,gBAAA,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,CAAA;AAC3B,gBAAA,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,CAAA;gBAEnC,IAAI,CAAC,KAAK,EAAE;AACV,oBAAA,OAAO,KAAK,CAAA;AACb,iBAAA;AAED,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,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;AAE3E,wBAAA,OAAO,KAAK,CAAA;AACb,qBAAA;AACH,iBAAC,CAAC,CAAA;AAEF,gBAAA,OAAO,SAAS,CAAA;AAClB,aAAC,CAAC;SACH,CAAA;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,CAAA;KACF;AACF,CAAA;;;;"}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@tiptap/core'), require('@tiptap/pm/state'), require('@tiptap/suggestion')) :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(['exports', '@tiptap/core', '@tiptap/pm/state', '@tiptap/suggestion'], factory) :
|
|
4
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global["@tiptap/extension-mention"] = {}, global.core, global.state, global.Suggestion));
|
|
5
|
+
})(this, (function (exports, core, state, Suggestion) { 'use strict';
|
|
6
|
+
|
|
7
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
8
|
+
|
|
9
|
+
var Suggestion__default = /*#__PURE__*/_interopDefaultLegacy(Suggestion);
|
|
10
|
+
|
|
11
|
+
const MentionPluginKey = new state.PluginKey('mention');
|
|
12
|
+
const Mention = core.Node.create({
|
|
13
|
+
name: 'mention',
|
|
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}`;
|
|
20
|
+
},
|
|
21
|
+
suggestion: {
|
|
22
|
+
char: '@',
|
|
23
|
+
pluginKey: MentionPluginKey,
|
|
24
|
+
command: ({ editor, range, props }) => {
|
|
25
|
+
var _a, _b;
|
|
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
|
+
(_b = window.getSelection()) === null || _b === void 0 ? void 0 : _b.collapseToEnd();
|
|
48
|
+
},
|
|
49
|
+
allow: ({ state, range }) => {
|
|
50
|
+
const $from = state.doc.resolve(range.from);
|
|
51
|
+
const type = state.schema.nodes[this.name];
|
|
52
|
+
const allow = !!$from.parent.type.contentMatch.matchType(type);
|
|
53
|
+
return allow;
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
group: 'inline',
|
|
59
|
+
inline: true,
|
|
60
|
+
selectable: false,
|
|
61
|
+
atom: true,
|
|
62
|
+
addAttributes() {
|
|
63
|
+
return {
|
|
64
|
+
id: {
|
|
65
|
+
default: null,
|
|
66
|
+
parseHTML: element => element.getAttribute('data-id'),
|
|
67
|
+
renderHTML: attributes => {
|
|
68
|
+
if (!attributes.id) {
|
|
69
|
+
return {};
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
'data-id': attributes.id,
|
|
73
|
+
};
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
label: {
|
|
77
|
+
default: null,
|
|
78
|
+
parseHTML: element => element.getAttribute('data-label'),
|
|
79
|
+
renderHTML: attributes => {
|
|
80
|
+
if (!attributes.label) {
|
|
81
|
+
return {};
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
'data-label': attributes.label,
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
};
|
|
89
|
+
},
|
|
90
|
+
parseHTML() {
|
|
91
|
+
return [
|
|
92
|
+
{
|
|
93
|
+
tag: `span[data-type="${this.name}"]`,
|
|
94
|
+
},
|
|
95
|
+
];
|
|
96
|
+
},
|
|
97
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
98
|
+
return [
|
|
99
|
+
'span',
|
|
100
|
+
core.mergeAttributes({ 'data-type': this.name }, this.options.HTMLAttributes, HTMLAttributes),
|
|
101
|
+
this.options.renderLabel({
|
|
102
|
+
options: this.options,
|
|
103
|
+
node,
|
|
104
|
+
}),
|
|
105
|
+
];
|
|
106
|
+
},
|
|
107
|
+
renderText({ node }) {
|
|
108
|
+
return this.options.renderLabel({
|
|
109
|
+
options: this.options,
|
|
110
|
+
node,
|
|
111
|
+
});
|
|
112
|
+
},
|
|
113
|
+
addKeyboardShortcuts() {
|
|
114
|
+
return {
|
|
115
|
+
Backspace: () => this.editor.commands.command(({ tr, state }) => {
|
|
116
|
+
let isMention = false;
|
|
117
|
+
const { selection } = state;
|
|
118
|
+
const { empty, anchor } = selection;
|
|
119
|
+
if (!empty) {
|
|
120
|
+
return false;
|
|
121
|
+
}
|
|
122
|
+
state.doc.nodesBetween(anchor - 1, anchor, (node, pos) => {
|
|
123
|
+
if (node.type.name === this.name) {
|
|
124
|
+
isMention = true;
|
|
125
|
+
tr.insertText(this.options.suggestion.char || '', pos, pos + node.nodeSize);
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
return isMention;
|
|
130
|
+
}),
|
|
131
|
+
};
|
|
132
|
+
},
|
|
133
|
+
addProseMirrorPlugins() {
|
|
134
|
+
return [
|
|
135
|
+
Suggestion__default["default"]({
|
|
136
|
+
editor: this.editor,
|
|
137
|
+
...this.options.suggestion,
|
|
138
|
+
}),
|
|
139
|
+
];
|
|
140
|
+
},
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
exports.Mention = Mention;
|
|
144
|
+
exports.MentionPluginKey = MentionPluginKey;
|
|
145
|
+
exports["default"] = Mention;
|
|
146
|
+
|
|
147
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
148
|
+
|
|
149
|
+
}));
|
|
150
|
+
//# sourceMappingURL=index.umd.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.umd.js","sources":["../src/mention.ts"],"sourcesContent":["import { mergeAttributes, Node } from '@tiptap/core'\nimport { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { PluginKey } from '@tiptap/pm/state'\nimport Suggestion, { SuggestionOptions } from '@tiptap/suggestion'\n\nexport type MentionOptions = {\n HTMLAttributes: Record<string, any>\n renderLabel: (props: { options: MentionOptions; node: ProseMirrorNode }) => 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 window.getSelection()?.collapseToEnd()\n },\n allow: ({ state, range }) => {\n const $from = state.doc.resolve(range.from)\n const type = state.schema.nodes[this.name]\n const allow = !!$from.parent.type.contentMatch.matchType(type)\n\n return allow\n },\n },\n }\n },\n\n group: 'inline',\n\n inline: true,\n\n selectable: false,\n\n atom: true,\n\n addAttributes() {\n return {\n id: {\n default: null,\n parseHTML: element => element.getAttribute('data-id'),\n renderHTML: attributes => {\n if (!attributes.id) {\n return {}\n }\n\n return {\n 'data-id': attributes.id,\n }\n },\n },\n\n label: {\n default: null,\n parseHTML: element => element.getAttribute('data-label'),\n renderHTML: attributes => {\n if (!attributes.label) {\n return {}\n }\n\n return {\n 'data-label': attributes.label,\n }\n },\n },\n }\n },\n\n parseHTML() {\n return [\n {\n tag: `span[data-type=\"${this.name}\"]`,\n },\n ]\n },\n\n renderHTML({ node, HTMLAttributes }) {\n 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":";;;;;;;;;;QAWa,gBAAgB,GAAG,IAAIA,eAAS,CAAC,SAAS,EAAC;AAE3C,QAAA,OAAO,GAAGC,SAAI,CAAC,MAAM,CAAiB;EACjD,IAAA,IAAI,EAAE,SAAS;MAEf,UAAU,GAAA;UACR,OAAO;EACL,YAAA,cAAc,EAAE,EAAE;EAClB,YAAA,WAAW,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,EAAA;;kBAC3B,OAAO,CAAA,EAAG,OAAO,CAAC,UAAU,CAAC,IAAI,CAAA,EAAG,MAAA,IAAI,CAAC,KAAK,CAAC,KAAK,mCAAI,IAAI,CAAC,KAAK,CAAC,EAAE,EAAE,CAAA;eACxE;EACD,YAAA,UAAU,EAAE;EACV,gBAAA,IAAI,EAAE,GAAG;EACT,gBAAA,SAAS,EAAE,gBAAgB;kBAC3B,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,KAAI;;;;EAGpC,oBAAA,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAA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kBACT,MAAM,EAAE,IAAI,CAAC,MAAM;EACnB,gBAAA,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU;eAC3B,CAAC;WACH,CAAA;OACF;EACF,CAAA;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Node } from '@tiptap/core';
|
|
2
|
+
import { Node as ProseMirrorNode } from '@tiptap/pm/model';
|
|
3
|
+
import { PluginKey } from '@tiptap/pm/state';
|
|
4
|
+
import { SuggestionOptions } from '@tiptap/suggestion';
|
|
5
|
+
export declare type MentionOptions = {
|
|
6
|
+
HTMLAttributes: Record<string, any>;
|
|
7
|
+
renderLabel: (props: {
|
|
8
|
+
options: MentionOptions;
|
|
9
|
+
node: ProseMirrorNode;
|
|
10
|
+
}) => string;
|
|
11
|
+
suggestion: Omit<SuggestionOptions, 'editor'>;
|
|
12
|
+
};
|
|
13
|
+
export declare const MentionPluginKey: PluginKey<any>;
|
|
14
|
+
export declare const Mention: Node<MentionOptions, any>;
|
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.
|
|
4
|
+
"version": "2.0.0-beta.215",
|
|
5
5
|
"homepage": "https://tiptap.dev",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -15,14 +15,15 @@
|
|
|
15
15
|
"type": "module",
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
|
-
"types": "./dist/index.d.ts",
|
|
18
|
+
"types": "./dist/packages/extension-mention/src/index.d.ts",
|
|
19
19
|
"import": "./dist/index.js",
|
|
20
20
|
"require": "./dist/index.cjs"
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"main": "dist/index.cjs",
|
|
24
24
|
"module": "dist/index.js",
|
|
25
|
-
"
|
|
25
|
+
"umd": "dist/index.umd.js",
|
|
26
|
+
"types": "dist/packages/extension-mention/src/index.d.ts",
|
|
26
27
|
"files": [
|
|
27
28
|
"src",
|
|
28
29
|
"dist"
|
|
@@ -33,9 +34,9 @@
|
|
|
33
34
|
"@tiptap/suggestion": "^2.0.0-beta.209"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
|
-
"@tiptap/core": "^2.0.0-beta.
|
|
37
|
-
"@tiptap/pm": "^2.0.0-beta.
|
|
38
|
-
"@tiptap/suggestion": "^2.0.0-beta.
|
|
37
|
+
"@tiptap/core": "^2.0.0-beta.215",
|
|
38
|
+
"@tiptap/pm": "^2.0.0-beta.215",
|
|
39
|
+
"@tiptap/suggestion": "^2.0.0-beta.215"
|
|
39
40
|
},
|
|
40
41
|
"repository": {
|
|
41
42
|
"type": "git",
|
|
@@ -43,17 +44,7 @@
|
|
|
43
44
|
"directory": "packages/extension-mention"
|
|
44
45
|
},
|
|
45
46
|
"scripts": {
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
"tsup": {
|
|
49
|
-
"entry": [
|
|
50
|
-
"src/index.ts"
|
|
51
|
-
],
|
|
52
|
-
"dts": true,
|
|
53
|
-
"splitting": true,
|
|
54
|
-
"format": [
|
|
55
|
-
"esm",
|
|
56
|
-
"cjs"
|
|
57
|
-
]
|
|
47
|
+
"clean": "rm -rf dist",
|
|
48
|
+
"build": "npm run clean && rollup -c"
|
|
58
49
|
}
|
|
59
50
|
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Node as Node$1 } from '@tiptap/core';
|
|
2
|
-
import { Node } from '@tiptap/pm/model';
|
|
3
|
-
import { PluginKey } from '@tiptap/pm/state';
|
|
4
|
-
import { SuggestionOptions } from '@tiptap/suggestion';
|
|
5
|
-
|
|
6
|
-
declare type MentionOptions = {
|
|
7
|
-
HTMLAttributes: Record<string, any>;
|
|
8
|
-
renderLabel: (props: {
|
|
9
|
-
options: MentionOptions;
|
|
10
|
-
node: Node;
|
|
11
|
-
}) => string;
|
|
12
|
-
suggestion: Omit<SuggestionOptions, 'editor'>;
|
|
13
|
-
};
|
|
14
|
-
declare const MentionPluginKey: PluginKey<any>;
|
|
15
|
-
declare const Mention: Node$1<MentionOptions, any>;
|
|
16
|
-
|
|
17
|
-
export { Mention, MentionOptions, MentionPluginKey, Mention as default };
|