Skip to content

Commit 9ef3e12

Browse files
committed
Base Editor setup
1 parent 4329bbf commit 9ef3e12

12 files changed

+51
-250
lines changed

.flowconfig

+2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
[ignore]
22
.*/scripts/.*
33
.*/build/.*
4+
.*/.idea/.*
45
.*/__tests__/.*
56
.*/dist/.*
67
.*/npm/.*
78
.*/.tempUserDataDir/.*
89
.*/node_modules/.*
10+
.*/.storybook/.*
911

1012
[include]
1113
./packages/

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
# production
1414
/build
15+
/dist
1516

1617
# misc
1718
.DS_Store

babel.config.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ module.exports = (api) => {
22
api.cache(true)
33

44
return {
5-
presets: ['@babel/preset-env', '@babel/preset-react'],
5+
presets: ['@babel/preset-env', '@babel/preset-react', '@babel/preset-flow'],
66
plugins: [
77
'@babel/plugin-proposal-object-rest-spread',
88
'@babel/transform-runtime',

package.json

+12-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"description": "Atlas shared component library",
99
"license": "MIT",
1010
"dependencies": {
11-
"@excalidraw/excalidraw": "^0.11.0",
1211
"@fortawesome/fontawesome-svg-core": "^6.1.1",
1312
"@fortawesome/free-brands-svg-icons": "^6.1.1",
1413
"@fortawesome/pro-regular-svg-icons": "^6.1.1",
@@ -35,6 +34,7 @@
3534
"@testing-library/user-event": "^13.5.0",
3635
"babel-plugin-macros": "^3.1.0",
3736
"eslint-config-react-app": "^7.0.1",
37+
"flow-bin": "^0.177.0",
3838
"formik": "^2.2.9",
3939
"katex": "^0.15.3",
4040
"lexical": "^0.2.5",
@@ -56,7 +56,7 @@
5656
],
5757
"scripts": {
5858
"start": "react-scripts start",
59-
"build": "babel src -d dist --extensions \".js,.jsx,.ts,.tsx\" --ignore \"**/*.test.js\" --ignore \"**/*.stories.js\"",
59+
"build": "cross-env BABEL_ENV=production babel src -d dist",
6060
"test": "react-scripts test",
6161
"release": "auto shipit",
6262
"clean": "rm -rf dist",
@@ -128,6 +128,16 @@
128128
"react-bootstrap": "^2.0.0",
129129
"react-dom": "^16.0.0 || ^17.0.0"
130130
},
131+
"babel": {
132+
"presets": [
133+
[
134+
"react-app",
135+
{
136+
"absoluteRuntime": false
137+
}
138+
]
139+
]
140+
},
131141
"husky": {
132142
"hooks": {
133143
"pre-commit": "lint-staged"

src/components/Editor/Editor.stories.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import React from 'react'
22
import {Editor} from './index'
33

44
export default {
5-
title: 'Editor',
5+
title: 'components/Editor',
66
component: Editor,
77
argTypes: {},
88
}

src/components/index.js

+6-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
2-
import * as yup from 'yup'
3-
import * as formik from 'formik'
4-
51
export * from './Button'
62
export * from './ToggleButtonGroup'
73
export * from './Modal'
@@ -25,33 +21,25 @@ export * from './CheckboxGroup'
2521
export * from './RadioGroup'
2622
export * from './Select'
2723
export * from './Toasts'
28-
// export * from './Form';
29-
// export * from './InputGroup';
30-
// export * from './Image';
31-
// export * from './ProgressBar';
32-
// export * from './Spinner';
33-
// export * from './Alert';
24+
export * from './Form';
25+
export * from './InputGroup';
26+
export * from './Image';
27+
export * from './ProgressBar';
28+
export * from './Spinner';
29+
export * from './Alert';
3430

3531
export {
36-
Form,
3732
Row,
3833
Col,
39-
InputGroup,
4034
FormControl,
4135
Dropdown,
4236
DropdownButton,
43-
Image,
4437
Container,
4538
Navbar,
4639
Nav,
4740
NavDropdown,
4841
Popover,
4942
OverlayTrigger,
50-
ProgressBar,
51-
Spinner,
52-
Alert,
5343
ButtonToolbar,
5444
ButtonGroup,
5545
} from 'react-bootstrap'
56-
57-
export { yup, formik }

src/editor/Editor.jsx

+1-3
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,11 @@ import PollPlugin from './plugins/PollPlugin'
3838
import TableCellActionMenuPlugin from './plugins/TableActionMenuPlugin'
3939
import TableCellResizer from './plugins/TableCellResizer'
4040
import ToolbarPlugin from './plugins/ToolbarPlugin'
41-
import TwitterPlugin from './plugins/TwitterPlugin'
4241
import YouTubePlugin from './plugins/YouTubePlugin'
4342
import ContentEditable from './ui/ContentEditable'
4443
import Placeholder from './ui/Placeholder'
4544

46-
export default function Editor(): React$Node {
45+
export default function Editor() {
4746
const {historyState} = useSharedHistoryContext();
4847

4948
const text = 'Write something...';
@@ -85,7 +84,6 @@ export default function Editor(): React$Node {
8584
<ImagesPlugin />
8685
<LinkPlugin />
8786
<PollPlugin />
88-
<TwitterPlugin />
8987
<YouTubePlugin />
9088
<ClickableLinkPlugin />
9189
</>

src/editor/Settings.jsx

-117
This file was deleted.

src/editor/nodes/PlaygroundNodes.js

-6
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,11 @@ import {HeadingNode, QuoteNode} from '@lexical/rich-text'
1919
import {TableCellNode, TableNode, TableRowNode} from '@lexical/table'
2020

2121
import {EmojiNode} from './EmojiNode'
22-
import {EquationNode} from './EquationNode'
23-
import {ExcalidrawNode} from './ExcalidrawNode'
2422
import {ImageNode} from './ImageNode'
2523
import {KeywordNode} from './KeywordNode'
2624
import {MentionNode} from './MentionNode'
2725
import {PollNode} from './PollNode'
2826
import {StickyNode} from './StickyNode'
29-
import {TweetNode} from './TweetNode.jsx'
3027
import {TypeaheadNode} from './TypeaheadNode'
3128
import {YouTubeNode} from './YouTubeNode.jsx'
3229

@@ -49,12 +46,9 @@ const PlaygroundNodes: Array<Class<LexicalNode>> = [
4946
ImageNode,
5047
MentionNode,
5148
EmojiNode,
52-
ExcalidrawNode,
53-
EquationNode,
5449
TypeaheadNode,
5550
KeywordNode,
5651
HorizontalRuleNode,
57-
TweetNode,
5852
YouTubeNode,
5953
];
6054

src/editor/plugins/ToolbarPlugin.jsx

-37
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ import LinkPreview from '../ui/LinkPreview'
7272
import TextInput from '../ui/TextInput'
7373
import {INSERT_EQUATION_COMMAND} from './EquationsPlugin'
7474
import {INSERT_POLL_COMMAND} from './PollPlugin'
75-
import {INSERT_TWEET_COMMAND} from './TwitterPlugin'
7675
import {INSERT_YOUTUBE_COMMAND} from './YouTubePlugin'
7776

7877
const supportedBlockTypes = new Set([
@@ -481,42 +480,6 @@ function InsertPollDialog({
481480
);
482481
}
483482

484-
const VALID_TWITTER_URL = /twitter.com\/[0-9a-zA-Z]{1,20}\/status\/([0-9]*)/g;
485-
486-
function InsertTweetDialog({
487-
activeEditor,
488-
onClose,
489-
}: {
490-
activeEditor: LexicalEditor,
491-
onClose: () => void,
492-
}): React$Node {
493-
const [text, setText] = useState('');
494-
495-
const onClick = () => {
496-
const tweetID = text.split('status/')?.[1]?.split('?')?.[0];
497-
activeEditor.dispatchCommand(INSERT_TWEET_COMMAND, tweetID);
498-
onClose();
499-
};
500-
501-
const isDisabled = text === '' || !text.match(VALID_TWITTER_URL);
502-
503-
return (
504-
<>
505-
<TextInput
506-
label="Tweet URL"
507-
placeholder="i.e. https://twitter.com/jack/status/20"
508-
onChange={setText}
509-
value={text}
510-
/>
511-
<div className="ToolbarPlugin__dialogActions">
512-
<Button disabled={isDisabled} onClick={onClick}>
513-
Confirm
514-
</Button>
515-
</div>
516-
</>
517-
);
518-
}
519-
520483
// Taken from https://stackoverflow.com/a/9102270
521484
const YOUTUBE_ID_PARSER =
522485
/^.*(youtu\.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/;

0 commit comments

Comments
 (0)