-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathVisualEditor.REL1_31.diff
35 lines (34 loc) · 1.04 KB
/
VisualEditor.REL1_31.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
35
diff --git a/src/dm/ve.dm.Surface.js b/src/dm/ve.dm.Surface.js
index 6e09d7c2f..e8b01ad12 100644
--- a/src/dm/ve.dm.Surface.js
+++ b/src/dm/ve.dm.Surface.js
@@ -607,6 +607,30 @@ 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( this.getDocument(), 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.length,
+ [ replace ],
+ [ this.getDocument().store ]
+ );
+ replaceChange.applyTo( this );
+};
+
/**
* Set a linear selection at a specified range on the model
*