Merge pull request #23 from github/update-dependencies

Update dependencies
This commit is contained in:
Kristján Oddsson 2021-04-12 14:29:14 +01:00 коммит произвёл GitHub
Родитель efdf8c6ed7 c98a71ac5f
Коммит 3a48da5b7e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
8 изменённых файлов: 5774 добавлений и 2555 удалений

Просмотреть файл

@ -1,11 +1,9 @@
{
"extends": [
"plugin:github/browser",
"plugin:github/es6",
"plugin:github/typescript"
],
"root": true,
"plugins": ["github"],
"extends": ["plugin:github/browser", "plugin:github/recommended", "plugin:github/typescript"],
"globals": {
"TextExpanderElement": "readable"
"TextExpanderElement": "readonly"
},
"rules": {
"no-invalid-this": "off"

8163
package-lock.json сгенерированный

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -10,7 +10,7 @@
"scripts": {
"clean": "rm -rf dist build",
"compile": "tsc",
"lint": "github-lint",
"lint": "eslint .",
"prebuild": "npm run clean && npm run lint && npm run compile",
"build": "rollup -c",
"pretest": "npm run build && rollup -c rollup.config.test.js",
@ -33,18 +33,18 @@
},
"devDependencies": {
"@github/prettier-config": "0.0.4",
"chai": "^4.2.0",
"eslint": "^6.6.0",
"eslint-plugin-github": "^3.4.1",
"karma": "^5.0.2",
"chai": "^4.3.4",
"eslint": "^7.24.0",
"eslint-plugin-github": "^4.1.3",
"karma": "^6.3.2",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^3.1.0",
"karma-mocha": "^2.0.0",
"karma-mocha": "^2.0.1",
"karma-mocha-reporter": "^2.2.5",
"mocha": "^7.1.2",
"rollup": "^1.26.3",
"mocha": "^8.3.2",
"rollup": "^2.45.1",
"rollup-plugin-node-resolve": "^5.2.0",
"typescript": "^3.8.3"
"typescript": "^4.2.4"
},
"eslintIgnore": [
"build/",

Просмотреть файл

@ -234,21 +234,21 @@ export default class TextExpanderElement extends HTMLElement {
return keys.map(key => ({key, multiWord: globalMultiWord || multiWord.includes(key)}))
}
connectedCallback() {
connectedCallback(): void {
const input = this.querySelector('input[type="text"], textarea')
if (!(input instanceof HTMLInputElement || input instanceof HTMLTextAreaElement)) return
const state = new TextExpander(this, input)
states.set(this, state)
}
disconnectedCallback() {
disconnectedCallback(): void {
const state: TextExpander = states.get(this)
if (!state) return
state.destroy()
states.delete(this)
}
dismiss() {
dismiss(): void {
const state: TextExpander = states.get(this)
if (!state) return
state.dismissMenu()

Просмотреть файл

@ -1,131 +1,131 @@
import query from '../dist/query'
describe('text-expander single word parsing', function() {
it('does not match empty text', function() {
describe('text-expander single word parsing', function () {
it('does not match empty text', function () {
const found = query('', ':', 0)
assert(found == null)
})
it('does not match without activation key', function() {
it('does not match without activation key', function () {
const found = query('cat', ':', 3)
assert(found == null)
})
it('matches only activation key', function() {
it('matches only activation key', function () {
const found = query(':', ':', 1)
assert.deepEqual(found, {text: '', position: 1})
})
it('matches trailing activation key', function() {
it('matches trailing activation key', function () {
const found = query('hi :', ':', 4)
assert.deepEqual(found, {text: '', position: 4})
})
it('matches start of text', function() {
it('matches start of text', function () {
const found = query(':cat', ':', 4)
assert.deepEqual(found, {text: 'cat', position: 1})
})
it('matches end of text', function() {
it('matches end of text', function () {
const found = query('hi :cat', ':', 7)
assert.deepEqual(found, {text: 'cat', position: 4})
})
it('matches middle of text', function() {
it('matches middle of text', function () {
const found = query('hi :cat bye', ':', 7)
assert.deepEqual(found, {text: 'cat', position: 4})
})
it('matches only at word boundary', function() {
it('matches only at word boundary', function () {
const found = query('hi:cat', ':', 6)
assert(found == null)
})
it('matches last activation key word', function() {
it('matches last activation key word', function () {
const found = query('hi :cat bye :dog', ':', 16)
assert.deepEqual(found, {text: 'dog', position: 13})
})
it('matches closest activation key word', function() {
it('matches closest activation key word', function () {
const found = query('hi :cat bye :dog', ':', 7)
assert.deepEqual(found, {text: 'cat', position: 4})
})
it('does not match with a space between cursor and activation key', function() {
it('does not match with a space between cursor and activation key', function () {
const found = query('hi :cat bye', ':', 11)
assert(found == null)
})
})
describe('text-expander multi word parsing', function() {
it('does not match empty text', function() {
describe('text-expander multi word parsing', function () {
it('does not match empty text', function () {
const found = query('', ':', 0, {multiWord: true})
assert(found == null)
})
it('does not match without activation key', function() {
it('does not match without activation key', function () {
const found = query('cat', ':', 3, {multiWord: true})
assert(found == null)
})
it('matches only activation key', function() {
it('matches only activation key', function () {
const found = query(':', ':', 1, {multiWord: true})
assert.deepEqual(found, {text: '', position: 1})
})
it('matches trailing activation key', function() {
it('matches trailing activation key', function () {
const found = query('hi :', ':', 4, {multiWord: true})
assert.deepEqual(found, {text: '', position: 4})
})
it('matches start of text', function() {
it('matches start of text', function () {
const found = query(':cat', ':', 4, {multiWord: true})
assert.deepEqual(found, {text: 'cat', position: 1})
})
it('matches end of text', function() {
it('matches end of text', function () {
const found = query('hi :cat', ':', 7, {multiWord: true})
assert.deepEqual(found, {text: 'cat', position: 4})
})
it('matches middle of text', function() {
it('matches middle of text', function () {
const found = query('hi :cat bye', ':', 7, {multiWord: true})
assert.deepEqual(found, {text: 'cat', position: 4})
})
it('matches only at word boundary', function() {
it('matches only at word boundary', function () {
const found = query('hi:cat', ':', 6, {multiWord: true})
assert(found == null)
})
it('matches last activation key word', function() {
it('matches last activation key word', function () {
const found = query('hi :cat bye :dog', ':', 16, {multiWord: true})
assert.deepEqual(found, {text: 'dog', position: 13})
})
it('matches closest activation key word', function() {
it('matches closest activation key word', function () {
const found = query('hi :cat bye :dog', ':', 7, {multiWord: true})
assert.deepEqual(found, {text: 'cat', position: 4})
})
it('matches with a space between cursor and activation key', function() {
it('matches with a space between cursor and activation key', function () {
const found = query('hi :cat bye', ':', 11, {multiWord: true})
assert.deepEqual(found, {text: 'cat bye', position: 4})
})
it('does not match with a dot between cursor and activation key', function() {
it('does not match with a dot between cursor and activation key', function () {
const found = query('hi :cat. bye', ':', 11, {multiWord: true})
assert(found == null)
})
it('does not match with a space between text and activation key', function() {
it('does not match with a space between text and activation key', function () {
const found = query('hi : cat bye', ':', 7, {multiWord: true})
assert(found == null)
})
})
describe('text-expander multi word parsing with multiple activation keys', function() {
it('does not match consecutive activation keys', function() {
describe('text-expander multi word parsing with multiple activation keys', function () {
it('does not match consecutive activation keys', function () {
let found = query('::', ':', 2, {multiWord: true})
assert(found == null)
@ -145,7 +145,7 @@ describe('text-expander multi word parsing with multiple activation keys', funct
assert(found == null)
})
it('uses lastMatchPosition to match', function() {
it('uses lastMatchPosition to match', function () {
let found = query('hi :cat :bye', ':', 12, {multiWord: true, lastMatchPosition: 4})
assert.deepEqual(found, {text: 'cat :bye', position: 4})
@ -157,13 +157,13 @@ describe('text-expander multi word parsing with multiple activation keys', funct
})
})
describe('text-expander limits the lookBack after commit', function() {
it('does not match if lookBackIndex is bigger than activation key index', function() {
describe('text-expander limits the lookBack after commit', function () {
it('does not match if lookBackIndex is bigger than activation key index', function () {
const found = query('hi :cat bye', ':', 11, {multiWord: true, lookBackIndex: 7})
assert(found == null)
})
it('matches if lookBackIndex is lower than activation key index', function() {
it('matches if lookBackIndex is lower than activation key index', function () {
const found = query('hi :cat bye :dog', ':', 16, {multiWord: true, lookBackIndex: 7})
assert(found, {text: 'dog', position: 13})
})

Просмотреть файл

@ -1,19 +1,19 @@
describe('text-expander element', function() {
describe('element creation', function() {
it('creates from document.createElement', function() {
describe('text-expander element', function () {
describe('element creation', function () {
it('creates from document.createElement', function () {
const el = document.createElement('text-expander')
assert.equal('TEXT-EXPANDER', el.nodeName)
assert(el instanceof window.TextExpanderElement)
})
it('creates from constructor', function() {
it('creates from constructor', function () {
const el = new window.TextExpanderElement()
assert.equal('TEXT-EXPANDER', el.nodeName)
})
})
describe('after tree insertion', function() {
beforeEach(function() {
describe('after tree insertion', function () {
beforeEach(function () {
const container = document.createElement('div')
container.innerHTML = `
<text-expander keys=": @ [[">
@ -23,11 +23,11 @@ describe('text-expander element', function() {
document.body.append(container)
})
afterEach(function() {
afterEach(function () {
document.body.innerHTML = ''
})
it('has activation keys', function() {
it('has activation keys', function () {
const expander = document.querySelector('text-expander')
assert.deepEqual(
[
@ -39,7 +39,7 @@ describe('text-expander element', function() {
)
})
it('dispatches change event', async function() {
it('dispatches change event', async function () {
const expander = document.querySelector('text-expander')
const input = expander.querySelector('textarea')
const result = once(expander, 'text-expander-change')
@ -49,7 +49,7 @@ describe('text-expander element', function() {
assert.equal(':', key)
})
it('dismisses the menu when dismiss() is called', async function() {
it('dismisses the menu when dismiss() is called', async function () {
const expander = document.querySelector('text-expander')
const input = expander.querySelector('textarea')
const menu = document.createElement('ul')
@ -70,7 +70,7 @@ describe('text-expander element', function() {
assert.isNull(expander.querySelector('ul'))
})
it('dispatches change events for 2 char activation keys', async function() {
it('dispatches change events for 2 char activation keys', async function () {
const expander = document.querySelector('text-expander')
const input = expander.querySelector('textarea')
@ -92,8 +92,8 @@ describe('text-expander element', function() {
})
})
describe('multi-word scenarios', function() {
beforeEach(function() {
describe('multi-word scenarios', function () {
beforeEach(function () {
const container = document.createElement('div')
container.innerHTML = `
<text-expander keys="@ # [[" multiword="# [[">
@ -103,11 +103,11 @@ describe('text-expander element', function() {
document.body.append(container)
})
afterEach(function() {
afterEach(function () {
document.body.innerHTML = ''
})
it('has activation keys', function() {
it('has activation keys', function () {
const expander = document.querySelector('text-expander')
assert.deepEqual(
[
@ -119,7 +119,7 @@ describe('text-expander element', function() {
)
})
it('dispatches change event for multi-word', async function() {
it('dispatches change event for multi-word', async function () {
const expander = document.querySelector('text-expander')
const input = expander.querySelector('textarea')
const result = once(expander, 'text-expander-change')
@ -130,7 +130,7 @@ describe('text-expander element', function() {
assert.equal('some text', text)
})
it('dispatches change events for 2 char activation keys for multi-word', async function() {
it('dispatches change events for 2 char activation keys for multi-word', async function () {
const expander = document.querySelector('text-expander')
const input = expander.querySelector('textarea')
@ -152,7 +152,7 @@ describe('text-expander element', function() {
assert.deepEqual(receivedText, expectedText)
})
it('dispatches change event for single word match after multi-word', async function() {
it('dispatches change event for single word match after multi-word', async function () {
const expander = document.querySelector('text-expander')
const input = expander.querySelector('textarea')
const result = once(expander, 'text-expander-change')
@ -163,7 +163,7 @@ describe('text-expander element', function() {
assert.equal('match', text)
})
it('dispatches change event for multi-word with single word inside', async function() {
it('dispatches change event for multi-word with single word inside', async function () {
const expander = document.querySelector('text-expander')
const input = expander.querySelector('textarea')
const result = once(expander, 'text-expander-change')
@ -174,7 +174,7 @@ describe('text-expander element', function() {
assert.equal('some text @match word', text)
})
it('dispatches change event for the first activation key even if it is typed again', async function() {
it('dispatches change event for the first activation key even if it is typed again', async function () {
const expander = document.querySelector('text-expander')
const input = expander.querySelector('textarea')

Просмотреть файл

@ -1,33 +1,33 @@
import textFieldMirror from '../dist/text-field-mirror'
describe('textFieldMirror', function() {
describe('textFieldMirror', function () {
let textarea
let input
beforeEach(function() {
beforeEach(function () {
textarea = document.createElement('textarea')
input = document.createElement('input')
input.type = 'text'
document.body.append(textarea, input)
})
afterEach(function() {
afterEach(function () {
document.body.innerHTML = ''
})
it('create mirror for textarea', function() {
it('create mirror for textarea', function () {
const {mirror, marker} = textFieldMirror(textarea)
assert.ok(mirror)
assert.ok(marker)
})
it('create mirror for text input', function() {
it('create mirror for text input', function () {
const {mirror, marker} = textFieldMirror(input)
assert.ok(mirror)
assert.ok(marker)
})
it('returns an Element attached to the DOM', function() {
it('returns an Element attached to the DOM', function () {
let {mirror: ancestor} = textFieldMirror(textarea)
while (ancestor.parentNode) {
ancestor = ancestor.parentNode
@ -35,11 +35,11 @@ describe('textFieldMirror', function() {
assert.equal(ancestor, document)
})
it('returns the same Element on multiple calls', function() {
it('returns the same Element on multiple calls', function () {
assert.equal(textFieldMirror(textarea).mirror, textFieldMirror(textarea).mirror)
})
it('returns a new Element when the old mirror is detached from the DOM', function() {
it('returns a new Element when the old mirror is detached from the DOM', function () {
const {mirror} = textFieldMirror(textarea)
mirror.parentNode.removeChild(mirror)
assert.notEqual(textFieldMirror(textarea).mirror, mirror)

Просмотреть файл

@ -18,17 +18,17 @@ function textareaContentsHeight(textarea) {
return height
}
describe('textareaContentsHeight', function() {
describe('textareaContentsHeight', function () {
let field
beforeEach(function() {
beforeEach(function () {
document.body.innerHTML = `
<textarea style="height: 40px; width: 395px;"></textarea>
`
field = document.querySelector('textarea')
})
afterEach(function() {
afterEach(function () {
document.body.innerHTML = ''
})
@ -38,17 +38,17 @@ Lorem ipsum dolor sit amet, id vel assum aeterno fierent. Ad ipsum expetendis vi
Duo id facer facete nonumes, vim no accusata dissentiet. Cum paulo delectus platonem no. Mea in latine virtute theophrastus, te minim blandit per. Vel idque homero in, vix scripta pertinax ea, eu ius delenit commune pertinacia. Noluisse voluptua invidunt ea his, id has graece maiestatis complectitur, vix cetero officiis apeirian te. Ut velit epicurei duo, vel possim aeterno convenire ei.
`
it('height of empty textarea', function() {
it('height of empty textarea', function () {
assert.equal(0, textareaContentsHeight(field))
})
it('height of single line textarea', function() {
it('height of single line textarea', function () {
field.value = 'Hello, World!'
const height = textareaContentsHeight(field)
assert.ok(13 <= height && height <= 21, height)
})
it('height of multiline textarea', function() {
it('height of multiline textarea', function () {
field.value = slipsum
const height = textareaContentsHeight(field)
assert.ok(150 <= height && height <= 400, height)