goodteditor-ui 1.0.101 → 1.0.103

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goodteditor-ui",
3
- "version": "1.0.101",
3
+ "version": "1.0.103",
4
4
  "main": "index.js",
5
5
  "homepage": "https://goodt-ui.netlify.app/",
6
6
  "scripts": {
@@ -102,6 +102,10 @@ export default {
102
102
  classes.push('is-edited');
103
103
  }
104
104
 
105
+ if (this.isValid === false) {
106
+ classes.push('invalid');
107
+ }
108
+
105
109
  return classes;
106
110
  },
107
111
  isValid() {
@@ -163,16 +167,18 @@ export default {
163
167
  * @param {string} value
164
168
  */
165
169
  setValue(value) {
166
- if (value === this.valueLast) {
167
- return;
168
- }
169
170
  this.$el.textContent = value;
170
- this.valueLast = value;
171
- this.$emit('input', value);
172
- this.$emit('change', value);
171
+ if (value !== this.valueLast) {
172
+ this.valueLast = value;
173
+ this.$emit('input', value);
174
+ this.$emit('change', value);
175
+ }
173
176
  },
174
177
  commitValue() {
175
- this.setValue(this.isValid ? this.valueDirty : this.valueLast);
178
+ if (this.isValid === false) {
179
+ this.valueDirty = this.valueLast;
180
+ }
181
+ this.setValue(this.valueDirty);
176
182
  this.setIsEdited(false);
177
183
  },
178
184
  onFocus() {
@@ -195,7 +201,7 @@ export default {
195
201
  * @param {KeyboardEvent} event
196
202
  */
197
203
  onKeyup({ target }) {
198
- this.valueDirty = target.textContent.trim();
204
+ this.valueDirty = target.textContent.replace(/\s+/g, ' ').trim();
199
205
  }
200
206
  }
201
207
  };
@@ -236,6 +242,11 @@ export default {
236
242
 
237
243
  &.is-edited {
238
244
  white-space: pre-line;
245
+
246
+ &.invalid {
247
+ color: var(--color-red);
248
+ outline-color: var(--color-red);
249
+ }
239
250
  }
240
251
  }
241
252
  </style>