All Projects → alioguzhan → React Editext

alioguzhan / React Editext

Licence: mit
Editable Text Component for React Apps

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Editext

Smith
A simple text editor written in Rust
Stars: ✭ 141 (-29.15%)
Mutual labels:  text-editor
Brackeys Ide
👨‍💻 Brackeys IDE is a fast and free multi-language code editor for Android.
Stars: ✭ 154 (-22.61%)
Mutual labels:  text-editor
Dred
A fast, lightweight text editor.
Stars: ✭ 186 (-6.53%)
Mutual labels:  text-editor
Lintalist
Searchable interactive texts to copy & paste text, run scripts, using easily exchangeable bundles
Stars: ✭ 147 (-26.13%)
Mutual labels:  text-editor
Pell
📝 the simplest and smallest WYSIWYG text editor for web, with no dependencies
Stars: ✭ 11,653 (+5755.78%)
Mutual labels:  text-editor
Ngx Wig
Angular(...Angular 7, Angular 8, Angular 9, Angular 10, Angular 11) WYSIWYG HTML Rich Text Editor (from ngWig - https://github.com/stevermeister/ngWig)
Stars: ✭ 178 (-10.55%)
Mutual labels:  text-editor
Neo Mc
A Midnight Commander fork with scripting and other features.
Stars: ✭ 129 (-35.18%)
Mutual labels:  text-editor
Slate Plugins
A set of my personal Slate editor plugins, in a monorepo.
Stars: ✭ 191 (-4.02%)
Mutual labels:  text-editor
Vue Trix
Trix text editor component for Vue.js
Stars: ✭ 159 (-20.1%)
Mutual labels:  text-editor
Ci edit
A terminal text editor with mouse support and ctrl+Q to quit.
Stars: ✭ 183 (-8.04%)
Mutual labels:  text-editor
Lime Qml
QML frontend for LimeText
Stars: ✭ 150 (-24.62%)
Mutual labels:  text-editor
Oni
Oni: Modern Modal Editing - powered by Neovim
Stars: ✭ 11,466 (+5661.81%)
Mutual labels:  text-editor
Nib
Wysiwyg / Text editor components built using React and Prosemirror
Stars: ✭ 181 (-9.05%)
Mutual labels:  text-editor
Acme2k
acme2k - text editor fo' all the cool cats who ain't 'fraid of no mice
Stars: ✭ 143 (-28.14%)
Mutual labels:  text-editor
Abricotine
Markdown editor with inline preview
Stars: ✭ 2,308 (+1059.8%)
Mutual labels:  text-editor
Proton
A stand-alone application to quickly preview and edit Markdown files using Electron.
Stars: ✭ 140 (-29.65%)
Mutual labels:  text-editor
Bim
small terminal text editor with syntax highlighting
Stars: ✭ 174 (-12.56%)
Mutual labels:  text-editor
Sapling
A highly experimental vi-inspired editor where you edit code, not text.
Stars: ✭ 195 (-2.01%)
Mutual labels:  text-editor
Blindpad
Collaborative text editor (like Google Docs or CoderPad) with integrated semi-anonymizing voice chat intended to help reduce bias in technical communication.
Stars: ✭ 191 (-4.02%)
Mutual labels:  text-editor
Qmarkdowntextedit
A C++ Qt QPlainTextEdit widget with markdown highlighting support and a lot of other extras
Stars: ✭ 182 (-8.54%)
Mutual labels:  text-editor

react-editext

Editable Text Component for React Applications

NPM npm Github codecov Quality Gate Status All Contributors

Install

npm install --save react-editext

Or with yarn:

yarn add react-editext

Usage

EdiText is highly customizable. You can see more examples here. Here is a basic usage:

import React, { useState } from 'react'

import EdiText from 'react-editext'

function Example(props) {
  const [value, setValue] = useState('What is real? How do you define real?')

  const handleSave = val => {
    console.log('Edited Value -> ', val)
    setValue(val)
  }
  return (
      <div className="container">
        <EdiText
          type="text"
          value={value}
          onSave={handleSave}
        />
      </div>
    )
}

There is also a codesandbox template that you can fork and play with it:

Edit react-editext-template

You can customize almost everything based on your needs. Please navigate to Props section. I mean, just scroll down.

Props

Prop Type Required Default Note
value string Yes '' Value of the content and input [in edit mode]
type string Yes text Input type. Possible options are: text, password, number, email, textarea, date, datetime-local, time, month, url, week, tel
hint node No '' A simple hint message appears at the bottom of input element. Any valid element is allowed.
onSave function Yes Function will be called when save button clicked. value and inputProps are passed to cb.
inputProps object No Props to be passed to input element. Any kind of valid DOM attributes are welcome.
viewProps object No Props to be passed to div element that shows the text. You can specify your own styles or className
validation function No Pass your own validation function. takes one param -> value. It must return true or false
validationMessage node No Invalid Value If validation fails this message will appear
onValidationFail function No Pass your own function to track when validation failed. See Examples page for the usage.
onCancel function No Function will be called when editing is cancelled. value and inputProps are passed as params.
saveButtonContent node No '' Content for save button. Any valid element is allowed. Default is: ✓
cancelButtonContent node No '' Content for cancel button. Any valid element is allowed. Default is: ✕
editButtonContent node No '' Content for edit button. Any valid element is allowed. Default is: ✎
saveButtonClassName string No Custom class name for save button.
cancelButtonClassName string No Custom class name for cancel button.
editButtonClassName string No Custom class name for edit button.
viewContainerClassName string No Custom class name for the container in view mode.See here
editContainerClassName string No Custom class name for the container in edit mode. Will be set to viewContainerClassName if you set it and omit this. See here
mainContainerClassName string No Custom class name for the top-level main container. See here
hideIcons bool No false Set it to true if you don't want to see default icons on action buttons. See Examples page for more details.
buttonsAlign string No after Set this to before if you want to locate action buttons before the input instead of after it. See here.
editOnViewClick bool No false Set it to true if you want clicking on the view to activate the editor.
editing bool No false Set it to true if you want the view state to be edit mode.
onEditingStart function No Function that will be called when the editing mode is active. See here
showButtonsOnHover bool No false Set it to true if you want to display action buttons only when the text hovered by the user. See here
submitOnEnter bool No false Set it to true if you want to submit the form when Enter is pressed. Be careful if you have multiple instances of <EdiText/> on the same page.
cancelOnEscape bool No false Set it to true if you want to cancel the form when Escape is pressed. See here
cancelOnUnfocus bool No false Set it to true if you want to cancel the form when clicked outside of the input. See here
submitOnUnfocus bool No false Set it to true if you want to submit the form when clicked outside of the input. See here
startEditingOnFocus bool No false Activates the edit mode when the view container is in focus. See here
startEditingOnEnter bool No false Activates the edit mode when the Enter key is pressed. See here
tabIndex number No An helper shortcut in case you want to pass the same tabIndex to both viewProps and inputProps.

Styling with styled-components

You can style your <EdiText/> components with styled-components or similar libraries. You can either target internal HTML elements by their type ( or order) , or you can select them by attribute values.

Each customizable HTML element has a editext=xxx attribute. Use below as a reference table:

Attr. Value Description
view-container the container in view mode
edit-container the container in edit mode
button-container the container for the save and cancel buttons
edit-button use this to style the edit button
save-button use this to style the save button
cancel-button use this to style the cancel button
input There is only one input. You can select it directly or just use this attr value.
hint To style the hint container.

Usage:

 button[editext="cancel-button"] {
    &:hover {
      background: crimson;
      color: #fff;
    }
  }

  div[editext="view-container"] {
    background: #6293C3;
    padding: 15px;
    border-radius: 5px;
    color: #fff;
  }

  input, textarea { /** or input[editext="input"] {} */
    background: #1D2225;
    color: #F4C361;
    font-weight: bold;
    border-radius: 5px;
  }

See the example code.

Browser Support

ChromeChrome FirefoxFirefox SafariSafari iOS SafariiOS Safari OperaOpera IE / EdgeIE / Edge
✅ ❗️
  • rows prop for textarea has no effect in IE/Edge. You can set its height with some css.

Contributors ✨

Thanks goes to these wonderful people (emoji key):


alioguzhan

💻 📖

jdoklovic

💻

Obed Castillo

💻

Bruno Aderaldo

🐛 💻

Sascha Kiefer

💬 🤔

Ehab Alsharif

💻 📖

Harsha N Hegde

🐛 💻

Justin Kuntz

🤔 🐛

Braulio Soncco

🤔

zig

🐛

Isaiah Taylor

🤔

anz000

🤔

Amir M

🤔

Harshil Parmar

📖

Brandon Paris

🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT © alioguzhan

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].