Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@github/text-expander-element

Package Overview
Dependencies
Maintainers
14
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@github/text-expander-element

Activates a suggestion menu to expand text snippets as you type.

  • 0.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
453
decreased by-85.42%
Maintainers
14
Weekly downloads
 
Created
Source

<text-expander> element

Activates a suggestion menu to expand text snippets as you type.

Installation

$ npm install --save @github/text-expander-element

Usage

import '@github/text-expander-element'
<text-expander keys=": @ #">
  <textarea></textarea>
</text-expander>

Attributes

  • keys is a space separated list of menu activation keys

Events

const expander = document.querySelector('text-expander')

expander.addEventListener('text-expander-change', function(event) {
  const {key, provide} = event.detail
  if (key === ':') {
    const menu = document.createElement('ul')
    const item = document.createElement('li')
    item.textContent = '🐈'
    item.role = 'option'
    menu.append(item)
    provide(Promise.resolve({matched: true, fragment: menu}))
  }
})

expander.addEventListener('text-expander-value', function(event) {
  const {key, item}  = event.detail
  if (key === ':') {
    event.detail.value = '🐈'
  }
})

Browser support

Browsers without native custom element support require a polyfill.

  • Chrome
  • Firefox
  • Safari
  • Microsoft Edge

Development

npm install
npm test

License

Distributed under the MIT license. See LICENSE for details.

Keywords

FAQs

Package last updated on 12 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc