@tiptap/extension-emoji 3.2.2 → 3.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +6 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
- package/src/emoji.ts +9 -3
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tiptap/extension-emoji",
|
|
3
3
|
"description": "emoji extension for tiptap",
|
|
4
|
-
"version": "3.
|
|
4
|
+
"version": "3.3.1",
|
|
5
5
|
"homepage": "https://tiptap.dev/api/nodes/emoji",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"tiptap",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"dist"
|
|
37
37
|
],
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"@tiptap/core": "^3.
|
|
40
|
-
"@tiptap/
|
|
41
|
-
"@tiptap/
|
|
39
|
+
"@tiptap/core": "^3.3.1",
|
|
40
|
+
"@tiptap/suggestion": "^3.3.1",
|
|
41
|
+
"@tiptap/pm": "^3.3.1"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"emoji-regex": "^10.4.0",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
"emoji-datasource": "^7.0.2",
|
|
50
50
|
"json5": "^2.2.3",
|
|
51
51
|
"tsm": "^2.3.0",
|
|
52
|
-
"@tiptap/core": "^3.
|
|
53
|
-
"@tiptap/pm": "^3.
|
|
54
|
-
"@tiptap/suggestion": "^3.
|
|
52
|
+
"@tiptap/core": "^3.3.1",
|
|
53
|
+
"@tiptap/pm": "^3.3.1",
|
|
54
|
+
"@tiptap/suggestion": "^3.3.1"
|
|
55
55
|
},
|
|
56
56
|
"scripts": {
|
|
57
57
|
"build": "tsup",
|
package/src/emoji.ts
CHANGED
|
@@ -92,7 +92,7 @@ export const EmojiSuggestionPluginKey = new PluginKey('emojiSuggestion')
|
|
|
92
92
|
|
|
93
93
|
export const inputRegex = /:([a-zA-Z0-9_+-]+):$/
|
|
94
94
|
|
|
95
|
-
export const pasteRegex =
|
|
95
|
+
export const pasteRegex = /(^|\s):([a-zA-Z0-9_+-]+):/g
|
|
96
96
|
|
|
97
97
|
export const Emoji = Node.create<EmojiOptions, EmojiStorage>({
|
|
98
98
|
name: 'emoji',
|
|
@@ -329,15 +329,21 @@ export const Emoji = Node.create<EmojiOptions, EmojiStorage>({
|
|
|
329
329
|
new PasteRule({
|
|
330
330
|
find: pasteRegex,
|
|
331
331
|
handler: ({ range, match, chain }) => {
|
|
332
|
-
|
|
332
|
+
// match[1] is the optional prefix (start or whitespace), match[2] is the shortcode name
|
|
333
|
+
const prefix = match[1] || ''
|
|
334
|
+
const name = match[2]
|
|
333
335
|
|
|
334
336
|
if (!shortcodeToEmoji(name, this.options.emojis)) {
|
|
335
337
|
return
|
|
336
338
|
}
|
|
337
339
|
|
|
340
|
+
// Replace only the shortcode portion (preserve the prefix)
|
|
341
|
+
const shortcodeFrom = range.from + prefix.length
|
|
342
|
+
const shortcodeTo = range.to
|
|
343
|
+
|
|
338
344
|
chain()
|
|
339
345
|
.insertContentAt(
|
|
340
|
-
|
|
346
|
+
{ from: shortcodeFrom, to: shortcodeTo },
|
|
341
347
|
{
|
|
342
348
|
type: this.name,
|
|
343
349
|
attrs: {
|