Gaea Editor ·
gaea-editor
Help develops build a scalable website visualization builder.
Requirement
- Node > 8.0
- Typescript 3.0
Quick start
npm i gaea-editor --save
And then, it's easy to use:
; ReactDOM.render div style= Editor / /div, document.getElementById'react-root';
- For vue - gaea-editor-vue, thanks CharlieLau.
Add custom component to the drag menu
You can add any react components to the drag menu, through the following line of code:
;Editor componentClasses= /;
BasicComponents
supportcontainer
,button
,icon
,select
,switch
. And there must be at least one component to setisContainer=true
that can be used as outer container.Generally speaking, with
BasicComponents
concat is ok, because the componentcontainer
BasicComponents
offered is a container.
Add editSetting
to each component props, to let the editor know how to edit it visualizations:
defaultProps =;
editors
More about gaea-editor provides several built-in type editing props. If you need to expand it, you can refer to custom plugin.
common field:
field
: which props to edit. EX:value
visible
style.backgroundColor
.text
: If exist, will appear in the form label to prompt the user.
The following are the built-in types:
string
Suitable for any string editing scene.
number
Suitable for any number editing scene.
In many cases, it is suggested that inputRange
and outputRange
be set to the same value.
boolean
Suitable for any boolean editing scene.
select
Suitable for enumable editing scene.
color
Suitable for color picker editing scene.
display
Suitable for layout editing scene.
Because this type will edit multiple props properties, such as style.display
style.flexDirection
, so don't need to specify the field
field.
box-editor
Suitable for margin-padding editing scene.
Because this type will edit multiple props properties, such as margin
padding
, so don't need to specify the field
field.
array
Super type, allow visualizations to edit a array type props.
You can change string
to boolean
, than it can edit boolean array:
object array
Super type, allow visualizations to edit a array type props.
Each field in data
describes how the key should be edited in the object in array.
Each field in
data
is aeditor
type. You can even nestedarray
orobject
type inside.
object
Super type, allow visualizations to edit a object type props.
Each field in data
describes how the key should be edited in this object.
Each field in
data
is aeditor
type. You can even nestedarray
orobject
type inside.
Options
You can add custom components, custom plugins, save callback, and read saved data.
Props | Type | Description |
---|---|---|
onSave | (info?: string) => void |
When you click the Save button, feed back to you to save the information |
defaultValue | object |
Editor initial value, you can pass the value of the onSave callback and resume the draft |
componentClasses | Array<React.ComponentClass<IGaeaProps>> |
React classes. Any react component is supported, but you need some configuration information to tell the editor how to edit it. see custom-component-config |
plugins | IPlugin[] |
Advanced usage for custom editor functionality. |
locale | string | zh or cn |
ViewportRender | React.ReactElement<any> | You can rewrite viewport element. |
disableBuiltInPlugin | string[] | Disable built in plugins. |
preComponents | Array<{ gaeaKey: string; components: IPreComponent[]; }> | See docs/basic.tsx |
value | object |
Editor initial value, you can pass the value of the onSave (use this.setState chanage its value) |
onSave
Parameter:
defaultValue
Parameter: The defaultValue
came from onSave
.
componentClasses
Parameter:
Read more in custom-component-config.
plugins
Parameter: First you should install dob-react
.
npm i dob-react
position: "mainToolEditorTypeShow", class: ShowEditor}
What is position
? What can i do with plugin? See more in custom-plugin
Communication
Talk to us about gaea-editor using DingDing.
Local development run
git clone https://github.com/ascoders/gaea-editor.gitcd gaea-editornpm inpm run docs
Will automatically open the default browser.
Deploy
Step 1, get value by onSave
method in gaea-editor
:
; ReactDOM.render, document.getElementById'react-root';
step 2, install gaea-render
, and pass value to it:
npm i gaea-render
; ; // <Editor onSave={value => // From here. } /> ReactDOM.render, document.getElementById'react-root';
Custom component
By default, both gaea-editor
and gaea-render
using gaea-basic-components
. You can overwrite it by these code:
;; ReactDOM.render, document.getElementById'react-editor';ReactDOM.render, document.getElementById'react-render';
Or concat
gaea-basic-components
:
;;; ReactDOM.render , document.getElementById'react-editor';ReactDOM.render , document.getElementById'react-render';