Skip to content

Commit 937bd5b

Browse files
author
Julian Krispel-Samsel
committed
init
0 parents  commit 937bd5b

14 files changed

+8387
-0
lines changed

.gitignore

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# See https://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
6+
# testing
7+
/coverage
8+
9+
# production
10+
/build
11+
12+
# misc
13+
.DS_Store
14+
.env.local
15+
.env.development.local
16+
.env.test.local
17+
.env.production.local
18+
19+
npm-debug.log*
20+
yarn-debug.log*
21+
yarn-error.log*

README.md

+1,901
Large diffs are not rendered by default.

package.json

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "getting-started-with-draft-js-plugins",
3+
"version": "0.1.0",
4+
"private": true,
5+
"dependencies": {
6+
"draft-js-plugins-editor": "^2.0.0-beta1",
7+
"react": "^15.6.1",
8+
"react-dom": "^15.6.1"
9+
},
10+
"devDependencies": {
11+
"react-scripts": "1.0.7"
12+
},
13+
"scripts": {
14+
"start": "react-scripts start",
15+
"build": "react-scripts build",
16+
"test": "react-scripts test --env=jsdom",
17+
"eject": "react-scripts eject"
18+
}
19+
}

public/favicon.ico

24.3 KB
Binary file not shown.

public/index.html

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
6+
<meta name="theme-color" content="#000000">
7+
<!--
8+
manifest.json provides metadata used when your web app is added to the
9+
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
10+
-->
11+
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
12+
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
13+
<!--
14+
Notice the use of %PUBLIC_URL% in the tags above.
15+
It will be replaced with the URL of the `public` folder during the build.
16+
Only files inside the `public` folder can be referenced from the HTML.
17+
18+
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
19+
work correctly both with client-side routing and a non-root public URL.
20+
Learn how to configure a non-root public URL by running `npm run build`.
21+
-->
22+
<title>React App</title>
23+
</head>
24+
<body>
25+
<noscript>
26+
You need to enable JavaScript to run this app.
27+
</noscript>
28+
<div id="root"></div>
29+
<!--
30+
This HTML file is a template.
31+
If you open it directly in the browser, you will see an empty page.
32+
33+
You can add webfonts, meta tags, or analytics to this file.
34+
The build step will place the bundled scripts into the <body> tag.
35+
36+
To begin the development, run `npm start` or `yarn start`.
37+
To create a production bundle, use `npm run build` or `yarn build`.
38+
-->
39+
</body>
40+
</html>

public/manifest.json

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"short_name": "React App",
3+
"name": "Create React App Sample",
4+
"icons": [
5+
{
6+
"src": "favicon.ico",
7+
"sizes": "192x192",
8+
"type": "image/png"
9+
}
10+
],
11+
"start_url": "./index.html",
12+
"display": "standalone",
13+
"theme_color": "#000000",
14+
"background_color": "#ffffff"
15+
}

src/App.css

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
.App {
2+
text-align: center;
3+
}
4+
5+
.App-logo {
6+
animation: App-logo-spin infinite 20s linear;
7+
height: 80px;
8+
}
9+
10+
.App-header {
11+
background-color: #222;
12+
height: 150px;
13+
padding: 20px;
14+
color: white;
15+
}
16+
17+
.App-intro {
18+
font-size: large;
19+
}
20+
21+
@keyframes App-logo-spin {
22+
from { transform: rotate(0deg); }
23+
to { transform: rotate(360deg); }
24+
}

src/App.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React, { Component } from 'react';
2+
import { EditorState } from 'draft-js';
3+
import Editor from 'draft-js-plugins-editor';
4+
5+
class App extends Component {
6+
constructor(props) {
7+
super(props);
8+
this.state = {
9+
editorState: EditorState.createEmpty(),
10+
}
11+
}
12+
13+
onChange = (editorState) => {
14+
this.setState({
15+
editorState,
16+
});
17+
}
18+
19+
render() {
20+
return (
21+
<Editor
22+
editorState={this.state.editorState}
23+
onChange={this.onChange}
24+
/>
25+
);
26+
}
27+
}
28+
29+
export default App;

src/App.test.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import App from './App';
4+
5+
it('renders without crashing', () => {
6+
const div = document.createElement('div');
7+
ReactDOM.render(<App />, div);
8+
});

src/index.css

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
html,body{ height: 100%; }
2+
body {
3+
margin: 0;
4+
font-family: sans-serif;
5+
background: #f0f0f0;
6+
}
7+
8+
.public-DraftEditor-content{
9+
background: #fff;
10+
border: 1px solid #ccc;
11+
border-radius: 5px;
12+
top: 2em;
13+
right: 2em;
14+
position: absolute;
15+
padding: 1em;
16+
left: 2em;
17+
bottom: 2em;
18+
}

src/index.js

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import App from './App';
4+
import registerServiceWorker from './registerServiceWorker';
5+
import './index.css';
6+
7+
ReactDOM.render(<App />, document.getElementById('root'));
8+
registerServiceWorker();

src/logo.svg

+7
Loading

src/registerServiceWorker.js

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// In production, we register a service worker to serve assets from local cache.
2+
3+
// This lets the app load faster on subsequent visits in production, and gives
4+
// it offline capabilities. However, it also means that developers (and users)
5+
// will only see deployed updates on the "N+1" visit to a page, since previously
6+
// cached resources are updated in the background.
7+
8+
// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
9+
// This link also includes instructions on opting out of this behavior.
10+
11+
export default function register() {
12+
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
13+
window.addEventListener('load', () => {
14+
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
15+
navigator.serviceWorker
16+
.register(swUrl)
17+
.then(registration => {
18+
registration.onupdatefound = () => {
19+
const installingWorker = registration.installing;
20+
installingWorker.onstatechange = () => {
21+
if (installingWorker.state === 'installed') {
22+
if (navigator.serviceWorker.controller) {
23+
// At this point, the old content will have been purged and
24+
// the fresh content will have been added to the cache.
25+
// It's the perfect time to display a "New content is
26+
// available; please refresh." message in your web app.
27+
console.log('New content is available; please refresh.');
28+
} else {
29+
// At this point, everything has been precached.
30+
// It's the perfect time to display a
31+
// "Content is cached for offline use." message.
32+
console.log('Content is cached for offline use.');
33+
}
34+
}
35+
};
36+
};
37+
})
38+
.catch(error => {
39+
console.error('Error during service worker registration:', error);
40+
});
41+
});
42+
}
43+
}
44+
45+
export function unregister() {
46+
if ('serviceWorker' in navigator) {
47+
navigator.serviceWorker.ready.then(registration => {
48+
registration.unregister();
49+
});
50+
}
51+
}

0 commit comments

Comments
 (0)