3.0.4 • Published 8 years ago

apeman-react-builder v3.0.4

Weekly downloads
2
License
MIT
Repository
github
Last release
8 years ago

apeman-react-builder

Build Status Code Climate Code Coverage npm Version JS Standard

apeman react package for builder components.

Installation

$ npm install apeman-react-builder --save

Demo

Live demo is hosted on GitHub Pages.

Usage

'use strict'

import React from 'react'
import {ApBuilder, ApBuilderStyle} from 'apeman-react-builder'
import {ApTabStyle} from 'apeman-react-tab'
import {ApFrameStyle} from 'apeman-react-frame'

const color = '#38E'
const ExampleComponent = React.createClass({
  getInitialState () {
    return {
      html: `
<html><body><!-- ** --></body></html>
`,
      script: `
console.log('hoge', window.foo)
/* ... */
`,
      globals: {
        foo: 'This is foo!!'
      }
    }
  },

  render () {
    const s = this
    let { state } = s
    return (
      <div>
        <ApBuilderStyle highlightColor={ color }/>
        <ApTabStyle highlightColor={ color }/>
        <ApButtonStyle highlightColor={ color }/>
        <ApFrameStyle highlightColor={ color }/>
        <ApBuilderStyle highlightColor={ color }/>
        <ApBuilder html={ state.html }
                   script={ state.script }
                   compile={ (script) => { /* ... */ return script } }
                   globals={ state.globals }/>
      </div>
    )
  }
})

Components

ApBuilderEditor

Props

NameTypeDefaultDescription
onChangefuncHandle for change
onCancelfuncHandle for cancel
onSubmitfuncHandle for submit
labelsobject{

cancel: 'Cancel', submit: 'Submit' } | | Label texts | | src | string | | | Editting source | | mode | string | | | Editting type | | error | string|object | | | Error message | | spinning | bool | | | Show spinner | | actions | array | [] | | Custom actions |

ApBuilderFrame

Props

NameTypeDefaultDescription
srcstringSource string
onLoadfuncHandler for load event
onScriptErrorfuncHandler for script error
globalsobject{}Global variables inside iframe
scriptstringScript to execute when loaded
compilefunc(script) => scriptCompile script before executing
vrnumberVersion number
id`ap-builder-frame-${uuid.v4()}`

ApBuilderStyle

Props

NameTypeDefaultDescription
styleobject{}
highlightColorstringApStyle.DEFAULT_HIGHLIGHT_COLOR
backgroundColorApStyle.DEFAULT_BACKGROUND_COLOR

ApBuilder

Props

NameTypeDefaultDescription
htmlstring''Html contents
scriptstring''Script text
globalsobjectGlobal variables
compilefuncCompile script before executing
onHtmlEditfunc() => undefinedHandle html edit
onScriptEditfunc() => undefinedHandle script edit
onScriptErrorfuncHandle script error
labelsobject{

htmlTab: 'HTML', scriptTab: 'Script' } | | Labels | | errors | object | | | Errors | | htmlMode | string | 'htmlmixed' | | Codemirror mode for html | | scriptMode | string | 'javascript' | | Codemirror mode for script | | htmlActions | array | | | Custom actions for html editor | | scriptActions | array | | | Custom actions for script editor | | isSupported | func | function() { return /Chrome/.test(navigator.userAgent) } | | Check if supported |

License

This software is released under the MIT License.

Links

3.0.4

8 years ago

3.0.3

8 years ago

3.0.2

8 years ago

3.0.1

8 years ago

3.0.0

8 years ago

2.0.0

8 years ago

1.2.12

8 years ago

1.2.11

8 years ago

1.2.10

8 years ago

1.2.9

8 years ago

1.2.8

8 years ago

1.2.7

8 years ago

1.2.6

8 years ago

1.2.5

8 years ago

1.2.4

8 years ago

1.2.3

8 years ago

1.2.2

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.13

8 years ago

1.1.12

8 years ago

1.1.10

8 years ago

1.1.8

8 years ago

1.1.7

8 years ago

1.1.6

8 years ago

1.1.5

8 years ago

1.1.4

8 years ago

1.1.3

8 years ago

1.1.2

8 years ago

1.1.1

8 years ago

1.1.0

8 years ago

1.0.7

8 years ago

1.0.6

8 years ago

1.0.5

8 years ago

1.0.4

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.0

8 years ago