mirror of https://github.com/artf/grapesjs.git
3 changed files with 45 additions and 0 deletions
@ -0,0 +1,19 @@ |
|||||
|
import { toLowerCase } from '../../utils/mixins'; |
||||
|
import Component from './Component'; |
||||
|
|
||||
|
export const type = 'data-variable'; |
||||
|
|
||||
|
export default class ComponentDataVariable extends Component { |
||||
|
get defaults() { |
||||
|
return { |
||||
|
// @ts-ignore
|
||||
|
...super.defaults, |
||||
|
type, |
||||
|
source: '', |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
static isComponent(el: HTMLElement) { |
||||
|
return toLowerCase(el.tagName) === type; |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,19 @@ |
|||||
|
import ComponentDataVariable from '../model/ComponentDataVariable'; |
||||
|
import ComponentView from './ComponentView'; |
||||
|
|
||||
|
export default class ComponentDataVariableView extends ComponentView<ComponentDataVariable> { |
||||
|
initialize(opt = {}) { |
||||
|
super.initialize(opt); |
||||
|
const { model, em } = this; |
||||
|
const { key } = model.attributes; |
||||
|
this.listenTo(em, key, () => this.postRender()); |
||||
|
} |
||||
|
|
||||
|
postRender() { |
||||
|
const { key, default: def } = this.model.attributes; |
||||
|
// this.el.innerHTML = getValue(key, def);
|
||||
|
this.el.innerHTML = def; |
||||
|
console.log('this.el.innerHTML', { key, def }); |
||||
|
super.postRender(); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue