Commit 80e0e8a 1 parent b8d6149 commit 80e0e8a Copy full SHA for 80e0e8a
File tree 3 files changed +25
-31
lines changed
3 files changed +25
-31
lines changed Original file line number Diff line number Diff line change @@ -8,26 +8,12 @@ class TextAreaControl extends Control {
8
8
config : {
9
9
label : i18n . get ( 'controls.form.textarea' ) ,
10
10
} ,
11
- // This is the beginning of actions being supported for render
12
- // editor field actions should be in config.action
13
- // action: {
14
- // mousedown: function(evt) {
15
- // let {target} = evt;
16
- // let startHeight = target.style.height;
17
- // const onMouseup = evt => {
18
- // let {target} = evt;
19
- // let endHeight = target.style.height;
20
- // if (startHeight !== endHeight) {
21
- // //eslint-disable-next-line
22
- // let fieldId = closest(target, '.stage-field').id;
23
- // const field = d.fields.get(fieldId).instance;
24
- // field.addAttribute('style', `height: ${endHeight}`);
25
- // }
26
- // target.removeEventListener('mouseup', onMouseup);
27
- // };
28
- // target.addEventListener('mouseup', onMouseup);
29
- // }
30
- // },
11
+ // actions here will be applied to the preview in the editor
12
+ action : {
13
+ input : function ( { target : { value } } ) {
14
+ this . setData ?. ( 'value' , value )
15
+ } ,
16
+ } ,
31
17
meta : {
32
18
group : 'common' ,
33
19
icon : 'textarea' ,
Original file line number Diff line number Diff line change @@ -12,14 +12,10 @@ import { CONTROL_GROUP_CLASSNAME } from '../../constants.js'
12
12
import Components , { Stages , Rows } from '../index.js'
13
13
14
14
// control configs
15
- import layoutControls from './layout/index.js'
16
- import formControls from './form/index.js'
17
- import htmlControls from './html/index.js'
15
+
18
16
import defaultOptions from './options.js'
19
17
import { get , set } from '../../common/utils/object.mjs'
20
18
21
- const defaultElements = [ ...formControls , ...htmlControls , ...layoutControls ]
22
-
23
19
/**
24
20
*
25
21
*/
@@ -379,7 +375,14 @@ export class Controls {
379
375
this . container = container
380
376
this . groupOrder = unique ( groupOrder . concat ( [ 'common' , 'html' , 'layout' ] ) )
381
377
this . options = options
382
- return Promise . all ( this . registerControls ( [ ...defaultElements , ...elements ] ) )
378
+
379
+ const layoutControls = await import ( './layout/index.js' )
380
+ const formControls = await import ( './form/index.js' )
381
+ const htmlControls = await import ( './html/index.js' )
382
+
383
+ const allControls = [ layoutControls . default , formControls . default , htmlControls . default ] . flat ( )
384
+
385
+ return Promise . all ( this . registerControls ( [ ...allControls , ...elements ] ) )
383
386
}
384
387
}
385
388
Original file line number Diff line number Diff line change @@ -130,13 +130,15 @@ export default class Field extends Component {
130
130
}
131
131
}
132
132
133
+ setData = ( path , value ) => {
134
+ return super . set ( path , value )
135
+ }
136
+
133
137
/**
134
138
* wrapper for Data.set
135
139
*/
136
- set ( ...args ) {
137
- const [ path , value ] = args
138
-
139
- const data = super . set ( path , value )
140
+ set ( path , value ) {
141
+ const data = this . setData ( path , value )
140
142
this . updatePreview ( )
141
143
142
144
return data
@@ -310,7 +312,10 @@ export default class Field extends Component {
310
312
const prevData = clone ( this . data )
311
313
const { action = { } } = controls . get ( prevData . config . controlId )
312
314
prevData . id = `prev-${ this . id } `
313
- prevData . action = action
315
+ prevData . action = Object . entries ( action ) . reduce ( ( acc , [ key , value ] ) => {
316
+ acc [ key ] = value . bind ( this )
317
+ return acc
318
+ } , { } )
314
319
315
320
if ( this . data ?. config . editableContent ) {
316
321
prevData . attrs = { ...prevData . attrs , contenteditable : true }
You can’t perform that action at this time.
0 commit comments