@github/text-expander-element
Advanced tools
Comparing version 2.3.0 to 2.5.0
@@ -386,2 +386,3 @@ const ctrlBindings = !!navigator.userAgent.match(/Macintosh/); | ||
onCommit({ target }) { | ||
var _a; | ||
const item = target; | ||
@@ -397,3 +398,3 @@ if (!(item instanceof HTMLElement)) | ||
const remaining = this.input.value.substring(match.position + match.text.length); | ||
const detail = { item, key: match.key, value: null }; | ||
const detail = { item, key: match.key, value: null, continue: false }; | ||
const canceled = !this.expander.dispatchEvent(new CustomEvent('text-expander-value', { cancelable: true, detail })); | ||
@@ -404,3 +405,7 @@ if (canceled) | ||
return; | ||
const value = `${detail.value} `; | ||
let suffix = (_a = this.expander.getAttribute('suffix')) !== null && _a !== void 0 ? _a : ' '; | ||
if (detail.continue) { | ||
suffix = ''; | ||
} | ||
const value = `${detail.value}${suffix}`; | ||
this.input.value = beginning + value + remaining; | ||
@@ -414,4 +419,6 @@ const cursor = beginning.length + value.length; | ||
this.input.selectionEnd = cursor; | ||
this.lookBackIndex = cursor; | ||
this.match = null; | ||
if (!detail.continue) { | ||
this.lookBackIndex = cursor; | ||
this.match = null; | ||
} | ||
this.expander.dispatchEvent(new CustomEvent('text-expander-committed', { cancelable: false, detail: { input: this.input } })); | ||
@@ -418,0 +425,0 @@ } |
@@ -216,2 +216,3 @@ import Combobox from '@github/combobox-nav'; | ||
onCommit({ target }) { | ||
var _a; | ||
const item = target; | ||
@@ -227,3 +228,3 @@ if (!(item instanceof HTMLElement)) | ||
const remaining = this.input.value.substring(match.position + match.text.length); | ||
const detail = { item, key: match.key, value: null }; | ||
const detail = { item, key: match.key, value: null, continue: false }; | ||
const canceled = !this.expander.dispatchEvent(new CustomEvent('text-expander-value', { cancelable: true, detail })); | ||
@@ -234,3 +235,7 @@ if (canceled) | ||
return; | ||
const value = `${detail.value} `; | ||
let suffix = (_a = this.expander.getAttribute('suffix')) !== null && _a !== void 0 ? _a : ' '; | ||
if (detail.continue) { | ||
suffix = ''; | ||
} | ||
const value = `${detail.value}${suffix}`; | ||
this.input.value = beginning + value + remaining; | ||
@@ -244,4 +249,6 @@ const cursor = beginning.length + value.length; | ||
this.input.selectionEnd = cursor; | ||
this.lookBackIndex = cursor; | ||
this.match = null; | ||
if (!detail.continue) { | ||
this.lookBackIndex = cursor; | ||
this.match = null; | ||
} | ||
this.expander.dispatchEvent(new CustomEvent('text-expander-committed', { cancelable: false, detail: { input: this.input } })); | ||
@@ -248,0 +255,0 @@ } |
@@ -69,2 +69,3 @@ import Combobox from '@github/combobox-nav'; | ||
onCommit({ target }) { | ||
var _a; | ||
const item = target; | ||
@@ -80,3 +81,3 @@ if (!(item instanceof HTMLElement)) | ||
const remaining = this.input.value.substring(match.position + match.text.length); | ||
const detail = { item, key: match.key, value: null }; | ||
const detail = { item, key: match.key, value: null, continue: false }; | ||
const canceled = !this.expander.dispatchEvent(new CustomEvent('text-expander-value', { cancelable: true, detail })); | ||
@@ -87,3 +88,7 @@ if (canceled) | ||
return; | ||
const value = `${detail.value} `; | ||
let suffix = (_a = this.expander.getAttribute('suffix')) !== null && _a !== void 0 ? _a : ' '; | ||
if (detail.continue) { | ||
suffix = ''; | ||
} | ||
const value = `${detail.value}${suffix}`; | ||
this.input.value = beginning + value + remaining; | ||
@@ -97,4 +102,6 @@ const cursor = beginning.length + value.length; | ||
this.input.selectionEnd = cursor; | ||
this.lookBackIndex = cursor; | ||
this.match = null; | ||
if (!detail.continue) { | ||
this.lookBackIndex = cursor; | ||
this.match = null; | ||
} | ||
this.expander.dispatchEvent(new CustomEvent('text-expander-committed', { cancelable: false, detail: { input: this.input } })); | ||
@@ -101,0 +108,0 @@ } |
{ | ||
"name": "@github/text-expander-element", | ||
"version": "2.3.0", | ||
"version": "2.5.0", | ||
"description": "Activates a suggestion menu to expand text snippets as you type.", | ||
@@ -5,0 +5,0 @@ "repository": "github/text-expander-element", |
@@ -40,2 +40,3 @@ # <text-expander> element | ||
- you can provide a space separated list of activation keys that should support multi-word matching | ||
- `suffix` is a string that is appended to the value during expansion, default is a single space character | ||
@@ -83,2 +84,3 @@ ## Events | ||
- `value`: A null value placeholder to replace the query. To replace the text query, simply re-assign this value. | ||
- `continue`: A boolean value to specify whether to continue autocompletion after inserting a value. Defaults to `false`. If set to `true`, will not add a space after inserted value and will keep firing the `text-expander-change` event. | ||
@@ -85,0 +87,0 @@ ```js |
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
50970
1273
130