@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.js CHANGED
@@ -19394,7 +19394,7 @@ function shortcodeToEmoji(shortcode, emojis2) {
19394
19394
  // src/emoji.ts
19395
19395
  var EmojiSuggestionPluginKey = new PluginKey("emojiSuggestion");
19396
19396
  var inputRegex = /:([a-zA-Z0-9_+-]+):$/;
19397
- var pasteRegex = /:([a-zA-Z0-9_+-]+):/g;
19397
+ var pasteRegex = /(^|\s):([a-zA-Z0-9_+-]+):/g;
19398
19398
  var Emoji = Node.create({
19399
19399
  name: "emoji",
19400
19400
  inline: true,
@@ -19573,12 +19573,15 @@ var Emoji = Node.create({
19573
19573
  new PasteRule({
19574
19574
  find: pasteRegex,
19575
19575
  handler: ({ range, match, chain }) => {
19576
- const name = match[1];
19576
+ const prefix = match[1] || "";
19577
+ const name = match[2];
19577
19578
  if (!shortcodeToEmoji(name, this.options.emojis)) {
19578
19579
  return;
19579
19580
  }
19581
+ const shortcodeFrom = range.from + prefix.length;
19582
+ const shortcodeTo = range.to;
19580
19583
  chain().insertContentAt(
19581
- range,
19584
+ { from: shortcodeFrom, to: shortcodeTo },
19582
19585
  {
19583
19586
  type: this.name,
19584
19587
  attrs: {