Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] Migrate to React #91

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
cfaec8b
Start migrating to React
ryanscottaudio Apr 11, 2017
1b00a01
Merge
ryanscottaudio Apr 12, 2017
c9eca4c
Switch more components to React
ryanscottaudio Apr 12, 2017
ed50734
add proptypes
ryanscottaudio Apr 12, 2017
3b90046
Some linting
ryanscottaudio Apr 12, 2017
97131ef
return undefined
ryanscottaudio Apr 13, 2017
9b50886
Update travis to node 6
ryanscottaudio Apr 13, 2017
0f820b2
Install react-test-renderer
ryanscottaudio Apr 13, 2017
0797393
camelCase contentEditable
ryanscottaudio Apr 13, 2017
e608959
Move more to react
ryanscottaudio Apr 19, 2017
14869d4
Move outer code to flow
ryanscottaudio Apr 24, 2017
caf1cb4
Lint/flow
ryanscottaudio Apr 25, 2017
8ac3a99
Add spread operator plugin
ryanscottaudio Apr 25, 2017
9cef906
Switch back to old test command
ryanscottaudio Apr 25, 2017
41bfea4
Add example back in
ryanscottaudio Apr 25, 2017
1679d41
Fix calling class as function issue
ryanscottaudio Apr 25, 2017
4d619f3
Lint
ryanscottaudio Apr 25, 2017
6b3f1c6
Avoid using delegateTarget which is unique to ddeku
ryanscottaudio Apr 25, 2017
4a705ab
Fix fsF
ryanscottaudio Apr 25, 2017
aa7791b
Start trying to use jsdom in tests since enzyme's iframes never call …
ryanscottaudio Apr 25, 2017
8de740c
Use jsdom 9
ryanscottaudio Apr 25, 2017
852c1de
Remove jsdom; react-dom can render fine without it
ryanscottaudio Apr 25, 2017
8c321c0
Add faucet back in
ryanscottaudio Apr 25, 2017
bedeb18
Fix instagram fixture
ryanscottaudio Apr 25, 2017
b92be99
Fix more tests
ryanscottaudio Apr 25, 2017
58e2832
Break out stripper function
ryanscottaudio Apr 25, 2017
65c6496
Pipe browser tests to faucet (needed for tests to fail correctly in t…
ellell Apr 26, 2017
6348248
Fix expected iframe allowfullscren value
ellell Apr 26, 2017
0713603
Bubble mouseup event in test
ellell Apr 26, 2017
0a8aaea
move event callbacks outside of render, can use ref instead of delega…
ellell Apr 26, 2017
dd0278c
Fix for mouseup event not firing on child elements of <article>
ellell Apr 26, 2017
b373235
Fix typo in test
ellell Apr 26, 2017
505d5ed
Fix cut/paste update
ellell Apr 26, 2017
19a7c05
cleanup before rendering app in new test
ellell Apr 26, 2017
6505a7f
Fix setting selection in test (was incorrect because of react comment…
ellell Apr 26, 2017
d6eb887
Fix custom keydown, need persist to get access to .metaKey for example
ellell Apr 26, 2017
3d7c1e6
Fix node test command
ellell Apr 26, 2017
abafdd5
Fix lint/flow
ellell Apr 26, 2017
b164102
Fix error where articleElm is null
ellell Apr 26, 2017
cd07848
Only render when props have changed
ellell Apr 26, 2017
3e955bb
Strip react before diffing innerhtml
ryanscottaudio Apr 26, 2017
9261dcc
Update readme
ryanscottaudio Apr 26, 2017
8c52475
Use string replacement to strip react tags
ryanscottaudio Apr 26, 2017
1febc68
remove removal of react root for faster diffing
ryanscottaudio Apr 26, 2017
8ac6290
Dont check items against each other because they're arrays
ryanscottaudio Apr 26, 2017
26d3ed4
Add deep check back in
ryanscottaudio Apr 27, 2017
0d8d0c8
remove deepequal
ryanscottaudio Apr 27, 2017
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
{
"plugins": [
["transform-react-jsx", { "pragma": "element" }]
],
"presets": ["es2015"]
"plugins": ["transform-object-assign"],
"presets": ["es2015", "react"]
}
8 changes: 8 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[ignore]
<PROJECT_ROOT>/node_modules/*

[include]

[libs]

[options]
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ language: node_js
sudo: required
dist: trusty
node_js:
- '4'
- '6'
cache:
directories:
- $HOME/.npm
Expand Down
93 changes: 23 additions & 70 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,70 +1,13 @@
# article-json-to-contenteditable
# article-json-to-contenteditable [![Build Status](https://travis-ci.org/micnews/article-json-to-contenteditable.png?branch=master)](https://travis-ci.org/micnews/article-json-to-contenteditable)


## Installation

Download node at [nodejs.org](http://nodejs.org) and install it, if you haven't already.
## Installation

```sh
npm install article-json-to-contenteditable --save
```
## Example
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you move the example/client.js file to the root and name it example.js I think it will be included in the readme automatically. Might be nice, wdyt?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

definitely!

```js
import {render, tree} from 'deku';
import setupArticle from '../lib';
import element from 'magic-virtual-element';

const Article = setupArticle();
const container = document.querySelector('#editor');

const items = [
{
type: 'paragraph',
children: [{
type: 'text',
content: 'Text text text',
href: null,
italic: false,
bold: false,
mark: false,
markClass: null
}]
}, {
type: 'embed',
embedType: 'facebook',
url: 'https://www.facebook.com/david.bjorklund/posts/10153809692501070',
embedAs: 'post',
date: 'Thursday, January 21, 2016',
user: 'David Pop Hipsterson',
text: [{
content: 'Hey!So, for the last few weeks I\'ve worked on http://mic.com/ - the new home for mic.com (on desktop) - please take a look :)',
href: null
}]
}
];

const getCustomKeyDown = (e) => {
// Return method(s) to handle any keydown events you want custom
// handling for, like undo/redo etc.
const zKeyCode = 90;
if (e.metaKey && e.keyCode === zKeyCode) {
return function handleUndoRedo () {
console.log('should undo/redo');
};
}
};

const onUpdate = ({items, selectionBoundingClientRect, activeItem}) => {
console.log('in client.js onUpdate');
console.log('selectionBoundingClientRect:', selectionBoundingClientRect);
console.log('activeItem:', activeItem);
app.mount(<Article items={items} onUpdate={onUpdate} getCustomKeyDown={getCustomKeyDown} />);
};

const app = tree(<Article items={items} onUpdate={onUpdate} getCustomKeyDown={getCustomKeyDown} />);

render(app, container);

```

## Tests

Expand All @@ -75,37 +18,47 @@ npm test

## Dependencies

- [article-json-html-render](https://github.com/micnews/article-json-html-render): Base for html-based article-json renderer, such as [article-json-to-amp](https://www.npmjs.com/package/article-json-to-amp)
- [deku](https://github.com/dekujs/deku): Create view components using a virtual DOM
- [article-json-react-render](https://github.com/micnews/article-json-react-render): Render article json as react components
- [dift](https://github.com/ashaffer/dift): Super fast list diff algorithm
- [embeds](https://github.com/micnews/embeds): Parse &amp; render embeds
- [get-selection-range-from-elm](https://github.com/micnews/get-selection-range-from-elm): window.getSelection().rangeAt(0) but only if it exists &amp; is within an element
- [html-to-article-json](https://github.com/micnews/html-to-article-json): Converting HTML to article-json
- [immutable-array-methods](https://github.com/micnews/immutable-array-methods): Immutable versions of normally mutable array methods, such as pop(), push(), splice()
- [immutable-object-methods](https://github.com/micnews/immutable-object-methods): Update normal plain javascript object, immutable style. Simlar to how immutable.js, seamless-immutable etc does it but a lot smaller and simpler.
- [is-image](https://github.com/sindresorhus/is-image): Check if a filepath is an image
- [is-url](https://github.com/segmentio/is-url): Check whether a string is a URL.
- [keycode](https://github.com/timoxley/keycode): Convert between keyboard keycodes and keynames and vice versa.
- [magic-virtual-element](https://github.com/dekujs/magic-virtual-element): Build virtual tree elements with magic attributes
- [morphdom](https://github.com/patrick-steele-idem/morphdom): Morph a DOM tree to another DOM tree (no virtual DOM needed)
- [react](https://github.com/facebook/react): React is a JavaScript library for building user interfaces.
- [react-dom](https://github.com/facebook/react): React package for working with the DOM.
- [save-selection](https://github.com/micnews/save-selection): Save &amp; restore selections in a document, using `&lt;mark&gt;` elements

## Dev Dependencies

- [babel-cli](https://github.com/babel/babel/tree/master/packages): Babel command line.
- [babel-plugin-transform-react-jsx](https://github.com/babel/babel/tree/master/packages): Turn JSX into React function calls
- [babel-plugin-transform-object-assign](https://github.com/babel/babel/tree/master/packages): Replace Object.assign with an inline helper
- [babel-preset-es2015](https://github.com/babel/babel/tree/master/packages): Babel preset for all es2015 plugins.
- [babel-preset-react](https://github.com/babel/babel/tree/master/packages): Babel preset for all React plugins.
- [babel-tape-runner](https://github.com/wavded/babel-tape-runner): Babel + Tape for running your ES Next tests
- [babel-watch](https://github.com/kmagiera/babel-watch): Reload your babel-node app on JS source file changes. And do it *fast*.
- [babelify](https://github.com/babel/babelify): Babel browserify transform
- [beefy](https://github.com/chrisdickinson/beefy): local development server that aims to make using browserify fast and fun
- [brfs](https://github.com/substack/brfs): browserify fs.readFileSync() static asset inliner
- [browserify](https://github.com/substack/node-browserify): browser-side require() the node way
- [create-event](https://github.com/kenany/create-event): Create an event object
- [electron-prebuilt](https://github.com/electron-userland/electron-prebuilt): Install electron prebuilt binaries for the command-line use using npm
- [devtool](https://github.com/Jam3/devtool): runs Node.js programs through Chromium DevTools
- [enzyme](https://github.com/airbnb/enzyme): JavaScript Testing utilities for React
- [faucet](https://github.com/substack/faucet): human-readable TAP summarizer
- [semistandard-deku](https://github.com/micnews/semistandard-deku): All the goodness of `feross/standard` with semicolons sprinkled on top. Adapted for deku
- [flow-bin](https://github.com/flowtype/flow-bin): Binary wrapper for Flow - A static type checker for JavaScript
- [miclint](https://github.com/micnews/miclint): Mic lint CLI
- [package-json-to-readme](https://github.com/zeke/package-json-to-readme): Generate a README.md from package.json contents
- [pretty](https://github.com/jonschlinkert/pretty): Some tweaks for beautifying HTML with js-beautify according to my preferences.
- [react-addons-test-utils](https://github.com/facebook/react): This package provides the React TestUtils add-on.
- [react-test-renderer](https://github.com/facebook/react): React package for snapshot testing.
- [snazzy](https://github.com/feross/snazzy): Format JavaScript Standard Style as Stylish (i.e. snazzy) output
- [tape](https://github.com/substack/tape): tap-producing test harness for node and browsers
- [tape-catch](https://github.com/michaelrhodes/tape-catch): a wrapper around tape that catches and reports exceptions
- [testron](https://github.com/shama/testron): CI your client side tests with Electron


## License

MIT

_Generated by [package-json-to-readme](https://github.com/zeke/package-json-to-readme)_
Loading