|
@@ -1,35 +1,34 @@
|
|
|
-import React, { useEffect, useRef } from 'react';
|
|
|
|
|
|
|
+import React, {
|
|
|
|
|
+ useCallback, useEffect, useMemo, useRef, useState,
|
|
|
|
|
+} from 'react';
|
|
|
|
|
|
|
|
|
|
+import dynamic from 'next/dynamic';
|
|
|
import PropTypes from 'prop-types';
|
|
import PropTypes from 'prop-types';
|
|
|
|
|
+import { debounce } from 'throttle-debounce';
|
|
|
|
|
|
|
|
import MarkdownTable from '~/client/models/MarkdownTable';
|
|
import MarkdownTable from '~/client/models/MarkdownTable';
|
|
|
-import AppContainer from '~/client/services/AppContainer';
|
|
|
|
|
-import EditorContainer from '~/client/services/EditorContainer';
|
|
|
|
|
-import PageContainer from '~/client/services/PageContainer';
|
|
|
|
|
|
|
+import { blinkSectionHeaderAtBoot } from '~/client/util/blink-section-header';
|
|
|
import { getOptionsToSave } from '~/client/util/editor';
|
|
import { getOptionsToSave } from '~/client/util/editor';
|
|
|
import {
|
|
import {
|
|
|
- useCurrentPagePath, useIsGuestUser,
|
|
|
|
|
|
|
+ useIsGuestUser, useIsBlinkedHeaderAtBoot,
|
|
|
} from '~/stores/context';
|
|
} from '~/stores/context';
|
|
|
import {
|
|
import {
|
|
|
useSWRxSlackChannels, useIsSlackEnabled, usePageTagsForEditors, useIsEnabledUnsavedWarning,
|
|
useSWRxSlackChannels, useIsSlackEnabled, usePageTagsForEditors, useIsEnabledUnsavedWarning,
|
|
|
} from '~/stores/editor';
|
|
} from '~/stores/editor';
|
|
|
|
|
+import { useSWRxCurrentPage } from '~/stores/page';
|
|
|
|
|
+import { useViewOptions } from '~/stores/renderer';
|
|
|
import {
|
|
import {
|
|
|
- useEditorMode, useIsMobile, useSelectedGrant, useSelectedGrantGroupId, useSelectedGrantGroupName,
|
|
|
|
|
|
|
+ useEditorMode, useIsMobile,
|
|
|
} from '~/stores/ui';
|
|
} from '~/stores/ui';
|
|
|
import loggerFactory from '~/utils/logger';
|
|
import loggerFactory from '~/utils/logger';
|
|
|
|
|
|
|
|
import RevisionRenderer from './Page/RevisionRenderer';
|
|
import RevisionRenderer from './Page/RevisionRenderer';
|
|
|
-import DrawioModal from './PageEditor/DrawioModal';
|
|
|
|
|
-import GridEditModal from './PageEditor/GridEditModal';
|
|
|
|
|
-import HandsontableModal from './PageEditor/HandsontableModal';
|
|
|
|
|
-import LinkEditModal from './PageEditor/LinkEditModal';
|
|
|
|
|
import mdu from './PageEditor/MarkdownDrawioUtil';
|
|
import mdu from './PageEditor/MarkdownDrawioUtil';
|
|
|
import mtu from './PageEditor/MarkdownTableUtil';
|
|
import mtu from './PageEditor/MarkdownTableUtil';
|
|
|
-import { withUnstatedContainers } from './UnstatedUtils';
|
|
|
|
|
|
|
|
|
|
const logger = loggerFactory('growi:Page');
|
|
const logger = loggerFactory('growi:Page');
|
|
|
|
|
|
|
|
-class Page extends React.Component {
|
|
|
|
|
|
|
+class PageSubstance extends React.Component {
|
|
|
|
|
|
|
|
constructor(props) {
|
|
constructor(props) {
|
|
|
super(props);
|
|
super(props);
|
|
@@ -39,8 +38,6 @@ class Page extends React.Component {
|
|
|
currentTargetDrawioArea: null,
|
|
currentTargetDrawioArea: null,
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
- this.growiRenderer = this.props.appContainer.getRenderer('page');
|
|
|
|
|
-
|
|
|
|
|
this.gridEditModal = React.createRef();
|
|
this.gridEditModal = React.createRef();
|
|
|
this.linkEditModal = React.createRef();
|
|
this.linkEditModal = React.createRef();
|
|
|
this.handsontableModal = React.createRef();
|
|
this.handsontableModal = React.createRef();
|
|
@@ -56,10 +53,10 @@ class Page extends React.Component {
|
|
|
* @param endLineNumber
|
|
* @param endLineNumber
|
|
|
*/
|
|
*/
|
|
|
launchHandsontableModal(beginLineNumber, endLineNumber) {
|
|
launchHandsontableModal(beginLineNumber, endLineNumber) {
|
|
|
- const markdown = this.props.pageContainer.state.markdown;
|
|
|
|
|
- const tableLines = markdown.split(/\r\n|\r|\n/).slice(beginLineNumber - 1, endLineNumber).join('\n');
|
|
|
|
|
- this.setState({ currentTargetTableArea: { beginLineNumber, endLineNumber } });
|
|
|
|
|
- this.handsontableModal.current.show(MarkdownTable.fromMarkdownString(tableLines));
|
|
|
|
|
|
|
+ // const markdown = this.props.pageContainer.state.markdown;
|
|
|
|
|
+ // const tableLines = markdown.split(/\r\n|\r|\n/).slice(beginLineNumber - 1, endLineNumber).join('\n');
|
|
|
|
|
+ // this.setState({ currentTargetTableArea: { beginLineNumber, endLineNumber } });
|
|
|
|
|
+ // this.handsontableModal.current.show(MarkdownTable.fromMarkdownString(tableLines));
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -68,96 +65,102 @@ class Page extends React.Component {
|
|
|
* @param endLineNumber
|
|
* @param endLineNumber
|
|
|
*/
|
|
*/
|
|
|
launchDrawioModal(beginLineNumber, endLineNumber) {
|
|
launchDrawioModal(beginLineNumber, endLineNumber) {
|
|
|
- const markdown = this.props.pageContainer.state.markdown;
|
|
|
|
|
- const drawioMarkdownArray = markdown.split(/\r\n|\r|\n/).slice(beginLineNumber - 1, endLineNumber);
|
|
|
|
|
- const drawioData = drawioMarkdownArray.slice(1, drawioMarkdownArray.length - 1).join('\n').trim();
|
|
|
|
|
- this.setState({ currentTargetDrawioArea: { beginLineNumber, endLineNumber } });
|
|
|
|
|
- this.drawioModal.current.show(drawioData);
|
|
|
|
|
|
|
+ // const markdown = this.props.pageContainer.state.markdown;
|
|
|
|
|
+ // const drawioMarkdownArray = markdown.split(/\r\n|\r|\n/).slice(beginLineNumber - 1, endLineNumber);
|
|
|
|
|
+ // const drawioData = drawioMarkdownArray.slice(1, drawioMarkdownArray.length - 1).join('\n').trim();
|
|
|
|
|
+ // this.setState({ currentTargetDrawioArea: { beginLineNumber, endLineNumber } });
|
|
|
|
|
+ // this.drawioModal.current.show(drawioData);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async saveHandlerForHandsontableModal(markdownTable) {
|
|
async saveHandlerForHandsontableModal(markdownTable) {
|
|
|
- const {
|
|
|
|
|
- isSlackEnabled, slackChannels, pageContainer, mutateIsEnabledUnsavedWarning, grant, grantGroupId, grantGroupName, pageTags,
|
|
|
|
|
- } = this.props;
|
|
|
|
|
- const optionsToSave = getOptionsToSave(isSlackEnabled, slackChannels, grant, grantGroupId, grantGroupName, pageTags);
|
|
|
|
|
-
|
|
|
|
|
- const newMarkdown = mtu.replaceMarkdownTableInMarkdown(
|
|
|
|
|
- markdownTable,
|
|
|
|
|
- this.props.pageContainer.state.markdown,
|
|
|
|
|
- this.state.currentTargetTableArea.beginLineNumber,
|
|
|
|
|
- this.state.currentTargetTableArea.endLineNumber,
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- // disable unsaved warning
|
|
|
|
|
- mutateIsEnabledUnsavedWarning(false);
|
|
|
|
|
-
|
|
|
|
|
- // eslint-disable-next-line no-unused-vars
|
|
|
|
|
- const { page, tags } = await pageContainer.save(newMarkdown, this.props.editorMode, optionsToSave);
|
|
|
|
|
- logger.debug('success to save');
|
|
|
|
|
-
|
|
|
|
|
- pageContainer.showSuccessToastr();
|
|
|
|
|
- }
|
|
|
|
|
- catch (error) {
|
|
|
|
|
- logger.error('failed to save', error);
|
|
|
|
|
- pageContainer.showErrorToastr(error);
|
|
|
|
|
- }
|
|
|
|
|
- finally {
|
|
|
|
|
- this.setState({ currentTargetTableArea: null });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // const {
|
|
|
|
|
+ // isSlackEnabled, slackChannels, pageContainer, mutateIsEnabledUnsavedWarning, grant, grantGroupId, grantGroupName, pageTags,
|
|
|
|
|
+ // } = this.props;
|
|
|
|
|
+ // const optionsToSave = getOptionsToSave(isSlackEnabled, slackChannels, grant, grantGroupId, grantGroupName, pageTags);
|
|
|
|
|
+
|
|
|
|
|
+ // const newMarkdown = mtu.replaceMarkdownTableInMarkdown(
|
|
|
|
|
+ // markdownTable,
|
|
|
|
|
+ // this.props.pageContainer.state.markdown,
|
|
|
|
|
+ // this.state.currentTargetTableArea.beginLineNumber,
|
|
|
|
|
+ // this.state.currentTargetTableArea.endLineNumber,
|
|
|
|
|
+ // );
|
|
|
|
|
+
|
|
|
|
|
+ // try {
|
|
|
|
|
+ // // disable unsaved warning
|
|
|
|
|
+ // mutateIsEnabledUnsavedWarning(false);
|
|
|
|
|
+
|
|
|
|
|
+ // // eslint-disable-next-line no-unused-vars
|
|
|
|
|
+ // const { page, tags } = await pageContainer.save(newMarkdown, this.props.editorMode, optionsToSave);
|
|
|
|
|
+ // logger.debug('success to save');
|
|
|
|
|
+
|
|
|
|
|
+ // pageContainer.showSuccessToastr();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // catch (error) {
|
|
|
|
|
+ // logger.error('failed to save', error);
|
|
|
|
|
+ // pageContainer.showErrorToastr(error);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // finally {
|
|
|
|
|
+ // this.setState({ currentTargetTableArea: null });
|
|
|
|
|
+ // }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
async saveHandlerForDrawioModal(drawioData) {
|
|
async saveHandlerForDrawioModal(drawioData) {
|
|
|
- const {
|
|
|
|
|
- isSlackEnabled, slackChannels, pageContainer, pageTags, grant, grantGroupId, grantGroupName, mutateIsEnabledUnsavedWarning,
|
|
|
|
|
- } = this.props;
|
|
|
|
|
- const optionsToSave = getOptionsToSave(isSlackEnabled, slackChannels, grant, grantGroupId, grantGroupName, pageTags);
|
|
|
|
|
-
|
|
|
|
|
- const newMarkdown = mdu.replaceDrawioInMarkdown(
|
|
|
|
|
- drawioData,
|
|
|
|
|
- this.props.pageContainer.state.markdown,
|
|
|
|
|
- this.state.currentTargetDrawioArea.beginLineNumber,
|
|
|
|
|
- this.state.currentTargetDrawioArea.endLineNumber,
|
|
|
|
|
- );
|
|
|
|
|
-
|
|
|
|
|
- try {
|
|
|
|
|
- // disable unsaved warning
|
|
|
|
|
- mutateIsEnabledUnsavedWarning(false);
|
|
|
|
|
-
|
|
|
|
|
- // eslint-disable-next-line no-unused-vars
|
|
|
|
|
- const { page, tags } = await pageContainer.save(newMarkdown, this.props.editorMode, optionsToSave);
|
|
|
|
|
- logger.debug('success to save');
|
|
|
|
|
-
|
|
|
|
|
- pageContainer.showSuccessToastr();
|
|
|
|
|
- }
|
|
|
|
|
- catch (error) {
|
|
|
|
|
- logger.error('failed to save', error);
|
|
|
|
|
- pageContainer.showErrorToastr(error);
|
|
|
|
|
- }
|
|
|
|
|
- finally {
|
|
|
|
|
- this.setState({ currentTargetDrawioArea: null });
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ // const {
|
|
|
|
|
+ // isSlackEnabled, slackChannels, pageContainer, pageTags, grant, grantGroupId, grantGroupName, mutateIsEnabledUnsavedWarning,
|
|
|
|
|
+ // } = this.props;
|
|
|
|
|
+ // const optionsToSave = getOptionsToSave(isSlackEnabled, slackChannels, grant, grantGroupId, grantGroupName, pageTags);
|
|
|
|
|
+
|
|
|
|
|
+ // const newMarkdown = mdu.replaceDrawioInMarkdown(
|
|
|
|
|
+ // drawioData,
|
|
|
|
|
+ // this.props.pageContainer.state.markdown,
|
|
|
|
|
+ // this.state.currentTargetDrawioArea.beginLineNumber,
|
|
|
|
|
+ // this.state.currentTargetDrawioArea.endLineNumber,
|
|
|
|
|
+ // );
|
|
|
|
|
+
|
|
|
|
|
+ // try {
|
|
|
|
|
+ // // disable unsaved warning
|
|
|
|
|
+ // mutateIsEnabledUnsavedWarning(false);
|
|
|
|
|
+
|
|
|
|
|
+ // // eslint-disable-next-line no-unused-vars
|
|
|
|
|
+ // const { page, tags } = await pageContainer.save(newMarkdown, this.props.editorMode, optionsToSave);
|
|
|
|
|
+ // logger.debug('success to save');
|
|
|
|
|
+
|
|
|
|
|
+ // pageContainer.showSuccessToastr();
|
|
|
|
|
+ // }
|
|
|
|
|
+ // catch (error) {
|
|
|
|
|
+ // logger.error('failed to save', error);
|
|
|
|
|
+ // pageContainer.showErrorToastr(error);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // finally {
|
|
|
|
|
+ // this.setState({ currentTargetDrawioArea: null });
|
|
|
|
|
+ // }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
render() {
|
|
|
const {
|
|
const {
|
|
|
- pageContainer, pagePath, isMobile, isGuestUser,
|
|
|
|
|
|
|
+ rendererOptions, page, isMobile, isGuestUser,
|
|
|
} = this.props;
|
|
} = this.props;
|
|
|
- const { markdown, revisionId } = pageContainer.state;
|
|
|
|
|
|
|
+ const { path } = page;
|
|
|
|
|
+ const { _id: revisionId, body: markdown } = page.revision;
|
|
|
|
|
+
|
|
|
|
|
+ // const DrawioModal = dynamic(() => import('./PageEditor/DrawioModal'), { ssr: false });
|
|
|
|
|
+ // const GridEditModal = dynamic(() => import('./PageEditor/GridEditModal'), { ssr: false });
|
|
|
|
|
+ // const HandsontableModal = dynamic(() => import('./PageEditor/HandsontableModal'), { ssr: false });
|
|
|
|
|
+ // const LinkEditModal = dynamic(() => import('./PageEditor/LinkEditModal'), { ssr: false });
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
<div className={`mb-5 ${isMobile ? 'page-mobile' : ''}`}>
|
|
<div className={`mb-5 ${isMobile ? 'page-mobile' : ''}`}>
|
|
|
|
|
|
|
|
{ revisionId != null && (
|
|
{ revisionId != null && (
|
|
|
- <RevisionRenderer growiRenderer={this.growiRenderer} markdown={markdown} pagePath={pagePath} />
|
|
|
|
|
|
|
+ <RevisionRenderer rendererOptions={rendererOptions} markdown={markdown} pagePath={path} />
|
|
|
)}
|
|
)}
|
|
|
|
|
|
|
|
{ !isGuestUser && (
|
|
{ !isGuestUser && (
|
|
|
<>
|
|
<>
|
|
|
- <GridEditModal ref={this.gridEditModal} />
|
|
|
|
|
- <LinkEditModal ref={this.LinkEditModal} />
|
|
|
|
|
- <HandsontableModal ref={this.handsontableModal} onSave={this.saveHandlerForHandsontableModal} />
|
|
|
|
|
- <DrawioModal ref={this.drawioModal} onSave={this.saveHandlerForDrawioModal} />
|
|
|
|
|
|
|
+ {/* <GridEditModal ref={this.gridEditModal} /> */}
|
|
|
|
|
+ {/* <LinkEditModal ref={this.LinkEditModal} /> */}
|
|
|
|
|
+ {/* <HandsontableModal ref={this.handsontableModal} onSave={this.saveHandlerForHandsontableModal} /> */}
|
|
|
|
|
+ {/* <DrawioModal ref={this.drawioModal} onSave={this.saveHandlerForDrawioModal} /> */}
|
|
|
</>
|
|
</>
|
|
|
)}
|
|
)}
|
|
|
</div>
|
|
</div>
|
|
@@ -166,89 +169,90 @@ class Page extends React.Component {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-Page.propTypes = {
|
|
|
|
|
- // TODO: remove this when omitting unstated is completed
|
|
|
|
|
- appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
|
|
- pageContainer: PropTypes.instanceOf(PageContainer).isRequired,
|
|
|
|
|
- editorContainer: PropTypes.instanceOf(EditorContainer).isRequired,
|
|
|
|
|
|
|
+PageSubstance.propTypes = {
|
|
|
|
|
+ rendererOptions: PropTypes.object.isRequired,
|
|
|
|
|
|
|
|
- pagePath: PropTypes.string.isRequired,
|
|
|
|
|
|
|
+ page: PropTypes.any.isRequired,
|
|
|
pageTags: PropTypes.arrayOf(PropTypes.string),
|
|
pageTags: PropTypes.arrayOf(PropTypes.string),
|
|
|
editorMode: PropTypes.string.isRequired,
|
|
editorMode: PropTypes.string.isRequired,
|
|
|
isGuestUser: PropTypes.bool.isRequired,
|
|
isGuestUser: PropTypes.bool.isRequired,
|
|
|
isMobile: PropTypes.bool,
|
|
isMobile: PropTypes.bool,
|
|
|
isSlackEnabled: PropTypes.bool.isRequired,
|
|
isSlackEnabled: PropTypes.bool.isRequired,
|
|
|
slackChannels: PropTypes.string.isRequired,
|
|
slackChannels: PropTypes.string.isRequired,
|
|
|
- grant: PropTypes.number.isRequired,
|
|
|
|
|
- grantGroupId: PropTypes.string,
|
|
|
|
|
- grantGroupName: PropTypes.string,
|
|
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
-const PageWrapper = (props) => {
|
|
|
|
|
- const { data: currentPagePath } = useCurrentPagePath();
|
|
|
|
|
|
|
+export const Page = (props) => {
|
|
|
|
|
+ const { data: currentPage } = useSWRxCurrentPage();
|
|
|
const { data: editorMode } = useEditorMode();
|
|
const { data: editorMode } = useEditorMode();
|
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
const { data: isGuestUser } = useIsGuestUser();
|
|
|
const { data: isMobile } = useIsMobile();
|
|
const { data: isMobile } = useIsMobile();
|
|
|
- const { data: slackChannelsData } = useSWRxSlackChannels(currentPagePath);
|
|
|
|
|
|
|
+ const { data: slackChannelsData } = useSWRxSlackChannels(currentPage?.path);
|
|
|
const { data: isSlackEnabled } = useIsSlackEnabled();
|
|
const { data: isSlackEnabled } = useIsSlackEnabled();
|
|
|
const { data: pageTags } = usePageTagsForEditors();
|
|
const { data: pageTags } = usePageTagsForEditors();
|
|
|
- const { data: grant } = useSelectedGrant();
|
|
|
|
|
- const { data: grantGroupId } = useSelectedGrantGroupId();
|
|
|
|
|
- const { data: grantGroupName } = useSelectedGrantGroupName();
|
|
|
|
|
|
|
+ const { data: rendererOptions } = useViewOptions();
|
|
|
const { mutate: mutateIsEnabledUnsavedWarning } = useIsEnabledUnsavedWarning();
|
|
const { mutate: mutateIsEnabledUnsavedWarning } = useIsEnabledUnsavedWarning();
|
|
|
|
|
+ const { data: isBlinkedAtBoot, mutate: mutateBlinkedAtBoot } = useIsBlinkedHeaderAtBoot();
|
|
|
|
|
|
|
|
const pageRef = useRef(null);
|
|
const pageRef = useRef(null);
|
|
|
|
|
|
|
|
- // set handler to open DrawioModal
|
|
|
|
|
- useEffect(() => {
|
|
|
|
|
- const handler = (beginLineNumber, endLineNumber) => {
|
|
|
|
|
- if (pageRef?.current != null) {
|
|
|
|
|
- pageRef.current.launchDrawioModal(beginLineNumber, endLineNumber);
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
- window.globalEmitter.on('launchDrawioModal', handler);
|
|
|
|
|
-
|
|
|
|
|
- return function cleanup() {
|
|
|
|
|
- window.globalEmitter.removeListener('launchDrawioModal', handler);
|
|
|
|
|
- };
|
|
|
|
|
- }, []);
|
|
|
|
|
-
|
|
|
|
|
- // set handler to open HandsontableModal
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
- const handler = (beginLineNumber, endLineNumber) => {
|
|
|
|
|
- if (pageRef?.current != null) {
|
|
|
|
|
- pageRef.current.launchHandsontableModal(beginLineNumber, endLineNumber);
|
|
|
|
|
- }
|
|
|
|
|
- };
|
|
|
|
|
- window.globalEmitter.on('launchHandsontableModal', handler);
|
|
|
|
|
-
|
|
|
|
|
- return function cleanup() {
|
|
|
|
|
- window.globalEmitter.removeListener('launchHandsontableModal', handler);
|
|
|
|
|
- };
|
|
|
|
|
- }, []);
|
|
|
|
|
|
|
+ if (isBlinkedAtBoot) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- if (currentPagePath == null || editorMode == null || isGuestUser == null) {
|
|
|
|
|
|
|
+ blinkSectionHeaderAtBoot();
|
|
|
|
|
+ mutateBlinkedAtBoot(true);
|
|
|
|
|
+ }, [mutateBlinkedAtBoot]);
|
|
|
|
|
+
|
|
|
|
|
+ // // set handler to open DrawioModal
|
|
|
|
|
+ // useEffect(() => {
|
|
|
|
|
+ // const handler = (beginLineNumber, endLineNumber) => {
|
|
|
|
|
+ // if (pageRef?.current != null) {
|
|
|
|
|
+ // pageRef.current.launchDrawioModal(beginLineNumber, endLineNumber);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // };
|
|
|
|
|
+ // window.globalEmitter.on('launchDrawioModal', handler);
|
|
|
|
|
+
|
|
|
|
|
+ // return function cleanup() {
|
|
|
|
|
+ // window.globalEmitter.removeListener('launchDrawioModal', handler);
|
|
|
|
|
+ // };
|
|
|
|
|
+ // }, []);
|
|
|
|
|
+
|
|
|
|
|
+ // // set handler to open HandsontableModal
|
|
|
|
|
+ // useEffect(() => {
|
|
|
|
|
+ // const handler = (beginLineNumber, endLineNumber) => {
|
|
|
|
|
+ // if (pageRef?.current != null) {
|
|
|
|
|
+ // pageRef.current.launchHandsontableModal(beginLineNumber, endLineNumber);
|
|
|
|
|
+ // }
|
|
|
|
|
+ // };
|
|
|
|
|
+ // window.globalEmitter.on('launchHandsontableModal', handler);
|
|
|
|
|
+
|
|
|
|
|
+ // return function cleanup() {
|
|
|
|
|
+ // window.globalEmitter.removeListener('launchHandsontableModal', handler);
|
|
|
|
|
+ // };
|
|
|
|
|
+ // }, []);
|
|
|
|
|
+
|
|
|
|
|
+ if (currentPage == null || editorMode == null || isGuestUser == null || rendererOptions == null) {
|
|
|
|
|
+ logger.warn('Some of materials are missing.', {
|
|
|
|
|
+ currentPage: currentPage?._id, editorMode, isGuestUser, rendererOptions,
|
|
|
|
|
+ });
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
return (
|
|
|
- <Page
|
|
|
|
|
|
|
+ <PageSubstance
|
|
|
{...props}
|
|
{...props}
|
|
|
ref={pageRef}
|
|
ref={pageRef}
|
|
|
- pagePath={currentPagePath}
|
|
|
|
|
|
|
+ rendererOptions={rendererOptions}
|
|
|
|
|
+ page={currentPage}
|
|
|
editorMode={editorMode}
|
|
editorMode={editorMode}
|
|
|
isGuestUser={isGuestUser}
|
|
isGuestUser={isGuestUser}
|
|
|
isMobile={isMobile}
|
|
isMobile={isMobile}
|
|
|
isSlackEnabled={isSlackEnabled}
|
|
isSlackEnabled={isSlackEnabled}
|
|
|
pageTags={pageTags}
|
|
pageTags={pageTags}
|
|
|
slackChannels={slackChannelsData.toString()}
|
|
slackChannels={slackChannelsData.toString()}
|
|
|
- grant={grant}
|
|
|
|
|
- grantGroupId={grantGroupId}
|
|
|
|
|
- grantGroupName={grantGroupName}
|
|
|
|
|
mutateIsEnabledUnsavedWarning={mutateIsEnabledUnsavedWarning}
|
|
mutateIsEnabledUnsavedWarning={mutateIsEnabledUnsavedWarning}
|
|
|
/>
|
|
/>
|
|
|
);
|
|
);
|
|
|
};
|
|
};
|
|
|
-
|
|
|
|
|
-export default withUnstatedContainers(PageWrapper, [AppContainer, PageContainer, EditorContainer]);
|
|
|