Installations
npm install free-editor
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
9.2.1
NPM Version
5.7.1
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
TypeScript (100%)
Developer
cag2050
Download Statistics
Total Downloads
2,081
Last Day
2
Last Week
11
Last Month
102
Last Year
1,333
GitHub Statistics
1 Stars
5 Commits
1 Branches
1 Contributors
Package Meta Information
Latest Version
1.0.1
Package Id
free-editor@1.0.1
Unpacked Size
961.36 kB
Size
444.46 kB
File Count
357
NPM Version
5.7.1
Node Version
9.2.1
Total Downloads
Cumulative downloads
Total Downloads
2,081
Last day
100%
2
Compared to previous day
Last week
-42.1%
11
Compared to previous week
Last month
6.3%
102
Compared to previous month
Last year
670.5%
1,333
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Gaea Editor ·
![code coverage](https://img.shields.io/codecov/c/github/ascoders/gaea-editor/master.svg)
gaea-editor
Help develops build a scalable website visualization builder.
Quick start
1npm i gaea-editor --save
And then, it's easy to use:
1import Editor from 'gaea-editor'; 2 3ReactDOM.render( 4 <div style={{ width: '100vw', height: '100vh' }}> 5 <Editor /> 6 </div>, 7 document.getElementById('react-root') 8);
- 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:
1import BasicComponents from 'gaea-basic-components'; 2<Editor componentClasses={[...BasicComponents, CustomComponent1, CustomComponent2]} />;
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:
1defaultProps = { 2 editSetting: { 3 key: 'my-custom-key', // Unique key. 4 name: 'Custom one', // The name shown in drag menu. 5 isContainer: false, // Can be dragged in. 6 editors: [ 7 { 8 field: 'title', 9 text: 'Text', 10 type: 'string' 11 } 12 ] // Tell gaea-editor, which props can be edited and how to edit it. 13 } 14};
More about editors
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.
1{ 2 type: 'string', 3 text: 'Text', 4 field: 'value' 5}
number
Suitable for any number editing scene.
In many cases, it is suggested that inputRange
and outputRange
be set to the same value.
1{ 2 type: 'number', 3 text: 'Text', 4 field: 'value', 5 data: { 6 useSlider: true, 7 step: 1, 8 inputRange: [0, 100], 9 outputRange: [0, 1] 10 } 11}
boolean
Suitable for any boolean editing scene.
1{ 2 type: 'boolean', 3 text: 'Checked', 4 field: 'value' 5}
select
Suitable for enumable editing scene.
1{ 2 type: 'select', 3 text: 'Text', 4 field: 'value', 5 data: [{ 6 text: 'Default', 7 value: 0 8 }, { 9 text: 'Small', 10 value: 1 11 }, { 12 text: 'Large', 13 value: 2 14 }] 15}
color
Suitable for color picker editing scene.
1{ 2 type: 'color', 3 text: 'Text', 4 field: 'style.backgroundColor', 5}
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.
1{ 2 type: 'display', 3 text: 'Text' 4}
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.
1{ 2 type: 'box-editor', 3 text: 'Text' 4}
array
Super type, allow visualizations to edit a array type props.
1{ 2 type: 'array', 3 text: 'values', 4 data: 'string' 5}
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.
1{ 2 type: 'array', 3 text: 'Options', 4 data: [{ 5 field: "value", 6 type: "string", 7 text: "Value" 8 }, { 9 field: "text", 10 type: "string", 11 text: "Text" 12 }, { 13 field: "disabled", 14 type: "boolean", 15 text: "Disabled" 16 }] 17}
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.
1{ 2 type: 'object', 3 text: 'Text', 4 data: [{ 5 field: "name", 6 type: "string", 7 text: "Name" 8 }, { 9 field: "age", 10 type: "number", 11 text: "Age" 12 }] 13}
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. |
Parameter: onSave
1export function renderGaeaEditor() { 2 return ( 3 <Editor 4 onSave={value => { 5 // send the value data to your server. 6 }} 7 /> 8 ); 9}
Parameter: value
The value
came from onSave
.
1export function renderGaeaEditor() { 2 return <Editor value={value} />; 3}
Parameter: componentClasses
1class MyInput extends React.Component { 2 render() { 3 return <input />; 4 } 5} 6 7export function renderGaeaEditor() { 8 return <Editor componentClasses={[MyInput]} />; 9}
Read more in custom-component-config.
Parameter: plugins
First you should install dob-react
.
1npm i dob-react
1import { Connect } from 'dob-react' 2 3@Connect 4class Plugin extends React.Component { 5 render() { 6 return 'plugin' 7 } 8} 9 10const plugin { 11 position: "mainToolEditorTypeShow", 12 class: ShowEditor 13} 14 15export function renderGaeaEditor() { 16 return ( 17 <Editor plugins={[ Plugin ]}/> 18 ) 19}
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
1git clone https://github.com/ascoders/gaea-editor.git 2cd gaea-editor 3npm i 4npm run docs
Will automatically open the default browser.
Deploy
Step 1, get value by onSave
method in gaea-editor
:
1import Editor from 'gaea-editor'; 2 3ReactDOM.render(<Editor onSave={value => saveToServer(value)} />, document.getElementById('react-root'));
step 2, install gaea-render
, and pass value to it:
1npm i gaea-render
1import Render from 'gaea-render'; 2 3const value = getValueFromServer(); // <Editor onSave={value => // From here. } /> 4 5ReactDOM.render(<Render value={value} />, 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:
1import Editor from 'gaea-editor'; 2import Render from 'gaea-render'; 3 4ReactDOM.render(<Editor componentClasses={myCustomComponents} />, document.getElementById('react-editor')); 5ReactDOM.render(<Render componentClasses={myCustomComponents} />, document.getElementById('react-render'));
Or concat
gaea-basic-components
:
1import Editor from 'gaea-editor'; 2import Render from 'gaea-render'; 3import BasicComponents from 'gaea-basic-components'; 4 5ReactDOM.render( 6 <Editor componentClasses={[...BasicComponents, myCustomComponents]} />, 7 document.getElementById('react-editor') 8); 9ReactDOM.render( 10 <Render componentClasses={[...BasicComponents, myCustomComponents]} />, 11 document.getElementById('react-render') 12);
![Empty State](/_next/static/media/empty.e5fae2e5.png)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
Found 0/5 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
license file not detected
Details
- Warn: project does not have a license file
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Reason
13 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-4xc9-xhrj-v574
- Warn: Project is vulnerable to: GHSA-x5rq-j2xg-h7qm
- Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695
- Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw
- Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9
- Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm
- Warn: Project is vulnerable to: GHSA-8hfj-j24r-96c4
- Warn: Project is vulnerable to: GHSA-wc69-rhjr-hc9g
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-662x-fhqg-9p8v
- Warn: Project is vulnerable to: GHSA-394c-5j6w-4xmx
- Warn: Project is vulnerable to: GHSA-78cj-fxph-m83p
- Warn: Project is vulnerable to: GHSA-fhg7-m89q-25r3
Score
1.3
/10
Last Scanned on 2025-02-03
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to free-editor
@free-transform/editor-vue
This template should help get you started developing with Vue 3 and TypeScript in Vite. The template uses Vue 3 `<script setup>` SFCs, check out the [script setup docs](https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup) to learn more.
swagger-editor-dist
This module, `swagger-editor-dist`, exposes Swagger-Editor's entire dist folder as an almost (see [anonymized analytics](#anonymized-analytics)) dependency-free npm module.
@akilli/editor
A HTML standards-compliant and dependency-free rich text editor
free-slate-editor