@strapi/content-manager 5.50.0 → 5.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/admin/components/ComponentIcon.js.map +1 -1
- package/dist/admin/components/ComponentIcon.mjs.map +1 -1
- package/dist/admin/components/ConfigurationForm/Fields.js.map +1 -1
- package/dist/admin/components/ConfigurationForm/Fields.mjs.map +1 -1
- package/dist/admin/components/DragLayer.js.map +1 -1
- package/dist/admin/components/DragLayer.mjs.map +1 -1
- package/dist/admin/components/LeftMenu.js +66 -67
- package/dist/admin/components/LeftMenu.js.map +1 -1
- package/dist/admin/components/LeftMenu.mjs +68 -69
- package/dist/admin/components/LeftMenu.mjs.map +1 -1
- package/dist/admin/history/components/VersionInputRenderer.js +3 -3
- package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
- package/dist/admin/history/components/VersionInputRenderer.mjs +3 -3
- package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
- package/dist/admin/history/routes.js.map +1 -1
- package/dist/admin/history/routes.mjs.map +1 -1
- package/dist/admin/hooks/useDocumentActions.js +15 -8
- package/dist/admin/hooks/useDocumentActions.js.map +1 -1
- package/dist/admin/hooks/useDocumentActions.mjs +15 -8
- package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
- package/dist/admin/hooks/useDocumentContext.js.map +1 -1
- package/dist/admin/hooks/useDocumentContext.mjs.map +1 -1
- package/dist/admin/index.js.map +1 -1
- package/dist/admin/index.mjs.map +1 -1
- package/dist/admin/layout.js +18 -6
- package/dist/admin/layout.js.map +1 -1
- package/dist/admin/layout.mjs +18 -6
- package/dist/admin/layout.mjs.map +1 -1
- package/dist/admin/pages/ComponentConfigurationPage.js.map +1 -1
- package/dist/admin/pages/ComponentConfigurationPage.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.js +7 -6
- package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
- package/dist/admin/pages/EditView/components/DocumentActions.mjs +7 -6
- package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js +6 -3
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs +6 -3
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.js +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.mjs +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Initializer.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Initializer.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.js +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.mjs +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Input.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +2 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +2 -1
- package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +8 -5
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +8 -5
- package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/UID.js +5 -4
- package/dist/admin/pages/EditView/components/FormInputs/UID.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/UID.mjs +5 -4
- package/dist/admin/pages/EditView/components/FormInputs/UID.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Editor.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Field.js +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Field.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Field.mjs +2 -2
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/Field.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/utils/utils.js.map +1 -1
- package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/utils/utils.mjs.map +1 -1
- package/dist/admin/pages/EditView/components/Panels.js.map +1 -1
- package/dist/admin/pages/EditView/components/Panels.mjs.map +1 -1
- package/dist/admin/pages/EditView/utils/data.js.map +1 -1
- package/dist/admin/pages/EditView/utils/data.mjs.map +1 -1
- package/dist/admin/pages/ListConfiguration/components/Settings.js.map +1 -1
- package/dist/admin/pages/ListConfiguration/components/Settings.mjs.map +1 -1
- package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.js.map +1 -1
- package/dist/admin/pages/ListConfiguration/components/SortDisplayedFields.mjs.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.js +71 -11
- package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
- package/dist/admin/pages/ListView/ListViewPage.mjs +73 -13
- package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/Actions.js +2 -1
- package/dist/admin/pages/ListView/components/BulkActions/Actions.js.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/Actions.mjs +2 -1
- package/dist/admin/pages/ListView/components/BulkActions/Actions.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.js.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/ConfirmBulkActionDialog.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.js.map +1 -1
- package/dist/admin/pages/ListView/components/BulkActions/PublishAction.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/Filters.js +5 -3
- package/dist/admin/pages/ListView/components/Filters.js.map +1 -1
- package/dist/admin/pages/ListView/components/Filters.mjs +5 -3
- package/dist/admin/pages/ListView/components/Filters.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/TableActions.js +37 -0
- package/dist/admin/pages/ListView/components/TableActions.js.map +1 -1
- package/dist/admin/pages/ListView/components/TableActions.mjs +39 -2
- package/dist/admin/pages/ListView/components/TableActions.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/CellContent.js +26 -1
- package/dist/admin/pages/ListView/components/TableCells/CellContent.js.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/CellContent.mjs +26 -2
- package/dist/admin/pages/ListView/components/TableCells/CellContent.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/CellValue.js +8 -7
- package/dist/admin/pages/ListView/components/TableCells/CellValue.js.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/CellValue.mjs +8 -7
- package/dist/admin/pages/ListView/components/TableCells/CellValue.mjs.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/Components.js.map +1 -1
- package/dist/admin/pages/ListView/components/TableCells/Components.mjs.map +1 -1
- package/dist/admin/preview/pages/Preview.js +2 -0
- package/dist/admin/preview/pages/Preview.js.map +1 -1
- package/dist/admin/preview/pages/Preview.mjs +2 -0
- package/dist/admin/preview/pages/Preview.mjs.map +1 -1
- package/dist/admin/preview/routes.js.map +1 -1
- package/dist/admin/preview/routes.mjs.map +1 -1
- package/dist/admin/preview/utils/fieldUtils.js.map +1 -1
- package/dist/admin/preview/utils/fieldUtils.mjs.map +1 -1
- package/dist/admin/router.js.map +1 -1
- package/dist/admin/router.mjs.map +1 -1
- package/dist/admin/services/documents.js.map +1 -1
- package/dist/admin/services/documents.mjs.map +1 -1
- package/dist/admin/src/components/ComponentIcon.d.ts +4 -3
- package/dist/admin/src/components/DragLayer.d.ts +1 -1
- package/dist/admin/src/history/routes.d.ts +2 -2
- package/dist/admin/src/history/services/historyVersion.d.ts +1 -1
- package/dist/admin/src/hooks/useDocumentActions.d.ts +17 -16
- package/dist/admin/src/hooks/useDocumentContext.d.ts +1 -1
- package/dist/admin/src/index.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/UID.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/Editor.d.ts +1 -1
- package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/utils/utils.d.ts +7 -1
- package/dist/admin/src/pages/ListView/components/TableCells/CellContent.d.ts +11 -2
- package/dist/admin/src/pages/ListView/components/TableCells/CellValue.d.ts +1 -1
- package/dist/admin/src/preview/routes.d.ts +2 -2
- package/dist/admin/src/preview/services/preview.d.ts +1 -1
- package/dist/admin/src/router.d.ts +2 -2
- package/dist/admin/src/services/api.d.ts +1 -1
- package/dist/admin/src/services/components.d.ts +2 -2
- package/dist/admin/src/services/contentTypes.d.ts +3 -3
- package/dist/admin/src/services/documents.d.ts +19 -19
- package/dist/admin/src/services/homepage.d.ts +1 -1
- package/dist/admin/src/services/init.d.ts +1 -1
- package/dist/admin/src/services/relations.d.ts +2 -2
- package/dist/admin/src/services/uid.d.ts +3 -3
- package/dist/admin/src/utils/api.d.ts +2 -2
- package/dist/admin/src/utils/conditionalFields.d.ts +1 -0
- package/dist/admin/src/utils/objects.d.ts +7 -4
- package/dist/admin/src/utils/validation.d.ts +2 -1
- package/dist/admin/translations/en.json.js +1 -0
- package/dist/admin/translations/en.json.js.map +1 -1
- package/dist/admin/translations/en.json.mjs +1 -0
- package/dist/admin/translations/en.json.mjs.map +1 -1
- package/dist/admin/utils/api.js +6 -1
- package/dist/admin/utils/api.js.map +1 -1
- package/dist/admin/utils/api.mjs +6 -1
- package/dist/admin/utils/api.mjs.map +1 -1
- package/dist/admin/utils/conditionalFields.js.map +1 -1
- package/dist/admin/utils/conditionalFields.mjs.map +1 -1
- package/dist/admin/utils/objects.js +43 -13
- package/dist/admin/utils/objects.js.map +1 -1
- package/dist/admin/utils/objects.mjs +43 -13
- package/dist/admin/utils/objects.mjs.map +1 -1
- package/dist/admin/utils/validation.js.map +1 -1
- package/dist/admin/utils/validation.mjs.map +1 -1
- package/dist/server/controllers/collection-types.js +4 -1
- package/dist/server/controllers/collection-types.js.map +1 -1
- package/dist/server/controllers/collection-types.mjs +4 -1
- package/dist/server/controllers/collection-types.mjs.map +1 -1
- package/dist/server/controllers/relations.js +5 -4
- package/dist/server/controllers/relations.js.map +1 -1
- package/dist/server/controllers/relations.mjs +5 -4
- package/dist/server/controllers/relations.mjs.map +1 -1
- package/dist/server/controllers/validation/model-configuration.js +3 -1
- package/dist/server/controllers/validation/model-configuration.js.map +1 -1
- package/dist/server/controllers/validation/model-configuration.mjs +3 -1
- package/dist/server/controllers/validation/model-configuration.mjs.map +1 -1
- package/dist/server/homepage/services/homepage.js +27 -7
- package/dist/server/homepage/services/homepage.js.map +1 -1
- package/dist/server/homepage/services/homepage.mjs +27 -7
- package/dist/server/homepage/services/homepage.mjs.map +1 -1
- package/dist/server/services/permission.js +4 -3
- package/dist/server/services/permission.js.map +1 -1
- package/dist/server/services/permission.mjs +4 -3
- package/dist/server/services/permission.mjs.map +1 -1
- package/dist/server/src/controllers/collection-types.d.ts.map +1 -1
- package/dist/server/src/controllers/relations.d.ts.map +1 -1
- package/dist/server/src/homepage/services/homepage.d.ts.map +1 -1
- package/dist/server/src/services/permission.d.ts.map +1 -1
- package/package.json +6 -6
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Typography } from '@strapi/design-system';\nimport { BulletList, NumberList } from '@strapi/icons';\nimport { Schema } from '@strapi/types';\nimport { type Text, Editor, Node, Transforms, Path, Element } from 'slate';\nimport { type RenderElementProps, ReactEditor } from 'slate-react';\nimport { styled, type CSSProperties, css } from 'styled-components';\n\nimport { type BlocksStore } from '../BlocksEditor';\nimport { baseHandleConvert } from '../utils/conversions';\nimport { type Block } from '../utils/types';\n\nconst listStyle = css`\n display: flex;\n flex-direction: column;\n gap: ${({ theme }) => theme.spaces[2]};\n margin-inline-start: ${({ theme }) => theme.spaces[0]};\n margin-inline-end: ${({ theme }) => theme.spaces[0]};\n padding-inline-start: ${({ theme }) => theme.spaces[2]};\n\n ol,\n ul {\n margin-block-start: ${({ theme }) => theme.spaces[0]};\n margin-block-end: ${({ theme }) => theme.spaces[0]};\n }\n\n li {\n margin-inline-start: ${({ theme }) => theme.spaces[3]};\n }\n`;\n\nconst Orderedlist = styled.ol<{ $listStyleType: CSSProperties['listStyleType'] }>`\n list-style-type: ${(props) => props.$listStyleType};\n ${listStyle}\n`;\n\nconst Unorderedlist = styled.ul<{ $listStyleType: CSSProperties['listStyleType'] }>`\n list-style-type: ${(props) => props.$listStyleType};\n ${listStyle}\n`;\n\nconst orderedStyles = ['decimal', 'lower-alpha', 'upper-roman'];\nconst unorderedStyles = ['disc', 'circle', 'square'];\n\nconst isListNode = (element: Element): element is Schema.Attribute.ListBlockNode => {\n return element.type === 'list';\n};\n\nconst List = ({ attributes, children, element }: RenderElementProps) => {\n if (!isListNode(element)) {\n return null;\n }\n\n // Decide the subsequent style by referencing the given styles according to the format,\n // allowing for infinite nested lists\n const listStyles = element.format === 'ordered' ? orderedStyles : unorderedStyles;\n const nextIndex = (element.indentLevel || 0) % listStyles!.length;\n const listStyleType = listStyles![nextIndex];\n\n if (element.format === 'ordered') {\n return (\n <Orderedlist $listStyleType={listStyleType} {...attributes}>\n {children}\n </Orderedlist>\n );\n }\n\n return (\n <Unorderedlist $listStyleType={listStyleType} {...attributes}>\n {children}\n </Unorderedlist>\n );\n};\n\nconst replaceListWithEmptyBlock = (editor: Editor, currentListPath: Path) => {\n // Delete the empty list\n Transforms.removeNodes(editor, { at: currentListPath });\n\n if (currentListPath[0] === 0) {\n // If the list was the only (or first) block element then insert empty paragraph as editor needs default value\n Transforms.insertNodes(\n editor,\n {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n },\n { at: currentListPath }\n );\n Transforms.select(editor, currentListPath);\n }\n};\n\nconst isText = (node: unknown): node is Text => {\n return Node.isNode(node) && !Editor.isEditor(node) && node.type === 'text';\n};\n\n/**\n * Common handler for the backspace event on ordered and unordered lists\n */\nconst handleBackspaceKeyOnList = (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) return;\n\n const [currentListItem, currentListItemPath] = Editor.parent(editor, editor.selection.anchor);\n const [currentList, currentListPath] = Editor.parent(editor, currentListItemPath);\n const isListEmpty =\n currentList.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isListItemEmpty =\n currentListItem.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isFocusAtTheBeginningOfAChild =\n editor.selection.focus.offset === 0 && editor.selection.focus.path.at(-2) === 0;\n\n if (isListEmpty) {\n const parentListEntry = Editor.above(editor, {\n at: currentListPath,\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n });\n if (!parentListEntry) {\n event.preventDefault();\n replaceListWithEmptyBlock(editor, currentListPath);\n }\n } else if (isFocusAtTheBeginningOfAChild) {\n // If the focus is at the beginning of a child node we need to replace it with a paragraph\n Transforms.liftNodes(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n Transforms.setNodes(editor, { type: 'paragraph' });\n } else if (isListItemEmpty) {\n const previousEntry = Editor.previous(editor, {\n at: currentListItemPath,\n });\n const nextEntry = Editor.next(editor, {\n at: currentListItemPath,\n });\n\n if (previousEntry && nextEntry) {\n // If previous and next nodes are lists or list-items, delete empty list item\n event.preventDefault();\n Transforms.removeNodes(editor, {\n at: currentListItemPath,\n });\n\n // If previous and next nodes are lists with same format and indent Levels, then merge the nodes\n const [previousList] = previousEntry;\n const [nextList] = nextEntry;\n if (\n !Editor.isEditor(previousList) &&\n !isText(previousList) &&\n isListNode(previousList) &&\n !Editor.isEditor(nextList) &&\n !isText(nextList) &&\n isListNode(nextList)\n ) {\n if (\n previousList.type === 'list' &&\n nextList.type === 'list' &&\n previousList.format === nextList.format &&\n previousList.indentLevel === nextList.indentLevel\n ) {\n Transforms.mergeNodes(editor, {\n at: currentListItemPath,\n });\n }\n }\n }\n }\n};\n\n/**\n * Common handler for the enter key on ordered and unordered lists\n */\nconst handleEnterKeyOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [currentListItem, currentListItemPath] = currentListItemEntry;\n const [currentList, currentListPath] = Editor.parent(editor, currentListItemPath);\n const isListEmpty =\n currentList.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isListItemEmpty =\n currentListItem.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isFocusAtTheBeginningOfAChild =\n editor.selection.focus.offset === 0 && editor.selection.focus.path.at(-1) === 0;\n\n if (isListEmpty) {\n replaceListWithEmptyBlock(editor, currentListPath);\n } else if (isFocusAtTheBeginningOfAChild && !isListItemEmpty) {\n // If the focus is at the beginning of a child node, shift below the list item and create a new list-item\n const currentNode = Editor.above(editor, { at: editor.selection.anchor });\n Transforms.insertNodes(editor, { type: 'list-item', children: [{ type: 'text', text: '' }] });\n if (currentNode) {\n const path = currentNode[1];\n const updatedPath = [...path.slice(0, -1), path[path.length - 1] + 1];\n Transforms.select(editor, {\n anchor: { path: updatedPath.concat(0), offset: 0 },\n focus: { path: updatedPath.concat(0), offset: 0 },\n });\n }\n } else if (isListItemEmpty) {\n // Check if there is a list above the current list and shift list-item under it\n if (\n !Editor.isEditor(currentList) &&\n isListNode(currentList) &&\n currentList?.indentLevel &&\n currentList.indentLevel > 0\n ) {\n const previousIndentLevel = currentList.indentLevel - 1;\n\n const parentListNodeEntry = Editor.above(editor, {\n match: (node) =>\n !Editor.isEditor(node) &&\n node.type === 'list' &&\n (node.indentLevel || 0) === previousIndentLevel,\n });\n\n if (parentListNodeEntry) {\n // Get the parent list path and add 1 to it to exit from the current list\n const modifiedPath = currentListItemPath.slice(0, -1);\n if (modifiedPath.length > 0) {\n modifiedPath[modifiedPath.length - 1] += 1;\n }\n\n // Shift list-item under parent list\n Transforms.moveNodes(editor, {\n at: currentListItemPath,\n to: modifiedPath,\n });\n return;\n }\n }\n\n // Otherwise delete the empty list item and create a new paragraph below the parent list\n Transforms.removeNodes(editor, { at: currentListItemPath });\n\n const createdParagraphPath = Path.next(currentListPath);\n Transforms.insertNodes(\n editor,\n {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n },\n { at: createdParagraphPath }\n );\n\n // Move the selection to the newly created paragraph\n Transforms.select(editor, createdParagraphPath);\n } else {\n // Check if the cursor is at the end of the list item\n const isNodeEnd = Editor.isEnd(editor, editor.selection.anchor, currentListItemPath);\n\n if (isNodeEnd) {\n // If there was nothing after the cursor, create a fresh new list item,\n // in order to avoid carrying over the modifiers from the previous list item\n Transforms.insertNodes(editor, { type: 'list-item', children: [{ type: 'text', text: '' }] });\n } else {\n // If there is something after the cursor, split the current list item,\n // so that we keep the content and the modifiers\n Transforms.splitNodes(editor);\n }\n }\n};\n\n/**\n * Common handler for converting a node to a list\n */\nconst handleConvertToList = (editor: Editor, format: Block<'list'>['format']) => {\n const convertedPath = baseHandleConvert<Block<'list-item'>>(editor, { type: 'list-item' });\n\n if (!convertedPath) return;\n\n Transforms.wrapNodes(editor, { type: 'list', format, children: [] }, { at: convertedPath });\n};\n\n/**\n * Common handler for the tab key on ordered and unordered lists\n */\nconst handleTabOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [currentListItem, currentListItemPath] = currentListItemEntry;\n const [currentList] = Editor.parent(editor, currentListItemPath);\n\n // Skip tabbing if list-item is the first item in the list\n if (currentListItem === currentList.children[0]) return;\n\n const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);\n const previousNode = currentList.children[currentListItemIndex - 1];\n\n // If previous node is a list block then move the list-item under it\n if (previousNode.type === 'list') {\n const nodePath = ReactEditor.findPath(editor, previousNode);\n const insertAtPath = previousNode.children.length;\n\n Transforms.moveNodes(editor, {\n at: currentListItemPath,\n to: nodePath.concat(insertAtPath),\n });\n return;\n }\n\n if (!Editor.isEditor(currentList) && isListNode(currentList)) {\n // Wrap list-item with list block on tab\n Transforms.wrapNodes(editor, {\n type: 'list',\n format: currentList.format,\n indentLevel: (currentList.indentLevel || 0) + 1,\n children: [],\n });\n }\n};\n\n/**\n * Common handler for the shift+tab key on ordered and unordered lists (un-indentation)\n */\n\nconst hasChildren = (node: any): node is { children: unknown[] } => {\n return typeof node === 'object' && node !== null && 'children' in node;\n};\n\nconst handleShiftTabOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [, currentListItemPath] = currentListItemEntry;\n\n const [currentList] = Editor.parent(editor, currentListItemPath);\n\n if (\n !Editor.isEditor(currentList) &&\n hasChildren(currentList) &&\n (currentList as any).type === 'list'\n ) {\n const parentListPath = Path.parent(currentListItemPath);\n\n const [parentList] = Editor.parent(editor, parentListPath);\n\n // Case 1: The parent of the current list is the editor itself.\n if (Editor.isEditor(parentList)) {\n // Lift the list item to the top level of the editor's children.\n Transforms.liftNodes(editor, {\n at: currentListItemPath,\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n // Change the type of the newly lifted node from 'list-item' to 'paragraph'.\n Transforms.setNodes(editor, { type: 'paragraph' });\n return;\n }\n\n // Case 2: The parent of the current list is another list.\n if (hasChildren(parentList) && (parentList as any).type === 'list') {\n Transforms.liftNodes(editor, {\n at: currentListItemPath,\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n\n try {\n const [remainingList, remainingListPath] = Editor.node(editor, parentListPath);\n\n if (\n hasChildren(remainingList) &&\n (remainingList as any).type === 'list' &&\n remainingList.children.length === 0\n ) {\n Transforms.removeNodes(editor, { at: remainingListPath });\n }\n } catch (error) {\n // The path might no longer exist if the structure changed, which is fine\n }\n }\n }\n};\n\n// All that's in common between ordered and unordered list blocks\nconst baseListBlock = {\n renderElement: (props) => <List {...props} />,\n isInBlocksSelector: true,\n handleEnterKey: handleEnterKeyOnList,\n handleBackspaceKey: handleBackspaceKeyOnList,\n handleTab: handleTabOnList,\n isDraggable: (element) => {\n if (!isListNode(element)) {\n throw Error();\n }\n const indentLevel = element.indentLevel ?? 0;\n return indentLevel === 0;\n },\n} satisfies Partial<BlocksStore['list-ordered' | 'list-unordered']>;\n\nconst listBlocks: Pick<BlocksStore, 'list-ordered' | 'list-unordered' | 'list-item'> = {\n 'list-ordered': {\n ...baseListBlock,\n label: {\n id: 'components.Blocks.blocks.orderedList',\n defaultMessage: 'Numbered list',\n },\n icon: NumberList,\n matchNode: (node) => node.type === 'list' && node.format === 'ordered',\n handleConvert: (editor) => handleConvertToList(editor, 'ordered'),\n handleShiftTab: handleShiftTabOnList,\n snippets: ['1.'],\n },\n 'list-unordered': {\n ...baseListBlock,\n label: {\n id: 'components.Blocks.blocks.unorderedList',\n defaultMessage: 'Bulleted list',\n },\n icon: BulletList,\n matchNode: (node) => node.type === 'list' && node.format === 'unordered',\n handleConvert: (editor) => handleConvertToList(editor, 'unordered'),\n handleShiftTab: handleShiftTabOnList,\n snippets: ['-', '*', '+'],\n },\n 'list-item': {\n renderElement: (props) => (\n <Typography tag=\"li\" {...props.attributes}>\n {props.children}\n </Typography>\n ),\n // No handleConvert, list items are created when converting to the parent list\n matchNode: (node) => node.type === 'list-item',\n isInBlocksSelector: false,\n dragHandleTopMargin: '-2px',\n isDraggable: () => false,\n },\n};\n\nexport { listBlocks };\n"],"names":["listStyle","css","theme","spaces","Orderedlist","styled","ol","props","$listStyleType","Unorderedlist","ul","orderedStyles","unorderedStyles","isListNode","element","type","List","attributes","children","listStyles","format","nextIndex","indentLevel","length","listStyleType","_jsx","replaceListWithEmptyBlock","editor","currentListPath","Transforms","removeNodes","at","insertNodes","text","select","isText","node","Node","isNode","Editor","isEditor","handleBackspaceKeyOnList","event","selection","currentListItem","currentListItemPath","parent","anchor","currentList","isListEmpty","isListItemEmpty","isFocusAtTheBeginningOfAChild","focus","offset","path","parentListEntry","above","match","preventDefault","liftNodes","setNodes","previousEntry","previous","nextEntry","next","previousList","nextList","mergeNodes","handleEnterKeyOnList","currentListItemEntry","currentNode","updatedPath","slice","concat","previousIndentLevel","parentListNodeEntry","modifiedPath","moveNodes","to","createdParagraphPath","Path","isNodeEnd","isEnd","splitNodes","handleConvertToList","convertedPath","baseHandleConvert","wrapNodes","handleTabOnList","currentListItemIndex","findIndex","item","previousNode","nodePath","ReactEditor","findPath","insertAtPath","hasChildren","handleShiftTabOnList","parentListPath","parentList","remainingList","remainingListPath","error","baseListBlock","renderElement","isInBlocksSelector","handleEnterKey","handleBackspaceKey","handleTab","isDraggable","Error","listBlocks","label","id","defaultMessage","icon","NumberList","matchNode","handleConvert","handleShiftTab","snippets","BulletList","Typography","tag","dragHandleTopMargin"],"mappings":";;;;;;;;;;;AAaA,MAAMA,SAAAA,GAAYC,oBAAG;;;OAGd,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;uBACjB,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;qBACnC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;wBAC9B,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;;;;wBAIjC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;sBACnC,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;;;;yBAI9B,EAAE,CAAC,EAAED,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;;AAE1D,CAAC;AAED,MAAMC,WAAAA,GAAcC,uBAAAA,CAAOC,EAAsD;AAC9D,mBAAA,EAAE,CAACC,KAAAA,GAAUA,KAAAA,CAAMC,cAAc,CAAC;AACnD,EAAA,EAAER,SAAAA;AACJ,CAAC;AAED,MAAMS,aAAAA,GAAgBJ,uBAAAA,CAAOK,EAAsD;AAChE,mBAAA,EAAE,CAACH,KAAAA,GAAUA,KAAAA,CAAMC,cAAc,CAAC;AACnD,EAAA,EAAER,SAAAA;AACJ,CAAC;AAED,MAAMW,aAAAA,GAAgB;AAAC,IAAA,SAAA;AAAW,IAAA,aAAA;AAAe,IAAA;AAAc,CAAA;AAC/D,MAAMC,eAAAA,GAAkB;AAAC,IAAA,MAAA;AAAQ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AAAA,EAAqB,MAAA;AACrBf,QAAAA,WAAAA,EAAa,IAAM;AACrB;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"List.js","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Typography } from '@strapi/design-system';\nimport { BulletList, NumberList } from '@strapi/icons';\nimport { Schema } from '@strapi/types';\nimport { type Text, Editor, Node, Transforms, Path, Element } from 'slate';\nimport { type RenderElementProps, ReactEditor } from 'slate-react';\nimport { styled, type CSSProperties, css } from 'styled-components';\n\nimport { type BlocksStore } from '../BlocksEditor';\nimport { baseHandleConvert } from '../utils/conversions';\nimport { type Block } from '../utils/types';\n\nconst listStyle = css`\n display: flex;\n flex-direction: column;\n gap: ${({ theme }) => theme.spaces[2]};\n margin-inline-start: ${({ theme }) => theme.spaces[0]};\n margin-inline-end: ${({ theme }) => theme.spaces[0]};\n padding-inline-start: ${({ theme }) => theme.spaces[2]};\n\n ol,\n ul {\n margin-block-start: ${({ theme }) => theme.spaces[0]};\n margin-block-end: ${({ theme }) => theme.spaces[0]};\n }\n\n li {\n margin-inline-start: ${({ theme }) => theme.spaces[3]};\n }\n`;\n\nconst Orderedlist = styled.ol<{ $listStyleType: CSSProperties['listStyleType'] }>`\n list-style-type: ${(props) => props.$listStyleType};\n ${listStyle}\n`;\n\nconst Unorderedlist = styled.ul<{ $listStyleType: CSSProperties['listStyleType'] }>`\n list-style-type: ${(props) => props.$listStyleType};\n ${listStyle}\n`;\n\nconst orderedStyles = ['decimal', 'lower-alpha', 'upper-roman'];\nconst unorderedStyles = ['disc', 'circle', 'square'];\n\nconst isListNode = (element: Element): element is Schema.Attribute.ListBlockNode => {\n return element.type === 'list';\n};\n\nconst List = ({ attributes, children, element }: RenderElementProps) => {\n if (!isListNode(element)) {\n return null;\n }\n\n // Decide the subsequent style by referencing the given styles according to the format,\n // allowing for infinite nested lists\n const listStyles = element.format === 'ordered' ? orderedStyles : unorderedStyles;\n const nextIndex = (element.indentLevel || 0) % listStyles!.length;\n const listStyleType = listStyles![nextIndex];\n\n if (element.format === 'ordered') {\n return (\n <Orderedlist $listStyleType={listStyleType} {...attributes}>\n {children}\n </Orderedlist>\n );\n }\n\n return (\n <Unorderedlist $listStyleType={listStyleType} {...attributes}>\n {children}\n </Unorderedlist>\n );\n};\n\nconst replaceListWithEmptyBlock = (editor: Editor, currentListPath: Path) => {\n // Delete the empty list\n Transforms.removeNodes(editor, { at: currentListPath });\n\n if (currentListPath[0] === 0) {\n // If the list was the only (or first) block element then insert empty paragraph as editor needs default value\n Transforms.insertNodes(\n editor,\n {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n },\n { at: currentListPath }\n );\n Transforms.select(editor, currentListPath);\n }\n};\n\nconst isText = (node: unknown): node is Text => {\n return Node.isNode(node) && !Editor.isEditor(node) && node.type === 'text';\n};\n\n/**\n * Common handler for the backspace event on ordered and unordered lists\n */\nconst handleBackspaceKeyOnList = (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) return;\n\n const [currentListItem, currentListItemPath] = Editor.parent(editor, editor.selection.anchor);\n const [currentList, currentListPath] = Editor.parent(editor, currentListItemPath);\n const isListEmpty =\n currentList.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isListItemEmpty =\n currentListItem.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isFocusAtTheBeginningOfAChild =\n editor.selection.focus.offset === 0 && editor.selection.focus.path.at(-2) === 0;\n\n if (isListEmpty) {\n const parentListEntry = Editor.above(editor, {\n at: currentListPath,\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n });\n if (!parentListEntry) {\n event.preventDefault();\n replaceListWithEmptyBlock(editor, currentListPath);\n }\n } else if (isFocusAtTheBeginningOfAChild) {\n // If the focus is at the beginning of a child node we need to replace it with a paragraph\n Transforms.liftNodes(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n Transforms.setNodes(editor, { type: 'paragraph' });\n } else if (isListItemEmpty) {\n const previousEntry = Editor.previous(editor, {\n at: currentListItemPath,\n });\n const nextEntry = Editor.next(editor, {\n at: currentListItemPath,\n });\n\n if (previousEntry && nextEntry) {\n // If previous and next nodes are lists or list-items, delete empty list item\n event.preventDefault();\n Transforms.removeNodes(editor, {\n at: currentListItemPath,\n });\n\n // If previous and next nodes are lists with same format and indent Levels, then merge the nodes\n const [previousList] = previousEntry;\n const [nextList] = nextEntry;\n if (\n !Editor.isEditor(previousList) &&\n !isText(previousList) &&\n isListNode(previousList) &&\n !Editor.isEditor(nextList) &&\n !isText(nextList) &&\n isListNode(nextList)\n ) {\n if (\n previousList.type === 'list' &&\n nextList.type === 'list' &&\n previousList.format === nextList.format &&\n previousList.indentLevel === nextList.indentLevel\n ) {\n Transforms.mergeNodes(editor, {\n at: currentListItemPath,\n });\n }\n }\n }\n }\n};\n\n/**\n * Common handler for the enter key on ordered and unordered lists\n */\nconst handleEnterKeyOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [currentListItem, currentListItemPath] = currentListItemEntry;\n const [currentList, currentListPath] = Editor.parent(editor, currentListItemPath);\n const isListEmpty =\n currentList.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isListItemEmpty =\n currentListItem.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isFocusAtTheBeginningOfAChild =\n editor.selection.focus.offset === 0 && editor.selection.focus.path.at(-1) === 0;\n\n if (isListEmpty) {\n replaceListWithEmptyBlock(editor, currentListPath);\n } else if (isFocusAtTheBeginningOfAChild && !isListItemEmpty) {\n // If the focus is at the beginning of a child node, shift below the list item and create a new list-item\n const currentNode = Editor.above(editor, { at: editor.selection.anchor });\n Transforms.insertNodes(editor, { type: 'list-item', children: [{ type: 'text', text: '' }] });\n if (currentNode) {\n const path = currentNode[1];\n const updatedPath = [...path.slice(0, -1), path[path.length - 1] + 1];\n Transforms.select(editor, {\n anchor: { path: updatedPath.concat(0), offset: 0 },\n focus: { path: updatedPath.concat(0), offset: 0 },\n });\n }\n } else if (isListItemEmpty) {\n // Check if there is a list above the current list and shift list-item under it\n if (\n !Editor.isEditor(currentList) &&\n isListNode(currentList) &&\n currentList?.indentLevel &&\n currentList.indentLevel > 0\n ) {\n const previousIndentLevel = currentList.indentLevel - 1;\n\n const parentListNodeEntry = Editor.above(editor, {\n match: (node) =>\n !Editor.isEditor(node) &&\n node.type === 'list' &&\n (node.indentLevel || 0) === previousIndentLevel,\n });\n\n if (parentListNodeEntry) {\n // Get the parent list path and add 1 to it to exit from the current list\n const modifiedPath = currentListItemPath.slice(0, -1);\n if (modifiedPath.length > 0) {\n modifiedPath[modifiedPath.length - 1] += 1;\n }\n\n // Shift list-item under parent list\n Transforms.moveNodes(editor, {\n at: currentListItemPath,\n to: modifiedPath,\n });\n return;\n }\n }\n\n // Otherwise delete the empty list item and create a new paragraph below the parent list\n Transforms.removeNodes(editor, { at: currentListItemPath });\n\n const createdParagraphPath = Path.next(currentListPath);\n Transforms.insertNodes(\n editor,\n {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n },\n { at: createdParagraphPath }\n );\n\n // Move the selection to the newly created paragraph\n Transforms.select(editor, createdParagraphPath);\n } else {\n // Check if the cursor is at the end of the list item\n const isNodeEnd = Editor.isEnd(editor, editor.selection.anchor, currentListItemPath);\n\n if (isNodeEnd) {\n // If there was nothing after the cursor, create a fresh new list item,\n // in order to avoid carrying over the modifiers from the previous list item\n Transforms.insertNodes(editor, { type: 'list-item', children: [{ type: 'text', text: '' }] });\n } else {\n // If there is something after the cursor, split the current list item,\n // so that we keep the content and the modifiers\n Transforms.splitNodes(editor);\n }\n }\n};\n\n/**\n * Common handler for converting a node to a list\n */\nconst handleConvertToList = (editor: Editor, format: Block<'list'>['format']) => {\n const convertedPath = baseHandleConvert<Block<'list-item'>>(editor, { type: 'list-item' });\n\n if (!convertedPath) return;\n\n Transforms.wrapNodes(editor, { type: 'list', format, children: [] }, { at: convertedPath });\n};\n\n/**\n * Common handler for the tab key on ordered and unordered lists\n */\nconst handleTabOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [currentListItem, currentListItemPath] = currentListItemEntry;\n const [currentList] = Editor.parent(editor, currentListItemPath);\n\n // Skip tabbing if list-item is the first item in the list\n if (currentListItem === currentList.children[0]) return;\n\n const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);\n const previousNode = currentList.children[currentListItemIndex - 1];\n\n // If previous node is a list block then move the list-item under it\n if (previousNode.type === 'list') {\n const nodePath = ReactEditor.findPath(editor, previousNode);\n const insertAtPath = previousNode.children.length;\n\n Transforms.moveNodes(editor, {\n at: currentListItemPath,\n to: nodePath.concat(insertAtPath),\n });\n return;\n }\n\n if (!Editor.isEditor(currentList) && isListNode(currentList)) {\n // Wrap list-item with list block on tab\n Transforms.wrapNodes(editor, {\n type: 'list',\n format: currentList.format,\n indentLevel: (currentList.indentLevel || 0) + 1,\n children: [],\n });\n }\n};\n\n/**\n * Common handler for the shift+tab key on ordered and unordered lists (un-indentation)\n */\n\nconst hasChildren = (node: unknown): node is { children: unknown[] } => {\n return typeof node === 'object' && node !== null && 'children' in node;\n};\n\nconst isNestedListNode = (node: unknown): node is { type: 'list'; children: unknown[] } => {\n return hasChildren(node) && 'type' in node && node.type === 'list';\n};\n\nconst handleShiftTabOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [, currentListItemPath] = currentListItemEntry;\n\n const [currentList] = Editor.parent(editor, currentListItemPath);\n\n if (!Editor.isEditor(currentList) && isNestedListNode(currentList)) {\n const parentListPath = Path.parent(currentListItemPath);\n\n const [parentList] = Editor.parent(editor, parentListPath);\n\n // Case 1: The parent of the current list is the editor itself.\n if (Editor.isEditor(parentList)) {\n // Lift the list item to the top level of the editor's children.\n Transforms.liftNodes(editor, {\n at: currentListItemPath,\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n // Change the type of the newly lifted node from 'list-item' to 'paragraph'.\n Transforms.setNodes(editor, { type: 'paragraph' });\n return;\n }\n\n // Case 2: The parent of the current list is another list.\n if (isNestedListNode(parentList)) {\n Transforms.liftNodes(editor, {\n at: currentListItemPath,\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n\n try {\n const [remainingList, remainingListPath] = Editor.node(editor, parentListPath);\n\n if (isNestedListNode(remainingList) && remainingList.children.length === 0) {\n Transforms.removeNodes(editor, { at: remainingListPath });\n }\n } catch (error) {\n // The path might no longer exist if the structure changed, which is fine\n }\n }\n }\n};\n\n// All that's in common between ordered and unordered list blocks\nconst baseListBlock = {\n renderElement: (props) => <List {...props} />,\n isInBlocksSelector: true,\n handleEnterKey: handleEnterKeyOnList,\n handleBackspaceKey: handleBackspaceKeyOnList,\n handleTab: handleTabOnList,\n isDraggable: (element) => {\n if (!isListNode(element)) {\n throw Error();\n }\n const indentLevel = element.indentLevel ?? 0;\n return indentLevel === 0;\n },\n} satisfies Partial<BlocksStore['list-ordered' | 'list-unordered']>;\n\nconst listBlocks: Pick<BlocksStore, 'list-ordered' | 'list-unordered' | 'list-item'> = {\n 'list-ordered': {\n ...baseListBlock,\n label: {\n id: 'components.Blocks.blocks.orderedList',\n defaultMessage: 'Numbered list',\n },\n icon: NumberList,\n matchNode: (node) => node.type === 'list' && node.format === 'ordered',\n handleConvert: (editor) => handleConvertToList(editor, 'ordered'),\n handleShiftTab: handleShiftTabOnList,\n snippets: ['1.'],\n },\n 'list-unordered': {\n ...baseListBlock,\n label: {\n id: 'components.Blocks.blocks.unorderedList',\n defaultMessage: 'Bulleted list',\n },\n icon: BulletList,\n matchNode: (node) => node.type === 'list' && node.format === 'unordered',\n handleConvert: (editor) => handleConvertToList(editor, 'unordered'),\n handleShiftTab: handleShiftTabOnList,\n snippets: ['-', '*', '+'],\n },\n 'list-item': {\n renderElement: (props) => (\n <Typography tag=\"li\" {...props.attributes}>\n {props.children}\n </Typography>\n ),\n // No handleConvert, list items are created when converting to the parent list\n matchNode: (node) => node.type === 'list-item',\n isInBlocksSelector: false,\n dragHandleTopMargin: '-2px',\n isDraggable: () => false,\n },\n};\n\nexport { listBlocks };\n"],"names":["listStyle","css","theme","spaces","Orderedlist","styled","ol","props","$listStyleType","Unorderedlist","ul","orderedStyles","unorderedStyles","isListNode","element","type","List","attributes","children","listStyles","format","nextIndex","indentLevel","length","listStyleType","_jsx","replaceListWithEmptyBlock","editor","currentListPath","Transforms","removeNodes","at","insertNodes","text","select","isText","node","Node","isNode","Editor","isEditor","handleBackspaceKeyOnList","event","selection","currentListItem","currentListItemPath","parent","anchor","currentList","isListEmpty","isListItemEmpty","isFocusAtTheBeginningOfAChild","focus","offset","path","parentListEntry","above","match","preventDefault","liftNodes","setNodes","previousEntry","previous","nextEntry","next","previousList","nextList","mergeNodes","handleEnterKeyOnList","currentListItemEntry","currentNode","updatedPath","slice","concat","previousIndentLevel","parentListNodeEntry","modifiedPath","moveNodes","to","createdParagraphPath","Path","isNodeEnd","isEnd","splitNodes","handleConvertToList","convertedPath","baseHandleConvert","wrapNodes","handleTabOnList","currentListItemIndex","findIndex","item","previousNode","nodePath","ReactEditor","findPath","insertAtPath","hasChildren","isNestedListNode","handleShiftTabOnList","parentListPath","parentList","remainingList","remainingListPath","error","baseListBlock","renderElement","isInBlocksSelector","handleEnterKey","handleBackspaceKey","handleTab","isDraggable","Error","listBlocks","label","id","defaultMessage","icon","NumberList","matchNode","handleConvert","handleShiftTab","snippets","BulletList","Typ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AqB,MAAA;AACrBf,QAAAA,WAAAA,EAAa,IAAM;AACrB;AACF;;;;"}
|
|
@@ -307,6 +307,9 @@ const isText = (node)=>{
|
|
|
307
307
|
*/ const hasChildren = (node)=>{
|
|
308
308
|
return typeof node === 'object' && node !== null && 'children' in node;
|
|
309
309
|
};
|
|
310
|
+
const isNestedListNode = (node)=>{
|
|
311
|
+
return hasChildren(node) && 'type' in node && node.type === 'list';
|
|
312
|
+
};
|
|
310
313
|
const handleShiftTabOnList = (editor)=>{
|
|
311
314
|
const currentListItemEntry = Editor.above(editor, {
|
|
312
315
|
match: (node)=>!Editor.isEditor(node) && 'type' in node && node.type === 'list-item'
|
|
@@ -316,7 +319,7 @@ const handleShiftTabOnList = (editor)=>{
|
|
|
316
319
|
}
|
|
317
320
|
const [, currentListItemPath] = currentListItemEntry;
|
|
318
321
|
const [currentList] = Editor.parent(editor, currentListItemPath);
|
|
319
|
-
if (!Editor.isEditor(currentList) &&
|
|
322
|
+
if (!Editor.isEditor(currentList) && isNestedListNode(currentList)) {
|
|
320
323
|
const parentListPath = Path.parent(currentListItemPath);
|
|
321
324
|
const [parentList] = Editor.parent(editor, parentListPath);
|
|
322
325
|
// Case 1: The parent of the current list is the editor itself.
|
|
@@ -333,14 +336,14 @@ const handleShiftTabOnList = (editor)=>{
|
|
|
333
336
|
return;
|
|
334
337
|
}
|
|
335
338
|
// Case 2: The parent of the current list is another list.
|
|
336
|
-
if (
|
|
339
|
+
if (isNestedListNode(parentList)) {
|
|
337
340
|
Transforms.liftNodes(editor, {
|
|
338
341
|
at: currentListItemPath,
|
|
339
342
|
match: (node)=>!Editor.isEditor(node) && 'type' in node && node.type === 'list-item'
|
|
340
343
|
});
|
|
341
344
|
try {
|
|
342
345
|
const [remainingList, remainingListPath] = Editor.node(editor, parentListPath);
|
|
343
|
-
if (
|
|
346
|
+
if (isNestedListNode(remainingList) && remainingList.children.length === 0) {
|
|
344
347
|
Transforms.removeNodes(editor, {
|
|
345
348
|
at: remainingListPath
|
|
346
349
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.mjs","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/List.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Typography } from '@strapi/design-system';\nimport { BulletList, NumberList } from '@strapi/icons';\nimport { Schema } from '@strapi/types';\nimport { type Text, Editor, Node, Transforms, Path, Element } from 'slate';\nimport { type RenderElementProps, ReactEditor } from 'slate-react';\nimport { styled, type CSSProperties, css } from 'styled-components';\n\nimport { type BlocksStore } from '../BlocksEditor';\nimport { baseHandleConvert } from '../utils/conversions';\nimport { type Block } from '../utils/types';\n\nconst listStyle = css`\n display: flex;\n flex-direction: column;\n gap: ${({ theme }) => theme.spaces[2]};\n margin-inline-start: ${({ theme }) => theme.spaces[0]};\n margin-inline-end: ${({ theme }) => theme.spaces[0]};\n padding-inline-start: ${({ theme }) => theme.spaces[2]};\n\n ol,\n ul {\n margin-block-start: ${({ theme }) => theme.spaces[0]};\n margin-block-end: ${({ theme }) => theme.spaces[0]};\n }\n\n li {\n margin-inline-start: ${({ theme }) => theme.spaces[3]};\n }\n`;\n\nconst Orderedlist = styled.ol<{ $listStyleType: CSSProperties['listStyleType'] }>`\n list-style-type: ${(props) => props.$listStyleType};\n ${listStyle}\n`;\n\nconst Unorderedlist = styled.ul<{ $listStyleType: CSSProperties['listStyleType'] }>`\n list-style-type: ${(props) => props.$listStyleType};\n ${listStyle}\n`;\n\nconst orderedStyles = ['decimal', 'lower-alpha', 'upper-roman'];\nconst unorderedStyles = ['disc', 'circle', 'square'];\n\nconst isListNode = (element: Element): element is Schema.Attribute.ListBlockNode => {\n return element.type === 'list';\n};\n\nconst List = ({ attributes, children, element }: RenderElementProps) => {\n if (!isListNode(element)) {\n return null;\n }\n\n // Decide the subsequent style by referencing the given styles according to the format,\n // allowing for infinite nested lists\n const listStyles = element.format === 'ordered' ? orderedStyles : unorderedStyles;\n const nextIndex = (element.indentLevel || 0) % listStyles!.length;\n const listStyleType = listStyles![nextIndex];\n\n if (element.format === 'ordered') {\n return (\n <Orderedlist $listStyleType={listStyleType} {...attributes}>\n {children}\n </Orderedlist>\n );\n }\n\n return (\n <Unorderedlist $listStyleType={listStyleType} {...attributes}>\n {children}\n </Unorderedlist>\n );\n};\n\nconst replaceListWithEmptyBlock = (editor: Editor, currentListPath: Path) => {\n // Delete the empty list\n Transforms.removeNodes(editor, { at: currentListPath });\n\n if (currentListPath[0] === 0) {\n // If the list was the only (or first) block element then insert empty paragraph as editor needs default value\n Transforms.insertNodes(\n editor,\n {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n },\n { at: currentListPath }\n );\n Transforms.select(editor, currentListPath);\n }\n};\n\nconst isText = (node: unknown): node is Text => {\n return Node.isNode(node) && !Editor.isEditor(node) && node.type === 'text';\n};\n\n/**\n * Common handler for the backspace event on ordered and unordered lists\n */\nconst handleBackspaceKeyOnList = (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) return;\n\n const [currentListItem, currentListItemPath] = Editor.parent(editor, editor.selection.anchor);\n const [currentList, currentListPath] = Editor.parent(editor, currentListItemPath);\n const isListEmpty =\n currentList.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isListItemEmpty =\n currentListItem.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isFocusAtTheBeginningOfAChild =\n editor.selection.focus.offset === 0 && editor.selection.focus.path.at(-2) === 0;\n\n if (isListEmpty) {\n const parentListEntry = Editor.above(editor, {\n at: currentListPath,\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n });\n if (!parentListEntry) {\n event.preventDefault();\n replaceListWithEmptyBlock(editor, currentListPath);\n }\n } else if (isFocusAtTheBeginningOfAChild) {\n // If the focus is at the beginning of a child node we need to replace it with a paragraph\n Transforms.liftNodes(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n Transforms.setNodes(editor, { type: 'paragraph' });\n } else if (isListItemEmpty) {\n const previousEntry = Editor.previous(editor, {\n at: currentListItemPath,\n });\n const nextEntry = Editor.next(editor, {\n at: currentListItemPath,\n });\n\n if (previousEntry && nextEntry) {\n // If previous and next nodes are lists or list-items, delete empty list item\n event.preventDefault();\n Transforms.removeNodes(editor, {\n at: currentListItemPath,\n });\n\n // If previous and next nodes are lists with same format and indent Levels, then merge the nodes\n const [previousList] = previousEntry;\n const [nextList] = nextEntry;\n if (\n !Editor.isEditor(previousList) &&\n !isText(previousList) &&\n isListNode(previousList) &&\n !Editor.isEditor(nextList) &&\n !isText(nextList) &&\n isListNode(nextList)\n ) {\n if (\n previousList.type === 'list' &&\n nextList.type === 'list' &&\n previousList.format === nextList.format &&\n previousList.indentLevel === nextList.indentLevel\n ) {\n Transforms.mergeNodes(editor, {\n at: currentListItemPath,\n });\n }\n }\n }\n }\n};\n\n/**\n * Common handler for the enter key on ordered and unordered lists\n */\nconst handleEnterKeyOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [currentListItem, currentListItemPath] = currentListItemEntry;\n const [currentList, currentListPath] = Editor.parent(editor, currentListItemPath);\n const isListEmpty =\n currentList.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isListItemEmpty =\n currentListItem.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isFocusAtTheBeginningOfAChild =\n editor.selection.focus.offset === 0 && editor.selection.focus.path.at(-1) === 0;\n\n if (isListEmpty) {\n replaceListWithEmptyBlock(editor, currentListPath);\n } else if (isFocusAtTheBeginningOfAChild && !isListItemEmpty) {\n // If the focus is at the beginning of a child node, shift below the list item and create a new list-item\n const currentNode = Editor.above(editor, { at: editor.selection.anchor });\n Transforms.insertNodes(editor, { type: 'list-item', children: [{ type: 'text', text: '' }] });\n if (currentNode) {\n const path = currentNode[1];\n const updatedPath = [...path.slice(0, -1), path[path.length - 1] + 1];\n Transforms.select(editor, {\n anchor: { path: updatedPath.concat(0), offset: 0 },\n focus: { path: updatedPath.concat(0), offset: 0 },\n });\n }\n } else if (isListItemEmpty) {\n // Check if there is a list above the current list and shift list-item under it\n if (\n !Editor.isEditor(currentList) &&\n isListNode(currentList) &&\n currentList?.indentLevel &&\n currentList.indentLevel > 0\n ) {\n const previousIndentLevel = currentList.indentLevel - 1;\n\n const parentListNodeEntry = Editor.above(editor, {\n match: (node) =>\n !Editor.isEditor(node) &&\n node.type === 'list' &&\n (node.indentLevel || 0) === previousIndentLevel,\n });\n\n if (parentListNodeEntry) {\n // Get the parent list path and add 1 to it to exit from the current list\n const modifiedPath = currentListItemPath.slice(0, -1);\n if (modifiedPath.length > 0) {\n modifiedPath[modifiedPath.length - 1] += 1;\n }\n\n // Shift list-item under parent list\n Transforms.moveNodes(editor, {\n at: currentListItemPath,\n to: modifiedPath,\n });\n return;\n }\n }\n\n // Otherwise delete the empty list item and create a new paragraph below the parent list\n Transforms.removeNodes(editor, { at: currentListItemPath });\n\n const createdParagraphPath = Path.next(currentListPath);\n Transforms.insertNodes(\n editor,\n {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n },\n { at: createdParagraphPath }\n );\n\n // Move the selection to the newly created paragraph\n Transforms.select(editor, createdParagraphPath);\n } else {\n // Check if the cursor is at the end of the list item\n const isNodeEnd = Editor.isEnd(editor, editor.selection.anchor, currentListItemPath);\n\n if (isNodeEnd) {\n // If there was nothing after the cursor, create a fresh new list item,\n // in order to avoid carrying over the modifiers from the previous list item\n Transforms.insertNodes(editor, { type: 'list-item', children: [{ type: 'text', text: '' }] });\n } else {\n // If there is something after the cursor, split the current list item,\n // so that we keep the content and the modifiers\n Transforms.splitNodes(editor);\n }\n }\n};\n\n/**\n * Common handler for converting a node to a list\n */\nconst handleConvertToList = (editor: Editor, format: Block<'list'>['format']) => {\n const convertedPath = baseHandleConvert<Block<'list-item'>>(editor, { type: 'list-item' });\n\n if (!convertedPath) return;\n\n Transforms.wrapNodes(editor, { type: 'list', format, children: [] }, { at: convertedPath });\n};\n\n/**\n * Common handler for the tab key on ordered and unordered lists\n */\nconst handleTabOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [currentListItem, currentListItemPath] = currentListItemEntry;\n const [currentList] = Editor.parent(editor, currentListItemPath);\n\n // Skip tabbing if list-item is the first item in the list\n if (currentListItem === currentList.children[0]) return;\n\n const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);\n const previousNode = currentList.children[currentListItemIndex - 1];\n\n // If previous node is a list block then move the list-item under it\n if (previousNode.type === 'list') {\n const nodePath = ReactEditor.findPath(editor, previousNode);\n const insertAtPath = previousNode.children.length;\n\n Transforms.moveNodes(editor, {\n at: currentListItemPath,\n to: nodePath.concat(insertAtPath),\n });\n return;\n }\n\n if (!Editor.isEditor(currentList) && isListNode(currentList)) {\n // Wrap list-item with list block on tab\n Transforms.wrapNodes(editor, {\n type: 'list',\n format: currentList.format,\n indentLevel: (currentList.indentLevel || 0) + 1,\n children: [],\n });\n }\n};\n\n/**\n * Common handler for the shift+tab key on ordered and unordered lists (un-indentation)\n */\n\nconst hasChildren = (node: any): node is { children: unknown[] } => {\n return typeof node === 'object' && node !== null && 'children' in node;\n};\n\nconst handleShiftTabOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [, currentListItemPath] = currentListItemEntry;\n\n const [currentList] = Editor.parent(editor, currentListItemPath);\n\n if (\n !Editor.isEditor(currentList) &&\n hasChildren(currentList) &&\n (currentList as any).type === 'list'\n ) {\n const parentListPath = Path.parent(currentListItemPath);\n\n const [parentList] = Editor.parent(editor, parentListPath);\n\n // Case 1: The parent of the current list is the editor itself.\n if (Editor.isEditor(parentList)) {\n // Lift the list item to the top level of the editor's children.\n Transforms.liftNodes(editor, {\n at: currentListItemPath,\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n // Change the type of the newly lifted node from 'list-item' to 'paragraph'.\n Transforms.setNodes(editor, { type: 'paragraph' });\n return;\n }\n\n // Case 2: The parent of the current list is another list.\n if (hasChildren(parentList) && (parentList as any).type === 'list') {\n Transforms.liftNodes(editor, {\n at: currentListItemPath,\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n\n try {\n const [remainingList, remainingListPath] = Editor.node(editor, parentListPath);\n\n if (\n hasChildren(remainingList) &&\n (remainingList as any).type === 'list' &&\n remainingList.children.length === 0\n ) {\n Transforms.removeNodes(editor, { at: remainingListPath });\n }\n } catch (error) {\n // The path might no longer exist if the structure changed, which is fine\n }\n }\n }\n};\n\n// All that's in common between ordered and unordered list blocks\nconst baseListBlock = {\n renderElement: (props) => <List {...props} />,\n isInBlocksSelector: true,\n handleEnterKey: handleEnterKeyOnList,\n handleBackspaceKey: handleBackspaceKeyOnList,\n handleTab: handleTabOnList,\n isDraggable: (element) => {\n if (!isListNode(element)) {\n throw Error();\n }\n const indentLevel = element.indentLevel ?? 0;\n return indentLevel === 0;\n },\n} satisfies Partial<BlocksStore['list-ordered' | 'list-unordered']>;\n\nconst listBlocks: Pick<BlocksStore, 'list-ordered' | 'list-unordered' | 'list-item'> = {\n 'list-ordered': {\n ...baseListBlock,\n label: {\n id: 'components.Blocks.blocks.orderedList',\n defaultMessage: 'Numbered list',\n },\n icon: NumberList,\n matchNode: (node) => node.type === 'list' && node.format === 'ordered',\n handleConvert: (editor) => handleConvertToList(editor, 'ordered'),\n handleShiftTab: handleShiftTabOnList,\n snippets: ['1.'],\n },\n 'list-unordered': {\n ...baseListBlock,\n label: {\n id: 'components.Blocks.blocks.unorderedList',\n defaultMessage: 'Bulleted list',\n },\n icon: BulletList,\n matchNode: (node) => node.type === 'list' && node.format === 'unordered',\n handleConvert: (editor) => handleConvertToList(editor, 'unordered'),\n handleShiftTab: handleShiftTabOnList,\n snippets: ['-', '*', '+'],\n },\n 'list-item': {\n renderElement: (props) => (\n <Typography tag=\"li\" {...props.attributes}>\n {props.children}\n </Typography>\n ),\n // No handleConvert, list items are created when converting to the parent list\n matchNode: (node) => node.type === 'list-item',\n isInBlocksSelector: false,\n dragHandleTopMargin: '-2px',\n isDraggable: () => false,\n },\n};\n\nexport { listBlocks };\n"],"names":["listStyle","css","theme","spaces","Orderedlist","styled","ol","props","$listStyleType","Unorderedlist","ul","orderedStyles","unorderedStyles","isListNode","element","type","List","attributes","children","listStyles","format","nextIndex","indentLevel","length","listStyleType","_jsx","replaceListWithEmptyBlock","editor","currentListPath","Transforms","removeNodes","at","insertNodes","text","select","isText","node","Node","isNode","Editor","isEditor","handleBackspaceKeyOnList","event","selection","currentListItem","currentListItemPath","parent","anchor","currentList","isListEmpty","isListItemEmpty","isFocusAtTheBeginningOfAChild","focus","offset","path","parentListEntry","above","match","preventDefault","liftNodes","setNodes","previousEntry","previous","nextEntry","next","previousList","nextList","mergeNodes","handleEnterKeyOnList","currentListItemEntry","currentNode","updatedPath","slice","concat","previousIndentLevel","parentListNodeEntry","modifiedPath","moveNodes","to","createdParagraphPath","Path","isNodeEnd","isEnd","splitNodes","handleConvertToList","convertedPath","baseHandleConvert","wrapNodes","handleTabOnList","currentListItemIndex","findIndex","item","previousNode","nodePath","ReactEditor","findPath","insertAtPath","hasChildren","handleShiftTabOnList","parentListPath","parentList","remainingList","remainingListPath","error","baseListBlock","renderElement","isInBlocksSelector","handleEnterKey","handleBackspaceKey","handleTab","isDraggable","Error","listBlocks","label","id","defaultMessage","icon","NumberList","matchNode","handleConvert","handleShiftTab","snippets","BulletList","Typography","tag","dragHandleTopMargin"],"mappings":";;;;;;;;;AAaA,MAAMA,SAAAA,G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/List.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Typography } from '@strapi/design-system';\nimport { BulletList, NumberList } from '@strapi/icons';\nimport { Schema } from '@strapi/types';\nimport { type Text, Editor, Node, Transforms, Path, Element } from 'slate';\nimport { type RenderElementProps, ReactEditor } from 'slate-react';\nimport { styled, type CSSProperties, css } from 'styled-components';\n\nimport { type BlocksStore } from '../BlocksEditor';\nimport { baseHandleConvert } from '../utils/conversions';\nimport { type Block } from '../utils/types';\n\nconst listStyle = css`\n display: flex;\n flex-direction: column;\n gap: ${({ theme }) => theme.spaces[2]};\n margin-inline-start: ${({ theme }) => theme.spaces[0]};\n margin-inline-end: ${({ theme }) => theme.spaces[0]};\n padding-inline-start: ${({ theme }) => theme.spaces[2]};\n\n ol,\n ul {\n margin-block-start: ${({ theme }) => theme.spaces[0]};\n margin-block-end: ${({ theme }) => theme.spaces[0]};\n }\n\n li {\n margin-inline-start: ${({ theme }) => theme.spaces[3]};\n }\n`;\n\nconst Orderedlist = styled.ol<{ $listStyleType: CSSProperties['listStyleType'] }>`\n list-style-type: ${(props) => props.$listStyleType};\n ${listStyle}\n`;\n\nconst Unorderedlist = styled.ul<{ $listStyleType: CSSProperties['listStyleType'] }>`\n list-style-type: ${(props) => props.$listStyleType};\n ${listStyle}\n`;\n\nconst orderedStyles = ['decimal', 'lower-alpha', 'upper-roman'];\nconst unorderedStyles = ['disc', 'circle', 'square'];\n\nconst isListNode = (element: Element): element is Schema.Attribute.ListBlockNode => {\n return element.type === 'list';\n};\n\nconst List = ({ attributes, children, element }: RenderElementProps) => {\n if (!isListNode(element)) {\n return null;\n }\n\n // Decide the subsequent style by referencing the given styles according to the format,\n // allowing for infinite nested lists\n const listStyles = element.format === 'ordered' ? orderedStyles : unorderedStyles;\n const nextIndex = (element.indentLevel || 0) % listStyles!.length;\n const listStyleType = listStyles![nextIndex];\n\n if (element.format === 'ordered') {\n return (\n <Orderedlist $listStyleType={listStyleType} {...attributes}>\n {children}\n </Orderedlist>\n );\n }\n\n return (\n <Unorderedlist $listStyleType={listStyleType} {...attributes}>\n {children}\n </Unorderedlist>\n );\n};\n\nconst replaceListWithEmptyBlock = (editor: Editor, currentListPath: Path) => {\n // Delete the empty list\n Transforms.removeNodes(editor, { at: currentListPath });\n\n if (currentListPath[0] === 0) {\n // If the list was the only (or first) block element then insert empty paragraph as editor needs default value\n Transforms.insertNodes(\n editor,\n {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n },\n { at: currentListPath }\n );\n Transforms.select(editor, currentListPath);\n }\n};\n\nconst isText = (node: unknown): node is Text => {\n return Node.isNode(node) && !Editor.isEditor(node) && node.type === 'text';\n};\n\n/**\n * Common handler for the backspace event on ordered and unordered lists\n */\nconst handleBackspaceKeyOnList = (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) return;\n\n const [currentListItem, currentListItemPath] = Editor.parent(editor, editor.selection.anchor);\n const [currentList, currentListPath] = Editor.parent(editor, currentListItemPath);\n const isListEmpty =\n currentList.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isListItemEmpty =\n currentListItem.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isFocusAtTheBeginningOfAChild =\n editor.selection.focus.offset === 0 && editor.selection.focus.path.at(-2) === 0;\n\n if (isListEmpty) {\n const parentListEntry = Editor.above(editor, {\n at: currentListPath,\n match: (node) => !Editor.isEditor(node) && node.type === 'list',\n });\n if (!parentListEntry) {\n event.preventDefault();\n replaceListWithEmptyBlock(editor, currentListPath);\n }\n } else if (isFocusAtTheBeginningOfAChild) {\n // If the focus is at the beginning of a child node we need to replace it with a paragraph\n Transforms.liftNodes(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n Transforms.setNodes(editor, { type: 'paragraph' });\n } else if (isListItemEmpty) {\n const previousEntry = Editor.previous(editor, {\n at: currentListItemPath,\n });\n const nextEntry = Editor.next(editor, {\n at: currentListItemPath,\n });\n\n if (previousEntry && nextEntry) {\n // If previous and next nodes are lists or list-items, delete empty list item\n event.preventDefault();\n Transforms.removeNodes(editor, {\n at: currentListItemPath,\n });\n\n // If previous and next nodes are lists with same format and indent Levels, then merge the nodes\n const [previousList] = previousEntry;\n const [nextList] = nextEntry;\n if (\n !Editor.isEditor(previousList) &&\n !isText(previousList) &&\n isListNode(previousList) &&\n !Editor.isEditor(nextList) &&\n !isText(nextList) &&\n isListNode(nextList)\n ) {\n if (\n previousList.type === 'list' &&\n nextList.type === 'list' &&\n previousList.format === nextList.format &&\n previousList.indentLevel === nextList.indentLevel\n ) {\n Transforms.mergeNodes(editor, {\n at: currentListItemPath,\n });\n }\n }\n }\n }\n};\n\n/**\n * Common handler for the enter key on ordered and unordered lists\n */\nconst handleEnterKeyOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [currentListItem, currentListItemPath] = currentListItemEntry;\n const [currentList, currentListPath] = Editor.parent(editor, currentListItemPath);\n const isListEmpty =\n currentList.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isListItemEmpty =\n currentListItem.children.length === 1 &&\n isText(currentListItem.children[0]) &&\n currentListItem.children[0].text === '';\n const isFocusAtTheBeginningOfAChild =\n editor.selection.focus.offset === 0 && editor.selection.focus.path.at(-1) === 0;\n\n if (isListEmpty) {\n replaceListWithEmptyBlock(editor, currentListPath);\n } else if (isFocusAtTheBeginningOfAChild && !isListItemEmpty) {\n // If the focus is at the beginning of a child node, shift below the list item and create a new list-item\n const currentNode = Editor.above(editor, { at: editor.selection.anchor });\n Transforms.insertNodes(editor, { type: 'list-item', children: [{ type: 'text', text: '' }] });\n if (currentNode) {\n const path = currentNode[1];\n const updatedPath = [...path.slice(0, -1), path[path.length - 1] + 1];\n Transforms.select(editor, {\n anchor: { path: updatedPath.concat(0), offset: 0 },\n focus: { path: updatedPath.concat(0), offset: 0 },\n });\n }\n } else if (isListItemEmpty) {\n // Check if there is a list above the current list and shift list-item under it\n if (\n !Editor.isEditor(currentList) &&\n isListNode(currentList) &&\n currentList?.indentLevel &&\n currentList.indentLevel > 0\n ) {\n const previousIndentLevel = currentList.indentLevel - 1;\n\n const parentListNodeEntry = Editor.above(editor, {\n match: (node) =>\n !Editor.isEditor(node) &&\n node.type === 'list' &&\n (node.indentLevel || 0) === previousIndentLevel,\n });\n\n if (parentListNodeEntry) {\n // Get the parent list path and add 1 to it to exit from the current list\n const modifiedPath = currentListItemPath.slice(0, -1);\n if (modifiedPath.length > 0) {\n modifiedPath[modifiedPath.length - 1] += 1;\n }\n\n // Shift list-item under parent list\n Transforms.moveNodes(editor, {\n at: currentListItemPath,\n to: modifiedPath,\n });\n return;\n }\n }\n\n // Otherwise delete the empty list item and create a new paragraph below the parent list\n Transforms.removeNodes(editor, { at: currentListItemPath });\n\n const createdParagraphPath = Path.next(currentListPath);\n Transforms.insertNodes(\n editor,\n {\n type: 'paragraph',\n children: [{ type: 'text', text: '' }],\n },\n { at: createdParagraphPath }\n );\n\n // Move the selection to the newly created paragraph\n Transforms.select(editor, createdParagraphPath);\n } else {\n // Check if the cursor is at the end of the list item\n const isNodeEnd = Editor.isEnd(editor, editor.selection.anchor, currentListItemPath);\n\n if (isNodeEnd) {\n // If there was nothing after the cursor, create a fresh new list item,\n // in order to avoid carrying over the modifiers from the previous list item\n Transforms.insertNodes(editor, { type: 'list-item', children: [{ type: 'text', text: '' }] });\n } else {\n // If there is something after the cursor, split the current list item,\n // so that we keep the content and the modifiers\n Transforms.splitNodes(editor);\n }\n }\n};\n\n/**\n * Common handler for converting a node to a list\n */\nconst handleConvertToList = (editor: Editor, format: Block<'list'>['format']) => {\n const convertedPath = baseHandleConvert<Block<'list-item'>>(editor, { type: 'list-item' });\n\n if (!convertedPath) return;\n\n Transforms.wrapNodes(editor, { type: 'list', format, children: [] }, { at: convertedPath });\n};\n\n/**\n * Common handler for the tab key on ordered and unordered lists\n */\nconst handleTabOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [currentListItem, currentListItemPath] = currentListItemEntry;\n const [currentList] = Editor.parent(editor, currentListItemPath);\n\n // Skip tabbing if list-item is the first item in the list\n if (currentListItem === currentList.children[0]) return;\n\n const currentListItemIndex = currentList.children.findIndex((item) => item === currentListItem);\n const previousNode = currentList.children[currentListItemIndex - 1];\n\n // If previous node is a list block then move the list-item under it\n if (previousNode.type === 'list') {\n const nodePath = ReactEditor.findPath(editor, previousNode);\n const insertAtPath = previousNode.children.length;\n\n Transforms.moveNodes(editor, {\n at: currentListItemPath,\n to: nodePath.concat(insertAtPath),\n });\n return;\n }\n\n if (!Editor.isEditor(currentList) && isListNode(currentList)) {\n // Wrap list-item with list block on tab\n Transforms.wrapNodes(editor, {\n type: 'list',\n format: currentList.format,\n indentLevel: (currentList.indentLevel || 0) + 1,\n children: [],\n });\n }\n};\n\n/**\n * Common handler for the shift+tab key on ordered and unordered lists (un-indentation)\n */\n\nconst hasChildren = (node: unknown): node is { children: unknown[] } => {\n return typeof node === 'object' && node !== null && 'children' in node;\n};\n\nconst isNestedListNode = (node: unknown): node is { type: 'list'; children: unknown[] } => {\n return hasChildren(node) && 'type' in node && node.type === 'list';\n};\n\nconst handleShiftTabOnList = (editor: Editor) => {\n const currentListItemEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n\n if (!currentListItemEntry || !editor.selection) {\n return;\n }\n\n const [, currentListItemPath] = currentListItemEntry;\n\n const [currentList] = Editor.parent(editor, currentListItemPath);\n\n if (!Editor.isEditor(currentList) && isNestedListNode(currentList)) {\n const parentListPath = Path.parent(currentListItemPath);\n\n const [parentList] = Editor.parent(editor, parentListPath);\n\n // Case 1: The parent of the current list is the editor itself.\n if (Editor.isEditor(parentList)) {\n // Lift the list item to the top level of the editor's children.\n Transforms.liftNodes(editor, {\n at: currentListItemPath,\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n // Change the type of the newly lifted node from 'list-item' to 'paragraph'.\n Transforms.setNodes(editor, { type: 'paragraph' });\n return;\n }\n\n // Case 2: The parent of the current list is another list.\n if (isNestedListNode(parentList)) {\n Transforms.liftNodes(editor, {\n at: currentListItemPath,\n match: (node) => !Editor.isEditor(node) && 'type' in node && node.type === 'list-item',\n });\n\n try {\n const [remainingList, remainingListPath] = Editor.node(editor, parentListPath);\n\n if (isNestedListNode(remainingList) && remainingList.children.length === 0) {\n Transforms.removeNodes(editor, { at: remainingListPath });\n }\n } catch (error) {\n // The path might no longer exist if the structure changed, which is fine\n }\n }\n }\n};\n\n// All that's in common between ordered and unordered list blocks\nconst baseListBlock = {\n renderElement: (props) => <List {...props} />,\n isInBlocksSelector: true,\n handleEnterKey: handleEnterKeyOnList,\n handleBackspaceKey: handleBackspaceKeyOnList,\n handleTab: handleTabOnList,\n isDraggable: (element) => {\n if (!isListNode(element)) {\n throw Error();\n }\n const indentLevel = element.indentLevel ?? 0;\n return indentLevel === 0;\n },\n} satisfies Partial<BlocksStore['list-ordered' | 'list-unordered']>;\n\nconst listBlocks: Pick<BlocksStore, 'list-ordered' | 'list-unordered' | 'list-item'> = {\n 'list-ordered': {\n ...baseListBlock,\n label: {\n id: 'components.Blocks.blocks.orderedList',\n defaultMessage: 'Numbered list',\n },\n icon: NumberList,\n matchNode: (node) => node.type === 'list' && node.format === 'ordered',\n handleConvert: (editor) => handleConvertToList(editor, 'ordered'),\n handleShiftTab: handleShiftTabOnList,\n snippets: ['1.'],\n },\n 'list-unordered': {\n ...baseListBlock,\n label: {\n id: 'components.Blocks.blocks.unorderedList',\n defaultMessage: 'Bulleted list',\n },\n icon: BulletList,\n matchNode: (node) => node.type === 'list' && node.format === 'unordered',\n handleConvert: (editor) => handleConvertToList(editor, 'unordered'),\n handleShiftTab: handleShiftTabOnList,\n snippets: ['-', '*', '+'],\n },\n 'list-item': {\n renderElement: (props) => (\n <Typography tag=\"li\" {...props.attributes}>\n {props.children}\n </Typography>\n ),\n // No handleConvert, list items are created when converting to the parent list\n matchNode: (node) => node.type === 'list-item',\n isInBlocksSelector: false,\n dragHandleTopMargin: '-2px',\n isDraggable: () => false,\n },\n};\n\nexport { listBlocks };\n"],"names":["listStyle","css","theme","spaces","Orderedlist","styled","ol","props","$listStyleType","Unorderedlist","ul","orderedStyles","unorderedStyles","isListNode","element","type","List","attributes","children","listStyles","format","nextIndex","indentLevel","length","listStyleType","_jsx","replaceListWithEmptyBlock","editor","currentListPath","Transforms","removeNodes","at","insertNodes","text","select","isText","node","Node","isNode","Editor","isEditor","handleBackspaceKeyOnList","event","selection","currentListItem","currentListItemPath","parent","anchor","currentList","isListEmpty","isListItemEmpty","isFocusAtTheBeginningOfAChild","focus","offset","path","parentListEntry","above","match","preventDefault","liftNodes","setNodes","previousEntry","previous","nextEntry","next","previousList","nextList","mergeNodes","handleEnterKeyOnList","currentListItemEntry","currentNode","updatedPath","slice","concat","previousIndentLevel","parentListNodeEntry","modifiedPath","moveNodes","to","createdParagraphPath","Path","isNodeEnd","isEnd","splitNodes","handleConvertToList","convertedPath","baseHandleConvert","wrapNodes","handleTabOnList","currentListItemIndex","findIndex","item","previousNode","nodePath","ReactEditor","findPath","insertAtPath","hasChildren","isNestedListNode","handleShiftTabOnList","parentListPath","parentList","remainingList","remainingListPath","error","baseListBlock","renderElement","isInBlocksSelector","handleEnterKey","handleBackspaceKey","handleTab","isDraggable","Error","listBlocks","label","id","defaultMessage","icon","NumberList","matchNode","handleConvert","handleShiftTab","snippets","BulletList","Typography","tag","dragHandleTopMargin"],"mappings":";;;;;;;;;AAaA,MAAMA,SAAAA,GAAYC,GAAG;;;OAGd,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,C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AAKrB,IAAI,KAAK,MAAA,IAAUqB,IAAAA,CAAKhB,MAAM,KAAK,SAAA;QAC7DoG,aAAAA,EAAe,CAAC7F,MAAAA,GAAWyD,mBAAAA,CAAoBzD,MAAAA,EAAQ,SAAA,CAAA;QACvD8F,cAAAA,EAAgBtB,oBAAAA;QAChBuB,QAAAA,EAAU;AAAC,YAAA;AAAK;AAClB,KAAA;IACA,gBAAA,EAAkB;AAChB,QAAA,GAAGjB,aAAa;QAChBS,KAAAA,EAAO;YACLC,EAAAA,EAAI,wCAAA;YACJC,cAAAA,EAAgB;AAClB,SAAA;QACAC,IAAAA,EAAMM,UAAAA;QACNJ,SAAAA,EAAW,CAACnF,OAASA,IAAAA,CAAKrB,IAAI,KAAK,MAAA,IAAUqB,IAAAA,CAAKhB,MAAM,KAAK,WAAA;QAC7DoG,aAAAA,EAAe,CAAC7F,MAAAA,GAAWyD,mBAAAA,CAAoBzD,MAAAA,EAAQ,WAAA,CAAA;QACvD8F,cAAAA,EAAgBtB,oBAAAA;QAChBuB,QAAAA,EAAU;AAAC,YAAA,GAAA;AAAK,YAAA,GAAA;AAAK,YAAA;AAAI;AAC3B,KAAA;IACA,WAAA,EAAa;QACXhB,aAAAA,EAAe,CAACnG,sBACdkB,GAAA,CAACmG,UAAAA,EAAAA;gBAAWC,GAAAA,EAAI,IAAA;AAAM,gBAAA,GAAGtH,MAAMU,UAAU;AACtCV,gBAAAA,QAAAA,EAAAA,KAAAA,CAAMW;;;AAIXqG,QAAAA,SAAAA,EAAW,CAACnF,IAAAA,GAASA,IAAAA,CAAKrB,IAAI,KAAK,WAAA;QACnC4F,kBAAAA,EAAoB,KAAA;QACpBmB,mBAAAA,EAAqB,MAAA;AACrBf,QAAAA,WAAAA,EAAa,IAAM;AACrB;AACF;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlocksInput.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useField, type InputProps } from '@strapi/admin/strapi-admin';\nimport { Field, Flex } from '@strapi/design-system';\n\nimport { BlocksEditor } from './BlocksEditor';\n\nimport type { Schema } from '@strapi/types';\n\ninterface BlocksInputProps extends Omit<InputProps, 'type'> {\n labelAction?: React.ReactNode;\n type: Schema.Attribute.Blocks['type'];\n}\n\nconst BlocksInput = React.forwardRef<{ focus: () => void }, BlocksInputProps>(\n ({ label, name, required = false, hint, labelAction, ...editorProps }, forwardedRef) => {\n const id = React.useId();\n const field = useField(name);\n\n return (\n <Field.Root id={id} name={name} hint={hint} error={field.error} required={required}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <Field.Label action={labelAction}>{label}</Field.Label>\n <BlocksEditor\n name={name}\n error={field.error}\n ref={forwardedRef}\n value={field.value}\n onChange={field.onChange}\n ariaLabelId={id}\n {...editorProps}\n />\n <Field.Hint />\n <Field.Error />\n </Flex>\n </Field.Root>\n );\n }\n);\n\nconst MemoizedBlocksInput = React.memo(BlocksInput);\n\nexport { MemoizedBlocksInput as BlocksInput };\n"],"names":["BlocksInput","React","forwardRef","label","name","required","hint","labelAction","editorProps","forwardedRef","id","useId","field","useField","_jsx","Field","Root","error","_jsxs","Flex","direction","alignItems","gap","Label","action","BlocksEditor","ref","value","onChange","ariaLabelId","Hint","Error","MemoizedBlocksInput","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAMA,4BAAcC,gBAAAA,CAAMC,UAAU,CAClC,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAAA,GAAW,KAAK,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGC,aAAa,EAAEC,YAAAA,GAAAA;IACrE,MAAMC,EAAAA,GAAKT,iBAAMU,KAAK,EAAA;AACtB,IAAA,MAAMC,QAAQC,oBAAAA,
|
|
1
|
+
{"version":3,"file":"BlocksInput.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useField, type InputProps } from '@strapi/admin/strapi-admin';\nimport { Field, Flex } from '@strapi/design-system';\n\nimport { BlocksEditor } from './BlocksEditor';\n\nimport type { Schema } from '@strapi/types';\n\ninterface BlocksInputProps extends Omit<InputProps, 'type'> {\n labelAction?: React.ReactNode;\n type: Schema.Attribute.Blocks['type'];\n}\n\nconst BlocksInput = React.forwardRef<{ focus: () => void }, BlocksInputProps>(\n ({ label, name, required = false, hint, labelAction, ...editorProps }, forwardedRef) => {\n const id = React.useId();\n const field = useField<Schema.Attribute.BlocksValue>(name);\n\n return (\n <Field.Root id={id} name={name} hint={hint} error={field.error} required={required}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <Field.Label action={labelAction}>{label}</Field.Label>\n <BlocksEditor\n name={name}\n error={field.error}\n ref={forwardedRef}\n value={field.value ?? []}\n onChange={field.onChange}\n ariaLabelId={id}\n {...editorProps}\n />\n <Field.Hint />\n <Field.Error />\n </Flex>\n </Field.Root>\n );\n }\n);\n\nconst MemoizedBlocksInput = React.memo(BlocksInput);\n\nexport { MemoizedBlocksInput as BlocksInput };\n"],"names":["BlocksInput","React","forwardRef","label","name","required","hint","labelAction","editorProps","forwardedRef","id","useId","field","useField","_jsx","Field","Root","error","_jsxs","Flex","direction","alignItems","gap","Label","action","BlocksEditor","ref","value","onChange","ariaLabelId","Hint","Error","MemoizedBlocksInput","memo"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAcA,MAAMA,4BAAcC,gBAAAA,CAAMC,UAAU,CAClC,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAAA,GAAW,KAAK,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGC,aAAa,EAAEC,YAAAA,GAAAA;IACrE,MAAMC,EAAAA,GAAKT,iBAAMU,KAAK,EAAA;AACtB,IAAA,MAAMC,QAAQC,oBAAAA,CAAuCT,IAAAA,CAAAA;IAErD,qBACEU,cAAA,CAACC,mBAAMC,IAAI,EAAA;QAACN,EAAAA,EAAIA,EAAAA;QAAIN,IAAAA,EAAMA,IAAAA;QAAME,IAAAA,EAAMA,IAAAA;AAAMW,QAAAA,KAAAA,EAAOL,MAAMK,KAAK;QAAEZ,QAAAA,EAAUA,QAAAA;AACxE,QAAA,QAAA,gBAAAa,eAAA,CAACC,iBAAAA,EAAAA;YAAKC,SAAAA,EAAU,QAAA;YAASC,UAAAA,EAAW,SAAA;YAAUC,GAAAA,EAAK,CAAA;;AACjD,8BAAAR,cAAA,CAACC,mBAAMQ,KAAK,EAAA;oBAACC,MAAAA,EAAQjB,WAAAA;AAAcJ,oBAAAA,QAAAA,EAAAA;;8BACnCW,cAAA,CAACW,yBAAAA,EAAAA;oBACCrB,IAAAA,EAAMA,IAAAA;AACNa,oBAAAA,KAAAA,EAAOL,MAAMK,KAAK;oBAClBS,GAAAA,EAAKjB,YAAAA;oBACLkB,KAAAA,EAAOf,KAAAA,CAAMe,KAAK,IAAI,EAAE;AACxBC,oBAAAA,QAAAA,EAAUhB,MAAMgB,QAAQ;oBACxBC,WAAAA,EAAanB,EAAAA;AACZ,oBAAA,GAAGF;;AAEN,8BAAAM,cAAA,CAACC,mBAAMe,IAAI,EAAA,EAAA,CAAA;AACX,8BAAAhB,cAAA,CAACC,mBAAMgB,KAAK,EAAA,EAAA;;;;AAIpB,CAAA,CAAA;AAGF,MAAMC,mBAAAA,iBAAsB/B,gBAAAA,CAAMgC,IAAI,CAACjC,WAAAA;;;;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlocksInput.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useField, type InputProps } from '@strapi/admin/strapi-admin';\nimport { Field, Flex } from '@strapi/design-system';\n\nimport { BlocksEditor } from './BlocksEditor';\n\nimport type { Schema } from '@strapi/types';\n\ninterface BlocksInputProps extends Omit<InputProps, 'type'> {\n labelAction?: React.ReactNode;\n type: Schema.Attribute.Blocks['type'];\n}\n\nconst BlocksInput = React.forwardRef<{ focus: () => void }, BlocksInputProps>(\n ({ label, name, required = false, hint, labelAction, ...editorProps }, forwardedRef) => {\n const id = React.useId();\n const field = useField(name);\n\n return (\n <Field.Root id={id} name={name} hint={hint} error={field.error} required={required}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <Field.Label action={labelAction}>{label}</Field.Label>\n <BlocksEditor\n name={name}\n error={field.error}\n ref={forwardedRef}\n value={field.value}\n onChange={field.onChange}\n ariaLabelId={id}\n {...editorProps}\n />\n <Field.Hint />\n <Field.Error />\n </Flex>\n </Field.Root>\n );\n }\n);\n\nconst MemoizedBlocksInput = React.memo(BlocksInput);\n\nexport { MemoizedBlocksInput as BlocksInput };\n"],"names":["BlocksInput","React","forwardRef","label","name","required","hint","labelAction","editorProps","forwardedRef","id","useId","field","useField","_jsx","Field","Root","error","_jsxs","Flex","direction","alignItems","gap","Label","action","BlocksEditor","ref","value","onChange","ariaLabelId","Hint","Error","MemoizedBlocksInput","memo"],"mappings":";;;;;;AAcA,MAAMA,4BAAcC,KAAAA,CAAMC,UAAU,CAClC,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAAA,GAAW,KAAK,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGC,aAAa,EAAEC,YAAAA,GAAAA;IACrE,MAAMC,EAAAA,GAAKT,MAAMU,KAAK,EAAA;AACtB,IAAA,MAAMC,QAAQC,QAAAA,
|
|
1
|
+
{"version":3,"file":"BlocksInput.mjs","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksInput.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useField, type InputProps } from '@strapi/admin/strapi-admin';\nimport { Field, Flex } from '@strapi/design-system';\n\nimport { BlocksEditor } from './BlocksEditor';\n\nimport type { Schema } from '@strapi/types';\n\ninterface BlocksInputProps extends Omit<InputProps, 'type'> {\n labelAction?: React.ReactNode;\n type: Schema.Attribute.Blocks['type'];\n}\n\nconst BlocksInput = React.forwardRef<{ focus: () => void }, BlocksInputProps>(\n ({ label, name, required = false, hint, labelAction, ...editorProps }, forwardedRef) => {\n const id = React.useId();\n const field = useField<Schema.Attribute.BlocksValue>(name);\n\n return (\n <Field.Root id={id} name={name} hint={hint} error={field.error} required={required}>\n <Flex direction=\"column\" alignItems=\"stretch\" gap={1}>\n <Field.Label action={labelAction}>{label}</Field.Label>\n <BlocksEditor\n name={name}\n error={field.error}\n ref={forwardedRef}\n value={field.value ?? []}\n onChange={field.onChange}\n ariaLabelId={id}\n {...editorProps}\n />\n <Field.Hint />\n <Field.Error />\n </Flex>\n </Field.Root>\n );\n }\n);\n\nconst MemoizedBlocksInput = React.memo(BlocksInput);\n\nexport { MemoizedBlocksInput as BlocksInput };\n"],"names":["BlocksInput","React","forwardRef","label","name","required","hint","labelAction","editorProps","forwardedRef","id","useId","field","useField","_jsx","Field","Root","error","_jsxs","Flex","direction","alignItems","gap","Label","action","BlocksEditor","ref","value","onChange","ariaLabelId","Hint","Error","MemoizedBlocksInput","memo"],"mappings":";;;;;;AAcA,MAAMA,4BAAcC,KAAAA,CAAMC,UAAU,CAClC,CAAC,EAAEC,KAAK,EAAEC,IAAI,EAAEC,QAAAA,GAAW,KAAK,EAAEC,IAAI,EAAEC,WAAW,EAAE,GAAGC,aAAa,EAAEC,YAAAA,GAAAA;IACrE,MAAMC,EAAAA,GAAKT,MAAMU,KAAK,EAAA;AACtB,IAAA,MAAMC,QAAQC,QAAAA,CAAuCT,IAAAA,CAAAA;IAErD,qBACEU,GAAA,CAACC,MAAMC,IAAI,EAAA;QAACN,EAAAA,EAAIA,EAAAA;QAAIN,IAAAA,EAAMA,IAAAA;QAAME,IAAAA,EAAMA,IAAAA;AAAMW,QAAAA,KAAAA,EAAOL,MAAMK,KAAK;QAAEZ,QAAAA,EAAUA,QAAAA;AACxE,QAAA,QAAA,gBAAAa,IAAA,CAAC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