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

trix

Package Overview
Dependencies
Maintainers
0
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

trix

A rich text editor for everyday writing

  • 2.1.10
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
0
Created

What is trix?

Trix is a rich text editor for everyday writing. It is designed to provide a simple and intuitive interface for creating and editing text content, with support for formatting, embedding media, and more.

What are trix's main functionalities?

Basic Text Formatting

This feature allows users to apply basic text formatting such as bold, italic, and underline. The code sample demonstrates how to initialize the Trix editor and insert bold text.

document.addEventListener('trix-initialize', function(event) {
  var editor = event.target.editor;
  editor.insertString('Hello, world!');
  editor.activateAttribute('bold');
  editor.insertString(' This is bold text.');
});

Embedding Media

This feature allows users to embed media such as images and videos into the text editor. The code sample demonstrates how to handle file attachments and embed them as data URLs.

document.addEventListener('trix-attachment-add', function(event) {
  var attachment = event.attachment;
  if (attachment.file) {
    var reader = new FileReader();
    reader.onload = function() {
      attachment.setAttributes({ url: reader.result });
    };
    reader.readAsDataURL(attachment.file);
  }
});

Custom Toolbar Buttons

This feature allows users to add custom buttons to the Trix editor toolbar. The code sample demonstrates how to add a custom 'Strike' button to the toolbar.

document.addEventListener('trix-initialize', function(event) {
  var buttonHTML = '<button type="button" class="trix-button" data-trix-attribute="strike">Strike</button>';
  var toolbar = event.target.toolbarElement;
  toolbar.querySelector('.trix-button-group--text-tools').insertAdjacentHTML('beforeend', buttonHTML);
});

Other packages similar to trix

Keywords

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

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