| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /**
- * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
- * For licensing, see LICENSE.md.
- */
- 'use strict';
- import Controller from '../ui/controller.js';
- import Model from '../ui/model.js';
- import utils from '../utils.js';
- import ObservableMixin from '../observablemixin.js';
- /**
- * @memberOf core.editable
- * @extends core.ui.Controller
- * @mixes core.ObservableMixin
- */
- export default class Editable extends Controller {
- /**
- * Creates a new instance of the Editable class.
- *
- * @param editor
- */
- constructor( editor ) {
- super();
- this.editor = editor;
- /**
- * Whether the editable is in read-write or read-only mode.
- *
- * @member {Boolean} core.editable.Editable#isEditable
- */
- this.set( 'isEditable', true );
- /**
- * Whether the editable is focused.
- *
- * @readonly
- * @member {Boolean} core.editable.Editable#isFocused
- */
- this.set( 'isFocused', false );
- }
- /**
- * The model for the editable view.
- *
- * @readonly
- * @type {core.ui.Model}
- */
- get viewModel() {
- if ( this._viewModel ) {
- return this._viewModel;
- }
- const viewModel = new Model( {
- isFocused: this.isFocused
- } );
- this._viewModel = viewModel;
- viewModel.bind( 'isEditable' ).to( this );
- this.bind( 'isFocused' ).to( viewModel );
- return viewModel;
- }
- /**
- * Temporary implementation (waiting for integration with the data model).
- *
- * @param {String} data HTML to be loaded.
- */
- setData( data ) {
- this.view.editableElement.innerHTML = data;
- }
- /**
- * Temporary implementation (waiting for integration with the data model).
- *
- * @returns {String} HTML string.
- */
- getData() {
- return this.view.editableElement.innerHTML;
- }
- }
- utils.mix( Editable, ObservableMixin );
|