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

trix

Package Overview
Dependencies
Maintainers
2
Versions
56
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

  • 0.9.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
193K
decreased by-2.14%
Maintainers
2
Weekly downloads
 
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 13 Apr 2016

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