easy-richtextarea 4.0.32 → 4.0.34

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.
@@ -12,10 +12,9 @@ import transformSelection from "./transform/selection";
12
12
  import generateOperations from "./operations/generate";
13
13
 
14
14
  import { TEXT, EMPTY_STRING } from "./constants";
15
- import { F_KEY_CODE, Z_KEY_CODE } from "./keyCodes";
15
+ import { Z_KEY_CODE } from "./keyCodes";
16
16
  import { CUT_EVENT_TYPE,
17
17
  COPY_EVENT_TYPE,
18
- FIND_EVENT_TYPE,
19
18
  BLUR_EVENT_TYPE,
20
19
  PASTE_EVENT_TYPE,
21
20
  INPUT_EVENT_TYPE,
@@ -164,11 +163,6 @@ export default class RichTextarea extends Element {
164
163
  case Z_KEY_CODE:
165
164
  preventDefault = this.zKeyDown(event, element);
166
165
 
167
- break;
168
-
169
- case F_KEY_CODE:
170
- preventDefault = this.fKeyDown(event, element);
171
-
172
166
  break;
173
167
  }
174
168
 
@@ -205,20 +199,17 @@ export default class RichTextarea extends Element {
205
199
 
206
200
  const content = this.getContent(),
207
201
  selection = this.getSelection(),
208
- contentChanged = this.hasContentChanged(),
209
- changed = (contentChanged || selectionChanged);
202
+ contentChanged = this.hasContentChanged();
210
203
 
211
- if (changed) {
212
- this.callHandlers(eventType, event, element);
213
- }
204
+ if (contentChanged && undoable) {
205
+ const previousContent = this.getPreviousContent(),
206
+ operations = generateOperations(previousContent, content);
214
207
 
215
- if (undoable) {
216
- if (contentChanged) {
217
- const previousContent = this.getPreviousContent(),
218
- operations = generateOperations(previousContent, content);
208
+ this.undoBuffer.addOperations(operations);
209
+ }
219
210
 
220
- this.undoBuffer.addOperations(operations);
221
- }
211
+ if (contentChanged || selectionChanged) {
212
+ this.callHandlers(eventType, event, element);
222
213
  }
223
214
 
224
215
  const previousContent = content, ///
@@ -338,22 +329,6 @@ export default class RichTextarea extends Element {
338
329
  }
339
330
  }
340
331
 
341
- fKeyDown(event, element) {
342
- let preventDefault = false;
343
-
344
- const { ctrlKey, metaKey } = event;
345
-
346
- if (ctrlKey || metaKey) {
347
- const eventType = FIND_EVENT_TYPE;
348
-
349
- this.callHandlers(eventType, event, element);
350
-
351
- preventDefault = true;
352
- }
353
-
354
- return preventDefault;
355
- }
356
-
357
332
  zKeyDown(event, element) {
358
333
  let preventDefault = false;
359
334
 
@@ -366,7 +341,6 @@ export default class RichTextarea extends Element {
366
341
 
367
342
  if (operation !== null) {
368
343
  const undoable = false,
369
- eventType = CHANGE_EVENT_TYPE,
370
344
  selection = Selection.fromOperation(operation),
371
345
  setPreviousSelection = false;
372
346
 
@@ -374,7 +348,7 @@ export default class RichTextarea extends Element {
374
348
 
375
349
  this.setSelection(selection, setPreviousSelection);
376
350
 
377
- this.intermediateHandler(event, element, undoable, eventType);
351
+ this.intermediateHandler(event, element, undoable);
378
352
  }
379
353
 
380
354
  preventDefault = true;
@@ -404,11 +378,10 @@ export default class RichTextarea extends Element {
404
378
  this.undoBuffer.transform(operations);
405
379
 
406
380
  const event = null,
407
- element = this,
408
- undoable = false,
409
- eventType = CHANGE_EVENT_TYPE;
381
+ element = this, ///
382
+ undoable = false;
410
383
 
411
- this.intermediateHandler(event, element, undoable, eventType);
384
+ this.intermediateHandler(event, element, undoable);
412
385
  }
413
386
 
414
387
  applyOperation(operation) {
@@ -503,8 +476,7 @@ export default class RichTextarea extends Element {
503
476
  }
504
477
 
505
478
  didMount() {
506
- const { onFind, onBlur, onFocus, onScroll, onChange } = this.properties,
507
- findHandler = onFind, ///
479
+ const { onBlur, onFocus, onScroll, onChange } = this.properties,
508
480
  blurHandler = onBlur, ///
509
481
  focusHandler = onFocus, ///
510
482
  scrollHandler = onScroll, ///
@@ -512,8 +484,6 @@ export default class RichTextarea extends Element {
512
484
 
513
485
  this.updateInitialState();
514
486
 
515
- findHandler && this.onFind(findHandler, this);
516
-
517
487
  blurHandler && this.onBlur(blurHandler, this);
518
488
 
519
489
  focusHandler && this.onFocus(focusHandler, this);
@@ -524,15 +494,12 @@ export default class RichTextarea extends Element {
524
494
  }
525
495
 
526
496
  willUnmount() {
527
- const { onFind, onBlur, onFocus, onScroll, onChange } = this.properties,
528
- findHandler = onFind, ///
497
+ const { onBlur, onFocus, onScroll, onChange } = this.properties,
529
498
  blurHandler = onBlur, ///
530
499
  focusHandler = onFocus, ///
531
500
  scrollHandler = onScroll, ///
532
501
  changeHandler = onChange; ///
533
502
 
534
- findHandler && this.offFind(findHandler, this);
535
-
536
503
  blurHandler && this.offBlur(blurHandler, this);
537
504
 
538
505
  focusHandler && this.offFocus(focusHandler, this);
@@ -576,7 +543,6 @@ export default class RichTextarea extends Element {
576
543
  static tagName = "textarea";
577
544
 
578
545
  static ignoredProperties = [
579
- "onFind",
580
546
  "onBlur",
581
547
  "onFocus",
582
548
  "onScroll",