File tree Expand file tree Collapse file tree 3 files changed +25
-31
lines changed
Expand file tree Collapse file tree 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 {
88 config : {
99 label : i18n . get ( 'controls.form.textarea' ) ,
1010 } ,
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+ } ,
3117 meta : {
3218 group : 'common' ,
3319 icon : 'textarea' ,
Original file line number Diff line number Diff line change @@ -12,14 +12,10 @@ import { CONTROL_GROUP_CLASSNAME } from '../../constants.js'
1212import Components , { Stages , Rows } from '../index.js'
1313
1414// control configs
15- import layoutControls from './layout/index.js'
16- import formControls from './form/index.js'
17- import htmlControls from './html/index.js'
15+
1816import defaultOptions from './options.js'
1917import { get , set } from '../../common/utils/object.mjs'
2018
21- const defaultElements = [ ...formControls , ...htmlControls , ...layoutControls ]
22-
2319/**
2420 *
2521 */
@@ -379,7 +375,14 @@ export class Controls {
379375 this . container = container
380376 this . groupOrder = unique ( groupOrder . concat ( [ 'common' , 'html' , 'layout' ] ) )
381377 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 ] ) )
383386 }
384387}
385388
Original file line number Diff line number Diff line change @@ -130,13 +130,15 @@ export default class Field extends Component {
130130 }
131131 }
132132
133+ setData = ( path , value ) => {
134+ return super . set ( path , value )
135+ }
136+
133137 /**
134138 * wrapper for Data.set
135139 */
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 )
140142 this . updatePreview ( )
141143
142144 return data
@@ -310,7 +312,10 @@ export default class Field extends Component {
310312 const prevData = clone ( this . data )
311313 const { action = { } } = controls . get ( prevData . config . controlId )
312314 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+ } , { } )
314319
315320 if ( this . data ?. config . editableContent ) {
316321 prevData . attrs = { ...prevData . attrs , contenteditable : true }
You can’t perform that action at this time.
0 commit comments