@react-email/editor 1.7.10 → 1.7.12

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 CHANGED
@@ -4,7 +4,7 @@ const require_core = require("./core-CVuVY_7y.cjs");
4
4
  const require_extensions = require("./extensions-v0KmVEud.cjs");
5
5
  const require_extension = require("./extension-B9JdGycJ.cjs");
6
6
  const require_extension$1 = require("./extension-Bxo1U1sw.cjs");
7
- const require_root = require("./root-DgHJ2pvv.cjs");
7
+ const require_root = require("./root-DXzIKdv0.cjs");
8
8
  let _tiptap_react = require("@tiptap/react");
9
9
  let react = require("react");
10
10
  let _tiptap_html = require("@tiptap/html");
package/dist/index.mjs CHANGED
@@ -2,7 +2,7 @@ import { n as composeReactEmail } from "./core-CtoP6qua.mjs";
2
2
  import { t as StarterKit } from "./extensions-Ba_RFa_P.mjs";
3
3
  import { t as EmailTheming } from "./extension-Cmj_sthx.mjs";
4
4
  import { t as createImageExtension } from "./extension-Dw-hZZaA.mjs";
5
- import { t as SlashCommandRoot, x as BubbleMenu } from "./root-DiU3P7qT.mjs";
5
+ import { t as SlashCommandRoot, x as BubbleMenu } from "./root-BSpn9_eH.mjs";
6
6
  import { EditorProvider, useCurrentEditor } from "@tiptap/react";
7
7
  import { forwardRef, useEffect, useImperativeHandle, useLayoutEffect, useMemo, useRef } from "react";
8
8
  import { generateJSON } from "@tiptap/html";
@@ -3,7 +3,7 @@ import { t as editorEventBus } from "./event-bus-CqrIUE24.mjs";
3
3
  import { n as setTextAlignment, t as getSelectionAlignment } from "./utils-T5ykbLcL.mjs";
4
4
  import { useCurrentEditor, useEditorState } from "@tiptap/react";
5
5
  import * as React$1 from "react";
6
- import { useCallback, useEffect, useLayoutEffect, useRef, useState } from "react";
6
+ import { useCallback, useEffect, useLayoutEffect, useMemo, useRef, useState } from "react";
7
7
  import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
8
8
  import { extensions } from "@tiptap/core";
9
9
  import { NodeSelection, PluginKey } from "@tiptap/pm/state";
@@ -2071,11 +2071,17 @@ const CATEGORY_ORDER = [
2071
2071
  ];
2072
2072
  function groupByCategory(items) {
2073
2073
  const seen = /* @__PURE__ */ new Map();
2074
- for (const item of items) {
2074
+ items.forEach((item, index) => {
2075
2075
  const existing = seen.get(item.category);
2076
- if (existing) existing.push(item);
2077
- else seen.set(item.category, [item]);
2078
- }
2076
+ if (existing) existing.push({
2077
+ item,
2078
+ index
2079
+ });
2080
+ else seen.set(item.category, [{
2081
+ item,
2082
+ index
2083
+ }]);
2084
+ });
2079
2085
  const ordered = [];
2080
2086
  for (const cat of CATEGORY_ORDER) {
2081
2087
  const group = seen.get(cat);
@@ -2093,6 +2099,9 @@ function groupByCategory(items) {
2093
2099
  });
2094
2100
  return ordered;
2095
2101
  }
2102
+ function orderItemsByCategory(items) {
2103
+ return groupByCategory(items).flatMap((group) => group.items.map(({ item }) => item));
2104
+ }
2096
2105
  function CommandItem({ item, selected, onSelect }) {
2097
2106
  return /* @__PURE__ */ jsxs("button", {
2098
2107
  "data-re-slash-command-item": "",
@@ -2129,24 +2138,19 @@ function CommandList({ items, query, selectedIndex, onSelect }) {
2129
2138
  }, item.title))
2130
2139
  })
2131
2140
  });
2132
- const groups = groupByCategory(items);
2133
- let flatIndex = 0;
2134
2141
  return /* @__PURE__ */ jsx("div", {
2135
2142
  "data-re-slash-command": "",
2136
2143
  children: /* @__PURE__ */ jsx("div", {
2137
2144
  "data-re-slash-command-scroll": "",
2138
2145
  ref: containerRef,
2139
- children: groups.map((group) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
2146
+ children: groupByCategory(items).map((group) => /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
2140
2147
  "data-re-slash-command-category": "",
2141
2148
  children: group.category
2142
- }), group.items.map((item) => {
2143
- const currentIndex = flatIndex++;
2144
- return /* @__PURE__ */ jsx(CommandItem, {
2145
- item,
2146
- onSelect: () => onSelect(currentIndex),
2147
- selected: currentIndex === selectedIndex
2148
- }, item.title);
2149
- })] }, group.category))
2149
+ }), group.items.map(({ item, index }) => /* @__PURE__ */ jsx(CommandItem, {
2150
+ item,
2151
+ onSelect: () => onSelect(index),
2152
+ selected: index === selectedIndex
2153
+ }, item.title))] }, group.category))
2150
2154
  })
2151
2155
  });
2152
2156
  }
@@ -2413,7 +2417,9 @@ function SlashCommandRoot({ items: itemsProp, filterItems: filterItemsProp, char
2413
2417
  const commandRef = useRef(null);
2414
2418
  const suggestionItemsRef = useRef([]);
2415
2419
  const selectedIndexRef = useRef(0);
2416
- suggestionItemsRef.current = state.items;
2420
+ const isGrouped = !children && !state.query.trim();
2421
+ const items = useMemo(() => isGrouped ? orderItemsByCategory(state.items) : state.items, [isGrouped, state.items]);
2422
+ suggestionItemsRef.current = items;
2417
2423
  selectedIndexRef.current = selectedIndex;
2418
2424
  const { refs, floatingStyles } = useFloating({
2419
2425
  open: state.active,
@@ -2507,7 +2513,7 @@ function SlashCommandRoot({ items: itemsProp, filterItems: filterItemsProp, char
2507
2513
  }, [editor, char]);
2508
2514
  if (!editor || !state.active) return null;
2509
2515
  const renderProps = {
2510
- items: state.items,
2516
+ items,
2511
2517
  query: state.query,
2512
2518
  selectedIndex,
2513
2519
  onSelect
@@ -2524,4 +2530,4 @@ function SlashCommandRoot({ items: itemsProp, filterItems: filterItemsProp, char
2524
2530
  //#endregion
2525
2531
  export { BubbleMenuButtonToolbar as $, BubbleMenuImageUnlink as A, ChevronDownIcon as At, BubbleMenuNodeSelector as B, BubbleMenuLinkDefault as C, Heading2Icon as Ct, BubbleMenuLinkForm as D, Columns3Icon as Dt, BubbleMenuLinkOpenLink as E, Columns4Icon as Et, RootWithDefault as F, AlignLeftIcon as Ft, BubbleMenuItalic as G, NodeSelectorRoot as H, BubbleMenuUppercase as I, AlignCenterIcon as It, EditorFocusScope as J, BubbleMenuItemGroup as K, BubbleMenuUnderline as L, BubbleMenuImageForm as M, CaseUpperIcon as Mt, BubbleMenuImageEditLink as N, BoldIcon as Nt, BubbleMenuLinkEditLink as O, Columns2Icon as Ot, BubbleMenuButtonDefault as P, AlignRightIcon as Pt, BubbleMenuButtonUnlink as Q, bubbleMenuTriggers as R, BubbleMenuSeparator as S, Heading3Icon as St, BubbleMenuLinkToolbar as T, ExternalLinkIcon as Tt, NodeSelectorTrigger as U, NodeSelectorContent as V, BubbleMenuLinkSelector as W, FocusScopeContext as X, EditorFocusScopeProvider as Y, useEditorFocusScope as Z, TWO_COLUMNS as _, MousePointerIcon as _t, BUTTON as a, BubbleMenuAlignCenter as at, isInsideNode as b, LinkIcon as bt, FOUR_COLUMNS as c, UnlinkIcon as ct, H3 as d, TextIcon as dt, BubbleMenuButtonForm as et, NUMBERED_LIST as f, StrikethroughIcon as ft, THREE_COLUMNS as g, PencilIcon as gt, TEXT as h, Rows2Icon as ht, BULLET_LIST as i, BubbleMenuAlignLeft as it, BubbleMenuImageToolbar as j, CheckIcon as jt, BubbleMenuImageDefault as k, CodeIcon as kt, H1 as l, UnderlineIcon as lt, SECTION as m, SplitSquareVerticalIcon as mt, filterAndRankItems as n, BubbleMenuBold as nt, CODE as o, BubbleMenuItem as ot, QUOTE as p, SquareCodeIcon as pt, BubbleMenuCode as q, scoreItem as r, BubbleMenuAlignRight as rt, DIVIDER as s, useBubbleMenuContext as st, SlashCommandRoot as t, BubbleMenuButtonEditLink as tt, H2 as u, TextQuoteIcon as ut, defaultSlashCommands as v, ListOrderedIcon as vt, BubbleMenuLinkUnlink as w, Heading1Icon as wt, BubbleMenu$1 as x, ItalicIcon as xt, isAtMaxColumnsDepth as y, ListIcon as yt, BubbleMenuStrike as z };
2526
2532
 
2527
- //# sourceMappingURL=root-DiU3P7qT.mjs.map
2533
+ //# sourceMappingURL=root-BSpn9_eH.mjs.map