easy-richtextarea 4.0.4 → 4.0.7
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 +199 -120
- package/lib/browser.js +9 -5
- package/lib/main.js +9 -5
- package/lib/richTextarea.js +18 -1
- package/lib/transform/content.js +19 -0
- package/lib/{operations/transform.js → transform/operations.js} +1 -1
- package/lib/transform/selection.js +19 -0
- package/lib/undoBuffer.js +36 -1
- package/package.json +1 -1
- package/src/browser.js +3 -3
- package/src/main.js +3 -2
- package/src/richTextarea.js +30 -0
- package/src/transform/content.js +11 -0
- package/src/transform/selection.js +11 -0
- package/src/undoBuffer.js +32 -0
- package/lib/content/transform.js +0 -17
- package/src/content/transform.js +0 -5
- /package/src/{operations/transform.js → transform/operations.js} +0 -0
package/src/undoBuffer.js
CHANGED
|
@@ -2,8 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
import { arrayUtilities } from "necessary";
|
|
4
4
|
|
|
5
|
+
import EmptyOperation from "./operation/empty";
|
|
5
6
|
import InsertOperation from "./operation/insert";
|
|
6
7
|
import DeleteOperation from "./operation/delete";
|
|
8
|
+
import transformOperations from "./transform/operations";
|
|
7
9
|
|
|
8
10
|
const { push } = arrayUtilities;
|
|
9
11
|
|
|
@@ -51,6 +53,12 @@ export default class UndoBuffer {
|
|
|
51
53
|
return operation;
|
|
52
54
|
}
|
|
53
55
|
|
|
56
|
+
transform(operations) {
|
|
57
|
+
this.operations = transformOperations(this.operations, operations);
|
|
58
|
+
|
|
59
|
+
this.filterEmptyOperations();
|
|
60
|
+
}
|
|
61
|
+
|
|
54
62
|
addOperations(operations) {
|
|
55
63
|
const start = this.position; ///
|
|
56
64
|
|
|
@@ -63,6 +71,30 @@ export default class UndoBuffer {
|
|
|
63
71
|
this.position = operationsLength; ///
|
|
64
72
|
}
|
|
65
73
|
|
|
74
|
+
filterEmptyOperations() {
|
|
75
|
+
let length = this.operations.length,
|
|
76
|
+
position = 0;
|
|
77
|
+
|
|
78
|
+
while (position < length) {
|
|
79
|
+
const operation = this.operations[position];
|
|
80
|
+
|
|
81
|
+
if (operation instanceof EmptyOperation) {
|
|
82
|
+
const start = position, ///
|
|
83
|
+
deleteCount = 1;
|
|
84
|
+
|
|
85
|
+
this.operations.splice(start, deleteCount);
|
|
86
|
+
|
|
87
|
+
if (this.position > position) {
|
|
88
|
+
this.position--;
|
|
89
|
+
}
|
|
90
|
+
} else {
|
|
91
|
+
position++;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
length = this.operations.length;
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
66
98
|
static fromNothing() {
|
|
67
99
|
const position = 0,
|
|
68
100
|
operations = [],
|
package/lib/content/transform.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
Object.defineProperty(exports, "default", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
get: function() {
|
|
8
|
-
return transformContent;
|
|
9
|
-
}
|
|
10
|
-
});
|
|
11
|
-
function transformContent(content, operations) {
|
|
12
|
-
return operations.reduce(function(content, operation) {
|
|
13
|
-
return operation.transformContent(content);
|
|
14
|
-
}, content);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250ZW50L3RyYW5zZm9ybS5qcyJdLCJzb3VyY2VzQ29udGVudCI6WyJcInVzZSBzdHJpY3RcIjtcclxuXHJcbmV4cG9ydCBkZWZhdWx0IGZ1bmN0aW9uIHRyYW5zZm9ybUNvbnRlbnQoY29udGVudCwgb3BlcmF0aW9ucykge1xyXG4gIHJldHVybiBvcGVyYXRpb25zLnJlZHVjZSgoY29udGVudCwgb3BlcmF0aW9uKSA9PiBvcGVyYXRpb24udHJhbnNmb3JtQ29udGVudChjb250ZW50KSwgY29udGVudCk7XHJcbn1cclxuIl0sIm5hbWVzIjpbInRyYW5zZm9ybUNvbnRlbnQiLCJjb250ZW50Iiwib3BlcmF0aW9ucyIsInJlZHVjZSIsIm9wZXJhdGlvbiJdLCJtYXBwaW5ncyI6IkFBQUE7Ozs7K0JBRUE7OztlQUF3QkE7OztBQUFULFNBQVNBLGlCQUFpQkMsT0FBTyxFQUFFQyxVQUFVLEVBQUU7SUFDNUQsT0FBT0EsV0FBV0MsTUFBTSxDQUFDLFNBQUNGLFNBQVNHO2VBQWNBLFVBQVVKLGdCQUFnQixDQUFDQztPQUFVQTtBQUN4RiJ9
|
package/src/content/transform.js
DELETED
|
File without changes
|