@strapi/content-manager 5.53.0 → 5.54.0

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.
Files changed (79) hide show
  1. package/dist/admin/components/ActionsDrawer.js +17 -6
  2. package/dist/admin/components/ActionsDrawer.js.map +1 -1
  3. package/dist/admin/components/ActionsDrawer.mjs +19 -8
  4. package/dist/admin/components/ActionsDrawer.mjs.map +1 -1
  5. package/dist/admin/history/components/VersionsList.js +37 -43
  6. package/dist/admin/history/components/VersionsList.js.map +1 -1
  7. package/dist/admin/history/components/VersionsList.mjs +37 -43
  8. package/dist/admin/history/components/VersionsList.mjs.map +1 -1
  9. package/dist/admin/pages/EditView/EditViewPage.js +15 -20
  10. package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
  11. package/dist/admin/pages/EditView/EditViewPage.mjs +15 -20
  12. package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
  13. package/dist/admin/pages/EditView/components/DocumentActions.js +2 -0
  14. package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
  15. package/dist/admin/pages/EditView/components/DocumentActions.mjs +2 -0
  16. package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
  17. package/dist/admin/pages/EditView/components/EditorToolbarObserver.js +74 -7
  18. package/dist/admin/pages/EditView/components/EditorToolbarObserver.js.map +1 -1
  19. package/dist/admin/pages/EditView/components/EditorToolbarObserver.mjs +74 -7
  20. package/dist/admin/pages/EditView/components/EditorToolbarObserver.mjs.map +1 -1
  21. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +7 -2
  22. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
  23. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +7 -2
  24. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
  25. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js +59 -2
  26. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
  27. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs +60 -3
  28. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
  29. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.js +4 -1
  30. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.js.map +1 -1
  31. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.mjs +4 -1
  32. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.mjs.map +1 -1
  33. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js +4 -1
  34. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
  35. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs +4 -1
  36. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
  37. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.js +2 -1
  38. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.js.map +1 -1
  39. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.mjs +2 -1
  40. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.mjs.map +1 -1
  41. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.js +25 -2
  42. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.js.map +1 -1
  43. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.mjs +5 -2
  44. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.mjs.map +1 -1
  45. package/dist/admin/pages/EditView/components/InputRenderer.js +5 -1
  46. package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
  47. package/dist/admin/pages/EditView/components/InputRenderer.mjs +6 -2
  48. package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
  49. package/dist/admin/pages/ListView/ListViewPage.js +1 -0
  50. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  51. package/dist/admin/pages/ListView/ListViewPage.mjs +1 -0
  52. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  53. package/dist/admin/preview/components/InputPopover.js +64 -46
  54. package/dist/admin/preview/components/InputPopover.js.map +1 -1
  55. package/dist/admin/preview/components/InputPopover.mjs +66 -49
  56. package/dist/admin/preview/components/InputPopover.mjs.map +1 -1
  57. package/dist/admin/preview/hooks/usePreviewInputManager.js +23 -7
  58. package/dist/admin/preview/hooks/usePreviewInputManager.js.map +1 -1
  59. package/dist/admin/preview/hooks/usePreviewInputManager.mjs +25 -9
  60. package/dist/admin/preview/hooks/usePreviewInputManager.mjs.map +1 -1
  61. package/dist/admin/preview/pages/Preview.js +19 -0
  62. package/dist/admin/preview/pages/Preview.js.map +1 -1
  63. package/dist/admin/preview/pages/Preview.mjs +20 -1
  64. package/dist/admin/preview/pages/Preview.mjs.map +1 -1
  65. package/dist/admin/preview/utils/constants.js +9 -3
  66. package/dist/admin/preview/utils/constants.js.map +1 -1
  67. package/dist/admin/preview/utils/constants.mjs +9 -3
  68. package/dist/admin/preview/utils/constants.mjs.map +1 -1
  69. package/dist/admin/src/components/ActionsDrawer.d.ts +1 -0
  70. package/dist/admin/src/pages/EditView/components/EditorToolbarObserver.d.ts +2 -1
  71. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.d.ts +5 -1
  72. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.d.ts +5 -0
  73. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +5 -0
  74. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.d.ts +2 -1
  75. package/dist/admin/src/preview/components/InputPopover.d.ts +2 -1
  76. package/dist/admin/src/preview/pages/Preview.d.ts +1 -0
  77. package/dist/admin/src/preview/utils/constants.d.ts +8 -1
  78. package/dist/server/preview/controllers/previewScript.js +548 -22
  79. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"BlocksEditor.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n createContext,\n useStrapiApp,\n type FieldValue,\n useIsMobile,\n} from '@strapi/admin/strapi-admin';\nimport { IconButton, Divider, VisuallyHidden } from '@strapi/design-system';\nimport { Expand } from '@strapi/icons';\nimport { flushSync } from 'react-dom';\nimport { MessageDescriptor, useIntl } from 'react-intl';\nimport { Editor, type Descendant, createEditor, Transforms, Element } from 'slate';\nimport { withHistory } from 'slate-history';\nimport { type RenderElementProps, Slate, withReact, ReactEditor, useSlate } from 'slate-react';\nimport { styled, type CSSProperties } from 'styled-components';\n\nimport { ContentManagerPlugin } from '../../../../../content-manager';\nimport { getTranslation } from '../../../../../utils/translations';\n\nimport { BlocksContent, type BlocksContentProps } from './BlocksContent';\nimport { BlocksToolbar } from './BlocksToolbar';\nimport { EditorLayout } from './EditorLayout';\nimport { type ModifiersStore, modifiers } from './Modifiers';\nimport { withStrapiSchema } from './plugins/withStrapiSchema';\nimport { isNonNullable } from './utils/types';\n\nimport type { Schema } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * BlocksEditorProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface CustomNode extends Omit<Schema.Attribute.BlocksNode, 'type'> {\n type: Schema.Attribute.BlocksNode['type'] | string;\n level?: number;\n format?: string;\n}\n\ninterface BaseBlock {\n renderElement: (props: RenderElementProps) => React.JSX.Element;\n /** Function to check if a given node is of this type of block */\n matchNode: (node: Schema.Attribute.BlocksNode | CustomNode) => boolean;\n handleConvert?: (editor: Editor) => void | (() => React.JSX.Element);\n handleEnterKey?: (editor: Editor) => void;\n handleBackspaceKey?: (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => void;\n handleTab?: (editor: Editor) => void;\n handleShiftTab?: (editor: Editor) => void;\n snippets?: string[];\n /** Adjust the vertical positioning of the drag-to-reorder grip icon */\n dragHandleTopMargin?: CSSProperties['marginTop'];\n /** A Slate plugin: function that will wrap the editor creation */\n plugin?: (editor: Editor) => Editor;\n /**\n * Function that checks if an element should be draggable\n * @default () => true */\n isDraggable?: (element: Element) => boolean;\n}\n\nexport interface NonSelectorBlock extends BaseBlock {\n isInBlocksSelector?: false;\n}\n\nexport interface SelectorBlock extends BaseBlock {\n isInBlocksSelector: true;\n icon?: React.ComponentType;\n label: MessageDescriptor;\n}\n\ntype NonSelectorBlockKey = 'list-item' | 'link';\n\nconst selectorBlockKeys = [\n 'paragraph',\n 'heading-one',\n 'heading-two',\n 'heading-three',\n 'heading-four',\n 'heading-five',\n 'heading-six',\n 'list-ordered',\n 'list-unordered',\n 'image',\n 'quote',\n 'code',\n] as const;\n\ntype SelectorBlockKey = (typeof selectorBlockKeys)[number];\n\nconst isSelectorBlockKey = (key: unknown): key is SelectorBlockKey => {\n return typeof key === 'string' && selectorBlockKeys.includes(key as SelectorBlockKey);\n};\n\ntype BlocksStore = {\n [K in SelectorBlockKey]: SelectorBlock;\n} & {\n [K in NonSelectorBlockKey]: NonSelectorBlock;\n};\n\ntype RichTextBlocksStore = Partial<BlocksStore> & Record<string, SelectorBlock | NonSelectorBlock>;\n\ninterface BlocksEditorContextValue {\n blocks: RichTextBlocksStore;\n modifiers: ModifiersStore;\n disabled: boolean;\n name: string;\n setLiveText: (text: string) => void;\n isExpandedMode: boolean;\n /** Push debounced Slate → form sync immediately (e.g. on Editable blur before Save). */\n flushPendingFormSync: () => void;\n}\n\nconst [BlocksEditorProvider, usePartialBlocksEditorContext] =\n createContext<BlocksEditorContextValue>('BlocksEditor');\n\nfunction useBlocksEditorContext(consumerName: string): BlocksEditorContextValue & {\n editor: Editor;\n} {\n const context = usePartialBlocksEditorContext(consumerName, (state) => state);\n const editor = useSlate();\n\n return {\n ...context,\n editor,\n };\n}\n\n/* -------------------------------------------------------------------------------------------------\n * BlocksEditor\n * -----------------------------------------------------------------------------------------------*/\n\nconst EditorDivider = styled(Divider)`\n background: ${({ theme }) => theme.colors.neutral200};\n`;\n\n/**\n * Forces an update of the Slate editor when the value prop changes from outside of Slate.\n * The root cause is that Slate is not a controlled component: https://github.com/ianstormtaylor/slate/issues/4612\n * Why not use JSON.stringify(value) as the key?\n * Because it would force a rerender of the entire editor every time the user types a character.\n * Why not use the entity id as the key, since it's unique for each locale?\n * Because it would not solve the problem when using the \"fill in from other locale\" feature\n */\nfunction useResetKey(\n editor: Editor,\n value?: Schema.Attribute.BlocksValue\n): {\n key: number;\n incrementSlateUpdatesCount: () => void;\n} {\n // Keep track how many times Slate detected a change from a user interaction in the editor\n const slateUpdatesCount = React.useRef(0);\n // Keep track of how many times the value prop was updated, whether from within editor or from outside\n const valueUpdatesCount = React.useRef(0);\n // Use a key to force a rerender of the Slate editor when needed\n const [key, setKey] = React.useState(0);\n\n React.useEffect(() => {\n valueUpdatesCount.current += 1;\n\n // If the 2 refs are not equal, it means the value was updated from outside\n if (valueUpdatesCount.current !== slateUpdatesCount.current) {\n // Bring the 2 refs back in sync\n slateUpdatesCount.current = valueUpdatesCount.current;\n\n // The update may just be an echo of the editor's own content coming back through the form\n // (e.g. the debounced sync, or a re-render while document queries settle). Remounting in\n // that case is pointless and destructive: it wipes pending input and the DOM under the\n // user's caret. Only force a remount when the content is actually different.\n const externalState = value?.length ? normalizeBlocksState(editor, value) : null;\n const editorState = normalizeBlocksState(editor, editor.children);\n if (JSON.stringify(externalState) === JSON.stringify(editorState)) {\n return;\n }\n\n // The remount reuses the same editor instance, so a selection pointing into the old\n // content would survive it and crash slate-react's toDOMPoint when the new content is\n // shorter. Drop the selection before swapping the children.\n if (editor.selection) {\n Transforms.deselect(editor);\n }\n\n // Change the key to force a rerender of the Slate editor,\n // which will pick up the new value through its initialValue prop\n setKey((previousKey) => previousKey + 1);\n }\n }, [editor, value]);\n\n const incrementSlateUpdatesCount = React.useCallback(() => {\n slateUpdatesCount.current += 1;\n }, []);\n\n return { key, incrementSlateUpdatesCount };\n}\n\nconst pipe =\n (...fns: ((baseEditor: Editor) => Editor)[]) =>\n (value: Editor) =>\n fns.reduce<Editor>((prev, fn) => fn(prev), value);\n\n/**\n * Normalize the blocks state to null if the editor state is considered empty,\n * otherwise return the state\n */\nconst normalizeBlocksState = (\n editor: Editor,\n value: Schema.Attribute.BlocksValue | Descendant[]\n): Schema.Attribute.BlocksValue | Descendant[] | null => {\n const isEmpty =\n value.length === 1 && Editor.isEmpty(editor, value[0] as Schema.Attribute.BlocksNode);\n\n return isEmpty ? null : value;\n};\n\ninterface BlocksEditorProps\n extends Pick<FieldValue<Schema.Attribute.BlocksValue>, 'onChange' | 'value' | 'error'>,\n BlocksContentProps {\n disabled?: boolean;\n name: string;\n}\n\nconst BlocksEditor = React.forwardRef<{ focus: () => void }, BlocksEditorProps>(\n ({ disabled = false, name, onChange, value, error, ...contentProps }, forwardedRef) => {\n const { formatMessage } = useIntl();\n const isMobile = useIsMobile();\n\n const blocks = useStrapiApp(\n 'BlocksEditor',\n (state) =>\n (\n state.plugins['content-manager']?.apis as\n | ContentManagerPlugin['config']['apis']\n | undefined\n )?.getRichTextBlocks() ?? ({} as RichTextBlocksStore)\n );\n\n const blockRegisteredPlugins = Object.values(blocks)\n .map((block) => block.plugin)\n .filter(isNonNullable);\n\n const [editor] = React.useState(() =>\n pipe(withHistory, withStrapiSchema, withReact, ...blockRegisteredPlugins)(createEditor())\n );\n const [liveText, setLiveText] = React.useState('');\n const ariaDescriptionId = React.useId();\n const [isExpandedMode, handleToggleExpand] = React.useReducer((prev) => !prev, false);\n\n /**\n * Editable is not able to hold the ref, https://github.com/ianstormtaylor/slate/issues/4082\n * so with \"useImperativeHandle\" we can use ReactEditor methods to expose to the parent above\n * also not passing forwarded ref here, gives console warning.\n */\n React.useImperativeHandle(\n forwardedRef,\n () => ({\n focus() {\n ReactEditor.focus(editor);\n },\n }),\n [editor]\n );\n\n const { key, incrementSlateUpdatesCount } = useResetKey(editor, value);\n\n const debounceTimeout = React.useRef<NodeJS.Timeout | null>(null);\n\n const flushPendingFormSync = React.useCallback(() => {\n if (!debounceTimeout.current) {\n return;\n }\n clearTimeout(debounceTimeout.current);\n debounceTimeout.current = null;\n // Counter was already bumped when the AST changed; only push form state here.\n // Ensure Strapi Form state updates before the next event (e.g. Save click) reads values.\n flushSync(() => {\n onChange(\n name,\n normalizeBlocksState(editor, editor.children) as Schema.Attribute.BlocksValue\n );\n });\n }, [editor, name, onChange]);\n\n const handleSlateChange = React.useCallback(\n (state: Descendant[]) => {\n const isAstChange = editor.operations.some((op) => op.type !== 'set_selection');\n\n if (isAstChange) {\n /**\n * Slate handles the state of the editor internally. We just need to keep Strapi's form\n * state in sync with it in order to make sure that things like the \"modified\" state\n * isn't broken. Updating the whole state on every change is very expensive however,\n * so we debounce calls to onChange to mitigate input lag.\n *\n * Bump the reset-key counter immediately (not inside the debounce). Otherwise any\n * value-prop identity change during the 300ms window — e.g. clicking the blocks\n * toolbar — looks like an external update with stale empty form state and remounts\n * the editor, wiping the pending input (blocks e2e flake).\n */\n incrementSlateUpdatesCount();\n\n if (debounceTimeout.current) {\n clearTimeout(debounceTimeout.current);\n }\n\n // Set a new debounce timeout\n debounceTimeout.current = setTimeout(() => {\n // Normalize the state (empty editor becomes null)\n onChange(name, normalizeBlocksState(editor, state) as Schema.Attribute.BlocksValue);\n debounceTimeout.current = null;\n }, 300);\n }\n },\n [editor, incrementSlateUpdatesCount, name, onChange]\n );\n\n // Clean up the timeout on unmount\n React.useEffect(() => {\n return () => {\n if (debounceTimeout.current) {\n clearTimeout(debounceTimeout.current);\n }\n };\n }, []);\n\n // Ensure the editor is in sync after discard\n React.useEffect(() => {\n // Never deselect while the editor is actively focused (typing / editing),\n if (ReactEditor.isFocused(editor)) {\n return;\n }\n\n // Normalize empty states for comparison to avoid losing focus on the editor when content is deleted\n const normalizedValue = value?.length ? value : null;\n const normalizedEditorState = normalizeBlocksState(editor, editor.children);\n\n // Compare the field value with the editor state to check for a stale selection\n if (\n normalizedValue &&\n normalizedEditorState &&\n JSON.stringify(normalizedEditorState) !== JSON.stringify(normalizedValue)\n ) {\n // When there is a diff, unset selection to avoid an invalid state\n Transforms.deselect(editor);\n }\n }, [editor, value]);\n\n return (\n <>\n <VisuallyHidden id={ariaDescriptionId}>\n {formatMessage({\n id: getTranslation('components.Blocks.dnd.instruction'),\n defaultMessage: `To reorder blocks, press Command or Control along with Shift and the Up or Down arrow keys`,\n })}\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"assertive\">{liveText}</VisuallyHidden>\n <Slate\n editor={editor}\n initialValue={\n value?.length ? value : [{ type: 'paragraph', children: [{ type: 'text', text: '' }] }]\n }\n onChange={handleSlateChange}\n key={key}\n >\n <BlocksEditorProvider\n blocks={blocks}\n modifiers={modifiers}\n disabled={disabled}\n name={name}\n setLiveText={setLiveText}\n isExpandedMode={isExpandedMode}\n flushPendingFormSync={flushPendingFormSync}\n >\n <EditorLayout\n error={error}\n disabled={disabled}\n onToggleExpand={handleToggleExpand}\n ariaDescriptionId={ariaDescriptionId}\n >\n <BlocksToolbar />\n <EditorDivider width=\"100%\" />\n <BlocksContent {...contentProps} />\n {!isExpandedMode && !isMobile && (\n <IconButton\n position=\"absolute\"\n bottom=\"1.2rem\"\n right=\"1.2rem\"\n shadow=\"filterShadow\"\n label={formatMessage({\n id: getTranslation('components.Blocks.expand'),\n defaultMessage: 'Expand',\n })}\n onClick={handleToggleExpand}\n >\n <Expand />\n </IconButton>\n )}\n </EditorLayout>\n </BlocksEditorProvider>\n </Slate>\n </>\n );\n }\n);\n\nexport {\n type BlocksStore,\n type RichTextBlocksStore,\n type SelectorBlockKey,\n BlocksEditor,\n BlocksEditorProvider,\n useBlocksEditorContext,\n isSelectorBlockKey,\n normalizeBlocksState,\n};\n"],"names":["BlocksEditorProvider","usePartialBlocksEditorContext","createContext","useBlocksEditorContext","consumerName","context","state","editor","useSlate","EditorDivider","styled","Divider","theme","colors","neutral200","useResetKey","value","slateUpdatesCount","React","useRef","valueUpdatesCount","key","setKey","useState","useEffect","current","externalState","length","normalizeBlocksState","editorState","children","JSON","stringify","selection","Transforms","deselect","previousKey","incrementSlateUpdatesCount","useCallback","pipe","fns","reduce","prev","fn","isEmpty","Editor","BlocksEditor","forwardRef","disabled","name","onChange","error","contentProps","forwardedRef","formatMessage","useIntl","isMobile","useIsMobile","blocks","useStrapiApp","plugins","apis","getRichTextBlocks","blockRegisteredPlugins","Object","values","map","block","plugin","filter","isNonNullable","withHistory","withStrapiSchema","withReact","createEditor","liveText","setLiveText","ariaDescriptionId","useId","isExpandedMode","handleToggleExpand","useReducer","useImperativeHandle","focus","ReactEditor","debounceTimeout","flushPendingFormSync","clearTimeout","flushSync","handleSlateChange","isAstChange","operations","some","op","type","setTimeout","isFocused","normalizedValue","normalizedEditorState","_jsxs","_Fragment","_jsx","VisuallyHidden","id","getTranslation","defaultMessage","aria-live","Slate","initialValue","text","modifiers","EditorLayout","onToggleExpand","BlocksToolbar","width","BlocksContent","IconButton","position","bottom","right","shadow","label","onClick","Expand"],"mappings":";;;;;;;;;;;;;;;;;;;AA+GA,MAAM,CAACA,oBAAAA,EAAsBC,6BAAAA,CAA8B,GACzDC,aAAAA,CAAwC,cAAA;AAE1C,SAASC,uBAAuBC,YAAoB,EAAA;AAGlD,IAAA,MAAMC,OAAAA,GAAUJ,6BAAAA,CAA8BG,YAAAA,EAAc,CAACE,KAAAA,GAAUA,KAAAA,CAAAA;AACvE,IAAA,MAAMC,MAAAA,GAASC,QAAAA,EAAAA;IAEf,OAAO;AACL,QAAA,GAAGH,OAAO;AACVE,QAAAA;AACF,KAAA;AACF;AAEA;;AAEkG,qGAElG,MAAME,aAAAA,GAAgBC,MAAAA,CAAOC,OAAAA,CAAQ;cACvB,EAAE,CAAC,E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BAAAA;AAGV,gBAAA,QAAA,gBAAAY,GAAA,CAACrG,oBAAAA,EAAAA;oBACC0D,MAAAA,EAAQA,MAAAA;oBACRoD,SAAAA,EAAWA,SAAAA;oBACX9D,QAAAA,EAAUA,QAAAA;oBACVC,IAAAA,EAAMA,IAAAA;oBACN2B,WAAAA,EAAaA,WAAAA;oBACbG,cAAAA,EAAgBA,cAAAA;oBAChBO,oBAAAA,EAAsBA,oBAAAA;AAEtB,oBAAA,QAAA,gBAAAa,IAAA,CAACY,YAAAA,EAAAA;wBACC5D,KAAAA,EAAOA,KAAAA;wBACPH,QAAAA,EAAUA,QAAAA;wBACVgE,cAAAA,EAAgBhC,kBAAAA;wBAChBH,iBAAAA,EAAmBA,iBAAAA;;0CAEnBwB,GAAA,CAACY,aAAAA,EAAAA,EAAAA,CAAAA;0CACDZ,GAAA,CAAC5F,aAAAA,EAAAA;gCAAcyG,KAAAA,EAAM;;0CACrBb,GAAA,CAACc,aAAAA,EAAAA;AAAe,gCAAA,GAAG/D;;4BAClB,CAAC2B,cAAAA,IAAkB,CAACvB,QAAAA,kBACnB6C,GAAA,CAACe,UAAAA,EAAAA;gCACCC,QAAAA,EAAS,UAAA;gCACTC,MAAAA,EAAO,QAAA;gCACPC,KAAAA,EAAM,QAAA;gCACNC,MAAAA,EAAO,cAAA;AACPC,gCAAAA,KAAAA,EAAOnE,aAAAA,CAAc;AACnBiD,oCAAAA,EAAAA,EAAIC,cAAAA,CAAe,0BAAA,CAAA;oCACnBC,cAAAA,EAAgB;AAClB,iCAAA,CAAA;gCACAiB,OAAAA,EAAS1C,kBAAAA;AAET,gCAAA,QAAA,gBAAAqB,GAAA,CAACsB,MAAAA,EAAAA,EAAAA;;;;;AAhCJtG,aAAAA,EAAAA,GAAAA;;;AAwCb,CAAA;;;;"}
1
+ {"version":3,"file":"BlocksEditor.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport {\n createContext,\n useStrapiApp,\n type FieldValue,\n useIsMobile,\n} from '@strapi/admin/strapi-admin';\nimport { IconButton, Divider, VisuallyHidden } from '@strapi/design-system';\nimport { Expand } from '@strapi/icons';\nimport { flushSync } from 'react-dom';\nimport { MessageDescriptor, useIntl } from 'react-intl';\nimport { Editor, type Descendant, createEditor, Transforms, Element, Node } from 'slate';\nimport { withHistory } from 'slate-history';\nimport { type RenderElementProps, Slate, withReact, ReactEditor, useSlate } from 'slate-react';\nimport { styled, type CSSProperties } from 'styled-components';\n\nimport { ContentManagerPlugin } from '../../../../../content-manager';\nimport { getTranslation } from '../../../../../utils/translations';\n\nimport { BlocksContent, type BlocksContentProps } from './BlocksContent';\nimport { BlocksToolbar } from './BlocksToolbar';\nimport { EditorLayout } from './EditorLayout';\nimport { type ModifiersStore, modifiers } from './Modifiers';\nimport { withStrapiSchema } from './plugins/withStrapiSchema';\nimport { isNonNullable } from './utils/types';\n\nimport type { Schema } from '@strapi/types';\n\n/* -------------------------------------------------------------------------------------------------\n * BlocksEditorProvider\n * -----------------------------------------------------------------------------------------------*/\n\ninterface CustomNode extends Omit<Schema.Attribute.BlocksNode, 'type'> {\n type: Schema.Attribute.BlocksNode['type'] | string;\n level?: number;\n format?: string;\n}\n\ninterface BaseBlock {\n renderElement: (props: RenderElementProps) => React.JSX.Element;\n /** Function to check if a given node is of this type of block */\n matchNode: (node: Schema.Attribute.BlocksNode | CustomNode) => boolean;\n handleConvert?: (editor: Editor) => void | (() => React.JSX.Element);\n handleEnterKey?: (editor: Editor) => void;\n handleBackspaceKey?: (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => void;\n handleTab?: (editor: Editor) => void;\n handleShiftTab?: (editor: Editor) => void;\n snippets?: string[];\n /** Adjust the vertical positioning of the drag-to-reorder grip icon */\n dragHandleTopMargin?: CSSProperties['marginTop'];\n /** A Slate plugin: function that will wrap the editor creation */\n plugin?: (editor: Editor) => Editor;\n /**\n * Function that checks if an element should be draggable\n * @default () => true */\n isDraggable?: (element: Element) => boolean;\n}\n\nexport interface NonSelectorBlock extends BaseBlock {\n isInBlocksSelector?: false;\n}\n\nexport interface SelectorBlock extends BaseBlock {\n isInBlocksSelector: true;\n icon?: React.ComponentType;\n label: MessageDescriptor;\n}\n\ntype NonSelectorBlockKey = 'list-item' | 'link';\n\nconst selectorBlockKeys = [\n 'paragraph',\n 'heading-one',\n 'heading-two',\n 'heading-three',\n 'heading-four',\n 'heading-five',\n 'heading-six',\n 'list-ordered',\n 'list-unordered',\n 'image',\n 'quote',\n 'code',\n] as const;\n\ntype SelectorBlockKey = (typeof selectorBlockKeys)[number];\n\nconst isSelectorBlockKey = (key: unknown): key is SelectorBlockKey => {\n return typeof key === 'string' && selectorBlockKeys.includes(key as SelectorBlockKey);\n};\n\ntype BlocksStore = {\n [K in SelectorBlockKey]: SelectorBlock;\n} & {\n [K in NonSelectorBlockKey]: NonSelectorBlock;\n};\n\ntype RichTextBlocksStore = Partial<BlocksStore> & Record<string, SelectorBlock | NonSelectorBlock>;\n\ninterface BlocksEditorContextValue {\n blocks: RichTextBlocksStore;\n modifiers: ModifiersStore;\n disabled: boolean;\n name: string;\n setLiveText: (text: string) => void;\n isExpandedMode: boolean;\n /** Push debounced Slate → form sync immediately (e.g. on Editable blur before Save). */\n flushPendingFormSync: () => void;\n}\n\nconst [BlocksEditorProvider, usePartialBlocksEditorContext] =\n createContext<BlocksEditorContextValue>('BlocksEditor');\n\nfunction useBlocksEditorContext(consumerName: string): BlocksEditorContextValue & {\n editor: Editor;\n} {\n const context = usePartialBlocksEditorContext(consumerName, (state) => state);\n const editor = useSlate();\n\n return {\n ...context,\n editor,\n };\n}\n\n/* -------------------------------------------------------------------------------------------------\n * BlocksEditor\n * -----------------------------------------------------------------------------------------------*/\n\nconst EditorDivider = styled(Divider)`\n background: ${({ theme }) => theme.colors.neutral200};\n`;\n\n/**\n * Forces an update of the Slate editor when the value prop changes from outside of Slate.\n * The root cause is that Slate is not a controlled component: https://github.com/ianstormtaylor/slate/issues/4612\n * Why not use JSON.stringify(value) as the key?\n * Because it would force a rerender of the entire editor every time the user types a character.\n * Why not use the entity id as the key, since it's unique for each locale?\n * Because it would not solve the problem when using the \"fill in from other locale\" feature\n */\nfunction useResetKey(\n editor: Editor,\n value?: Schema.Attribute.BlocksValue\n): {\n key: number;\n incrementSlateUpdatesCount: () => void;\n} {\n // Keep track how many times Slate detected a change from a user interaction in the editor\n const slateUpdatesCount = React.useRef(0);\n // Keep track of how many times the value prop was updated, whether from within editor or from outside\n const valueUpdatesCount = React.useRef(0);\n // Use a key to force a rerender of the Slate editor when needed\n const [key, setKey] = React.useState(0);\n\n React.useEffect(() => {\n valueUpdatesCount.current += 1;\n\n // If the 2 refs are not equal, it means the value was updated from outside\n if (valueUpdatesCount.current !== slateUpdatesCount.current) {\n // Bring the 2 refs back in sync\n slateUpdatesCount.current = valueUpdatesCount.current;\n\n // The update may just be an echo of the editor's own content coming back through the form\n // (e.g. the debounced sync, or a re-render while document queries settle). Remounting in\n // that case is pointless and destructive: it wipes pending input and the DOM under the\n // user's caret. Only force a remount when the content is actually different.\n const externalState = value?.length ? normalizeBlocksState(editor, value) : null;\n const editorState = normalizeBlocksState(editor, editor.children);\n if (JSON.stringify(externalState) === JSON.stringify(editorState)) {\n return;\n }\n\n // The remount reuses the same editor instance, so a selection pointing into the old\n // content would survive it and crash slate-react's toDOMPoint when the new content is\n // shorter. Drop the selection before swapping the children.\n if (editor.selection) {\n Transforms.deselect(editor);\n }\n\n // Change the key to force a rerender of the Slate editor,\n // which will pick up the new value through its initialValue prop\n setKey((previousKey) => previousKey + 1);\n }\n }, [editor, value]);\n\n const incrementSlateUpdatesCount = React.useCallback(() => {\n slateUpdatesCount.current += 1;\n }, []);\n\n return { key, incrementSlateUpdatesCount };\n}\n\nconst pipe =\n (...fns: ((baseEditor: Editor) => Editor)[]) =>\n (value: Editor) =>\n fns.reduce<Editor>((prev, fn) => fn(prev), value);\n\n/**\n * Normalize the blocks state to null if the editor state is considered empty,\n * otherwise return the state\n */\nconst normalizeBlocksState = (\n editor: Editor,\n value: Schema.Attribute.BlocksValue | Descendant[]\n): Schema.Attribute.BlocksValue | Descendant[] | null => {\n const isEmpty =\n value.length === 1 && Editor.isEmpty(editor, value[0] as Schema.Attribute.BlocksNode);\n\n return isEmpty ? null : value;\n};\n\ninterface BlocksEditorProps\n extends Pick<FieldValue<Schema.Attribute.BlocksValue>, 'onChange' | 'value' | 'error'>,\n BlocksContentProps {\n disabled?: boolean;\n name: string;\n /** When true, sync form state on every keystroke (Live Preview popover). */\n livePreviewSync?: boolean;\n /** Index of the block that was double-clicked in the live preview. When provided,\n * the editor positions the Slate cursor at that block on mount instead of using autoFocus. */\n blockIndex?: number | null;\n}\n\nconst BlocksEditor = React.forwardRef<{ focus: () => void }, BlocksEditorProps>(\n (\n {\n disabled = false,\n name,\n onChange,\n value,\n error,\n livePreviewSync = false,\n blockIndex,\n ...contentProps\n },\n forwardedRef\n ) => {\n const { formatMessage } = useIntl();\n const isMobile = useIsMobile();\n\n const blocks = useStrapiApp(\n 'BlocksEditor',\n (state) =>\n (\n state.plugins['content-manager']?.apis as\n | ContentManagerPlugin['config']['apis']\n | undefined\n )?.getRichTextBlocks() ?? ({} as RichTextBlocksStore)\n );\n\n const blockRegisteredPlugins = Object.values(blocks)\n .map((block) => block.plugin)\n .filter(isNonNullable);\n\n const [editor] = React.useState(() =>\n pipe(withHistory, withStrapiSchema, withReact, ...blockRegisteredPlugins)(createEditor())\n );\n const [liveText, setLiveText] = React.useState('');\n const ariaDescriptionId = React.useId();\n const [isExpandedMode, handleToggleExpand] = React.useReducer((prev) => !prev, false);\n\n /**\n * Editable is not able to hold the ref, https://github.com/ianstormtaylor/slate/issues/4082\n * so with \"useImperativeHandle\" we can use ReactEditor methods to expose to the parent above\n * also not passing forwarded ref here, gives console warning.\n */\n React.useImperativeHandle(\n forwardedRef,\n () => ({\n focus() {\n ReactEditor.focus(editor);\n },\n }),\n [editor]\n );\n\n const { key, incrementSlateUpdatesCount } = useResetKey(editor, value);\n\n const debounceTimeout = React.useRef<NodeJS.Timeout | null>(null);\n\n const flushPendingFormSync = React.useCallback(() => {\n if (!debounceTimeout.current) {\n return;\n }\n clearTimeout(debounceTimeout.current);\n debounceTimeout.current = null;\n // Counter was already bumped when the AST changed; only push form state here.\n // Ensure Strapi Form state updates before the next event (e.g. Save click) reads values.\n flushSync(() => {\n onChange(\n name,\n normalizeBlocksState(editor, editor.children) as Schema.Attribute.BlocksValue\n );\n });\n }, [editor, name, onChange]);\n\n const handleSlateChange = React.useCallback(\n (state: Descendant[]) => {\n const isAstChange = editor.operations.some((op) => op.type !== 'set_selection');\n\n if (isAstChange) {\n /**\n * Slate handles the state of the editor internally. We just need to keep Strapi's form\n * state in sync with it in order to make sure that things like the \"modified\" state\n * isn't broken. Updating the whole state on every change is very expensive however,\n * so we debounce calls to onChange to mitigate input lag.\n *\n * Bump the reset-key counter immediately (not inside the debounce). Otherwise any\n * value-prop identity change during the 300ms window — e.g. clicking the blocks\n * toolbar — looks like an external update with stale empty form state and remounts\n * the editor, wiping the pending input (blocks e2e flake).\n */\n incrementSlateUpdatesCount();\n if (livePreviewSync) {\n onChange(name, normalizeBlocksState(editor, state) as Schema.Attribute.BlocksValue);\n return;\n }\n\n if (debounceTimeout.current) {\n clearTimeout(debounceTimeout.current);\n }\n\n debounceTimeout.current = setTimeout(() => {\n // Normalize the state (empty editor becomes null)\n onChange(name, normalizeBlocksState(editor, state) as Schema.Attribute.BlocksValue);\n debounceTimeout.current = null;\n }, 300);\n }\n },\n [editor, incrementSlateUpdatesCount, livePreviewSync, name, onChange]\n );\n\n // Clean up the timeout on unmount\n React.useEffect(() => {\n return () => {\n if (debounceTimeout.current) {\n clearTimeout(debounceTimeout.current);\n }\n };\n }, []);\n\n // When opened from a live-preview double-click, position the cursor at the clicked block\n React.useEffect(() => {\n if (blockIndex == null) return;\n\n const targetIndex = Math.min(blockIndex, editor.children.length - 1);\n\n try {\n Transforms.select(editor, Editor.start(editor, [targetIndex]));\n } catch {\n // Slate tree not yet ready; skip cursor positioning and scroll\n return;\n }\n try {\n ReactEditor.focus(editor);\n } catch {\n // non-fatal — editor DOM not yet committed\n }\n\n // Defer scroll past the re-render triggered by Transforms.select above.\n // Slate's handleScrollSelectionIntoView runs as a layout effect during\n // that re-render; our rAF fires after it, letting us override the position.\n const raf = requestAnimationFrame(() => {\n try {\n const blockNode = Node.get(editor, [targetIndex]);\n const domEl = ReactEditor.toDOMNode(editor, blockNode as Element);\n // Walk to BlocksContent's scroll container via the Slate editor root,\n // bypassing scrollIntoView which can target overflow:hidden ancestors.\n const editorDomEl = domEl.closest('[data-slate-editor]');\n const scrollContainer = editorDomEl?.parentElement as HTMLElement | null;\n if (scrollContainer) {\n const blockRect = domEl.getBoundingClientRect();\n const containerRect = scrollContainer.getBoundingClientRect();\n // 24px = BlocksContent paddingTop={6} (design-system 4px scale)\n scrollContainer.scrollTop =\n blockRect.top - containerRect.top + scrollContainer.scrollTop - 24;\n } else {\n domEl.scrollIntoView({ block: 'start' });\n }\n } catch {\n // scroll errors are non-fatal; the cursor is already positioned\n }\n });\n\n return () => cancelAnimationFrame(raf);\n // `key` is included so that if useResetKey remounts the Slate editor (clearing\n // editor.selection to null), this effect re-runs and restores the cursor position.\n }, [blockIndex, editor, key]);\n\n // Ensure the editor is in sync after discard\n React.useEffect(() => {\n // Never deselect while the editor is actively focused (typing / editing),\n if (ReactEditor.isFocused(editor)) {\n return;\n }\n\n // Normalize empty states for comparison to avoid losing focus on the editor when content is deleted\n const normalizedValue = value?.length ? value : null;\n const normalizedEditorState = normalizeBlocksState(editor, editor.children);\n\n // Compare the field value with the editor state to check for a stale selection\n if (\n normalizedValue &&\n normalizedEditorState &&\n JSON.stringify(normalizedEditorState) !== JSON.stringify(normalizedValue)\n ) {\n // When there is a diff, unset selection to avoid an invalid state\n Transforms.deselect(editor);\n }\n }, [editor, value]);\n\n return (\n <>\n <VisuallyHidden id={ariaDescriptionId}>\n {formatMessage({\n id: getTranslation('components.Blocks.dnd.instruction'),\n defaultMessage: `To reorder blocks, press Command or Control along with Shift and the Up or Down arrow keys`,\n })}\n </VisuallyHidden>\n <VisuallyHidden aria-live=\"assertive\">{liveText}</VisuallyHidden>\n <Slate\n editor={editor}\n initialValue={\n value?.length ? value : [{ type: 'paragraph', children: [{ type: 'text', text: '' }] }]\n }\n onChange={handleSlateChange}\n key={key}\n >\n <BlocksEditorProvider\n blocks={blocks}\n modifiers={modifiers}\n disabled={disabled}\n name={name}\n setLiveText={setLiveText}\n isExpandedMode={isExpandedMode}\n flushPendingFormSync={flushPendingFormSync}\n >\n <EditorLayout\n error={error}\n disabled={disabled}\n onToggleExpand={handleToggleExpand}\n ariaDescriptionId={ariaDescriptionId}\n livePreviewSync={livePreviewSync}\n >\n <BlocksToolbar />\n <EditorDivider width=\"100%\" />\n <BlocksContent {...contentProps} />\n {!isExpandedMode && !isMobile && (\n <IconButton\n position=\"absolute\"\n bottom=\"1.2rem\"\n right=\"1.2rem\"\n shadow=\"filterShadow\"\n label={formatMessage({\n id: getTranslation('components.Blocks.expand'),\n defaultMessage: 'Expand',\n })}\n onClick={handleToggleExpand}\n >\n <Expand />\n </IconButton>\n )}\n </EditorLayout>\n </BlocksEditorProvider>\n </Slate>\n </>\n );\n }\n);\n\nexport {\n type BlocksStore,\n type RichTextBlocksStore,\n type SelectorBlockKey,\n BlocksEditor,\n BlocksEditorProvider,\n useBlocksEditorContext,\n isSelectorBlockKey,\n normalizeBlocksState,\n};\n"],"names":["BlocksEditorProvider","usePartialBlocksEditorContext","createContext","useBlocksEditorContext","consumerName","context","state","editor","useSlate","EditorDivider","styled","Divider","theme","colors","neutral200","useResetKey","value","slateUpdatesCount","React","useRef","valueUpdatesCount","key","setKey","useState","useEffect","current","externalState","length","normalizeBlocksState","editorState","children","JSON","stringify","selection","Transforms","deselect","previousKey","incrementSlateUpdatesCount","useCallback","pipe","fns","reduce","prev","fn","isEmpty","Editor","BlocksEditor","forwardRef","disabled","name","onChange","error","livePreviewSync","blockIndex","contentProps","forwardedRef","formatMessage","useIntl","isMobile","useIsMobile","blocks","useStrapiApp","plugins","apis","getRichTextBlocks","blockRegisteredPlugins","Object","values","map","block","plugin","filter","isNonNullable","withHistory","withStrapiSchema","withReact","createEditor","liveText","setLiveText","ariaDescriptionId","useId","isExpandedMode","handleToggleExpand","useReducer","useImperativeHandle","focus","ReactEditor","debounceTimeout","flushPendingFormSync","clearTimeout","flushSync","handleSlateChange","isAstChange","operations","some","op","type","setTimeout","targetIndex","Math","min","select","start","raf","requestAnimationFrame","blockNode","Node","get","domEl","toDOMNode","editorDomEl","closest","scrollContainer","parentElement","blockRect","getBoundingClientRect","containerRect","scrollTop","top","scrollIntoView","cancelAnimationFrame","isFocused","normalizedValue","normalizedEditorState","_jsxs","_Fragment","_jsx","VisuallyHidden","id","getTranslation","defaultMessage","aria-live","Slate","initialValue","text","modifiers","EditorLayout","onToggleExpand","BlocksToolbar","width","BlocksContent","IconButton","position","bottom","right","shadow","label","onClick","Expand"],"mappings":";;;;;;;;;;;;;;;;;;;AA+GA,MAAM,CAACA,oBAAAA,EAAsBC,6BAAAA,CAA8B,GACzDC,aAAAA,CAAwC,cAAA;AAE1C,SAASC,uBAAuBC,YAAoB,EAAA;AAGlD,IAAA,MAAMC,OAAAA,GAAUJ,6BAAAA,CAA8BG,YAAAA,EAAc,CAACE,KAAAA,GAAUA,KAAAA,CAAAA;AACvE,IAAA,MAAMC,MAAAA,GAASC,QAAAA,EAAAA;IAEf,OAAO;AACL,QAAA,GAAGH,OAAO;AACVE,QAAAA;AACF,KAAA;AACF;AAEA;;AAEkG,qGAElG,MAAME,aAAAA,GAAgBC,MAAAA,CAAOC,OAAAA,CAAQ;cACvB,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACC,UAAU,CAAC;AACvD,CAAC;AAED;;;;;;;AAOC,IACD,SAASC,WAAAA,CACPR,MAAc,EACdS,KAAoC,EAAA;;I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AAO1F,aAAAA,CAAc;AACnBwE,oCAAAA,EAAAA,EAAIC,cAAAA,CAAe,0BAAA,CAAA;oCACnBC,cAAAA,EAAgB;AAClB,iCAAA,CAAA;gCACAiB,OAAAA,EAASjE,kBAAAA;AAET,gCAAA,QAAA,gBAAA4C,GAAA,CAACsB,MAAAA,EAAAA,EAAAA;;;;;AAjCJ/H,aAAAA,EAAAA,GAAAA;;;AAyCb,CAAA;;;;"}
@@ -26,7 +26,7 @@ function _interopNamespace(e) {
26
26
 
27
27
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
28
 
29
- const BlocksInput = /*#__PURE__*/ React__namespace.forwardRef(({ label, name, required = false, hint, labelAction, ...editorProps }, forwardedRef)=>{
29
+ const BlocksInput = /*#__PURE__*/ React__namespace.forwardRef(({ label, name, required = false, hint, labelAction, livePreviewSync = false, ...editorProps }, forwardedRef)=>{
30
30
  const id = React__namespace.useId();
31
31
  const field = strapiAdmin.useField(name);
32
32
  return /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Root, {
@@ -35,10 +35,12 @@ const BlocksInput = /*#__PURE__*/ React__namespace.forwardRef(({ label, name, re
35
35
  hint: hint,
36
36
  error: field.error,
37
37
  required: required,
38
+ minHeight: livePreviewSync ? 0 : undefined,
38
39
  children: /*#__PURE__*/ jsxRuntime.jsxs(designSystem.Flex, {
39
40
  direction: "column",
40
41
  alignItems: "stretch",
41
42
  gap: 1,
43
+ minHeight: livePreviewSync ? 0 : undefined,
42
44
  children: [
43
45
  /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Label, {
44
46
  action: labelAction,
@@ -51,6 +53,7 @@ const BlocksInput = /*#__PURE__*/ React__namespace.forwardRef(({ label, name, re
51
53
  value: field.value ?? [],
52
54
  onChange: field.onChange,
53
55
  ariaLabelId: id,
56
+ livePreviewSync: livePreviewSync,
54
57
  ...editorProps
55
58
  }),
56
59
  /*#__PURE__*/ jsxRuntime.jsx(designSystem.Field.Hint, {}),
@@ -1 +1 @@
1
- {"version":3,"file":"BlocksInput.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useField, type InputProps } from '@strapi/admin/strapi-admin';\nimport { Field, Flex } from '@strapi/design-system';\n\nimport { BlocksEditor } from './BlocksEditor';\n\nimport type { Schema } from '@strapi/types';\n\ninterface BlocksInputProps extends Omit<InputProps, 'type'> {\n labelAction?: React.ReactNode;\n type: Schema.Attribute.Blocks['type'];\n}\n\nconst BlocksInput = React.forwardRef<{ focus: () => void }, BlocksInputProps>(\n ({ label, name, required = false, hint, labelAction, ...editorProps }, forwardedRef) => {\n const id = React.useId();\n const field = useField<Schema.Attribute.BlocksValue>(name);\n\n return (\n <Field.Root id={id} name={name} hint={hint} error={field.error} required={required}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <Field.Label action={labelAction}>{label}</Field.Label>\n <BlocksEditor\n name={name}\n error={field.error}\n ref={forwardedRef}\n value={field.value ?? []}\n onChange={field.onChange}\n ariaLabelId={id}\n {...editorProps}\n />\n <Field.Hint />\n <Field.Error />\n </Flex>\n </Field.Root>\n );\n }\n);\n\nconst MemoizedBlocksInput = React.memo(BlocksInput);\n\nexport { MemoizedBlocksInput as BlocksInput };\n"],"names":["BlocksInput","React","forwardRef","label","name","required","hint","labelAction","editorProps","forwardedRef","id","useId","field","useField","_jsx","Field","Root","error","_jsxs","Flex","direction","alignItems","gap","Label","action","BlocksEditor","ref","value","onChange","ariaLabelId","Hint","Error","MemoizedBlocksInput","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAMA,4BAAcC,gBAAAA,CAAMC,UAAU,CAClC,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAAA,GAAW,KAAK,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGC,aAAa,EAAEC,YAAAA,GAAAA;IACrE,MAAMC,EAAAA,GAAKT,iBAAMU,KAAK,EAAA;AACtB,IAAA,MAAMC,QAAQC,oBAAAA,CAAuCT,IAAAA,CAAAA;IAErD,qBACEU,cAAA,CAACC,mBAAMC,IAAI,EAAA;QAACN,EAAAA,EAAIA,EAAAA;QAAIN,IAAAA,EAAMA,IAAAA;QAAME,IAAAA,EAAMA,IAAAA;AAAMW,QAAAA,KAAAA,EAAOL,MAAMK,KAAK;QAAEZ,QAAAA,EAAUA,QAAAA;AACxE,QAAA,QAAA,gBAAAa,eAAA,CAACC,iBAAAA,EAAAA;YAAKC,SAAAA,EAAU,QAAA;YAASC,UAAAA,EAAW,SAAA;YAAUC,GAAAA,EAAK,CAAA;;AACjD,8BAAAR,cAAA,CAACC,mBAAMQ,KAAK,EAAA;oBAACC,MAAAA,EAAQjB,WAAAA;AAAcJ,oBAAAA,QAAAA,EAAAA;;8BACnCW,cAAA,CAACW,yBAAAA,EAAAA;oBACCrB,IAAAA,EAAMA,IAAAA;AACNa,oBAAAA,KAAAA,EAAOL,MAAMK,KAAK;oBAClBS,GAAAA,EAAKjB,YAAAA;oBACLkB,KAAAA,EAAOf,KAAAA,CAAMe,KAAK,IAAI,EAAE;AACxBC,oBAAAA,QAAAA,EAAUhB,MAAMgB,QAAQ;oBACxBC,WAAAA,EAAanB,EAAAA;AACZ,oBAAA,GAAGF;;AAEN,8BAAAM,cAAA,CAACC,mBAAMe,IAAI,EAAA,EAAA,CAAA;AACX,8BAAAhB,cAAA,CAACC,mBAAMgB,KAAK,EAAA,EAAA;;;;AAIpB,CAAA,CAAA;AAGF,MAAMC,mBAAAA,iBAAsB/B,gBAAAA,CAAMgC,IAAI,CAACjC,WAAAA;;;;"}
1
+ {"version":3,"file":"BlocksInput.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useField, type InputProps } from '@strapi/admin/strapi-admin';\nimport { Field, Flex } from '@strapi/design-system';\n\nimport { BlocksEditor } from './BlocksEditor';\n\nimport type { Schema } from '@strapi/types';\n\ninterface BlocksInputProps extends Omit<InputProps, 'type'> {\n labelAction?: React.ReactNode;\n type: Schema.Attribute.Blocks['type'];\n autoFocus?: boolean;\n livePreviewSync?: boolean;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n blockIndex?: number | null;\n}\n\nconst BlocksInput = React.forwardRef<{ focus: () => void }, BlocksInputProps>(\n (\n { label, name, required = false, hint, labelAction, livePreviewSync = false, ...editorProps },\n forwardedRef\n ) => {\n const id = React.useId();\n const field = useField<Schema.Attribute.BlocksValue>(name);\n\n return (\n <Field.Root\n id={id}\n name={name}\n hint={hint}\n error={field.error}\n required={required}\n minHeight={livePreviewSync ? 0 : undefined}\n >\n <Flex\n direction=\"column\"\n alignItems=\"stretch\"\n gap={1}\n minHeight={livePreviewSync ? 0 : undefined}\n >\n <Field.Label action={labelAction}>{label}</Field.Label>\n <BlocksEditor\n name={name}\n error={field.error}\n ref={forwardedRef}\n value={field.value ?? []}\n onChange={field.onChange}\n ariaLabelId={id}\n livePreviewSync={livePreviewSync}\n {...editorProps}\n />\n <Field.Hint />\n <Field.Error />\n </Flex>\n </Field.Root>\n );\n }\n);\n\nconst MemoizedBlocksInput = React.memo(BlocksInput);\n\nexport { MemoizedBlocksInput as BlocksInput };\n"],"names":["BlocksInput","React","forwardRef","label","name","required","hint","labelAction","livePreviewSync","editorProps","forwardedRef","id","useId","field","useField","_jsx","Field","Root","error","minHeight","undefined","_jsxs","Flex","direction","alignItems","gap","Label","action","BlocksEditor","ref","value","onChange","ariaLabelId","Hint","Error","MemoizedBlocksInput","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmBA,MAAMA,WAAAA,iBAAcC,iBAAMC,UAAU,CAClC,CACE,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAAA,GAAW,KAAK,EAAEC,IAAI,EAAEC,WAAW,EAAEC,kBAAkB,KAAK,EAAE,GAAGC,WAAAA,EAAa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7 +4,7 @@ import { useField } from '@strapi/admin/strapi-admin';
4
4
  import { Field, Flex } from '@strapi/design-system';
5
5
  import { BlocksEditor } from './BlocksEditor.mjs';
6
6
 
7
- const BlocksInput = /*#__PURE__*/ React.forwardRef(({ label, name, required = false, hint, labelAction, ...editorProps }, forwardedRef)=>{
7
+ const BlocksInput = /*#__PURE__*/ React.forwardRef(({ label, name, required = false, hint, labelAction, livePreviewSync = false, ...editorProps }, forwardedRef)=>{
8
8
  const id = React.useId();
9
9
  const field = useField(name);
10
10
  return /*#__PURE__*/ jsx(Field.Root, {
@@ -13,10 +13,12 @@ const BlocksInput = /*#__PURE__*/ React.forwardRef(({ label, name, required = fa
13
13
  hint: hint,
14
14
  error: field.error,
15
15
  required: required,
16
+ minHeight: livePreviewSync ? 0 : undefined,
16
17
  children: /*#__PURE__*/ jsxs(Flex, {
17
18
  direction: "column",
18
19
  alignItems: "stretch",
19
20
  gap: 1,
21
+ minHeight: livePreviewSync ? 0 : undefined,
20
22
  children: [
21
23
  /*#__PURE__*/ jsx(Field.Label, {
22
24
  action: labelAction,
@@ -29,6 +31,7 @@ const BlocksInput = /*#__PURE__*/ React.forwardRef(({ label, name, required = fa
29
31
  value: field.value ?? [],
30
32
  onChange: field.onChange,
31
33
  ariaLabelId: id,
34
+ livePreviewSync: livePreviewSync,
32
35
  ...editorProps
33
36
  }),
34
37
  /*#__PURE__*/ jsx(Field.Hint, {}),
@@ -1 +1 @@
1
- {"version":3,"file":"BlocksInput.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useField, type InputProps } from '@strapi/admin/strapi-admin';\nimport { Field, Flex } from '@strapi/design-system';\n\nimport { BlocksEditor } from './BlocksEditor';\n\nimport type { Schema } from '@strapi/types';\n\ninterface BlocksInputProps extends Omit<InputProps, 'type'> {\n labelAction?: React.ReactNode;\n type: Schema.Attribute.Blocks['type'];\n}\n\nconst BlocksInput = React.forwardRef<{ focus: () => void }, BlocksInputProps>(\n ({ label, name, required = false, hint, labelAction, ...editorProps }, forwardedRef) => {\n const id = React.useId();\n const field = useField<Schema.Attribute.BlocksValue>(name);\n\n return (\n <Field.Root id={id} name={name} hint={hint} error={field.error} required={required}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <Field.Label action={labelAction}>{label}</Field.Label>\n <BlocksEditor\n name={name}\n error={field.error}\n ref={forwardedRef}\n value={field.value ?? []}\n onChange={field.onChange}\n ariaLabelId={id}\n {...editorProps}\n />\n <Field.Hint />\n <Field.Error />\n </Flex>\n </Field.Root>\n );\n }\n);\n\nconst MemoizedBlocksInput = React.memo(BlocksInput);\n\nexport { MemoizedBlocksInput as BlocksInput };\n"],"names":["BlocksInput","React","forwardRef","label","name","required","hint","labelAction","editorProps","forwardedRef","id","useId","field","useField","_jsx","Field","Root","error","_jsxs","Flex","direction","alignItems","gap","Label","action","BlocksEditor","ref","value","onChange","ariaLabelId","Hint","Error","MemoizedBlocksInput","memo"],"mappings":";;;;;;AAcA,MAAMA,4BAAcC,KAAAA,CAAMC,UAAU,CAClC,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAAA,GAAW,KAAK,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGC,aAAa,EAAEC,YAAAA,GAAAA;IACrE,MAAMC,EAAAA,GAAKT,MAAMU,KAAK,EAAA;AACtB,IAAA,MAAMC,QAAQC,QAAAA,CAAuCT,IAAAA,CAAAA;IAErD,qBACEU,GAAA,CAACC,MAAMC,IAAI,EAAA;QAACN,EAAAA,EAAIA,EAAAA;QAAIN,IAAAA,EAAMA,IAAAA;QAAME,IAAAA,EAAMA,IAAAA;AAAMW,QAAAA,KAAAA,EAAOL,MAAMK,KAAK;QAAEZ,QAAAA,EAAUA,QAAAA;AACxE,QAAA,QAAA,gBAAAa,IAAA,CAACC,IAAAA,EAAAA;YAAKC,SAAAA,EAAU,QAAA;YAASC,UAAAA,EAAW,SAAA;YAAUC,GAAAA,EAAK,CAAA;;AACjD,8BAAAR,GAAA,CAACC,MAAMQ,KAAK,EAAA;oBAACC,MAAAA,EAAQjB,WAAAA;AAAcJ,oBAAAA,QAAAA,EAAAA;;8BACnCW,GAAA,CAACW,YAAAA,EAAAA;oBACCrB,IAAAA,EAAMA,IAAAA;AACNa,oBAAAA,KAAAA,EAAOL,MAAMK,KAAK;oBAClBS,GAAAA,EAAKjB,YAAAA;oBACLkB,KAAAA,EAAOf,KAAAA,CAAMe,KAAK,IAAI,EAAE;AACxBC,oBAAAA,QAAAA,EAAUhB,MAAMgB,QAAQ;oBACxBC,WAAAA,EAAanB,EAAAA;AACZ,oBAAA,GAAGF;;AAEN,8BAAAM,GAAA,CAACC,MAAMe,IAAI,EAAA,EAAA,CAAA;AACX,8BAAAhB,GAAA,CAACC,MAAMgB,KAAK,EAAA,EAAA;;;;AAIpB,CAAA,CAAA;AAGF,MAAMC,mBAAAA,iBAAsB/B,KAAAA,CAAMgC,IAAI,CAACjC,WAAAA;;;;"}
1
+ {"version":3,"file":"BlocksInput.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useField, type InputProps } from '@strapi/admin/strapi-admin';\nimport { Field, Flex } from '@strapi/design-system';\n\nimport { BlocksEditor } from './BlocksEditor';\n\nimport type { Schema } from '@strapi/types';\n\ninterface BlocksInputProps extends Omit<InputProps, 'type'> {\n labelAction?: React.ReactNode;\n type: Schema.Attribute.Blocks['type'];\n autoFocus?: boolean;\n livePreviewSync?: boolean;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n blockIndex?: number | null;\n}\n\nconst BlocksInput = React.forwardRef<{ focus: () => void }, BlocksInputProps>(\n (\n { label, name, required = false, hint, labelAction, livePreviewSync = false, ...editorProps },\n forwardedRef\n ) => {\n const id = React.useId();\n const field = useField<Schema.Attribute.BlocksValue>(name);\n\n return (\n <Field.Root\n id={id}\n name={name}\n hint={hint}\n error={field.error}\n required={required}\n minHeight={livePreviewSync ? 0 : undefined}\n >\n <Flex\n direction=\"column\"\n alignItems=\"stretch\"\n gap={1}\n minHeight={livePreviewSync ? 0 : undefined}\n >\n <Field.Label action={labelAction}>{label}</Field.Label>\n <BlocksEditor\n name={name}\n error={field.error}\n ref={forwardedRef}\n value={field.value ?? []}\n onChange={field.onChange}\n ariaLabelId={id}\n livePreviewSync={livePreviewSync}\n {...editorProps}\n />\n <Field.Hint />\n <Field.Error />\n </Flex>\n </Field.Root>\n );\n }\n);\n\nconst MemoizedBlocksInput = React.memo(BlocksInput);\n\nexport { MemoizedBlocksInput as BlocksInput };\n"],"names":["BlocksInput","React","forwardRef","label","name","required","hint","labelAction","livePreviewSync","editorProps","forwardedRef","id","useId","field","useField","_jsx","Field","Root","error","minHeight","undefined","_jsxs","Flex","direction","alignItems","gap","Label","action","BlocksEditor","ref","value","onChange","ariaLabelId","Hint","Error","MemoizedBlocksInput","memo"],"mappings":";;;;;;AAmBA,MAAMA,WAAAA,iBAAcC,MAAMC,UAAU,CAClC,CACE,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAAA,GAAW,KAAK,EAAEC,IAAI,EAAEC,WAAW,EAAEC,kBAAkB,KAAK,EAAE,GAAGC,WAAAA,EAAa,EAC7FC,YAAAA,GAAAA;IAEA,MAAMC,EAAAA,GAAKV,MAAMW,KAAK,EAAA;AACtB,IAAA,MAAMC,QAAQC,QAAAA,CAAuCV,IAAAA,CAAAA;IAErD,qBACEW,GAAA,CAACC,MAAMC,IAAI,EAAA;QACTN,EAAAA,EAAIA,EAAAA;QACJP,IAAAA,EAAMA,IAAAA;QACNE,IAAAA,EAAMA,IAAAA;AACNY,QAAAA,KAAAA,EAAOL,MAAMK,KAAK;QAClBb,QAAAA,EAAUA,QAAAA;AACVc,QAAAA,SAAAA,EAAWX,kBAAkB,CAAA,GAAIY,SAAAA;AAEjC,QAAA,QAAA,gBAAAC,IAAA,CAACC,IAAAA,EAAAA;YACCC,SAAAA,EAAU,QAAA;YACVC,UAAAA,EAAW,SAAA;YACXC,GAAAA,EAAK,CAAA;AACLN,YAAAA,SAAAA,EAAWX,kBAAkB,CAAA,GAAIY,SAAAA;;AAEjC,8BAAAL,GAAA,CAACC,MAAMU,KAAK,EAAA;oBAACC,MAAAA,EAAQpB,WAAAA;AAAcJ,oBAAAA,QAAAA,EAAAA;;8BACnCY,GAAA,CAACa,YAAAA,EAAAA;oBACCxB,IAAAA,EAAMA,IAAAA;AACNc,oBAAAA,KAAAA,EAAOL,MAAMK,KAAK;oBAClBW,GAAAA,EAAKnB,YAAAA;oBACLoB,KAAAA,EAAOjB,KAAAA,CAAMiB,KAAK,IAAI,EAAE;AACxBC,oBAAAA,QAAAA,EAAUlB,MAAMkB,QAAQ;oBACxBC,WAAAA,EAAarB,EAAAA;oBACbH,eAAAA,EAAiBA,eAAAA;AAChB,oBAAA,GAAGC;;AAEN,8BAAAM,GAAA,CAACC,MAAMiB,IAAI,EAAA,EAAA,CAAA;AACX,8BAAAlB,GAAA,CAACC,MAAMkB,KAAK,EAAA,EAAA;;;;AAIpB,CAAA,CAAA;AAGF,MAAMC,mBAAAA,iBAAsBlC,KAAAA,CAAMmC,IAAI,CAACpC,WAAAA;;;;"}
@@ -620,6 +620,7 @@ const BlocksToolbar = ()=>{
620
620
  const { editor, blocks, modifiers, disabled } = BlocksEditor.useBlocksEditorContext('BlocksToolbar');
621
621
  const { formatMessage } = reactIntl.useIntl();
622
622
  const isMobile = strapiAdmin.useIsMobile();
623
+ const toolbarContainerRef = React__namespace.useRef(null);
623
624
  /**
624
625
  * The modifier buttons are disabled when an image is selected.
625
626
  */ const checkButtonDisabled = ()=>{
@@ -752,12 +753,14 @@ const BlocksToolbar = ()=>{
752
753
  type: "multiple",
753
754
  asChild: true,
754
755
  children: /*#__PURE__*/ jsxRuntime.jsx(designSystem.Flex, {
756
+ ref: toolbarContainerRef,
755
757
  direction: "row",
756
758
  gap: 1,
757
759
  grow: 1,
758
760
  overflow: "hidden",
759
761
  children: /*#__PURE__*/ jsxRuntime.jsx(EditorToolbarObserver.EditorToolbarObserver, {
760
- observedComponents: observedComponents
762
+ observedComponents: observedComponents,
763
+ containerRef: toolbarContainerRef
761
764
  })
762
765
  })
763
766
  })
@@ -1 +1 @@
1
- {"version":3,"file":"BlocksToolbar.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport * as Toolbar from '@radix-ui/react-toolbar';\nimport { useIsMobile } from '@strapi/admin/strapi-admin';\nimport {\n Flex,\n Tooltip,\n SingleSelect,\n SingleSelectOption,\n Box,\n FlexComponent,\n BoxComponent,\n Menu,\n} from '@strapi/design-system';\nimport { Link, ArrowUp, ArrowDown } from '@strapi/icons';\nimport { MessageDescriptor, useIntl } from 'react-intl';\nimport { Editor, Transforms, Element as SlateElement, Node, type Ancestor } from 'slate';\nimport { ReactEditor } from 'slate-react';\nimport { css, styled } from 'styled-components';\n\nimport { getTranslation } from '../../../../../utils/translations';\nimport { EditorToolbarObserver, type ObservedComponent } from '../../EditorToolbarObserver';\n\nimport { insertLink } from './Blocks/Link';\nimport { type BlocksStore, type SelectorBlock, useBlocksEditorContext } from './BlocksEditor';\nimport { type Block, getEntries, getKeys } from './utils/types';\n\nconst ToolbarWrapper = styled<FlexComponent>(Flex)`\n &[aria-disabled='true'] {\n cursor: not-allowed;\n background: ${({ theme }) => theme.colors.neutral150};\n }\n`;\n\nconst ToolbarSeparator = styled(Toolbar.Separator)`\n background: ${({ theme }) => theme.colors.neutral150};\n width: 1px;\n height: 2.4rem;\n margin-left: ${({ theme }) => theme.spaces[1]};\n margin-right: ${({ theme }) => theme.spaces[1]};\n\n ${({ theme }) => theme.breakpoints.medium} {\n margin-left: ${({ theme }) => theme.spaces[2]};\n margin-right: ${({ theme }) => theme.spaces[2]};\n }\n`;\n\nconst FlexButton = styled<FlexComponent<'button'>>(Flex)`\n // Inherit the not-allowed cursor from ToolbarWrapper when disabled\n &[aria-disabled] {\n cursor: not-allowed;\n }\n\n &[aria-disabled='false'] {\n cursor: pointer;\n\n // Only apply hover styles if the button is enabled on desktop\n ${({ theme }) => theme.breakpoints.medium} {\n &:hover {\n background: ${({ theme }) => theme.colors.primary100};\n }\n }\n }\n`;\n\nconst SelectWrapper = styled<BoxComponent>(Box)`\n // Styling changes to SingleSelect component don't work, so adding wrapper to target SingleSelect\n div[role='combobox'] {\n border: none;\n cursor: pointer;\n min-height: unset;\n padding-top: ${({ theme }) => theme.spaces[2]};\n padding-bottom: ${({ theme }) => theme.spaces[2]};\n padding-left: ${({ theme }) => theme.spaces[4]};\n padding-right: ${({ theme }) => theme.spaces[4]};\n gap: ${({ theme }) => theme.spaces[2]};\n \n ${({ theme }) => theme.breakpoints.medium} {\n padding-top: ${({ theme }) => theme.spaces[1]};\n padding-bottom: ${({ theme }) => theme.spaces[1]};\n gap: ${({ theme }) => theme.spaces[4]};\n }\n\n &[aria-disabled='false']:hover {\n cursor: pointer;\n background: ${({ theme }) => theme.colors.primary100};\n }\n\n &[aria-disabled] {\n background: transparent;\n cursor: inherit;\n\n // Select text and icons should also have disabled color\n span {\n color: ${({ theme }) => theme.colors.neutral600};\n }\n }\n\n & > span:first-child {\n gap: ${({ theme }) => theme.spaces[0]};\n\n ${({ theme }) => theme.breakpoints.medium} {\n gap: ${({ theme }) => theme.spaces[3]};\n }\n }\n`;\n\n/**\n * Handles the modal component that may be returned by a block when converting it\n */\nfunction useConversionModal() {\n const [modalElement, setModalComponent] = React.useState<React.JSX.Element | null>(null);\n\n const handleConversionResult = (renderModal: void | (() => React.JSX.Element) | undefined) => {\n // Not all blocks return a modal\n if (renderModal) {\n // Use cloneElement to apply a key because to create a new instance of the component\n // Without the new key, the state is kept from previous times that option was picked\n setModalComponent(React.cloneElement(renderModal(), { key: Date.now() }));\n }\n };\n\n return { modalElement, handleConversionResult };\n}\n\ninterface ToolbarButtonProps {\n icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>;\n name: string;\n label: MessageDescriptor;\n isActive: boolean;\n disabled: boolean;\n handleClick: () => void;\n}\n\nconst ToolbarButton = ({\n icon: Icon,\n name,\n label,\n isActive,\n disabled,\n handleClick,\n}: ToolbarButtonProps) => {\n const { editor } = useBlocksEditorContext('ToolbarButton');\n const { formatMessage } = useIntl();\n const labelMessage = formatMessage(label);\n\n const enabledColor = isActive ? 'primary600' : 'neutral600';\n\n return (\n <Tooltip label={labelMessage}>\n <Toolbar.ToggleItem\n value={name}\n data-state={isActive ? 'on' : 'off'}\n onPointerDown={(e) => {\n e.preventDefault();\n handleClick();\n ReactEditor.focus(editor);\n }}\n aria-disabled={disabled}\n disabled={disabled}\n aria-label={labelMessage}\n asChild\n >\n <FlexButton\n tag=\"button\"\n background={isActive ? 'primary100' : ''}\n alignItems=\"center\"\n justifyContent=\"center\"\n width={7}\n height={7}\n hasRadius\n type=\"button\"\n >\n {Icon && <Icon fill={disabled ? 'neutral300' : enabledColor} />}\n </FlexButton>\n </Toolbar.ToggleItem>\n </Tooltip>\n );\n};\n\nconst BlocksDropdown = () => {\n const { editor, blocks, disabled } = useBlocksEditorContext('BlocksDropdown');\n const { formatMessage } = useIntl();\n const { modalElement, handleConversionResult } = useConversionModal();\n const isMobile = useIsMobile();\n\n const blockKeysToInclude: string[] = getEntries(blocks).reduce<string[]>(\n (currentKeys, [key, block]) => {\n return block?.isInBlocksSelector ? [...currentKeys, key] : currentKeys;\n },\n []\n );\n\n const [blockSelected, setBlockSelected] = React.useState<string>('paragraph');\n\n const handleSelect = (optionKey: unknown) => {\n if (typeof optionKey !== 'string' || !blocks[optionKey]) {\n return;\n }\n\n const editorIsEmpty =\n editor.children.length === 1 && Editor.isEmpty(editor, editor.children[0]);\n\n if (!editor.selection && !editorIsEmpty) {\n // Toolbar buttons steal focus in Playwright (and sometimes in real browsers), clearing\n // selection. Convert the last existing block — do not insert a new empty block, which\n // would leave the user's content behind and convert a blank node instead.\n const [, lastPath] = Editor.last(editor, []);\n Transforms.select(editor, Editor.range(editor, lastPath));\n } else if (!editor.selection && editorIsEmpty) {\n // When there is no selection and the editor is empty,\n // select the empty paragraph from Slate's initialValue so it gets converted\n Transforms.select(editor, Editor.start(editor, [0, 0]));\n }\n\n // If selection is already a list block, toggle its format\n const currentListEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n });\n\n if (currentListEntry && ['list-ordered', 'list-unordered'].includes(optionKey)) {\n const [currentList, currentListPath] = currentListEntry;\n const format = optionKey === 'list-ordered' ? 'ordered' : 'unordered';\n\n if (!Editor.isEditor(currentList) && isListNode(currentList)) {\n // Format is different, toggle list format\n if (currentList.format !== format) {\n Transforms.setNodes(editor, { format }, { at: currentListPath });\n }\n }\n return;\n }\n\n // Let the block handle the Slate conversion logic\n const maybeRenderModal = blocks[optionKey]?.handleConvert?.(editor);\n handleConversionResult(maybeRenderModal);\n\n setBlockSelected(optionKey);\n\n ReactEditor.focus(editor);\n };\n\n /**\n * Prevent the select from focusing itself so ReactEditor.focus(editor) can focus the editor instead.\n *\n * The editor first loses focus to a blur event when clicking the select button. However,\n * refocusing the editor is not enough since the select's default behavior is to refocus itself\n * after an option is selected.\n *\n */\n const preventSelectFocus = (e: Event) => e.preventDefault();\n\n // Listen to the selection change and update the selected block in the dropdown\n React.useEffect(() => {\n if (editor.selection) {\n let selectedNode: Ancestor;\n\n // If selection anchor is a list-item, get its parent\n const currentListEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n at: editor.selection.anchor,\n });\n\n if (currentListEntry) {\n const [currentList] = currentListEntry;\n selectedNode = currentList;\n } else {\n // Get the parent node of the anchor other than list-item\n const [anchorNode] = Editor.parent(editor, editor.selection.anchor, {\n edge: 'start',\n depth: 2,\n });\n\n // @ts-expect-error slate's delete behaviour creates an exceptional type\n if (anchorNode.type === 'list-item') {\n // When the last node in the selection is a list item,\n // slate's default delete operation leaves an empty list-item instead of converting it into a paragraph.\n // Issue: https://github.com/ianstormtaylor/slate/issues/2500\n\n Transforms.setNodes(editor, { type: 'paragraph' });\n // @ts-expect-error convert explicitly type to paragraph\n selectedNode = { ...anchorNode, type: 'paragraph' };\n } else {\n selectedNode = anchorNode;\n }\n }\n\n // Find the block key that matches the anchor node\n const anchorBlockKey = getKeys(blocks).find(\n (blockKey) => !Editor.isEditor(selectedNode) && blocks[blockKey]?.matchNode(selectedNode)\n );\n\n // Change the value selected in the dropdown if it doesn't match the anchor block key\n if (anchorBlockKey && anchorBlockKey !== blockSelected) {\n setBlockSelected(anchorBlockKey);\n }\n }\n }, [editor.selection, editor, blocks, blockSelected]);\n\n React.useEffect(() => {\n // If the selected block is not in the list of blocks to include, change the selected block to the first one\n if (blockKeysToInclude.length > 0 && !blockKeysToInclude.includes(blockSelected)) {\n setBlockSelected(blockKeysToInclude[0]);\n }\n }, [blockKeysToInclude, blockSelected]);\n\n if (!blocks[blockSelected]) {\n return null;\n }\n\n const selectedBlock = blocks[blockSelected] as SelectorBlock;\n const Icon = selectedBlock.icon;\n\n return (\n <>\n <SelectWrapper>\n <SingleSelect\n startIcon={Icon && <Icon />}\n onChange={handleSelect}\n customizeContent={() => (isMobile ? '' : formatMessage(selectedBlock.label))}\n value={blockSelected}\n onCloseAutoFocus={preventSelectFocus}\n aria-label={formatMessage({\n id: 'components.Blocks.blocks.selectBlock',\n defaultMessage: 'Select a block',\n })}\n disabled={disabled}\n >\n {blockKeysToInclude.map((key) => {\n const selectorBlock = blocks[key] as SelectorBlock;\n return (\n <BlockOption\n key={key}\n value={key}\n label={selectorBlock.label}\n icon={selectorBlock.icon}\n blockSelected={blockSelected}\n />\n );\n })}\n </SingleSelect>\n </SelectWrapper>\n {modalElement}\n </>\n );\n};\n\ninterface BlockOptionProps {\n value: string;\n icon?: React.ComponentType<React.SVGProps<SVGElement>>;\n label: MessageDescriptor;\n blockSelected: string;\n}\n\nconst BlockOption = ({ value, icon: Icon, label, blockSelected }: BlockOptionProps) => {\n const { formatMessage } = useIntl();\n\n const isSelected = value === blockSelected;\n\n return (\n <SingleSelectOption\n startIcon={Icon && <Icon fill={isSelected ? 'primary600' : 'neutral500'} />}\n value={value}\n >\n {formatMessage(label)}\n </SingleSelectOption>\n );\n};\n\nconst isListNode = (node: unknown): node is Block<'list'> => {\n return Node.isNode(node) && !Editor.isEditor(node) && node.type === 'list';\n};\n\ninterface ListButtonProps {\n block: BlocksStore['list-ordered'] | BlocksStore['list-unordered'];\n format: Block<'list'>['format'];\n location?: 'toolbar' | 'menu';\n}\n\nconst ListButton = ({ block, format, location = 'toolbar' }: ListButtonProps) => {\n const { formatMessage } = useIntl();\n const { editor, disabled, blocks } = useBlocksEditorContext('ListButton');\n\n const isListActive = () => {\n if (!editor.selection) return false;\n\n // Get the parent list at selection anchor node\n const currentListEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n at: editor.selection.anchor,\n });\n\n if (currentListEntry) {\n const [currentList] = currentListEntry;\n if (!Editor.isEditor(currentList) && isListNode(currentList) && currentList.format === format)\n return true;\n }\n\n return false;\n };\n\n /**\n * @TODO: Currently, applying list while multiple blocks are selected is not supported.\n * We should implement this feature in the future.\n */\n const isListDisabled = () => {\n // Always disabled when the whole editor is disabled\n if (disabled) {\n return true;\n }\n\n // Always enabled when there's no selection\n if (!editor.selection) {\n return false;\n }\n\n // Get the block node closest to the anchor and focus\n const anchorNodeEntry = Editor.above(editor, {\n at: editor.selection.anchor,\n match: (node) => !Editor.isEditor(node) && node.type !== 'text',\n });\n const focusNodeEntry = Editor.above(editor, {\n at: editor.selection.focus,\n match: (node) => !Editor.isEditor(node) && node.type !== 'text',\n });\n\n if (!anchorNodeEntry || !focusNodeEntry) {\n return false;\n }\n\n // Disabled if the anchor and focus are not in the same block\n return anchorNodeEntry[0] !== focusNodeEntry[0];\n };\n\n const toggleList = (format: Block<'list'>['format']) => {\n let currentListEntry;\n if (editor.selection) {\n currentListEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n });\n } else {\n // If no selection, toggle last inserted node\n const [_, lastNodePath] = Editor.last(editor, []);\n currentListEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n at: lastNodePath,\n });\n }\n\n if (!currentListEntry) {\n // If selection is not a list then convert it to list\n blocks[`list-${format}`]?.handleConvert!(editor);\n return;\n }\n\n // If selection is already a list then toggle format\n const [currentList, currentListPath] = currentListEntry;\n\n if (!Editor.isEditor(currentList) && isListNode(currentList)) {\n if (currentList.format !== format) {\n // Format is different, toggle list format\n Transforms.setNodes(editor, { format }, { at: currentListPath });\n } else {\n // Format is same, convert selected list-item to paragraph\n blocks['paragraph']?.handleConvert!(editor);\n }\n }\n };\n\n if (location === 'menu') {\n const Icon = block.icon;\n\n return (\n <StyledMenuItem\n startIcon={Icon && <Icon />}\n onSelect={() => toggleList(format)}\n isActive={isListActive()}\n disabled={isListDisabled()}\n >\n {formatMessage(block.label)}\n </StyledMenuItem>\n );\n }\n\n return (\n <ToolbarButton\n icon={block.icon}\n name={format}\n label={block.label}\n isActive={isListActive()}\n disabled={isListDisabled()}\n handleClick={() => toggleList(format)}\n />\n );\n};\n\nconst LinkButton = ({\n disabled,\n location = 'toolbar',\n}: {\n disabled: boolean;\n location?: 'toolbar' | 'menu';\n}) => {\n const { editor } = useBlocksEditorContext('LinkButton');\n const { formatMessage } = useIntl();\n\n const isLinkActive = () => {\n const { selection } = editor;\n\n if (!selection) return false;\n\n const [match] = Array.from(\n Editor.nodes(editor, {\n at: Editor.unhangRange(editor, selection),\n match: (node) => SlateElement.isElement(node) && node.type === 'link',\n })\n );\n\n return Boolean(match);\n };\n\n const isLinkDisabled = () => {\n // Always disabled when the whole editor is disabled\n if (disabled) {\n return true;\n }\n\n // Always enabled when there's no selection\n if (!editor.selection) {\n return false;\n }\n\n // Get the block node closest to the anchor and focus\n const anchorNodeEntry = Editor.above(editor, {\n at: editor.selection.anchor,\n match: (node) => !Editor.isEditor(node) && node.type !== 'text',\n });\n const focusNodeEntry = Editor.above(editor, {\n at: editor.selection.focus,\n match: (node) => !Editor.isEditor(node) && node.type !== 'text',\n });\n\n if (!anchorNodeEntry || !focusNodeEntry) {\n return false;\n }\n\n // Disabled if the anchor and focus are not in the same block\n return anchorNodeEntry[0] !== focusNodeEntry[0];\n };\n\n const addLink = () => {\n editor.shouldSaveLinkPath = true;\n // We insert an empty anchor, so we split the DOM to have a element we can use as reference for the popover\n insertLink(editor, { url: '' });\n };\n\n const label = {\n id: 'components.Blocks.link',\n defaultMessage: 'Link',\n } as MessageDescriptor;\n\n if (location === 'menu') {\n return (\n <StyledMenuItem\n startIcon={<Link />}\n onSelect={addLink}\n isActive={isLinkActive()}\n disabled={isLinkDisabled()}\n >\n {formatMessage(label)}\n </StyledMenuItem>\n );\n }\n\n return (\n <ToolbarButton\n icon={Link}\n name=\"link\"\n label={label}\n isActive={isLinkActive()}\n handleClick={addLink}\n disabled={isLinkDisabled()}\n />\n );\n};\n\nconst StyledMenuItem = styled(Menu.Item)<{ isActive: boolean }>`\n ${(props) =>\n props.isActive &&\n css`\n color: ${({ theme }) => theme.colors.primary600};\n font-weight: 600;\n `}\n\n svg {\n fill: ${({ theme, isActive }) =>\n isActive ? theme.colors.primary600 : theme.colors.neutral500};\n }\n`;\n\nconst ReorderToolbarButtons = () => {\n const { editor, disabled, blocks, name, setLiveText } =\n useBlocksEditorContext('ReorderToolbarButtons');\n const { formatMessage } = useIntl();\n\n const selection = editor.selection;\n const totalBlocks = editor.children.length;\n\n const anchorIndex = selection ? selection.anchor.path[0] : null;\n const focusIndex = selection ? selection.focus.path[0] : null;\n const isSingleBlockSelection =\n anchorIndex !== null && focusIndex !== null && anchorIndex === focusIndex;\n\n const selectedTopLevelNode =\n isSingleBlockSelection && anchorIndex !== null ? editor.children[anchorIndex] : null;\n const selectedBlock =\n selectedTopLevelNode &&\n Object.values(blocks).find((block) => block.matchNode(selectedTopLevelNode));\n\n const isSelectedBlockDraggable =\n selectedTopLevelNode && selectedBlock\n ? (selectedBlock.isDraggable?.(selectedTopLevelNode) ?? true)\n : false;\n\n const canMoveUp =\n !disabled &&\n isSingleBlockSelection &&\n isSelectedBlockDraggable &&\n anchorIndex !== null &&\n anchorIndex > 0;\n const canMoveDown =\n !disabled &&\n isSingleBlockSelection &&\n isSelectedBlockDraggable &&\n anchorIndex !== null &&\n anchorIndex < totalBlocks - 1;\n\n const moveBlock = (direction: 'up' | 'down') => {\n if (!selection || anchorIndex === null) return;\n\n const currentIndex = [anchorIndex];\n const newIndex = [direction === 'up' ? anchorIndex - 1 : anchorIndex + 1];\n\n Transforms.moveNodes(editor, {\n at: currentIndex,\n to: newIndex,\n });\n\n // Keep the moved block focused so disabled states update immediately.\n Transforms.select(editor, Editor.start(editor, newIndex));\n ReactEditor.focus(editor);\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('components.Blocks.dnd.reorder'),\n defaultMessage: '{item}, moved. New position in the editor: {position}.',\n },\n {\n item: `${name}.${currentIndex[0] + 1}`,\n position: `${newIndex[0] + 1} of ${editor.children.length}`,\n }\n )\n );\n };\n\n return (\n <Flex direction=\"row\" gap={1}>\n <Tooltip\n label={formatMessage({\n id: getTranslation('components.DynamicZone.move-up'),\n defaultMessage: 'Move up',\n })}\n >\n <Toolbar.Button\n onPointerDown={(e) => {\n e.preventDefault();\n if (canMoveUp) moveBlock('up');\n }}\n aria-disabled={!canMoveUp}\n disabled={!canMoveUp}\n aria-label={formatMessage({\n id: getTranslation('components.DynamicZone.move-up'),\n defaultMessage: 'Move up',\n })}\n asChild\n >\n <FlexButton\n tag=\"button\"\n alignItems=\"center\"\n justifyContent=\"center\"\n width={7}\n height={7}\n hasRadius\n type=\"button\"\n >\n <ArrowUp fill={!canMoveUp ? 'neutral300' : 'neutral600'} />\n </FlexButton>\n </Toolbar.Button>\n </Tooltip>\n\n <Tooltip\n label={formatMessage({\n id: getTranslation('components.DynamicZone.move-down'),\n defaultMessage: 'Move down',\n })}\n >\n <Toolbar.Button\n onPointerDown={(e) => {\n e.preventDefault();\n if (canMoveDown) moveBlock('down');\n }}\n aria-disabled={!canMoveDown}\n disabled={!canMoveDown}\n aria-label={formatMessage({\n id: getTranslation('components.DynamicZone.move-down'),\n defaultMessage: 'Move down',\n })}\n asChild\n >\n <FlexButton\n tag=\"button\"\n alignItems=\"center\"\n justifyContent=\"center\"\n width={7}\n height={7}\n hasRadius\n type=\"button\"\n >\n <ArrowDown fill={!canMoveDown ? 'neutral300' : 'neutral600'} />\n </FlexButton>\n </Toolbar.Button>\n </Tooltip>\n </Flex>\n );\n};\n\nconst BlocksToolbar = () => {\n const { editor, blocks, modifiers, disabled } = useBlocksEditorContext('BlocksToolbar');\n const { formatMessage } = useIntl();\n const isMobile = useIsMobile();\n\n /**\n * The modifier buttons are disabled when an image is selected.\n */\n const checkButtonDisabled = () => {\n // Always disabled when the whole editor is disabled\n if (disabled) {\n return true;\n }\n\n if (!editor.selection) {\n return false;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n if (!selectedNode) return true;\n\n if (['image', 'code'].includes(selectedNode.type)) {\n return true;\n }\n\n return false;\n };\n\n const isButtonDisabled = checkButtonDisabled();\n\n /**\n * Observed components are ones that may or may not be visible in the toolbar, depending on the\n * available space. They provide two render props:\n * - renderInToolbar: for when we try to render the component in the toolbar (may be hidden)\n * - renderInMenu: for when the component didn't fit in the toolbar and is relegated\n * to the \"more\" menu\n */\n const observedComponents: ObservedComponent[] = [\n ...Object.entries(modifiers).map(([name, modifier]) => {\n const Icon = modifier.icon;\n const isActive = modifier.checkIsActive(editor);\n const handleSelect = () => modifier.handleToggle(editor);\n\n return {\n toolbar: (\n <ToolbarButton\n key={name}\n name={name}\n icon={modifier.icon}\n label={modifier.label}\n isActive={modifier.checkIsActive(editor)}\n handleClick={handleSelect}\n disabled={isButtonDisabled}\n />\n ),\n menu: (\n <StyledMenuItem startIcon={<Icon />} onSelect={handleSelect} isActive={isActive}>\n {formatMessage(modifier.label)}\n </StyledMenuItem>\n ),\n key: `modifier.${name}`,\n };\n }),\n {\n toolbar: <LinkButton disabled={isButtonDisabled} location=\"toolbar\" />,\n menu: <LinkButton disabled={isButtonDisabled} location=\"menu\" />,\n key: 'block.link',\n },\n {\n // List buttons can only be rendered together when in the toolbar\n toolbar: (\n <Flex direction=\"row\">\n <ToolbarSeparator style={{ marginLeft: '0.4rem' }} />\n <Toolbar.ToggleGroup type=\"single\" asChild>\n <Flex gap={1}>\n <ListButton block={blocks['list-unordered']!} format=\"unordered\" location=\"toolbar\" />\n <ListButton block={blocks['list-ordered']!} format=\"ordered\" location=\"toolbar\" />\n </Flex>\n </Toolbar.ToggleGroup>\n </Flex>\n ),\n menu: (\n <>\n <Menu.Separator />\n <ListButton block={blocks['list-unordered']!} format=\"unordered\" location=\"menu\" />\n <ListButton block={blocks['list-ordered']!} format=\"ordered\" location=\"menu\" />\n </>\n ),\n key: 'block.list',\n },\n ];\n\n return (\n <Toolbar.Root aria-disabled={disabled} asChild>\n <ToolbarWrapper padding={{ initial: 1, medium: 2 }} width=\"100%\">\n <BlocksDropdown />\n {isMobile && (\n <>\n <ToolbarSeparator />\n <ReorderToolbarButtons />\n </>\n )}\n <ToolbarSeparator />\n <Toolbar.ToggleGroup type=\"multiple\" asChild>\n <Flex direction=\"row\" gap={1} grow={1} overflow=\"hidden\">\n <EditorToolbarObserver observedComponents={observedComponents} />\n </Flex>\n </Toolbar.ToggleGroup>\n </ToolbarWrapper>\n </Toolbar.Root>\n );\n};\n\nexport { BlocksToolbar, useConversionModal };\n"],"names":["ToolbarWrapper","styled","Flex","theme","colors","neutral150","ToolbarSeparator","Toolbar","Separator","spaces","breakpoints","medium","FlexButton","primary100","SelectWrapper","Box","neutral600","useConversionModal","modalElement","setModalComponent","React","useState","handleConversionResult","renderModal","cloneElement","key","Date","now","ToolbarButton","icon","Icon","name","label","isActive","disabled","handleClick","editor","useBlocksEditorContext","formatMessage","useIntl","labelMessage","enabledColor","_jsx","Tooltip","ToggleItem","value","data-state","onPointerDown","e","preventDefault","ReactEditor","focus","aria-disabled","aria-label","asChild","tag","background","alignItems","justifyContent","width","height","hasRadius","type","fill","BlocksDropdown","blocks","isMobile","useIsMobile","blockKeysToInclude","getEntries","reduce","currentKeys","block","isInBlocksSelector","blockSelected","setBlockSelected","handleSelect","optionKey","editorIsEmpty","children","length","Editor","isEmpty","selection","lastPath","last","Transforms","select","range","start","currentListEntry","above","match","node","isEditor","includes","currentList","currentListPath","format","isListNode","setNodes","at","maybeRenderModal","handleConvert","preventSelectFocus","useEffect","selectedNode","anchor","anchorNode","parent","edge","depth","anchorBlockKey","getKeys","find","blockKey","matchNode","selectedBlock","_jsxs","_Fragment","SingleSelect","startIcon","onChange","customizeContent","onCloseAutoFocus","id","defaultMessage","map","selectorBlock","BlockOption","isSelected","SingleSelectOption","Node","isNode","ListButton","location","isListActive","isListDisabled","anchorNodeEntry","focusNodeEntry","toggleList","_","lastNodePath","StyledMenuItem","onSelect","LinkButton","isLinkActive","Array","from","nodes","unhangRange","SlateElement","isElement","Boolean","isLinkDisabled","addLink","shouldSaveLinkPath","insertLink","url","Link","Menu","Item","props","css","primary600","neutral500","ReorderToolbarButtons","setLiveText","totalBlocks","anchorIndex","path","focusIndex","isSingleBlockSelection","selectedTopLevelNode","Object","values","isSelectedBlockDraggable","isDraggable","canMoveUp","canMoveDown","moveBlock","direction","currentIndex","newIndex","moveNodes","to","getTranslation","item","position","gap","Button","ArrowUp","ArrowDown","BlocksToolbar","modifiers","checkButtonDisabled","isButtonDisabled","observedComponents","entries","modifier","checkIsActive","handleToggle","toolbar","menu","style","marginLeft","ToggleGroup","Root","padding","initial","grow","overflow","EditorToolbarObserver"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAMA,cAAAA,GAAiBC,uBAAAA,CAAsBC,iBAAAA,CAAK;;;gBAGlC,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA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AAA,EAAoBA;;;;;;;AAMvD;;;;;"}
1
+ {"version":3,"file":"BlocksToolbar.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport * as Toolbar from '@radix-ui/react-toolbar';\nimport { useIsMobile } from '@strapi/admin/strapi-admin';\nimport {\n Flex,\n Tooltip,\n SingleSelect,\n SingleSelectOption,\n Box,\n FlexComponent,\n BoxComponent,\n Menu,\n} from '@strapi/design-system';\nimport { Link, ArrowUp, ArrowDown } from '@strapi/icons';\nimport { MessageDescriptor, useIntl } from 'react-intl';\nimport { Editor, Transforms, Element as SlateElement, Node, type Ancestor } from 'slate';\nimport { ReactEditor } from 'slate-react';\nimport { css, styled } from 'styled-components';\n\nimport { getTranslation } from '../../../../../utils/translations';\nimport { EditorToolbarObserver, type ObservedComponent } from '../../EditorToolbarObserver';\n\nimport { insertLink } from './Blocks/Link';\nimport { type BlocksStore, type SelectorBlock, useBlocksEditorContext } from './BlocksEditor';\nimport { type Block, getEntries, getKeys } from './utils/types';\n\nconst ToolbarWrapper = styled<FlexComponent>(Flex)`\n &[aria-disabled='true'] {\n cursor: not-allowed;\n background: ${({ theme }) => theme.colors.neutral150};\n }\n`;\n\nconst ToolbarSeparator = styled(Toolbar.Separator)`\n background: ${({ theme }) => theme.colors.neutral150};\n width: 1px;\n height: 2.4rem;\n margin-left: ${({ theme }) => theme.spaces[1]};\n margin-right: ${({ theme }) => theme.spaces[1]};\n\n ${({ theme }) => theme.breakpoints.medium} {\n margin-left: ${({ theme }) => theme.spaces[2]};\n margin-right: ${({ theme }) => theme.spaces[2]};\n }\n`;\n\nconst FlexButton = styled<FlexComponent<'button'>>(Flex)`\n // Inherit the not-allowed cursor from ToolbarWrapper when disabled\n &[aria-disabled] {\n cursor: not-allowed;\n }\n\n &[aria-disabled='false'] {\n cursor: pointer;\n\n // Only apply hover styles if the button is enabled on desktop\n ${({ theme }) => theme.breakpoints.medium} {\n &:hover {\n background: ${({ theme }) => theme.colors.primary100};\n }\n }\n }\n`;\n\nconst SelectWrapper = styled<BoxComponent>(Box)`\n // Styling changes to SingleSelect component don't work, so adding wrapper to target SingleSelect\n div[role='combobox'] {\n border: none;\n cursor: pointer;\n min-height: unset;\n padding-top: ${({ theme }) => theme.spaces[2]};\n padding-bottom: ${({ theme }) => theme.spaces[2]};\n padding-left: ${({ theme }) => theme.spaces[4]};\n padding-right: ${({ theme }) => theme.spaces[4]};\n gap: ${({ theme }) => theme.spaces[2]};\n \n ${({ theme }) => theme.breakpoints.medium} {\n padding-top: ${({ theme }) => theme.spaces[1]};\n padding-bottom: ${({ theme }) => theme.spaces[1]};\n gap: ${({ theme }) => theme.spaces[4]};\n }\n\n &[aria-disabled='false']:hover {\n cursor: pointer;\n background: ${({ theme }) => theme.colors.primary100};\n }\n\n &[aria-disabled] {\n background: transparent;\n cursor: inherit;\n\n // Select text and icons should also have disabled color\n span {\n color: ${({ theme }) => theme.colors.neutral600};\n }\n }\n\n & > span:first-child {\n gap: ${({ theme }) => theme.spaces[0]};\n\n ${({ theme }) => theme.breakpoints.medium} {\n gap: ${({ theme }) => theme.spaces[3]};\n }\n }\n`;\n\n/**\n * Handles the modal component that may be returned by a block when converting it\n */\nfunction useConversionModal() {\n const [modalElement, setModalComponent] = React.useState<React.JSX.Element | null>(null);\n\n const handleConversionResult = (renderModal: void | (() => React.JSX.Element) | undefined) => {\n // Not all blocks return a modal\n if (renderModal) {\n // Use cloneElement to apply a key because to create a new instance of the component\n // Without the new key, the state is kept from previous times that option was picked\n setModalComponent(React.cloneElement(renderModal(), { key: Date.now() }));\n }\n };\n\n return { modalElement, handleConversionResult };\n}\n\ninterface ToolbarButtonProps {\n icon?: React.ComponentType<React.SVGProps<SVGSVGElement>>;\n name: string;\n label: MessageDescriptor;\n isActive: boolean;\n disabled: boolean;\n handleClick: () => void;\n}\n\nconst ToolbarButton = ({\n icon: Icon,\n name,\n label,\n isActive,\n disabled,\n handleClick,\n}: ToolbarButtonProps) => {\n const { editor } = useBlocksEditorContext('ToolbarButton');\n const { formatMessage } = useIntl();\n const labelMessage = formatMessage(label);\n\n const enabledColor = isActive ? 'primary600' : 'neutral600';\n\n return (\n <Tooltip label={labelMessage}>\n <Toolbar.ToggleItem\n value={name}\n data-state={isActive ? 'on' : 'off'}\n onPointerDown={(e) => {\n e.preventDefault();\n handleClick();\n ReactEditor.focus(editor);\n }}\n aria-disabled={disabled}\n disabled={disabled}\n aria-label={labelMessage}\n asChild\n >\n <FlexButton\n tag=\"button\"\n background={isActive ? 'primary100' : ''}\n alignItems=\"center\"\n justifyContent=\"center\"\n width={7}\n height={7}\n hasRadius\n type=\"button\"\n >\n {Icon && <Icon fill={disabled ? 'neutral300' : enabledColor} />}\n </FlexButton>\n </Toolbar.ToggleItem>\n </Tooltip>\n );\n};\n\nconst BlocksDropdown = () => {\n const { editor, blocks, disabled } = useBlocksEditorContext('BlocksDropdown');\n const { formatMessage } = useIntl();\n const { modalElement, handleConversionResult } = useConversionModal();\n const isMobile = useIsMobile();\n\n const blockKeysToInclude: string[] = getEntries(blocks).reduce<string[]>(\n (currentKeys, [key, block]) => {\n return block?.isInBlocksSelector ? [...currentKeys, key] : currentKeys;\n },\n []\n );\n\n const [blockSelected, setBlockSelected] = React.useState<string>('paragraph');\n\n const handleSelect = (optionKey: unknown) => {\n if (typeof optionKey !== 'string' || !blocks[optionKey]) {\n return;\n }\n\n const editorIsEmpty =\n editor.children.length === 1 && Editor.isEmpty(editor, editor.children[0]);\n\n if (!editor.selection && !editorIsEmpty) {\n // Toolbar buttons steal focus in Playwright (and sometimes in real browsers), clearing\n // selection. Convert the last existing block — do not insert a new empty block, which\n // would leave the user's content behind and convert a blank node instead.\n const [, lastPath] = Editor.last(editor, []);\n Transforms.select(editor, Editor.range(editor, lastPath));\n } else if (!editor.selection && editorIsEmpty) {\n // When there is no selection and the editor is empty,\n // select the empty paragraph from Slate's initialValue so it gets converted\n Transforms.select(editor, Editor.start(editor, [0, 0]));\n }\n\n // If selection is already a list block, toggle its format\n const currentListEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n });\n\n if (currentListEntry && ['list-ordered', 'list-unordered'].includes(optionKey)) {\n const [currentList, currentListPath] = currentListEntry;\n const format = optionKey === 'list-ordered' ? 'ordered' : 'unordered';\n\n if (!Editor.isEditor(currentList) && isListNode(currentList)) {\n // Format is different, toggle list format\n if (currentList.format !== format) {\n Transforms.setNodes(editor, { format }, { at: currentListPath });\n }\n }\n return;\n }\n\n // Let the block handle the Slate conversion logic\n const maybeRenderModal = blocks[optionKey]?.handleConvert?.(editor);\n handleConversionResult(maybeRenderModal);\n\n setBlockSelected(optionKey);\n\n ReactEditor.focus(editor);\n };\n\n /**\n * Prevent the select from focusing itself so ReactEditor.focus(editor) can focus the editor instead.\n *\n * The editor first loses focus to a blur event when clicking the select button. However,\n * refocusing the editor is not enough since the select's default behavior is to refocus itself\n * after an option is selected.\n *\n */\n const preventSelectFocus = (e: Event) => e.preventDefault();\n\n // Listen to the selection change and update the selected block in the dropdown\n React.useEffect(() => {\n if (editor.selection) {\n let selectedNode: Ancestor;\n\n // If selection anchor is a list-item, get its parent\n const currentListEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n at: editor.selection.anchor,\n });\n\n if (currentListEntry) {\n const [currentList] = currentListEntry;\n selectedNode = currentList;\n } else {\n // Get the parent node of the anchor other than list-item\n const [anchorNode] = Editor.parent(editor, editor.selection.anchor, {\n edge: 'start',\n depth: 2,\n });\n\n // @ts-expect-error slate's delete behaviour creates an exceptional type\n if (anchorNode.type === 'list-item') {\n // When the last node in the selection is a list item,\n // slate's default delete operation leaves an empty list-item instead of converting it into a paragraph.\n // Issue: https://github.com/ianstormtaylor/slate/issues/2500\n\n Transforms.setNodes(editor, { type: 'paragraph' });\n // @ts-expect-error convert explicitly type to paragraph\n selectedNode = { ...anchorNode, type: 'paragraph' };\n } else {\n selectedNode = anchorNode;\n }\n }\n\n // Find the block key that matches the anchor node\n const anchorBlockKey = getKeys(blocks).find(\n (blockKey) => !Editor.isEditor(selectedNode) && blocks[blockKey]?.matchNode(selectedNode)\n );\n\n // Change the value selected in the dropdown if it doesn't match the anchor block key\n if (anchorBlockKey && anchorBlockKey !== blockSelected) {\n setBlockSelected(anchorBlockKey);\n }\n }\n }, [editor.selection, editor, blocks, blockSelected]);\n\n React.useEffect(() => {\n // If the selected block is not in the list of blocks to include, change the selected block to the first one\n if (blockKeysToInclude.length > 0 && !blockKeysToInclude.includes(blockSelected)) {\n setBlockSelected(blockKeysToInclude[0]);\n }\n }, [blockKeysToInclude, blockSelected]);\n\n if (!blocks[blockSelected]) {\n return null;\n }\n\n const selectedBlock = blocks[blockSelected] as SelectorBlock;\n const Icon = selectedBlock.icon;\n\n return (\n <>\n <SelectWrapper>\n <SingleSelect\n startIcon={Icon && <Icon />}\n onChange={handleSelect}\n customizeContent={() => (isMobile ? '' : formatMessage(selectedBlock.label))}\n value={blockSelected}\n onCloseAutoFocus={preventSelectFocus}\n aria-label={formatMessage({\n id: 'components.Blocks.blocks.selectBlock',\n defaultMessage: 'Select a block',\n })}\n disabled={disabled}\n >\n {blockKeysToInclude.map((key) => {\n const selectorBlock = blocks[key] as SelectorBlock;\n return (\n <BlockOption\n key={key}\n value={key}\n label={selectorBlock.label}\n icon={selectorBlock.icon}\n blockSelected={blockSelected}\n />\n );\n })}\n </SingleSelect>\n </SelectWrapper>\n {modalElement}\n </>\n );\n};\n\ninterface BlockOptionProps {\n value: string;\n icon?: React.ComponentType<React.SVGProps<SVGElement>>;\n label: MessageDescriptor;\n blockSelected: string;\n}\n\nconst BlockOption = ({ value, icon: Icon, label, blockSelected }: BlockOptionProps) => {\n const { formatMessage } = useIntl();\n\n const isSelected = value === blockSelected;\n\n return (\n <SingleSelectOption\n startIcon={Icon && <Icon fill={isSelected ? 'primary600' : 'neutral500'} />}\n value={value}\n >\n {formatMessage(label)}\n </SingleSelectOption>\n );\n};\n\nconst isListNode = (node: unknown): node is Block<'list'> => {\n return Node.isNode(node) && !Editor.isEditor(node) && node.type === 'list';\n};\n\ninterface ListButtonProps {\n block: BlocksStore['list-ordered'] | BlocksStore['list-unordered'];\n format: Block<'list'>['format'];\n location?: 'toolbar' | 'menu';\n}\n\nconst ListButton = ({ block, format, location = 'toolbar' }: ListButtonProps) => {\n const { formatMessage } = useIntl();\n const { editor, disabled, blocks } = useBlocksEditorContext('ListButton');\n\n const isListActive = () => {\n if (!editor.selection) return false;\n\n // Get the parent list at selection anchor node\n const currentListEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n at: editor.selection.anchor,\n });\n\n if (currentListEntry) {\n const [currentList] = currentListEntry;\n if (!Editor.isEditor(currentList) && isListNode(currentList) && currentList.format === format)\n return true;\n }\n\n return false;\n };\n\n /**\n * @TODO: Currently, applying list while multiple blocks are selected is not supported.\n * We should implement this feature in the future.\n */\n const isListDisabled = () => {\n // Always disabled when the whole editor is disabled\n if (disabled) {\n return true;\n }\n\n // Always enabled when there's no selection\n if (!editor.selection) {\n return false;\n }\n\n // Get the block node closest to the anchor and focus\n const anchorNodeEntry = Editor.above(editor, {\n at: editor.selection.anchor,\n match: (node) => !Editor.isEditor(node) && node.type !== 'text',\n });\n const focusNodeEntry = Editor.above(editor, {\n at: editor.selection.focus,\n match: (node) => !Editor.isEditor(node) && node.type !== 'text',\n });\n\n if (!anchorNodeEntry || !focusNodeEntry) {\n return false;\n }\n\n // Disabled if the anchor and focus are not in the same block\n return anchorNodeEntry[0] !== focusNodeEntry[0];\n };\n\n const toggleList = (format: Block<'list'>['format']) => {\n let currentListEntry;\n if (editor.selection) {\n currentListEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n });\n } else {\n // If no selection, toggle last inserted node\n const [_, lastNodePath] = Editor.last(editor, []);\n currentListEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n at: lastNodePath,\n });\n }\n\n if (!currentListEntry) {\n // If selection is not a list then convert it to list\n blocks[`list-${format}`]?.handleConvert!(editor);\n return;\n }\n\n // If selection is already a list then toggle format\n const [currentList, currentListPath] = currentListEntry;\n\n if (!Editor.isEditor(currentList) && isListNode(currentList)) {\n if (currentList.format !== format) {\n // Format is different, toggle list format\n Transforms.setNodes(editor, { format }, { at: currentListPath });\n } else {\n // Format is same, convert selected list-item to paragraph\n blocks['paragraph']?.handleConvert!(editor);\n }\n }\n };\n\n if (location === 'menu') {\n const Icon = block.icon;\n\n return (\n <StyledMenuItem\n startIcon={Icon && <Icon />}\n onSelect={() => toggleList(format)}\n isActive={isListActive()}\n disabled={isListDisabled()}\n >\n {formatMessage(block.label)}\n </StyledMenuItem>\n );\n }\n\n return (\n <ToolbarButton\n icon={block.icon}\n name={format}\n label={block.label}\n isActive={isListActive()}\n disabled={isListDisabled()}\n handleClick={() => toggleList(format)}\n />\n );\n};\n\nconst LinkButton = ({\n disabled,\n location = 'toolbar',\n}: {\n disabled: boolean;\n location?: 'toolbar' | 'menu';\n}) => {\n const { editor } = useBlocksEditorContext('LinkButton');\n const { formatMessage } = useIntl();\n\n const isLinkActive = () => {\n const { selection } = editor;\n\n if (!selection) return false;\n\n const [match] = Array.from(\n Editor.nodes(editor, {\n at: Editor.unhangRange(editor, selection),\n match: (node) => SlateElement.isElement(node) && node.type === 'link',\n })\n );\n\n return Boolean(match);\n };\n\n const isLinkDisabled = () => {\n // Always disabled when the whole editor is disabled\n if (disabled) {\n return true;\n }\n\n // Always enabled when there's no selection\n if (!editor.selection) {\n return false;\n }\n\n // Get the block node closest to the anchor and focus\n const anchorNodeEntry = Editor.above(editor, {\n at: editor.selection.anchor,\n match: (node) => !Editor.isEditor(node) && node.type !== 'text',\n });\n const focusNodeEntry = Editor.above(editor, {\n at: editor.selection.focus,\n match: (node) => !Editor.isEditor(node) && node.type !== 'text',\n });\n\n if (!anchorNodeEntry || !focusNodeEntry) {\n return false;\n }\n\n // Disabled if the anchor and focus are not in the same block\n return anchorNodeEntry[0] !== focusNodeEntry[0];\n };\n\n const addLink = () => {\n editor.shouldSaveLinkPath = true;\n // We insert an empty anchor, so we split the DOM to have a element we can use as reference for the popover\n insertLink(editor, { url: '' });\n };\n\n const label = {\n id: 'components.Blocks.link',\n defaultMessage: 'Link',\n } as MessageDescriptor;\n\n if (location === 'menu') {\n return (\n <StyledMenuItem\n startIcon={<Link />}\n onSelect={addLink}\n isActive={isLinkActive()}\n disabled={isLinkDisabled()}\n >\n {formatMessage(label)}\n </StyledMenuItem>\n );\n }\n\n return (\n <ToolbarButton\n icon={Link}\n name=\"link\"\n label={label}\n isActive={isLinkActive()}\n handleClick={addLink}\n disabled={isLinkDisabled()}\n />\n );\n};\n\nconst StyledMenuItem = styled(Menu.Item)<{ isActive: boolean }>`\n ${(props) =>\n props.isActive &&\n css`\n color: ${({ theme }) => theme.colors.primary600};\n font-weight: 600;\n `}\n\n svg {\n fill: ${({ theme, isActive }) =>\n isActive ? theme.colors.primary600 : theme.colors.neutral500};\n }\n`;\n\nconst ReorderToolbarButtons = () => {\n const { editor, disabled, blocks, name, setLiveText } =\n useBlocksEditorContext('ReorderToolbarButtons');\n const { formatMessage } = useIntl();\n\n const selection = editor.selection;\n const totalBlocks = editor.children.length;\n\n const anchorIndex = selection ? selection.anchor.path[0] : null;\n const focusIndex = selection ? selection.focus.path[0] : null;\n const isSingleBlockSelection =\n anchorIndex !== null && focusIndex !== null && anchorIndex === focusIndex;\n\n const selectedTopLevelNode =\n isSingleBlockSelection && anchorIndex !== null ? editor.children[anchorIndex] : null;\n const selectedBlock =\n selectedTopLevelNode &&\n Object.values(blocks).find((block) => block.matchNode(selectedTopLevelNode));\n\n const isSelectedBlockDraggable =\n selectedTopLevelNode && selectedBlock\n ? (selectedBlock.isDraggable?.(selectedTopLevelNode) ?? true)\n : false;\n\n const canMoveUp =\n !disabled &&\n isSingleBlockSelection &&\n isSelectedBlockDraggable &&\n anchorIndex !== null &&\n anchorIndex > 0;\n const canMoveDown =\n !disabled &&\n isSingleBlockSelection &&\n isSelectedBlockDraggable &&\n anchorIndex !== null &&\n anchorIndex < totalBlocks - 1;\n\n const moveBlock = (direction: 'up' | 'down') => {\n if (!selection || anchorIndex === null) return;\n\n const currentIndex = [anchorIndex];\n const newIndex = [direction === 'up' ? anchorIndex - 1 : anchorIndex + 1];\n\n Transforms.moveNodes(editor, {\n at: currentIndex,\n to: newIndex,\n });\n\n // Keep the moved block focused so disabled states update immediately.\n Transforms.select(editor, Editor.start(editor, newIndex));\n ReactEditor.focus(editor);\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('components.Blocks.dnd.reorder'),\n defaultMessage: '{item}, moved. New position in the editor: {position}.',\n },\n {\n item: `${name}.${currentIndex[0] + 1}`,\n position: `${newIndex[0] + 1} of ${editor.children.length}`,\n }\n )\n );\n };\n\n return (\n <Flex direction=\"row\" gap={1}>\n <Tooltip\n label={formatMessage({\n id: getTranslation('components.DynamicZone.move-up'),\n defaultMessage: 'Move up',\n })}\n >\n <Toolbar.Button\n onPointerDown={(e) => {\n e.preventDefault();\n if (canMoveUp) moveBlock('up');\n }}\n aria-disabled={!canMoveUp}\n disabled={!canMoveUp}\n aria-label={formatMessage({\n id: getTranslation('components.DynamicZone.move-up'),\n defaultMessage: 'Move up',\n })}\n asChild\n >\n <FlexButton\n tag=\"button\"\n alignItems=\"center\"\n justifyContent=\"center\"\n width={7}\n height={7}\n hasRadius\n type=\"button\"\n >\n <ArrowUp fill={!canMoveUp ? 'neutral300' : 'neutral600'} />\n </FlexButton>\n </Toolbar.Button>\n </Tooltip>\n\n <Tooltip\n label={formatMessage({\n id: getTranslation('components.DynamicZone.move-down'),\n defaultMessage: 'Move down',\n })}\n >\n <Toolbar.Button\n onPointerDown={(e) => {\n e.preventDefault();\n if (canMoveDown) moveBlock('down');\n }}\n aria-disabled={!canMoveDown}\n disabled={!canMoveDown}\n aria-label={formatMessage({\n id: getTranslation('components.DynamicZone.move-down'),\n defaultMessage: 'Move down',\n })}\n asChild\n >\n <FlexButton\n tag=\"button\"\n alignItems=\"center\"\n justifyContent=\"center\"\n width={7}\n height={7}\n hasRadius\n type=\"button\"\n >\n <ArrowDown fill={!canMoveDown ? 'neutral300' : 'neutral600'} />\n </FlexButton>\n </Toolbar.Button>\n </Tooltip>\n </Flex>\n );\n};\n\nconst BlocksToolbar = () => {\n const { editor, blocks, modifiers, disabled } = useBlocksEditorContext('BlocksToolbar');\n const { formatMessage } = useIntl();\n const isMobile = useIsMobile();\n const toolbarContainerRef = React.useRef<HTMLElement>(null);\n\n /**\n * The modifier buttons are disabled when an image is selected.\n */\n const checkButtonDisabled = () => {\n // Always disabled when the whole editor is disabled\n if (disabled) {\n return true;\n }\n\n if (!editor.selection) {\n return false;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n if (!selectedNode) return true;\n\n if (['image', 'code'].includes(selectedNode.type)) {\n return true;\n }\n\n return false;\n };\n\n const isButtonDisabled = checkButtonDisabled();\n\n /**\n * Observed components are ones that may or may not be visible in the toolbar, depending on the\n * available space. They provide two render props:\n * - renderInToolbar: for when we try to render the component in the toolbar (may be hidden)\n * - renderInMenu: for when the component didn't fit in the toolbar and is relegated\n * to the \"more\" menu\n */\n const observedComponents: ObservedComponent[] = [\n ...Object.entries(modifiers).map(([name, modifier]) => {\n const Icon = modifier.icon;\n const isActive = modifier.checkIsActive(editor);\n const handleSelect = () => modifier.handleToggle(editor);\n\n return {\n toolbar: (\n <ToolbarButton\n key={name}\n name={name}\n icon={modifier.icon}\n label={modifier.label}\n isActive={modifier.checkIsActive(editor)}\n handleClick={handleSelect}\n disabled={isButtonDisabled}\n />\n ),\n menu: (\n <StyledMenuItem startIcon={<Icon />} onSelect={handleSelect} isActive={isActive}>\n {formatMessage(modifier.label)}\n </StyledMenuItem>\n ),\n key: `modifier.${name}`,\n };\n }),\n {\n toolbar: <LinkButton disabled={isButtonDisabled} location=\"toolbar\" />,\n menu: <LinkButton disabled={isButtonDisabled} location=\"menu\" />,\n key: 'block.link',\n },\n {\n // List buttons can only be rendered together when in the toolbar\n toolbar: (\n <Flex direction=\"row\">\n <ToolbarSeparator style={{ marginLeft: '0.4rem' }} />\n <Toolbar.ToggleGroup type=\"single\" asChild>\n <Flex gap={1}>\n <ListButton block={blocks['list-unordered']!} format=\"unordered\" location=\"toolbar\" />\n <ListButton block={blocks['list-ordered']!} format=\"ordered\" location=\"toolbar\" />\n </Flex>\n </Toolbar.ToggleGroup>\n </Flex>\n ),\n menu: (\n <>\n <Menu.Separator />\n <ListButton block={blocks['list-unordered']!} format=\"unordered\" location=\"menu\" />\n <ListButton block={blocks['list-ordered']!} format=\"ordered\" location=\"menu\" />\n </>\n ),\n key: 'block.list',\n },\n ];\n\n return (\n <Toolbar.Root aria-disabled={disabled} asChild>\n <ToolbarWrapper padding={{ initial: 1, medium: 2 }} width=\"100%\">\n <BlocksDropdown />\n {isMobile && (\n <>\n <ToolbarSeparator />\n <ReorderToolbarButtons />\n </>\n )}\n <ToolbarSeparator />\n <Toolbar.ToggleGroup type=\"multiple\" asChild>\n <Flex ref={toolbarContainerRef} direction=\"row\" gap={1} grow={1} overflow=\"hidden\">\n <EditorToolbarObserver\n observedComponents={observedComponents}\n containerRef={toolbarContainerRef}\n />\n </Flex>\n </Toolbar.ToggleGroup>\n </ToolbarWrapper>\n </Toolbar.Root>\n );\n};\n\nexport { BlocksToolbar, useConversionModal };\n"],"names":["ToolbarWrapper","styled","Flex","theme","colors","neutral150","ToolbarSeparator","Toolbar","Separator","spaces","breakpoints","medium","FlexButton","primary100","SelectWrapper","Box","neutral600","useConversionModal","modalElement","setModalComponent","React","useState","handleConversionResult","renderModal","cloneElement","key","Date","now","ToolbarButton","icon","Icon","name","label","isActive","disabled","handleClick","editor","useBlocksEditorContext","formatMessage","useIntl","labelMessage","enabledColor","_jsx","Tooltip","ToggleItem","value","data-state","onPointerDown","e","preventDefault","ReactEditor","focus","aria-disabled","aria-label","asChild","tag","background","alignItems","justifyContent","width","height","hasRadius","type","fill","BlocksDropdown","blocks","isMobile","useIsMobile","blockKeysToInclude","getEntries","reduce","currentKeys","block","isInBlocksSelector","blockSelected","setBlockSelected","handleSelect","optionKey","editorIsEmpty","children","length","Editor","isEmpty","selection","lastPath","last","Transforms","select","range","start","currentListEntry","above","match","node","isEditor","includes","currentList","currentListPath","format","isListNode","setNodes","at","maybeRenderModal","handleConvert","preventSelectFocus","useEffect","selectedNode","anchor","anchorNode","parent","edge","depth","anchorBlockKey","getKeys","find","blockKey","matchNode","selectedBlock","_jsxs","_Fragment","SingleSelect","startIcon","onChange","customizeContent","onCloseAutoFocus","id","defaultMessage","map","selectorBlock","BlockOption","isSelected","SingleSelectOption","Node","isNode","ListButton","location","isListActive","isListDisabled","anchorNodeEntry","focusNodeEntry","toggleList","_","lastNodePath","StyledMenuItem","onSelect","LinkButton","isLinkActive","Array","from","nodes","unhangRange","SlateElement","isElement","Boolean","isLinkDisabled","addLink","shouldSaveLinkPath","insertLink","url","Link","Menu","Item","props","css","primary600","neutral500","ReorderToolbarButtons","setLiveText","totalBlocks","anchorIndex","path","focusIndex","isSingleBlockSelection","selectedTopLevelNode","Object","values","isSelectedBlockDraggable","isDraggable","canMoveUp","canMoveDown","moveBlock","direction","currentIndex","newIndex","moveNodes","to","getTranslation","item","position","gap","Button","ArrowUp","ArrowDown","BlocksToolbar","modifiers","toolbarContainerRef","useRef","checkButtonDisabled","isButtonDisabled","observedComponents","entries","modifier","checkIsActive","handleToggle","toolbar","menu","style","marginLeft","ToggleGroup","Root","padding","initial","ref","grow","overflow","EditorToolbarObserver","containerRef"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,MAAMA,cAAAA,GAAiBC,uBAAAA,CAAsBC,iBAAAA,CAAK;;;gBAGlC,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAACC,UAAU,CAAC;;AAEzD,CAAC;AAED,MAAMC,gBAAAA,GAAmBL,uB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AAA,EAAAA;4BACChB,kBAAAA,EAAoBA,kBAAAA;4BACpBiB,YAAAA,EAAcrB;;;;;;;AAO5B;;;;;"}
@@ -597,6 +597,7 @@ const BlocksToolbar = ()=>{
597
597
  const { editor, blocks, modifiers, disabled } = useBlocksEditorContext('BlocksToolbar');
598
598
  const { formatMessage } = useIntl();
599
599
  const isMobile = useIsMobile();
600
+ const toolbarContainerRef = React.useRef(null);
600
601
  /**
601
602
  * The modifier buttons are disabled when an image is selected.
602
603
  */ const checkButtonDisabled = ()=>{
@@ -729,12 +730,14 @@ const BlocksToolbar = ()=>{
729
730
  type: "multiple",
730
731
  asChild: true,
731
732
  children: /*#__PURE__*/ jsx(Flex, {
733
+ ref: toolbarContainerRef,
732
734
  direction: "row",
733
735
  gap: 1,
734
736
  grow: 1,
735
737
  overflow: "hidden",
736
738
  children: /*#__PURE__*/ jsx(EditorToolbarObserver, {
737
- observedComponents: observedComponents
739
+ observedComponents: observedComponents,
740
+ containerRef: toolbarContainerRef
738
741
  })
739
742
  })
740
743
  })