= (props) => {
return (
{availableControls.map(style => {
- if (props.toolbarMode &&
+ if (props.inlineMode &&
(style.type !== "inline" && (style.name !== "link" && style.name !== "clear"))) {
return null
}
@@ -234,8 +245,8 @@ const EditorControls: FunctionComponent = (props) => {
}
return (
- = (props) => {
style={style.style}
type={style.type}
icon={style.icon}
- toolbarMode={props.toolbarMode}
+ component={style.component}
+ inlineMode={props.inlineMode}
disabled={props.disabled}
/>
)
@@ -251,4 +263,4 @@ const EditorControls: FunctionComponent = (props) => {
)
}
-export default EditorControls
\ No newline at end of file
+export default Toolbar
\ No newline at end of file
diff --git a/src/components/ToolbarButton.tsx b/src/components/ToolbarButton.tsx
new file mode 100644
index 0000000..d8e2229
--- /dev/null
+++ b/src/components/ToolbarButton.tsx
@@ -0,0 +1,55 @@
+import React, { FunctionComponent } from 'react'
+import { IconButton } from '@material-ui/core'
+import { TToolbarComponentProps } from './Toolbar'
+
+interface IToolbarButtonProps {
+ id?: string
+ label: string
+ style: string
+ type: string
+ active?: boolean
+ icon?: JSX.Element
+ onClick?: any
+ inlineMode?: boolean
+ disabled?: boolean
+ component?: FunctionComponent
+}
+
+const ToolbarButton: FunctionComponent = (props: IToolbarButtonProps) => {
+ const size = !props.inlineMode ? "medium" : "small"
+ const toolbarId = props.inlineMode ? "-toolbar" : ""
+ const elemId = props.id + toolbarId
+ const sharedProps = {
+ id: elemId,
+ onMouseDown: (e: React.MouseEvent) => {
+ e.preventDefault()
+ if (props.onClick) {
+ props.onClick(props.style, props.type, elemId, props.inlineMode)
+ }
+ },
+ disabled: props.disabled || false
+ }
+ if (props.icon) {
+ return (
+
+ {props.icon}
+
+ )
+ }
+ if (props.component) {
+ return (
+
+ )
+ }
+ return null
+}
+
+export default ToolbarButton
\ No newline at end of file
diff --git a/src/utils.ts b/src/utils.ts
index ac6643a..7209ecd 100644
--- a/src/utils.ts
+++ b/src/utils.ts
@@ -1,7 +1,7 @@
import { EditorState, DraftBlockType, ContentBlock, ContentState,
Modifier, SelectionState } from 'draft-js'
import Immutable from 'immutable'
-import { TCustomControl } from './components/EditorControls'
+import { TCustomControl } from './components/Toolbar'
export type TSelectionInfo = {
inlineStyle: Immutable.OrderedSet,