-
Notifications
You must be signed in to change notification settings - Fork 198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: textarea value not saved/rendered #390
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,10 @@ import { CONTROL_GROUP_CLASSNAME } from '../../constants.js' | |
import Components, { Stages, Rows } from '../index.js' | ||
|
||
// control configs | ||
import layoutControls from './layout/index.js' | ||
import formControls from './form/index.js' | ||
import htmlControls from './html/index.js' | ||
|
||
import defaultOptions from './options.js' | ||
import { get, set } from '../../common/utils/object.mjs' | ||
|
||
const defaultElements = [...formControls, ...htmlControls, ...layoutControls] | ||
|
||
/** | ||
* | ||
*/ | ||
|
@@ -379,7 +375,14 @@ export class Controls { | |
this.container = container | ||
this.groupOrder = unique(groupOrder.concat(['common', 'html', 'layout'])) | ||
this.options = options | ||
return Promise.all(this.registerControls([...defaultElements, ...elements])) | ||
|
||
const layoutControls = await import('./layout/index.js') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. using dynamic import to prevent circular dependency found when writing tests for controls |
||
const formControls = await import('./form/index.js') | ||
const htmlControls = await import('./html/index.js') | ||
|
||
const allControls = [layoutControls.default, formControls.default, htmlControls.default].flat() | ||
|
||
return Promise.all(this.registerControls([...allControls, ...elements])) | ||
} | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -130,13 +130,15 @@ export default class Field extends Component { | |
} | ||
} | ||
|
||
setData = (path, value) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. shortcut for setting data without updating the preview or edit panels |
||
return super.set(path, value) | ||
} | ||
|
||
/** | ||
* wrapper for Data.set | ||
*/ | ||
set(...args) { | ||
const [path, value] = args | ||
|
||
const data = super.set(path, value) | ||
set(path, value) { | ||
const data = this.setData(path, value) | ||
this.updatePreview() | ||
|
||
return data | ||
|
@@ -310,7 +312,10 @@ export default class Field extends Component { | |
const prevData = clone(this.data) | ||
const { action = {} } = controls.get(prevData.config.controlId) | ||
prevData.id = `prev-${this.id}` | ||
prevData.action = action | ||
prevData.action = Object.entries(action).reduce((acc, [key, value]) => { | ||
acc[key] = value.bind(this) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure about this one but it binds the Field instance so we have access to |
||
return acc | ||
}, {}) | ||
|
||
if (this.data?.config.editableContent) { | ||
prevData.attrs = { ...prevData.attrs, contenteditable: true } | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this
will be the Field instance when called from editor preview