@strapi/content-manager 0.0.0-experimental.7d94d6f1299d54c2aa90675f15b27b5c463aacc7 → 0.0.0-experimental.7ec9307c395022dd904738ffdb0c9d7c4e5b24d9

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 (147) hide show
  1. package/dist/admin/components/LeftMenu.js +30 -34
  2. package/dist/admin/components/LeftMenu.js.map +1 -1
  3. package/dist/admin/components/LeftMenu.mjs +32 -36
  4. package/dist/admin/components/LeftMenu.mjs.map +1 -1
  5. package/dist/admin/components/Widgets.js +161 -0
  6. package/dist/admin/components/Widgets.js.map +1 -0
  7. package/dist/admin/components/Widgets.mjs +158 -0
  8. package/dist/admin/components/Widgets.mjs.map +1 -0
  9. package/dist/admin/hooks/useDocumentActions.js +5 -1
  10. package/dist/admin/hooks/useDocumentActions.js.map +1 -1
  11. package/dist/admin/hooks/useDocumentActions.mjs +5 -1
  12. package/dist/admin/hooks/useDocumentActions.mjs.map +1 -1
  13. package/dist/admin/hooks/useDocumentContext.js.map +1 -1
  14. package/dist/admin/hooks/useDocumentContext.mjs.map +1 -1
  15. package/dist/admin/index.js +42 -5
  16. package/dist/admin/index.js.map +1 -1
  17. package/dist/admin/index.mjs +42 -3
  18. package/dist/admin/index.mjs.map +1 -1
  19. package/dist/admin/pages/EditView/components/DocumentActions.js +206 -21
  20. package/dist/admin/pages/EditView/components/DocumentActions.js.map +1 -1
  21. package/dist/admin/pages/EditView/components/DocumentActions.mjs +208 -23
  22. package/dist/admin/pages/EditView/components/DocumentActions.mjs.map +1 -1
  23. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js +7 -12
  24. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.js.map +1 -1
  25. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs +8 -13
  26. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/BlocksEditor.mjs.map +1 -1
  27. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.js +46 -95
  28. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.js.map +1 -1
  29. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.mjs +48 -78
  30. package/dist/admin/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.mjs.map +1 -1
  31. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js +2 -0
  32. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.js.map +1 -1
  33. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs +2 -0
  34. package/dist/admin/pages/EditView/components/FormInputs/Component/Repeatable.mjs.map +1 -1
  35. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js +128 -55
  36. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.js.map +1 -1
  37. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs +128 -55
  38. package/dist/admin/pages/EditView/components/FormInputs/Relations/RelationModal.mjs.map +1 -1
  39. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js +89 -50
  40. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.js.map +1 -1
  41. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs +91 -52
  42. package/dist/admin/pages/EditView/components/FormInputs/Relations/Relations.mjs.map +1 -1
  43. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.js +50 -97
  44. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.js.map +1 -1
  45. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.mjs +51 -79
  46. package/dist/admin/pages/EditView/components/FormInputs/Wysiwyg/EditorLayout.mjs.map +1 -1
  47. package/dist/admin/pages/EditView/components/FormLayout.js +3 -3
  48. package/dist/admin/pages/EditView/components/FormLayout.js.map +1 -1
  49. package/dist/admin/pages/EditView/components/FormLayout.mjs +3 -3
  50. package/dist/admin/pages/EditView/components/FormLayout.mjs.map +1 -1
  51. package/dist/admin/pages/ListView/ListViewPage.js +0 -77
  52. package/dist/admin/pages/ListView/ListViewPage.js.map +1 -1
  53. package/dist/admin/pages/ListView/ListViewPage.mjs +1 -78
  54. package/dist/admin/pages/ListView/ListViewPage.mjs.map +1 -1
  55. package/dist/admin/preview/components/PreviewHeader.js +1 -1
  56. package/dist/admin/preview/components/PreviewHeader.js.map +1 -1
  57. package/dist/admin/preview/components/PreviewHeader.mjs +1 -1
  58. package/dist/admin/preview/components/PreviewHeader.mjs.map +1 -1
  59. package/dist/admin/services/homepage.js +30 -0
  60. package/dist/admin/services/homepage.js.map +1 -0
  61. package/dist/admin/services/homepage.mjs +28 -0
  62. package/dist/admin/services/homepage.mjs.map +1 -0
  63. package/dist/admin/src/components/Widgets.d.ts +3 -0
  64. package/dist/admin/src/hooks/useDocumentContext.d.ts +1 -1
  65. package/dist/admin/src/pages/EditView/components/FormInputs/BlocksInput/EditorLayout.d.ts +2 -2
  66. package/dist/admin/src/pages/EditView/components/FormInputs/Relations/RelationModal.d.ts +26 -5
  67. package/dist/admin/src/pages/EditView/components/FormLayout.d.ts +0 -1
  68. package/dist/admin/src/services/homepage.d.ts +5 -0
  69. package/dist/admin/translations/en.json.js +2 -1
  70. package/dist/admin/translations/en.json.js.map +1 -1
  71. package/dist/admin/translations/en.json.mjs +2 -1
  72. package/dist/admin/translations/en.json.mjs.map +1 -1
  73. package/dist/admin/translations/ru.json.js +235 -226
  74. package/dist/admin/translations/ru.json.js.map +1 -1
  75. package/dist/admin/translations/ru.json.mjs +230 -226
  76. package/dist/admin/translations/ru.json.mjs.map +1 -1
  77. package/dist/server/controllers/index.js +3 -1
  78. package/dist/server/controllers/index.js.map +1 -1
  79. package/dist/server/controllers/index.mjs +3 -1
  80. package/dist/server/controllers/index.mjs.map +1 -1
  81. package/dist/server/homepage/controllers/homepage.js +57 -0
  82. package/dist/server/homepage/controllers/homepage.js.map +1 -0
  83. package/dist/server/homepage/controllers/homepage.mjs +36 -0
  84. package/dist/server/homepage/controllers/homepage.mjs.map +1 -0
  85. package/dist/server/homepage/controllers/index.js +10 -0
  86. package/dist/server/homepage/controllers/index.js.map +1 -0
  87. package/dist/server/homepage/controllers/index.mjs +8 -0
  88. package/dist/server/homepage/controllers/index.mjs.map +1 -0
  89. package/dist/server/homepage/index.js +14 -0
  90. package/dist/server/homepage/index.js.map +1 -0
  91. package/dist/server/homepage/index.mjs +12 -0
  92. package/dist/server/homepage/index.mjs.map +1 -0
  93. package/dist/server/homepage/routes/homepage.js +25 -0
  94. package/dist/server/homepage/routes/homepage.js.map +1 -0
  95. package/dist/server/homepage/routes/homepage.mjs +23 -0
  96. package/dist/server/homepage/routes/homepage.mjs.map +1 -0
  97. package/dist/server/homepage/routes/index.js +13 -0
  98. package/dist/server/homepage/routes/index.js.map +1 -0
  99. package/dist/server/homepage/routes/index.mjs +11 -0
  100. package/dist/server/homepage/routes/index.mjs.map +1 -0
  101. package/dist/server/homepage/services/homepage.js +157 -0
  102. package/dist/server/homepage/services/homepage.js.map +1 -0
  103. package/dist/server/homepage/services/homepage.mjs +155 -0
  104. package/dist/server/homepage/services/homepage.mjs.map +1 -0
  105. package/dist/server/homepage/services/index.js +10 -0
  106. package/dist/server/homepage/services/index.js.map +1 -0
  107. package/dist/server/homepage/services/index.mjs +8 -0
  108. package/dist/server/homepage/services/index.mjs.map +1 -0
  109. package/dist/server/preview/services/preview.js +0 -1
  110. package/dist/server/preview/services/preview.js.map +1 -1
  111. package/dist/server/preview/services/preview.mjs +0 -1
  112. package/dist/server/preview/services/preview.mjs.map +1 -1
  113. package/dist/server/routes/index.js +3 -1
  114. package/dist/server/routes/index.js.map +1 -1
  115. package/dist/server/routes/index.mjs +3 -1
  116. package/dist/server/routes/index.mjs.map +1 -1
  117. package/dist/server/services/index.js +3 -1
  118. package/dist/server/services/index.js.map +1 -1
  119. package/dist/server/services/index.mjs +3 -1
  120. package/dist/server/services/index.mjs.map +1 -1
  121. package/dist/server/src/controllers/index.d.ts.map +1 -1
  122. package/dist/server/src/homepage/controllers/homepage.d.ts +7 -0
  123. package/dist/server/src/homepage/controllers/homepage.d.ts.map +1 -0
  124. package/dist/server/src/homepage/controllers/index.d.ts +2 -0
  125. package/dist/server/src/homepage/controllers/index.d.ts.map +1 -0
  126. package/dist/server/src/homepage/index.d.ts +16 -0
  127. package/dist/server/src/homepage/index.d.ts.map +1 -0
  128. package/dist/server/src/homepage/routes/homepage.d.ts +4 -0
  129. package/dist/server/src/homepage/routes/homepage.d.ts.map +1 -0
  130. package/dist/server/src/homepage/routes/index.d.ts +8 -0
  131. package/dist/server/src/homepage/routes/index.d.ts.map +1 -0
  132. package/dist/server/src/homepage/services/homepage.d.ts +11 -0
  133. package/dist/server/src/homepage/services/homepage.d.ts.map +1 -0
  134. package/dist/server/src/homepage/services/index.d.ts +9 -0
  135. package/dist/server/src/homepage/services/index.d.ts.map +1 -0
  136. package/dist/server/src/index.d.ts +7 -1
  137. package/dist/server/src/index.d.ts.map +1 -1
  138. package/dist/server/src/preview/services/preview.d.ts.map +1 -1
  139. package/dist/server/src/routes/index.d.ts +1 -0
  140. package/dist/server/src/routes/index.d.ts.map +1 -1
  141. package/dist/server/src/services/data-mapper.d.ts +0 -1
  142. package/dist/server/src/services/data-mapper.d.ts.map +1 -1
  143. package/dist/server/src/services/index.d.ts +6 -1
  144. package/dist/server/src/services/index.d.ts.map +1 -1
  145. package/dist/shared/contracts/homepage.d.ts +25 -0
  146. package/dist/shared/contracts/homepage.d.ts.map +1 -0
  147. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"useDocumentContext.js","sources":["../../../admin/src/hooks/useDocumentContext.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\n\nimport { useDoc, useDocument, type UseDocument } from '../hooks/useDocument';\nimport { useRelationModal } from '../pages/EditView/components/FormInputs/Relations/RelationModal';\nimport { buildValidParams } from '../utils/api';\n\ninterface DocumentMeta {\n /**\n * The equivalent of the \":id\" url param value\n * i.e. gus5a67jcboa3o2zjnz39mb1\n */\n documentId: string;\n /**\n * The equivalent of the url \":slug\" param value\n * i.e. api::articles.article\n */\n model: string;\n /**\n * The equivalent of the url \":collectionType\" param value\n * i.e. collection-types or single-types\n */\n collectionType: string;\n /**\n * Query params object\n * i.e. { locale: 'fr' }\n */\n params?: Record<string, string | string[] | null>;\n}\n\ninterface DocumentContextValue {\n currentDocumentMeta: DocumentMeta;\n currentDocument: ReturnType<UseDocument>;\n}\n\nfunction useDocumentContext(consumerName: string): DocumentContextValue {\n // Try to get state from the relation modal context first\n const currentRelationDocumentMeta = useRelationModal(\n consumerName,\n (state) => state.currentDocumentMeta,\n false\n );\n const currentRelationDocument = useRelationModal(\n consumerName,\n (state) => state.currentDocument,\n false\n );\n\n // Then try to get the same state from the URL\n const { collectionType, model, id: documentId } = useDoc();\n const [{ query }] = useQueryParams();\n\n // TODO: look into why we never seem to pass any params\n const params = React.useMemo(() => buildValidParams(query ?? {}), [query]);\n const urlDocumentMeta: DocumentMeta = { collectionType, model, documentId: documentId!, params };\n const urlDocument = useDocument(urlDocumentMeta);\n\n /**\n * If there's modal state, use it in priority as it's the most specific\n * Fallback to the state derived from the URL, which is the default behavior,\n * used for the edit view, history and preview.\n */\n return {\n currentDocumentMeta: currentRelationDocumentMeta ?? urlDocumentMeta,\n currentDocument: currentRelationDocument ?? urlDocument,\n };\n}\n\nexport { useDocumentContext };\nexport type { DocumentMeta };\n"],"names":["useDocumentContext","consumerName","currentRelationDocumentMeta","useRelationModal","state","currentDocumentMeta","currentRelationDocument","currentDocument","collectionType","model","id","documentId","useDoc","query","useQueryParams","params","React","useMemo","buildValidParams","urlDocumentMeta","urlDocument","useDocument"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAASA,mBAAmBC,YAAoB,EAAA;;AAE9C,IAAA,MAAMC,8BAA8BC,8BAClCF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMC,mBAAmB,EACpC,KAAA,CAAA;AAEF,IAAA,MAAMC,0BAA0BH,8BAC9BF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMG,eAAe,EAChC,KAAA,CAAA;;IAIF,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAEC,EAAIC,EAAAA,UAAU,EAAE,GAAGC,kBAAAA,EAAAA;AAClD,IAAA,MAAM,CAAC,EAAEC,KAAK,EAAE,CAAC,GAAGC,0BAAAA,EAAAA;;IAGpB,MAAMC,MAAAA,GAASC,iBAAMC,OAAO,CAAC,IAAMC,oBAAiBL,CAAAA,KAAAA,IAAS,EAAK,CAAA,EAAA;AAACA,QAAAA;AAAM,KAAA,CAAA;AACzE,IAAA,MAAMM,eAAgC,GAAA;AAAEX,QAAAA,cAAAA;AAAgBC,QAAAA,KAAAA;QAAOE,UAAYA,EAAAA,UAAAA;AAAaI,QAAAA;AAAO,KAAA;AAC/F,IAAA,MAAMK,cAAcC,uBAAYF,CAAAA,eAAAA,CAAAA;AAEhC;;;;AAIC,MACD,OAAO;AACLd,QAAAA,mBAAAA,EAAqBH,2BAA+BiB,IAAAA,eAAAA;AACpDZ,QAAAA,eAAAA,EAAiBD,uBAA2Bc,IAAAA;AAC9C,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"useDocumentContext.js","sources":["../../../admin/src/hooks/useDocumentContext.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\n\nimport { useDoc, useDocument, type UseDocument } from '../hooks/useDocument';\nimport { useRelationModal } from '../pages/EditView/components/FormInputs/Relations/RelationModal';\nimport { buildValidParams } from '../utils/api';\n\ninterface DocumentMeta {\n /**\n * The equivalent of the \":id\" url param value\n * i.e. gus5a67jcboa3o2zjnz39mb1\n */\n documentId?: string;\n /**\n * The equivalent of the url \":slug\" param value\n * i.e. api::articles.article\n */\n model: string;\n /**\n * The equivalent of the url \":collectionType\" param value\n * i.e. collection-types or single-types\n */\n collectionType: string;\n /**\n * Query params object\n * i.e. { locale: 'fr' }\n */\n params?: Record<string, string | string[] | null>;\n}\n\ninterface DocumentContextValue {\n currentDocumentMeta: DocumentMeta;\n currentDocument: ReturnType<UseDocument>;\n}\n\nfunction useDocumentContext(consumerName: string): DocumentContextValue {\n // Try to get state from the relation modal context first\n const currentRelationDocumentMeta = useRelationModal(\n consumerName,\n (state) => state.currentDocumentMeta,\n false\n );\n const currentRelationDocument = useRelationModal(\n consumerName,\n (state) => state.currentDocument,\n false\n );\n\n // Then try to get the same state from the URL\n const { collectionType, model, id: documentId } = useDoc();\n const [{ query }] = useQueryParams();\n\n // TODO: look into why we never seem to pass any params\n const params = React.useMemo(() => buildValidParams(query ?? {}), [query]);\n const urlDocumentMeta: DocumentMeta = { collectionType, model, documentId: documentId!, params };\n const urlDocument = useDocument(urlDocumentMeta);\n\n /**\n * If there's modal state, use it in priority as it's the most specific\n * Fallback to the state derived from the URL, which is the default behavior,\n * used for the edit view, history and preview.\n */\n return {\n currentDocumentMeta: currentRelationDocumentMeta ?? urlDocumentMeta,\n currentDocument: currentRelationDocument ?? urlDocument,\n };\n}\n\nexport { useDocumentContext };\nexport type { DocumentMeta };\n"],"names":["useDocumentContext","consumerName","currentRelationDocumentMeta","useRelationModal","state","currentDocumentMeta","currentRelationDocument","currentDocument","collectionType","model","id","documentId","useDoc","query","useQueryParams","params","React","useMemo","buildValidParams","urlDocumentMeta","urlDocument","useDocument"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCA,SAASA,mBAAmBC,YAAoB,EAAA;;AAE9C,IAAA,MAAMC,8BAA8BC,8BAClCF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMC,mBAAmB,EACpC,KAAA,CAAA;AAEF,IAAA,MAAMC,0BAA0BH,8BAC9BF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMG,eAAe,EAChC,KAAA,CAAA;;IAIF,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAEC,EAAIC,EAAAA,UAAU,EAAE,GAAGC,kBAAAA,EAAAA;AAClD,IAAA,MAAM,CAAC,EAAEC,KAAK,EAAE,CAAC,GAAGC,0BAAAA,EAAAA;;IAGpB,MAAMC,MAAAA,GAASC,iBAAMC,OAAO,CAAC,IAAMC,oBAAiBL,CAAAA,KAAAA,IAAS,EAAK,CAAA,EAAA;AAACA,QAAAA;AAAM,KAAA,CAAA;AACzE,IAAA,MAAMM,eAAgC,GAAA;AAAEX,QAAAA,cAAAA;AAAgBC,QAAAA,KAAAA;QAAOE,UAAYA,EAAAA,UAAAA;AAAaI,QAAAA;AAAO,KAAA;AAC/F,IAAA,MAAMK,cAAcC,uBAAYF,CAAAA,eAAAA,CAAAA;AAEhC;;;;AAIC,MACD,OAAO;AACLd,QAAAA,mBAAAA,EAAqBH,2BAA+BiB,IAAAA,eAAAA;AACpDZ,QAAAA,eAAAA,EAAiBD,uBAA2Bc,IAAAA;AAC9C,KAAA;AACF;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useDocumentContext.mjs","sources":["../../../admin/src/hooks/useDocumentContext.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\n\nimport { useDoc, useDocument, type UseDocument } from '../hooks/useDocument';\nimport { useRelationModal } from '../pages/EditView/components/FormInputs/Relations/RelationModal';\nimport { buildValidParams } from '../utils/api';\n\ninterface DocumentMeta {\n /**\n * The equivalent of the \":id\" url param value\n * i.e. gus5a67jcboa3o2zjnz39mb1\n */\n documentId: string;\n /**\n * The equivalent of the url \":slug\" param value\n * i.e. api::articles.article\n */\n model: string;\n /**\n * The equivalent of the url \":collectionType\" param value\n * i.e. collection-types or single-types\n */\n collectionType: string;\n /**\n * Query params object\n * i.e. { locale: 'fr' }\n */\n params?: Record<string, string | string[] | null>;\n}\n\ninterface DocumentContextValue {\n currentDocumentMeta: DocumentMeta;\n currentDocument: ReturnType<UseDocument>;\n}\n\nfunction useDocumentContext(consumerName: string): DocumentContextValue {\n // Try to get state from the relation modal context first\n const currentRelationDocumentMeta = useRelationModal(\n consumerName,\n (state) => state.currentDocumentMeta,\n false\n );\n const currentRelationDocument = useRelationModal(\n consumerName,\n (state) => state.currentDocument,\n false\n );\n\n // Then try to get the same state from the URL\n const { collectionType, model, id: documentId } = useDoc();\n const [{ query }] = useQueryParams();\n\n // TODO: look into why we never seem to pass any params\n const params = React.useMemo(() => buildValidParams(query ?? {}), [query]);\n const urlDocumentMeta: DocumentMeta = { collectionType, model, documentId: documentId!, params };\n const urlDocument = useDocument(urlDocumentMeta);\n\n /**\n * If there's modal state, use it in priority as it's the most specific\n * Fallback to the state derived from the URL, which is the default behavior,\n * used for the edit view, history and preview.\n */\n return {\n currentDocumentMeta: currentRelationDocumentMeta ?? urlDocumentMeta,\n currentDocument: currentRelationDocument ?? urlDocument,\n };\n}\n\nexport { useDocumentContext };\nexport type { DocumentMeta };\n"],"names":["useDocumentContext","consumerName","currentRelationDocumentMeta","useRelationModal","state","currentDocumentMeta","currentRelationDocument","currentDocument","collectionType","model","id","documentId","useDoc","query","useQueryParams","params","React","useMemo","buildValidParams","urlDocumentMeta","urlDocument","useDocument"],"mappings":";;;;;;AAoCA,SAASA,mBAAmBC,YAAoB,EAAA;;AAE9C,IAAA,MAAMC,8BAA8BC,gBAClCF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMC,mBAAmB,EACpC,KAAA,CAAA;AAEF,IAAA,MAAMC,0BAA0BH,gBAC9BF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMG,eAAe,EAChC,KAAA,CAAA;;IAIF,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAEC,EAAIC,EAAAA,UAAU,EAAE,GAAGC,MAAAA,EAAAA;AAClD,IAAA,MAAM,CAAC,EAAEC,KAAK,EAAE,CAAC,GAAGC,cAAAA,EAAAA;;IAGpB,MAAMC,MAAAA,GAASC,MAAMC,OAAO,CAAC,IAAMC,gBAAiBL,CAAAA,KAAAA,IAAS,EAAK,CAAA,EAAA;AAACA,QAAAA;AAAM,KAAA,CAAA;AACzE,IAAA,MAAMM,eAAgC,GAAA;AAAEX,QAAAA,cAAAA;AAAgBC,QAAAA,KAAAA;QAAOE,UAAYA,EAAAA,UAAAA;AAAaI,QAAAA;AAAO,KAAA;AAC/F,IAAA,MAAMK,cAAcC,WAAYF,CAAAA,eAAAA,CAAAA;AAEhC;;;;AAIC,MACD,OAAO;AACLd,QAAAA,mBAAAA,EAAqBH,2BAA+BiB,IAAAA,eAAAA;AACpDZ,QAAAA,eAAAA,EAAiBD,uBAA2Bc,IAAAA;AAC9C,KAAA;AACF;;;;"}
1
+ {"version":3,"file":"useDocumentContext.mjs","sources":["../../../admin/src/hooks/useDocumentContext.ts"],"sourcesContent":["import * as React from 'react';\n\nimport { useQueryParams } from '@strapi/admin/strapi-admin';\n\nimport { useDoc, useDocument, type UseDocument } from '../hooks/useDocument';\nimport { useRelationModal } from '../pages/EditView/components/FormInputs/Relations/RelationModal';\nimport { buildValidParams } from '../utils/api';\n\ninterface DocumentMeta {\n /**\n * The equivalent of the \":id\" url param value\n * i.e. gus5a67jcboa3o2zjnz39mb1\n */\n documentId?: string;\n /**\n * The equivalent of the url \":slug\" param value\n * i.e. api::articles.article\n */\n model: string;\n /**\n * The equivalent of the url \":collectionType\" param value\n * i.e. collection-types or single-types\n */\n collectionType: string;\n /**\n * Query params object\n * i.e. { locale: 'fr' }\n */\n params?: Record<string, string | string[] | null>;\n}\n\ninterface DocumentContextValue {\n currentDocumentMeta: DocumentMeta;\n currentDocument: ReturnType<UseDocument>;\n}\n\nfunction useDocumentContext(consumerName: string): DocumentContextValue {\n // Try to get state from the relation modal context first\n const currentRelationDocumentMeta = useRelationModal(\n consumerName,\n (state) => state.currentDocumentMeta,\n false\n );\n const currentRelationDocument = useRelationModal(\n consumerName,\n (state) => state.currentDocument,\n false\n );\n\n // Then try to get the same state from the URL\n const { collectionType, model, id: documentId } = useDoc();\n const [{ query }] = useQueryParams();\n\n // TODO: look into why we never seem to pass any params\n const params = React.useMemo(() => buildValidParams(query ?? {}), [query]);\n const urlDocumentMeta: DocumentMeta = { collectionType, model, documentId: documentId!, params };\n const urlDocument = useDocument(urlDocumentMeta);\n\n /**\n * If there's modal state, use it in priority as it's the most specific\n * Fallback to the state derived from the URL, which is the default behavior,\n * used for the edit view, history and preview.\n */\n return {\n currentDocumentMeta: currentRelationDocumentMeta ?? urlDocumentMeta,\n currentDocument: currentRelationDocument ?? urlDocument,\n };\n}\n\nexport { useDocumentContext };\nexport type { DocumentMeta };\n"],"names":["useDocumentContext","consumerName","currentRelationDocumentMeta","useRelationModal","state","currentDocumentMeta","currentRelationDocument","currentDocument","collectionType","model","id","documentId","useDoc","query","useQueryParams","params","React","useMemo","buildValidParams","urlDocumentMeta","urlDocument","useDocument"],"mappings":";;;;;;AAoCA,SAASA,mBAAmBC,YAAoB,EAAA;;AAE9C,IAAA,MAAMC,8BAA8BC,gBAClCF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMC,mBAAmB,EACpC,KAAA,CAAA;AAEF,IAAA,MAAMC,0BAA0BH,gBAC9BF,CAAAA,YAAAA,EACA,CAACG,KAAUA,GAAAA,KAAAA,CAAMG,eAAe,EAChC,KAAA,CAAA;;IAIF,MAAM,EAAEC,cAAc,EAAEC,KAAK,EAAEC,EAAIC,EAAAA,UAAU,EAAE,GAAGC,MAAAA,EAAAA;AAClD,IAAA,MAAM,CAAC,EAAEC,KAAK,EAAE,CAAC,GAAGC,cAAAA,EAAAA;;IAGpB,MAAMC,MAAAA,GAASC,MAAMC,OAAO,CAAC,IAAMC,gBAAiBL,CAAAA,KAAAA,IAAS,EAAK,CAAA,EAAA;AAACA,QAAAA;AAAM,KAAA,CAAA;AACzE,IAAA,MAAMM,eAAgC,GAAA;AAAEX,QAAAA,cAAAA;AAAgBC,QAAAA,KAAAA;QAAOE,UAAYA,EAAAA,UAAAA;AAAaI,QAAAA;AAAO,KAAA;AAC/F,IAAA,MAAMK,cAAcC,WAAYF,CAAAA,eAAAA,CAAAA;AAEhC;;;;AAIC,MACD,OAAO;AACLd,QAAAA,mBAAAA,EAAqBH,2BAA+BiB,IAAAA,eAAAA;AACpDZ,QAAAA,eAAAA,EAAiBD,uBAA2Bc,IAAAA;AAC9C,KAAA;AACF;;;;"}
@@ -18,9 +18,7 @@ var useDocumentActions = require('./hooks/useDocumentActions.js');
18
18
  var useDocumentLayout = require('./hooks/useDocumentLayout.js');
19
19
  var DocumentRBAC = require('./features/DocumentRBAC.js');
20
20
 
21
- function _interopNamespaceDefaultOnly (e) { return Object.freeze({ __proto__: null, default: e }); }
22
-
23
- function __variableDynamicImportRuntime1__(path) {
21
+ function __variableDynamicImportRuntime3__(path) {
24
22
  switch (path) {
25
23
  case './translations/ar.json': return Promise.resolve().then(function () { return require('./translations/ar.json.js'); });
26
24
  case './translations/ca.json': return Promise.resolve().then(function () { return require('./translations/ca.json.js'); });
@@ -43,7 +41,7 @@ function __variableDynamicImportRuntime1__(path) {
43
41
  case './translations/pl.json': return Promise.resolve().then(function () { return require('./translations/pl.json.js'); });
44
42
  case './translations/pt-BR.json': return Promise.resolve().then(function () { return require('./translations/pt-BR.json.js'); });
45
43
  case './translations/pt.json': return Promise.resolve().then(function () { return require('./translations/pt.json.js'); });
46
- case './translations/ru.json': return Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespaceDefaultOnly(require('./translations/ru.json.js')); });
44
+ case './translations/ru.json': return Promise.resolve().then(function () { return require('./translations/ru.json.js'); });
47
45
  case './translations/sa.json': return Promise.resolve().then(function () { return require('./translations/sa.json.js'); });
48
46
  case './translations/sk.json': return Promise.resolve().then(function () { return require('./translations/sk.json.js'); });
49
47
  case './translations/sv.json': return Promise.resolve().then(function () { return require('./translations/sv.json.js'); });
@@ -88,6 +86,45 @@ var index = {
88
86
  children: router.routes
89
87
  });
90
88
  app.registerPlugin(cm.config);
89
+ // Register homepage widgets
90
+ app.widgets.register([
91
+ {
92
+ icon: Icons.Pencil,
93
+ title: {
94
+ id: `${plugin.PLUGIN_ID}.widget.last-edited.title`,
95
+ defaultMessage: 'Last edited entries'
96
+ },
97
+ component: async ()=>{
98
+ const { LastEditedWidget } = await Promise.resolve().then(function () { return require('./components/Widgets.js'); });
99
+ return LastEditedWidget;
100
+ },
101
+ pluginId: plugin.PLUGIN_ID,
102
+ id: 'last-edited-entries',
103
+ permissions: [
104
+ {
105
+ action: 'plugin::content-manager.explorer.read'
106
+ }
107
+ ]
108
+ },
109
+ {
110
+ icon: Icons.CheckCircle,
111
+ title: {
112
+ id: `${plugin.PLUGIN_ID}.widget.last-published.title`,
113
+ defaultMessage: 'Last published entries'
114
+ },
115
+ component: async ()=>{
116
+ const { LastPublishedWidget } = await Promise.resolve().then(function () { return require('./components/Widgets.js'); });
117
+ return LastPublishedWidget;
118
+ },
119
+ pluginId: plugin.PLUGIN_ID,
120
+ id: 'last-published-entries',
121
+ permissions: [
122
+ {
123
+ action: 'plugin::content-manager.explorer.read'
124
+ }
125
+ ]
126
+ }
127
+ ]);
91
128
  },
92
129
  bootstrap (app) {
93
130
  if (typeof index$1.historyAdmin.bootstrap === 'function') {
@@ -99,7 +136,7 @@ var index = {
99
136
  },
100
137
  async registerTrads ({ locales }) {
101
138
  const importedTrads = await Promise.all(locales.map((locale)=>{
102
- return __variableDynamicImportRuntime1__(`./translations/${locale}.json`).then(({ default: data })=>{
139
+ return __variableDynamicImportRuntime3__(`./translations/${locale}.json`).then(({ default: data })=>{
103
140
  return {
104
141
  data: translations.prefixPluginTranslations(data, plugin.PLUGIN_ID),
105
142
  locale
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../admin/src/index.ts"],"sourcesContent":["import { Feather } from '@strapi/icons';\n\nimport { PLUGIN_ID } from './constants/plugin';\nimport { ContentManagerPlugin } from './content-manager';\nimport { historyAdmin } from './history';\nimport { reducer } from './modules/reducers';\nimport { previewAdmin } from './preview';\nimport { routes } from './router';\nimport { prefixPluginTranslations } from './utils/translations';\n\n// NOTE: we have to preload it to ensure chunks will have it available as global\nimport 'prismjs';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: any) {\n const cm = new ContentManagerPlugin();\n\n app.addReducers({\n [PLUGIN_ID]: reducer,\n });\n\n app.addMenuLink({\n to: PLUGIN_ID,\n icon: Feather,\n intlLabel: {\n id: `content-manager.plugin.name`,\n defaultMessage: 'Content Manager',\n },\n permissions: [],\n position: 1,\n });\n\n app.router.addRoute({\n path: 'content-manager/*',\n lazy: async () => {\n const { Layout } = await import('./layout');\n\n return {\n Component: Layout,\n };\n },\n children: routes,\n });\n\n app.registerPlugin(cm.config);\n },\n bootstrap(app: any) {\n if (typeof historyAdmin.bootstrap === 'function') {\n historyAdmin.bootstrap(app);\n }\n if (typeof previewAdmin.bootstrap === 'function') {\n previewAdmin.bootstrap(app);\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\nexport * from './exports';\n"],"names":["register","app","cm","ContentManagerPlugin","addReducers","PLUGIN_ID","reducer","addMenuLink","to","icon","Feather","intlLabel","id","defaultMessage","permissions","position","router","addRoute","path","lazy","Layout","Component","children","routes","registerPlugin","config","bootstrap","historyAdmin","previewAdmin","registerTrads","locales","importedTrads","Promise","all","map","locale","then","default","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAQ,EAAA;AACf,QAAA,M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AAC,CAAC,eAAe,EAAEA,MAAO,CAAA,KAAK,CAAC,CAAA,CAC1CC,IAAI,CAAC,CAAC,EAAEC,OAAAA,EAASC,IAAI,EAAE,GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,sCAAyBD,IAAMjC,EAAAA,gBAAAA,CAAAA;AACrC8B,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA,CACCK,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPH,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;AACJ,SAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQS,OAAO,CAACV,aAAAA,CAAAA;AACzB;AACF,CAAE;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../admin/src/index.ts"],"sourcesContent":["import { CheckCircle, Feather, Pencil } from '@strapi/icons';\n\nimport { PLUGIN_ID } from './constants/plugin';\nimport { ContentManagerPlugin } from './content-manager';\nimport { historyAdmin } from './history';\nimport { reducer } from './modules/reducers';\nimport { previewAdmin } from './preview';\nimport { routes } from './router';\nimport { prefixPluginTranslations } from './utils/translations';\n\n// NOTE: we have to preload it to ensure chunks will have it available as global\nimport 'prismjs';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: any) {\n const cm = new ContentManagerPlugin();\n\n app.addReducers({\n [PLUGIN_ID]: reducer,\n });\n\n app.addMenuLink({\n to: PLUGIN_ID,\n icon: Feather,\n intlLabel: {\n id: `content-manager.plugin.name`,\n defaultMessage: 'Content Manager',\n },\n permissions: [],\n position: 1,\n });\n\n app.router.addRoute({\n path: 'content-manager/*',\n lazy: async () => {\n const { Layout } = await import('./layout');\n\n return {\n Component: Layout,\n };\n },\n children: routes,\n });\n\n app.registerPlugin(cm.config);\n\n // Register homepage widgets\n app.widgets.register([\n {\n icon: Pencil,\n title: {\n id: `${PLUGIN_ID}.widget.last-edited.title`,\n defaultMessage: 'Last edited entries',\n },\n component: async () => {\n const { LastEditedWidget } = await import('./components/Widgets');\n return LastEditedWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'last-edited-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n },\n {\n icon: CheckCircle,\n title: {\n id: `${PLUGIN_ID}.widget.last-published.title`,\n defaultMessage: 'Last published entries',\n },\n component: async () => {\n const { LastPublishedWidget } = await import('./components/Widgets');\n return LastPublishedWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'last-published-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n },\n ]);\n },\n bootstrap(app: any) {\n if (typeof historyAdmin.bootstrap === 'function') {\n historyAdmin.bootstrap(app);\n }\n if (typeof previewAdmin.bootstrap === 'function') {\n previewAdmin.bootstrap(app);\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\nexport * from './exports';\n"],"names":["register","app","cm","ContentManagerPlugin","addReducers","PLUGIN_ID","reducer","addMenuLink","to","icon","Feather","intlLabel","id","defaultMessage","permissions","position","router","addRoute","path","lazy","Layout","Component","children","routes","registerPlugin","config","widgets","Pencil","title","component","LastEditedWidget","pluginId","action","CheckCircle","LastPublishedWidget","bootstrap","historyAdmin","previewAdmin","registerTrads","locales","importedTrads","Promise","all","map","locale","then","default","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAQ,EAAA;AACf,QAAA,MAAMC,KAAK,IAAIC,mCAAAA,EAAAA;AAEfF,QAAAA,GAAAA,CAAIG,WAAW,CAAC;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ACJ,SAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQS,OAAO,CAACV,aAAAA,CAAAA;AACzB;AACF,CAAE;;;;;;;;;;;;"}
@@ -1,4 +1,4 @@
1
- import { Feather } from '@strapi/icons';
1
+ import { Feather, Pencil, CheckCircle } from '@strapi/icons';
2
2
  import { PLUGIN_ID } from './constants/plugin.mjs';
3
3
  import { ContentManagerPlugin } from './content-manager.mjs';
4
4
  import { historyAdmin } from './history/index.mjs';
@@ -14,7 +14,7 @@ export { useDocumentActions as unstable_useDocumentActions } from './hooks/useDo
14
14
  export { useDocumentLayout as unstable_useDocumentLayout } from './hooks/useDocumentLayout.mjs';
15
15
  export { DocumentRBAC, useDocumentRBAC } from './features/DocumentRBAC.mjs';
16
16
 
17
- function __variableDynamicImportRuntime1__(path) {
17
+ function __variableDynamicImportRuntime3__(path) {
18
18
  switch (path) {
19
19
  case './translations/ar.json': return import('./translations/ar.json.mjs');
20
20
  case './translations/ca.json': return import('./translations/ca.json.mjs');
@@ -82,6 +82,45 @@ var index = {
82
82
  children: routes
83
83
  });
84
84
  app.registerPlugin(cm.config);
85
+ // Register homepage widgets
86
+ app.widgets.register([
87
+ {
88
+ icon: Pencil,
89
+ title: {
90
+ id: `${PLUGIN_ID}.widget.last-edited.title`,
91
+ defaultMessage: 'Last edited entries'
92
+ },
93
+ component: async ()=>{
94
+ const { LastEditedWidget } = await import('./components/Widgets.mjs');
95
+ return LastEditedWidget;
96
+ },
97
+ pluginId: PLUGIN_ID,
98
+ id: 'last-edited-entries',
99
+ permissions: [
100
+ {
101
+ action: 'plugin::content-manager.explorer.read'
102
+ }
103
+ ]
104
+ },
105
+ {
106
+ icon: CheckCircle,
107
+ title: {
108
+ id: `${PLUGIN_ID}.widget.last-published.title`,
109
+ defaultMessage: 'Last published entries'
110
+ },
111
+ component: async ()=>{
112
+ const { LastPublishedWidget } = await import('./components/Widgets.mjs');
113
+ return LastPublishedWidget;
114
+ },
115
+ pluginId: PLUGIN_ID,
116
+ id: 'last-published-entries',
117
+ permissions: [
118
+ {
119
+ action: 'plugin::content-manager.explorer.read'
120
+ }
121
+ ]
122
+ }
123
+ ]);
85
124
  },
86
125
  bootstrap (app) {
87
126
  if (typeof historyAdmin.bootstrap === 'function') {
@@ -93,7 +132,7 @@ var index = {
93
132
  },
94
133
  async registerTrads ({ locales }) {
95
134
  const importedTrads = await Promise.all(locales.map((locale)=>{
96
- return __variableDynamicImportRuntime1__(`./translations/${locale}.json`).then(({ default: data })=>{
135
+ return __variableDynamicImportRuntime3__(`./translations/${locale}.json`).then(({ default: data })=>{
97
136
  return {
98
137
  data: prefixPluginTranslations(data, PLUGIN_ID),
99
138
  locale
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../../admin/src/index.ts"],"sourcesContent":["import { Feather } from '@strapi/icons';\n\nimport { PLUGIN_ID } from './constants/plugin';\nimport { ContentManagerPlugin } from './content-manager';\nimport { historyAdmin } from './history';\nimport { reducer } from './modules/reducers';\nimport { previewAdmin } from './preview';\nimport { routes } from './router';\nimport { prefixPluginTranslations } from './utils/translations';\n\n// NOTE: we have to preload it to ensure chunks will have it available as global\nimport 'prismjs';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: any) {\n const cm = new ContentManagerPlugin();\n\n app.addReducers({\n [PLUGIN_ID]: reducer,\n });\n\n app.addMenuLink({\n to: PLUGIN_ID,\n icon: Feather,\n intlLabel: {\n id: `content-manager.plugin.name`,\n defaultMessage: 'Content Manager',\n },\n permissions: [],\n position: 1,\n });\n\n app.router.addRoute({\n path: 'content-manager/*',\n lazy: async () => {\n const { Layout } = await import('./layout');\n\n return {\n Component: Layout,\n };\n },\n children: routes,\n });\n\n app.registerPlugin(cm.config);\n },\n bootstrap(app: any) {\n if (typeof historyAdmin.bootstrap === 'function') {\n historyAdmin.bootstrap(app);\n }\n if (typeof previewAdmin.bootstrap === 'function') {\n previewAdmin.bootstrap(app);\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\nexport * from './exports';\n"],"names":["register","app","cm","ContentManagerPlugin","addReducers","PLUGIN_ID","reducer","addMenuLink","to","icon","Feather","intlLabel","id","defaultMessage","permissions","position","router","addRoute","path","lazy","Layout","Component","children","routes","registerPlugin","config","bootstrap","historyAdmin","previewAdmin","registerTrads","locales","importedTrads","Promise","all","map","locale","then","default","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAQ,EAAA;AACf,QAAA,MAAMC,KAAK,IAAIC,oBAAAA,EAAAA;AAEfF,QAAAA,GAAAA,CAAIG,WAAW,CAAC;AACd,YAAA,CAACC,YAAYC;AACf,SAAA,CAAA;AAEAL,QAAAA,GAAAA,CAAIM,WAAW,CAAC;YACdC,EAAIH,EAAAA,SAAAA;YACJI,IAAMC,EAAAA,OAAAA;YACNC,SAAW,EAAA;gBACTC,EAAI,EAAA,CAAC,2BAA2B,CAAC;gBACjCC,cAAgB,EAAA;AAClB,aAAA;AACAC,YAAAA,WAAAA,EAAa,EAAE;YACfC,QAAU,EAAA;AACZ,SAAA,CAAA;QAEAd,GAAIe,CAAAA,MAAM,CAACC,QAAQ,CAAC;YAClBC,IAAM,EAAA,mBAAA;YACNC,IAAM,EAAA,UAAA;AACJ,gBAAA,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAM,OAAO,cAAA,CAAA;gBAEhC,OAAO;oBACLC,SAAWD,EAAAA;AACb,iBAAA;AACF,aAAA;YACAE,QAAUC,EAAAA;AACZ,SAAA,CAAA;QAEAtB,GAAIuB,CAAAA,cAAc,CAACtB,EAAAA,CAAGuB,MAAM,CAAA;AAC9B,KAAA;AACAC,IAAAA,SAAAA,CAAAA,CAAUzB,GAAQ,EAAA;AAChB,QAAA,IAAI,OAAO0B,YAAAA,CAAaD,SAAS,KAAK,UAAY,EAAA;AAChDC,YAAAA,YAAAA,CAAaD,SAAS,CAACzB,GAAAA,CAAAA;AACzB;AACA,QAAA,IAAI,OAAO2B,YAAAA,CAAaF,SAAS,KAAK,UAAY,EAAA;AAChDE,YAAAA,YAAAA,CAAaF,SAAS,CAACzB,GAAAA,CAAAA;AACzB;AACF,KAAA;IACA,MAAM4B,aAAAA,CAAAA,CAAc,EAAEC,OAAO,EAAyB,EAAA;QACpD,MAAMC,aAAAA,GAAgB,MAAMC,OAAQC,CAAAA,GAAG,CACrCH,OAAQI,CAAAA,GAAG,CAAC,CAACC,MAAAA,GAAAA;AACX,YAAA,OAAO,iCAAM,CAAC,CAAC,eAAe,EAAEA,MAAO,CAAA,KAAK,CAAC,CAAA,CAC1CC,IAAI,CAAC,CAAC,EAAEC,OAAAA,EAASC,IAAI,EAAE,GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,yBAAyBD,IAAMjC,EAAAA,SAAAA,CAAAA;AACrC8B,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA,CACCK,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPH,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;AACJ,SAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQS,OAAO,CAACV,aAAAA,CAAAA;AACzB;AACF,CAAE;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../../admin/src/index.ts"],"sourcesContent":["import { CheckCircle, Feather, Pencil } from '@strapi/icons';\n\nimport { PLUGIN_ID } from './constants/plugin';\nimport { ContentManagerPlugin } from './content-manager';\nimport { historyAdmin } from './history';\nimport { reducer } from './modules/reducers';\nimport { previewAdmin } from './preview';\nimport { routes } from './router';\nimport { prefixPluginTranslations } from './utils/translations';\n\n// NOTE: we have to preload it to ensure chunks will have it available as global\nimport 'prismjs';\n\n// eslint-disable-next-line import/no-default-export\nexport default {\n register(app: any) {\n const cm = new ContentManagerPlugin();\n\n app.addReducers({\n [PLUGIN_ID]: reducer,\n });\n\n app.addMenuLink({\n to: PLUGIN_ID,\n icon: Feather,\n intlLabel: {\n id: `content-manager.plugin.name`,\n defaultMessage: 'Content Manager',\n },\n permissions: [],\n position: 1,\n });\n\n app.router.addRoute({\n path: 'content-manager/*',\n lazy: async () => {\n const { Layout } = await import('./layout');\n\n return {\n Component: Layout,\n };\n },\n children: routes,\n });\n\n app.registerPlugin(cm.config);\n\n // Register homepage widgets\n app.widgets.register([\n {\n icon: Pencil,\n title: {\n id: `${PLUGIN_ID}.widget.last-edited.title`,\n defaultMessage: 'Last edited entries',\n },\n component: async () => {\n const { LastEditedWidget } = await import('./components/Widgets');\n return LastEditedWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'last-edited-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n },\n {\n icon: CheckCircle,\n title: {\n id: `${PLUGIN_ID}.widget.last-published.title`,\n defaultMessage: 'Last published entries',\n },\n component: async () => {\n const { LastPublishedWidget } = await import('./components/Widgets');\n return LastPublishedWidget;\n },\n pluginId: PLUGIN_ID,\n id: 'last-published-entries',\n permissions: [{ action: 'plugin::content-manager.explorer.read' }],\n },\n ]);\n },\n bootstrap(app: any) {\n if (typeof historyAdmin.bootstrap === 'function') {\n historyAdmin.bootstrap(app);\n }\n if (typeof previewAdmin.bootstrap === 'function') {\n previewAdmin.bootstrap(app);\n }\n },\n async registerTrads({ locales }: { locales: string[] }) {\n const importedTrads = await Promise.all(\n locales.map((locale) => {\n return import(`./translations/${locale}.json`)\n .then(({ default: data }) => {\n return {\n data: prefixPluginTranslations(data, PLUGIN_ID),\n locale,\n };\n })\n .catch(() => {\n return {\n data: {},\n locale,\n };\n });\n })\n );\n\n return Promise.resolve(importedTrads);\n },\n};\n\nexport * from './exports';\n"],"names":["register","app","cm","ContentManagerPlugin","addReducers","PLUGIN_ID","reducer","addMenuLink","to","icon","Feather","intlLabel","id","defaultMessage","permissions","position","router","addRoute","path","lazy","Layout","Component","children","routes","registerPlugin","config","widgets","Pencil","title","component","LastEditedWidget","pluginId","action","CheckCircle","LastPublishedWidget","bootstrap","historyAdmin","previewAdmin","registerTrads","locales","importedTrads","Promise","all","map","locale","then","default","data","prefixPluginTranslations","catch","resolve"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA;AACA,YAAe;AACbA,IAAAA,QAAAA,CAAAA,CAASC,GAAQ,EAAA;AACf,QAAA,MAAMC,KAAK,IAAIC,oBAAAA,EAAAA;AAEfF,QAAAA,GAAAA,CAAIG,WAAW,CAAC;AACd,YAAA,CAACC,YAAYC;AACf,SAAA,CAAA;AAEAL,QAAAA,GAAAA,CAAIM,WAAW,CAAC;YACdC,EAAIH,EAAAA,SAAAA;YACJI,IAAMC,EAAAA,OAAAA;YACNC,SAAW,EAAA;gBACTC,EAAI,EAAA,CAAC,2BAA2B,CAAC;gBACjCC,cAAgB,EAAA;AAClB,aAAA;AACAC,YAAAA,WAAAA,EAAa,EAAE;YACfC,QAAU,EAAA;AACZ,SAAA,CAAA;QAEAd,GAAIe,CAAAA,MAAM,CAACC,QAAQ,CAAC;YAClBC,IAAM,EAAA,mBAAA;YACNC,IAAM,EAAA,UAAA;AACJ,gBAAA,MAAM,EAAEC,MAAM,EAAE,GAAG,MAAM,OAAO,cAAA,CAAA;gBAEhC,OAAO;oBACLC,SAAWD,EAAAA;AACb,iBAAA;AACF,aAAA;YACAE,QAAUC,EAAAA;AACZ,SAAA,CAAA;QAEAtB,GAAIuB,CAAAA,cAAc,CAACtB,EAAAA,CAAGuB,MAAM,CAAA;;QAG5BxB,GAAIyB,CAAAA,OAAO,CAAC1B,QAAQ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AAAA,CAAAA,CAAc,EAAEC,OAAO,EAAyB,EAAA;QACpD,MAAMC,aAAAA,GAAgB,MAAMC,OAAQC,CAAAA,GAAG,CACrCH,OAAQI,CAAAA,GAAG,CAAC,CAACC,MAAAA,GAAAA;AACX,YAAA,OAAO,iCAAM,CAAC,CAAC,eAAe,EAAEA,MAAO,CAAA,KAAK,CAAC,CAAA,CAC1CC,IAAI,CAAC,CAAC,EAAEC,OAAAA,EAASC,IAAI,EAAE,GAAA;gBACtB,OAAO;AACLA,oBAAAA,IAAAA,EAAMC,yBAAyBD,IAAM1C,EAAAA,SAAAA,CAAAA;AACrCuC,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA,CACCK,KAAK,CAAC,IAAA;gBACL,OAAO;AACLF,oBAAAA,IAAAA,EAAM,EAAC;AACPH,oBAAAA;AACF,iBAAA;AACF,aAAA,CAAA;AACJ,SAAA,CAAA,CAAA;QAGF,OAAOH,OAAAA,CAAQS,OAAO,CAACV,aAAAA,CAAAA;AACzB;AACF,CAAE;;;;"}
@@ -6,6 +6,9 @@ var strapiAdmin = require('@strapi/admin/strapi-admin');
6
6
  var designSystem = require('@strapi/design-system');
7
7
  var Icons = require('@strapi/icons');
8
8
  var mapValues = require('lodash/fp/mapValues');
9
+ var get = require('lodash/get');
10
+ var merge = require('lodash/merge');
11
+ var set = require('lodash/set');
9
12
  var reactIntl = require('react-intl');
10
13
  var reactRouterDom = require('react-router-dom');
11
14
  var styledComponents = require('styled-components');
@@ -20,6 +23,7 @@ var router = require('../../../router.js');
20
23
  var documents = require('../../../services/documents.js');
21
24
  var api = require('../../../utils/api.js');
22
25
  var translations = require('../../../utils/translations.js');
26
+ var RelationModal = require('./FormInputs/Relations/RelationModal.js');
23
27
 
24
28
  function _interopNamespaceDefault(e) {
25
29
  var n = Object.create(null);
@@ -40,6 +44,38 @@ function _interopNamespaceDefault(e) {
40
44
 
41
45
  var React__namespace = /*#__PURE__*/_interopNamespaceDefault(React);
42
46
 
47
+ const connectRelationToParent = (parentDataToUpdate, fieldToConnect, data, fieldToConnectUID)=>{
48
+ /*
49
+ * Check if the fieldToConnect is already present in the parentDataToUpdate.
50
+ * This happens in particular when in the parentDocument you have created
51
+ * a new component without saving.
52
+ */ const isFieldPresent = !!get(parentDataToUpdate, fieldToConnect);
53
+ const fieldToConnectPath = isFieldPresent ? fieldToConnect : fieldToConnect.split('.').slice(0, -1).join('.');
54
+ const fieldToConnectValue = isFieldPresent ? {
55
+ connect: [
56
+ {
57
+ id: data.documentId,
58
+ documentId: data.documentId,
59
+ locale: data.locale
60
+ }
61
+ ]
62
+ } : {
63
+ [fieldToConnect.split('.').pop()]: {
64
+ connect: [
65
+ {
66
+ id: data.documentId,
67
+ documentId: data.documentId,
68
+ locale: data.locale
69
+ }
70
+ ],
71
+ disconnect: []
72
+ },
73
+ // In case the object was not present you need to pass the componentUID of the parent document
74
+ __component: fieldToConnectUID
75
+ };
76
+ const objectToConnect = set({}, fieldToConnectPath, fieldToConnectValue);
77
+ return merge(parentDataToUpdate, objectToConnect);
78
+ };
43
79
  const DocumentActions = ({ actions })=>{
44
80
  const { formatMessage } = reactIntl.useIntl();
45
81
  const [primaryAction, secondaryAction, ...restActions] = actions.filter((action)=>{
@@ -395,7 +431,17 @@ const transformData = (data)=>{
395
431
  const setErrors = strapiAdmin.useForm('PublishAction', (state)=>state.setErrors);
396
432
  const formValues = strapiAdmin.useForm('PublishAction', ({ values })=>values);
397
433
  const resetForm = strapiAdmin.useForm('PublishAction', ({ resetForm })=>resetForm);
434
+ // need to discriminate if the publish is coming from a relation modal or in the edit view
435
+ const relationContext = RelationModal.useRelationModal('PublishAction', ()=>true, false);
436
+ const fromRelationModal = relationContext != undefined;
437
+ const dispatch = RelationModal.useRelationModal('PublishAction', (state)=>state.dispatch);
438
+ const fieldToConnect = RelationModal.useRelationModal('PublishAction', (state)=>state.state.fieldToConnect, false);
439
+ const fieldToConnectUID = RelationModal.useRelationModal('PublishAction', (state)=>state.state.fieldToConnectUID, false);
440
+ const documentHistory = RelationModal.useRelationModal('PublishAction', (state)=>state.state.documentHistory, false);
441
+ const rootDocumentMeta = RelationModal.useRelationModal('PublishAction', (state)=>state.rootDocumentMeta);
398
442
  const { currentDocumentMeta } = useDocumentContext.useDocumentContext('PublishAction');
443
+ const [updateDocumentMutation] = documents.useUpdateDocumentMutation();
444
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
399
445
  const idToPublish = currentDocumentMeta.documentId || id;
400
446
  React__namespace.useEffect(()=>{
401
447
  if (isErrorDraftRelations) {
@@ -479,6 +525,16 @@ const transformData = (data)=>{
479
525
  model,
480
526
  currentDocumentMeta.params
481
527
  ]);
528
+ const parentDocumentMetaToUpdate = documentHistory?.at(-2) ?? rootDocumentMeta;
529
+ const parentDocumentData = useDocument.useDocument({
530
+ documentId: parentDocumentMetaToUpdate?.documentId,
531
+ model: parentDocumentMetaToUpdate?.model,
532
+ collectionType: parentDocumentMetaToUpdate?.collectionType,
533
+ params: parentDocumentMetaToUpdate?.params
534
+ }, {
535
+ skip: !parentDocumentMetaToUpdate
536
+ });
537
+ const { getInitialFormValues } = useDocument.useDoc();
482
538
  const isDocumentPublished = (document?.[attributes.PUBLISHED_AT_ATTRIBUTE_NAME] || meta?.availableStatus.some((doc)=>doc[attributes.PUBLISHED_AT_ATTRIBUTE_NAME] !== null)) && document?.status !== 'modified';
483
539
  if (!schema?.options?.draftAndPublish) {
484
540
  return null;
@@ -512,11 +568,59 @@ const transformData = (data)=>{
512
568
  if ('data' in res && collectionType !== collections.SINGLE_TYPES) {
513
569
  /**
514
570
  * TODO: refactor the router so we can just do `../${res.data.documentId}` instead of this.
515
- */ if (idToPublish === 'create') {
571
+ */ if (idToPublish === 'create' && !fromRelationModal) {
516
572
  navigate({
517
573
  pathname: `../${collectionType}/${model}/${res.data.documentId}`,
518
574
  search: rawQuery
519
575
  });
576
+ } else if (fromRelationModal) {
577
+ const newRelation = {
578
+ documentId: res.data.documentId,
579
+ collectionType,
580
+ model,
581
+ params: currentDocumentMeta.params
582
+ };
583
+ /*
584
+ * Update, if needed, the parent relation with the newly published document.
585
+ * Check if in history we have the parent relation otherwise use the
586
+ * rootDocument
587
+ */ if (fieldToConnect && documentHistory && (parentDocumentMetaToUpdate.documentId || parentDocumentMetaToUpdate.collectionType === collections.SINGLE_TYPES)) {
588
+ const parentDataToUpdate = parentDocumentMetaToUpdate.collectionType === collections.SINGLE_TYPES ? getInitialFormValues() : parentDocumentData.getInitialFormValues();
589
+ const metaDocumentToUpdate = documentHistory.at(-2) ?? rootDocumentMeta;
590
+ const dataToUpdate = connectRelationToParent(parentDataToUpdate, fieldToConnect, res.data, fieldToConnectUID);
591
+ try {
592
+ const updateRes = await updateDocumentMutation({
593
+ collectionType: metaDocumentToUpdate.collectionType,
594
+ model: metaDocumentToUpdate.model,
595
+ documentId: metaDocumentToUpdate.collectionType !== collections.SINGLE_TYPES ? metaDocumentToUpdate.documentId : undefined,
596
+ params: metaDocumentToUpdate.params,
597
+ data: dataToUpdate
598
+ });
599
+ if ('error' in updateRes) {
600
+ toggleNotification({
601
+ type: 'danger',
602
+ message: formatAPIError(updateRes.error)
603
+ });
604
+ return;
605
+ }
606
+ } catch (err) {
607
+ toggleNotification({
608
+ type: 'danger',
609
+ message: formatMessage({
610
+ id: 'notification.error',
611
+ defaultMessage: 'An error occurred'
612
+ })
613
+ });
614
+ throw err;
615
+ }
616
+ }
617
+ dispatch({
618
+ type: 'GO_TO_CREATED_RELATION',
619
+ payload: {
620
+ document: newRelation,
621
+ shouldBypassConfirmation: true
622
+ }
623
+ });
520
624
  }
521
625
  } else if ('error' in res && api.isBaseQueryError(res.error) && res.error.name === 'ValidationError') {
522
626
  setErrors(formatValidationErrors(res.error));
@@ -592,14 +696,34 @@ const UpdateAction = ({ activeTab, documentId, model, collectionType })=>{
592
696
  const { create, update, clone, isLoading } = useDocumentActions.useDocumentActions();
593
697
  const [{ rawQuery }] = strapiAdmin.useQueryParams();
594
698
  const onPreview = Preview.usePreviewContext('UpdateAction', (state)=>state.onPreview, false);
699
+ const { getInitialFormValues } = useDocument.useDoc();
595
700
  const isSubmitting = strapiAdmin.useForm('UpdateAction', ({ isSubmitting })=>isSubmitting);
596
701
  const modified = strapiAdmin.useForm('UpdateAction', ({ modified })=>modified);
597
702
  const setSubmitting = strapiAdmin.useForm('UpdateAction', ({ setSubmitting })=>setSubmitting);
598
703
  const document = strapiAdmin.useForm('UpdateAction', ({ values })=>values);
599
704
  const validate = strapiAdmin.useForm('UpdateAction', (state)=>state.validate);
600
705
  const setErrors = strapiAdmin.useForm('UpdateAction', (state)=>state.setErrors);
601
- const resetForm = strapiAdmin.useForm('PublishAction', ({ resetForm })=>resetForm);
706
+ const resetForm = strapiAdmin.useForm('UpdateAction', ({ resetForm })=>resetForm);
707
+ const dispatch = RelationModal.useRelationModal('UpdateAction', (state)=>state.dispatch);
708
+ // need to discriminate if the update is coming from a relation modal or in the edit view
709
+ const relationContext = RelationModal.useRelationModal('UpdateAction', ()=>true, false);
710
+ const fieldToConnect = RelationModal.useRelationModal('UpdateAction', (state)=>state.state.fieldToConnect, false);
711
+ const fieldToConnectUID = RelationModal.useRelationModal('PublishAction', (state)=>state.state.fieldToConnectUID, false);
712
+ const documentHistory = RelationModal.useRelationModal('UpdateAction', (state)=>state.state.documentHistory, false);
713
+ const rootDocumentMeta = RelationModal.useRelationModal('UpdateAction', (state)=>state.rootDocumentMeta);
714
+ const fromRelationModal = relationContext != undefined;
602
715
  const { currentDocumentMeta } = useDocumentContext.useDocumentContext('UpdateAction');
716
+ const [updateDocumentMutation] = documents.useUpdateDocumentMutation();
717
+ const { _unstableFormatAPIError: formatAPIError } = strapiAdmin.useAPIErrorHandler();
718
+ const parentDocumentMetaToUpdate = documentHistory?.at(-2) ?? rootDocumentMeta;
719
+ const parentDocumentData = useDocument.useDocument({
720
+ documentId: parentDocumentMetaToUpdate?.documentId,
721
+ model: parentDocumentMetaToUpdate?.model,
722
+ collectionType: parentDocumentMetaToUpdate?.collectionType,
723
+ params: parentDocumentMetaToUpdate?.params
724
+ }, {
725
+ skip: !parentDocumentMetaToUpdate
726
+ });
603
727
  const handleUpdate = React__namespace.useCallback(async ()=>{
604
728
  setSubmitting(true);
605
729
  try {
@@ -653,13 +777,64 @@ const UpdateAction = ({ activeTab, documentId, model, collectionType })=>{
653
777
  params: currentDocumentMeta.params
654
778
  }, transformData(document));
655
779
  if ('data' in res && collectionType !== collections.SINGLE_TYPES) {
656
- navigate({
657
- pathname: `../${res.data.documentId}`,
658
- search: rawQuery
659
- }, {
660
- replace: true,
661
- relative: 'path'
662
- });
780
+ if (fromRelationModal) {
781
+ const createdRelation = {
782
+ documentId: res.data.documentId,
783
+ collectionType,
784
+ model,
785
+ params: currentDocumentMeta.params
786
+ };
787
+ /*
788
+ * Update, if needed, the parent relation with the newly published document.
789
+ * Check if in history we have the parent relation otherwise use the
790
+ * rootDocument
791
+ */ if (fieldToConnect && documentHistory && (parentDocumentMetaToUpdate.documentId || parentDocumentMetaToUpdate.collectionType === collections.SINGLE_TYPES)) {
792
+ const parentDataToUpdate = parentDocumentMetaToUpdate.collectionType === collections.SINGLE_TYPES ? getInitialFormValues() : parentDocumentData.getInitialFormValues();
793
+ const dataToUpdate = connectRelationToParent(parentDataToUpdate, fieldToConnect, res.data, fieldToConnectUID);
794
+ try {
795
+ const updateRes = await updateDocumentMutation({
796
+ collectionType: parentDocumentMetaToUpdate.collectionType,
797
+ model: parentDocumentMetaToUpdate.model,
798
+ documentId: parentDocumentMetaToUpdate.collectionType !== collections.SINGLE_TYPES ? parentDocumentMetaToUpdate.documentId : undefined,
799
+ params: parentDocumentMetaToUpdate.params,
800
+ data: {
801
+ ...dataToUpdate
802
+ }
803
+ });
804
+ if ('error' in updateRes) {
805
+ toggleNotification({
806
+ type: 'danger',
807
+ message: formatAPIError(updateRes.error)
808
+ });
809
+ return;
810
+ }
811
+ } catch (err) {
812
+ toggleNotification({
813
+ type: 'danger',
814
+ message: formatMessage({
815
+ id: 'notification.error',
816
+ defaultMessage: 'An error occurred'
817
+ })
818
+ });
819
+ throw err;
820
+ }
821
+ }
822
+ dispatch({
823
+ type: 'GO_TO_CREATED_RELATION',
824
+ payload: {
825
+ document: createdRelation,
826
+ shouldBypassConfirmation: true
827
+ }
828
+ });
829
+ } else {
830
+ navigate({
831
+ pathname: `../${res.data.documentId}`,
832
+ search: rawQuery
833
+ }, {
834
+ replace: true,
835
+ relative: 'path'
836
+ });
837
+ }
663
838
  } else if ('error' in res && api.isBaseQueryError(res.error) && res.error.name === 'ValidationError') {
664
839
  setErrors(formatValidationErrors(res.error));
665
840
  }
@@ -671,26 +846,36 @@ const UpdateAction = ({ activeTab, documentId, model, collectionType })=>{
671
846
  }
672
847
  }
673
848
  }, [
849
+ setSubmitting,
850
+ modified,
851
+ validate,
852
+ isCloning,
853
+ documentId,
854
+ collectionType,
855
+ toggleNotification,
856
+ formatMessage,
674
857
  clone,
858
+ model,
675
859
  cloneMatch?.params.origin,
676
- collectionType,
677
- create,
678
860
  currentDocumentMeta.params,
679
861
  document,
680
- documentId,
681
- formatMessage,
682
- formatValidationErrors,
683
- isCloning,
684
- model,
685
- modified,
686
862
  navigate,
687
863
  rawQuery,
688
- resetForm,
689
864
  setErrors,
690
- setSubmitting,
691
- toggleNotification,
865
+ formatValidationErrors,
692
866
  update,
693
- validate,
867
+ resetForm,
868
+ create,
869
+ fromRelationModal,
870
+ fieldToConnect,
871
+ documentHistory,
872
+ parentDocumentMetaToUpdate,
873
+ dispatch,
874
+ getInitialFormValues,
875
+ parentDocumentData,
876
+ fieldToConnectUID,
877
+ updateDocumentMutation,
878
+ formatAPIError,
694
879
  onPreview
695
880
  ]);
696
881
  // Auto-save on CMD+S or CMD+Enter on macOS, and CTRL+S or CTRL+Enter on Windows/Linux