@textcomplete/core
Advanced tools
Comparing version 0.1.12 to 0.1.13
@@ -24,3 +24,3 @@ import { EventEmitter } from "eventemitter3"; | ||
export declare const DEFAULT_DROPDOWN_ITEM_CLASS_NAME = "textcomplete-item"; | ||
export declare const DEFAULT_DROPDOWN_ITEM_ACTIVE_CLASS_NAME: string; | ||
export declare const DEFAULT_DROPDOWN_ITEM_ACTIVE_CLASS_NAME = "textcomplete-item active"; | ||
export declare class Dropdown extends EventEmitter { | ||
@@ -27,0 +27,0 @@ readonly el: HTMLUListElement; |
@@ -14,10 +14,2 @@ "use strict"; | ||
class Dropdown extends eventemitter3_1.EventEmitter { | ||
constructor(el, option) { | ||
super(); | ||
this.el = el; | ||
this.option = option; | ||
this.shown = false; | ||
this.items = []; | ||
this.activeIndex = null; | ||
} | ||
static create(option) { | ||
@@ -35,2 +27,10 @@ const ul = document.createElement("ul"); | ||
} | ||
constructor(el, option) { | ||
super(); | ||
this.el = el; | ||
this.option = option; | ||
this.shown = false; | ||
this.items = []; | ||
this.activeIndex = null; | ||
} | ||
/** | ||
@@ -37,0 +37,0 @@ * Render the given search results. Previous results are cleared. |
@@ -10,3 +10,3 @@ import { EventEmitter } from "eventemitter3"; | ||
} | ||
declare type KeyCode = "ESC" | "ENTER" | "UP" | "DOWN" | "OTHER"; | ||
type KeyCode = "ESC" | "ENTER" | "UP" | "DOWN" | "OTHER"; | ||
export declare abstract class Editor extends EventEmitter { | ||
@@ -13,0 +13,0 @@ /** |
@@ -94,17 +94,22 @@ "use strict"; | ||
getCode(e) { | ||
return e.keyCode === 9 // tab | ||
? "ENTER" | ||
: e.keyCode === 13 // enter | ||
? "ENTER" | ||
: e.keyCode === 27 // esc | ||
? "ESC" | ||
: e.keyCode === 38 // up | ||
? "UP" | ||
: e.keyCode === 40 // down | ||
? "DOWN" | ||
: e.keyCode === 78 && e.ctrlKey // ctrl-n | ||
? "DOWN" | ||
: e.keyCode === 80 && e.ctrlKey // ctrl-p | ||
? "UP" | ||
: "OTHER"; | ||
switch (e.keyCode) { | ||
case 9: // tab | ||
case 13: // enter | ||
return "ENTER"; | ||
case 27: // esc | ||
return "ESC"; | ||
case 38: // up | ||
return "UP"; | ||
case 40: // down | ||
return "DOWN"; | ||
case 78: // ctrl-n | ||
if (e.ctrlKey) | ||
return "DOWN"; | ||
break; | ||
case 80: // ctrl-p | ||
if (e.ctrlKey) | ||
return "UP"; | ||
break; | ||
} | ||
return "OTHER"; | ||
} | ||
@@ -111,0 +116,0 @@ } |
import { SearchResult } from "./SearchResult"; | ||
export declare type SearchCallback<T> = (results: T[]) => void; | ||
declare type ReplaceResult = [string, string] | string | null; | ||
export type SearchCallback<T> = (results: T[]) => void; | ||
type ReplaceResult = [string, string] | string | null; | ||
export interface StrategyProps<T = any> { | ||
@@ -5,0 +5,0 @@ match: RegExp | ((regexp: string | RegExp) => RegExpMatchArray | null); |
{ | ||
"name": "@textcomplete/core", | ||
"version": "0.1.12", | ||
"version": "0.1.13", | ||
"description": "Textcomplete core.", | ||
@@ -12,11 +12,11 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"build": "rm -fr dist && tsc", | ||
"format:eslint": "eslint --fix 'src/**/*.ts'", | ||
"format:prettier": "prettier --write 'src/**/*.ts'", | ||
"build": "rimraf dist && tsc", | ||
"format:eslint": "eslint --fix src/**/*.ts", | ||
"format:prettier": "prettier --write src/**/*.ts", | ||
"format": "run-s format:eslint format:prettier", | ||
"lint": "eslint 'src/**/*.ts'", | ||
"lint": "eslint src/**/*.ts", | ||
"test": "jest" | ||
}, | ||
"dependencies": { | ||
"eventemitter3": "^4.0.4" | ||
"eventemitter3": "^5.0.1" | ||
}, | ||
@@ -26,3 +26,3 @@ "publishConfig": { | ||
}, | ||
"gitHead": "fffd47c1709bdebffeb13ac2ce66127c6ca649a4" | ||
"gitHead": "975b9ff3f498410195d64482956b418acdcfb1e1" | ||
} |
# @textcomplete/core | ||
> Core of Textcomplete | ||
Core of Textcomplete | ||
[![npm version](https://badge.fury.io/js/@textcomplete%2Fcore.svg)](http://badge.fury.io/js/@textcomplete%2Fcore) | ||
Read more and check the live demo at [yuku.takahashi.coffee/textcomplete](https://yuku.takahashi.coffee/textcomplete/) | ||
## License | ||
© Yuku Takahashi - This software is licensed under the MIT license. |
@@ -251,4 +251,4 @@ import { EventEmitter } from "eventemitter3" | ||
: this.option.rotate | ||
? 0 | ||
: null | ||
? 0 | ||
: null | ||
} | ||
@@ -261,4 +261,4 @@ | ||
: this.option.rotate | ||
? this.items.length - 1 | ||
: null | ||
? this.items.length - 1 | ||
: null | ||
} | ||
@@ -265,0 +265,0 @@ |
@@ -112,18 +112,21 @@ import { EventEmitter } from "eventemitter3" | ||
protected getCode(e: KeyboardEvent): KeyCode { | ||
return e.keyCode === 9 // tab | ||
? "ENTER" | ||
: e.keyCode === 13 // enter | ||
? "ENTER" | ||
: e.keyCode === 27 // esc | ||
? "ESC" | ||
: e.keyCode === 38 // up | ||
? "UP" | ||
: e.keyCode === 40 // down | ||
? "DOWN" | ||
: e.keyCode === 78 && e.ctrlKey // ctrl-n | ||
? "DOWN" | ||
: e.keyCode === 80 && e.ctrlKey // ctrl-p | ||
? "UP" | ||
: "OTHER" | ||
switch (e.keyCode) { | ||
case 9: // tab | ||
case 13: // enter | ||
return "ENTER" | ||
case 27: // esc | ||
return "ESC" | ||
case 38: // up | ||
return "UP" | ||
case 40: // down | ||
return "DOWN" | ||
case 78: // ctrl-n | ||
if (e.ctrlKey) return "DOWN" | ||
break | ||
case 80: // ctrl-p | ||
if (e.ctrlKey) return "UP" | ||
break | ||
} | ||
return "OTHER" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
85479
1899
12
+ Addedeventemitter3@5.0.1(transitive)
- Removedeventemitter3@4.0.7(transitive)
Updatedeventemitter3@^5.0.1