All Projects → abhaynikam → react-trix-rte

abhaynikam / react-trix-rte

Licence: MIT license
React wrapper for Trix rich text editor created by Basecamp

Programming Languages

javascript
184084 projects - #8 most used programming language
SCSS
7915 projects

Projects that are alternatives of or similar to react-trix-rte

django-trix
Basecamp's Trix rich text editor widget for Django
Stars: ✭ 46 (-30.3%)
Mutual labels:  trix, trix-editor
striven-editor
The editor used in the Striven ERP system.
Stars: ✭ 14 (-78.79%)
Mutual labels:  rich-text-editor
React Text Selection Popover
Selection based Text UI made easy
Stars: ✭ 245 (+271.21%)
Mutual labels:  rich-text-editor
cm-page-builder
Page builder package like notion
Stars: ✭ 29 (-56.06%)
Mutual labels:  rich-text-editor
Ngx Editor
🖋️ Rich Text Editor for angular using ProseMirror
Stars: ✭ 251 (+280.3%)
Mutual labels:  rich-text-editor
ember-pell
Ember addon for simplest and smallest (1kB) WYSIWYG text editor for web, with no dependencies
Stars: ✭ 56 (-15.15%)
Mutual labels:  rich-text-editor
Mui Rte
Material-UI Rich Text Editor and Viewer
Stars: ✭ 233 (+253.03%)
Mutual labels:  rich-text-editor
bside
Github Content Management System
Stars: ✭ 22 (-66.67%)
Mutual labels:  rich-text-editor
ray
HTML-powered text editor for creating and organizing personal notes.
Stars: ✭ 115 (+74.24%)
Mutual labels:  rich-text-editor
wysiwyg-editor-python-sdk
Python SDK to ease the integration of Froala WYSIWYG Editor on server side.
Stars: ✭ 20 (-69.7%)
Mutual labels:  rich-text-editor
basecampy3
A Python API for Basecamp 3
Stars: ✭ 31 (-53.03%)
Mutual labels:  basecamp
Textbus
基于组件 + 数据驱动的现代富文本编辑器
Stars: ✭ 242 (+266.67%)
Mutual labels:  rich-text-editor
ngx-wall
Helps build content editor for note-taking application
Stars: ✭ 78 (+18.18%)
Mutual labels:  rich-text-editor
Czi Prosemirror
Rich Text Editor built with React and ProseMirror
Stars: ✭ 247 (+274.24%)
Mutual labels:  rich-text-editor
osx-trix
Handy Patches, Fixes, Tips and Tricks for Apples OS X Platform
Stars: ✭ 29 (-56.06%)
Mutual labels:  trix
Slate Collaborative
slatejs collaborative plugin & microservice https://slate-collaborative.herokuapp.com/
Stars: ✭ 236 (+257.58%)
Mutual labels:  rich-text-editor
basecamp-linux
Unofficial Basecamp GNU/Linux desktop client
Stars: ✭ 32 (-51.52%)
Mutual labels:  basecamp
artibox
Artibox - A complete rich text editor based on Slate framework.
Stars: ✭ 21 (-68.18%)
Mutual labels:  rich-text-editor
iOS-HTMLTextEditor
A simple implementation of an HTML Editor using CKEditor in a web view.
Stars: ✭ 57 (-13.64%)
Mutual labels:  rich-text-editor
live-editor
Real-time collaboration editing service with integrated editor component.
Stars: ✭ 35 (-46.97%)
Mutual labels:  rich-text-editor

React Trix RTE

NPM GitHub Workflow Status npm

React Trix rich text editor is react wrapper built for the Trix editor created by Basecamp. We have built this library because we were rewriting the same component in multiple project.

This wrapper uses React hooks and adds readable event listeners on the Trix editor. The library also adds two toolbar components which has the ability to customize the toolbar actions as per our need.

Demo

Please see the some live example on ReactTrixRTE-Storybook

ReactTrixRTE

Installation

To install the React Trix RTE, run the following command in the console.

npm install react-trix-rte
OR
yarn add react-trix-rte

Usage

import Trix from "trix";
import React, { useState } from "react";
import { ReactTrixRTEInput } from "react-trix-rte";

export default function TrixEditor(props) {
  const [value, setValue] = useState("");

  function handleChange(event, newValue) {
    setValue(newValue); // OR custom on change listener.
  }

  return (
    <ReactTrixRTEInput
      defaultValue="<div>React Trix Rich Text Editor</div>"
      onChange={handleChange}
    />
  )
}

Upgrading to 1.0.7 or higher

React Trix RTE version 1.0.7 removes the dependency import for Trix because using Trix outside directly causes problems. Read issue: 17 and 19.

Import import Trix from "trix"; to the component using React Trix RTE.

ReactTrixInput API

ReactTrixInput is the Trix editor input which by default comes with the toolbar. The ReactTrixInput comes with following properties that could be accepted.

Name Type Description
id string The HTML id attribute for the input field
name string The HTML name attribute for the input field
toolbarId string If a custom toolbar is used for the Trix Input, pass the toolbarId of the custom toolbar to the input.
isRailsDirectUpload boolean React Trix editor support direct uploading of the files to the service if you are using Rails as a backend server. This defaults to false
railsDirectUploadUrl string Custom URL for Rails direct upload (data-direct-upload-url)
railsBlobUrl string Custom URL for Rails blob template (data-blob-url-template)
placeholder string Adds a placeholder to the React Trix Input
defaultValue string The default value of the React Trix Input
autofocus boolean Autofocus in the trix input. This is defaults to false
className string Apply a custom css class to the editor
trixInputRef function Adds a custom ref to the React Trix Input to programmatically edit text. Read the documentation for manual things you can perform on Trix editor here
onBeforeInitialize function Fires when the <trix-editor> element is attached to the DOM just before Trix installs its editor object.
onInitialize function Fires when the <trix-editor> element is attached to the DOM and its editor object is ready for use.
onChange function Fires whenever the editor’s contents have changed.
onSelectionChange function Fires any time the selected range changes in the editor.
onBlur function Fire when the editor loses focus.
onFocus function Fire when the editor gains focus.
onFileAccepted function Fires when a file is dropped or inserted into the editor. You can access the DOM File object through the file property on the event. Call preventDefault on the event to prevent attaching the file to the document.
onAttachmentAdd function Fires after an attachment is added to the document. You can access the Trix attachment object through the attachment property on the event. If the attachment object has a file property, you should store this file remotely and set the attachment’s URL attribute. See the attachment example for detailed information.
onAttachmentRemove function Fires when an attachment is removed from the document. You can access the Trix attachment object through the attachment property on the event. You may wish to use this event to clean up remotely stored files.

ReactTrixRTEToolbar API

ReactTrixRTEToolbar is the custom Trix editor toolbar component. This component helps in customizing the toolbar options, classes and attributes in better way.

Name Type Description
toolbarId string The ReactTrixInput initialize the default toolbar if the toolbarId is missing or not matching. Make sure the toolbarId matches.
disableGroupingAction boolean Defaults to false. If the disableGroupingAction is enabled the toolbar actions are not grouped for a type. Example: text tools won't be grouped
toolbarActions array Allows customizing the list of toolbar actions. The available actions are ["bold", "italic", "strike", "link", "heading1", "quote", "code", "bullet", "number", "outdent", "indent", "attachFiles", "undo", "redo"].
customToolbarActions object Override the toolbar actions properties or add custom toolbar actions. You can refer to default toolbar actions options

Custom Toolbar Usage

import React, { useState } from "react";
import Trix from "trix";
import { ReactTrixRTEInput, ReactTrixRTEToolbar } from "react-trix-rte";

export default function TrixEditor(props) {
  const [value, setValue] = useState("");

  function handleChange(event, newValue) {
    setValue(newValue); // OR custom on change listener.
  }

  return (
    <Fragment>
      <ReactTrixRTEToolbar toolbarId="react-trix-rte-editor" />
      <ReactTrixRTEInput
        toolbarId="react-trix-rte-editor"
        defaultValue="<div>React Trix Rich Text Editor</div>"
        onChange={handleChange}
      />
    </Fragment>
  )
}

Contributing

Read more about contributing to the ReactTrixRTE.

Author

Abhay Nikam

Contributor

CUnknown

License

This project is licensed under the MIT License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].