@teamwork/autocomplete-core
Advanced tools
Comparing version 1.1.3 to 1.2.0
@@ -6,2 +6,14 @@ # Change Log | ||
# [1.2.0](https://github.com/Teamwork/autocomplete/compare/@teamwork/autocomplete-core@1.1.3...@teamwork/autocomplete-core@1.2.0) (2020-07-29) | ||
### Features | ||
* add caretOffset to Autocomplete ([c5e7ee3](https://github.com/Teamwork/autocomplete/commit/c5e7ee3d86117655f9c3b127f97abaefd4537942)) | ||
* add getCaretPosition to EditorAdapter ([5f0d7ce](https://github.com/Teamwork/autocomplete/commit/5f0d7ce3d5d75ceb578b23efdc855fca67c703d3)) | ||
## [1.1.3](https://github.com/Teamwork/autocomplete/compare/@teamwork/autocomplete-core@1.1.2...@teamwork/autocomplete-core@1.1.3) (2020-04-20) | ||
@@ -8,0 +20,0 @@ |
@@ -54,2 +54,9 @@ import { EmitterInterface, TypedEventEmitter } from '@syncot/events'; | ||
destroy(): void; | ||
/** | ||
* Gets the screen coordinates of the caret. | ||
* @param offset Allows getting the caret position | ||
* as if it was moved by the specified number of characters | ||
* relative to the actual caret position. Defaults to 0. | ||
*/ | ||
getCaretPosition(offset?: number): Position; | ||
} |
@@ -79,2 +79,6 @@ import { EmitterInterface, TypedEventEmitter } from '@syncot/events'; | ||
/** | ||
* Emitted when the `caretOffset` property is updated. | ||
*/ | ||
caretOffset: void; | ||
/** | ||
* Emitted when the `caretPosition` property is updated. | ||
@@ -121,2 +125,6 @@ */ | ||
/** | ||
* The number of characters between the start of `matchedText` and the caret. | ||
*/ | ||
readonly caretOffset: number; | ||
/** | ||
* The screen coordinates of the caret. | ||
@@ -123,0 +131,0 @@ */ |
import { TypedEventEmitter } from '@syncot/events'; | ||
const defaultCaretOffset = 0; | ||
const defaultMatchedText = ''; | ||
@@ -32,2 +33,3 @@ const defaultItems = Object.freeze([]); | ||
this._matchedText = defaultMatchedText; | ||
this._caretOffset = defaultCaretOffset; | ||
this._caretPosition = defaultPosition; | ||
@@ -169,2 +171,11 @@ this._editorPosition = defaultPosition; | ||
} | ||
get caretOffset() { | ||
return this._caretOffset; | ||
} | ||
set caretOffset(caretOffset) { | ||
if (this._caretOffset !== caretOffset) { | ||
this._caretOffset = caretOffset; | ||
this.emitLater('caretOffset'); | ||
} | ||
} | ||
get caretPosition() { | ||
@@ -288,2 +299,3 @@ return this._caretPosition; | ||
this.matchedText = matchedText; | ||
this.caretOffset = lengthBefore; | ||
this.caretPosition = this.editorAdapter.caretPosition; | ||
@@ -311,2 +323,3 @@ this.editorPosition = this.editorAdapter.editorPosition; | ||
this.matchedText = defaultMatchedText; | ||
this.caretOffset = defaultCaretOffset; | ||
this.caretPosition = defaultPosition; | ||
@@ -313,0 +326,0 @@ this.editorPosition = defaultPosition; |
{ | ||
"name": "@teamwork/autocomplete-core", | ||
"version": "1.1.3", | ||
"version": "1.2.0", | ||
"description": "The core autocomplete components.", | ||
@@ -29,3 +29,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "73bc66719fc99e304408a635fd434c3448d1641f" | ||
"gitHead": "8bff14dd65b076b5fb7056cd6b94d01d33b073e7" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23335
616