easy-richtextarea 4.0.16 → 4.0.17
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/example.js +43 -41
- package/lib/operation/delete.js +13 -13
- package/lib/operation/empty.js +8 -8
- package/lib/operation/insert.js +13 -13
- package/lib/richTextarea.js +5 -3
- package/lib/selection.js +8 -8
- package/package.json +1 -1
- package/src/operation/delete.js +18 -18
- package/src/operation/empty.js +6 -6
- package/src/operation/insert.js +18 -18
- package/src/richTextarea.js +10 -2
- package/src/selection.js +11 -7
package/src/operation/delete.js
CHANGED
|
@@ -23,6 +23,24 @@ export default class DeleteOperation {
|
|
|
23
23
|
return this.position;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
transformContent(content) {
|
|
27
|
+
let start, end;
|
|
28
|
+
|
|
29
|
+
start = 0;
|
|
30
|
+
|
|
31
|
+
end = this.position;
|
|
32
|
+
|
|
33
|
+
const leftContent = content.substring(start, end),
|
|
34
|
+
contentLength = this.content.length;
|
|
35
|
+
|
|
36
|
+
start = this.position + contentLength;
|
|
37
|
+
|
|
38
|
+
const rightContent = content.substring(start),
|
|
39
|
+
transformedContent = leftContent + rightContent;
|
|
40
|
+
|
|
41
|
+
return transformedContent;
|
|
42
|
+
}
|
|
43
|
+
|
|
26
44
|
transformOperation(operation) {
|
|
27
45
|
const type = operation.getType();
|
|
28
46
|
|
|
@@ -98,24 +116,6 @@ export default class DeleteOperation {
|
|
|
98
116
|
}
|
|
99
117
|
}
|
|
100
118
|
|
|
101
|
-
transformContent(content) {
|
|
102
|
-
let start, end;
|
|
103
|
-
|
|
104
|
-
start = 0;
|
|
105
|
-
|
|
106
|
-
end = this.position;
|
|
107
|
-
|
|
108
|
-
const leftContent = content.substring(start, end),
|
|
109
|
-
contentLength = this.content.length;
|
|
110
|
-
|
|
111
|
-
start = this.position + contentLength;
|
|
112
|
-
|
|
113
|
-
const rightContent = content.substring(start),
|
|
114
|
-
transformedContent = leftContent + rightContent;
|
|
115
|
-
|
|
116
|
-
return transformedContent;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
119
|
transformSelection(selection) {
|
|
120
120
|
let transformedSelection;
|
|
121
121
|
|
package/src/operation/empty.js
CHANGED
|
@@ -11,6 +11,12 @@ export default class EmptyOperation {
|
|
|
11
11
|
return this.type;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
transformContent(content) {
|
|
15
|
+
const transformedContent = content; ///
|
|
16
|
+
|
|
17
|
+
return transformedContent;
|
|
18
|
+
}
|
|
19
|
+
|
|
14
20
|
transformOperation(operation) {
|
|
15
21
|
return ((tau, rho) => {
|
|
16
22
|
|
|
@@ -19,12 +25,6 @@ export default class EmptyOperation {
|
|
|
19
25
|
})(operation, this);
|
|
20
26
|
}
|
|
21
27
|
|
|
22
|
-
transformContent(content) {
|
|
23
|
-
const transformedContent = content; ///
|
|
24
|
-
|
|
25
|
-
return transformedContent;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
28
|
transformSelection(selection) {
|
|
29
29
|
const transformedSelection = selection.clone();
|
|
30
30
|
|
package/src/operation/insert.js
CHANGED
|
@@ -24,6 +24,24 @@ export default class InsertOperation {
|
|
|
24
24
|
return this.position;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
transformContent(content) {
|
|
28
|
+
let start,
|
|
29
|
+
end;
|
|
30
|
+
|
|
31
|
+
start = 0;
|
|
32
|
+
|
|
33
|
+
end = this.position;
|
|
34
|
+
|
|
35
|
+
const leftContent = content.substring(start, end);
|
|
36
|
+
|
|
37
|
+
start = this.position;
|
|
38
|
+
|
|
39
|
+
const rightContent = content.substring(start),
|
|
40
|
+
transformedContent = leftContent + this.content + rightContent;
|
|
41
|
+
|
|
42
|
+
return transformedContent;
|
|
43
|
+
}
|
|
44
|
+
|
|
27
45
|
transformOperation(operation) {
|
|
28
46
|
const type = operation.getType();
|
|
29
47
|
|
|
@@ -81,24 +99,6 @@ export default class InsertOperation {
|
|
|
81
99
|
}
|
|
82
100
|
}
|
|
83
101
|
|
|
84
|
-
transformContent(content) {
|
|
85
|
-
let start,
|
|
86
|
-
end;
|
|
87
|
-
|
|
88
|
-
start = 0;
|
|
89
|
-
|
|
90
|
-
end = this.position;
|
|
91
|
-
|
|
92
|
-
const leftContent = content.substring(start, end);
|
|
93
|
-
|
|
94
|
-
start = this.position;
|
|
95
|
-
|
|
96
|
-
const rightContent = content.substring(start),
|
|
97
|
-
transformedContent = leftContent + this.content + rightContent;
|
|
98
|
-
|
|
99
|
-
return transformedContent;
|
|
100
|
-
}
|
|
101
|
-
|
|
102
102
|
transformSelection(selection) {
|
|
103
103
|
let transformedSelection;
|
|
104
104
|
|
package/src/richTextarea.js
CHANGED
|
@@ -245,10 +245,14 @@ export default class RichTextarea extends Element {
|
|
|
245
245
|
const operation = this.undoBuffer.undo();
|
|
246
246
|
|
|
247
247
|
if (operation !== null) {
|
|
248
|
-
const undoable = false
|
|
248
|
+
const undoable = false,
|
|
249
|
+
selection = Selection.fromOperation(operation),
|
|
250
|
+
setPreviousSelection = false;
|
|
249
251
|
|
|
250
252
|
this.applyOperation(operation);
|
|
251
253
|
|
|
254
|
+
this.setSelection(selection, setPreviousSelection);
|
|
255
|
+
|
|
252
256
|
this.intermediateHandler(event, element, undoable);
|
|
253
257
|
}
|
|
254
258
|
}
|
|
@@ -257,10 +261,14 @@ export default class RichTextarea extends Element {
|
|
|
257
261
|
const operation = this.undoBuffer.redo();
|
|
258
262
|
|
|
259
263
|
if (operation !== null) {
|
|
260
|
-
const undoable = false
|
|
264
|
+
const undoable = false,
|
|
265
|
+
selection = Selection.fromOperation(operation),
|
|
266
|
+
setPreviousSelection = false;
|
|
261
267
|
|
|
262
268
|
this.applyOperation(operation);
|
|
263
269
|
|
|
270
|
+
this.setSelection(selection, setPreviousSelection);
|
|
271
|
+
|
|
264
272
|
this.intermediateHandler(event, element, undoable);
|
|
265
273
|
}
|
|
266
274
|
}
|
package/src/selection.js
CHANGED
|
@@ -116,6 +116,17 @@ export default class Selection {
|
|
|
116
116
|
return selection;
|
|
117
117
|
}
|
|
118
118
|
|
|
119
|
+
static fromOperation(operation) {
|
|
120
|
+
const content = operation.getContent(),
|
|
121
|
+
position = operation.getPosition(),
|
|
122
|
+
contentLength = content.length,
|
|
123
|
+
startPosition = position + contentLength,
|
|
124
|
+
endPosition = startPosition, ///
|
|
125
|
+
selection = new Selection(startPosition, endPosition);
|
|
126
|
+
|
|
127
|
+
return selection;
|
|
128
|
+
}
|
|
129
|
+
|
|
119
130
|
static fromSelection(selection) {
|
|
120
131
|
const startPosition = selection.getStartPosition(),
|
|
121
132
|
endPosition = selection.getEndPosition();
|
|
@@ -135,13 +146,6 @@ export default class Selection {
|
|
|
135
146
|
|
|
136
147
|
}
|
|
137
148
|
|
|
138
|
-
static fromStartPosition(startPosition) {
|
|
139
|
-
const endPosition = startPosition, ///
|
|
140
|
-
selection = new Selection(startPosition, endPosition);
|
|
141
|
-
|
|
142
|
-
return selection;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
149
|
static fromStartPositionAndEndPosition(startPosition, endPosition) {
|
|
146
150
|
const selection = new Selection(startPosition, endPosition);
|
|
147
151
|
|