diff options
Diffstat (limited to 'src/client/views/Main.tsx')
-rw-r--r-- | src/client/views/Main.tsx | 99 |
1 files changed, 87 insertions, 12 deletions
diff --git a/src/client/views/Main.tsx b/src/client/views/Main.tsx index 259ffbbc5..8968acbbb 100644 --- a/src/client/views/Main.tsx +++ b/src/client/views/Main.tsx @@ -7,7 +7,6 @@ import * as dotenv from 'dotenv'; // see https://github.com/motdotla/dotenv#how- import * as React from 'react'; import * as ReactDOM from 'react-dom/client'; import { AssignAllExtensions } from '../../extensions/Extensions'; -import { Doc } from '../../fields/Doc'; import { FieldLoader } from '../../fields/FieldLoader'; import { BranchingTrailManager } from '../util/BranchingTrailManager'; import { CurrentUserUtils } from '../util/CurrentUserUtils'; @@ -16,11 +15,49 @@ import { PingManager } from '../util/PingManager'; import { ReplayMovements } from '../util/ReplayMovements'; import { TrackMovements } from '../util/TrackMovements'; import { KeyManager } from './GlobalKeyHandler'; +import { InkingStroke } from './InkingStroke'; import { MainView } from './MainView'; +import { CollectionCalendarView } from './collections/CollectionCalendarView'; +import { CollectionDockingView } from './collections/CollectionDockingView'; import { CollectionView } from './collections/CollectionView'; +import { TabDocView } from './collections/TabDocView'; +import { CollectionFreeFormView } from './collections/collectionFreeForm'; import { CollectionFreeFormInfoUI } from './collections/collectionFreeForm/CollectionFreeFormInfoUI'; +import { CollectionSchemaView } from './collections/collectionSchema/CollectionSchemaView'; +import { SchemaRowBox } from './collections/collectionSchema/SchemaRowBox'; import './global/globalScripts'; +import { AudioBox } from './nodes/AudioBox'; +import { ComparisonBox } from './nodes/ComparisonBox'; +import { DataVizBox } from './nodes/DataVizBox/DataVizBox'; +import { DocumentContentsView, HTMLtag } from './nodes/DocumentContentsView'; +import { EquationBox } from './nodes/EquationBox'; +import { FieldView } from './nodes/FieldView'; +import { FontIconBox } from './nodes/FontIconBox/FontIconBox'; +import { FunctionPlotBox } from './nodes/FunctionPlotBox'; +import { ImageBox } from './nodes/ImageBox'; import { KeyValueBox } from './nodes/KeyValueBox'; +import { LabelBox } from './nodes/LabelBox'; +import { LinkBox } from './nodes/LinkBox'; +import { LoadingBox } from './nodes/LoadingBox'; +import { MapBox } from './nodes/MapBox/MapBox'; +import { MapPushpinBox } from './nodes/MapBox/MapPushpinBox'; +import { PDFBox } from './nodes/PDFBox'; +import { PhysicsSimulationBox } from './nodes/PhysicsBox/PhysicsSimulationBox'; +import { RecordingBox } from './nodes/RecordingBox'; +import { ScreenshotBox } from './nodes/ScreenshotBox'; +import { ScriptingBox } from './nodes/ScriptingBox'; +import { VideoBox } from './nodes/VideoBox'; +import { WebBox } from './nodes/WebBox'; +import { DashDocCommentView } from './nodes/formattedText/DashDocCommentView'; +import { DashDocView } from './nodes/formattedText/DashDocView'; +import { DashFieldView } from './nodes/formattedText/DashFieldView'; +import { EquationView } from './nodes/formattedText/EquationView'; +import { FootnoteView } from './nodes/formattedText/FootnoteView'; +import { FormattedTextBox } from './nodes/formattedText/FormattedTextBox'; +import { SummaryView } from './nodes/formattedText/SummaryView'; +import { ImportElementBox } from './nodes/importBox/ImportElementBox'; +import { PresBox, PresElementBox } from './nodes/trails'; +import { SearchBox } from './search/SearchBox'; dotenv.config(); @@ -36,22 +73,14 @@ FieldLoader.ServerLoadStatus = { requested: 0, retrieved: 0, message: 'cache' }; root.render(<FieldLoader />); window.location.search.includes('safe') && CollectionView.SetSafeMode(true); const info = await CurrentUserUtils.loadCurrentUser(); - // if (info.email === 'guest') DocServer.Control.makeReadOnly(); if (!info.userDocumentId) { alert('Fatal Error: user not found in database'); return; } await CurrentUserUtils.loadUserDocument(info); setTimeout(() => { - document.getElementById('root')!.addEventListener( - 'wheel', - event => { - if (event.ctrlKey) { - event.preventDefault(); - } - }, - true - ); + // prevent zooming browser + document.getElementById('root')!.addEventListener('wheel', event => event.ctrlKey && event.preventDefault(), true); const startload = (document as any).startLoad; const loading = Date.now() - (startload ? Number(startload) : Date.now() - 3000); console.log('Loading Time = ' + loading); @@ -65,10 +94,56 @@ FieldLoader.ServerLoadStatus = { requested: 0, retrieved: 0, message: 'cache' }; new PingManager(); new KeyManager(); - // iniitialize plugin apis + // initialize plugins and classes that require plugins + CollectionDockingView.Init(TabDocView); + FormattedTextBox.Init((tbox: FormattedTextBox) => ({ + dashComment(node: any, view: any, getPos: any) { return new DashDocCommentView(node, view, getPos); }, // prettier-ignore + dashDoc(node: any, view: any, getPos: any) { return new DashDocView(node, view, getPos, tbox); }, // prettier-ignore + dashField(node: any, view: any, getPos: any) { return new DashFieldView(node, view, getPos, tbox); }, // prettier-ignore + equation(node: any, view: any, getPos: any) { return new EquationView(node, view, getPos, tbox); }, // prettier-ignore + summary(node: any, view: any, getPos: any) { return new SummaryView(node, view, getPos); }, // prettier-ignore + footnote(node: any, view: any, getPos: any) { return new FootnoteView(node, view, getPos); }, // prettier-ignore + })); CollectionFreeFormInfoUI.Init(); LinkFollower.Init(); KeyValueBox.Init(); + PresBox.Init(TabDocView.AllTabDocs); + DocumentContentsView.Init(KeyValueBox.LayoutString(), { + FormattedTextBox, + ImageBox, + FontIconBox, + LabelBox, + EquationBox, + FieldView, + CollectionFreeFormView, + CollectionDockingView, + CollectionSchemaView, + CollectionCalendarView, + CollectionView, + WebBox, + KeyValueBox, + PDFBox, + VideoBox, + AudioBox, + RecordingBox, + PresBox, + PresElementBox, + SearchBox, + FunctionPlotBox, + InkingStroke, + LinkBox, + ScriptingBox, + MapBox, + ScreenshotBox, + DataVizBox, + HTMLtag, + ComparisonBox, + LoadingBox, + PhysicsSimulationBox, + SchemaRowBox, + ImportElementBox, + MapPushpinBox, + }); root.render(<MainView />); }, 0); })(); |