-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVisualEditor.diff
34 lines (33 loc) · 1013 Bytes
/
VisualEditor.diff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
diff --git a/src/dm/ve.dm.Surface.js b/src/dm/ve.dm.Surface.js
index c61047a14..3504df0c0 100644
--- a/src/dm/ve.dm.Surface.js
+++ b/src/dm/ve.dm.Surface.js
@@ -692,6 +692,29 @@ ve.dm.Surface.prototype.stopQueueingContextChanges = function () {
}
};
+/**
+ * Set a linear selection at a specified range on the model
+ *
+ * @param {number} [from=0] Anchor offset
+ * @param {number} [to=from] Focus offset
+ */
+ve.dm.Surface.prototype.setLinearSelectionFromRange = function ( from, to ) {
+ this.setSelection( new ve.dm.LinearSelection( new ve.Range( from, to ) ) );
+};
+
+ve.dm.Surface.prototype.doReplacementRange = function( from, to, newText ) {
+ var replace = ve.dm.TransactionBuilder.static.newFromReplacement(
+ this.getDocument(),
+ new ve.Range( from, to ),
+ newText
+ );
+ var replaceChange = new ve.dm.Change(
+ this.getDocument().completeHistory.getLength(),
+ [ replace ]
+ );
+ replaceChange.applyTo( this );
+};
+
/**
* Set a linear selection at a specified range on the model
*