@crystallize/design-system 1.11.4 → 1.11.5

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/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @crystallize/design-system
2
2
 
3
+ ## 1.11.5
4
+
5
+ ### Patch Changes
6
+
7
+ - f7cb015: Allow to pass a portal container, in order to attach the menu on the Dialog cases
8
+
3
9
  ## 1.11.4
4
10
 
5
11
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -3,9 +3,9 @@ import { HTMLAttributes, ReactNode, ComponentPropsWithRef, ComponentProps, RefAt
3
3
  import * as class_variance_authority_dist_types from 'class-variance-authority/dist/types';
4
4
  import * as class_variance_authority from 'class-variance-authority';
5
5
  import { VariantProps } from 'class-variance-authority';
6
+ import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
6
7
  import * as CheckboxPrimitive from '@radix-ui/react-checkbox';
7
8
  import * as DialogPrimitive from '@radix-ui/react-dialog';
8
- import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
9
9
  import * as RadioGroupPrimitive from '@radix-ui/react-radio-group';
10
10
  import * as ProgressPrimitives from '@radix-ui/react-progress';
11
11
  import * as _radix_ui_react_select from '@radix-ui/react-select';
@@ -19,15 +19,45 @@ type ItemProps = HTMLAttributes<HTMLLIElement> & {
19
19
  };
20
20
  declare function Item({ children, className, onSelect }: ItemProps): JSX.Element;
21
21
 
22
+ type DropdownMenuItemProps = DropdownMenuPrimitive.MenuItemProps & {
23
+ children: ReactNode;
24
+ };
25
+ declare function DropdownMenuItem({ children, className, ...delegated }: DropdownMenuItemProps): JSX.Element;
26
+
27
+ type DropdownMenuLabelProps = {
28
+ children: ReactNode;
29
+ };
30
+ declare function DropdownMenuLabel({ children }: DropdownMenuLabelProps): JSX.Element;
31
+
32
+ type Container = HTMLElement | null | undefined;
33
+ type DropdownMenuRootProps = DropdownMenuPrimitive.MenuContentProps & {
34
+ children: ReactNode;
35
+ content: ReactNode;
36
+ alignContent?: 'start' | 'center' | 'end';
37
+ disabled?: boolean;
38
+ onOpenChange?: (open: boolean) => void;
39
+ container?: Container;
40
+ };
41
+ declare function DropdownMenuRoot({ children, content, alignContent, disabled, onOpenChange, container, ...delegated }: DropdownMenuRootProps): JSX.Element;
42
+
43
+ declare const DropdownMenu: {
44
+ Root: typeof DropdownMenuRoot;
45
+ Item: typeof DropdownMenuItem;
46
+ Label: typeof DropdownMenuLabel;
47
+ Separator: react.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuSeparatorProps & react.RefAttributes<HTMLDivElement>>;
48
+ Portal: react.FC<DropdownMenuPrimitive.DropdownMenuPortalProps>;
49
+ };
50
+
22
51
  type ButtonStylesProps$1 = VariantProps<typeof buttonStyles$2>;
23
52
  declare const buttonStyles$2: (props?: ({
24
53
  size?: "xs" | "sm" | null | undefined;
25
54
  } & class_variance_authority_dist_types.ClassProp) | undefined) => string;
26
55
  type ActionMenuProps = ButtonStylesProps$1 & {
27
56
  children: ReactNode;
57
+ container?: Container;
28
58
  tabIndex?: number;
29
59
  };
30
- declare function ActionMenu({ children, tabIndex, size }: ActionMenuProps): JSX.Element;
60
+ declare function ActionMenu({ children, container, tabIndex, size }: ActionMenuProps): JSX.Element;
31
61
  declare namespace ActionMenu {
32
62
  var Item: typeof Item;
33
63
  var Separator: typeof Separator;
@@ -188,33 +218,6 @@ declare function showInfo(delegated: DialogFuncProps): {
188
218
  };
189
219
  declare function destroyAll(): void;
190
220
 
191
- type DropdownMenuItemProps = DropdownMenuPrimitive.MenuItemProps & {
192
- children: ReactNode;
193
- };
194
- declare function DropdownMenuItem({ children, className, ...delegated }: DropdownMenuItemProps): JSX.Element;
195
-
196
- type DropdownMenuLabelProps = {
197
- children: ReactNode;
198
- };
199
- declare function DropdownMenuLabel({ children }: DropdownMenuLabelProps): JSX.Element;
200
-
201
- type DropdownMenuRootProps = DropdownMenuPrimitive.MenuContentProps & {
202
- children: ReactNode;
203
- content: ReactNode;
204
- alignContent?: 'start' | 'center' | 'end';
205
- disabled?: boolean;
206
- onOpenChange?: (open: boolean) => void;
207
- };
208
- declare function DropdownMenuRoot({ children, content, alignContent, disabled, onOpenChange, ...delegated }: DropdownMenuRootProps): JSX.Element;
209
-
210
- declare const DropdownMenu: {
211
- Root: typeof DropdownMenuRoot;
212
- Item: typeof DropdownMenuItem;
213
- Label: typeof DropdownMenuLabel;
214
- Separator: react.ForwardRefExoticComponent<DropdownMenuPrimitive.DropdownMenuSeparatorProps & react.RefAttributes<HTMLDivElement>>;
215
- Portal: react.FC<DropdownMenuPrimitive.DropdownMenuPortalProps>;
216
- };
217
-
218
221
  type IconButtonStylesProps = VariantProps<typeof buttonStyles>;
219
222
  declare const buttonStyles: (props?: ({
220
223
  variant?: "default" | "elevate" | null | undefined;
@@ -488,4 +491,4 @@ declare const tokens: {
488
491
  card: string;
489
492
  };
490
493
 
491
- export { ActionMenu, Avatar, Button, ButtonProps, Card, Checkbox, CheckboxProps, CheckboxRef, CrystallizeRichText, CrystallizeRichTextActionMenuItem, Dialog, DropdownMenu, Icon, IconButton, IconButtonProps, InlineRadio, Input, InputWithLabel, Label, Progress, Radio, RichTextEditor, Select, Slider, Spinner, Tag, buttonTokens, cardToken, destroyAll, showConfirm, showDialog, showError, showInfo, showWarning, tokens };
494
+ export { ActionMenu, Avatar, Button, ButtonProps, Card, Checkbox, CheckboxProps, CheckboxRef, Container, CrystallizeRichText, CrystallizeRichTextActionMenuItem, Dialog, DropdownMenu, DropdownMenuRootProps, Icon, IconButton, IconButtonProps, InlineRadio, Input, InputWithLabel, Label, Progress, Radio, RichTextEditor, Select, Slider, Spinner, Tag, buttonTokens, cardToken, destroyAll, showConfirm, showDialog, showError, showInfo, showWarning, tokens };
package/dist/index.js CHANGED
@@ -288,6 +288,7 @@ function DropdownMenuRoot({
288
288
  alignContent = "center",
289
289
  disabled,
290
290
  onOpenChange,
291
+ container,
291
292
  ...delegated
292
293
  }) {
293
294
  return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(DropdownMenuPrimitive3.Root, {
@@ -299,6 +300,7 @@ function DropdownMenuRoot({
299
300
  children
300
301
  }),
301
302
  /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuPrimitive3.Portal, {
303
+ container,
302
304
  children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(DropdownMenuPrimitive3.Content, {
303
305
  align: alignContent,
304
306
  sideOffset: 5,
@@ -354,10 +356,11 @@ var buttonStyles2 = (0, import_class_variance_authority7.cva)("c-action-menu", {
354
356
  size: "sm"
355
357
  }
356
358
  });
357
- function ActionMenu({ children, tabIndex, size }) {
359
+ function ActionMenu({ children, container, tabIndex, size }) {
358
360
  return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(DropdownMenu.Root, {
359
361
  content: children,
360
362
  alignContent: "center",
363
+ container,
361
364
  children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("button", {
362
365
  "aria-label": "more options",
363
366
  className: buttonStyles2({ size }),
@@ -3618,7 +3621,7 @@ function Tag({ children, className, variant, ...delegated }) {
3618
3621
  }
3619
3622
 
3620
3623
  // src/rich-text-editor/rich-text-editor.tsx
3621
- var import_react77 = require("react");
3624
+ var import_react78 = require("react");
3622
3625
  var import_LexicalAutoFocusPlugin = require("@lexical/react/LexicalAutoFocusPlugin");
3623
3626
  var import_LexicalClearEditorPlugin = require("@lexical/react/LexicalClearEditorPlugin");
3624
3627
  var import_LexicalComposer = require("@lexical/react/LexicalComposer");
@@ -5729,7 +5732,7 @@ function TableActionMenuPlugin({
5729
5732
  }
5730
5733
 
5731
5734
  // src/rich-text-editor/plugins/ToolbarPlugin/index.tsx
5732
- var import_react76 = require("react");
5735
+ var import_react77 = require("react");
5733
5736
  var import_lexical16 = require("lexical");
5734
5737
  var import_code9 = require("@lexical/code");
5735
5738
  var import_link6 = require("@lexical/link");
@@ -5742,6 +5745,7 @@ var import_selection3 = require("@lexical/selection");
5742
5745
  var import_utils4 = require("@lexical/utils");
5743
5746
 
5744
5747
  // src/rich-text-editor/plugins/ActionsPlugin/index.tsx
5748
+ var import_react75 = require("react");
5745
5749
  var import_lexical15 = require("lexical");
5746
5750
  var import_LexicalComposerContext10 = require("@lexical/react/LexicalComposerContext");
5747
5751
  var import_jsx_runtime87 = require("react/jsx-runtime");
@@ -5759,11 +5763,14 @@ function ActionsPlugin({
5759
5763
  }) {
5760
5764
  const [editor] = (0, import_LexicalComposerContext10.useLexicalComposerContext)();
5761
5765
  const tr = useTr();
5766
+ const actionMenuAnchorRef = (0, import_react75.useRef)(null);
5762
5767
  return /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)("div", {
5768
+ ref: actionMenuAnchorRef,
5763
5769
  className: "z-50 flex items-center ",
5764
5770
  children: [
5765
5771
  /* @__PURE__ */ (0, import_jsx_runtime87.jsx)("div", {}),
5766
5772
  /* @__PURE__ */ (0, import_jsx_runtime87.jsxs)(ActionMenu, {
5773
+ container: actionMenuAnchorRef.current,
5767
5774
  children: [
5768
5775
  !prepend ? null : prepend.map((actionItem) => /* @__PURE__ */ (0, import_jsx_runtime87.jsx)(ActionMenu.Item, {
5769
5776
  onSelect: actionItem.action,
@@ -5794,12 +5801,12 @@ function ActionsPlugin({
5794
5801
  }
5795
5802
 
5796
5803
  // src/rich-text-editor/plugins/ToolbarPlugin/insert-table.tsx
5797
- var import_react75 = require("react");
5804
+ var import_react76 = require("react");
5798
5805
  var import_table5 = require("@lexical/table");
5799
5806
  var import_jsx_runtime88 = require("react/jsx-runtime");
5800
5807
  function InsertTableDialog({ activeEditor }) {
5801
- const [rows, setRows] = (0, import_react75.useState)("5");
5802
- const [columns, setColumns] = (0, import_react75.useState)("5");
5808
+ const [rows, setRows] = (0, import_react76.useState)("5");
5809
+ const [columns, setColumns] = (0, import_react76.useState)("5");
5803
5810
  const tr = useTr();
5804
5811
  const onClick = () => {
5805
5812
  if (parseInt(rows) < 1 || parseInt(columns) < 1) {
@@ -6067,23 +6074,23 @@ function ToolbarPlugin({
6067
6074
  actionsMenuAppend
6068
6075
  }) {
6069
6076
  const [editor] = (0, import_LexicalComposerContext11.useLexicalComposerContext)();
6070
- const [activeEditor, setActiveEditor] = (0, import_react76.useState)(editor);
6071
- const [blockType, setBlockType] = (0, import_react76.useState)("paragraph");
6072
- const [selectedElementKey, setSelectedElementKey] = (0, import_react76.useState)(null);
6073
- const [isLink, setIsLink] = (0, import_react76.useState)(false);
6074
- const [isBold, setIsBold] = (0, import_react76.useState)(false);
6075
- const [isItalic, setIsItalic] = (0, import_react76.useState)(false);
6076
- const [isUnderline, setIsUnderline] = (0, import_react76.useState)(false);
6077
- const [isStrikethrough, setIsStrikethrough] = (0, import_react76.useState)(false);
6078
- const [isSubscript, setIsSubscript] = (0, import_react76.useState)(false);
6079
- const [isSuperscript, setIsSuperscript] = (0, import_react76.useState)(false);
6080
- const [isCode, setIsCode] = (0, import_react76.useState)(false);
6081
- const [canUndo, setCanUndo] = (0, import_react76.useState)(false);
6082
- const [canRedo, setCanRedo] = (0, import_react76.useState)(false);
6077
+ const [activeEditor, setActiveEditor] = (0, import_react77.useState)(editor);
6078
+ const [blockType, setBlockType] = (0, import_react77.useState)("paragraph");
6079
+ const [selectedElementKey, setSelectedElementKey] = (0, import_react77.useState)(null);
6080
+ const [isLink, setIsLink] = (0, import_react77.useState)(false);
6081
+ const [isBold, setIsBold] = (0, import_react77.useState)(false);
6082
+ const [isItalic, setIsItalic] = (0, import_react77.useState)(false);
6083
+ const [isUnderline, setIsUnderline] = (0, import_react77.useState)(false);
6084
+ const [isStrikethrough, setIsStrikethrough] = (0, import_react77.useState)(false);
6085
+ const [isSubscript, setIsSubscript] = (0, import_react77.useState)(false);
6086
+ const [isSuperscript, setIsSuperscript] = (0, import_react77.useState)(false);
6087
+ const [isCode, setIsCode] = (0, import_react77.useState)(false);
6088
+ const [canUndo, setCanUndo] = (0, import_react77.useState)(false);
6089
+ const [canRedo, setCanRedo] = (0, import_react77.useState)(false);
6083
6090
  const tr = useTr();
6084
- const [codeLanguage, setCodeLanguage] = (0, import_react76.useState)("");
6085
- const [isEditable, setIsEditable] = (0, import_react76.useState)(() => editor.isEditable());
6086
- const updateToolbar = (0, import_react76.useCallback)(() => {
6091
+ const [codeLanguage, setCodeLanguage] = (0, import_react77.useState)("");
6092
+ const [isEditable, setIsEditable] = (0, import_react77.useState)(() => editor.isEditable());
6093
+ const updateToolbar = (0, import_react77.useCallback)(() => {
6087
6094
  const selection = (0, import_lexical16.$getSelection)();
6088
6095
  if ((0, import_lexical16.$isRangeSelection)(selection)) {
6089
6096
  const anchorNode = selection.anchor.getNode();
@@ -6130,7 +6137,7 @@ function ToolbarPlugin({
6130
6137
  }
6131
6138
  }
6132
6139
  }, [activeEditor]);
6133
- (0, import_react76.useEffect)(() => {
6140
+ (0, import_react77.useEffect)(() => {
6134
6141
  return editor.registerCommand(
6135
6142
  import_lexical16.SELECTION_CHANGE_COMMAND,
6136
6143
  (_payload, newEditor) => {
@@ -6141,7 +6148,7 @@ function ToolbarPlugin({
6141
6148
  import_lexical16.COMMAND_PRIORITY_CRITICAL
6142
6149
  );
6143
6150
  }, [editor, updateToolbar]);
6144
- (0, import_react76.useEffect)(() => {
6151
+ (0, import_react77.useEffect)(() => {
6145
6152
  return (0, import_utils4.mergeRegister)(
6146
6153
  editor.registerEditableListener((editable) => {
6147
6154
  setIsEditable(editable);
@@ -6169,7 +6176,7 @@ function ToolbarPlugin({
6169
6176
  )
6170
6177
  );
6171
6178
  }, [activeEditor, editor, updateToolbar]);
6172
- const clearFormatting = (0, import_react76.useCallback)(() => {
6179
+ const clearFormatting = (0, import_react77.useCallback)(() => {
6173
6180
  activeEditor.update(() => {
6174
6181
  const selection = (0, import_lexical16.$getSelection)();
6175
6182
  if ((0, import_lexical16.$isRangeSelection)(selection)) {
@@ -6187,14 +6194,14 @@ function ToolbarPlugin({
6187
6194
  }
6188
6195
  });
6189
6196
  }, [activeEditor]);
6190
- const insertLink = (0, import_react76.useCallback)(() => {
6197
+ const insertLink = (0, import_react77.useCallback)(() => {
6191
6198
  if (!isLink) {
6192
6199
  editor.dispatchCommand(import_link6.TOGGLE_LINK_COMMAND, sanitizeUrl("https://"));
6193
6200
  } else {
6194
6201
  editor.dispatchCommand(import_link6.TOGGLE_LINK_COMMAND, null);
6195
6202
  }
6196
6203
  }, [editor, isLink]);
6197
- const onCodeLanguageSelect = (0, import_react76.useCallback)(
6204
+ const onCodeLanguageSelect = (0, import_react77.useCallback)(
6198
6205
  (value) => {
6199
6206
  activeEditor.update(() => {
6200
6207
  if (selectedElementKey !== null) {
@@ -6658,18 +6665,18 @@ function RichTextEditorWithoutContext({
6658
6665
  children: placeholderText ?? ""
6659
6666
  });
6660
6667
  const [editor] = (0, import_LexicalComposerContext12.useLexicalComposerContext)();
6661
- const [floatingAnchorElem, setFloatingAnchorElem] = (0, import_react77.useState)(null);
6662
- const [isSmallWidthViewport, setIsSmallWidthViewport] = (0, import_react77.useState)(false);
6663
- const firstOnChangeTriggeredRef = (0, import_react77.useRef)(!autoFocus);
6668
+ const [floatingAnchorElem, setFloatingAnchorElem] = (0, import_react78.useState)(null);
6669
+ const [isSmallWidthViewport, setIsSmallWidthViewport] = (0, import_react78.useState)(false);
6670
+ const firstOnChangeTriggeredRef = (0, import_react78.useRef)(!autoFocus);
6664
6671
  const onRef = (_floatingAnchorElem) => {
6665
6672
  if (_floatingAnchorElem !== null) {
6666
6673
  setFloatingAnchorElem(_floatingAnchorElem);
6667
6674
  }
6668
6675
  };
6669
- (0, import_react77.useEffect)(() => {
6676
+ (0, import_react78.useEffect)(() => {
6670
6677
  editor.setEditable(editable || false);
6671
6678
  }, [editable, editor]);
6672
- (0, import_react77.useEffect)(() => {
6679
+ (0, import_react78.useEffect)(() => {
6673
6680
  const updateViewPortWidth = () => {
6674
6681
  const isNextSmallWidthViewport = window.matchMedia("(max-width: 1025px)").matches;
6675
6682
  if (isNextSmallWidthViewport !== isSmallWidthViewport) {
package/dist/index.mjs CHANGED
@@ -228,6 +228,7 @@ function DropdownMenuRoot({
228
228
  alignContent = "center",
229
229
  disabled,
230
230
  onOpenChange,
231
+ container,
231
232
  ...delegated
232
233
  }) {
233
234
  return /* @__PURE__ */ jsxs3(DropdownMenuPrimitive3.Root, {
@@ -239,6 +240,7 @@ function DropdownMenuRoot({
239
240
  children
240
241
  }),
241
242
  /* @__PURE__ */ jsx6(DropdownMenuPrimitive3.Portal, {
243
+ container,
242
244
  children: /* @__PURE__ */ jsx6(DropdownMenuPrimitive3.Content, {
243
245
  align: alignContent,
244
246
  sideOffset: 5,
@@ -294,10 +296,11 @@ var buttonStyles2 = cva3("c-action-menu", {
294
296
  size: "sm"
295
297
  }
296
298
  });
297
- function ActionMenu({ children, tabIndex, size }) {
299
+ function ActionMenu({ children, container, tabIndex, size }) {
298
300
  return /* @__PURE__ */ jsx9(DropdownMenu.Root, {
299
301
  content: children,
300
302
  alignContent: "center",
303
+ container,
301
304
  children: /* @__PURE__ */ jsxs4("button", {
302
305
  "aria-label": "more options",
303
306
  className: buttonStyles2({ size }),
@@ -3558,7 +3561,7 @@ function Tag({ children, className, variant, ...delegated }) {
3558
3561
  }
3559
3562
 
3560
3563
  // src/rich-text-editor/rich-text-editor.tsx
3561
- import { useEffect as useEffect11, useRef as useRef5, useState as useState10 } from "react";
3564
+ import { useEffect as useEffect11, useRef as useRef6, useState as useState10 } from "react";
3562
3565
  import { AutoFocusPlugin } from "@lexical/react/LexicalAutoFocusPlugin";
3563
3566
  import { ClearEditorPlugin } from "@lexical/react/LexicalClearEditorPlugin";
3564
3567
  import { LexicalComposer } from "@lexical/react/LexicalComposer";
@@ -5764,6 +5767,7 @@ import {
5764
5767
  } from "@lexical/utils";
5765
5768
 
5766
5769
  // src/rich-text-editor/plugins/ActionsPlugin/index.tsx
5770
+ import { useRef as useRef5 } from "react";
5767
5771
  import { CLEAR_EDITOR_COMMAND } from "lexical";
5768
5772
  import { useLexicalComposerContext as useLexicalComposerContext10 } from "@lexical/react/LexicalComposerContext";
5769
5773
  import { jsx as jsx87, jsxs as jsxs64 } from "react/jsx-runtime";
@@ -5781,11 +5785,14 @@ function ActionsPlugin({
5781
5785
  }) {
5782
5786
  const [editor] = useLexicalComposerContext10();
5783
5787
  const tr = useTr();
5788
+ const actionMenuAnchorRef = useRef5(null);
5784
5789
  return /* @__PURE__ */ jsxs64("div", {
5790
+ ref: actionMenuAnchorRef,
5785
5791
  className: "z-50 flex items-center ",
5786
5792
  children: [
5787
5793
  /* @__PURE__ */ jsx87("div", {}),
5788
5794
  /* @__PURE__ */ jsxs64(ActionMenu, {
5795
+ container: actionMenuAnchorRef.current,
5789
5796
  children: [
5790
5797
  !prepend ? null : prepend.map((actionItem) => /* @__PURE__ */ jsx87(ActionMenu.Item, {
5791
5798
  onSelect: actionItem.action,
@@ -6682,7 +6689,7 @@ function RichTextEditorWithoutContext({
6682
6689
  const [editor] = useLexicalComposerContext12();
6683
6690
  const [floatingAnchorElem, setFloatingAnchorElem] = useState10(null);
6684
6691
  const [isSmallWidthViewport, setIsSmallWidthViewport] = useState10(false);
6685
- const firstOnChangeTriggeredRef = useRef5(!autoFocus);
6692
+ const firstOnChangeTriggeredRef = useRef6(!autoFocus);
6686
6693
  const onRef = (_floatingAnchorElem) => {
6687
6694
  if (_floatingAnchorElem !== null) {
6688
6695
  setFloatingAnchorElem(_floatingAnchorElem);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crystallize/design-system",
3
- "version": "1.11.4",
3
+ "version": "1.11.5",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -1,7 +1,7 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import { VariantProps, cva } from 'class-variance-authority';
3
3
 
4
- import { DropdownMenu } from '../dropdown-menu';
4
+ import { DropdownMenu, Container } from '../dropdown-menu';
5
5
  import { Item } from './action-item';
6
6
  import { Separator } from './action-item-separator';
7
7
 
@@ -20,12 +20,13 @@ const buttonStyles = cva('c-action-menu', {
20
20
 
21
21
  type ActionMenuProps = ButtonStylesProps & {
22
22
  children: ReactNode;
23
+ container?: Container;
23
24
  tabIndex?: number;
24
25
  };
25
26
 
26
- export function ActionMenu({ children, tabIndex, size }: ActionMenuProps) {
27
+ export function ActionMenu({ children, container, tabIndex, size }: ActionMenuProps) {
27
28
  return (
28
- <DropdownMenu.Root content={children} alignContent="center">
29
+ <DropdownMenu.Root content={children} alignContent="center" container={container}>
29
30
  <button
30
31
  aria-label="more options"
31
32
  className={buttonStyles({ size })}
@@ -1,12 +1,15 @@
1
1
  import type { ReactNode } from 'react';
2
2
  import * as DropdownMenuPrimitive from '@radix-ui/react-dropdown-menu';
3
3
 
4
+ export type Container = HTMLElement | null | undefined;
5
+
4
6
  export type DropdownMenuRootProps = DropdownMenuPrimitive.MenuContentProps & {
5
7
  children: ReactNode;
6
8
  content: ReactNode;
7
9
  alignContent?: 'start' | 'center' | 'end';
8
10
  disabled?: boolean;
9
11
  onOpenChange?: (open: boolean) => void;
12
+ container?: Container;
10
13
  };
11
14
 
12
15
  export function DropdownMenuRoot({
@@ -15,6 +18,7 @@ export function DropdownMenuRoot({
15
18
  alignContent = 'center',
16
19
  disabled,
17
20
  onOpenChange,
21
+ container,
18
22
  ...delegated
19
23
  }: DropdownMenuRootProps) {
20
24
  return (
@@ -22,7 +26,7 @@ export function DropdownMenuRoot({
22
26
  <DropdownMenuPrimitive.Trigger disabled={disabled} asChild>
23
27
  {children}
24
28
  </DropdownMenuPrimitive.Trigger>
25
- <DropdownMenuPrimitive.Portal>
29
+ <DropdownMenuPrimitive.Portal container={container}>
26
30
  <DropdownMenuPrimitive.Content
27
31
  align={alignContent}
28
32
  sideOffset={5}
@@ -2,9 +2,11 @@ import { Portal, Separator } from '@radix-ui/react-dropdown-menu';
2
2
 
3
3
  import { DropdownMenuItem } from './dropdown-menu-item';
4
4
  import { DropdownMenuLabel } from './dropdown-menu-label';
5
- import { DropdownMenuRoot } from './dropdown-menu-root';
5
+ import { DropdownMenuRoot, type DropdownMenuRootProps, type Container } from './dropdown-menu-root';
6
6
  import './dropdown-menu.css';
7
7
 
8
+ export { DropdownMenuRootProps, Container };
9
+
8
10
  export const DropdownMenu = {
9
11
  Root: DropdownMenuRoot,
10
12
  Item: DropdownMenuItem,
@@ -7,6 +7,7 @@
7
7
  *
8
8
  */
9
9
 
10
+ import { useRef } from 'react';
10
11
  import { CLEAR_EDITOR_COMMAND, LexicalEditor } from 'lexical';
11
12
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
12
13
 
@@ -34,11 +35,12 @@ export default function ActionsPlugin({
34
35
  }): JSX.Element {
35
36
  const [editor] = useLexicalComposerContext();
36
37
  const tr = useTr();
38
+ const actionMenuAnchorRef = useRef<HTMLDivElement>(null);
37
39
 
38
40
  return (
39
- <div className="z-50 flex items-center ">
41
+ <div ref={actionMenuAnchorRef} className="z-50 flex items-center ">
40
42
  <div></div>
41
- <ActionMenu>
43
+ <ActionMenu container={actionMenuAnchorRef.current}>
42
44
  {!prepend
43
45
  ? null
44
46
  : prepend.map(actionItem => (
@@ -4,7 +4,7 @@ import userEvent from '@testing-library/user-event';
4
4
  import { RichTextEditor } from '../rich-text-editor';
5
5
 
6
6
  describe('RichTextEditor code node', () => {
7
- it('can add a code block to an existing paragraph texst', async () => {
7
+ it('can add a code block to an existing paragraph text', async () => {
8
8
  const onChange = vi.fn();
9
9
 
10
10
  render(