2 * DO NOT EDIT THIS FILE.
3 * See the following change record for more information,
4 * https://www.drupal.org/node/2815083
8 (function ($, _, Drupal) {
9 Drupal.quickedit.editors.plain_text = Drupal.quickedit.EditorView.extend({
12 initialize: function initialize(options) {
13 Drupal.quickedit.EditorView.prototype.initialize.call(this, options);
15 var editorModel = this.model;
16 var fieldModel = this.fieldModel;
18 var $textElement = void 0;
19 var $fieldItems = this.$el.find('.quickedit-field');
20 if ($fieldItems.length) {
21 $textElement = this.$textElement = $fieldItems.eq(0);
23 $textElement = this.$textElement = this.$el;
25 editorModel.set('originalValue', $.trim(this.$textElement.text()));
27 var previousText = editorModel.get('originalValue');
28 $textElement.on('keyup paste', function (event) {
29 var currentText = $.trim($textElement.text());
30 if (previousText !== currentText) {
31 previousText = currentText;
32 editorModel.set('currentValue', currentText);
33 fieldModel.set('state', 'changed');
37 getEditedElement: function getEditedElement() {
38 return this.$textElement;
40 stateChange: function stateChange(fieldModel, state, options) {
41 var from = fieldModel.previous('state');
48 if (from !== 'inactive') {
49 this.$textElement.removeAttr('contenteditable');
51 if (from === 'invalid') {
52 this.removeValidationErrors();
61 fieldModel.set('state', 'active');
66 this.$textElement.attr('contenteditable', 'true');
73 if (from === 'invalid') {
74 this.removeValidationErrors();
83 this.showValidationErrors();
87 getQuickEditUISettings: function getQuickEditUISettings() {
88 return { padding: true, unifiedToolbar: false, fullWidthToolbar: false, popup: false };
90 revert: function revert() {
91 this.$textElement.html(this.model.get('originalValue'));
94 })(jQuery, _, Drupal);