diff --git a/index.js b/index.js index f70431f..3ab1e54 100644 --- a/index.js +++ b/index.js @@ -126,8 +126,7 @@ var Shared = (function () { case 'onSelection': { this.editor.on('beforeSelectionChange', function (cm, data) { - var _data = Object.assign({}, data); - _this.props.onSelection(_this.editor, _data); + _this.props.onSelection(_this.editor, data); }); } break; diff --git a/package-lock.json b/package-lock.json index 3597000..037cfe9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "react-codemirror2", - "version": "3.0.6", + "version": "3.0.7", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2380,12 +2380,12 @@ } }, "enzyme-adapter-react-16": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.0.2.tgz", - "integrity": "sha512-ePlf3ikzau4NatDCzBP1Y/rFgLhR6MnS1YQVrxD2KXFI31nE1HtL+6ciqALF8kHe5q7Y7lFAd1MYOLIriRqgcw==", + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/enzyme-adapter-react-16/-/enzyme-adapter-react-16-1.0.3.tgz", + "integrity": "sha512-jjUOXn0+Gl3oeQEnXchNoszwgkYEmnvcc+bKn6SrRE9wktCjccS20Gvu501GnJQbrfXBNSACgkClcMeFoucrkw==", "dev": true, "requires": { - "enzyme-adapter-utils": "1.0.1", + "enzyme-adapter-utils": "1.1.0", "lodash": "4.17.4", "object.assign": "4.0.4", "object.values": "1.0.4", @@ -2394,9 +2394,9 @@ } }, "enzyme-adapter-utils": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/enzyme-adapter-utils/-/enzyme-adapter-utils-1.0.1.tgz", - "integrity": "sha1-/NgSIzOaVaMS91UmQeBFxAQIQAk=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/enzyme-adapter-utils/-/enzyme-adapter-utils-1.1.0.tgz", + "integrity": "sha512-YsMYx1xbLB8EHlIlnczi7Z/QBvG1cFHK3Ok6F6LMJYmv/WgwU5Ks7DJIJxN4h+W6ncRvcTusWKiTQI58hkZbaQ==", "dev": true, "requires": { "lodash": "4.17.4", @@ -5401,6 +5401,12 @@ } } }, + "just-extend": { + "version": "1.1.27", + "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.27.tgz", + "integrity": "sha512-mJVp13Ix6gFo3SBAy9U/kL+oeZqzlYYYLQBwXVBlVzIsZwBqGREnOro24oC/8s8aox+rJhtZ2DiQof++IrkA+g==", + "dev": true + }, "kind-of": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", @@ -6048,6 +6054,42 @@ "integrity": "sha1-KzJxhOiZIQEXeyhWP7XnECrNDKk=", "dev": true }, + "nise": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/nise/-/nise-1.2.0.tgz", + "integrity": "sha512-q9jXh3UNsMV28KeqI43ILz5+c3l+RiNW8mhurEwCKckuHQbL+hTJIKKTiUlCPKlgQ/OukFvSnKB/Jk3+sFbkGA==", + "dev": true, + "requires": { + "formatio": "1.2.0", + "just-extend": "1.1.27", + "lolex": "1.6.0", + "path-to-regexp": "1.7.0", + "text-encoding": "0.6.4" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", + "dev": true + }, + "lolex": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.6.0.tgz", + "integrity": "sha1-OpoCg0UqR9dDnnJzG54H1zhuSfY=", + "dev": true + }, + "path-to-regexp": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", + "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", + "dev": true, + "requires": { + "isarray": "0.0.1" + } + } + } + }, "node-fetch": { "version": "1.7.2", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-1.7.2.tgz", @@ -8335,9 +8377,9 @@ "dev": true }, "sinon": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/sinon/-/sinon-4.0.2.tgz", - "integrity": "sha512-4mUsjHfjrHyPFGDTtNJl0q8cv4VOJGvQykI1r3fnn05ys0sQL9M1Y+DyyGNWLD2PMcoyqjJ/nFDm4K54V1eQOg==", + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/sinon/-/sinon-4.1.1.tgz", + "integrity": "sha512-l+74gYEaCH967jIfuLCsBxmAW88/6+y+dzr6HJqOuKdGFYA5JQWOxYcyF6aBd49v8/QOIIQYwzcfaTP9FQawdg==", "dev": true, "requires": { "diff": "3.4.0", @@ -8355,48 +8397,6 @@ "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=", "dev": true }, - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=", - "dev": true - }, - "just-extend": { - "version": "1.1.26", - "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-1.1.26.tgz", - "integrity": "sha512-IIG0FXHB/XpUZ7vGbktoc2EGsF+fLHJ1tU+vaqoKkVRBwH2FDxLTmkGkSp0XHRp6Y3KGZPIldH1YW8lOluGYrA==", - "dev": true - }, - "nise": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/nise/-/nise-1.2.0.tgz", - "integrity": "sha512-q9jXh3UNsMV28KeqI43ILz5+c3l+RiNW8mhurEwCKckuHQbL+hTJIKKTiUlCPKlgQ/OukFvSnKB/Jk3+sFbkGA==", - "dev": true, - "requires": { - "formatio": "1.2.0", - "just-extend": "1.1.26", - "lolex": "1.6.0", - "path-to-regexp": "1.7.0", - "text-encoding": "0.6.4" - }, - "dependencies": { - "lolex": { - "version": "1.6.0", - "resolved": "https://registry.npmjs.org/lolex/-/lolex-1.6.0.tgz", - "integrity": "sha1-OpoCg0UqR9dDnnJzG54H1zhuSfY=", - "dev": true - } - } - }, - "path-to-regexp": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.7.0.tgz", - "integrity": "sha1-Wf3g9DW62suhA6hOnTvGTpa5k30=", - "dev": true, - "requires": { - "isarray": "0.0.1" - } - }, "supports-color": { "version": "4.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", diff --git a/package.json b/package.json index 577d237..294a2d3 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "coveralls": "3.0.0", "css-loader": "0.28.7", "enzyme": "3.1.0", - "enzyme-adapter-react-16": "1.0.2", + "enzyme-adapter-react-16": "1.0.3", "express": "4.16.2", "gulp": "3.9.1", "gulp-replace": "0.6.1", @@ -89,7 +89,7 @@ "redux": "3.7.2", "rimraf": "2.6.2", "sass-loader": "6.0.6", - "sinon": "4.0.2", + "sinon": "4.1.1", "style-loader": "0.19.0", "ts-jest": "21.1.4", "typescript": "2.6.1", diff --git a/src/index.tsx b/src/index.tsx index 08a7380..f8b6779 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -32,10 +32,9 @@ export interface IGetSelectionOptions { update: (ranges: Array) => void; } +/* tshacks: laundry list of incorrect typings in @types/codemirror */ export interface IDoc extends codemirror.Doc { - /* tshack: `setCursor` has incorrect/missing overloaded signature in @types/codemirror */ setCursor: (pos: codemirror.Position, ch?: number, options?: {}) => void; - /* tshack: `setSelections` missing in @types/codemirror */ setSelections: (ranges: Array) => void; } @@ -203,12 +202,8 @@ class Shared implements ICommon { } break; case 'onSelection': { - this.editor.on('beforeSelectionChange', (cm, data) => { - - /* tshack: `beforeSelectionChange` return wrong type in @types/codemirror */ - let _data = Object.assign({}, data) as IGetSelectionOptions; - - this.props.onSelection(this.editor, _data); + this.editor.on('beforeSelectionChange', (cm, data: any) => { + this.props.onSelection(this.editor, data); }); } break;