Skip to content
This repository was archived by the owner on Feb 18, 2024. It is now read-only.

Commit 46b96fe

Browse files
Merge pull request #155 from PrivaNoteTeam/markdown-parsing-and-note-synchronization
Markdown Parsing
2 parents d5108c1 + d8f6e1a commit 46b96fe

File tree

71 files changed

+3015
-1265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+3015
-1265
lines changed

client/package-lock.json

Lines changed: 1827 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/package.json

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@
2424
"@testing-library/react": "^12.1.2",
2525
"@testing-library/react-hooks": "^7.0.2",
2626
"@types/jest": "^27.0.2",
27+
"@types/marked": "^3.0.2",
2728
"@types/mock-fs": "^4.13.1",
28-
"@types/react": "^17.0.24",
29+
"@types/react": "^17.0.33",
30+
"@types/react-router": "^5.1.17",
31+
"@types/react-router-dom": "^5.3.2",
32+
"@types/react-syntax-highlighter": "^13.5.2",
2933
"autoprefixer": "^10.3.5",
3034
"babel-jest": "^27.2.5",
3135
"css-loader": "^6.3.0",
@@ -39,6 +43,7 @@
3943
"mini-css-extract-plugin": "^2.3.0",
4044
"mock-fs": "^5.1.1",
4145
"module-alias": "^2.2.2",
46+
"node-loader": "^2.0.0",
4247
"postcss-cli": "^8.3.1",
4348
"postcss-loader": "^6.1.1",
4449
"prettier": "2.4.1",
@@ -54,20 +59,33 @@
5459
},
5560
"dependencies": {
5661
"@hookform/resolvers": "^2.8.1",
62+
"@monaco-editor/react": "^4.3.1",
5763
"@svgr/webpack": "^5.5.0",
5864
"@tailwindcss/aspect-ratio": "^0.3.0",
5965
"@types/axios": "^0.14.0",
6066
"@types/react-dom": "^17.0.9",
6167
"axios": "^0.23.0",
6268
"babel-core": "^6.26.3",
6369
"babel-preset-react": "^6.24.1",
70+
"chokidar": "^3.5.2",
6471
"google-auth-library": "^7.10.1",
6572
"googleapis": "^89.0.0",
73+
"highlight.js": "^11.3.1",
74+
"html-react-parser": "^1.4.0",
75+
"markdown-to-jsx": "^7.1.3",
76+
"marked": "^3.0.8",
77+
"monaco-editor": "^0.29.1",
6678
"mrm": "^3.0.9",
79+
"node-watch": "^0.7.2",
6780
"nodemailer": "^6.7.0",
6881
"react": "^17.0.2",
82+
"react-collapse-pane": "^2.0.1",
6983
"react-dom": "^17.0.2",
84+
"react-dropzone": "^11.4.2",
7085
"react-hook-form": "^7.16.1",
86+
"react-router": "^5.2.1",
87+
"react-router-dom": "^5.3.0",
88+
"react-syntax-highlighter": "^15.4.4",
7189
"typesafe-actions": "^5.1.0",
7290
"yup": "^0.32.9"
7391
}

client/src/app/App.tsx

Lines changed: 31 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,22 @@ import { SideMenu } from '@components/SideMenu';
99
import { getUser } from '@shared/Api/getUser';
1010
import { useIpcListeners } from './hooks/useIpcListeners';
1111
import { useGoogleDrive } from './hooks/useGoogleDrive';
12+
import { FileExplorer } from './components/FileExplorer';
13+
import { Placeholder } from './components/Placeholder';
14+
import { NotificationArea } from './components/NotificationArea';
15+
import { SplitPane } from 'react-collapse-pane';
1216

1317
export const editorReducer = (state: EditorState, action: EditorAction) => {
1418
switch (action.type) {
1519
case 'primarySelect':
16-
return { ...state, primarySelection: action.primarySelection };
20+
return { ...state, primarySelection: action.primarySelection! };
1721
case 'secondarySelect':
18-
return { ...state, secondarySelection: action.secondarySelection };
19-
case 'rename':
20-
return { ...state, isRenaming: action.isRenaming };
22+
return { ...state, secondarySelection: action.secondarySelection! };
2123
}
2224
};
2325

2426
export function App() {
25-
const [{ currentNote, notebook }] = useStore();
27+
const [{ currentFile, notebook }] = useStore();
2628
const [, userDispatch] = useUserStore();
2729

2830
useIpcListeners();
@@ -32,17 +34,34 @@ export function App() {
3234
getUser().then(({ user }) => {
3335
if (user) userDispatch({ type: 'login', user });
3436
});
35-
}, [currentNote, notebook]);
37+
}, [currentFile, notebook]);
3638

3739
return (
3840
<>
39-
<div className='bg-gray-800 w-screen h-screen flex'>
41+
<div className='bg-gray-800 w-screen h-screen flex relative'>
4042
<SideMenu />
41-
<EditorProvider
42-
initialState={{ isRenaming: false }}
43-
reducer={editorReducer}
44-
>
45-
<EditorPanel />
43+
<EditorProvider initialState={{}} reducer={editorReducer}>
44+
{notebook ? (
45+
<div className='relative flex-grow z-auto'>
46+
<SplitPane
47+
split='vertical'
48+
initialSizes={[1, 5]}
49+
resizerOptions={{
50+
hoverCss: {
51+
backgroundColor: 'rgb(59, 130, 246)'
52+
}
53+
}}
54+
>
55+
<FileExplorer />
56+
<EditorPanel />
57+
</SplitPane>
58+
</div>
59+
) : (
60+
<div className='relative flex-grow flex flex-col'>
61+
<NotificationArea />
62+
<Placeholder text='Open a notebook to continue' />
63+
</div>
64+
)}
4665
</EditorProvider>
4766
<PageManager />
4867
<ModalManager />
Lines changed: 1 addition & 0 deletions
Loading

client/src/app/components/EditorPanel.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,15 @@ import { useEditorPanel } from './editorPanel/useEditorPanel';
33
import { UIEditorPanel } from './editorPanel/UIEditorPanel';
44

55
export function EditorPanel() {
6-
const { fileExplorerVisible } = useEditorPanel();
6+
const { text, setText, handlePreviewClose, livePreviewVisiable } =
7+
useEditorPanel();
78

8-
return <UIEditorPanel fileExplorerVisible={fileExplorerVisible} />;
9+
return (
10+
<UIEditorPanel
11+
livePreviewVisiable={livePreviewVisiable}
12+
text={text}
13+
setText={setText}
14+
handlePreviewClose={handlePreviewClose}
15+
/>
16+
);
917
}
Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
import React from 'react';
2-
import { FileSystemItem } from '@types';
32
import { UIFileExplorer } from './fileExplorer/UIFileExplorer';
4-
53
import { useFileExplorer } from './fileExplorer/useFileExplorer';
64

7-
interface Props {
8-
items: FileSystemItem[];
9-
}
10-
11-
export function FileExplorer({ items }: Props) {
5+
export function FileExplorer() {
126
const {
7+
items,
138
handleAddDirectoryClick,
149
handleAddFileClick,
15-
handleOuterClick,
16-
renameText,
17-
setRenameText
10+
handleOuterClick
1811
} = useFileExplorer();
1912

2013
return (
@@ -23,8 +16,6 @@ export function FileExplorer({ items }: Props) {
2316
handleAddDirectoryClick={handleAddDirectoryClick}
2417
handleAddFileClick={handleAddFileClick}
2518
handleOuterClick={handleOuterClick}
26-
renameText={renameText}
27-
setRenameText={setRenameText}
2819
/>
2920
);
3021
}
Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,45 @@
11
import React from 'react';
2+
import { ipcRenderer } from 'electron';
3+
import { Route, useHistory } from 'react-router';
4+
import { CreateNotebookModal } from './CreateNotebookModal';
25
import { LoginModal } from './modalManager/LoginModal';
36
import { RegisterModal } from './modalManager/RegisterModal';
4-
import { CreateNotebookModal } from './CreateNotebookModal';
5-
import { ipcRenderer } from 'electron';
6-
import { useModalStore } from '../hooks';
7+
import { ResetPasswordModal } from './modalManager/ResetPasswordModal';
78
import { VerificiationModal } from './modalManager/VerificationModal';
89
import { TwoFactorAuthModal } from './modalManager/TwoFactorAuthModal';
910
import { ForgotPasswordModal } from './modalManager/ForgotPasswordModal';
10-
import { ResetPasswordModal } from './modalManager/ResetPasswordModal';
1111

1212
export function ModalManager() {
13-
const [
14-
{
15-
loginModalVisible,
16-
registerModalVisible,
17-
createNotebookModalVisible,
18-
verificationModalVisible,
19-
twoFactorAuthModalVisible,
20-
forgotPasswordModalVisible,
21-
resetPasswordModalVisible
22-
},
23-
modalManagerDispatch
24-
] = useModalStore();
25-
13+
let history = useHistory();
2614
ipcRenderer.on('createNotebook', () => {
27-
modalManagerDispatch({
28-
type: 'createNotebookModal',
29-
createNotebookModalVisible: true
30-
});
15+
history.push('/notebook/create');
3116
});
3217

33-
let render: JSX.Element | null = null;
34-
35-
if (loginModalVisible) {
36-
render = <LoginModal />;
37-
} else if (registerModalVisible) {
38-
render = <RegisterModal />;
39-
} else if (createNotebookModalVisible) {
40-
render = <CreateNotebookModal />;
41-
} else if (verificationModalVisible) {
42-
render = <VerificiationModal />;
43-
} else if (twoFactorAuthModalVisible) {
44-
render = <TwoFactorAuthModal />;
45-
} else if (forgotPasswordModalVisible) {
46-
render = <ForgotPasswordModal />;
47-
} else if (resetPasswordModalVisible) {
48-
render = <ResetPasswordModal />;
49-
}
50-
51-
return render;
18+
return (
19+
<>
20+
<Route
21+
path='/notebook/create'
22+
children={<CreateNotebookModal />}
23+
exact
24+
/>
25+
<Route path='/login' children={<LoginModal />} exact />
26+
<Route path='/register' children={<RegisterModal />} exact />
27+
<Route
28+
path='/forgot-password'
29+
children={<ForgotPasswordModal />}
30+
exact
31+
/>
32+
<Route
33+
path='/reset-password'
34+
children={<ResetPasswordModal />}
35+
exact
36+
/>
37+
<Route
38+
path='/verification'
39+
children={<VerificiationModal />}
40+
exact
41+
/>
42+
<Route path='/2fa' children={<TwoFactorAuthModal />} exact />
43+
</>
44+
);
5245
}
Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import React from 'react';
2-
import { usePageStore } from '@hooks';
32
import { CloudProviderPage } from './pageManager/cloudProviderPage';
43
import { SelectCloudProviderPage } from './pageManager/selectCloudProviderPage';
4+
import { Route } from 'react-router';
55

66
export function PageManager() {
7-
const [{ cloudProviderPageVisible, selectCloudProviderPageVisible }] =
8-
usePageStore();
9-
10-
let render: JSX.Element | null = null;
11-
12-
if (cloudProviderPageVisible) {
13-
render = <CloudProviderPage />;
14-
} else if (selectCloudProviderPageVisible) {
15-
render = <SelectCloudProviderPage />;
16-
}
17-
18-
return render;
7+
return (
8+
<>
9+
<Route path='/cloudprovider' children={<CloudProviderPage />} />
10+
<Route
11+
path='/cloudprovider/select'
12+
children={<SelectCloudProviderPage />}
13+
/>
14+
</>
15+
);
1916
}
File renamed without changes.

client/src/app/components/SideMenu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { useStore } from '@hooks';
77
export function SideMenu() {
88
const [{ notebook }] = useStore();
99
return (
10-
<div className='flex flex-col-reverse bg-gray-700 p-3'>
10+
<div className='flex flex-col-reverse bg-gray-700 p-3 flex-0'>
1111
<div className='space-y-reverse space-y-2 inline-flex flex-col-reverse cursor-pointer'>
1212
{notebook && <SettingsButton />}
1313
<UserButton />

0 commit comments

Comments
 (0)