@strapi/content-manager 5.53.0 → 5.55.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.
- package/dist/admin/components/ActionsDrawer.js +17 -6
- package/dist/admin/components/ActionsDrawer.js.map +1 -1
- package/dist/admin/components/ActionsDrawer.mjs +19 -8
- package/dist/admin/components/ActionsDrawer.mjs.map +1 -1
- package/dist/admin/components/LeftMenu.js +131 -52
- package/dist/admin/components/LeftMenu.js.map +1 -1
- package/dist/admin/components/LeftMenu.mjs +133 -54
- package/dist/admin/components/LeftMenu.mjs.map +1 -1
- package/dist/admin/history/components/VersionsList.js +37 -43
- package/dist/admin/history/components/VersionsList.js.map +1 -1
- package/dist/admin/history/components/VersionsList.mjs +37 -43
- package/dist/admin/history/components/VersionsList.mjs.map +1 -1
- package/dist/admin/hooks/useContentManagerInitData.js +3 -2
- package/dist/admin/hooks/useContentManagerInitData.js.map +1 -1
- package/dist/admin/hooks/useContentManagerInitData.mjs +3 -2
- package/dist/admin/hooks/useContentManagerInitData.mjs.map +1 -1
- package/dist/admin/hooks/useDocumentActions.js +3 -1
- package/dist/admin/hooks/useDocumentActions.js.map +1 -1
- package/dist/admin/hooks/useDocumentActions.mjs +4 -2
- package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
- package/dist/admin/layout.js +2 -4
- package/dist/admin/layout.js.map +1 -1
- package/dist/admin/layout.mjs +2 -4
- package/dist/admin/layout.mjs.map +1 -1
- package/dist/admin/modules/app.js +3 -1
- package/dist/admin/modules/app.js.map +1 -1
- package/dist/admin/modules/app.mjs +3 -1
- package/dist/admin/modules/app.mjs.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.js +15 -20
- package/dist/admin/pages/EditView/EditViewPage.js.map +1 -1
- package/dist/admin/pages/EditView/EditViewPage.mjs +15 -20
- package/dist/admin/pages/EditView/EditViewPage.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.js +2 -0
- package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.mjs +2 -0
- package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/EditorToolbarObserver.js +74 -7
- package/dist/admin/pages/EditView/components/EditorToolbarObserver.js.map +1 -1
- package/dist/admin/pages/EditView/components/EditorToolbarObserver.mjs +74 -7
- package/dist/admin/pages/EditView/components/EditorToolbarObserver.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +7 -2
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +7 -2
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js +59 -2
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs +60 -3
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.js +4 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.mjs +4 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js +4 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs +4 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.js +2 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.mjs +2 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +58 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +58 -2
- package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.js +25 -2
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.mjs +5 -2
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/WysiwygNav.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js +5 -1
- package/dist/admin/pages/EditView/components/InputRenderer.js.map +1 -1
- package/dist/admin/pages/EditView/components/InputRenderer.mjs +6 -2
- package/dist/admin/pages/EditView/components/InputRenderer.mjs.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.js +1 -0
- package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.mjs +1 -0
- package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
- package/dist/admin/preview/components/InputPopover.js +64 -46
- package/dist/admin/preview/components/InputPopover.js.map +1 -1
- package/dist/admin/preview/components/InputPopover.mjs +66 -49
- package/dist/admin/preview/components/InputPopover.mjs.map +1 -1
- package/dist/admin/preview/hooks/usePreviewInputManager.js +23 -7
- package/dist/admin/preview/hooks/usePreviewInputManager.js.map +1 -1
- package/dist/admin/preview/hooks/usePreviewInputManager.mjs +25 -9
- package/dist/admin/preview/hooks/usePreviewInputManager.mjs.map +1 -1
- package/dist/admin/preview/pages/Preview.js +19 -0
- package/dist/admin/preview/pages/Preview.js.map +1 -1
- package/dist/admin/preview/pages/Preview.mjs +20 -1
- package/dist/admin/preview/pages/Preview.mjs.map +1 -1
- package/dist/admin/preview/utils/constants.js +9 -3
- package/dist/admin/preview/utils/constants.js.map +1 -1
- package/dist/admin/preview/utils/constants.mjs +9 -3
- package/dist/admin/preview/utils/constants.mjs.map +1 -1
- package/dist/admin/src/components/ActionsDrawer.d.ts +1 -0
- package/dist/admin/src/modules/app.d.ts +2 -0
- package/dist/admin/src/pages/EditView/components/EditorToolbarObserver.d.ts +2 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.d.ts +5 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.d.ts +5 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.d.ts +5 -0
- package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.d.ts +2 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +14 -1
- package/dist/admin/src/preview/components/InputPopover.d.ts +2 -1
- package/dist/admin/src/preview/pages/Preview.d.ts +1 -0
- package/dist/admin/src/preview/utils/constants.d.ts +8 -1
- package/dist/admin/src/services/init.d.ts +1 -0
- package/dist/admin/src/utils/contentStructure.d.ts +59 -0
- package/dist/admin/utils/contentStructure.js +136 -0
- package/dist/admin/utils/contentStructure.js.map +1 -0
- package/dist/admin/utils/contentStructure.mjs +130 -0
- package/dist/admin/utils/contentStructure.mjs.map +1 -0
- package/dist/server/controllers/init.js +7 -2
- package/dist/server/controllers/init.js.map +1 -1
- package/dist/server/controllers/init.mjs +7 -2
- package/dist/server/controllers/init.mjs.map +1 -1
- package/dist/server/preview/controllers/previewScript.js +548 -22
- package/dist/server/services/content-structure.js +53 -0
- package/dist/server/services/content-structure.js.map +1 -0
- package/dist/server/services/content-structure.mjs +51 -0
- package/dist/server/services/content-structure.mjs.map +1 -0
- package/dist/server/services/index.js +2 -0
- package/dist/server/services/index.js.map +1 -1
- package/dist/server/services/index.mjs +2 -0
- package/dist/server/services/index.mjs.map +1 -1
- package/dist/server/src/controllers/index.d.ts +1 -1
- package/dist/server/src/controllers/init.d.ts +1 -1
- package/dist/server/src/controllers/init.d.ts.map +1 -1
- package/dist/server/src/index.d.ts +6 -1
- package/dist/server/src/index.d.ts.map +1 -1
- package/dist/server/src/services/content-structure.d.ts +8 -0
- package/dist/server/src/services/content-structure.d.ts.map +1 -0
- package/dist/server/src/services/index.d.ts +5 -0
- package/dist/server/src/services/index.d.ts.map +1 -1
- package/dist/server/src/utils/index.d.ts +2 -0
- package/dist/server/src/utils/index.d.ts.map +1 -1
- package/dist/server/utils/index.js.map +1 -1
- package/dist/server/utils/index.mjs.map +1 -1
- package/dist/shared/contracts/init.d.ts +2 -0
- package/dist/shared/contracts/init.d.ts.map +1 -1
- package/package.json +5 -5
|
@@ -289,7 +289,7 @@ const baseRenderElement = ({ props, blocks, editor, dragDirection, setDragDirect
|
|
|
289
289
|
});
|
|
290
290
|
};
|
|
291
291
|
const dragNoop = ()=>true;
|
|
292
|
-
const BlocksContent = ({ placeholder, ariaLabelId })=>{
|
|
292
|
+
const BlocksContent = ({ placeholder, ariaLabelId, autoFocus, onFocus, onBlur })=>{
|
|
293
293
|
const { editor, disabled, blocks, modifiers, setLiveText, isExpandedMode, flushPendingFormSync } = useBlocksEditorContext('BlocksContent');
|
|
294
294
|
const isMobile = useIsMobile();
|
|
295
295
|
const blocksRef = React.useRef(null);
|
|
@@ -519,7 +519,12 @@ const BlocksContent = ({ placeholder, ariaLabelId })=>{
|
|
|
519
519
|
renderLeaf: renderLeaf,
|
|
520
520
|
onKeyDown: handleKeyDown,
|
|
521
521
|
scrollSelectionIntoView: handleScrollSelectionIntoView,
|
|
522
|
-
|
|
522
|
+
autoFocus: autoFocus,
|
|
523
|
+
onFocus: onFocus,
|
|
524
|
+
onBlur: (event)=>{
|
|
525
|
+
flushPendingFormSync();
|
|
526
|
+
onBlur?.(event);
|
|
527
|
+
},
|
|
523
528
|
// As we have our own handler to drag and drop the elements returing true will skip slate's own event handler
|
|
524
529
|
onDrop: dragNoop,
|
|
525
530
|
onDragStart: dragNoop
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlocksContent.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useIsMobile } from '@strapi/admin/strapi-admin';\nimport {\n Box,\n BoxComponent,\n Flex,\n FlexComponent,\n IconButton,\n IconButtonComponent,\n useComposedRefs,\n} from '@strapi/design-system';\nimport { Drag } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { Editor, Range, Transforms } from 'slate';\nimport { ReactEditor, type RenderElementProps, type RenderLeafProps, Editable } from 'slate-react';\nimport { styled, CSSProperties, css } from 'styled-components';\n\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { useDragAndDrop, DIRECTIONS } from '../../../../../hooks/useDragAndDrop';\nimport { getTranslation } from '../../../../../utils/translations';\n\nimport { decorateCode } from './Blocks/Code';\nimport { type BlocksStore, useBlocksEditorContext } from './BlocksEditor';\nimport { useConversionModal } from './BlocksToolbar';\nimport { type ModifiersStore } from './Modifiers';\nimport { getEntries } from './utils/types';\n\nconst StyledEditable = styled(Editable)<{ $isExpandedMode: boolean }>`\n // The outline style is set on the wrapper with :focus-within\n outline: none;\n display: flex;\n flex-direction: column;\n gap: ${({ theme }) => theme.spaces[3]};\n height: 100%;\n // For fullscreen align input in the center with fixed width\n width: ${(props) => (props.$isExpandedMode ? '512px' : '100%')};\n margin: auto;\n font-size: 1.6rem;\n\n ${({ theme }) => theme.breakpoints.medium} {\n font-size: 1.4rem;\n }\n > *:last-child {\n padding-bottom: ${({ theme }) => theme.spaces[3]};\n }\n`;\n\nconst Wrapper = styled<BoxComponent>(Box)<{ $isOverDropTarget: boolean }>`\n position: ${({ $isOverDropTarget }) => $isOverDropTarget && 'relative'};\n`;\n\ntype DragDirection = (typeof DIRECTIONS)[keyof typeof DIRECTIONS];\n\nconst DropPlaceholder = styled<BoxComponent>(Box)<{\n dragDirection: DragDirection | null;\n placeholderMargin: 1 | 2;\n}>`\n position: absolute;\n right: 0;\n\n // Show drop placeholder 8px above or below the drop target\n ${({ dragDirection, theme, placeholderMargin }) => css`\n top: ${dragDirection === DIRECTIONS.UPWARD && `-${theme.spaces[placeholderMargin]}`};\n bottom: ${dragDirection === DIRECTIONS.DOWNWARD && `-${theme.spaces[placeholderMargin]}`};\n `}\n`;\n\nconst DragItem = styled<FlexComponent>(Flex)<{ $dragVisibility: CSSProperties['visibility'] }>`\n // Style each block rendered using renderElement()\n & > [data-slate-node='element'] {\n width: 100%;\n opacity: inherit;\n }\n\n // Set the visibility of drag button\n [role='button'] {\n visibility: ${(props) => props.$dragVisibility};\n opacity: inherit;\n }\n &[aria-disabled='true'] {\n user-drag: none;\n }\n`;\n\nconst DragIconButton = styled<IconButtonComponent<'div'>>(IconButton)<{\n $dragHandleTopMargin?: CSSProperties['marginTop'];\n}>`\n user-select: none;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n border-radius: ${({ theme }) => theme.borderRadius};\n padding-left: ${({ theme }) => theme.spaces[0]};\n padding-right: ${({ theme }) => theme.spaces[0]};\n padding-top: ${({ theme }) => theme.spaces[1]};\n padding-bottom: ${({ theme }) => theme.spaces[1]};\n visibility: hidden;\n cursor: grab;\n opacity: inherit;\n margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};\n\n &:hover {\n background: ${({ theme }) => theme.colors.neutral100};\n }\n &:active {\n cursor: grabbing;\n background: ${({ theme }) => theme.colors.neutral150};\n }\n &[aria-disabled='true'] {\n visibility: hidden;\n }\n svg {\n min-width: ${({ theme }) => theme.spaces[3]};\n\n path {\n fill: ${({ theme }) => theme.colors.neutral500};\n }\n }\n`;\n\ntype Direction = {\n setDragDirection: (direction: DragDirection) => void;\n dragDirection: DragDirection | null;\n};\n\ntype DragAndDropElementProps = Direction & {\n children: RenderElementProps['children'];\n index: Array<number>;\n dragHandleTopMargin?: CSSProperties['marginTop'];\n};\n\nconst DragAndDropElement = ({\n children,\n index,\n setDragDirection,\n dragDirection,\n dragHandleTopMargin,\n}: DragAndDropElementProps) => {\n const { editor, disabled, name, setLiveText } = useBlocksEditorContext('DragAndDropElement');\n const { formatMessage } = useIntl();\n const [dragVisibility, setDragVisibility] = React.useState<CSSProperties['visibility']>('hidden');\n const isDragAndDropEnabled = !disabled;\n\n const handleMoveBlock = React.useCallback(\n (newIndex: Array<number>, currentIndex: Array<number>) => {\n Transforms.moveNodes(editor, {\n at: currentIndex,\n to: newIndex,\n });\n\n // Add 1 to the index for the live text message\n const currentIndexPosition = [currentIndex[0] + 1, ...currentIndex.slice(1)];\n const newIndexPosition = [newIndex[0] + 1, ...newIndex.slice(1)];\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}.${currentIndexPosition.join(',')}`,\n position: `${newIndexPosition.join(',')} of ${editor.children.length}`,\n }\n )\n );\n },\n [editor, formatMessage, name, setLiveText]\n );\n\n const [{ handlerId, isDragging, isOverDropTarget, direction }, blockRef, dropRef, dragRef] =\n useDragAndDrop(isDragAndDropEnabled, {\n type: `${ItemTypes.BLOCKS}_${name}`,\n index,\n item: {\n index,\n displayedValue: children,\n },\n onDropItem(currentIndex, newIndex) {\n if (newIndex) handleMoveBlock(newIndex, currentIndex);\n },\n });\n\n const composedBoxRefs = useComposedRefs(blockRef, dropRef);\n\n // Set Drag direction before loosing state while dragging\n React.useEffect(() => {\n if (direction) {\n setDragDirection(direction);\n }\n }, [direction, setDragDirection]);\n\n // On selection change hide drag handle\n React.useEffect(() => {\n setDragVisibility('hidden');\n }, [editor.selection]);\n\n return (\n <Wrapper ref={composedBoxRefs} $isOverDropTarget={isOverDropTarget}>\n {isOverDropTarget && (\n <DropPlaceholder\n borderStyle=\"solid\"\n borderColor=\"secondary200\"\n borderWidth=\"2px\"\n width=\"calc(100% - 24px)\"\n marginLeft=\"auto\"\n dragDirection={dragDirection}\n // For list items placeholder reduce the margin around\n placeholderMargin={children.props.as && children.props.as === 'li' ? 1 : 2}\n />\n )}\n {isDragging ? (\n <CloneDragItem dragHandleTopMargin={dragHandleTopMargin}>{children}</CloneDragItem>\n ) : (\n <DragItem\n ref={dragRef}\n data-handler-id={handlerId}\n gap={2}\n paddingLeft={2}\n alignItems=\"start\"\n onDragStart={\n isDragAndDropEnabled\n ? (event) => {\n const target = event.target as HTMLElement;\n const currentTarget = event.currentTarget as HTMLElement;\n\n // Dragging action should only trigger drag event when button is dragged, however update styles on the whole dragItem.\n if (target.getAttribute('role') !== 'button') {\n event.preventDefault();\n } else {\n // Setting styles using dragging state is not working, so set it on current target element as nodes get dragged\n currentTarget.style.opacity = '0.5';\n }\n }\n : undefined\n }\n onDragEnd={\n isDragAndDropEnabled\n ? (event) => {\n const currentTarget = event.currentTarget as HTMLElement;\n currentTarget.style.opacity = '1';\n }\n : undefined\n }\n onMouseEnter={() => setDragVisibility('visible')}\n onFocusCapture={() => setDragVisibility('visible')}\n onBlurCapture={() => setDragVisibility('hidden')}\n onMouseLeave={() => setDragVisibility('hidden')}\n aria-disabled={disabled}\n $dragVisibility={dragVisibility}\n >\n <DragIconButton\n tag=\"div\"\n contentEditable={false}\n role=\"button\"\n tabIndex={0}\n withTooltip={false}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n onClick={(e: React.MouseEvent) => e.stopPropagation()}\n aria-disabled={disabled}\n disabled={disabled}\n draggable={isDragAndDropEnabled}\n // For some blocks top margin added to drag handle to align at the text level\n $dragHandleTopMargin={dragHandleTopMargin}\n >\n <Drag color=\"primary500\" />\n </DragIconButton>\n {children}\n </DragItem>\n )}\n </Wrapper>\n );\n};\n\ninterface CloneDragItemProps {\n children: RenderElementProps['children'];\n dragHandleTopMargin?: CSSProperties['marginTop'];\n}\n\n// To prevent applying opacity to the original item being dragged, display a cloned element without opacity.\nconst CloneDragItem = ({ children, dragHandleTopMargin }: CloneDragItemProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <DragItem gap={2} paddingLeft={2} alignItems=\"start\" $dragVisibility=\"visible\">\n <DragIconButton\n tag=\"div\"\n role=\"button\"\n withTooltip={false}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n $dragHandleTopMargin={dragHandleTopMargin}\n >\n <Drag color=\"neutral600\" />\n </DragIconButton>\n {children}\n </DragItem>\n );\n};\n\ninterface ExtendedRenderLeafProps extends RenderLeafProps {\n leaf: RenderLeafProps['leaf'] & { className?: string };\n}\n\nconst baseRenderLeaf = (props: ExtendedRenderLeafProps, modifiers: ModifiersStore) => {\n // Recursively wrap the children for each active modifier\n const wrappedChildren = getEntries(modifiers).reduce((currentChildren, modifierEntry) => {\n const [name, modifier] = modifierEntry;\n\n if (props.leaf[name]) {\n return modifier.renderLeaf(currentChildren);\n }\n\n return currentChildren;\n }, props.children);\n\n return (\n <span {...props.attributes} className={props.leaf.className}>\n {wrappedChildren}\n </span>\n );\n};\n\ntype BaseRenderElementProps = Direction & {\n props: RenderElementProps['children'];\n blocks: Partial<BlocksStore>;\n editor: Editor;\n isMobile: boolean;\n};\n\nconst baseRenderElement = ({\n props,\n blocks,\n editor,\n dragDirection,\n setDragDirection,\n isMobile,\n}: BaseRenderElementProps) => {\n const { element } = props;\n\n const blockMatch = Object.values(blocks).find((block) => block?.matchNode(element));\n const block = blockMatch || blocks.paragraph;\n\n if (!block) {\n return <></>;\n }\n\n const nodePath = ReactEditor.findPath(editor, element);\n\n const isDraggable = block.isDraggable?.(element) ?? true;\n\n if (!isDraggable || isMobile) {\n return block.renderElement(props);\n }\n\n return (\n <DragAndDropElement\n index={nodePath}\n setDragDirection={setDragDirection}\n dragDirection={dragDirection}\n dragHandleTopMargin={block.dragHandleTopMargin}\n >\n {block.renderElement(props)}\n </DragAndDropElement>\n );\n};\n\nconst dragNoop = () => true;\n\ninterface BlocksContentProps {\n placeholder?: string;\n ariaLabelId: string;\n}\n\nconst BlocksContent = ({ placeholder, ariaLabelId }: BlocksContentProps) => {\n const { editor, disabled, blocks, modifiers, setLiveText, isExpandedMode, flushPendingFormSync } =\n useBlocksEditorContext('BlocksContent');\n const isMobile = useIsMobile();\n const blocksRef = React.useRef<HTMLDivElement>(null);\n const { formatMessage } = useIntl();\n const [dragDirection, setDragDirection] = React.useState<DragDirection | null>(null);\n const { modalElement, handleConversionResult } = useConversionModal();\n\n // Create renderLeaf function based on the modifiers store\n const renderLeaf = React.useCallback(\n (props: ExtendedRenderLeafProps) => baseRenderLeaf(props, modifiers),\n [modifiers]\n );\n\n const handleMoveBlocks = (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) return;\n\n const start = Range.start(editor.selection);\n const currentIndex = [start.path[0]];\n let newIndexPosition = 0;\n\n if (event.key === 'ArrowUp') {\n newIndexPosition = currentIndex[0] > 0 ? currentIndex[0] - 1 : currentIndex[0];\n } else {\n newIndexPosition =\n currentIndex[0] < editor.children.length - 1 ? currentIndex[0] + 1 : currentIndex[0];\n }\n\n const newIndex = [newIndexPosition];\n\n if (newIndexPosition !== currentIndex[0]) {\n Transforms.moveNodes(editor, {\n at: currentIndex,\n to: newIndex,\n });\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 event.preventDefault();\n }\n };\n\n // Create renderElement function base on the blocks store\n const renderElement = React.useCallback(\n (props: RenderElementProps) =>\n baseRenderElement({ props, blocks, editor, dragDirection, setDragDirection, isMobile }),\n [blocks, editor, dragDirection, isMobile, setDragDirection]\n );\n\n const checkSnippet = (event: React.KeyboardEvent<HTMLElement>) => {\n // Get current text block\n if (!editor.selection) {\n return;\n }\n\n const [textNode, textNodePath] = Editor.node(editor, editor.selection.anchor.path);\n\n // Narrow the type to a text node\n if (Editor.isEditor(textNode) || textNode.type !== 'text') {\n return;\n }\n\n // Don't check for snippets if we're not at the start of a block\n if (textNodePath.at(-1) !== 0) {\n return;\n }\n\n // Check if the text node starts with a known snippet\n const blockMatchingSnippet = Object.values(blocks).find((block) => {\n return block?.snippets?.includes(textNode.text);\n });\n\n if (blockMatchingSnippet?.handleConvert) {\n // Prevent the space from being created and delete the snippet\n event.preventDefault();\n Transforms.delete(editor, {\n distance: textNode.text.length,\n unit: 'character',\n reverse: true,\n });\n\n // Convert the selected block\n const maybeRenderModal = blockMatchingSnippet.handleConvert(editor);\n handleConversionResult(maybeRenderModal);\n }\n };\n\n const handleEnter = (event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) {\n return;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n const selectedBlock = Object.values(blocks).find((block) => block?.matchNode(selectedNode));\n if (!selectedBlock) {\n return;\n }\n\n // Allow forced line breaks when shift is pressed\n if (event.shiftKey && selectedNode.type !== 'image') {\n Transforms.insertText(editor, '\\n');\n return;\n }\n\n // Check if there's an enter handler for the selected block\n if (selectedBlock.handleEnterKey) {\n selectedBlock.handleEnterKey(editor);\n } else {\n blocks.paragraph?.handleEnterKey!(editor);\n }\n };\n\n const handleBackspaceEvent = (event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) {\n return;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n const selectedBlock = Object.values(blocks).find((block) => block?.matchNode(selectedNode));\n\n if (!selectedBlock) {\n return;\n }\n\n if (selectedBlock.handleBackspaceKey) {\n selectedBlock.handleBackspaceKey(editor, event);\n }\n };\n\n const handleTab = (event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) {\n return;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n const selectedBlock = Object.values(blocks).find((block) => block?.matchNode(selectedNode));\n if (!selectedBlock) {\n return;\n }\n\n event.preventDefault();\n\n if (event.shiftKey && selectedBlock.handleShiftTab) {\n // Handle Shift+Tab (unindent)\n selectedBlock.handleShiftTab(editor);\n } else if (!event.shiftKey && selectedBlock.handleTab) {\n // Handle Tab (indent)\n selectedBlock.handleTab(editor);\n }\n };\n\n const handleKeyboardShortcuts = (event: React.KeyboardEvent<HTMLElement>) => {\n const isCtrlOrCmd = event.metaKey || event.ctrlKey;\n\n if (isCtrlOrCmd) {\n // Check if there's a modifier to toggle\n Object.values(modifiers).forEach((value) => {\n if (value.isValidEventKey(event)) {\n event.preventDefault();\n value.handleToggle(editor);\n return;\n }\n });\n if (event.shiftKey && ['ArrowUp', 'ArrowDown'].includes(event.key)) {\n handleMoveBlocks(editor, event);\n }\n }\n };\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLElement> = (event) => {\n // Find the right block-specific handlers for enter and backspace key presses\n switch (event.key) {\n case 'Enter':\n if (!event.nativeEvent.isComposing) {\n event.preventDefault();\n return handleEnter(event);\n }\n break;\n case 'Backspace':\n return handleBackspaceEvent(event);\n case 'Tab':\n return handleTab(event);\n case 'Escape':\n return ReactEditor.blur(editor);\n }\n handleKeyboardShortcuts(event);\n // Check if a snippet was triggered\n if (event.key === ' ') {\n checkSnippet(event);\n }\n };\n\n /**\n * scrollSelectionIntoView : Slate's default method to scroll a DOM selection into the view,\n * thats shifting layout for us when there is a overflowY:scroll on the viewport.\n * We are overriding it to check if the selection is not fully within the visible area of the editor,\n * we use scrollBy one line to the bottom\n */\n\n const handleScrollSelectionIntoView = React.useCallback(() => {\n if (!editor.selection || !blocksRef.current) {\n return;\n }\n\n const domRange = ReactEditor.toDOMRange(editor, editor.selection);\n const domRect = domRange.getBoundingClientRect();\n\n const editorRect = blocksRef.current.getBoundingClientRect();\n\n // Check if the selection is not fully within the visible area of the editor\n if (domRect.top < editorRect.top || domRect.bottom > editorRect.bottom) {\n // Scroll by one line to the bottom\n blocksRef.current.scrollBy({\n top: 28, // 20px is the line-height + 8px line gap\n behavior: 'smooth',\n });\n }\n }, [editor]);\n\n return (\n <Box\n ref={blocksRef}\n grow={1}\n width=\"100%\"\n overflow=\"auto\"\n fontSize={2}\n background=\"neutral0\"\n color=\"neutral800\"\n lineHeight={6}\n paddingLeft={{ initial: 4, medium: 0 }}\n paddingRight={7}\n paddingTop={6}\n paddingBottom={3}\n >\n <StyledEditable\n aria-labelledby={ariaLabelId}\n readOnly={disabled}\n placeholder={placeholder}\n $isExpandedMode={isExpandedMode}\n decorate={decorateCode}\n renderElement={renderElement}\n renderLeaf={renderLeaf}\n onKeyDown={handleKeyDown}\n scrollSelectionIntoView={handleScrollSelectionIntoView}\n onBlur={flushPendingFormSync}\n // As we have our own handler to drag and drop the elements returing true will skip slate's own event handler\n onDrop={dragNoop}\n onDragStart={dragNoop}\n />\n {modalElement}\n </Box>\n );\n};\n\nexport { BlocksContent, BlocksContentProps };\n"],"names":["StyledEditable","styled","Editable","theme","spaces","props","$isExpandedMode","breakpoints","medium","Wrapper","Box","$isOverDropTarget","DropPlaceholder","dragDirection","placeholderMargin","css","DIRECTIONS","UPWARD","DOWNWARD","DragItem","Flex","$dragVisibility","DragIconButton","IconButton","borderRadius","$dragHandleTopMargin","colors","neutral100","neutral150","neutral500","DragAndDropElement","children","index","setDragDirection","dragHandleTopMargin","editor","disabled","name","setLiveText","useBlocksEditorContext","formatMessage","useIntl","dragVisibility","setDragVisibility","React","useState","isDragAndDropEnabled","handleMoveBlock","useCallback","newIndex","currentIndex","Transforms","moveNodes","at","to","currentIndexPosition","slice","newIndexPosition","id","getTranslation","defaultMessage","item","join","position","length","handlerId","isDragging","isOverDropTarget","direction","blockRef","dropRef","dragRef","useDragAndDrop","type","ItemTypes","BLOCKS","displayedValue","onDropItem","composedBoxRefs","useComposedRefs","useEffect","selection","_jsxs","ref","_jsx","borderStyle","borderColor","borderWidth","width","marginLeft","as","CloneDragItem","data-handler-id","gap","paddingLeft","alignItems","onDragStart","event","target","currentTarget","getAttribute","preventDefault","style","opacity","undefined","onDragEnd","onMouseEnter","onFocusCapture","onBlurCapture","onMouseLeave","aria-disabled","tag","contentEditable","role","tabIndex","withTooltip","label","onClick","e","stopPropagation","draggable","Drag","color","baseRenderLeaf","modifiers","wrappedChildren","getEntries","reduce","currentChildren","modifierEntry","modifier","leaf","renderLeaf","span","attributes","className","baseRenderElement","blocks","isMobile","element","blockMatch","Object","values","find","block","matchNode","paragraph","_Fragment","nodePath","ReactEditor","findPath","isDraggable","renderElement","dragNoop","BlocksContent","placeholder","ariaLabelId","isExpandedMode","flushPendingFormSync","useIsMobile","blocksRef","useRef","modalElement","handleConversionResult","useConversionModal","handleMoveBlocks","start","Range","path","key","checkSnippet","textNode","textNodePath","Editor","node","anchor","isEditor","blockMatchingSnippet","snippets","includes","text","handleConvert","delete","distance","unit","reverse","maybeRenderModal","handleEnter","selectedNode","selectedBlock","shiftKey","insertText","handleEnterKey","handleBackspaceEvent","handleBackspaceKey","handleTab","handleShiftTab","handleKeyboardShortcuts","isCtrlOrCmd","metaKey","ctrlKey","forEach","value","isValidEventKey","handleToggle","handleKeyDown","nativeEvent","isComposing","blur","handleScrollSelectionIntoView","current","domRange","toDOMRange","domRect","getBoundingClientRect","editorRect","top","bottom","scrollBy","behavior","grow","overflow","fontSize","background","lineHeight","initial","paddingRight","paddingTop","paddingBottom","aria-labelledby","readOnly","decorate","decorateCode","onKeyDown","scrollSelectionIntoView","onBlur","onDrop"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,MAAMA,cAAAA,GAAiBC,MAAAA,CAAOC,QAAAA,CAAuC;;;;;OAK9D,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;;;AAG/B,SAAA,EAAE,CAACC,KAAAA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EX,IAAA,qBACE+C,IAAA,CAACxE,GAAAA,EAAAA;QACCyE,GAAAA,EAAK6E,SAAAA;QACL4D,IAAAA,EAAM,CAAA;QACNpI,KAAAA,EAAM,MAAA;QACNqI,QAAAA,EAAS,MAAA;QACTC,QAAAA,EAAU,CAAA;QACVC,UAAAA,EAAW,UAAA;QACXrG,KAAAA,EAAM,YAAA;QACNsG,UAAAA,EAAY,CAAA;QACZlI,WAAAA,EAAa;YAAEmI,OAAAA,EAAS,CAAA;YAAGzN,MAAAA,EAAQ;AAAE,SAAA;QACrC0N,YAAAA,EAAc,CAAA;QACdC,UAAAA,EAAY,CAAA;QACZC,aAAAA,EAAe,CAAA;;0BAEfhJ,GAAA,CAACpF,cAAAA,EAAAA;gBACCqO,iBAAAA,EAAiBzE,WAAAA;gBACjB0E,QAAAA,EAAUlM,QAAAA;gBACVuH,WAAAA,EAAaA,WAAAA;gBACbrJ,eAAAA,EAAiBuJ,cAAAA;gBACjB0E,QAAAA,EAAUC,YAAAA;gBACVhF,aAAAA,EAAeA,aAAAA;gBACfpB,UAAAA,EAAYA,UAAAA;gBACZqG,SAAAA,EAAW5B,aAAAA;gBACX6B,uBAAAA,EAAyBzB,6BAAAA;gBACzB0B,MAAAA,EAAQ7E,oBAAAA;;gBAER8E,MAAAA,EAAQnF,QAAAA;gBACRzD,WAAAA,EAAayD;;AAEdS,YAAAA;;;AAGP;;;;"}
|
|
1
|
+
{"version":3,"file":"BlocksContent.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useIsMobile } from '@strapi/admin/strapi-admin';\nimport {\n Box,\n BoxComponent,\n Flex,\n FlexComponent,\n IconButton,\n IconButtonComponent,\n useComposedRefs,\n} from '@strapi/design-system';\nimport { Drag } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { Editor, Range, Transforms } from 'slate';\nimport { ReactEditor, type RenderElementProps, type RenderLeafProps, Editable } from 'slate-react';\nimport { styled, CSSProperties, css } from 'styled-components';\n\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { useDragAndDrop, DIRECTIONS } from '../../../../../hooks/useDragAndDrop';\nimport { getTranslation } from '../../../../../utils/translations';\n\nimport { decorateCode } from './Blocks/Code';\nimport { type BlocksStore, useBlocksEditorContext } from './BlocksEditor';\nimport { useConversionModal } from './BlocksToolbar';\nimport { type ModifiersStore } from './Modifiers';\nimport { getEntries } from './utils/types';\n\nconst StyledEditable = styled(Editable)<{ $isExpandedMode: boolean }>`\n // The outline style is set on the wrapper with :focus-within\n outline: none;\n display: flex;\n flex-direction: column;\n gap: ${({ theme }) => theme.spaces[3]};\n height: 100%;\n // For fullscreen align input in the center with fixed width\n width: ${(props) => (props.$isExpandedMode ? '512px' : '100%')};\n margin: auto;\n font-size: 1.6rem;\n\n ${({ theme }) => theme.breakpoints.medium} {\n font-size: 1.4rem;\n }\n > *:last-child {\n padding-bottom: ${({ theme }) => theme.spaces[3]};\n }\n`;\n\nconst Wrapper = styled<BoxComponent>(Box)<{ $isOverDropTarget: boolean }>`\n position: ${({ $isOverDropTarget }) => $isOverDropTarget && 'relative'};\n`;\n\ntype DragDirection = (typeof DIRECTIONS)[keyof typeof DIRECTIONS];\n\nconst DropPlaceholder = styled<BoxComponent>(Box)<{\n dragDirection: DragDirection | null;\n placeholderMargin: 1 | 2;\n}>`\n position: absolute;\n right: 0;\n\n // Show drop placeholder 8px above or below the drop target\n ${({ dragDirection, theme, placeholderMargin }) => css`\n top: ${dragDirection === DIRECTIONS.UPWARD && `-${theme.spaces[placeholderMargin]}`};\n bottom: ${dragDirection === DIRECTIONS.DOWNWARD && `-${theme.spaces[placeholderMargin]}`};\n `}\n`;\n\nconst DragItem = styled<FlexComponent>(Flex)<{ $dragVisibility: CSSProperties['visibility'] }>`\n // Style each block rendered using renderElement()\n & > [data-slate-node='element'] {\n width: 100%;\n opacity: inherit;\n }\n\n // Set the visibility of drag button\n [role='button'] {\n visibility: ${(props) => props.$dragVisibility};\n opacity: inherit;\n }\n &[aria-disabled='true'] {\n user-drag: none;\n }\n`;\n\nconst DragIconButton = styled<IconButtonComponent<'div'>>(IconButton)<{\n $dragHandleTopMargin?: CSSProperties['marginTop'];\n}>`\n user-select: none;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n border-radius: ${({ theme }) => theme.borderRadius};\n padding-left: ${({ theme }) => theme.spaces[0]};\n padding-right: ${({ theme }) => theme.spaces[0]};\n padding-top: ${({ theme }) => theme.spaces[1]};\n padding-bottom: ${({ theme }) => theme.spaces[1]};\n visibility: hidden;\n cursor: grab;\n opacity: inherit;\n margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};\n\n &:hover {\n background: ${({ theme }) => theme.colors.neutral100};\n }\n &:active {\n cursor: grabbing;\n background: ${({ theme }) => theme.colors.neutral150};\n }\n &[aria-disabled='true'] {\n visibility: hidden;\n }\n svg {\n min-width: ${({ theme }) => theme.spaces[3]};\n\n path {\n fill: ${({ theme }) => theme.colors.neutral500};\n }\n }\n`;\n\ntype Direction = {\n setDragDirection: (direction: DragDirection) => void;\n dragDirection: DragDirection | null;\n};\n\ntype DragAndDropElementProps = Direction & {\n children: RenderElementProps['children'];\n index: Array<number>;\n dragHandleTopMargin?: CSSProperties['marginTop'];\n};\n\nconst DragAndDropElement = ({\n children,\n index,\n setDragDirection,\n dragDirection,\n dragHandleTopMargin,\n}: DragAndDropElementProps) => {\n const { editor, disabled, name, setLiveText } = useBlocksEditorContext('DragAndDropElement');\n const { formatMessage } = useIntl();\n const [dragVisibility, setDragVisibility] = React.useState<CSSProperties['visibility']>('hidden');\n const isDragAndDropEnabled = !disabled;\n\n const handleMoveBlock = React.useCallback(\n (newIndex: Array<number>, currentIndex: Array<number>) => {\n Transforms.moveNodes(editor, {\n at: currentIndex,\n to: newIndex,\n });\n\n // Add 1 to the index for the live text message\n const currentIndexPosition = [currentIndex[0] + 1, ...currentIndex.slice(1)];\n const newIndexPosition = [newIndex[0] + 1, ...newIndex.slice(1)];\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}.${currentIndexPosition.join(',')}`,\n position: `${newIndexPosition.join(',')} of ${editor.children.length}`,\n }\n )\n );\n },\n [editor, formatMessage, name, setLiveText]\n );\n\n const [{ handlerId, isDragging, isOverDropTarget, direction }, blockRef, dropRef, dragRef] =\n useDragAndDrop(isDragAndDropEnabled, {\n type: `${ItemTypes.BLOCKS}_${name}`,\n index,\n item: {\n index,\n displayedValue: children,\n },\n onDropItem(currentIndex, newIndex) {\n if (newIndex) handleMoveBlock(newIndex, currentIndex);\n },\n });\n\n const composedBoxRefs = useComposedRefs(blockRef, dropRef);\n\n // Set Drag direction before loosing state while dragging\n React.useEffect(() => {\n if (direction) {\n setDragDirection(direction);\n }\n }, [direction, setDragDirection]);\n\n // On selection change hide drag handle\n React.useEffect(() => {\n setDragVisibility('hidden');\n }, [editor.selection]);\n\n return (\n <Wrapper ref={composedBoxRefs} $isOverDropTarget={isOverDropTarget}>\n {isOverDropTarget && (\n <DropPlaceholder\n borderStyle=\"solid\"\n borderColor=\"secondary200\"\n borderWidth=\"2px\"\n width=\"calc(100% - 24px)\"\n marginLeft=\"auto\"\n dragDirection={dragDirection}\n // For list items placeholder reduce the margin around\n placeholderMargin={children.props.as && children.props.as === 'li' ? 1 : 2}\n />\n )}\n {isDragging ? (\n <CloneDragItem dragHandleTopMargin={dragHandleTopMargin}>{children}</CloneDragItem>\n ) : (\n <DragItem\n ref={dragRef}\n data-handler-id={handlerId}\n gap={2}\n paddingLeft={2}\n alignItems=\"start\"\n onDragStart={\n isDragAndDropEnabled\n ? (event) => {\n const target = event.target as HTMLElement;\n const currentTarget = event.currentTarget as HTMLElement;\n\n // Dragging action should only trigger drag event when button is dragged, however update styles on the whole dragItem.\n if (target.getAttribute('role') !== 'button') {\n event.preventDefault();\n } else {\n // Setting styles using dragging state is not working, so set it on current target element as nodes get dragged\n currentTarget.style.opacity = '0.5';\n }\n }\n : undefined\n }\n onDragEnd={\n isDragAndDropEnabled\n ? (event) => {\n const currentTarget = event.currentTarget as HTMLElement;\n currentTarget.style.opacity = '1';\n }\n : undefined\n }\n onMouseEnter={() => setDragVisibility('visible')}\n onFocusCapture={() => setDragVisibility('visible')}\n onBlurCapture={() => setDragVisibility('hidden')}\n onMouseLeave={() => setDragVisibility('hidden')}\n aria-disabled={disabled}\n $dragVisibility={dragVisibility}\n >\n <DragIconButton\n tag=\"div\"\n contentEditable={false}\n role=\"button\"\n tabIndex={0}\n withTooltip={false}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n onClick={(e: React.MouseEvent) => e.stopPropagation()}\n aria-disabled={disabled}\n disabled={disabled}\n draggable={isDragAndDropEnabled}\n // For some blocks top margin added to drag handle to align at the text level\n $dragHandleTopMargin={dragHandleTopMargin}\n >\n <Drag color=\"primary500\" />\n </DragIconButton>\n {children}\n </DragItem>\n )}\n </Wrapper>\n );\n};\n\ninterface CloneDragItemProps {\n children: RenderElementProps['children'];\n dragHandleTopMargin?: CSSProperties['marginTop'];\n}\n\n// To prevent applying opacity to the original item being dragged, display a cloned element without opacity.\nconst CloneDragItem = ({ children, dragHandleTopMargin }: CloneDragItemProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <DragItem gap={2} paddingLeft={2} alignItems=\"start\" $dragVisibility=\"visible\">\n <DragIconButton\n tag=\"div\"\n role=\"button\"\n withTooltip={false}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n $dragHandleTopMargin={dragHandleTopMargin}\n >\n <Drag color=\"neutral600\" />\n </DragIconButton>\n {children}\n </DragItem>\n );\n};\n\ninterface ExtendedRenderLeafProps extends RenderLeafProps {\n leaf: RenderLeafProps['leaf'] & { className?: string };\n}\n\nconst baseRenderLeaf = (props: ExtendedRenderLeafProps, modifiers: ModifiersStore) => {\n // Recursively wrap the children for each active modifier\n const wrappedChildren = getEntries(modifiers).reduce((currentChildren, modifierEntry) => {\n const [name, modifier] = modifierEntry;\n\n if (props.leaf[name]) {\n return modifier.renderLeaf(currentChildren);\n }\n\n return currentChildren;\n }, props.children);\n\n return (\n <span {...props.attributes} className={props.leaf.className}>\n {wrappedChildren}\n </span>\n );\n};\n\ntype BaseRenderElementProps = Direction & {\n props: RenderElementProps['children'];\n blocks: Partial<BlocksStore>;\n editor: Editor;\n isMobile: boolean;\n};\n\nconst baseRenderElement = ({\n props,\n blocks,\n editor,\n dragDirection,\n setDragDirection,\n isMobile,\n}: BaseRenderElementProps) => {\n const { element } = props;\n\n const blockMatch = Object.values(blocks).find((block) => block?.matchNode(element));\n const block = blockMatch || blocks.paragraph;\n\n if (!block) {\n return <></>;\n }\n\n const nodePath = ReactEditor.findPath(editor, element);\n\n const isDraggable = block.isDraggable?.(element) ?? true;\n\n if (!isDraggable || isMobile) {\n return block.renderElement(props);\n }\n\n return (\n <DragAndDropElement\n index={nodePath}\n setDragDirection={setDragDirection}\n dragDirection={dragDirection}\n dragHandleTopMargin={block.dragHandleTopMargin}\n >\n {block.renderElement(props)}\n </DragAndDropElement>\n );\n};\n\nconst dragNoop = () => true;\n\ninterface BlocksContentProps {\n placeholder?: string;\n ariaLabelId: string;\n autoFocus?: boolean;\n onFocus?: React.FocusEventHandler<HTMLElement>;\n onBlur?: React.FocusEventHandler<HTMLElement>;\n}\n\nconst BlocksContent = ({\n placeholder,\n ariaLabelId,\n autoFocus,\n onFocus,\n onBlur,\n}: BlocksContentProps) => {\n const { editor, disabled, blocks, modifiers, setLiveText, isExpandedMode, flushPendingFormSync } =\n useBlocksEditorContext('BlocksContent');\n const isMobile = useIsMobile();\n const blocksRef = React.useRef<HTMLDivElement>(null);\n const { formatMessage } = useIntl();\n const [dragDirection, setDragDirection] = React.useState<DragDirection | null>(null);\n const { modalElement, handleConversionResult } = useConversionModal();\n\n // Create renderLeaf function based on the modifiers store\n const renderLeaf = React.useCallback(\n (props: ExtendedRenderLeafProps) => baseRenderLeaf(props, modifiers),\n [modifiers]\n );\n\n const handleMoveBlocks = (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) return;\n\n const start = Range.start(editor.selection);\n const currentIndex = [start.path[0]];\n let newIndexPosition = 0;\n\n if (event.key === 'ArrowUp') {\n newIndexPosition = currentIndex[0] > 0 ? currentIndex[0] - 1 : currentIndex[0];\n } else {\n newIndexPosition =\n currentIndex[0] < editor.children.length - 1 ? currentIndex[0] + 1 : currentIndex[0];\n }\n\n const newIndex = [newIndexPosition];\n\n if (newIndexPosition !== currentIndex[0]) {\n Transforms.moveNodes(editor, {\n at: currentIndex,\n to: newIndex,\n });\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 event.preventDefault();\n }\n };\n\n // Create renderElement function base on the blocks store\n const renderElement = React.useCallback(\n (props: RenderElementProps) =>\n baseRenderElement({ props, blocks, editor, dragDirection, setDragDirection, isMobile }),\n [blocks, editor, dragDirection, isMobile, setDragDirection]\n );\n\n const checkSnippet = (event: React.KeyboardEvent<HTMLElement>) => {\n // Get current text block\n if (!editor.selection) {\n return;\n }\n\n const [textNode, textNodePath] = Editor.node(editor, editor.selection.anchor.path);\n\n // Narrow the type to a text node\n if (Editor.isEditor(textNode) || textNode.type !== 'text') {\n return;\n }\n\n // Don't check for snippets if we're not at the start of a block\n if (textNodePath.at(-1) !== 0) {\n return;\n }\n\n // Check if the text node starts with a known snippet\n const blockMatchingSnippet = Object.values(blocks).find((block) => {\n return block?.snippets?.includes(textNode.text);\n });\n\n if (blockMatchingSnippet?.handleConvert) {\n // Prevent the space from being created and delete the snippet\n event.preventDefault();\n Transforms.delete(editor, {\n distance: textNode.text.length,\n unit: 'character',\n reverse: true,\n });\n\n // Convert the selected block\n const maybeRenderModal = blockMatchingSnippet.handleConvert(editor);\n handleConversionResult(maybeRenderModal);\n }\n };\n\n const handleEnter = (event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) {\n return;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n const selectedBlock = Object.values(blocks).find((block) => block?.matchNode(selectedNode));\n if (!selectedBlock) {\n return;\n }\n\n // Allow forced line breaks when shift is pressed\n if (event.shiftKey && selectedNode.type !== 'image') {\n Transforms.insertText(editor, '\\n');\n return;\n }\n\n // Check if there's an enter handler for the selected block\n if (selectedBlock.handleEnterKey) {\n selectedBlock.handleEnterKey(editor);\n } else {\n blocks.paragraph?.handleEnterKey!(editor);\n }\n };\n\n const handleBackspaceEvent = (event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) {\n return;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n const selectedBlock = Object.values(blocks).find((block) => block?.matchNode(selectedNode));\n\n if (!selectedBlock) {\n return;\n }\n\n if (selectedBlock.handleBackspaceKey) {\n selectedBlock.handleBackspaceKey(editor, event);\n }\n };\n\n const handleTab = (event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) {\n return;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n const selectedBlock = Object.values(blocks).find((block) => block?.matchNode(selectedNode));\n if (!selectedBlock) {\n return;\n }\n\n event.preventDefault();\n\n if (event.shiftKey && selectedBlock.handleShiftTab) {\n // Handle Shift+Tab (unindent)\n selectedBlock.handleShiftTab(editor);\n } else if (!event.shiftKey && selectedBlock.handleTab) {\n // Handle Tab (indent)\n selectedBlock.handleTab(editor);\n }\n };\n\n const handleKeyboardShortcuts = (event: React.KeyboardEvent<HTMLElement>) => {\n const isCtrlOrCmd = event.metaKey || event.ctrlKey;\n\n if (isCtrlOrCmd) {\n // Check if there's a modifier to toggle\n Object.values(modifiers).forEach((value) => {\n if (value.isValidEventKey(event)) {\n event.preventDefault();\n value.handleToggle(editor);\n return;\n }\n });\n if (event.shiftKey && ['ArrowUp', 'ArrowDown'].includes(event.key)) {\n handleMoveBlocks(editor, event);\n }\n }\n };\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLElement> = (event) => {\n // Find the right block-specific handlers for enter and backspace key presses\n switch (event.key) {\n case 'Enter':\n if (!event.nativeEvent.isComposing) {\n event.preventDefault();\n return handleEnter(event);\n }\n break;\n case 'Backspace':\n return handleBackspaceEvent(event);\n case 'Tab':\n return handleTab(event);\n case 'Escape':\n return ReactEditor.blur(editor);\n }\n handleKeyboardShortcuts(event);\n // Check if a snippet was triggered\n if (event.key === ' ') {\n checkSnippet(event);\n }\n };\n\n /**\n * scrollSelectionIntoView : Slate's default method to scroll a DOM selection into the view,\n * thats shifting layout for us when there is a overflowY:scroll on the viewport.\n * We are overriding it to check if the selection is not fully within the visible area of the editor,\n * we use scrollBy one line to the bottom\n */\n\n const handleScrollSelectionIntoView = React.useCallback(() => {\n if (!editor.selection || !blocksRef.current) {\n return;\n }\n\n const domRange = ReactEditor.toDOMRange(editor, editor.selection);\n const domRect = domRange.getBoundingClientRect();\n\n const editorRect = blocksRef.current.getBoundingClientRect();\n\n // Check if the selection is not fully within the visible area of the editor\n if (domRect.top < editorRect.top || domRect.bottom > editorRect.bottom) {\n // Scroll by one line to the bottom\n blocksRef.current.scrollBy({\n top: 28, // 20px is the line-height + 8px line gap\n behavior: 'smooth',\n });\n }\n }, [editor]);\n\n return (\n <Box\n ref={blocksRef}\n grow={1}\n width=\"100%\"\n overflow=\"auto\"\n fontSize={2}\n background=\"neutral0\"\n color=\"neutral800\"\n lineHeight={6}\n paddingLeft={{ initial: 4, medium: 0 }}\n paddingRight={7}\n paddingTop={6}\n paddingBottom={3}\n >\n <StyledEditable\n aria-labelledby={ariaLabelId}\n readOnly={disabled}\n placeholder={placeholder}\n $isExpandedMode={isExpandedMode}\n decorate={decorateCode}\n renderElement={renderElement}\n renderLeaf={renderLeaf}\n onKeyDown={handleKeyDown}\n scrollSelectionIntoView={handleScrollSelectionIntoView}\n autoFocus={autoFocus}\n onFocus={onFocus}\n onBlur={(event) => {\n flushPendingFormSync();\n onBlur?.(event);\n }}\n // As we have our own handler to drag and drop the elements returing true will skip slate's own event handler\n onDrop={dragNoop}\n onDragStart={dragNoop}\n />\n {modalElement}\n </Box>\n );\n};\n\nexport { BlocksContent, BlocksContentProps };\n"],"names":["StyledEditable","styled","Editable","theme","spaces","props","$isExpandedMode","breakpoints","medium","Wrapper","Box","$isOverDropTarget","DropPlaceholder","dragDirection","placeholderMargin","css","DIRECTIONS","UPWARD","DOWNWARD","DragItem","Flex","$dragVisibility","DragIconButton","IconButton","borderRadius","$dragHandleTopMargin","colors","neutral100","neutral150","neutral500","DragAndDropElement","children","index","setDragDirection","dragHandleTopMargin","editor","disabled","name","setLiveText","useBlocksEditorContext","formatMessage","useIntl","dragVisibility","setDragVisibility","React","useState","isDragAndDropEnabled","handleMoveBlock","useCallback","newIndex","currentIndex","Transforms","moveNodes","at","to","currentIndexPosition","slice","newIndexPosition","id","getTranslation","defaultMessage","item","join","position","length","handlerId","isDragging","isOverDropTarget","direction","blockRef","dropRef","dragRef","useDragAndDrop","type","ItemTypes","BLOCKS","displayedValue","onDropItem","composedBoxRefs","useComposedRefs","useEffect","selection","_jsxs","ref","_jsx","borderStyle","borderColor","borderWidth","width","marginLeft","as","CloneDragItem","data-handler-id","gap","paddingLeft","alignItems","onDragStart","event","target","currentTarget","getAttribute","preventDefault","style","opacity","undefined","onDragEnd","onMouseEnter","onFocusCapture","onBlurCapture","onMouseLeave","aria-disabled","tag","contentEditable","role","tabIndex","withTooltip","label","onClick","e","stopPropagation","draggable","Drag","color","baseRenderLeaf","modifiers","wrappedChildren","getEntries","reduce","currentChildren","modifierEntry","modifier","leaf","renderLeaf","span","attributes","className","baseRenderElement","blocks","isMobile","element","blockMatch","Object","values","find","block","matchNode","paragraph","_Fragment","nodePath","ReactEditor","findPath","isDraggable","renderElement","dragNoop","BlocksContent","placeholder","ariaLabelId","autoFocus","onFocus","onBlur","isExpandedMode","flushPendingFormSync","useIsMobile","blocksRef","useRef","modalElement","handleConversionResult","useConversionModal","handleMoveBlocks","start","Range","path","key","checkSnippet","textNode","textNodePath","Editor","node","anchor","isEditor","blockMatchingSnippet","snippets","includes","text","handleConvert","delete","distance","unit","reverse","maybeRenderModal","handleEnter","selectedNode","selectedBlock","shiftKey","insertText","handleEnterKey","handleBackspaceEvent","handleBackspaceKey","handleTab","handleShiftTab","handleKeyboardShortcuts","isCtrlOrCmd","metaKey","ctrlKey","forEach","value","isValidEventKey","handleToggle","handleKeyDown","nativeEvent","isComposing","blur","handleScrollSelectionIntoView","current","domRange","toDOMRange","domRect","getBoundingClientRect","editorRect","top","bottom","scrollBy","behavior","grow","overflow","fontSize","background","lineHeight","initial","paddingRight","paddingTop","paddingBottom","aria-labelledby","readOnly","decorate","decorateCode","onKeyDown","scrollSelectionIntoView","onDrop"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,MAAMA,cAAAA,GAAiBC,MAAAA,CAAOC,QAAAA,CAAuC;;;;;OAK9D,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;;;AAG/B,SAAA,EAAE,CAACC,KAAAA,GAAWA,KAAAA,CAAMC,eAAe,GAAG,UAAU,MAAA,CAAQ;;;;EAI/D,EAAE,CAAC,EAAEH,KAAK,EAAE,GAAKA,KAAAA,CAAMI,WAAW,CAACC,MAAM,CAAC;;;;oBAIxB,EAAE,CAAC,EAAEL,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;;AAErD,CAAC;AAED,MAAMK,OAAAA,GAAUR,MAAAA,CAAqBS,GAAAA,CAAoC;AAC7D,YAAA,EAAE,CAAC,EAAEC,iBAAiB,EAAE,GAAKA,qBAAqB,UAAA,CAAW;AACzE,CAAC;AAID,MAAMC,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A;QACdC,UAAAA,EAAY,CAAA;QACZC,aAAAA,EAAe,CAAA;;0BAEfnJ,GAAA,CAACpF,cAAAA,EAAAA;gBACCwO,iBAAAA,EAAiB5E,WAAAA;gBACjB6E,QAAAA,EAAUrM,QAAAA;gBACVuH,WAAAA,EAAaA,WAAAA;gBACbrJ,eAAAA,EAAiB0J,cAAAA;gBACjB0E,QAAAA,EAAUC,YAAAA;gBACVnF,aAAAA,EAAeA,aAAAA;gBACfpB,UAAAA,EAAYA,UAAAA;gBACZwG,SAAAA,EAAW5B,aAAAA;gBACX6B,uBAAAA,EAAyBzB,6BAAAA;gBACzBvD,SAAAA,EAAWA,SAAAA;gBACXC,OAAAA,EAASA,OAAAA;AACTC,gBAAAA,MAAAA,EAAQ,CAAC9D,KAAAA,GAAAA;AACPgE,oBAAAA,oBAAAA,EAAAA;oBACAF,MAAAA,GAAS9D,KAAAA,CAAAA;AACX,gBAAA,CAAA;;gBAEA6I,MAAAA,EAAQrF,QAAAA;gBACRzD,WAAAA,EAAayD;;AAEdY,YAAAA;;;AAGP;;;;"}
|
|
@@ -112,7 +112,7 @@ const pipe = (...fns)=>(value)=>fns.reduce((prev, fn)=>fn(prev), value);
|
|
|
112
112
|
const isEmpty = value.length === 1 && slate.Editor.isEmpty(editor, value[0]);
|
|
113
113
|
return isEmpty ? null : value;
|
|
114
114
|
};
|
|
115
|
-
const BlocksEditor = /*#__PURE__*/ React__namespace.forwardRef(({ disabled = false, name, onChange, value, error, ...contentProps }, forwardedRef)=>{
|
|
115
|
+
const BlocksEditor = /*#__PURE__*/ React__namespace.forwardRef(({ disabled = false, name, onChange, value, error, livePreviewSync = false, blockIndex, ...contentProps }, forwardedRef)=>{
|
|
116
116
|
const { formatMessage } = reactIntl.useIntl();
|
|
117
117
|
const isMobile = strapiAdmin.useIsMobile();
|
|
118
118
|
const blocks = strapiAdmin.useStrapiApp('BlocksEditor', (state)=>state.plugins['content-manager']?.apis?.getRichTextBlocks() ?? {});
|
|
@@ -164,10 +164,13 @@ const BlocksEditor = /*#__PURE__*/ React__namespace.forwardRef(({ disabled = fal
|
|
|
164
164
|
* toolbar — looks like an external update with stale empty form state and remounts
|
|
165
165
|
* the editor, wiping the pending input (blocks e2e flake).
|
|
166
166
|
*/ incrementSlateUpdatesCount();
|
|
167
|
+
if (livePreviewSync) {
|
|
168
|
+
onChange(name, normalizeBlocksState(editor, state));
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
167
171
|
if (debounceTimeout.current) {
|
|
168
172
|
clearTimeout(debounceTimeout.current);
|
|
169
173
|
}
|
|
170
|
-
// Set a new debounce timeout
|
|
171
174
|
debounceTimeout.current = setTimeout(()=>{
|
|
172
175
|
// Normalize the state (empty editor becomes null)
|
|
173
176
|
onChange(name, normalizeBlocksState(editor, state));
|
|
@@ -177,6 +180,7 @@ const BlocksEditor = /*#__PURE__*/ React__namespace.forwardRef(({ disabled = fal
|
|
|
177
180
|
}, [
|
|
178
181
|
editor,
|
|
179
182
|
incrementSlateUpdatesCount,
|
|
183
|
+
livePreviewSync,
|
|
180
184
|
name,
|
|
181
185
|
onChange
|
|
182
186
|
]);
|
|
@@ -188,6 +192,58 @@ const BlocksEditor = /*#__PURE__*/ React__namespace.forwardRef(({ disabled = fal
|
|
|
188
192
|
}
|
|
189
193
|
};
|
|
190
194
|
}, []);
|
|
195
|
+
// When opened from a live-preview double-click, position the cursor at the clicked block
|
|
196
|
+
React__namespace.useEffect(()=>{
|
|
197
|
+
if (blockIndex == null) return;
|
|
198
|
+
const targetIndex = Math.min(blockIndex, editor.children.length - 1);
|
|
199
|
+
try {
|
|
200
|
+
slate.Transforms.select(editor, slate.Editor.start(editor, [
|
|
201
|
+
targetIndex
|
|
202
|
+
]));
|
|
203
|
+
} catch {
|
|
204
|
+
// Slate tree not yet ready; skip cursor positioning and scroll
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
try {
|
|
208
|
+
slateReact.ReactEditor.focus(editor);
|
|
209
|
+
} catch {
|
|
210
|
+
// non-fatal — editor DOM not yet committed
|
|
211
|
+
}
|
|
212
|
+
// Defer scroll past the re-render triggered by Transforms.select above.
|
|
213
|
+
// Slate's handleScrollSelectionIntoView runs as a layout effect during
|
|
214
|
+
// that re-render; our rAF fires after it, letting us override the position.
|
|
215
|
+
const raf = requestAnimationFrame(()=>{
|
|
216
|
+
try {
|
|
217
|
+
const blockNode = slate.Node.get(editor, [
|
|
218
|
+
targetIndex
|
|
219
|
+
]);
|
|
220
|
+
const domEl = slateReact.ReactEditor.toDOMNode(editor, blockNode);
|
|
221
|
+
// Walk to BlocksContent's scroll container via the Slate editor root,
|
|
222
|
+
// bypassing scrollIntoView which can target overflow:hidden ancestors.
|
|
223
|
+
const editorDomEl = domEl.closest('[data-slate-editor]');
|
|
224
|
+
const scrollContainer = editorDomEl?.parentElement;
|
|
225
|
+
if (scrollContainer) {
|
|
226
|
+
const blockRect = domEl.getBoundingClientRect();
|
|
227
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
228
|
+
// 24px = BlocksContent paddingTop={6} (design-system 4px scale)
|
|
229
|
+
scrollContainer.scrollTop = blockRect.top - containerRect.top + scrollContainer.scrollTop - 24;
|
|
230
|
+
} else {
|
|
231
|
+
domEl.scrollIntoView({
|
|
232
|
+
block: 'start'
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
} catch {
|
|
236
|
+
// scroll errors are non-fatal; the cursor is already positioned
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
return ()=>cancelAnimationFrame(raf);
|
|
240
|
+
// `key` is included so that if useResetKey remounts the Slate editor (clearing
|
|
241
|
+
// editor.selection to null), this effect re-runs and restores the cursor position.
|
|
242
|
+
}, [
|
|
243
|
+
blockIndex,
|
|
244
|
+
editor,
|
|
245
|
+
key
|
|
246
|
+
]);
|
|
191
247
|
// Ensure the editor is in sync after discard
|
|
192
248
|
React__namespace.useEffect(()=>{
|
|
193
249
|
// Never deselect while the editor is actively focused (typing / editing),
|
|
@@ -246,6 +302,7 @@ const BlocksEditor = /*#__PURE__*/ React__namespace.forwardRef(({ disabled = fal
|
|
|
246
302
|
disabled: disabled,
|
|
247
303
|
onToggleExpand: handleToggleExpand,
|
|
248
304
|
ariaDescriptionId: ariaDescriptionId,
|
|
305
|
+
livePreviewSync: livePreviewSync,
|
|
249
306
|
children: [
|
|
250
307
|
/*#__PURE__*/ jsxRuntime.jsx(BlocksToolbar.BlocksToolbar, {}),
|
|
251
308
|
/*#__PURE__*/ jsxRuntime.jsx(EditorDivider, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlocksEditor.js","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,yBAAAA,CAAwC,cAAA;AAE1C,SAASC,uBAAuBC,YAAoB,EAAA;AAGlD,IAAA,MAAMC,OAAAA,GAAUJ,6BAAAA,CAA8BG,YAAAA,EAAc,CAACE,KAAAA,GAAUA,KAAAA,CAAA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EAAS1C,kBAAAA;AAET,gCAAA,QAAA,gBAAAqB,cAAA,CAACsB,YAAAA,EAAAA,EAAAA;;;;;AAhCJtG,aAAAA,EAAAA,GAAAA;;;AAwCb,CAAA;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"BlocksEditor.js","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,yBAAAA,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,mBAAAA,EAAAA;IAEf,OA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AA,EAAAA,CAAAA;0CACDZ,cAAA,CAACrH,aAAAA,EAAAA;gCAAckI,KAAAA,EAAM;;0CACrBb,cAAA,CAACc,2BAAAA,EAAAA;AAAe,gCAAA,GAAGtF;;4BAClB,CAAC2B,cAAAA,IAAkB,CAACvB,QAAAA,kBACnBoE,cAAA,CAACe,uBAAAA,EAAAA;gCACCC,QAAAA,EAAS,UAAA;gCACTC,MAAAA,EAAO,QAAA;gCACPC,KAAAA,EAAM,QAAA;gCACNC,MAAAA,EAAO,cAAA;AACPC,gCAAAA,KAAAA,EAAO1F,aAAAA,CAAc;AACnBwE,oCAAAA,EAAAA,EAAIC,2BAAAA,CAAe,0BAAA,CAAA;oCACnBC,cAAAA,EAAgB;AAClB,iCAAA,CAAA;gCACAiB,OAAAA,EAASjE,kBAAAA;AAET,gCAAA,QAAA,gBAAA4C,cAAA,CAACsB,YAAAA,EAAAA,EAAAA;;;;;AAjCJ/H,aAAAA,EAAAA,GAAAA;;;AAyCb,CAAA;;;;;;;"}
|
|
@@ -5,7 +5,7 @@ import { Divider, VisuallyHidden, IconButton } from '@strapi/design-system';
|
|
|
5
5
|
import { Expand } from '@strapi/icons';
|
|
6
6
|
import { flushSync } from 'react-dom';
|
|
7
7
|
import { useIntl } from 'react-intl';
|
|
8
|
-
import { createEditor, Transforms, Editor } from 'slate';
|
|
8
|
+
import { createEditor, Transforms, Editor, Node } from 'slate';
|
|
9
9
|
import { withHistory } from 'slate-history';
|
|
10
10
|
import { withReact, ReactEditor, Slate, useSlate } from 'slate-react';
|
|
11
11
|
import { styled } from 'styled-components';
|
|
@@ -90,7 +90,7 @@ const pipe = (...fns)=>(value)=>fns.reduce((prev, fn)=>fn(prev), value);
|
|
|
90
90
|
const isEmpty = value.length === 1 && Editor.isEmpty(editor, value[0]);
|
|
91
91
|
return isEmpty ? null : value;
|
|
92
92
|
};
|
|
93
|
-
const BlocksEditor = /*#__PURE__*/ React.forwardRef(({ disabled = false, name, onChange, value, error, ...contentProps }, forwardedRef)=>{
|
|
93
|
+
const BlocksEditor = /*#__PURE__*/ React.forwardRef(({ disabled = false, name, onChange, value, error, livePreviewSync = false, blockIndex, ...contentProps }, forwardedRef)=>{
|
|
94
94
|
const { formatMessage } = useIntl();
|
|
95
95
|
const isMobile = useIsMobile();
|
|
96
96
|
const blocks = useStrapiApp('BlocksEditor', (state)=>state.plugins['content-manager']?.apis?.getRichTextBlocks() ?? {});
|
|
@@ -142,10 +142,13 @@ const BlocksEditor = /*#__PURE__*/ React.forwardRef(({ disabled = false, name, o
|
|
|
142
142
|
* toolbar — looks like an external update with stale empty form state and remounts
|
|
143
143
|
* the editor, wiping the pending input (blocks e2e flake).
|
|
144
144
|
*/ incrementSlateUpdatesCount();
|
|
145
|
+
if (livePreviewSync) {
|
|
146
|
+
onChange(name, normalizeBlocksState(editor, state));
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
145
149
|
if (debounceTimeout.current) {
|
|
146
150
|
clearTimeout(debounceTimeout.current);
|
|
147
151
|
}
|
|
148
|
-
// Set a new debounce timeout
|
|
149
152
|
debounceTimeout.current = setTimeout(()=>{
|
|
150
153
|
// Normalize the state (empty editor becomes null)
|
|
151
154
|
onChange(name, normalizeBlocksState(editor, state));
|
|
@@ -155,6 +158,7 @@ const BlocksEditor = /*#__PURE__*/ React.forwardRef(({ disabled = false, name, o
|
|
|
155
158
|
}, [
|
|
156
159
|
editor,
|
|
157
160
|
incrementSlateUpdatesCount,
|
|
161
|
+
livePreviewSync,
|
|
158
162
|
name,
|
|
159
163
|
onChange
|
|
160
164
|
]);
|
|
@@ -166,6 +170,58 @@ const BlocksEditor = /*#__PURE__*/ React.forwardRef(({ disabled = false, name, o
|
|
|
166
170
|
}
|
|
167
171
|
};
|
|
168
172
|
}, []);
|
|
173
|
+
// When opened from a live-preview double-click, position the cursor at the clicked block
|
|
174
|
+
React.useEffect(()=>{
|
|
175
|
+
if (blockIndex == null) return;
|
|
176
|
+
const targetIndex = Math.min(blockIndex, editor.children.length - 1);
|
|
177
|
+
try {
|
|
178
|
+
Transforms.select(editor, Editor.start(editor, [
|
|
179
|
+
targetIndex
|
|
180
|
+
]));
|
|
181
|
+
} catch {
|
|
182
|
+
// Slate tree not yet ready; skip cursor positioning and scroll
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
try {
|
|
186
|
+
ReactEditor.focus(editor);
|
|
187
|
+
} catch {
|
|
188
|
+
// non-fatal — editor DOM not yet committed
|
|
189
|
+
}
|
|
190
|
+
// Defer scroll past the re-render triggered by Transforms.select above.
|
|
191
|
+
// Slate's handleScrollSelectionIntoView runs as a layout effect during
|
|
192
|
+
// that re-render; our rAF fires after it, letting us override the position.
|
|
193
|
+
const raf = requestAnimationFrame(()=>{
|
|
194
|
+
try {
|
|
195
|
+
const blockNode = Node.get(editor, [
|
|
196
|
+
targetIndex
|
|
197
|
+
]);
|
|
198
|
+
const domEl = ReactEditor.toDOMNode(editor, blockNode);
|
|
199
|
+
// Walk to BlocksContent's scroll container via the Slate editor root,
|
|
200
|
+
// bypassing scrollIntoView which can target overflow:hidden ancestors.
|
|
201
|
+
const editorDomEl = domEl.closest('[data-slate-editor]');
|
|
202
|
+
const scrollContainer = editorDomEl?.parentElement;
|
|
203
|
+
if (scrollContainer) {
|
|
204
|
+
const blockRect = domEl.getBoundingClientRect();
|
|
205
|
+
const containerRect = scrollContainer.getBoundingClientRect();
|
|
206
|
+
// 24px = BlocksContent paddingTop={6} (design-system 4px scale)
|
|
207
|
+
scrollContainer.scrollTop = blockRect.top - containerRect.top + scrollContainer.scrollTop - 24;
|
|
208
|
+
} else {
|
|
209
|
+
domEl.scrollIntoView({
|
|
210
|
+
block: 'start'
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
} catch {
|
|
214
|
+
// scroll errors are non-fatal; the cursor is already positioned
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
return ()=>cancelAnimationFrame(raf);
|
|
218
|
+
// `key` is included so that if useResetKey remounts the Slate editor (clearing
|
|
219
|
+
// editor.selection to null), this effect re-runs and restores the cursor position.
|
|
220
|
+
}, [
|
|
221
|
+
blockIndex,
|
|
222
|
+
editor,
|
|
223
|
+
key
|
|
224
|
+
]);
|
|
169
225
|
// Ensure the editor is in sync after discard
|
|
170
226
|
React.useEffect(()=>{
|
|
171
227
|
// Never deselect while the editor is actively focused (typing / editing),
|
|
@@ -224,6 +280,7 @@ const BlocksEditor = /*#__PURE__*/ React.forwardRef(({ disabled = false, name, o
|
|
|
224
280
|
disabled: disabled,
|
|
225
281
|
onToggleExpand: handleToggleExpand,
|
|
226
282
|
ariaDescriptionId: ariaDescriptionId,
|
|
283
|
+
livePreviewSync: livePreviewSync,
|
|
227
284
|
children: [
|
|
228
285
|
/*#__PURE__*/ jsx(BlocksToolbar, {}),
|
|
229
286
|
/*#__PURE__*/ jsx(EditorDivider, {
|