@strapi/content-manager 5.45.1 → 5.46.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.
Files changed (145) hide show
  1. package/dist/admin/constants/hooks.js +5 -0
  2. package/dist/admin/constants/hooks.js.map +1 -1
  3. package/dist/admin/constants/hooks.mjs +5 -0
  4. package/dist/admin/constants/hooks.mjs.map +1 -1
  5. package/dist/admin/content-manager.js +26 -2
  6. package/dist/admin/content-manager.js.map +1 -1
  7. package/dist/admin/content-manager.mjs +26 -2
  8. package/dist/admin/content-manager.mjs.map +1 -1
  9. package/dist/admin/history/components/VersionInputRenderer.js +1 -1
  10. package/dist/admin/history/components/VersionInputRenderer.js.map +1 -1
  11. package/dist/admin/history/components/VersionInputRenderer.mjs +1 -1
  12. package/dist/admin/history/components/VersionInputRenderer.mjs.map +1 -1
  13. package/dist/admin/hooks/usePersistentQueryParams.js +4 -1
  14. package/dist/admin/hooks/usePersistentQueryParams.js.map +1 -1
  15. package/dist/admin/hooks/usePersistentQueryParams.mjs +4 -1
  16. package/dist/admin/hooks/usePersistentQueryParams.mjs.map +1 -1
  17. package/dist/admin/pages/ComponentConfigurationPage.js +2 -45
  18. package/dist/admin/pages/ComponentConfigurationPage.js.map +1 -1
  19. package/dist/admin/pages/ComponentConfigurationPage.mjs +3 -46
  20. package/dist/admin/pages/ComponentConfigurationPage.mjs.map +1 -1
  21. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.js +21 -4
  22. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.js.map +1 -1
  23. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.mjs +19 -2
  24. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.mjs.map +1 -1
  25. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/Blocks/Link.mjs +1 -1
  26. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js +9 -6
  27. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.js.map +1 -1
  28. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs +10 -7
  29. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.mjs.map +1 -1
  30. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js +1 -34
  31. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
  32. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs +3 -35
  33. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
  34. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js +33 -18
  35. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.js.map +1 -1
  36. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs +34 -19
  37. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksToolbar.mjs.map +1 -1
  38. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore.js +22 -0
  39. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore.js.map +1 -0
  40. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore.mjs +20 -0
  41. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore.mjs.map +1 -0
  42. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js +15 -4
  43. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.js.map +1 -1
  44. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs +16 -5
  45. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/ComponentCategory.mjs.map +1 -1
  46. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js +26 -4
  47. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.js.map +1 -1
  48. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs +26 -4
  49. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.mjs.map +1 -1
  50. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js +31 -0
  51. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.js.map +1 -1
  52. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs +31 -0
  53. package/dist/admin/pages/EditView/components/FormInputs/DynamicZone/Field.mjs.map +1 -1
  54. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.js +11 -3
  55. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.js.map +1 -1
  56. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.mjs +11 -3
  57. package/dist/admin/pages/ListConfiguration/ListConfigurationPage.mjs.map +1 -1
  58. package/dist/admin/pages/ListView/ListViewPage.js +1 -0
  59. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  60. package/dist/admin/pages/ListView/ListViewPage.mjs +1 -0
  61. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  62. package/dist/admin/pages/ListView/components/Filters.js +38 -4
  63. package/dist/admin/pages/ListView/components/Filters.js.map +1 -1
  64. package/dist/admin/pages/ListView/components/Filters.mjs +39 -5
  65. package/dist/admin/pages/ListView/components/Filters.mjs.map +1 -1
  66. package/dist/admin/pages/formatComponentConfigurationEditLayout.js +58 -0
  67. package/dist/admin/pages/formatComponentConfigurationEditLayout.js.map +1 -0
  68. package/dist/admin/pages/formatComponentConfigurationEditLayout.mjs +56 -0
  69. package/dist/admin/pages/formatComponentConfigurationEditLayout.mjs.map +1 -0
  70. package/dist/admin/preview/components/InputPopover.js +3 -0
  71. package/dist/admin/preview/components/InputPopover.js.map +1 -1
  72. package/dist/admin/preview/components/InputPopover.mjs +3 -0
  73. package/dist/admin/preview/components/InputPopover.mjs.map +1 -1
  74. package/dist/admin/preview/hooks/usePreviewInputManager.js +24 -0
  75. package/dist/admin/preview/hooks/usePreviewInputManager.js.map +1 -1
  76. package/dist/admin/preview/hooks/usePreviewInputManager.mjs +24 -0
  77. package/dist/admin/preview/hooks/usePreviewInputManager.mjs.map +1 -1
  78. package/dist/admin/preview/utils/previewScript.js +616 -78
  79. package/dist/admin/preview/utils/previewScript.js.map +1 -1
  80. package/dist/admin/preview/utils/previewScript.mjs +616 -78
  81. package/dist/admin/preview/utils/previewScript.mjs.map +1 -1
  82. package/dist/admin/src/constants/hooks.d.ts +23 -0
  83. package/dist/admin/src/content-manager.d.ts +26 -0
  84. package/dist/admin/src/exports.d.ts +2 -0
  85. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.d.ts +14 -8
  86. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/DefaultBlocksStore.d.ts +3 -0
  87. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/ComponentCard.d.ts +1 -1
  88. package/dist/admin/src/pages/EditView/components/FormInputs/DynamicZone/DynamicComponent.d.ts +11 -1
  89. package/dist/admin/src/pages/EditView/components/FormInputs/Relations/Relations.d.ts +9 -5
  90. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.d.ts +4 -2
  91. package/dist/admin/src/pages/EditView/components/FormInputs/Wysiwyg/WysiwygStyles.d.ts +38 -6
  92. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +27 -5
  93. package/dist/admin/src/pages/ListView/components/Filters.d.ts +3 -4
  94. package/dist/admin/src/pages/formatComponentConfigurationEditLayout.d.ts +15 -0
  95. package/dist/admin/translations/cs.json.js +0 -1
  96. package/dist/admin/translations/cs.json.js.map +1 -1
  97. package/dist/admin/translations/cs.json.mjs +0 -1
  98. package/dist/admin/translations/cs.json.mjs.map +1 -1
  99. package/dist/admin/translations/de.json.js +0 -1
  100. package/dist/admin/translations/de.json.js.map +1 -1
  101. package/dist/admin/translations/de.json.mjs +0 -1
  102. package/dist/admin/translations/de.json.mjs.map +1 -1
  103. package/dist/admin/translations/en.json.js +0 -1
  104. package/dist/admin/translations/en.json.js.map +1 -1
  105. package/dist/admin/translations/en.json.mjs +0 -1
  106. package/dist/admin/translations/en.json.mjs.map +1 -1
  107. package/dist/admin/translations/es.json.js +0 -1
  108. package/dist/admin/translations/es.json.js.map +1 -1
  109. package/dist/admin/translations/es.json.mjs +0 -1
  110. package/dist/admin/translations/es.json.mjs.map +1 -1
  111. package/dist/admin/translations/fr.json.js +0 -1
  112. package/dist/admin/translations/fr.json.js.map +1 -1
  113. package/dist/admin/translations/fr.json.mjs +0 -1
  114. package/dist/admin/translations/fr.json.mjs.map +1 -1
  115. package/dist/admin/translations/nl.json.js +0 -1
  116. package/dist/admin/translations/nl.json.js.map +1 -1
  117. package/dist/admin/translations/nl.json.mjs +0 -1
  118. package/dist/admin/translations/nl.json.mjs.map +1 -1
  119. package/dist/admin/translations/pl.json.js +0 -1
  120. package/dist/admin/translations/pl.json.js.map +1 -1
  121. package/dist/admin/translations/pl.json.mjs +0 -1
  122. package/dist/admin/translations/pl.json.mjs.map +1 -1
  123. package/dist/admin/translations/ru.json.js +0 -1
  124. package/dist/admin/translations/ru.json.js.map +1 -1
  125. package/dist/admin/translations/ru.json.mjs +0 -1
  126. package/dist/admin/translations/ru.json.mjs.map +1 -1
  127. package/dist/admin/translations/uk.json.js +0 -1
  128. package/dist/admin/translations/uk.json.js.map +1 -1
  129. package/dist/admin/translations/uk.json.mjs +0 -1
  130. package/dist/admin/translations/uk.json.mjs.map +1 -1
  131. package/dist/admin/translations/zh-Hans.json.js +0 -1
  132. package/dist/admin/translations/zh-Hans.json.js.map +1 -1
  133. package/dist/admin/translations/zh-Hans.json.mjs +0 -1
  134. package/dist/admin/translations/zh-Hans.json.mjs.map +1 -1
  135. package/dist/server/homepage/services/homepage.js +12 -8
  136. package/dist/server/homepage/services/homepage.js.map +1 -1
  137. package/dist/server/homepage/services/homepage.mjs +12 -8
  138. package/dist/server/homepage/services/homepage.mjs.map +1 -1
  139. package/dist/server/services/metrics.js +1 -5
  140. package/dist/server/services/metrics.js.map +1 -1
  141. package/dist/server/services/metrics.mjs +1 -5
  142. package/dist/server/services/metrics.mjs.map +1 -1
  143. package/dist/server/src/homepage/services/homepage.d.ts.map +1 -1
  144. package/dist/server/src/services/metrics.d.ts.map +1 -1
  145. package/package.json +7 -7
@@ -4,7 +4,7 @@ var jsxRuntime = require('react/jsx-runtime');
4
4
  var React = require('react');
5
5
  var designSystem = require('@strapi/design-system');
6
6
  var Icons = require('@strapi/icons');
7
- var Prism = require('prismjs');
7
+ var PrismModule = require('prismjs');
8
8
  var reactIntl = require('react-intl');
9
9
  var slate = require('slate');
10
10
  var slateReact = require('slate-react');
@@ -82,19 +82,36 @@ function _interopNamespaceDefault(e) {
82
82
  }
83
83
 
84
84
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
85
- var Prism__namespace = /*#__PURE__*/_interopNamespaceDefault(Prism);
85
+ var PrismModule__namespace = /*#__PURE__*/_interopNamespaceDefault(PrismModule);
86
86
 
87
+ /**
88
+ * prismjs is UMD and may not expose a namespace when bundled by Vite; the content-manager
89
+ * index preloads it so `window.Prism` is set. Use that when the module import is empty.
90
+ */ function resolvePrism() {
91
+ if (typeof PrismModule__namespace !== 'undefined' && PrismModule__namespace?.languages) {
92
+ return PrismModule__namespace;
93
+ }
94
+ if (typeof window === 'undefined') {
95
+ return undefined;
96
+ }
97
+ const globalPrism = window.Prism;
98
+ return globalPrism;
99
+ }
100
+ const Prism = resolvePrism();
87
101
  const decorateCode = ([node, path])=>{
88
102
  const ranges = [];
103
+ // Prism can be undefined when the UMD bundle doesn't expose a namespace and window.Prism
104
+ // isn't set yet (e.g. this chunk ran before the content-manager preload). Skip decoration.
105
+ if (!Prism?.languages) return ranges;
89
106
  // make sure it is an Slate Element
90
107
  if (!slate.Element.isElement(node) || node.type !== 'code') return ranges;
91
108
  // transform the Element into a string
92
109
  const text = slate.Node.string(node);
93
110
  const language = constants.codeLanguages.find((lang)=>lang.value === node.language);
94
111
  const decorateKey = language?.decorate ?? language?.value;
95
- const selectedLanguage = Prism__namespace.languages[decorateKey || 'plaintext'];
112
+ const selectedLanguage = Prism.languages[decorateKey || 'plaintext'];
96
113
  // create "tokens" with "prismjs" and put them in "ranges"
97
- const tokens = Prism__namespace.tokenize(text, selectedLanguage);
114
+ const tokens = Prism.tokenize(text, selectedLanguage);
98
115
  let start = 0;
99
116
  for (const token of tokens){
100
117
  const length = token.length;
@@ -1 +1 @@
1
- {"version":3,"file":"Code.js","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, SingleSelect, SingleSelectOption } from '@strapi/design-system';\nimport { CodeBlock as CodeBlockIcon } from '@strapi/icons';\nimport * as Prism from 'prismjs';\nimport { useIntl } from 'react-intl';\nimport { BaseRange, Element, Editor, Node, NodeEntry, Transforms } from 'slate';\nimport { useSelected, type RenderElementProps, useFocused, ReactEditor } from 'slate-react';\nimport { styled } from 'styled-components';\n\nimport { useBlocksEditorContext, type BlocksStore } from '../BlocksEditor';\nimport { codeLanguages } from '../utils/constants';\nimport { baseHandleConvert } from '../utils/conversions';\nimport { pressEnterTwiceToExit } from '../utils/enterKey';\nimport { type Block } from '../utils/types';\n\nimport 'prismjs/themes/prism-solarizedlight.css';\nimport 'prismjs/components/prism-asmatmel';\nimport 'prismjs/components/prism-bash';\nimport 'prismjs/components/prism-basic';\nimport 'prismjs/components/prism-c';\nimport 'prismjs/components/prism-clojure';\nimport 'prismjs/components/prism-cobol';\nimport 'prismjs/components/prism-cpp';\nimport 'prismjs/components/prism-csharp';\nimport 'prismjs/components/prism-dart';\nimport 'prismjs/components/prism-docker';\nimport 'prismjs/components/prism-elixir';\nimport 'prismjs/components/prism-erlang';\nimport 'prismjs/components/prism-fortran';\nimport 'prismjs/components/prism-fsharp';\nimport 'prismjs/components/prism-go';\nimport 'prismjs/components/prism-graphql';\nimport 'prismjs/components/prism-groovy';\nimport 'prismjs/components/prism-haskell';\nimport 'prismjs/components/prism-haxe';\nimport 'prismjs/components/prism-ini';\nimport 'prismjs/components/prism-java';\nimport 'prismjs/components/prism-javascript';\nimport 'prismjs/components/prism-jsx';\nimport 'prismjs/components/prism-json';\nimport 'prismjs/components/prism-julia';\nimport 'prismjs/components/prism-kotlin';\nimport 'prismjs/components/prism-latex';\nimport 'prismjs/components/prism-lua';\nimport 'prismjs/components/prism-markdown';\nimport 'prismjs/components/prism-matlab';\nimport 'prismjs/components/prism-makefile';\nimport 'prismjs/components/prism-objectivec';\nimport 'prismjs/components/prism-perl';\nimport 'prismjs/components/prism-php';\nimport 'prismjs/components/prism-powershell';\nimport 'prismjs/components/prism-python';\nimport 'prismjs/components/prism-r';\nimport 'prismjs/components/prism-ruby';\nimport 'prismjs/components/prism-rust';\nimport 'prismjs/components/prism-sas';\nimport 'prismjs/components/prism-scala';\nimport 'prismjs/components/prism-scheme';\nimport 'prismjs/components/prism-sql';\nimport 'prismjs/components/prism-stata';\nimport 'prismjs/components/prism-swift';\nimport 'prismjs/components/prism-typescript';\nimport 'prismjs/components/prism-tsx';\nimport 'prismjs/components/prism-vbnet';\nimport 'prismjs/components/prism-yaml';\n\ntype BaseRangeCustom = BaseRange & { className: string };\n\nexport const decorateCode = ([node, path]: NodeEntry) => {\n const ranges: BaseRangeCustom[] = [];\n\n // make sure it is an Slate Element\n if (!Element.isElement(node) || node.type !== 'code') return ranges;\n // transform the Element into a string\n const text = Node.string(node);\n const language = codeLanguages.find((lang) => lang.value === node.language);\n const decorateKey = language?.decorate ?? language?.value;\n\n const selectedLanguage = Prism.languages[decorateKey || 'plaintext'];\n\n // create \"tokens\" with \"prismjs\" and put them in \"ranges\"\n const tokens = Prism.tokenize(text, selectedLanguage);\n let start = 0;\n for (const token of tokens) {\n const length = token.length;\n const end = start + length;\n if (typeof token !== 'string') {\n ranges.push({\n anchor: { path, offset: start },\n focus: { path, offset: end },\n className: `token ${token.type}`,\n });\n }\n start = end;\n }\n\n // these will be found in \"renderLeaf\" in \"leaf\" and their \"className\" will be applied\n return ranges;\n};\n\nconst CodeBlock = styled.pre`\n border-radius: ${({ theme }) => theme.borderRadius};\n background-color: ${({ theme }) => theme.colors.neutral100};\n max-width: 100%;\n overflow: auto;\n padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};\n flex-shrink: 1;\n\n & > code {\n font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas,\n monospace;\n color: ${({ theme }) => theme.colors.neutral800};\n overflow: auto;\n max-width: 100%;\n }\n`;\n\nconst CodeEditor = (props: RenderElementProps) => {\n const { editor } = useBlocksEditorContext('ImageDialog');\n const editorIsFocused = useFocused();\n const imageIsSelected = useSelected();\n const { formatMessage } = useIntl();\n const [isSelectOpen, setIsSelectOpen] = React.useState(false);\n const shouldDisplayLanguageSelect = (editorIsFocused && imageIsSelected) || isSelectOpen;\n\n return (\n <Box position=\"relative\" width=\"100%\">\n <CodeBlock {...props.attributes}>\n <code>{props.children}</code>\n </CodeBlock>\n {shouldDisplayLanguageSelect && (\n <Box\n position=\"absolute\"\n background=\"neutral0\"\n borderColor=\"neutral150\"\n borderStyle=\"solid\"\n borderWidth=\"0.5px\"\n shadow=\"tableShadow\"\n top=\"100%\"\n marginTop={1}\n right={0}\n padding={1}\n hasRadius\n >\n <SingleSelect\n onChange={(open) => {\n Transforms.setNodes(\n editor,\n { language: open.toString() },\n { match: (node) => !Editor.isEditor(node) && node.type === 'code' }\n );\n }}\n value={(props.element.type === 'code' && props.element.language) || 'plaintext'}\n onOpenChange={(open) => {\n setIsSelectOpen(open);\n\n // Focus the editor again when closing the select so the user can continue typing\n if (!open) {\n ReactEditor.focus(editor);\n }\n }}\n onCloseAutoFocus={(e) => e.preventDefault()}\n aria-label={formatMessage({\n id: 'components.Blocks.blocks.code.languageLabel',\n defaultMessage: 'Select a language',\n })}\n >\n {codeLanguages.map(({ value, label }) => (\n <SingleSelectOption value={value} key={value}>\n {label}\n </SingleSelectOption>\n ))}\n </SingleSelect>\n </Box>\n )}\n </Box>\n );\n};\n\nconst withCode = (editor: Editor) => {\n const { insertData } = editor;\n\n editor.insertData = (data) => {\n const pastedText = data.getData('text/plain');\n\n if (pastedText && editor.selection) {\n // Check if we're currently inside a code block\n const codeBlockEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'code',\n });\n\n if (codeBlockEntry) {\n // We're inside a code block, handle the paste specially\n // Replace the selected content with the pasted text, preserving newlines\n Transforms.insertText(editor, pastedText);\n return;\n }\n }\n\n // For non-code blocks, use the default behavior\n insertData(data);\n };\n\n return editor;\n};\n\nconst codeBlocks: Pick<BlocksStore, 'code'> = {\n code: {\n renderElement: (props) => <CodeEditor {...props} />,\n icon: CodeBlockIcon,\n label: {\n id: 'components.Blocks.blocks.code',\n defaultMessage: 'Code block',\n },\n matchNode: (node) => node.type === 'code',\n isInBlocksSelector: true,\n handleConvert(editor) {\n baseHandleConvert<Block<'code'>>(editor, { type: 'code', language: 'plaintext' });\n },\n handleEnterKey(editor) {\n pressEnterTwiceToExit(editor);\n },\n snippets: ['```'],\n plugin: withCode,\n },\n};\n\nexport { codeBlocks };\n"],"names":["decorateCode","node","path","ranges","Element","isElement","type","text","Node","string","language","codeLanguages","find","lang","value","decorateKey","decorate","selectedLanguage","Prism","languages","tokens","tokenize","start","token","length","end","push","anchor","offset","focus","className","CodeBlock","styled","pre","theme","borderRadius","colors","neutral100","spaces","neutral800","CodeEditor","props","editor","useBlocksEditorContext","editorIsFocused","useFocused","imageIsSelected","useSelected","formatMessage","useIntl","isSelectOpen","setIsSelectOpen","React","useState","shouldDisplayLanguageSelect","_jsxs","Box","position","width","_jsx","attributes","code","children","background","borderColor","borderStyle","borderWidth","shadow","top","marginTop","right","padding","hasRadius","SingleSelect","onChange","open","Transforms","setNodes","toString","match","Editor","isEditor","element","onOpenChange","ReactEditor","onCloseAutoFocus","e","preventDefault","aria-label","id","defaultMessage","map","label","SingleSelectOption","withCode","insertData","data","pastedText","getData","selection","codeBlockEntry","above","insertText","codeBlocks","renderElement","icon","CodeBlockIcon","matchNode","isInBlocksSelector","handleConvert","baseHandleConvert","handleEnterKey","pressEnterTwiceToExit","snippets","plugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEO,MAAMA,YAAAA,GAAe,CAAC,CAACC,MAAMC,IAAAA,CAAgB,GAAA;AAClD,IAAA,MAAMC,SAA4B,EAAE;;IAGpC,IAAI,CAACC,cAAQC,SAAS,CAACJ,SAASA,IAAAA,CAAKK,IAAI,KAAK,MAAA,EAAQ,OAAOH,MAAAA;;IAE7D,MAAMI,IAAAA,GAAOC,UAAAA,CAAKC,MAAM,CAACR,IAAAA,CAAAA;IACzB,MAAMS,QAAAA,GAAWC,uBAAAA,CAAcC,IAAI,CAAC,CAACC,OAASA,IAAAA,CAAKC,KAAK,KAAKb,IAAAA,CAAKS,QAAQ,CAAA;IAC1E,MAAMK,WAAAA,GAAcL,QAAAA,EAAUM,QAAAA,IAAYN,QAAAA,EAAUI,KAAAA;AAEpD,IAAA,MAAMG,gBAAAA,GAAmBC,gBAAAA,CAAMC,SAAS,CAACJ,eAAe,WAAA,CAAY;;AAGpE,IAAA,MAAMK,MAAAA,GAASF,gBAAAA,CAAMG,QAAQ,CAACd,IAAAA,EAAMU,gBAAAA,CAAAA;AACpC,IAAA,IAAIK,KAAAA,GAAQ,CAAA;IACZ,KAAK,MAAMC,SAASH,MAAAA,CAAQ;QAC1B,MAAMI,MAAAA,GAASD,MAAMC,MAAM;AAC3B,QAAA,MAAMC,MAAMH,KAAAA,GAAQE,MAAAA;QACpB,IAAI,OAAOD,UAAU,QAAA,EAAU;AAC7BpB,YAAAA,MAAAA,CAAOuB,IAAI,CAAC;gB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AAAA,CAAAA;AACb,IAAA,CAAA;IAEA,OAAOtD,MAAAA;AACT,CAAA;AAEA,MAAM6D,UAAAA,GAAwC;IAC5C1C,IAAAA,EAAM;QACJ2C,aAAAA,EAAe,CAAC/D,sBAAUkB,cAAA,CAACnB,UAAAA,EAAAA;AAAY,gBAAA,GAAGC;;QAC1CgE,IAAAA,EAAMC,eAAAA;QACNd,KAAAA,EAAO;YACLH,EAAAA,EAAI,+BAAA;YACJC,cAAAA,EAAgB;AAClB,SAAA;AACAiB,QAAAA,SAAAA,EAAW,CAAC1G,IAAAA,GAASA,IAAAA,CAAKK,IAAI,KAAK,MAAA;QACnCsG,kBAAAA,EAAoB,IAAA;AACpBC,QAAAA,aAAAA,CAAAA,CAAcnE,MAAM,EAAA;AAClBoE,YAAAA,6BAAAA,CAAiCpE,MAAAA,EAAQ;gBAAEpC,IAAAA,EAAM,MAAA;gBAAQI,QAAAA,EAAU;AAAY,aAAA,CAAA;AACjF,QAAA,CAAA;AACAqG,QAAAA,cAAAA,CAAAA,CAAerE,MAAM,EAAA;YACnBsE,8BAAAA,CAAsBtE,MAAAA,CAAAA;AACxB,QAAA,CAAA;QACAuE,QAAAA,EAAU;AAAC,YAAA;AAAM,SAAA;QACjBC,MAAAA,EAAQpB;AACV;AACF;;;;;"}
1
+ {"version":3,"file":"Code.js","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, SingleSelect, SingleSelectOption } from '@strapi/design-system';\nimport { CodeBlock as CodeBlockIcon } from '@strapi/icons';\nimport * as PrismModule from 'prismjs';\nimport { useIntl } from 'react-intl';\nimport { BaseRange, Element, Editor, Node, NodeEntry, Transforms } from 'slate';\nimport { useSelected, type RenderElementProps, useFocused, ReactEditor } from 'slate-react';\nimport { styled } from 'styled-components';\n\nimport { useBlocksEditorContext, type BlocksStore } from '../BlocksEditor';\nimport { codeLanguages } from '../utils/constants';\nimport { baseHandleConvert } from '../utils/conversions';\nimport { pressEnterTwiceToExit } from '../utils/enterKey';\nimport { type Block } from '../utils/types';\n\nimport 'prismjs/themes/prism-solarizedlight.css';\nimport 'prismjs/components/prism-asmatmel';\nimport 'prismjs/components/prism-bash';\nimport 'prismjs/components/prism-basic';\nimport 'prismjs/components/prism-c';\nimport 'prismjs/components/prism-clojure';\nimport 'prismjs/components/prism-cobol';\nimport 'prismjs/components/prism-cpp';\nimport 'prismjs/components/prism-csharp';\nimport 'prismjs/components/prism-dart';\nimport 'prismjs/components/prism-docker';\nimport 'prismjs/components/prism-elixir';\nimport 'prismjs/components/prism-erlang';\nimport 'prismjs/components/prism-fortran';\nimport 'prismjs/components/prism-fsharp';\nimport 'prismjs/components/prism-go';\nimport 'prismjs/components/prism-graphql';\nimport 'prismjs/components/prism-groovy';\nimport 'prismjs/components/prism-haskell';\nimport 'prismjs/components/prism-haxe';\nimport 'prismjs/components/prism-ini';\nimport 'prismjs/components/prism-java';\nimport 'prismjs/components/prism-javascript';\nimport 'prismjs/components/prism-jsx';\nimport 'prismjs/components/prism-json';\nimport 'prismjs/components/prism-julia';\nimport 'prismjs/components/prism-kotlin';\nimport 'prismjs/components/prism-latex';\nimport 'prismjs/components/prism-lua';\nimport 'prismjs/components/prism-markdown';\nimport 'prismjs/components/prism-matlab';\nimport 'prismjs/components/prism-makefile';\nimport 'prismjs/components/prism-objectivec';\nimport 'prismjs/components/prism-perl';\nimport 'prismjs/components/prism-php';\nimport 'prismjs/components/prism-powershell';\nimport 'prismjs/components/prism-python';\nimport 'prismjs/components/prism-r';\nimport 'prismjs/components/prism-ruby';\nimport 'prismjs/components/prism-rust';\nimport 'prismjs/components/prism-sas';\nimport 'prismjs/components/prism-scala';\nimport 'prismjs/components/prism-scheme';\nimport 'prismjs/components/prism-sql';\nimport 'prismjs/components/prism-stata';\nimport 'prismjs/components/prism-swift';\nimport 'prismjs/components/prism-typescript';\nimport 'prismjs/components/prism-tsx';\nimport 'prismjs/components/prism-vbnet';\nimport 'prismjs/components/prism-yaml';\n\n/**\n * prismjs is UMD and may not expose a namespace when bundled by Vite; the content-manager\n * index preloads it so `window.Prism` is set. Use that when the module import is empty.\n */\nfunction resolvePrism(): typeof PrismModule | undefined {\n if (typeof PrismModule !== 'undefined' && PrismModule?.languages) {\n return PrismModule;\n }\n\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n const globalPrism = (window as Window & { Prism?: typeof PrismModule }).Prism;\n return globalPrism;\n}\n\nconst Prism = resolvePrism();\n\ntype BaseRangeCustom = BaseRange & { className: string };\n\nexport const decorateCode = ([node, path]: NodeEntry) => {\n const ranges: BaseRangeCustom[] = [];\n\n // Prism can be undefined when the UMD bundle doesn't expose a namespace and window.Prism\n // isn't set yet (e.g. this chunk ran before the content-manager preload). Skip decoration.\n if (!Prism?.languages) return ranges;\n\n // make sure it is an Slate Element\n if (!Element.isElement(node) || node.type !== 'code') return ranges;\n // transform the Element into a string\n const text = Node.string(node);\n const language = codeLanguages.find((lang) => lang.value === node.language);\n const decorateKey = language?.decorate ?? language?.value;\n\n const selectedLanguage = Prism.languages[decorateKey || 'plaintext'];\n\n // create \"tokens\" with \"prismjs\" and put them in \"ranges\"\n const tokens = Prism.tokenize(text, selectedLanguage);\n let start = 0;\n for (const token of tokens) {\n const length = token.length;\n const end = start + length;\n if (typeof token !== 'string') {\n ranges.push({\n anchor: { path, offset: start },\n focus: { path, offset: end },\n className: `token ${token.type}`,\n });\n }\n start = end;\n }\n\n // these will be found in \"renderLeaf\" in \"leaf\" and their \"className\" will be applied\n return ranges;\n};\n\nconst CodeBlock = styled.pre`\n border-radius: ${({ theme }) => theme.borderRadius};\n background-color: ${({ theme }) => theme.colors.neutral100};\n max-width: 100%;\n overflow: auto;\n padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};\n flex-shrink: 1;\n\n & > code {\n font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas,\n monospace;\n color: ${({ theme }) => theme.colors.neutral800};\n overflow: auto;\n max-width: 100%;\n }\n`;\n\nconst CodeEditor = (props: RenderElementProps) => {\n const { editor } = useBlocksEditorContext('ImageDialog');\n const editorIsFocused = useFocused();\n const imageIsSelected = useSelected();\n const { formatMessage } = useIntl();\n const [isSelectOpen, setIsSelectOpen] = React.useState(false);\n const shouldDisplayLanguageSelect = (editorIsFocused && imageIsSelected) || isSelectOpen;\n\n return (\n <Box position=\"relative\" width=\"100%\">\n <CodeBlock {...props.attributes}>\n <code>{props.children}</code>\n </CodeBlock>\n {shouldDisplayLanguageSelect && (\n <Box\n position=\"absolute\"\n background=\"neutral0\"\n borderColor=\"neutral150\"\n borderStyle=\"solid\"\n borderWidth=\"0.5px\"\n shadow=\"tableShadow\"\n top=\"100%\"\n marginTop={1}\n right={0}\n padding={1}\n hasRadius\n >\n <SingleSelect\n onChange={(open) => {\n Transforms.setNodes(\n editor,\n { language: open.toString() },\n { match: (node) => !Editor.isEditor(node) && node.type === 'code' }\n );\n }}\n value={(props.element.type === 'code' && props.element.language) || 'plaintext'}\n onOpenChange={(open) => {\n setIsSelectOpen(open);\n\n // Focus the editor again when closing the select so the user can continue typing\n if (!open) {\n ReactEditor.focus(editor);\n }\n }}\n onCloseAutoFocus={(e) => e.preventDefault()}\n aria-label={formatMessage({\n id: 'components.Blocks.blocks.code.languageLabel',\n defaultMessage: 'Select a language',\n })}\n >\n {codeLanguages.map(({ value, label }) => (\n <SingleSelectOption value={value} key={value}>\n {label}\n </SingleSelectOption>\n ))}\n </SingleSelect>\n </Box>\n )}\n </Box>\n );\n};\n\nconst withCode = (editor: Editor) => {\n const { insertData } = editor;\n\n editor.insertData = (data) => {\n const pastedText = data.getData('text/plain');\n\n if (pastedText && editor.selection) {\n // Check if we're currently inside a code block\n const codeBlockEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'code',\n });\n\n if (codeBlockEntry) {\n // We're inside a code block, handle the paste specially\n // Replace the selected content with the pasted text, preserving newlines\n Transforms.insertText(editor, pastedText);\n return;\n }\n }\n\n // For non-code blocks, use the default behavior\n insertData(data);\n };\n\n return editor;\n};\n\nconst codeBlocks: Pick<BlocksStore, 'code'> = {\n code: {\n renderElement: (props) => <CodeEditor {...props} />,\n icon: CodeBlockIcon,\n label: {\n id: 'components.Blocks.blocks.code',\n defaultMessage: 'Code block',\n },\n matchNode: (node) => node.type === 'code',\n isInBlocksSelector: true,\n handleConvert(editor) {\n baseHandleConvert<Block<'code'>>(editor, { type: 'code', language: 'plaintext' });\n },\n handleEnterKey(editor) {\n pressEnterTwiceToExit(editor);\n },\n snippets: ['```'],\n plugin: withCode,\n },\n};\n\nexport { codeBlocks };\n"],"names":["resolvePrism","PrismModule","languages","window","undefined","globalPrism","Prism","decorateCode","node","path","ranges","Element","isElement","type","text","Node","string","language","codeLanguages","find","lang","value","decorateKey","decorate","selectedLanguage","tokens","tokenize","start","token","length","end","push","anchor","offset","focus","className","CodeBlock","styled","pre","theme","borderRadius","colors","neutral100","spaces","neutral800","CodeEditor","props","editor","useBlocksEditorContext","editorIsFocused","useFocused","imageIsSelected","useSelected","formatMessage","useIntl","isSelectOpen","setIsSelectOpen","React","useState","shouldDisplayLanguageSelect","_jsxs","Box","position","width","_jsx","attributes","code","children","background","borderColor","borderStyle","borderWidth","shadow","top","marginTop","right","padding","hasRadius","SingleSelect","onChange","open","Transforms","setNodes","toString","match","Editor","isEditor","element","onOpenChange","ReactEditor","onCloseAutoFocus","e","preventDefault","aria-label","id","defaultMessage","map","label","SingleSelectOption","withCode","insertData","data","pastedText","getData","selection","codeBlockEntry","above","insertText","codeBlocks","renderElement","icon","CodeBlockIcon","matchNode","isInBlocksSelector","handleConvert","baseHandleConvert","handleEnterKey","pressEnterTwiceToExit","snippets","plugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA;;;AAGC,IACD,SAASA,YAAAA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AA;AACF,YAAA;AACF,QAAA;;QAGAF,UAAAA,CAAWC,IAAAA,CAAAA;AACb,IAAA,CAAA;IAEA,OAAOtD,MAAAA;AACT,CAAA;AAEA,MAAM6D,UAAAA,GAAwC;IAC5C1C,IAAAA,EAAM;QACJ2C,aAAAA,EAAe,CAAC/D,sBAAUkB,cAAA,CAACnB,UAAAA,EAAAA;AAAY,gBAAA,GAAGC;;QAC1CgE,IAAAA,EAAMC,eAAAA;QACNd,KAAAA,EAAO;YACLH,EAAAA,EAAI,+BAAA;YACJC,cAAAA,EAAgB;AAClB,SAAA;AACAiB,QAAAA,SAAAA,EAAW,CAACxG,IAAAA,GAASA,IAAAA,CAAKK,IAAI,KAAK,MAAA;QACnCoG,kBAAAA,EAAoB,IAAA;AACpBC,QAAAA,aAAAA,CAAAA,CAAcnE,MAAM,EAAA;AAClBoE,YAAAA,6BAAAA,CAAiCpE,MAAAA,EAAQ;gBAAElC,IAAAA,EAAM,MAAA;gBAAQI,QAAAA,EAAU;AAAY,aAAA,CAAA;AACjF,QAAA,CAAA;AACAmG,QAAAA,cAAAA,CAAAA,CAAerE,MAAM,EAAA;YACnBsE,8BAAAA,CAAsBtE,MAAAA,CAAAA;AACxB,QAAA,CAAA;QACAuE,QAAAA,EAAU;AAAC,YAAA;AAAM,SAAA;QACjBC,MAAAA,EAAQpB;AACV;AACF;;;;;"}
@@ -2,9 +2,9 @@ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { Box, SingleSelect, SingleSelectOption } from '@strapi/design-system';
4
4
  import { CodeBlock as CodeBlock$1 } from '@strapi/icons';
5
- import * as Prism from 'prismjs';
5
+ import * as PrismModule from 'prismjs';
6
6
  import { useIntl } from 'react-intl';
7
- import { Editor, Transforms, Element, Node } from 'slate';
7
+ import { Element, Node, Editor, Transforms } from 'slate';
8
8
  import { useFocused, useSelected, ReactEditor } from 'slate-react';
9
9
  import { styled } from 'styled-components';
10
10
  import { useBlocksEditorContext } from '../BlocksEditor.mjs';
@@ -62,8 +62,25 @@ import 'prismjs/components/prism-tsx';
62
62
  import 'prismjs/components/prism-vbnet';
63
63
  import 'prismjs/components/prism-yaml';
64
64
 
65
+ /**
66
+ * prismjs is UMD and may not expose a namespace when bundled by Vite; the content-manager
67
+ * index preloads it so `window.Prism` is set. Use that when the module import is empty.
68
+ */ function resolvePrism() {
69
+ if (typeof PrismModule !== 'undefined' && PrismModule?.languages) {
70
+ return PrismModule;
71
+ }
72
+ if (typeof window === 'undefined') {
73
+ return undefined;
74
+ }
75
+ const globalPrism = window.Prism;
76
+ return globalPrism;
77
+ }
78
+ const Prism = resolvePrism();
65
79
  const decorateCode = ([node, path])=>{
66
80
  const ranges = [];
81
+ // Prism can be undefined when the UMD bundle doesn't expose a namespace and window.Prism
82
+ // isn't set yet (e.g. this chunk ran before the content-manager preload). Skip decoration.
83
+ if (!Prism?.languages) return ranges;
67
84
  // make sure it is an Slate Element
68
85
  if (!Element.isElement(node) || node.type !== 'code') return ranges;
69
86
  // transform the Element into a string
@@ -1 +1 @@
1
- {"version":3,"file":"Code.mjs","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, SingleSelect, SingleSelectOption } from '@strapi/design-system';\nimport { CodeBlock as CodeBlockIcon } from '@strapi/icons';\nimport * as Prism from 'prismjs';\nimport { useIntl } from 'react-intl';\nimport { BaseRange, Element, Editor, Node, NodeEntry, Transforms } from 'slate';\nimport { useSelected, type RenderElementProps, useFocused, ReactEditor } from 'slate-react';\nimport { styled } from 'styled-components';\n\nimport { useBlocksEditorContext, type BlocksStore } from '../BlocksEditor';\nimport { codeLanguages } from '../utils/constants';\nimport { baseHandleConvert } from '../utils/conversions';\nimport { pressEnterTwiceToExit } from '../utils/enterKey';\nimport { type Block } from '../utils/types';\n\nimport 'prismjs/themes/prism-solarizedlight.css';\nimport 'prismjs/components/prism-asmatmel';\nimport 'prismjs/components/prism-bash';\nimport 'prismjs/components/prism-basic';\nimport 'prismjs/components/prism-c';\nimport 'prismjs/components/prism-clojure';\nimport 'prismjs/components/prism-cobol';\nimport 'prismjs/components/prism-cpp';\nimport 'prismjs/components/prism-csharp';\nimport 'prismjs/components/prism-dart';\nimport 'prismjs/components/prism-docker';\nimport 'prismjs/components/prism-elixir';\nimport 'prismjs/components/prism-erlang';\nimport 'prismjs/components/prism-fortran';\nimport 'prismjs/components/prism-fsharp';\nimport 'prismjs/components/prism-go';\nimport 'prismjs/components/prism-graphql';\nimport 'prismjs/components/prism-groovy';\nimport 'prismjs/components/prism-haskell';\nimport 'prismjs/components/prism-haxe';\nimport 'prismjs/components/prism-ini';\nimport 'prismjs/components/prism-java';\nimport 'prismjs/components/prism-javascript';\nimport 'prismjs/components/prism-jsx';\nimport 'prismjs/components/prism-json';\nimport 'prismjs/components/prism-julia';\nimport 'prismjs/components/prism-kotlin';\nimport 'prismjs/components/prism-latex';\nimport 'prismjs/components/prism-lua';\nimport 'prismjs/components/prism-markdown';\nimport 'prismjs/components/prism-matlab';\nimport 'prismjs/components/prism-makefile';\nimport 'prismjs/components/prism-objectivec';\nimport 'prismjs/components/prism-perl';\nimport 'prismjs/components/prism-php';\nimport 'prismjs/components/prism-powershell';\nimport 'prismjs/components/prism-python';\nimport 'prismjs/components/prism-r';\nimport 'prismjs/components/prism-ruby';\nimport 'prismjs/components/prism-rust';\nimport 'prismjs/components/prism-sas';\nimport 'prismjs/components/prism-scala';\nimport 'prismjs/components/prism-scheme';\nimport 'prismjs/components/prism-sql';\nimport 'prismjs/components/prism-stata';\nimport 'prismjs/components/prism-swift';\nimport 'prismjs/components/prism-typescript';\nimport 'prismjs/components/prism-tsx';\nimport 'prismjs/components/prism-vbnet';\nimport 'prismjs/components/prism-yaml';\n\ntype BaseRangeCustom = BaseRange & { className: string };\n\nexport const decorateCode = ([node, path]: NodeEntry) => {\n const ranges: BaseRangeCustom[] = [];\n\n // make sure it is an Slate Element\n if (!Element.isElement(node) || node.type !== 'code') return ranges;\n // transform the Element into a string\n const text = Node.string(node);\n const language = codeLanguages.find((lang) => lang.value === node.language);\n const decorateKey = language?.decorate ?? language?.value;\n\n const selectedLanguage = Prism.languages[decorateKey || 'plaintext'];\n\n // create \"tokens\" with \"prismjs\" and put them in \"ranges\"\n const tokens = Prism.tokenize(text, selectedLanguage);\n let start = 0;\n for (const token of tokens) {\n const length = token.length;\n const end = start + length;\n if (typeof token !== 'string') {\n ranges.push({\n anchor: { path, offset: start },\n focus: { path, offset: end },\n className: `token ${token.type}`,\n });\n }\n start = end;\n }\n\n // these will be found in \"renderLeaf\" in \"leaf\" and their \"className\" will be applied\n return ranges;\n};\n\nconst CodeBlock = styled.pre`\n border-radius: ${({ theme }) => theme.borderRadius};\n background-color: ${({ theme }) => theme.colors.neutral100};\n max-width: 100%;\n overflow: auto;\n padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};\n flex-shrink: 1;\n\n & > code {\n font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas,\n monospace;\n color: ${({ theme }) => theme.colors.neutral800};\n overflow: auto;\n max-width: 100%;\n }\n`;\n\nconst CodeEditor = (props: RenderElementProps) => {\n const { editor } = useBlocksEditorContext('ImageDialog');\n const editorIsFocused = useFocused();\n const imageIsSelected = useSelected();\n const { formatMessage } = useIntl();\n const [isSelectOpen, setIsSelectOpen] = React.useState(false);\n const shouldDisplayLanguageSelect = (editorIsFocused && imageIsSelected) || isSelectOpen;\n\n return (\n <Box position=\"relative\" width=\"100%\">\n <CodeBlock {...props.attributes}>\n <code>{props.children}</code>\n </CodeBlock>\n {shouldDisplayLanguageSelect && (\n <Box\n position=\"absolute\"\n background=\"neutral0\"\n borderColor=\"neutral150\"\n borderStyle=\"solid\"\n borderWidth=\"0.5px\"\n shadow=\"tableShadow\"\n top=\"100%\"\n marginTop={1}\n right={0}\n padding={1}\n hasRadius\n >\n <SingleSelect\n onChange={(open) => {\n Transforms.setNodes(\n editor,\n { language: open.toString() },\n { match: (node) => !Editor.isEditor(node) && node.type === 'code' }\n );\n }}\n value={(props.element.type === 'code' && props.element.language) || 'plaintext'}\n onOpenChange={(open) => {\n setIsSelectOpen(open);\n\n // Focus the editor again when closing the select so the user can continue typing\n if (!open) {\n ReactEditor.focus(editor);\n }\n }}\n onCloseAutoFocus={(e) => e.preventDefault()}\n aria-label={formatMessage({\n id: 'components.Blocks.blocks.code.languageLabel',\n defaultMessage: 'Select a language',\n })}\n >\n {codeLanguages.map(({ value, label }) => (\n <SingleSelectOption value={value} key={value}>\n {label}\n </SingleSelectOption>\n ))}\n </SingleSelect>\n </Box>\n )}\n </Box>\n );\n};\n\nconst withCode = (editor: Editor) => {\n const { insertData } = editor;\n\n editor.insertData = (data) => {\n const pastedText = data.getData('text/plain');\n\n if (pastedText && editor.selection) {\n // Check if we're currently inside a code block\n const codeBlockEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'code',\n });\n\n if (codeBlockEntry) {\n // We're inside a code block, handle the paste specially\n // Replace the selected content with the pasted text, preserving newlines\n Transforms.insertText(editor, pastedText);\n return;\n }\n }\n\n // For non-code blocks, use the default behavior\n insertData(data);\n };\n\n return editor;\n};\n\nconst codeBlocks: Pick<BlocksStore, 'code'> = {\n code: {\n renderElement: (props) => <CodeEditor {...props} />,\n icon: CodeBlockIcon,\n label: {\n id: 'components.Blocks.blocks.code',\n defaultMessage: 'Code block',\n },\n matchNode: (node) => node.type === 'code',\n isInBlocksSelector: true,\n handleConvert(editor) {\n baseHandleConvert<Block<'code'>>(editor, { type: 'code', language: 'plaintext' });\n },\n handleEnterKey(editor) {\n pressEnterTwiceToExit(editor);\n },\n snippets: ['```'],\n plugin: withCode,\n },\n};\n\nexport { codeBlocks };\n"],"names":["decorateCode","node","path","ranges","Element","isElement","type","text","Node","string","language","codeLanguages","find","lang","value","decorateKey","decorate","selectedLanguage","Prism","languages","tokens","tokenize","start","token","length","end","push","anchor","offset","focus","className","CodeBlock","styled","pre","theme","borderRadius","colors","neutral100","spaces","neutral800","CodeEditor","props","editor","useBlocksEditorContext","editorIsFocused","useFocused","imageIsSelected","useSelected","formatMessage","useIntl","isSelectOpen","setIsSelectOpen","React","useState","shouldDisplayLanguageSelect","_jsxs","Box","position","width","_jsx","attributes","code","children","background","borderColor","borderStyle","borderWidth","shadow","top","marginTop","right","padding","hasRadius","SingleSelect","onChange","open","Transforms","setNodes","toString","match","Editor","isEditor","element","onOpenChange","ReactEditor","onCloseAutoFocus","e","preventDefault","aria-label","id","defaultMessage","map","label","SingleSelectOption","withCode","insertData","data","pastedText","getData","selection","codeBlockEntry","above","insertText","codeBlocks","renderElement","icon","CodeBlockIcon","matchNode","isInBlocksSelector","handleConvert","baseHandleConvert","handleEnterKey","pressEnterTwiceToExit","snippets","plugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqEO,MAAMA,YAAAA,GAAe,CAAC,CAACC,MAAMC,IAAAA,CAAgB,GAAA;AAClD,IAAA,MAAMC,SAA4B,EAAE;;IAGpC,IAAI,CAACC,QAAQC,SAAS,CAACJ,SAASA,IAAAA,CAAKK,IAAI,KAAK,MAAA,EAAQ,OAAOH,MAAAA;;IAE7D,MAAMI,IAAAA,GAAOC,IAAAA,CAAKC,MAAM,CAACR,IAAAA,CAAAA;IACzB,MAAMS,QAAAA,GAAWC,aAAAA,CAAcC,IAAI,CAAC,CAACC,OAASA,IAAAA,CAAKC,KAAK,KAAKb,IAAAA,CAAKS,QAAQ,CAAA;IAC1E,MAAMK,WAAAA,GAAcL,QAAAA,EAAUM,QAAAA,IAAYN,QAAAA,EAAUI,KAAAA;AAEpD,IAAA,MAAMG,gBAAAA,GAAmBC,KAAAA,CAAMC,SAAS,CAACJ,eAAe,WAAA,CAAY;;AAGpE,IAAA,MAAMK,MAAAA,GAASF,KAAAA,CAAMG,QAAQ,CAACd,IAAAA,EAAMU,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AAOC,QAAQ,CAAChF,IAAAA,CAAAA,IAASA,IAAAA,CAAKK,IAAI,KAAK;AAC3D,aAAA,CAAA;AAEA,YAAA,IAAI8F,cAAAA,EAAgB;;;gBAGlBxB,UAAAA,CAAW0B,UAAU,CAAC5D,MAAAA,EAAQuD,UAAAA,CAAAA;AAC9B,gBAAA;AACF,YAAA;AACF,QAAA;;QAGAF,UAAAA,CAAWC,IAAAA,CAAAA;AACb,IAAA,CAAA;IAEA,OAAOtD,MAAAA;AACT,CAAA;AAEA,MAAM6D,UAAAA,GAAwC;IAC5C1C,IAAAA,EAAM;QACJ2C,aAAAA,EAAe,CAAC/D,sBAAUkB,GAAA,CAACnB,UAAAA,EAAAA;AAAY,gBAAA,GAAGC;;QAC1CgE,IAAAA,EAAMC,WAAAA;QACNd,KAAAA,EAAO;YACLH,EAAAA,EAAI,+BAAA;YACJC,cAAAA,EAAgB;AAClB,SAAA;AACAiB,QAAAA,SAAAA,EAAW,CAAC1G,IAAAA,GAASA,IAAAA,CAAKK,IAAI,KAAK,MAAA;QACnCsG,kBAAAA,EAAoB,IAAA;AACpBC,QAAAA,aAAAA,CAAAA,CAAcnE,MAAM,EAAA;AAClBoE,YAAAA,iBAAAA,CAAiCpE,MAAAA,EAAQ;gBAAEpC,IAAAA,EAAM,MAAA;gBAAQI,QAAAA,EAAU;AAAY,aAAA,CAAA;AACjF,QAAA,CAAA;AACAqG,QAAAA,cAAAA,CAAAA,CAAerE,MAAM,EAAA;YACnBsE,qBAAAA,CAAsBtE,MAAAA,CAAAA;AACxB,QAAA,CAAA;QACAuE,QAAAA,EAAU;AAAC,YAAA;AAAM,SAAA;QACjBC,MAAAA,EAAQpB;AACV;AACF;;;;"}
1
+ {"version":3,"file":"Code.mjs","sources":["../../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/Blocks/Code.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { Box, SingleSelect, SingleSelectOption } from '@strapi/design-system';\nimport { CodeBlock as CodeBlockIcon } from '@strapi/icons';\nimport * as PrismModule from 'prismjs';\nimport { useIntl } from 'react-intl';\nimport { BaseRange, Element, Editor, Node, NodeEntry, Transforms } from 'slate';\nimport { useSelected, type RenderElementProps, useFocused, ReactEditor } from 'slate-react';\nimport { styled } from 'styled-components';\n\nimport { useBlocksEditorContext, type BlocksStore } from '../BlocksEditor';\nimport { codeLanguages } from '../utils/constants';\nimport { baseHandleConvert } from '../utils/conversions';\nimport { pressEnterTwiceToExit } from '../utils/enterKey';\nimport { type Block } from '../utils/types';\n\nimport 'prismjs/themes/prism-solarizedlight.css';\nimport 'prismjs/components/prism-asmatmel';\nimport 'prismjs/components/prism-bash';\nimport 'prismjs/components/prism-basic';\nimport 'prismjs/components/prism-c';\nimport 'prismjs/components/prism-clojure';\nimport 'prismjs/components/prism-cobol';\nimport 'prismjs/components/prism-cpp';\nimport 'prismjs/components/prism-csharp';\nimport 'prismjs/components/prism-dart';\nimport 'prismjs/components/prism-docker';\nimport 'prismjs/components/prism-elixir';\nimport 'prismjs/components/prism-erlang';\nimport 'prismjs/components/prism-fortran';\nimport 'prismjs/components/prism-fsharp';\nimport 'prismjs/components/prism-go';\nimport 'prismjs/components/prism-graphql';\nimport 'prismjs/components/prism-groovy';\nimport 'prismjs/components/prism-haskell';\nimport 'prismjs/components/prism-haxe';\nimport 'prismjs/components/prism-ini';\nimport 'prismjs/components/prism-java';\nimport 'prismjs/components/prism-javascript';\nimport 'prismjs/components/prism-jsx';\nimport 'prismjs/components/prism-json';\nimport 'prismjs/components/prism-julia';\nimport 'prismjs/components/prism-kotlin';\nimport 'prismjs/components/prism-latex';\nimport 'prismjs/components/prism-lua';\nimport 'prismjs/components/prism-markdown';\nimport 'prismjs/components/prism-matlab';\nimport 'prismjs/components/prism-makefile';\nimport 'prismjs/components/prism-objectivec';\nimport 'prismjs/components/prism-perl';\nimport 'prismjs/components/prism-php';\nimport 'prismjs/components/prism-powershell';\nimport 'prismjs/components/prism-python';\nimport 'prismjs/components/prism-r';\nimport 'prismjs/components/prism-ruby';\nimport 'prismjs/components/prism-rust';\nimport 'prismjs/components/prism-sas';\nimport 'prismjs/components/prism-scala';\nimport 'prismjs/components/prism-scheme';\nimport 'prismjs/components/prism-sql';\nimport 'prismjs/components/prism-stata';\nimport 'prismjs/components/prism-swift';\nimport 'prismjs/components/prism-typescript';\nimport 'prismjs/components/prism-tsx';\nimport 'prismjs/components/prism-vbnet';\nimport 'prismjs/components/prism-yaml';\n\n/**\n * prismjs is UMD and may not expose a namespace when bundled by Vite; the content-manager\n * index preloads it so `window.Prism` is set. Use that when the module import is empty.\n */\nfunction resolvePrism(): typeof PrismModule | undefined {\n if (typeof PrismModule !== 'undefined' && PrismModule?.languages) {\n return PrismModule;\n }\n\n if (typeof window === 'undefined') {\n return undefined;\n }\n\n const globalPrism = (window as Window & { Prism?: typeof PrismModule }).Prism;\n return globalPrism;\n}\n\nconst Prism = resolvePrism();\n\ntype BaseRangeCustom = BaseRange & { className: string };\n\nexport const decorateCode = ([node, path]: NodeEntry) => {\n const ranges: BaseRangeCustom[] = [];\n\n // Prism can be undefined when the UMD bundle doesn't expose a namespace and window.Prism\n // isn't set yet (e.g. this chunk ran before the content-manager preload). Skip decoration.\n if (!Prism?.languages) return ranges;\n\n // make sure it is an Slate Element\n if (!Element.isElement(node) || node.type !== 'code') return ranges;\n // transform the Element into a string\n const text = Node.string(node);\n const language = codeLanguages.find((lang) => lang.value === node.language);\n const decorateKey = language?.decorate ?? language?.value;\n\n const selectedLanguage = Prism.languages[decorateKey || 'plaintext'];\n\n // create \"tokens\" with \"prismjs\" and put them in \"ranges\"\n const tokens = Prism.tokenize(text, selectedLanguage);\n let start = 0;\n for (const token of tokens) {\n const length = token.length;\n const end = start + length;\n if (typeof token !== 'string') {\n ranges.push({\n anchor: { path, offset: start },\n focus: { path, offset: end },\n className: `token ${token.type}`,\n });\n }\n start = end;\n }\n\n // these will be found in \"renderLeaf\" in \"leaf\" and their \"className\" will be applied\n return ranges;\n};\n\nconst CodeBlock = styled.pre`\n border-radius: ${({ theme }) => theme.borderRadius};\n background-color: ${({ theme }) => theme.colors.neutral100};\n max-width: 100%;\n overflow: auto;\n padding: ${({ theme }) => `${theme.spaces[3]} ${theme.spaces[4]}`};\n flex-shrink: 1;\n\n & > code {\n font-family: 'SF Mono', SFMono-Regular, ui-monospace, 'DejaVu Sans Mono', Menlo, Consolas,\n monospace;\n color: ${({ theme }) => theme.colors.neutral800};\n overflow: auto;\n max-width: 100%;\n }\n`;\n\nconst CodeEditor = (props: RenderElementProps) => {\n const { editor } = useBlocksEditorContext('ImageDialog');\n const editorIsFocused = useFocused();\n const imageIsSelected = useSelected();\n const { formatMessage } = useIntl();\n const [isSelectOpen, setIsSelectOpen] = React.useState(false);\n const shouldDisplayLanguageSelect = (editorIsFocused && imageIsSelected) || isSelectOpen;\n\n return (\n <Box position=\"relative\" width=\"100%\">\n <CodeBlock {...props.attributes}>\n <code>{props.children}</code>\n </CodeBlock>\n {shouldDisplayLanguageSelect && (\n <Box\n position=\"absolute\"\n background=\"neutral0\"\n borderColor=\"neutral150\"\n borderStyle=\"solid\"\n borderWidth=\"0.5px\"\n shadow=\"tableShadow\"\n top=\"100%\"\n marginTop={1}\n right={0}\n padding={1}\n hasRadius\n >\n <SingleSelect\n onChange={(open) => {\n Transforms.setNodes(\n editor,\n { language: open.toString() },\n { match: (node) => !Editor.isEditor(node) && node.type === 'code' }\n );\n }}\n value={(props.element.type === 'code' && props.element.language) || 'plaintext'}\n onOpenChange={(open) => {\n setIsSelectOpen(open);\n\n // Focus the editor again when closing the select so the user can continue typing\n if (!open) {\n ReactEditor.focus(editor);\n }\n }}\n onCloseAutoFocus={(e) => e.preventDefault()}\n aria-label={formatMessage({\n id: 'components.Blocks.blocks.code.languageLabel',\n defaultMessage: 'Select a language',\n })}\n >\n {codeLanguages.map(({ value, label }) => (\n <SingleSelectOption value={value} key={value}>\n {label}\n </SingleSelectOption>\n ))}\n </SingleSelect>\n </Box>\n )}\n </Box>\n );\n};\n\nconst withCode = (editor: Editor) => {\n const { insertData } = editor;\n\n editor.insertData = (data) => {\n const pastedText = data.getData('text/plain');\n\n if (pastedText && editor.selection) {\n // Check if we're currently inside a code block\n const codeBlockEntry = Editor.above(editor, {\n match: (node) => !Editor.isEditor(node) && node.type === 'code',\n });\n\n if (codeBlockEntry) {\n // We're inside a code block, handle the paste specially\n // Replace the selected content with the pasted text, preserving newlines\n Transforms.insertText(editor, pastedText);\n return;\n }\n }\n\n // For non-code blocks, use the default behavior\n insertData(data);\n };\n\n return editor;\n};\n\nconst codeBlocks: Pick<BlocksStore, 'code'> = {\n code: {\n renderElement: (props) => <CodeEditor {...props} />,\n icon: CodeBlockIcon,\n label: {\n id: 'components.Blocks.blocks.code',\n defaultMessage: 'Code block',\n },\n matchNode: (node) => node.type === 'code',\n isInBlocksSelector: true,\n handleConvert(editor) {\n baseHandleConvert<Block<'code'>>(editor, { type: 'code', language: 'plaintext' });\n },\n handleEnterKey(editor) {\n pressEnterTwiceToExit(editor);\n },\n snippets: ['```'],\n plugin: withCode,\n },\n};\n\nexport { codeBlocks };\n"],"names":["resolvePrism","PrismModule","languages","window","undefined","globalPrism","Prism","decorateCode","node","path","ranges","Element","isElement","type","text","Node","string","language","codeLanguages","find","lang","value","decorateKey","decorate","selectedLanguage","tokens","tokenize","start","token","length","end","push","anchor","offset","focus","className","CodeBlock","styled","pre","theme","borderRadius","colors","neutral100","spaces","neutral800","CodeEditor","props","editor","useBlocksEditorContext","editorIsFocused","useFocused","imageIsSelected","useSelected","formatMessage","useIntl","isSelectOpen","setIsSelectOpen","React","useState","shouldDisplayLanguageSelect","_jsxs","Box","position","width","_jsx","attributes","code","children","background","borderColor","borderStyle","borderWidth","shadow","top","marginTop","right","padding","hasRadius","SingleSelect","onChange","open","Transforms","setNodes","toString","match","Editor","isEditor","element","onOpenChange","ReactEditor","onCloseAutoFocus","e","preventDefault","aria-label","id","defaultMessage","map","label","SingleSelectOption","withCode","insertData","data","pastedText","getData","selection","codeBlockEntry","above","insertText","codeBlocks","renderElement","icon","CodeBlockIcon","matchNode","isInBlocksSelector","handleConvert","baseHandleConvert","handleEnterKey","pressEnterTwiceToExit","snippets","plugin"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA;;;AAGC,IACD,SAASA,YAAAA,GAAAA;AACP,IAAA,IAAI,OAAOC,WAAAA,KAAgB,WAAA,IAAeA,WAAAA,EAAaC,SAAAA,EAAW;QAChE,OAAOD,WAAAA;AACT,IAAA;IAEA,IAAI,OAAOE,WAAW,WAAA,EAAa;QACjC,OAAOC,SAAAA;AACT,IAAA;IAEA,MAAMC,WAAAA,GAAc,MAACF,CAAmDG,KAAK;IAC7E,OAAOD,WAAAA;AACT;AAEA,MAAMC,KAAAA,GAAQN,YAAAA,EAAAA;AAIP,MAAMO,YAAAA,GAAe,CAAC,CAACC,MAAMC,IAAAA,CAAgB,GAAA;AAClD,IAAA,MAAMC,SAA4B,EAAE;;;IAIpC,IAAI,CAACJ,KAAAA,EAAOJ,SAAAA,EAAW,OAAOQ,MAAAA;;IAG9B,IAAI,CAACC,QAAQC,SAAS,CAACJ,SAASA,IAAAA,CAAKK,IAAI,KAAK,MAAA,EAAQ,OAAOH,MAAAA;;IAE7D,MAAMI,IAAAA,GAAOC,IAAAA,CAAKC,MAAM,CAACR,IAAAA,CAAAA;IACzB,MAAMS,QAAAA,GAAWC,aAAAA,CAAcC,IAAI,CAAC,CAACC,OAASA,IAAAA,CAAKC,KAAK,KAAKb,IAAAA,CAAKS,QAAQ,CAAA;IAC1E,MAAMK,WAAAA,GAAcL,QAAAA,EAAUM,QAAAA,IAAYN,QAAAA,EAAUI,KAAAA;AAEpD,IAAA,MAAMG,gBAAAA,GAAmBlB,KAAAA,CAAMJ,SAAS,CAACoB,eAAe,WAAA,CAAY;;AAGpE,IAAA,MAAMG,MAAAA,GAASnB,KAAAA,CAAMoB,QAAQ,CAACZ,IAAAA,E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A,CAAOC,QAAQ,CAAC9E,IAAAA,CAAAA,IAASA,IAAAA,CAAKK,IAAI,KAAK;AAC3D,aAAA,CAAA;AAEA,YAAA,IAAI4F,cAAAA,EAAgB;;;gBAGlBxB,UAAAA,CAAW0B,UAAU,CAAC5D,MAAAA,EAAQuD,UAAAA,CAAAA;AAC9B,gBAAA;AACF,YAAA;AACF,QAAA;;QAGAF,UAAAA,CAAWC,IAAAA,CAAAA;AACb,IAAA,CAAA;IAEA,OAAOtD,MAAAA;AACT,CAAA;AAEA,MAAM6D,UAAAA,GAAwC;IAC5C1C,IAAAA,EAAM;QACJ2C,aAAAA,EAAe,CAAC/D,sBAAUkB,GAAA,CAACnB,UAAAA,EAAAA;AAAY,gBAAA,GAAGC;;QAC1CgE,IAAAA,EAAMC,WAAAA;QACNd,KAAAA,EAAO;YACLH,EAAAA,EAAI,+BAAA;YACJC,cAAAA,EAAgB;AAClB,SAAA;AACAiB,QAAAA,SAAAA,EAAW,CAACxG,IAAAA,GAASA,IAAAA,CAAKK,IAAI,KAAK,MAAA;QACnCoG,kBAAAA,EAAoB,IAAA;AACpBC,QAAAA,aAAAA,CAAAA,CAAcnE,MAAM,EAAA;AAClBoE,YAAAA,iBAAAA,CAAiCpE,MAAAA,EAAQ;gBAAElC,IAAAA,EAAM,MAAA;gBAAQI,QAAAA,EAAU;AAAY,aAAA,CAAA;AACjF,QAAA,CAAA;AACAmG,QAAAA,cAAAA,CAAAA,CAAerE,MAAM,EAAA;YACnBsE,qBAAAA,CAAsBtE,MAAAA,CAAAA;AACxB,QAAA,CAAA;QACAuE,QAAAA,EAAU;AAAC,YAAA;AAAM,SAAA;QACjBC,MAAAA,EAAQpB;AACV;AACF;;;;"}
@@ -2,7 +2,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { Box, Button, Popover, Flex, Field } from '@strapi/design-system';
4
4
  import { useIntl } from 'react-intl';
5
- import { Editor, Path, Range, Point, Transforms, Element, Node } from 'slate';
5
+ import { Editor, Transforms, Range, Path, Point, Element, Node } from 'slate';
6
6
  import { ReactEditor } from 'slate-react';
7
7
  import { styled } from 'styled-components';
8
8
  import { useBlocksEditorContext } from '../BlocksEditor.mjs';
@@ -291,8 +291,11 @@ const baseRenderLeaf = (props, modifiers)=>{
291
291
  };
292
292
  const baseRenderElement = ({ props, blocks, editor, dragDirection, setDragDirection, isMobile })=>{
293
293
  const { element } = props;
294
- const blockMatch = Object.values(blocks).find((block)=>block.matchNode(element));
294
+ const blockMatch = Object.values(blocks).find((block)=>block?.matchNode(element));
295
295
  const block = blockMatch || blocks.paragraph;
296
+ if (!block) {
297
+ return /*#__PURE__*/ jsxRuntime.jsx(jsxRuntime.Fragment, {});
298
+ }
296
299
  const nodePath = slateReact.ReactEditor.findPath(editor, element);
297
300
  const isDraggable = block.isDraggable?.(element) ?? true;
298
301
  if (!isDraggable || isMobile) {
@@ -379,7 +382,7 @@ const BlocksContent = ({ placeholder, ariaLabelId })=>{
379
382
  }
380
383
  // Check if the text node starts with a known snippet
381
384
  const blockMatchingSnippet = Object.values(blocks).find((block)=>{
382
- return block.snippets?.includes(textNode.text);
385
+ return block?.snippets?.includes(textNode.text);
383
386
  });
384
387
  if (blockMatchingSnippet?.handleConvert) {
385
388
  // Prevent the space from being created and delete the snippet
@@ -399,7 +402,7 @@ const BlocksContent = ({ placeholder, ariaLabelId })=>{
399
402
  return;
400
403
  }
401
404
  const selectedNode = editor.children[editor.selection.anchor.path[0]];
402
- const selectedBlock = Object.values(blocks).find((block)=>block.matchNode(selectedNode));
405
+ const selectedBlock = Object.values(blocks).find((block)=>block?.matchNode(selectedNode));
403
406
  if (!selectedBlock) {
404
407
  return;
405
408
  }
@@ -412,7 +415,7 @@ const BlocksContent = ({ placeholder, ariaLabelId })=>{
412
415
  if (selectedBlock.handleEnterKey) {
413
416
  selectedBlock.handleEnterKey(editor);
414
417
  } else {
415
- blocks.paragraph.handleEnterKey(editor);
418
+ blocks.paragraph?.handleEnterKey(editor);
416
419
  }
417
420
  };
418
421
  const handleBackspaceEvent = (event)=>{
@@ -420,7 +423,7 @@ const BlocksContent = ({ placeholder, ariaLabelId })=>{
420
423
  return;
421
424
  }
422
425
  const selectedNode = editor.children[editor.selection.anchor.path[0]];
423
- const selectedBlock = Object.values(blocks).find((block)=>block.matchNode(selectedNode));
426
+ const selectedBlock = Object.values(blocks).find((block)=>block?.matchNode(selectedNode));
424
427
  if (!selectedBlock) {
425
428
  return;
426
429
  }
@@ -433,7 +436,7 @@ const BlocksContent = ({ placeholder, ariaLabelId })=>{
433
436
  return;
434
437
  }
435
438
  const selectedNode = editor.children[editor.selection.anchor.path[0]];
436
- const selectedBlock = Object.values(blocks).find((block)=>block.matchNode(selectedNode));
439
+ const selectedBlock = Object.values(blocks).find((block)=>block?.matchNode(selectedNode));
437
440
  if (!selectedBlock) {
438
441
  return;
439
442
  }
@@ -1 +1 @@
1
- {"version":3,"file":"BlocksContent.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useIsMobile } from '@strapi/admin/strapi-admin';\nimport {\n Box,\n BoxComponent,\n Flex,\n FlexComponent,\n IconButton,\n IconButtonComponent,\n useComposedRefs,\n} from '@strapi/design-system';\nimport { Drag } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { Editor, Range, Transforms } from 'slate';\nimport { ReactEditor, type RenderElementProps, type RenderLeafProps, Editable } from 'slate-react';\nimport { styled, CSSProperties, css } from 'styled-components';\n\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { useDragAndDrop, DIRECTIONS } from '../../../../../hooks/useDragAndDrop';\nimport { getTranslation } from '../../../../../utils/translations';\n\nimport { decorateCode } from './Blocks/Code';\nimport { type BlocksStore, useBlocksEditorContext } from './BlocksEditor';\nimport { useConversionModal } from './BlocksToolbar';\nimport { type ModifiersStore } from './Modifiers';\nimport { getEntries } from './utils/types';\n\nconst StyledEditable = styled(Editable)<{ $isExpandedMode: boolean }>`\n // The outline style is set on the wrapper with :focus-within\n outline: none;\n display: flex;\n flex-direction: column;\n gap: ${({ theme }) => theme.spaces[3]};\n height: 100%;\n // For fullscreen align input in the center with fixed width\n width: ${(props) => (props.$isExpandedMode ? '512px' : '100%')};\n margin: auto;\n font-size: 1.6rem;\n\n ${({ theme }) => theme.breakpoints.medium} {\n font-size: 1.4rem;\n }\n > *:last-child {\n padding-bottom: ${({ theme }) => theme.spaces[3]};\n }\n`;\n\nconst Wrapper = styled<BoxComponent>(Box)<{ $isOverDropTarget: boolean }>`\n position: ${({ $isOverDropTarget }) => $isOverDropTarget && 'relative'};\n`;\n\ntype DragDirection = (typeof DIRECTIONS)[keyof typeof DIRECTIONS];\n\nconst DropPlaceholder = styled<BoxComponent>(Box)<{\n dragDirection: DragDirection | null;\n placeholderMargin: 1 | 2;\n}>`\n position: absolute;\n right: 0;\n\n // Show drop placeholder 8px above or below the drop target\n ${({ dragDirection, theme, placeholderMargin }) => css`\n top: ${dragDirection === DIRECTIONS.UPWARD && `-${theme.spaces[placeholderMargin]}`};\n bottom: ${dragDirection === DIRECTIONS.DOWNWARD && `-${theme.spaces[placeholderMargin]}`};\n `}\n`;\n\nconst DragItem = styled<FlexComponent>(Flex)<{ $dragVisibility: CSSProperties['visibility'] }>`\n // Style each block rendered using renderElement()\n & > [data-slate-node='element'] {\n width: 100%;\n opacity: inherit;\n }\n\n // Set the visibility of drag button\n [role='button'] {\n visibility: ${(props) => props.$dragVisibility};\n opacity: inherit;\n }\n &[aria-disabled='true'] {\n user-drag: none;\n }\n`;\n\nconst DragIconButton = styled<IconButtonComponent<'div'>>(IconButton)<{\n $dragHandleTopMargin?: CSSProperties['marginTop'];\n}>`\n user-select: none;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n border-radius: ${({ theme }) => theme.borderRadius};\n padding-left: ${({ theme }) => theme.spaces[0]};\n padding-right: ${({ theme }) => theme.spaces[0]};\n padding-top: ${({ theme }) => theme.spaces[1]};\n padding-bottom: ${({ theme }) => theme.spaces[1]};\n visibility: hidden;\n cursor: grab;\n opacity: inherit;\n margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};\n\n &:hover {\n background: ${({ theme }) => theme.colors.neutral100};\n }\n &:active {\n cursor: grabbing;\n background: ${({ theme }) => theme.colors.neutral150};\n }\n &[aria-disabled='true'] {\n visibility: hidden;\n }\n svg {\n min-width: ${({ theme }) => theme.spaces[3]};\n\n path {\n fill: ${({ theme }) => theme.colors.neutral500};\n }\n }\n`;\n\ntype Direction = {\n setDragDirection: (direction: DragDirection) => void;\n dragDirection: DragDirection | null;\n};\n\ntype DragAndDropElementProps = Direction & {\n children: RenderElementProps['children'];\n index: Array<number>;\n dragHandleTopMargin?: CSSProperties['marginTop'];\n};\n\nconst DragAndDropElement = ({\n children,\n index,\n setDragDirection,\n dragDirection,\n dragHandleTopMargin,\n}: DragAndDropElementProps) => {\n const { editor, disabled, name, setLiveText } = useBlocksEditorContext('DragAndDropElement');\n const { formatMessage } = useIntl();\n const [dragVisibility, setDragVisibility] = React.useState<CSSProperties['visibility']>('hidden');\n const isDragAndDropEnabled = !disabled;\n\n const handleMoveBlock = React.useCallback(\n (newIndex: Array<number>, currentIndex: Array<number>) => {\n Transforms.moveNodes(editor, {\n at: currentIndex,\n to: newIndex,\n });\n\n // Add 1 to the index for the live text message\n const currentIndexPosition = [currentIndex[0] + 1, ...currentIndex.slice(1)];\n const newIndexPosition = [newIndex[0] + 1, ...newIndex.slice(1)];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('components.Blocks.dnd.reorder'),\n defaultMessage: '{item}, moved. New position in the editor: {position}.',\n },\n {\n item: `${name}.${currentIndexPosition.join(',')}`,\n position: `${newIndexPosition.join(',')} of ${editor.children.length}`,\n }\n )\n );\n },\n [editor, formatMessage, name, setLiveText]\n );\n\n const [{ handlerId, isDragging, isOverDropTarget, direction }, blockRef, dropRef, dragRef] =\n useDragAndDrop(isDragAndDropEnabled, {\n type: `${ItemTypes.BLOCKS}_${name}`,\n index,\n item: {\n index,\n displayedValue: children,\n },\n onDropItem(currentIndex, newIndex) {\n if (newIndex) handleMoveBlock(newIndex, currentIndex);\n },\n });\n\n const composedBoxRefs = useComposedRefs(blockRef, dropRef);\n\n // Set Drag direction before loosing state while dragging\n React.useEffect(() => {\n if (direction) {\n setDragDirection(direction);\n }\n }, [direction, setDragDirection]);\n\n // On selection change hide drag handle\n React.useEffect(() => {\n setDragVisibility('hidden');\n }, [editor.selection]);\n\n return (\n <Wrapper ref={composedBoxRefs} $isOverDropTarget={isOverDropTarget}>\n {isOverDropTarget && (\n <DropPlaceholder\n borderStyle=\"solid\"\n borderColor=\"secondary200\"\n borderWidth=\"2px\"\n width=\"calc(100% - 24px)\"\n marginLeft=\"auto\"\n dragDirection={dragDirection}\n // For list items placeholder reduce the margin around\n placeholderMargin={children.props.as && children.props.as === 'li' ? 1 : 2}\n />\n )}\n {isDragging ? (\n <CloneDragItem dragHandleTopMargin={dragHandleTopMargin}>{children}</CloneDragItem>\n ) : (\n <DragItem\n ref={dragRef}\n data-handler-id={handlerId}\n gap={2}\n paddingLeft={2}\n alignItems=\"start\"\n onDragStart={\n isDragAndDropEnabled\n ? (event) => {\n const target = event.target as HTMLElement;\n const currentTarget = event.currentTarget as HTMLElement;\n\n // Dragging action should only trigger drag event when button is dragged, however update styles on the whole dragItem.\n if (target.getAttribute('role') !== 'button') {\n event.preventDefault();\n } else {\n // Setting styles using dragging state is not working, so set it on current target element as nodes get dragged\n currentTarget.style.opacity = '0.5';\n }\n }\n : undefined\n }\n onDragEnd={\n isDragAndDropEnabled\n ? (event) => {\n const currentTarget = event.currentTarget as HTMLElement;\n currentTarget.style.opacity = '1';\n }\n : undefined\n }\n onMouseEnter={() => setDragVisibility('visible')}\n onFocusCapture={() => setDragVisibility('visible')}\n onBlurCapture={() => setDragVisibility('hidden')}\n onMouseLeave={() => setDragVisibility('hidden')}\n aria-disabled={disabled}\n $dragVisibility={dragVisibility}\n >\n <DragIconButton\n tag=\"div\"\n contentEditable={false}\n role=\"button\"\n tabIndex={0}\n withTooltip={false}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n onClick={(e: React.MouseEvent) => e.stopPropagation()}\n aria-disabled={disabled}\n disabled={disabled}\n draggable={isDragAndDropEnabled}\n // For some blocks top margin added to drag handle to align at the text level\n $dragHandleTopMargin={dragHandleTopMargin}\n >\n <Drag color=\"primary500\" />\n </DragIconButton>\n {children}\n </DragItem>\n )}\n </Wrapper>\n );\n};\n\ninterface CloneDragItemProps {\n children: RenderElementProps['children'];\n dragHandleTopMargin?: CSSProperties['marginTop'];\n}\n\n// To prevent applying opacity to the original item being dragged, display a cloned element without opacity.\nconst CloneDragItem = ({ children, dragHandleTopMargin }: CloneDragItemProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <DragItem gap={2} paddingLeft={2} alignItems=\"start\" $dragVisibility=\"visible\">\n <DragIconButton\n tag=\"div\"\n role=\"button\"\n withTooltip={false}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n $dragHandleTopMargin={dragHandleTopMargin}\n >\n <Drag color=\"neutral600\" />\n </DragIconButton>\n {children}\n </DragItem>\n );\n};\n\ninterface ExtendedRenderLeafProps extends RenderLeafProps {\n leaf: RenderLeafProps['leaf'] & { className?: string };\n}\n\nconst baseRenderLeaf = (props: ExtendedRenderLeafProps, modifiers: ModifiersStore) => {\n // Recursively wrap the children for each active modifier\n const wrappedChildren = getEntries(modifiers).reduce((currentChildren, modifierEntry) => {\n const [name, modifier] = modifierEntry;\n\n if (props.leaf[name]) {\n return modifier.renderLeaf(currentChildren);\n }\n\n return currentChildren;\n }, props.children);\n\n return (\n <span {...props.attributes} className={props.leaf.className}>\n {wrappedChildren}\n </span>\n );\n};\n\ntype BaseRenderElementProps = Direction & {\n props: RenderElementProps['children'];\n blocks: BlocksStore;\n editor: Editor;\n isMobile: boolean;\n};\n\nconst baseRenderElement = ({\n props,\n blocks,\n editor,\n dragDirection,\n setDragDirection,\n isMobile,\n}: BaseRenderElementProps) => {\n const { element } = props;\n\n const blockMatch = Object.values(blocks).find((block) => block.matchNode(element));\n const block = blockMatch || blocks.paragraph;\n const nodePath = ReactEditor.findPath(editor, element);\n\n const isDraggable = block.isDraggable?.(element) ?? true;\n\n if (!isDraggable || isMobile) {\n return block.renderElement(props);\n }\n\n return (\n <DragAndDropElement\n index={nodePath}\n setDragDirection={setDragDirection}\n dragDirection={dragDirection}\n dragHandleTopMargin={block.dragHandleTopMargin}\n >\n {block.renderElement(props)}\n </DragAndDropElement>\n );\n};\n\nconst dragNoop = () => true;\n\ninterface BlocksContentProps {\n placeholder?: string;\n ariaLabelId: string;\n}\n\nconst BlocksContent = ({ placeholder, ariaLabelId }: BlocksContentProps) => {\n const { editor, disabled, blocks, modifiers, setLiveText, isExpandedMode, flushPendingFormSync } =\n useBlocksEditorContext('BlocksContent');\n const isMobile = useIsMobile();\n const blocksRef = React.useRef<HTMLDivElement>(null);\n const { formatMessage } = useIntl();\n const [dragDirection, setDragDirection] = React.useState<DragDirection | null>(null);\n const { modalElement, handleConversionResult } = useConversionModal();\n\n // Create renderLeaf function based on the modifiers store\n const renderLeaf = React.useCallback(\n (props: ExtendedRenderLeafProps) => baseRenderLeaf(props, modifiers),\n [modifiers]\n );\n\n const handleMoveBlocks = (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) return;\n\n const start = Range.start(editor.selection);\n const currentIndex = [start.path[0]];\n let newIndexPosition = 0;\n\n if (event.key === 'ArrowUp') {\n newIndexPosition = currentIndex[0] > 0 ? currentIndex[0] - 1 : currentIndex[0];\n } else {\n newIndexPosition =\n currentIndex[0] < editor.children.length - 1 ? currentIndex[0] + 1 : currentIndex[0];\n }\n\n const newIndex = [newIndexPosition];\n\n if (newIndexPosition !== currentIndex[0]) {\n Transforms.moveNodes(editor, {\n at: currentIndex,\n to: newIndex,\n });\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('components.Blocks.dnd.reorder'),\n defaultMessage: '{item}, moved. New position in the editor: {position}.',\n },\n {\n item: `${name}.${currentIndex[0] + 1}`,\n position: `${newIndex[0] + 1} of ${editor.children.length}`,\n }\n )\n );\n\n event.preventDefault();\n }\n };\n\n // Create renderElement function base on the blocks store\n const renderElement = React.useCallback(\n (props: RenderElementProps) =>\n baseRenderElement({ props, blocks, editor, dragDirection, setDragDirection, isMobile }),\n [blocks, editor, dragDirection, isMobile, setDragDirection]\n );\n\n const checkSnippet = (event: React.KeyboardEvent<HTMLElement>) => {\n // Get current text block\n if (!editor.selection) {\n return;\n }\n\n const [textNode, textNodePath] = Editor.node(editor, editor.selection.anchor.path);\n\n // Narrow the type to a text node\n if (Editor.isEditor(textNode) || textNode.type !== 'text') {\n return;\n }\n\n // Don't check for snippets if we're not at the start of a block\n if (textNodePath.at(-1) !== 0) {\n return;\n }\n\n // Check if the text node starts with a known snippet\n const blockMatchingSnippet = Object.values(blocks).find((block) => {\n return block.snippets?.includes(textNode.text);\n });\n\n if (blockMatchingSnippet?.handleConvert) {\n // Prevent the space from being created and delete the snippet\n event.preventDefault();\n Transforms.delete(editor, {\n distance: textNode.text.length,\n unit: 'character',\n reverse: true,\n });\n\n // Convert the selected block\n const maybeRenderModal = blockMatchingSnippet.handleConvert(editor);\n handleConversionResult(maybeRenderModal);\n }\n };\n\n const handleEnter = (event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) {\n return;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n const selectedBlock = Object.values(blocks).find((block) => block.matchNode(selectedNode));\n if (!selectedBlock) {\n return;\n }\n\n // Allow forced line breaks when shift is pressed\n if (event.shiftKey && selectedNode.type !== 'image') {\n Transforms.insertText(editor, '\\n');\n return;\n }\n\n // Check if there's an enter handler for the selected block\n if (selectedBlock.handleEnterKey) {\n selectedBlock.handleEnterKey(editor);\n } else {\n blocks.paragraph.handleEnterKey!(editor);\n }\n };\n\n const handleBackspaceEvent = (event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) {\n return;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n const selectedBlock = Object.values(blocks).find((block) => block.matchNode(selectedNode));\n\n if (!selectedBlock) {\n return;\n }\n\n if (selectedBlock.handleBackspaceKey) {\n selectedBlock.handleBackspaceKey(editor, event);\n }\n };\n\n const handleTab = (event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) {\n return;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n const selectedBlock = Object.values(blocks).find((block) => block.matchNode(selectedNode));\n if (!selectedBlock) {\n return;\n }\n\n event.preventDefault();\n\n if (event.shiftKey && selectedBlock.handleShiftTab) {\n // Handle Shift+Tab (unindent)\n selectedBlock.handleShiftTab(editor);\n } else if (!event.shiftKey && selectedBlock.handleTab) {\n // Handle Tab (indent)\n selectedBlock.handleTab(editor);\n }\n };\n\n const handleKeyboardShortcuts = (event: React.KeyboardEvent<HTMLElement>) => {\n const isCtrlOrCmd = event.metaKey || event.ctrlKey;\n\n if (isCtrlOrCmd) {\n // Check if there's a modifier to toggle\n Object.values(modifiers).forEach((value) => {\n if (value.isValidEventKey(event)) {\n event.preventDefault();\n value.handleToggle(editor);\n return;\n }\n });\n if (event.shiftKey && ['ArrowUp', 'ArrowDown'].includes(event.key)) {\n handleMoveBlocks(editor, event);\n }\n }\n };\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLElement> = (event) => {\n // Find the right block-specific handlers for enter and backspace key presses\n switch (event.key) {\n case 'Enter':\n event.preventDefault();\n return handleEnter(event);\n case 'Backspace':\n return handleBackspaceEvent(event);\n case 'Tab':\n return handleTab(event);\n case 'Escape':\n return ReactEditor.blur(editor);\n }\n handleKeyboardShortcuts(event);\n // Check if a snippet was triggered\n if (event.key === ' ') {\n checkSnippet(event);\n }\n };\n\n /**\n * scrollSelectionIntoView : Slate's default method to scroll a DOM selection into the view,\n * thats shifting layout for us when there is a overflowY:scroll on the viewport.\n * We are overriding it to check if the selection is not fully within the visible area of the editor,\n * we use scrollBy one line to the bottom\n */\n\n const handleScrollSelectionIntoView = React.useCallback(() => {\n if (!editor.selection || !blocksRef.current) {\n return;\n }\n\n const domRange = ReactEditor.toDOMRange(editor, editor.selection);\n const domRect = domRange.getBoundingClientRect();\n\n const editorRect = blocksRef.current.getBoundingClientRect();\n\n // Check if the selection is not fully within the visible area of the editor\n if (domRect.top < editorRect.top || domRect.bottom > editorRect.bottom) {\n // Scroll by one line to the bottom\n blocksRef.current.scrollBy({\n top: 28, // 20px is the line-height + 8px line gap\n behavior: 'smooth',\n });\n }\n }, [editor]);\n\n return (\n <Box\n ref={blocksRef}\n grow={1}\n width=\"100%\"\n overflow=\"auto\"\n fontSize={2}\n background=\"neutral0\"\n color=\"neutral800\"\n lineHeight={6}\n paddingLeft={{ initial: 4, medium: 0 }}\n paddingRight={7}\n paddingTop={6}\n paddingBottom={3}\n >\n <StyledEditable\n aria-labelledby={ariaLabelId}\n readOnly={disabled}\n placeholder={placeholder}\n $isExpandedMode={isExpandedMode}\n decorate={decorateCode}\n renderElement={renderElement}\n renderLeaf={renderLeaf}\n onKeyDown={handleKeyDown}\n scrollSelectionIntoView={handleScrollSelectionIntoView}\n onBlur={flushPendingFormSync}\n // As we have our own handler to drag and drop the elements returing true will skip slate's own event handler\n onDrop={dragNoop}\n onDragStart={dragNoop}\n />\n {modalElement}\n </Box>\n );\n};\n\nexport { BlocksContent, BlocksContentProps };\n"],"names":["StyledEditable","styled","Editable","theme","spaces","props","$isExpandedMode","breakpoints","medium","Wrapper","Box","$isOverDropTarget","DropPlaceholder","dragDirection","placeholderMargin","css","DIRECTIONS","UPWARD","DOWNWARD","DragItem","Flex","$dragVisibility","DragIconButton","IconButton","borderRadius","$dragHandleTopMargin","colors","neutral100","neutral150","neutral500","DragAndDropElement","children","index","setDragDirection","dragHandleTopMargin","editor","disabled","name","setLiveText","useBlocksEditorContext","formatMessage","useIntl","dragVisibility","setDragVisibility","React","useState","isDragAndDropEnabled","handleMoveBlock","useCallback","newIndex","currentIndex","Transforms","moveNodes","at","to","currentIndexPosition","slice","newIndexPosition","id","getTranslation","defaultMessage","item","join","position","length","handlerId","isDragging","isOverDropTarget","direction","blockRef","dropRef","dragRef","useDragAndDrop","type","ItemTypes","BLOCKS","displayedValue","onDropItem","composedBoxRefs","useComposedRefs","useEffect","selection","_jsxs","ref","_jsx","borderStyle","borderColor","borderWidth","width","marginLeft","as","CloneDragItem","data-handler-id","gap","paddingLeft","alignItems","onDragStart","event","target","currentTarget","getAttribute","preventDefault","style","opacity","undefined","onDragEnd","onMouseEnter","onFocusCapture","onBlurCapture","onMouseLeave","aria-disabled","tag","contentEditable","role","tabIndex","withTooltip","label","onClick","e","stopPropagation","draggable","Drag","color","baseRenderLeaf","modifiers","wrappedChildren","getEntries","reduce","currentChildren","modifierEntry","modifier","leaf","renderLeaf","span","attributes","className","baseRenderElement","blocks","isMobile","element","blockMatch","Object","values","find","block","matchNode","paragraph","nodePath","ReactEditor","findPath","isDraggable","renderElement","dragNoop","BlocksContent","placeholder","ariaLabelId","isExpandedMode","flushPendingFormSync","useIsMobile","blocksRef","useRef","modalElement","handleConversionResult","useConversionModal","handleMoveBlocks","start","Range","path","key","checkSnippet","textNode","textNodePath","Editor","node","anchor","isEditor","blockMatchingSnippet","snippets","includes","text","handleConvert","delete","distance","unit","reverse","maybeRenderModal","handleEnter","selectedNode","selectedBlock","shiftKey","insertText","handleEnterKey","handleBackspaceEvent","handleBackspaceKey","handleTab","handleShiftTab","handleKeyboardShortcuts","isCtrlOrCmd","metaKey","ctrlKey","forEach","value","isValidEventKey","handleToggle","handleKeyDown","blur","handleScrollSelectionIntoView","current","domRange","toDOMRange","domRect","getBoundingClientRect","editorRect","top","bottom","scrollBy","behavior","grow","overflow","fontSize","background","lineHeight","initial","paddingRight","paddingTop","paddingBottom","aria-labelledby","readOnly","decorate","decorateCode","onKeyDown","scrollSelectionIntoView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QAAAA,EAAU;AACZ,aAAA,CAAA;AACF,QAAA;IACF,CAAA,EAAG;AAACrL,QAAAA;AAAO,KAAA,CAAA;AAEX,IAAA,qBACE+C,eAAA,CAACxE,gBAAAA,EAAAA;QACCyE,GAAAA,EAAK4E,SAAAA;QACL0D,IAAAA,EAAM,CAAA;QACNjI,KAAAA,EAAM,MAAA;QACNkI,QAAAA,EAAS,MAAA;QACTC,QAAAA,EAAU,CAAA;QACVC,UAAAA,EAAW,UAAA;QACXlG,KAAAA,EAAM,YAAA;QACNmG,UAAAA,EAAY,CAAA;QACZ/H,WAAAA,EAAa;YAAEgI,OAAAA,EAAS,CAAA;YAAGtN,MAAAA,EAAQ;AAAE,SAAA;QACrCuN,YAAAA,EAAc,CAAA;QACdC,UAAAA,EAAY,CAAA;QACZC,aAAAA,EAAe,CAAA;;0BAEf7I,cAAA,CAACpF,cAAAA,EAAAA;gBACCkO,iBAAAA,EAAiBvE,WAAAA;gBACjBwE,QAAAA,EAAU/L,QAAAA;gBACVsH,WAAAA,EAAaA,WAAAA;gBACbpJ,eAAAA,EAAiBsJ,cAAAA;gBACjBwE,QAAAA,EAAUC,iBAAAA;gBACV9E,aAAAA,EAAeA,aAAAA;gBACfnB,UAAAA,EAAYA,UAAAA;gBACZkG,SAAAA,EAAW1B,aAAAA;gBACX2B,uBAAAA,EAAyBzB,6BAAAA;gBACzB0B,MAAAA,EAAQ3E,oBAAAA;;gBAER4E,MAAAA,EAAQjF,QAAAA;gBACRxD,WAAAA,EAAawD;;AAEdS,YAAAA;;;AAGP;;;;"}
1
+ {"version":3,"file":"BlocksContent.js","sources":["../../../../../../../admin/src/pages/EditView/components/FormInputs/BlocksInput/BlocksContent.tsx"],"sourcesContent":["import * as React from 'react';\n\nimport { useIsMobile } from '@strapi/admin/strapi-admin';\nimport {\n Box,\n BoxComponent,\n Flex,\n FlexComponent,\n IconButton,\n IconButtonComponent,\n useComposedRefs,\n} from '@strapi/design-system';\nimport { Drag } from '@strapi/icons';\nimport { useIntl } from 'react-intl';\nimport { Editor, Range, Transforms } from 'slate';\nimport { ReactEditor, type RenderElementProps, type RenderLeafProps, Editable } from 'slate-react';\nimport { styled, CSSProperties, css } from 'styled-components';\n\nimport { ItemTypes } from '../../../../../constants/dragAndDrop';\nimport { useDragAndDrop, DIRECTIONS } from '../../../../../hooks/useDragAndDrop';\nimport { getTranslation } from '../../../../../utils/translations';\n\nimport { decorateCode } from './Blocks/Code';\nimport { type BlocksStore, useBlocksEditorContext } from './BlocksEditor';\nimport { useConversionModal } from './BlocksToolbar';\nimport { type ModifiersStore } from './Modifiers';\nimport { getEntries } from './utils/types';\n\nconst StyledEditable = styled(Editable)<{ $isExpandedMode: boolean }>`\n // The outline style is set on the wrapper with :focus-within\n outline: none;\n display: flex;\n flex-direction: column;\n gap: ${({ theme }) => theme.spaces[3]};\n height: 100%;\n // For fullscreen align input in the center with fixed width\n width: ${(props) => (props.$isExpandedMode ? '512px' : '100%')};\n margin: auto;\n font-size: 1.6rem;\n\n ${({ theme }) => theme.breakpoints.medium} {\n font-size: 1.4rem;\n }\n > *:last-child {\n padding-bottom: ${({ theme }) => theme.spaces[3]};\n }\n`;\n\nconst Wrapper = styled<BoxComponent>(Box)<{ $isOverDropTarget: boolean }>`\n position: ${({ $isOverDropTarget }) => $isOverDropTarget && 'relative'};\n`;\n\ntype DragDirection = (typeof DIRECTIONS)[keyof typeof DIRECTIONS];\n\nconst DropPlaceholder = styled<BoxComponent>(Box)<{\n dragDirection: DragDirection | null;\n placeholderMargin: 1 | 2;\n}>`\n position: absolute;\n right: 0;\n\n // Show drop placeholder 8px above or below the drop target\n ${({ dragDirection, theme, placeholderMargin }) => css`\n top: ${dragDirection === DIRECTIONS.UPWARD && `-${theme.spaces[placeholderMargin]}`};\n bottom: ${dragDirection === DIRECTIONS.DOWNWARD && `-${theme.spaces[placeholderMargin]}`};\n `}\n`;\n\nconst DragItem = styled<FlexComponent>(Flex)<{ $dragVisibility: CSSProperties['visibility'] }>`\n // Style each block rendered using renderElement()\n & > [data-slate-node='element'] {\n width: 100%;\n opacity: inherit;\n }\n\n // Set the visibility of drag button\n [role='button'] {\n visibility: ${(props) => props.$dragVisibility};\n opacity: inherit;\n }\n &[aria-disabled='true'] {\n user-drag: none;\n }\n`;\n\nconst DragIconButton = styled<IconButtonComponent<'div'>>(IconButton)<{\n $dragHandleTopMargin?: CSSProperties['marginTop'];\n}>`\n user-select: none;\n display: flex;\n align-items: center;\n justify-content: center;\n border: none;\n border-radius: ${({ theme }) => theme.borderRadius};\n padding-left: ${({ theme }) => theme.spaces[0]};\n padding-right: ${({ theme }) => theme.spaces[0]};\n padding-top: ${({ theme }) => theme.spaces[1]};\n padding-bottom: ${({ theme }) => theme.spaces[1]};\n visibility: hidden;\n cursor: grab;\n opacity: inherit;\n margin-top: ${(props) => props.$dragHandleTopMargin ?? 0};\n\n &:hover {\n background: ${({ theme }) => theme.colors.neutral100};\n }\n &:active {\n cursor: grabbing;\n background: ${({ theme }) => theme.colors.neutral150};\n }\n &[aria-disabled='true'] {\n visibility: hidden;\n }\n svg {\n min-width: ${({ theme }) => theme.spaces[3]};\n\n path {\n fill: ${({ theme }) => theme.colors.neutral500};\n }\n }\n`;\n\ntype Direction = {\n setDragDirection: (direction: DragDirection) => void;\n dragDirection: DragDirection | null;\n};\n\ntype DragAndDropElementProps = Direction & {\n children: RenderElementProps['children'];\n index: Array<number>;\n dragHandleTopMargin?: CSSProperties['marginTop'];\n};\n\nconst DragAndDropElement = ({\n children,\n index,\n setDragDirection,\n dragDirection,\n dragHandleTopMargin,\n}: DragAndDropElementProps) => {\n const { editor, disabled, name, setLiveText } = useBlocksEditorContext('DragAndDropElement');\n const { formatMessage } = useIntl();\n const [dragVisibility, setDragVisibility] = React.useState<CSSProperties['visibility']>('hidden');\n const isDragAndDropEnabled = !disabled;\n\n const handleMoveBlock = React.useCallback(\n (newIndex: Array<number>, currentIndex: Array<number>) => {\n Transforms.moveNodes(editor, {\n at: currentIndex,\n to: newIndex,\n });\n\n // Add 1 to the index for the live text message\n const currentIndexPosition = [currentIndex[0] + 1, ...currentIndex.slice(1)];\n const newIndexPosition = [newIndex[0] + 1, ...newIndex.slice(1)];\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('components.Blocks.dnd.reorder'),\n defaultMessage: '{item}, moved. New position in the editor: {position}.',\n },\n {\n item: `${name}.${currentIndexPosition.join(',')}`,\n position: `${newIndexPosition.join(',')} of ${editor.children.length}`,\n }\n )\n );\n },\n [editor, formatMessage, name, setLiveText]\n );\n\n const [{ handlerId, isDragging, isOverDropTarget, direction }, blockRef, dropRef, dragRef] =\n useDragAndDrop(isDragAndDropEnabled, {\n type: `${ItemTypes.BLOCKS}_${name}`,\n index,\n item: {\n index,\n displayedValue: children,\n },\n onDropItem(currentIndex, newIndex) {\n if (newIndex) handleMoveBlock(newIndex, currentIndex);\n },\n });\n\n const composedBoxRefs = useComposedRefs(blockRef, dropRef);\n\n // Set Drag direction before loosing state while dragging\n React.useEffect(() => {\n if (direction) {\n setDragDirection(direction);\n }\n }, [direction, setDragDirection]);\n\n // On selection change hide drag handle\n React.useEffect(() => {\n setDragVisibility('hidden');\n }, [editor.selection]);\n\n return (\n <Wrapper ref={composedBoxRefs} $isOverDropTarget={isOverDropTarget}>\n {isOverDropTarget && (\n <DropPlaceholder\n borderStyle=\"solid\"\n borderColor=\"secondary200\"\n borderWidth=\"2px\"\n width=\"calc(100% - 24px)\"\n marginLeft=\"auto\"\n dragDirection={dragDirection}\n // For list items placeholder reduce the margin around\n placeholderMargin={children.props.as && children.props.as === 'li' ? 1 : 2}\n />\n )}\n {isDragging ? (\n <CloneDragItem dragHandleTopMargin={dragHandleTopMargin}>{children}</CloneDragItem>\n ) : (\n <DragItem\n ref={dragRef}\n data-handler-id={handlerId}\n gap={2}\n paddingLeft={2}\n alignItems=\"start\"\n onDragStart={\n isDragAndDropEnabled\n ? (event) => {\n const target = event.target as HTMLElement;\n const currentTarget = event.currentTarget as HTMLElement;\n\n // Dragging action should only trigger drag event when button is dragged, however update styles on the whole dragItem.\n if (target.getAttribute('role') !== 'button') {\n event.preventDefault();\n } else {\n // Setting styles using dragging state is not working, so set it on current target element as nodes get dragged\n currentTarget.style.opacity = '0.5';\n }\n }\n : undefined\n }\n onDragEnd={\n isDragAndDropEnabled\n ? (event) => {\n const currentTarget = event.currentTarget as HTMLElement;\n currentTarget.style.opacity = '1';\n }\n : undefined\n }\n onMouseEnter={() => setDragVisibility('visible')}\n onFocusCapture={() => setDragVisibility('visible')}\n onBlurCapture={() => setDragVisibility('hidden')}\n onMouseLeave={() => setDragVisibility('hidden')}\n aria-disabled={disabled}\n $dragVisibility={dragVisibility}\n >\n <DragIconButton\n tag=\"div\"\n contentEditable={false}\n role=\"button\"\n tabIndex={0}\n withTooltip={false}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n onClick={(e: React.MouseEvent) => e.stopPropagation()}\n aria-disabled={disabled}\n disabled={disabled}\n draggable={isDragAndDropEnabled}\n // For some blocks top margin added to drag handle to align at the text level\n $dragHandleTopMargin={dragHandleTopMargin}\n >\n <Drag color=\"primary500\" />\n </DragIconButton>\n {children}\n </DragItem>\n )}\n </Wrapper>\n );\n};\n\ninterface CloneDragItemProps {\n children: RenderElementProps['children'];\n dragHandleTopMargin?: CSSProperties['marginTop'];\n}\n\n// To prevent applying opacity to the original item being dragged, display a cloned element without opacity.\nconst CloneDragItem = ({ children, dragHandleTopMargin }: CloneDragItemProps) => {\n const { formatMessage } = useIntl();\n\n return (\n <DragItem gap={2} paddingLeft={2} alignItems=\"start\" $dragVisibility=\"visible\">\n <DragIconButton\n tag=\"div\"\n role=\"button\"\n withTooltip={false}\n label={formatMessage({\n id: getTranslation('components.DragHandle-label'),\n defaultMessage: 'Drag',\n })}\n $dragHandleTopMargin={dragHandleTopMargin}\n >\n <Drag color=\"neutral600\" />\n </DragIconButton>\n {children}\n </DragItem>\n );\n};\n\ninterface ExtendedRenderLeafProps extends RenderLeafProps {\n leaf: RenderLeafProps['leaf'] & { className?: string };\n}\n\nconst baseRenderLeaf = (props: ExtendedRenderLeafProps, modifiers: ModifiersStore) => {\n // Recursively wrap the children for each active modifier\n const wrappedChildren = getEntries(modifiers).reduce((currentChildren, modifierEntry) => {\n const [name, modifier] = modifierEntry;\n\n if (props.leaf[name]) {\n return modifier.renderLeaf(currentChildren);\n }\n\n return currentChildren;\n }, props.children);\n\n return (\n <span {...props.attributes} className={props.leaf.className}>\n {wrappedChildren}\n </span>\n );\n};\n\ntype BaseRenderElementProps = Direction & {\n props: RenderElementProps['children'];\n blocks: Partial<BlocksStore>;\n editor: Editor;\n isMobile: boolean;\n};\n\nconst baseRenderElement = ({\n props,\n blocks,\n editor,\n dragDirection,\n setDragDirection,\n isMobile,\n}: BaseRenderElementProps) => {\n const { element } = props;\n\n const blockMatch = Object.values(blocks).find((block) => block?.matchNode(element));\n const block = blockMatch || blocks.paragraph;\n\n if (!block) {\n return <></>;\n }\n\n const nodePath = ReactEditor.findPath(editor, element);\n\n const isDraggable = block.isDraggable?.(element) ?? true;\n\n if (!isDraggable || isMobile) {\n return block.renderElement(props);\n }\n\n return (\n <DragAndDropElement\n index={nodePath}\n setDragDirection={setDragDirection}\n dragDirection={dragDirection}\n dragHandleTopMargin={block.dragHandleTopMargin}\n >\n {block.renderElement(props)}\n </DragAndDropElement>\n );\n};\n\nconst dragNoop = () => true;\n\ninterface BlocksContentProps {\n placeholder?: string;\n ariaLabelId: string;\n}\n\nconst BlocksContent = ({ placeholder, ariaLabelId }: BlocksContentProps) => {\n const { editor, disabled, blocks, modifiers, setLiveText, isExpandedMode, flushPendingFormSync } =\n useBlocksEditorContext('BlocksContent');\n const isMobile = useIsMobile();\n const blocksRef = React.useRef<HTMLDivElement>(null);\n const { formatMessage } = useIntl();\n const [dragDirection, setDragDirection] = React.useState<DragDirection | null>(null);\n const { modalElement, handleConversionResult } = useConversionModal();\n\n // Create renderLeaf function based on the modifiers store\n const renderLeaf = React.useCallback(\n (props: ExtendedRenderLeafProps) => baseRenderLeaf(props, modifiers),\n [modifiers]\n );\n\n const handleMoveBlocks = (editor: Editor, event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) return;\n\n const start = Range.start(editor.selection);\n const currentIndex = [start.path[0]];\n let newIndexPosition = 0;\n\n if (event.key === 'ArrowUp') {\n newIndexPosition = currentIndex[0] > 0 ? currentIndex[0] - 1 : currentIndex[0];\n } else {\n newIndexPosition =\n currentIndex[0] < editor.children.length - 1 ? currentIndex[0] + 1 : currentIndex[0];\n }\n\n const newIndex = [newIndexPosition];\n\n if (newIndexPosition !== currentIndex[0]) {\n Transforms.moveNodes(editor, {\n at: currentIndex,\n to: newIndex,\n });\n\n setLiveText(\n formatMessage(\n {\n id: getTranslation('components.Blocks.dnd.reorder'),\n defaultMessage: '{item}, moved. New position in the editor: {position}.',\n },\n {\n item: `${name}.${currentIndex[0] + 1}`,\n position: `${newIndex[0] + 1} of ${editor.children.length}`,\n }\n )\n );\n\n event.preventDefault();\n }\n };\n\n // Create renderElement function base on the blocks store\n const renderElement = React.useCallback(\n (props: RenderElementProps) =>\n baseRenderElement({ props, blocks, editor, dragDirection, setDragDirection, isMobile }),\n [blocks, editor, dragDirection, isMobile, setDragDirection]\n );\n\n const checkSnippet = (event: React.KeyboardEvent<HTMLElement>) => {\n // Get current text block\n if (!editor.selection) {\n return;\n }\n\n const [textNode, textNodePath] = Editor.node(editor, editor.selection.anchor.path);\n\n // Narrow the type to a text node\n if (Editor.isEditor(textNode) || textNode.type !== 'text') {\n return;\n }\n\n // Don't check for snippets if we're not at the start of a block\n if (textNodePath.at(-1) !== 0) {\n return;\n }\n\n // Check if the text node starts with a known snippet\n const blockMatchingSnippet = Object.values(blocks).find((block) => {\n return block?.snippets?.includes(textNode.text);\n });\n\n if (blockMatchingSnippet?.handleConvert) {\n // Prevent the space from being created and delete the snippet\n event.preventDefault();\n Transforms.delete(editor, {\n distance: textNode.text.length,\n unit: 'character',\n reverse: true,\n });\n\n // Convert the selected block\n const maybeRenderModal = blockMatchingSnippet.handleConvert(editor);\n handleConversionResult(maybeRenderModal);\n }\n };\n\n const handleEnter = (event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) {\n return;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n const selectedBlock = Object.values(blocks).find((block) => block?.matchNode(selectedNode));\n if (!selectedBlock) {\n return;\n }\n\n // Allow forced line breaks when shift is pressed\n if (event.shiftKey && selectedNode.type !== 'image') {\n Transforms.insertText(editor, '\\n');\n return;\n }\n\n // Check if there's an enter handler for the selected block\n if (selectedBlock.handleEnterKey) {\n selectedBlock.handleEnterKey(editor);\n } else {\n blocks.paragraph?.handleEnterKey!(editor);\n }\n };\n\n const handleBackspaceEvent = (event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) {\n return;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n const selectedBlock = Object.values(blocks).find((block) => block?.matchNode(selectedNode));\n\n if (!selectedBlock) {\n return;\n }\n\n if (selectedBlock.handleBackspaceKey) {\n selectedBlock.handleBackspaceKey(editor, event);\n }\n };\n\n const handleTab = (event: React.KeyboardEvent<HTMLElement>) => {\n if (!editor.selection) {\n return;\n }\n\n const selectedNode = editor.children[editor.selection.anchor.path[0]];\n const selectedBlock = Object.values(blocks).find((block) => block?.matchNode(selectedNode));\n if (!selectedBlock) {\n return;\n }\n\n event.preventDefault();\n\n if (event.shiftKey && selectedBlock.handleShiftTab) {\n // Handle Shift+Tab (unindent)\n selectedBlock.handleShiftTab(editor);\n } else if (!event.shiftKey && selectedBlock.handleTab) {\n // Handle Tab (indent)\n selectedBlock.handleTab(editor);\n }\n };\n\n const handleKeyboardShortcuts = (event: React.KeyboardEvent<HTMLElement>) => {\n const isCtrlOrCmd = event.metaKey || event.ctrlKey;\n\n if (isCtrlOrCmd) {\n // Check if there's a modifier to toggle\n Object.values(modifiers).forEach((value) => {\n if (value.isValidEventKey(event)) {\n event.preventDefault();\n value.handleToggle(editor);\n return;\n }\n });\n if (event.shiftKey && ['ArrowUp', 'ArrowDown'].includes(event.key)) {\n handleMoveBlocks(editor, event);\n }\n }\n };\n\n const handleKeyDown: React.KeyboardEventHandler<HTMLElement> = (event) => {\n // Find the right block-specific handlers for enter and backspace key presses\n switch (event.key) {\n case 'Enter':\n event.preventDefault();\n return handleEnter(event);\n case 'Backspace':\n return handleBackspaceEvent(event);\n case 'Tab':\n return handleTab(event);\n case 'Escape':\n return ReactEditor.blur(editor);\n }\n handleKeyboardShortcuts(event);\n // Check if a snippet was triggered\n if (event.key === ' ') {\n checkSnippet(event);\n }\n };\n\n /**\n * scrollSelectionIntoView : Slate's default method to scroll a DOM selection into the view,\n * thats shifting layout for us when there is a overflowY:scroll on the viewport.\n * We are overriding it to check if the selection is not fully within the visible area of the editor,\n * we use scrollBy one line to the bottom\n */\n\n const handleScrollSelectionIntoView = React.useCallback(() => {\n if (!editor.selection || !blocksRef.current) {\n return;\n }\n\n const domRange = ReactEditor.toDOMRange(editor, editor.selection);\n const domRect = domRange.getBoundingClientRect();\n\n const editorRect = blocksRef.current.getBoundingClientRect();\n\n // Check if the selection is not fully within the visible area of the editor\n if (domRect.top < editorRect.top || domRect.bottom > editorRect.bottom) {\n // Scroll by one line to the bottom\n blocksRef.current.scrollBy({\n top: 28, // 20px is the line-height + 8px line gap\n behavior: 'smooth',\n });\n }\n }, [editor]);\n\n return (\n <Box\n ref={blocksRef}\n grow={1}\n width=\"100%\"\n overflow=\"auto\"\n fontSize={2}\n background=\"neutral0\"\n color=\"neutral800\"\n lineHeight={6}\n paddingLeft={{ initial: 4, medium: 0 }}\n paddingRight={7}\n paddingTop={6}\n paddingBottom={3}\n >\n <StyledEditable\n aria-labelledby={ariaLabelId}\n readOnly={disabled}\n placeholder={placeholder}\n $isExpandedMode={isExpandedMode}\n decorate={decorateCode}\n renderElement={renderElement}\n renderLeaf={renderLeaf}\n onKeyDown={handleKeyDown}\n scrollSelectionIntoView={handleScrollSelectionIntoView}\n onBlur={flushPendingFormSync}\n // As we have our own handler to drag and drop the elements returing true will skip slate's own event handler\n onDrop={dragNoop}\n onDragStart={dragNoop}\n />\n {modalElement}\n </Box>\n );\n};\n\nexport { BlocksContent, BlocksContentProps };\n"],"names":["StyledEditable","styled","Editable","theme","spaces","props","$isExpandedMode","breakpoints","medium","Wrapper","Box","$isOverDropTarget","DropPlaceholder","dragDirection","placeholderMargin","css","DIRECTIONS","UPWARD","DOWNWARD","DragItem","Flex","$dragVisibility","DragIconButton","IconButton","borderRadius","$dragHandleTopMargin","colors","neutral100","neutral150","neutral500","DragAndDropElement","children","index","setDragDirection","dragHandleTopMargin","editor","disabled","name","setLiveText","useBlocksEditorContext","formatMessage","useIntl","dragVisibility","setDragVisibility","React","useState","isDragAndDropEnabled","handleMoveBlock","useCallback","newIndex","currentIndex","Transforms","moveNodes","at","to","currentIndexPosition","slice","newIndexPosition","id","getTranslation","defaultMessage","item","join","position","length","handlerId","isDragging","isOverDropTarget","direction","blockRef","dropRef","dragRef","useDragAndDrop","type","ItemTypes","BLOCKS","displayedValue","onDropItem","composedBoxRefs","useComposedRefs","useEffect","selection","_jsxs","ref","_jsx","borderStyle","borderColor","borderWidth","width","marginLeft","as","CloneDragItem","data-handler-id","gap","paddingLeft","alignItems","onDragStart","event","target","currentTarget","getAttribute","preventDefault","style","opacity","undefined","onDragEnd","onMouseEnter","onFocusCapture","onBlurCapture","onMouseLeave","aria-disabled","tag","contentEditable","role","tabIndex","withTooltip","label","onClick","e","stopPropagation","draggable","Drag","color","baseRenderLeaf","modifiers","wrappedChildren","getEntries","reduce","currentChildren","modifierEntry","modifier","leaf","renderLeaf","span","attributes","className","baseRenderElement","blocks","isMobile","element","blockMatch","Object","values","find","block","matchNode","paragraph","_Fragment","nodePath","ReactEditor","findPath","isDraggable","renderElement","dragNoop","BlocksContent","placeholder","ariaLabelId","isExpandedMode","flushPendingFormSync","useIsMobile","blocksRef","useRef","modalElement","handleConversionResult","useConversionModal","handleMoveBlocks","start","Range","path","key","checkSnippet","textNode","textNodePath","Editor","node","anchor","isEditor","blockMatchingSnippet","snippets","includes","text","handleConvert","delete","distance","unit","reverse","maybeRenderModal","handleEnter","selectedNode","selectedBlock","shiftKey","insertText","handleEnterKey","handleBackspaceEvent","handleBackspaceKey","handleTab","handleShiftTab","handleKeyboardShortcuts","isCtrlOrCmd","metaKey","ctrlKey","forEach","value","isValidEventKey","handleToggle","handleKeyDown","blur","handleScrollSelectionIntoView","current","domRange","toDOMRange","domRect","getBoundingClientRect","editorRect","top","bottom","scrollBy","behavior","grow","overflow","fontSize","background","lineHeight","initial","paddingRight","paddingTop","paddingBottom","aria-labelledby","readOnly","decorate","decorateCode","onKeyDown","scrollSelectionIntoView","onBlur","onDrop"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,MAAMA,cAAAA,GAAiBC,uBAAAA,CAAOC,mBAAAA,CAAuC;;;;;OAK9D,EAAE,CAAC,EAAEC,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;;;AAG/B,SAAA,EAAE,CAACC,KAAAA,GAAWA,KAAAA,CAAMC,eAAe,GAAG,UAAU,MAAA,CAAQ;;;;EAI/D,EAAE,CAAC,EAAEH,KAAK,EAAE,GAAKA,KAAAA,CAAMI,WAAW,CAACC,MAAM,CAAC;;;;oBAIxB,EAAE,CAAC,EAAEL,KAAK,EAAE,GAAKA,KAAAA,CAAMC,MAAM,CAAC,CAAA,CAAE,CAAC;;AAErD,CAAC;AAED,MAAMK,OAAAA,GAAUR,uBAAAA,CAAqBS,gBAAAA,CAAoC;AAC7D,YAAA,EAAE,CAAC,EAAEC,iBAAiB,EAAE,GAAKA,qBAAqB,UAAA,CAAW;AACzE,CAAC;AAID,MAAMC,eAAAA,GAAkBX,uBAAAA,CAAqBS,gBAAAA,CAG3C;;;;;EAKA,EAAE,CAAC,EAAEG,aAAa,EAAEV,KAAK,EAAEW,iBAAiB,EA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eAAAA,EAAiBuJ,cAAAA;gBACjBwE,QAAAA,EAAUC,iBAAAA;gBACV9E,aAAAA,EAAeA,aAAAA;gBACfpB,UAAAA,EAAYA,UAAAA;gBACZmG,SAAAA,EAAW1B,aAAAA;gBACX2B,uBAAAA,EAAyBzB,6BAAAA;gBACzB0B,MAAAA,EAAQ3E,oBAAAA;;gBAER4E,MAAAA,EAAQjF,QAAAA;gBACRzD,WAAAA,EAAayD;;AAEdS,YAAAA;;;AAGP;;;;"}
@@ -1,4 +1,4 @@
1
- import { jsxs, jsx } from 'react/jsx-runtime';
1
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
2
2
  import * as React from 'react';
3
3
  import { useIsMobile } from '@strapi/admin/strapi-admin';
4
4
  import { Box, Flex, IconButton, useComposedRefs } from '@strapi/design-system';
@@ -270,8 +270,11 @@ const baseRenderLeaf = (props, modifiers)=>{
270
270
  };
271
271
  const baseRenderElement = ({ props, blocks, editor, dragDirection, setDragDirection, isMobile })=>{
272
272
  const { element } = props;
273
- const blockMatch = Object.values(blocks).find((block)=>block.matchNode(element));
273
+ const blockMatch = Object.values(blocks).find((block)=>block?.matchNode(element));
274
274
  const block = blockMatch || blocks.paragraph;
275
+ if (!block) {
276
+ return /*#__PURE__*/ jsx(Fragment, {});
277
+ }
275
278
  const nodePath = ReactEditor.findPath(editor, element);
276
279
  const isDraggable = block.isDraggable?.(element) ?? true;
277
280
  if (!isDraggable || isMobile) {
@@ -358,7 +361,7 @@ const BlocksContent = ({ placeholder, ariaLabelId })=>{
358
361
  }
359
362
  // Check if the text node starts with a known snippet
360
363
  const blockMatchingSnippet = Object.values(blocks).find((block)=>{
361
- return block.snippets?.includes(textNode.text);
364
+ return block?.snippets?.includes(textNode.text);
362
365
  });
363
366
  if (blockMatchingSnippet?.handleConvert) {
364
367
  // Prevent the space from being created and delete the snippet
@@ -378,7 +381,7 @@ const BlocksContent = ({ placeholder, ariaLabelId })=>{
378
381
  return;
379
382
  }
380
383
  const selectedNode = editor.children[editor.selection.anchor.path[0]];
381
- const selectedBlock = Object.values(blocks).find((block)=>block.matchNode(selectedNode));
384
+ const selectedBlock = Object.values(blocks).find((block)=>block?.matchNode(selectedNode));
382
385
  if (!selectedBlock) {
383
386
  return;
384
387
  }
@@ -391,7 +394,7 @@ const BlocksContent = ({ placeholder, ariaLabelId })=>{
391
394
  if (selectedBlock.handleEnterKey) {
392
395
  selectedBlock.handleEnterKey(editor);
393
396
  } else {
394
- blocks.paragraph.handleEnterKey(editor);
397
+ blocks.paragraph?.handleEnterKey(editor);
395
398
  }
396
399
  };
397
400
  const handleBackspaceEvent = (event)=>{
@@ -399,7 +402,7 @@ const BlocksContent = ({ placeholder, ariaLabelId })=>{
399
402
  return;
400
403
  }
401
404
  const selectedNode = editor.children[editor.selection.anchor.path[0]];
402
- const selectedBlock = Object.values(blocks).find((block)=>block.matchNode(selectedNode));
405
+ const selectedBlock = Object.values(blocks).find((block)=>block?.matchNode(selectedNode));
403
406
  if (!selectedBlock) {
404
407
  return;
405
408
  }
@@ -412,7 +415,7 @@ const BlocksContent = ({ placeholder, ariaLabelId })=>{
412
415
  return;
413
416
  }
414
417
  const selectedNode = editor.children[editor.selection.anchor.path[0]];
415
- const selectedBlock = Object.values(blocks).find((block)=>block.matchNode(selectedNode));
418
+ const selectedBlock = Object.values(blocks).find((block)=>block?.matchNode(selectedNode));
416
419
  if (!selectedBlock) {
417
420
  return;
418
421
  }