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

edit-element

Package Overview
Dependencies
Maintainers
0
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edit-element

A lightweight and flexible JavaScript/TypeScript library for adding in-place editing functionality to HTML elements.

latest
npmnpm
Version
2.0.1
Version published
Maintainers
0
Created
Source

edit-element

A lightweight and flexible JavaScript/TypeScript library for adding in-place editing functionality to HTML elements.

Features

  • 🖊️ Make any HTML element in-place editable
  • ⚙️ CSM and ESM and TypeScript support
  • ⌨️ Configurable editing classname and submit shortcut key
  • ♿ Built-in accessibility support
  • 🔧 Flexible event callbacks

Installation

npm install edit-element

Basic Usage

import { EditElement } from 'edit-element';

// Make all elements with .editable class in-place editable
const editableElements = new EditElement('.editable');

Advanced Usage

import EditElement from 'edit-element';

// Make all elements with .editable class editable
const editableElements = new EditElement('.editable', {
  onEnter: (element) => {
    console.log('Editing started', element);
  },
  onSubmit: (element) => {
    console.log('Edit submitted', element.textContent);
  },
  onLeave: (element) => {
    console.log('Editing ended', element);
  },
  editingElementClassName: 'editing',
  submitKey: 'Enter',
});

Configuration Options

Options Interface

PropertyTypeRequiredDefaultDescription
onEnter(element: HTMLElement) => voidOptionalundefinedCallback function when editing starts
onSubmit(element: HTMLElement) => voidOptionalundefinedCallback function when edit is submitted
onLeave(element: HTMLElement) => voidOptionalundefinedCallback function when editing ends
editingElementClassNamestringOptionalundefinedCSS class name added during editing
submitKeystringOptional'Enter'Key to trigger submission

Methods

destroyAllEditable()

Remove all editable elements.

editableElements.destroyAllEditable();

destroyTargetEditable(selector: string)

Remove all editable elements by matching the specific querySelector query.

editableElements.destroyTargetEditable('.specific-editable');

License

MIT License

Contributing

Issues and pull requests are welcome!

FAQs

Package last updated on 09 Dec 2024

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