import controller from './contenteditable.controller';

/**
 * An attribute directive that shims contenteditable elements so they can be
 * used with ng-model and ng-change.  Based on the implementation described
 * here: https://docs.angularjs.org/api/ng/type/ngModel.NgModelController#custom-control-example,
 * but ES6-ified, simplified, and with a mem leak fix.
 */
const WsContentEditableDirective = () => ({
  restrict: 'A',
  require: {
    ngModelCtrl: 'ngModel',
  },
  controller,
  bindToController: true,
});

export default WsContentEditableDirective;
