|
|
@@ -8,12 +8,13 @@ import HeaderSearchBox from './components/HeaderSearchBox';
|
|
|
import SearchPage from './components/SearchPage';
|
|
|
import PageListSearch from './components/PageListSearch';
|
|
|
import PageHistory from './components/PageHistory';
|
|
|
+import PageComments from './components/PageComments';
|
|
|
+import PageCommentFormBehavior from './components/PageCommentFormBehavior';
|
|
|
import PageAttachment from './components/PageAttachment';
|
|
|
import SeenUserList from './components/SeenUserList';
|
|
|
import RevisionPath from './components/Page/RevisionPath';
|
|
|
import RevisionUrl from './components/Page/RevisionUrl';
|
|
|
import BookmarkButton from './components/BookmarkButton';
|
|
|
-//import PageComment from './components/PageComment';
|
|
|
|
|
|
if (!window) {
|
|
|
window = {};
|
|
|
@@ -21,10 +22,14 @@ if (!window) {
|
|
|
|
|
|
const mainContent = document.querySelector('#content-main');
|
|
|
let pageId = null;
|
|
|
+let pageRevisionId = null;
|
|
|
+let pageRevisionCreatedAt = null;
|
|
|
let pagePath;
|
|
|
let pageContent = null;
|
|
|
if (mainContent !== null) {
|
|
|
pageId = mainContent.attributes['data-page-id'].value;
|
|
|
+ pageRevisionId = mainContent.attributes['data-page-revision-id'].value;
|
|
|
+ pageRevisionCreatedAt = +mainContent.attributes['data-page-revision-created'].value;
|
|
|
pagePath = mainContent.attributes['data-path'].value;
|
|
|
const rawText = document.getElementById('raw-text-original');
|
|
|
if (rawText) {
|
|
|
@@ -51,29 +56,42 @@ if (isEnabledPlugins) {
|
|
|
crowiPlugin.installAll(crowi, crowiRenderer);
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * define components
|
|
|
+ * key: id of element
|
|
|
+ * value: React Element
|
|
|
+ */
|
|
|
const componentMappings = {
|
|
|
'search-top': <HeaderSearchBox crowi={crowi} />,
|
|
|
'search-page': <SearchPage crowi={crowi} />,
|
|
|
'page-list-search': <PageListSearch crowi={crowi} />,
|
|
|
+ 'page-comments-list': <PageComments pageId={pageId} revisionId={pageRevisionId} revisionCreatedAt= {pageRevisionCreatedAt} crowi={crowi} />,
|
|
|
'page-attachment': <PageAttachment pageId={pageId} pageContent={pageContent} crowi={crowi} />,
|
|
|
|
|
|
//'revision-history': <PageHistory pageId={pageId} />,
|
|
|
- //'page-comment': <PageComment />,
|
|
|
'seen-user-list': <SeenUserList pageId={pageId} crowi={crowi} />,
|
|
|
'bookmark-button': <BookmarkButton pageId={pageId} crowi={crowi} />,
|
|
|
};
|
|
|
+// additional definitions if pagePath exists
|
|
|
if (pagePath) {
|
|
|
componentMappings['revision-path'] = <RevisionPath pagePath={pagePath} />;
|
|
|
componentMappings['revision-url'] = <RevisionUrl pageId={pageId} pagePath={pagePath} />;
|
|
|
}
|
|
|
|
|
|
+let componentInstances = {};
|
|
|
Object.keys(componentMappings).forEach((key) => {
|
|
|
const elem = document.getElementById(key);
|
|
|
if (elem) {
|
|
|
- ReactDOM.render(componentMappings[key], elem);
|
|
|
+ componentInstances[key] = ReactDOM.render(componentMappings[key], elem);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+// render components with refs to another component
|
|
|
+const elem = document.getElementById('page-comment-form-behavior');
|
|
|
+if (elem) {
|
|
|
+ ReactDOM.render(<PageCommentFormBehavior crowi={crowi} pageComments={componentInstances['page-comments-list']} />, elem);
|
|
|
+}
|
|
|
+
|
|
|
// うわーもうー
|
|
|
$('a[data-toggle="tab"][href="#revision-history"]').on('show.bs.tab', function() {
|
|
|
ReactDOM.render(<PageHistory pageId={pageId} crowi={crowi} />, document.getElementById('revision-history'));
|