mirror of
https://github.com/strapi/strapi.git
synced 2025-11-16 10:07:55 +00:00
feat: preview content in an iframe (#22008)
* feat: preview content * fix: pr suggestions * fix: pr suggestions * fix: iframe border
This commit is contained in:
parent
f5312617ca
commit
011cefc73f
@ -5,7 +5,17 @@ const responseHandlers = require('./src/response-handlers');
|
|||||||
module.exports = [
|
module.exports = [
|
||||||
'strapi::logger',
|
'strapi::logger',
|
||||||
'strapi::errors',
|
'strapi::errors',
|
||||||
'strapi::security',
|
{
|
||||||
|
name: 'strapi::security',
|
||||||
|
config: {
|
||||||
|
contentSecurityPolicy: {
|
||||||
|
useDefaults: true,
|
||||||
|
directives: {
|
||||||
|
'frame-src': ["'self'"], // URLs that will be loaded in an iframe (e.g. Content Preview)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
'strapi::cors',
|
'strapi::cors',
|
||||||
'strapi::poweredBy',
|
'strapi::poweredBy',
|
||||||
'strapi::query',
|
'strapi::query',
|
||||||
|
|||||||
@ -0,0 +1,28 @@
|
|||||||
|
import * as React from 'react';
|
||||||
|
|
||||||
|
import { Box } from '@strapi/design-system';
|
||||||
|
import { useIntl } from 'react-intl';
|
||||||
|
|
||||||
|
import { usePreviewContext } from '../pages/Preview';
|
||||||
|
|
||||||
|
const PreviewContent = () => {
|
||||||
|
const previewUrl = usePreviewContext('PreviewContent', (state) => state.url);
|
||||||
|
|
||||||
|
const { formatMessage } = useIntl();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
src={previewUrl}
|
||||||
|
title={formatMessage({
|
||||||
|
id: 'content-manager.preview.panel.title',
|
||||||
|
defaultMessage: 'Preview',
|
||||||
|
})}
|
||||||
|
width="100%"
|
||||||
|
height="100%"
|
||||||
|
borderWidth={0}
|
||||||
|
tag="iframe"
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export { PreviewContent };
|
||||||
@ -1,7 +1,7 @@
|
|||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
|
|
||||||
import { Page, useQueryParams, useRBAC, createContext } from '@strapi/admin/strapi-admin';
|
import { Page, useQueryParams, useRBAC, createContext } from '@strapi/admin/strapi-admin';
|
||||||
import { Box, FocusTrap, Portal } from '@strapi/design-system';
|
import { Box, Flex, FocusTrap, Portal } from '@strapi/design-system';
|
||||||
import { useIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
import { useParams } from 'react-router-dom';
|
import { useParams } from 'react-router-dom';
|
||||||
|
|
||||||
@ -11,6 +11,7 @@ import { DocumentRBAC } from '../../features/DocumentRBAC';
|
|||||||
import { type UseDocument, useDocument } from '../../hooks/useDocument';
|
import { type UseDocument, useDocument } from '../../hooks/useDocument';
|
||||||
import { useDocumentLayout } from '../../hooks/useDocumentLayout';
|
import { useDocumentLayout } from '../../hooks/useDocumentLayout';
|
||||||
import { buildValidParams } from '../../utils/api';
|
import { buildValidParams } from '../../utils/api';
|
||||||
|
import { PreviewContent } from '../components/PreviewContent';
|
||||||
import { PreviewHeader } from '../components/PreviewHeader';
|
import { PreviewHeader } from '../components/PreviewHeader';
|
||||||
import { useGetPreviewUrlQuery } from '../services/preview';
|
import { useGetPreviewUrlQuery } from '../services/preview';
|
||||||
|
|
||||||
@ -127,7 +128,10 @@ const PreviewPage = () => {
|
|||||||
meta={documentResponse.meta}
|
meta={documentResponse.meta}
|
||||||
schema={documentResponse.schema}
|
schema={documentResponse.schema}
|
||||||
>
|
>
|
||||||
|
<Flex direction="column" height="100%" alignItems={'stretch'}>
|
||||||
<PreviewHeader />
|
<PreviewHeader />
|
||||||
|
<PreviewContent />
|
||||||
|
</Flex>
|
||||||
</PreviewProvider>
|
</PreviewProvider>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user