easy-richtextarea 4.0.31 → 4.0.33

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
 
@@ -338,22 +332,6 @@ export default class RichTextarea extends Element {
338
332
  }
339
333
  }
340
334
 
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
335
  zKeyDown(event, element) {
358
336
  let preventDefault = false;
359
337
 
@@ -503,8 +481,7 @@ export default class RichTextarea extends Element {
503
481
  }
504
482
 
505
483
  didMount() {
506
- const { onFind, onBlur, onFocus, onScroll, onChange } = this.properties,
507
- findHandler = onFind, ///
484
+ const { onBlur, onFocus, onScroll, onChange } = this.properties,
508
485
  blurHandler = onBlur, ///
509
486
  focusHandler = onFocus, ///
510
487
  scrollHandler = onScroll, ///
@@ -512,8 +489,6 @@ export default class RichTextarea extends Element {
512
489
 
513
490
  this.updateInitialState();
514
491
 
515
- findHandler && this.onFind(findHandler, this);
516
-
517
492
  blurHandler && this.onBlur(blurHandler, this);
518
493
 
519
494
  focusHandler && this.onFocus(focusHandler, this);
@@ -524,15 +499,12 @@ export default class RichTextarea extends Element {
524
499
  }
525
500
 
526
501
  willUnmount() {
527
- const { onFind, onBlur, onFocus, onScroll, onChange } = this.properties,
528
- findHandler = onFind, ///
502
+ const { onBlur, onFocus, onScroll, onChange } = this.properties,
529
503
  blurHandler = onBlur, ///
530
504
  focusHandler = onFocus, ///
531
505
  scrollHandler = onScroll, ///
532
506
  changeHandler = onChange; ///
533
507
 
534
- findHandler && this.offFind(findHandler, this);
535
-
536
508
  blurHandler && this.offBlur(blurHandler, this);
537
509
 
538
510
  focusHandler && this.offFocus(focusHandler, this);
@@ -576,7 +548,6 @@ export default class RichTextarea extends Element {
576
548
  static tagName = "textarea";
577
549
 
578
550
  static ignoredProperties = [
579
- "onFind",
580
551
  "onBlur",
581
552
  "onFocus",
582
553
  "onScroll",
package/src/selection.js CHANGED
@@ -28,6 +28,22 @@ export default class Selection {
28
28
  return length;
29
29
  }
30
30
 
31
+ compareTo(selection) {
32
+ let result = 0;
33
+
34
+ const startPosition = selection.getStartPosition();
35
+
36
+ if (this.startPosition > startPosition) {
37
+ result = +1;
38
+ }
39
+
40
+ if (this.startPosition < startPosition) {
41
+ result = -1;
42
+ }
43
+
44
+ return result;
45
+ }
46
+
31
47
  isEqualTo(selection) {
32
48
  let equalTo = false;
33
49
 
@@ -43,6 +59,14 @@ export default class Selection {
43
59
  return equalTo;
44
60
  }
45
61
 
62
+ isOverlappedBy(selection) {
63
+ const startPosition = selection.getStartPosition(),
64
+ endPosition = selection.getEndPosition(),
65
+ overlappedBy = ((startPosition <= this.endPosition) && (endPosition >= this.startPosition));
66
+
67
+ return overlappedBy;
68
+ }
69
+
46
70
  setStartPosition(startPosition) {
47
71
  this.startPosition = startPosition;
48
72
  }
@@ -90,20 +114,17 @@ export default class Selection {
90
114
  return transformedSelection;
91
115
  }
92
116
 
93
- compareTo(selection) {
94
- let result = 0;
117
+ mergedWith(selection) {
118
+ let startPosition = selection.getStartPosition(),
119
+ endPosition = selection.getEndPosition();
95
120
 
96
- const startPosition = selection.getStartPosition();
121
+ startPosition = Math.min(startPosition, this.startPosition); ///
97
122
 
98
- if (this.startPosition > startPosition) {
99
- result = +1;
100
- }
123
+ endPosition = Math.max(endPosition, this.endPosition); ///
101
124
 
102
- if (this.startPosition < startPosition) {
103
- result = -1;
104
- }
125
+ selection = new Selection(startPosition, endPosition); ///
105
126
 
106
- return result;
127
+ return selection;
107
128
  }
108
129
 
109
130
  emptied() {