@aeaton/react-prosemirror
Advanced tools
Comparing version 0.7.1 to 0.7.2
@@ -46,18 +46,5 @@ 'use strict'; | ||
var handle = function handle(cmd) { | ||
return function (e) { | ||
e.preventDefault(); | ||
cmd(state, dispatch); | ||
}; | ||
}; | ||
var Button = function Button(item, key) { | ||
var _classnames; | ||
var disabled = item.enable && !item.enable(state); | ||
// if (item.active && disabled) return null | ||
var active = item.active && item.active(state); | ||
// if (item.active && !active) return null | ||
return React.createElement( | ||
@@ -67,6 +54,9 @@ 'button', | ||
key: key, | ||
className: classnames((_classnames = {}, babelHelpers.defineProperty(_classnames, classes.button, true), babelHelpers.defineProperty(_classnames, classes.active, active), _classnames)), | ||
className: classnames((_classnames = {}, babelHelpers.defineProperty(_classnames, classes.button, true), babelHelpers.defineProperty(_classnames, classes.active, item.active && item.active(state)), _classnames)), | ||
title: item.title, | ||
disabled: disabled, | ||
onMouseDown: handle(item.run) | ||
disabled: item.enable && !item.enable(state), | ||
onMouseDown: function onMouseDown(e) { | ||
e.preventDefault(); | ||
item.run(state, dispatch); | ||
} | ||
}, | ||
@@ -133,3 +123,3 @@ item.content | ||
value: function render() { | ||
var menu = this.props.options.menu; | ||
var menu = this.props.menu; | ||
var state = this.state.state; | ||
@@ -203,3 +193,5 @@ | ||
value: function render() { | ||
var options = this.props.options; | ||
var _props2 = this.props, | ||
options = _props2.options, | ||
menu = _props2.menu; | ||
@@ -209,2 +201,3 @@ | ||
options: options, | ||
menu: menu, | ||
onChange: this.onChange | ||
@@ -211,0 +204,0 @@ }); |
{ | ||
"name": "@aeaton/react-prosemirror", | ||
"version": "0.7.1", | ||
"version": "0.7.2", | ||
"description": "A React component for ProseMirror", | ||
@@ -5,0 +5,0 @@ "main": "dist", |
@@ -15,6 +15,8 @@ ## Installation | ||
This example imports configuration from [@aeaton/react-prosemirror-config-default](https://www.npmjs.com/package/@aeaton/react-prosemirror-config-default). | ||
```js | ||
import React from 'react' | ||
import { HtmlEditor } from '@aeaton/react-prosemirror' | ||
import * as options from '@aeaton/react-prosemirror-config-default' | ||
import { options, menu } from '@aeaton/react-prosemirror-config-default' | ||
@@ -24,2 +26,3 @@ const Editor = ({ value, onChange }) => ( | ||
options={options} | ||
menu={menu} | ||
value={value} | ||
@@ -26,0 +29,0 @@ onChange={onChange} |
@@ -41,3 +41,3 @@ import React from 'react' | ||
render () { | ||
const { options: { menu } } = this.props | ||
const { menu } = this.props | ||
const { state } = this.state | ||
@@ -44,0 +44,0 @@ |
An editor for content stored as ProseMirror JSON. | ||
```js | ||
const options = require('@aeaton/react-prosemirror-config-default') | ||
const { options, menu } = require('@aeaton/react-prosemirror-config-default') | ||
@@ -15,2 +15,3 @@ initialState = { | ||
options={options} | ||
menu={menu} | ||
onChange={doc => setState({ doc })} | ||
@@ -17,0 +18,0 @@ /> |
@@ -43,3 +43,3 @@ import React from 'react' | ||
render () { | ||
const { options } = this.props | ||
const { options, menu } = this.props | ||
@@ -49,2 +49,3 @@ return ( | ||
options={options} | ||
menu={menu} | ||
onChange={this.onChange} | ||
@@ -51,0 +52,0 @@ /> |
@@ -6,3 +6,3 @@ An editor for content stored as HTML. | ||
```js | ||
const options = require('@aeaton/react-prosemirror-config-default') | ||
const { options, menu } = require('@aeaton/react-prosemirror-config-default') | ||
@@ -18,2 +18,3 @@ initialState = { | ||
options={options} | ||
menu={menu} | ||
value={state.value} | ||
@@ -20,0 +21,0 @@ onChange={value => setState({ value })} |
@@ -11,28 +11,18 @@ import React from 'react' | ||
const MenuBar = ({ menu, state, dispatch }) => { | ||
const handle = cmd => e => { | ||
e.preventDefault() | ||
cmd(state, dispatch) | ||
} | ||
const Button = (item, key) => ( | ||
<button | ||
key={key} | ||
className={classnames({ | ||
[classes.button]: true, | ||
[classes.active]: item.active && item.active(state) | ||
})} | ||
title={item.title} | ||
disabled={item.enable && !item.enable(state)} | ||
onMouseDown={e => { | ||
e.preventDefault() | ||
item.run(state, dispatch) | ||
}} | ||
>{item.content}</button> | ||
) | ||
const Button = (item, key) => { | ||
const disabled = item.enable && !item.enable(state) | ||
// if (item.active && disabled) return null | ||
const active = item.active && item.active(state) | ||
// if (item.active && !active) return null | ||
return ( | ||
<button | ||
key={key} | ||
className={classnames({ | ||
[classes.button]: true, | ||
[classes.active]: active | ||
})} | ||
title={item.title} | ||
disabled={disabled} | ||
onMouseDown={handle(item.run)} | ||
>{item.content}</button> | ||
) | ||
} | ||
const keys = Object.keys(menu) | ||
@@ -39,0 +29,0 @@ const limit = keys.length - 1 |
@@ -5,3 +5,3 @@ A React menu bar for a ProseMirror editor | ||
const { EditorState } = require('prosemirror-state') | ||
const options = require('@aeaton/react-prosemirror-config-default') | ||
const { options, menu } = require('@aeaton/react-prosemirror-config-default') | ||
@@ -13,3 +13,3 @@ initialState = { | ||
<MenuBar | ||
menu={options.menu} | ||
menu={menu} | ||
state={state.state} | ||
@@ -16,0 +16,0 @@ dispatch={transaction => { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
34
21936
368