Merge pull request #23756 from shiftkey/add-textarea-caret-package

add textarea-caret package
This commit is contained in:
Daniel Rosenwasser
2018-03-12 00:40:51 -07:00
committed by GitHub
4 changed files with 59 additions and 0 deletions
+19
View File
@@ -0,0 +1,19 @@
// Type definitions for textarea-caret 3.0
// Project: https://github.com/component/textarea-caret-position
// Definitions by: Brendan Forster <https://github.com/shiftkey>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.6
export = textarea_caret;
interface Caret {
top: number;
left: number;
height: number;
}
interface Options {
debug?: boolean;
}
declare function textarea_caret(element: HTMLElement, position: number, options?: Options): Caret;
@@ -0,0 +1,8 @@
import getCaretCoordinates = require('textarea-caret');
const element = document.querySelector('textarea');
element!.addEventListener('input', function() {
const caret = getCaretCoordinates(this, this.selectionEnd);
console.log('(top, left, height) = (%s, %s, %s)', caret.top, caret.left, caret.height);
});
+24
View File
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"textarea-caret-tests.ts"
]
}
+8
View File
@@ -0,0 +1,8 @@
{
"extends": "dtslint/dt.json",
"rules": {
"indent": [true, "spaces", 4],
"max-line-length": [true, 100],
"no-any": true
}
}