-
Notifications
You must be signed in to change notification settings - Fork 198
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(controls): block elements are not editable in the editor
resolves #161
- Loading branch information
1 parent
b8ce1e7
commit d099763
Showing
7 changed files
with
113 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
# Controls | ||
|
||
![formeo-controls](https://user-images.githubusercontent.com/1457540/56075239-26cbf100-5d74-11e9-8cd0-d4400705365f.png) | ||
|
||
A Control refers to inputs and elements that can be dragged to the stage when editing a form. In their most basic form, they can be a javascript literal object that defines basic information about the element eg. | ||
|
||
```javascript | ||
const inputElement = { | ||
tag: 'input', | ||
attrs: { | ||
required: false, // will render a checkbox in the editor to toggle required attribute | ||
type: 'text', | ||
className: '' // accepts string or array of class names | ||
}, | ||
config: { | ||
label: 'Input', // label that appears in the control side bar | ||
editorLabel: 'My Custom Input' // label that appears in the editor | ||
}, | ||
meta: { | ||
group: 'common', // group id | ||
icon: 'text-input-icon', // needs to be an svg or font icon id | ||
id: 'text-input' // unique that can be used to reference the control | ||
}, | ||
} | ||
``` | ||
|
||
## Control Groups | ||
|
||
Formeo comes with a 3 groups of basic controls. These groups can be disabled, extended, ordered, and more. The default control groups are `form`, `html`, and `layout`. | ||
|
||
### Form Controls | ||
|
||
Form controls are considered controls that users can interact with and at the time of writing Formeo ships with the following `form` controls: | ||
|
||
- button | ||
- checkbox-group | ||
- input | ||
- date | ||
- file | ||
- hidden | ||
- number | ||
- text | ||
- radio-group | ||
- select | ||
- textarea | ||
|
||
### HTML Controls | ||
|
||
HTML Controls are used to render html elements like `<p/>`, `<h1/>` and `<hr/>`. To make a Control's rendered html editable in the editor, set the `editableContent` to `true` when defining your control's `config`. Example: | ||
|
||
```javascript | ||
const paragraph = { | ||
tag: 'p', | ||
config: { | ||
label: 'Paragraph', | ||
editableContent: true | ||
}, | ||
content: | ||
'This content can be edited in the editor' | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Controls Options | ||
|
||
Control options can be used to disable, extend and modify the Formeo's control panel. | ||
|
||
| Option | Type | Description | Example | Default | | ||
| ------------------------- | ------ | --------------------------------------- | -------------------- | ------------------------------ | | ||
| [sortable](#sortable) | String | allow controls to be reordered by users | `true` | `false` | | ||
| [groupOrder](#groupOrder) | Array | allow controls to be reordered by users | `['html', 'layout']` | `['common', 'html', 'layout']` | | ||
|
||
## sortable | ||
|
||
```javascript | ||
const controlOptions = { | ||
sortable: true, | ||
} | ||
|
||
const formeoOptions = { | ||
controls: controlOptions, | ||
} | ||
|
||
const formeo = new FormeoEditor(formeoOptions) | ||
``` | ||
|
||
## groupOrder | ||
|
||
Set the group panel order with `groupOrder` | ||
|
||
```javascript | ||
const controlOptions = { | ||
groupOrder: ['common', 'html'], | ||
} | ||
|
||
const formeoOptions = { | ||
controls: controlOptions, | ||
} | ||
|
||
const formeo = new FormeoEditor(formeoOptions) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ Object { | |
], | ||
}, | ||
], | ||
"config": Object {}, | ||
"id": "test-id", | ||
} | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters