Ghost/ghost/admin/lib/koenig-editor/addon/components/koenig-card-html.js
Kevin Ansfield 37f393ca27 Koenig - Add caption to HTML/embed card
refs https://github.com/TryGhost/Ghost/issues/9311
- add basic implementation of a caption field to the embed card
2018-02-20 15:53:58 +00:00

44 lines
926 B
JavaScript

import Component from '@ember/component';
import layout from '../templates/components/koenig-card-html';
import {set} from '@ember/object';
export default Component.extend({
layout,
// attrs
payload: null,
isSelected: false,
isEditing: false,
// closure actions
saveCard: null,
init() {
this._super(...arguments);
if (!this.get('payload.html')) {
this.set('payload.html', '');
}
},
actions: {
updateHtml(html) {
this._updatePayloadAttr('html', html);
},
updateCaption(caption) {
this._updatePayloadAttr('caption', caption);
}
},
_updatePayloadAttr(attr, value) {
let payload = this.get('payload');
let save = this.get('saveCard');
set(payload, attr, value);
// update the mobiledoc and stay in edit mode
save(payload, false);
}
});