Skip to content
This repository was archived by the owner on Jan 4, 2021. It is now read-only.

Commit 1a9cc59

Browse files
author
Francois-Xavier Gentilhomme
committed
v1.0.7 Undo/redo and error mgmt improvements
1 parent 7b44629 commit 1a9cc59

File tree

9 files changed

+32
-20
lines changed

9 files changed

+32
-20
lines changed

bower.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "myscript",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"main": "./dist/myscript.js",
55
"description": "MyScriptJS is a free and open-source JavaScript library providing the easiest way to use MyScript Cloud handwriting recognition in your web app",
66
"keywords": [

dist/myscript.js

+6-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/myscript.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/myscript.min.js

+5-7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/myscript.min.js.map

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "myscript",
3-
"version": "1.0.6",
3+
"version": "1.0.7",
44
"main": "./dist/myscript.js",
55
"description": "MyScriptJS is a free and open-source JavaScript library providing the easiest way to use MyScript Cloud handwriting recognition in your web app",
66
"keywords": [

src/common/inkManager.js

+3
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@
4444
*/
4545
InkManager.prototype.startInkCapture = function (x, y, t) {
4646
if (!this.writing) {
47+
if (this.isRedoEmpty()) {
48+
this.clearUndoRedoStack();
49+
}
4750
this.currentStroke = new scope.Stroke();
4851
this.currentStroke.addX(x);
4952
this.currentStroke.addY(y);

src/networking/networkInterface.js

+2-4
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@
6262
if (request.readyState === 4) {
6363
if (request.status >= 200 && request.status < 300) {
6464
deferred.resolve(NetworkInterface.parse(request));
65-
} else {
66-
deferred.reject(NetworkInterface.parse(request));
6765
}
6866
}
6967
}
@@ -72,12 +70,12 @@
7270
if (request.status >= 200 && request.status < 300) {
7371
deferred.resolve(NetworkInterface.parse(request));
7472
} else {
75-
deferred.reject('Status code was ' + request.status);
73+
deferred.reject(new Error(request.responseText));
7674
}
7775
}
7876

7977
function onError() {
80-
deferred.reject('Can\'t XHR ' + JSON.stringify(url));
78+
deferred.reject(new Error('Can\'t XHR ' + url));
8179
}
8280

8381
function onProgress(event) {

test/unit/common/inkManager.js

+12
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,17 @@ describe('MyScriptJS: common/inkManager.js', function () {
145145
expect(inkManager.getUndoRedoStack()[inkManager.getUndoRedoStack().length - 1]).to.deep.equal(stroke);
146146
});
147147

148+
it('Test undo/redo stack', function () {
149+
inkManager.redo();
150+
151+
inkManager.startInkCapture(50, 2);
152+
inkManager.continueInkCapture(60, 8);
153+
inkManager.endInkCapture();
154+
155+
expect(inkManager.getStrokes().length).to.equal(2);
156+
expect(inkManager.getUndoRedoStack().length).to.equal(0);
157+
});
158+
148159
it('InkManager clear Undo/redo Stack', function () {
149160
inkManager.clearUndoRedoStack();
150161

@@ -153,6 +164,7 @@ describe('MyScriptJS: common/inkManager.js', function () {
153164
});
154165

155166
it('InkManager copy', function () {
167+
inkManager.clear();
156168
var copyStrokes = [];
157169
// add one stroke
158170
inkManager.startInkCapture(50, 2);

0 commit comments

Comments
 (0)