Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
LoicMahieu committed Mar 27, 2017
0 parents commit f775c43
Show file tree
Hide file tree
Showing 6 changed files with 166 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"presets": ["es2015", "stage-0", "react"],
"plugins": [
"add-module-exports",
"transform-react-jsx",
]
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
lib
node_modules
.npm
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2017 Loic Mahieu

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
41 changes: 41 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# `<TinyMCEInput>` for admin-on-rest

<TinyMCEInput> component for admin-on-rest, useful for editing HTML in admin GUIs.

Binding of [`<TinyMCE />`](https://github.com/instructure-react/react-tinymce) for [admin-on-rest](https://github.com/marmelab/admin-on-rest).

## Installation

```sh
npm install aor-tinymce-input --save
```

## Usage

```js
import React from 'react'
import {
Edit,
TextInput
} from 'admin-on-rest/mui'

import tinymce from 'tinymce/tinymce'
// react-tinymce use global ref
window.tinymce = tinymce

import 'tinymce/themes/modern/theme'
import 'tinymce/skins/lightgray/skin.min.css'

import TinyMCEInput from 'aor-tinymce-input'

export const PostEdit = (props) => (
<Edit>
<TextInput source="title" />
<TinyMCEInput source="content" config={{ skin: false }} />
</Edit>
)
```

## License

This library is licensed under the [MIT Licence](LICENSE), and sponsored by [iGLOO](https://igloo.be).
47 changes: 47 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "aor-tinymce-input",
"version": "0.0.0",
"description": "<TinyMCEInput /> component for admin-on-rest, useful for editing HTML in admin GUIs",
"main": "lib/index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "NODE_ENV=production babel ./src -d lib"
},
"files": [
"LICENSE",
"*.md",
"lib",
"src"
],
"repository": {
"type": "git",
"url": "git+https://github.com/loicmahieu/aor-tinymce-input.git"
},
"keywords": [
"reactjs",
"react",
"rest",
"html",
"editor",
"tinymce"
],
"author": "Loic Mahieu",
"license": "MIT",
"bugs": {
"url": "https://github.com/loicmahieu/aor-tinymce-input/issues"
},
"homepage": "https://github.com/loicmahieu/aor-tinymce-input#readme",
"devDependencies": {
"babel-cli": "^6.18.0",
"babel-plugin-add-module-exports": "^0.2.1",
"babel-plugin-transform-react-jsx": "^6.8.0",
"babel-preset-es2015": "^6.18.0",
"babel-preset-react": "^6.16.0",
"babel-preset-stage-0": "^6.16.0"
},
"dependencies": {
"react": "~15.4.0",
"react-tinymce": "^0.5.1",
"tinymce": "^4.5.5"
}
}
47 changes: 47 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@

import React, { PropTypes } from 'react'
import TinyMCE from 'react-tinymce'

const TinyMCEInput = ({
id,
disabled,
label,
name,
input: {
value,
onChange
},
config
}) => (
<TinyMCE
id={id}
content={value}
config={{
skin: false,
theme: 'modern',
...config
}}
onChange={e => {
onChange(e.target.getContent())
}}
/>
)

TinyMCEInput.propTypes = {
addField: PropTypes.bool.isRequired,
addLabel: PropTypes.bool.isRequired,
input: PropTypes.object,
label: PropTypes.string,
options: PropTypes.object,
source: PropTypes.string,
config: PropTypes.object
}

TinyMCEInput.defaultProps = {
addField: true,
addLabel: true,
options: {},
record: {}
}

export default TinyMCEInput

0 comments on commit f775c43

Please sign in to comment.