New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

textarea-code

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

textarea-code

Web Component that extends a textarea element with code editor behavior.

latest
Source
npmnpm
Version
4.0.1
Version published
Maintainers
1
Created
Source

textarea-code

Web Component that extends a textarea element with code editor behavior.

npm i textarea-code pnpm add textarea-code yarn add textarea-code

Examples

# web

    Try it live

    # view source example/web.ts

    import { TextAreaCodeElement } from 'textarea-code'
    
    customElements.define('textarea-code', TextAreaCodeElement, {
      extends: 'textarea',
    })
    
    document.body.innerHTML = /*html*/ `
    <style>
      html,
      body {
        width: 100%;
        height: 100%;
        padding: 0;
        margin: 0;
      }
    
      body,
      textarea {
        background: #292827;
        color: #fff;
        caret-color: #fff;
      }
    
      textarea {
        font-family: monospace;
        font-size: 10pt;
        line-height: 16px;
        padding: 0;
        margin: 0;
      }
    </style>
    <textarea id="output" is="textarea-code" rows="15" cols="60" tab-size="2" tab-style="spaces"></textarea>
    `
    
    const output = document.getElementById('output') as TextAreaCodeElement
    
    output.textContent = `\
    if (e.altKey || (cmdKey && e.shiftKey)) {
      if (['ArrowUp', 'ArrowDown', 'PageUp', 'PageDown'].includes(e.key)) {
        e.preventDefault()
        this.buffer.moveLines(
          {
            ArrowUp: -1,
            ArrowDown: 1,
            PageUp: -this.pageSize,
            PageDown: this.pageSize,
          }[e.key as 'ArrowUp']
        )
        return
      }
    }
    `
    

API

# Buffer src/buffer.ts#L19
# TextAreaCodeElement src/textarea-code.ts#L10
# Options src/buffer.ts#L11
# Point src/types.ts#L3
# SelectionDirection src/types.ts#L1

    "forward" | "backward" | "none"

Credits

  • sigl by stagas – Web framework

Contributing

Fork or edit and submit a PR.

All contributions are welcome!

License

MIT © 2022 stagas

Keywords

textarea

FAQs

Package last updated on 03 Aug 2022

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