Skip to content

Commit

Permalink
Merge 45e2919 into b946351
Browse files Browse the repository at this point in the history
  • Loading branch information
Himenon authored Oct 15, 2018
2 parents b946351 + 45e2919 commit dda23a2
Show file tree
Hide file tree
Showing 8 changed files with 424 additions and 5 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,12 @@
"cookie-parser": "^1.4.3",
"express": "^4.16.4",
"express-session": "^1.15.6",
"mdast-util-to-hast": "^3.0.2",
"portfinder": "^1.0.17",
"react": "^16.5.2",
"react-dom": "^16.5.2",
"remark": "^9.0.0",
"remark-react": "^4.0.3",
"styled-components": "^3.4.10"
}
}
9 changes: 9 additions & 0 deletions src/remark-react/__tests__/oneshot.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import * as React from 'react';
import * as OneShot from '../oneshot';


test('React.MyComponent', () => {
const comp = React.createElement(OneShot.App);
expect(comp).toEqual(<OneShot.App />);
});

37 changes: 37 additions & 0 deletions src/remark-react/oneshot.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import * as React from "react";
import * as remark from "remark";
import reactRenderer from "remark-react";

export interface AppState {
text: string;
}

export class App extends React.Component<{}, AppState> {
constructor(props: {}) {
super(props);
this.state = {
text: "# hello world"
};
}

onChange(e: React.ChangeEvent<HTMLTextAreaElement>): void {
this.setState({ text: e.target.value });
}

render() {
return (
<div>
<textarea value={this.state.text} onChange={this.onChange} />
<div id="preview">
{
// @ts-ignore
remark()
.use(reactRenderer)
.processSync(this.state.text).contents
}
</div>
</div>
);
}
}

6 changes: 6 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@
"section-matter": [
"./typings/section-matter/index.d.ts"
],
"remark": [
"./typings/remark/index.d.ts"
],
"remark-react": [
"./typings/remark-react/index.d.ts"
],
"section-matter*": [
"./typings/section-matter*"
]
Expand Down
5 changes: 5 additions & 0 deletions typings/mdast-util-to-hast/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export interface Options {
allowDangerousHTML: boolean
commonmark: boolean
handlers: Object
}
12 changes: 12 additions & 0 deletions typings/remark-react/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as React from 'react';

export interface Options {
createElement?: Function
sanitize?: boolean
toHast?: {}
remarkReactComponents?: {}
}

declare function remarkReact(options: Options): any;

export default remarkReact;
7 changes: 7 additions & 0 deletions typings/remark/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface Parser {}
interface Options {}


declare function parse(options: Options): Parser;

export default parse;
Loading

0 comments on commit dda23a2

Please sign in to comment.