Move sync root
This commit is contained in:
parent
490c0df56e
commit
d55aeabb3d
@ -9,6 +9,7 @@ import { Route, Switch, Redirect } from 'react-router-dom';
|
|||||||
import { Notifs } from 'redux-notifications';
|
import { Notifs } from 'redux-notifications';
|
||||||
import TopBarProgress from 'react-topbar-progress-indicator';
|
import TopBarProgress from 'react-topbar-progress-indicator';
|
||||||
import { Loader, colors } from 'netlify-cms-ui-default';
|
import { Loader, colors } from 'netlify-cms-ui-default';
|
||||||
|
import { ScrollSync } from 'react-scroll-sync';
|
||||||
|
|
||||||
import { loginUser, logoutUser } from '../../actions/auth';
|
import { loginUser, logoutUser } from '../../actions/auth';
|
||||||
import { currentBackend } from '../../backend';
|
import { currentBackend } from '../../backend';
|
||||||
@ -33,10 +34,15 @@ TopBarProgress.config({
|
|||||||
barThickness: 2,
|
barThickness: 2,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const AppRoot = styled.div`
|
||||||
|
width: 100%;
|
||||||
|
min-height: 100%;
|
||||||
|
`;
|
||||||
|
|
||||||
const AppWrapper = styled.div`
|
const AppWrapper = styled.div`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
min-height: 100%;
|
min-height: 100%;
|
||||||
`
|
`;
|
||||||
|
|
||||||
const AppMainContainer = styled.div`
|
const AppMainContainer = styled.div`
|
||||||
min-width: 1200px;
|
min-width: 1200px;
|
||||||
@ -180,6 +186,8 @@ class App extends React.Component {
|
|||||||
const hasWorkflow = publishMode === EDITORIAL_WORKFLOW;
|
const hasWorkflow = publishMode === EDITORIAL_WORKFLOW;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<ScrollSync>
|
||||||
|
<AppRoot id="cms-root">
|
||||||
<AppWrapper className="cms-wrapper">
|
<AppWrapper className="cms-wrapper">
|
||||||
<Notifs CustomComponent={Toast} />
|
<Notifs CustomComponent={Toast} />
|
||||||
<Header
|
<Header
|
||||||
@ -254,6 +262,8 @@ class App extends React.Component {
|
|||||||
{useMediaLibrary ? <MediaLibrary /> : null}
|
{useMediaLibrary ? <MediaLibrary /> : null}
|
||||||
</AppMainContainer>
|
</AppMainContainer>
|
||||||
</AppWrapper>
|
</AppWrapper>
|
||||||
|
</AppRoot>
|
||||||
|
</ScrollSync>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@ import React from 'react';
|
|||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
import { ScrollSyncPane } from 'react-scroll-sync';
|
||||||
|
|
||||||
function isVisible(field) {
|
function isVisible(field) {
|
||||||
return field.get('widget') !== 'hidden';
|
return field.get('widget') !== 'hidden';
|
||||||
@ -26,11 +27,13 @@ export default class Preview extends React.Component {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
|
<ScrollSyncPane>
|
||||||
<PreviewContainer>
|
<PreviewContainer>
|
||||||
{fields.filter(isVisible).map(field => (
|
{fields.filter(isVisible).map(field => (
|
||||||
<div key={field.get('name')}>{widgetFor(field.get('name'))}</div>
|
<div key={field.get('name')}>{widgetFor(field.get('name'))}</div>
|
||||||
))}
|
))}
|
||||||
</PreviewContainer>
|
</PreviewContainer>
|
||||||
|
</ScrollSyncPane>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ const StyledPreviewContent = styled.div`
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
const PreviewContent = ({ previewComponent, previewProps }: PreviewContentProps) => {
|
const PreviewContent = ({ previewComponent, previewProps }: PreviewContentProps) => {
|
||||||
const element = useMemo(() => document.getElementById('nc-root'), []);
|
const element = useMemo(() => document.getElementById('cms-root'), []);
|
||||||
|
|
||||||
return useMemo(() => {
|
return useMemo(() => {
|
||||||
if (!element) {
|
if (!element) {
|
||||||
|
@ -5,7 +5,6 @@ import { List, Map } from 'immutable';
|
|||||||
import ImmutablePropTypes from 'react-immutable-proptypes';
|
import ImmutablePropTypes from 'react-immutable-proptypes';
|
||||||
import { lengths } from 'netlify-cms-ui-default';
|
import { lengths } from 'netlify-cms-ui-default';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { ScrollSyncPane } from 'react-scroll-sync';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
resolveWidget,
|
resolveWidget,
|
||||||
@ -232,13 +231,11 @@ export class PreviewPane extends React.Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<ErrorBoundary config={config}>
|
<ErrorBoundary config={config}>
|
||||||
<ScrollSyncPane>{/* attachTo={document.getElementById('control-pane')}>*/}
|
|
||||||
<PreviewPaneFrame id="preview-pane" head={styleEls} initialContent={initialContent}>
|
<PreviewPaneFrame id="preview-pane" head={styleEls} initialContent={initialContent}>
|
||||||
<EditorPreviewContent
|
<EditorPreviewContent
|
||||||
{...{ previewComponent, previewProps: { ...previewProps, document, window } }}
|
{...{ previewComponent, previewProps: { ...previewProps, document, window } }}
|
||||||
/>
|
/>
|
||||||
</PreviewPaneFrame>
|
</PreviewPaneFrame>
|
||||||
</ScrollSyncPane>
|
|
||||||
</ErrorBoundary>
|
</ErrorBoundary>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user