Giter Site home page Giter Site logo

webscopeio / react-textarea-autocomplete Goto Github PK

View Code? Open in Web Editor NEW
450.0 14.0 80.0 1.07 MB

πŸ“ React component implements configurable GitHub's like textarea autocomplete.

License: MIT License

JavaScript 97.76% CSS 1.61% HTML 0.27% Shell 0.36%
react textarea autocomplete

react-textarea-autocomplete's Introduction

react-textarea-autocomplete πŸ“

Enhanced textarea to achieve autocomplete functionality.

MIT License PRs Welcome All Contributors npm




This package provides React Component to achieve GitHub's like functionality in comments regarding the textarea autocomplete. It can be used for example for emoji autocomplete or for @mentions. The render function (for displaying text enhanced by this textarea) is beyond the scope of this package and it should be solved separately.

Browsers support

IE / Edge
IE / Edge
Firefox
Firefox
Chrome
Chrome
Safari
Safari
iOS Safari
iOS Safari
Samsung
Samsung
Opera
Opera
IE11, Edge last 2 versions last 2 versions last 2 versions last 2 versions last 2 versions last 2 versions

Installation

This module is distributed via npm and should be installed as one of your project's dependencies:

yarn add @webscopeio/react-textarea-autocomplete

or there is UMD build available. Check out this pen as example.

This package also depends on react and prop-types. Please make sure you have those installed as well.

Props

☝️ Note: Every other props than the mentioned below will be propagated to the textarea itself

Props Type Description
trigger* Object: Trigger type Define triggers and their corresponding behavior
loadingComponent* React Component Gets data props which is already fetched (and displayed) suggestion
innerRef Function: (HTMLTextAreaElement) => void) Allows you to get React ref of the underlying textarea
scrollToItem boolean | (container: HTMLDivElement, item: HTMLDivElement) => void) Defaults to true. With default implementation it will scroll the dropdown every time when the item gets out of the view.
minChar Number Number of characters that user should type for trigger a suggestion. Defaults to 1.
onCaretPositionChange Function: (number) => void Listener called every time the textarea's caret position is changed. The listener is called with one attribute - caret position denoted by an integer number.
movePopupAsYouType boolean When it's true the textarea will move along with a caret as a user continues to type. Defaults to false.
boundariesElement string | HTMLElement Element which should prevent autocomplete to overflow. Defaults to body.
textAreaComponent React.Component | {component: React.Component, ref: string} What component use for as textarea. Default is textarea. (You can combine this with react-autosize-textarea for instance)
renderToBody boolean When set to true the autocomplete will be rendered at the end of the <body>. Default is false.
onItemHighlighted ({currentTrigger: string |Β null, item: string | Object | null}) => void Callback get called everytime item is highlighted in the list
onItemSelected ({currentTrigger: string, item: string | Object}) => void Callback get called everytime item is selected
style Style Object Style's of textarea
listStyle Style Object Styles of list's wrapper
itemStyle Style Object Styles of item's wrapper
loaderStyle Style Object Styles of loader's wrapper
containerStyle Style Object Styles of textarea's container
dropdownStyle Style Object Styles of dropdown's wrapper
className string ClassNames of the textarea
containerClassName string ClassNames of the textarea's container
listClassName string ClassNames of list's wrapper
itemClassName string ClassNames of item's wrapper
loaderClassName string ClassNames of loader's wrapper
dropdownClassName string ClassNames of dropdown's wrapper

*are mandatory

Methods

The methods below can be called on the React component's ref (see: React Docs)

Methods Description
getCaretPosition() : number Gets the current caret position in the textarea
setCaretPosition(position : number) : void Sets the caret position to the integer value passed as the argument
getSelectionPosition(): {selectionStart: number, selectionEnd: number} Returns selectionStart and selectionEnd of the textarea
getSelectedText(): ?string Returns currently selected word

Example:

import React, { Component } from "react";
import ReactTextareaAutocomplete from "@webscopeio/react-textarea-autocomplete";

class App extends Component {
  onCaretPositionChange = (position) => {
    console.log(`Caret position is equal to ${position}`);
  }

  resetCaretPosition = () => {
    this.rta.setCaretPosition(0);
  }

  printCurrentCaretPosition = () => {
    const caretPosition = this.rta.getCaretPosition();
    console.log(`Caret position is equal to ${caretPosition}`);
  }

  render() {
    return (
      <div className="app">
        <div className="controls">
            <button onClick={this.resetCaretPosition}>Reset caret position</button>
            <button onClick={this.printCurrentCaretPosition}>Print current caret position to the console</button>
        </div>
        <ReactTextareaAutocomplete
          className="my-textarea"
          loadingComponent={() => <span>Loading</span>}
          trigger={{ ... }}
          ref={(rta) => { this.rta = rta; } }
          onCaretPositionChange={this.onCaretPositionChange}
        />
      </div>
    );
  }
}

export default App;

Trigger type

{
    [triggerChar: string]: {|
      output?: (
        item: Object | string,
        trigger?: string
      ) =>
        | {|
            key?: ?string,
            text: string,
            caretPosition: "start" | "end" | "next" | number
          |}
        | string | null,
      dataProvider: (
        token: string
      ) => Promise<Array<Object | string>> | Array<Object | string>,
      allowWhitespace?: boolean,
      afterWhitespace?: boolean,
      component: ReactClass<*>
    |},
}
  • dataProvider is called after each keystroke to get data what the suggestion list should display (array or promise resolving array)

  • component is the component for render the item in suggestion list. It has selected and entity props provided by React Textarea Autocomplete

  • allowWhitespace (Optional; defaults to false) Set this to true if you want to provide autocomplete for words (tokens) containing whitespace

  • afterWhitespace (Optional; defaults to false) Show autocomplete only if it's preceded by whitespace. Cannot be combined with allowWhitespace

  • output (Optional for string based item. If the item is an object this method is required) This function defines text which will be placed into textarea after the user makes a selection.

    You can also specify the behavior of caret if you return object {text: "item", caretPosition: "start"} the caret will be before the word once the user confirms his selection. Other possible value are "next", "end" and number, which is absolute number in contex of textarea (0 is equal position before the first char). Defaults to "next" which is space after the injected word.

    The default behavior for string based item is a string: <TRIGGER><ITEM><TRIGGER>). This method should always return a unique string, otherwise, you have to use object notation and specify your own key or return object from dataProvider with key property.

    In order to skip the text replace phase let's return null.

create-react-app example && cd example && yarn add @jukben/emoji-search @webscopeio/react-textarea-autocomplete

There is also UMD build available, check this CodePen for a proof.πŸ’ͺ

App.js

import React, { Component } from "react";
import ReactTextareaAutocomplete from "@webscopeio/react-textarea-autocomplete";
import emoji from "@jukben/emoji-search";

import logo from "./logo.svg";
import "./App.css";
import "@webscopeio/react-textarea-autocomplete/style.css";

const Item = ({ entity: { name, char } }) => <div>{`${name}: ${char}`}</div>;
const Loading = ({ data }) => <div>Loading</div>;

class App extends Component {
  render() {
    return (
      <div className="App">
        <div className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <h2>Welcome to React</h2>
        </div>

        <ReactTextareaAutocomplete
          className="my-textarea"
          loadingComponent={Loading}
          style={{
            fontSize: "18px",
            lineHeight: "20px",
            padding: 5
          }}
          ref={rta => {
            this.rta = rta;
          }}
          innerRef={textarea => {
            this.textarea = textarea;
          }}
          containerStyle={{
            marginTop: 20,
            width: 400,
            height: 100,
            margin: "20px auto"
          }}
          minChar={0}
          trigger={{
            ":": {
              dataProvider: token => {
                return emoji(token)
                  .slice(0, 10)
                  .map(({ name, char }) => ({ name, char }));
              },
              component: Item,
              output: (item, trigger) => item.char
            }
          }}
        />
      </div>
    );
  }
}

export default App;

Development

Run yarn to fetch dependencies.

Run yarn lint check ESlint check (yarn lint:fix for quick fix)

Run yarn flow for flow check

Run yarn test to run unit-tests powered by Jest

Dev playground (recommended)

Run yarn dev and open http://localhost:8080 for the playground

Run yarn cypress:open for open Cypress for E2E testing

Build and link

Run yarn build and yarn link then in your project folder (you have to use the same version of React e.g 15.6.1) yarn link react-textarea-autocomplete to link together.

Your PR's are welcomed! ❀️

Contributors

Maintainer

Jakub BeneΕ‘

Currently, I'm the only maintainer of this project. All related work I'm doing for is in my free time. If you like what I'm doing consider buy me a β˜•. I'd appreciated! ❀️

ko-fi

Also, I'd love to thank these wonderful people for their contribution (emoji key). You rock! πŸ’ͺ


Jakub BeneΕ‘

πŸ’» πŸ“– 🎨 πŸ€”

Andrey Taktaev

πŸ’»

Marcin LichwaΕ‚a

πŸ’» πŸ“–

Davidson Nascimento

πŸ’»

KajMagnus

πŸ› πŸ’»

JÑn VorčÑk

πŸ› πŸ’»

Mateusz BurzyΕ„ski

πŸ’» πŸ“¦

Deepak Pai

πŸ› πŸ’»

Aleck Landgraf

πŸ’»

Serguei Okladnikov

πŸ› πŸ’»

Michal Zochowski

πŸ› πŸ’»

Igor Sachivka

πŸ› πŸ’»

Andrew Shini

πŸ› πŸ’»

Rikesh Ramlochund

πŸ› πŸ’»

Matthew Hamilton

πŸ›

Danila

πŸ› πŸ’»

Silvio Di Stefano

πŸ’»

Jelte Fennema

πŸ› πŸ’»

Andy Pearson

πŸ› πŸ’»

Martin Kinkelin

πŸ› πŸ’»

Christopher Tempel

πŸ› πŸ’»

Louis Bourque

πŸ› πŸ’»

Samuel Bolduc

πŸ’»

Anukul Sangwan

πŸ’»

Hisham Mahmood

πŸ’»

Łukasz Nojek

πŸ’»

Tom Richards

πŸ’»

Jake Ho

πŸ’»

jwtong

πŸ›

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

License

MIT

react-textarea-autocomplete's People

Contributors

alecklandgraf avatar andarist avatar andypearson avatar anukul avatar billgeoghegan avatar davidsonsns avatar debugpai avatar dependabot[bot] avatar hisham-pak avatar isachivka avatar jakejakeho avatar jeltef avatar jukben avatar jvorcak avatar jwtong avatar kajmagnus avatar kinke avatar louisbourque avatar lukaszmn avatar marcinlichwala avatar michauzo avatar o4epegb avatar oklas avatar rrikesh avatar samuelbolduc avatar sdistefano avatar superandrew213 avatar twrichards avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-textarea-autocomplete's Issues

Enable search on autocomplete

Enable searching on the autocomplete

Ex.
you type ':pa' the choices are {'package', 'page'}
then you type ':pac' the choice results is {'package'}

If the editor is at the bottom of the window, better open it upwards instead.

Discussion: #33

The dropdown always opens downwards, but sometimes, if the editor is at the bottom of the window, better open it upwards instead.

That's really good feedback. I'd love to implement this. Could be handy and really bulletproof functionality. Also, it would be cool to support also other directions. (right - left)

Something like https://popper.js.org/#example3, maybe we should use it. I need to dig more into it.

Add prop which close the dropdown when clicking outside

Discussion: #33

The only way to close the dropdown, is to click Esc? not clicking outside with the mouse? Could be a problem on mobile

That makes sense. I've basically copied GitHub functionality – there is no such a thing as a click outside for close the suggestion list. But I like the idea so far, so let's avoid breaking change and make it as the optional prop. πŸ’ͺ

Listener doesn't work after first unmount of Textarea

Hello, first of all thanks for your library

I faced an issue while using this.
After first unmount of Textarea main component list navigation with keys becomes impossible.
It happens because Textarea.jsx calls removeAll here https://github.com/webscopeio/react-textarea-autocomplete/blob/master/src/Textarea.jsx#L92

Which removes keydown event listener forever (until page refresh).
Next mounts of Textarea components won't work properly.

I fixed it roughly here master...JokerNN:master

This change effectively means that keydown event listener will persist forever. (downside of global singletone listener)

I will get rid of it in PR

ERROR in index-5353b33322ce416969f9.js from UglifyJs

When i use react-textarea-autocomplete like the demo, there is a error. That is the error of webpack to build:
ERROR in index-5353b33322ce416969f9.js from UglifyJs
Invalid assignment [index-5353b33322ce416969f9.js:6835,89]

Whether the use of "import emoji from "@jukben/emoji-search"" does't support β€œnew webpack.optimize.UglifyJsPlugin(),”

Including Trigger in selection output breaks functionality

Hello πŸ‘‹ ,

If you have a trigger like @ which opens up a list of users to select from, and the output is @audiolion, if you try to do another @ in the same textarea and select @webscopeio, the selection will replace the first @audiolion with @webscopeio instead of inserting the new autocomplete.

Seems fairly obvious that it looks for the first occurrence of the trigger in the document and replaces instead of maintaining the current selection of where the trigger occurred and replacing it there.

Popup not triggered if the trigger character is attached to text containing another trigger.

The popup is not triggered when there is no space between the typed trigger and other text which already includes a trigger. It works fine if I omit the @ symbol from the inserted text. However, I need to keep the @ symbol in the inserted text as it is used later to find variables in the text and replace them with their values.

I tried reading through the code but couldn't figure out what would cause this behaviour.

Here's a gif demonstrating the problem:
popup not triggered

Emoji research fails on specific string

Hi all,

here is the code of my component, based on the examples:

import React from "react";

import ReactTextareaAutocomplete from "@webscopeio/react-textarea-autocomplete";
import emoji from "@jukben/emoji-search";

import sort from 'match-sorter';


const ItemCategories = ({ entity: { name } }) => <div>{`#${name}`}</div>;
const ItemUsers = ({ entity: { username, full_name } }) => <div><b>{`@${username}`}</b> - {`${full_name}`}</div>;
const ItemEmojis = ({ entity: { name, char } }) => <div>{`${char} ${name}`}</div>;

export default function TextAreaAutoComplete({ Categories, Users, label, updateLabel }) {
  return (

    <ReactTextareaAutocomplete
        id="textareaSendMemo"
        className="form-control p-2"
        value={label}
        onChange={updateLabel}
        placeholder="Ecrivez votre mΓ©mo..."
        loadingComponent={() => <span>Loading</span>}
        trigger={{
          "#": {
            dataProvider: token => {
              let categories = Object.values(Categories)
                  .map(({ raw_name, name }) => ({ raw_name, name }));
              console.log(categories);
              return sort(categories, token, {keys: ['raw_name']});
            },
            component: ItemCategories,
            output: (item, trigger) => '#' + item.name
          },
          "@": {
            dataProvider: token => {
              let users = Object.values(Users)
                  .map(({ username, full_name }) => ({ username, full_name }));
              return sort(users, token, {keys: ['username', 'full_name']});
            },
            component: ItemUsers,
            output: (item, trigger) => '@' + item.username,
          },
          ":": {
            dataProvider: token => {
              return emoji(token)
                .slice(0, 8)
                .map(({ name, char }) => ({ name, char }));
            },
            component: ItemEmojis,
            output: (item, trigger) => item.char
          }
        }}
        closeOnClickOutside={true}
        movePopupAsYouType={true}
        itemClassName="rta-item"
        dropdownClassName="rta-dropdown"
    />
  );
}

The component is great but i just discovered that when i type ":ls" to research an emoji, it crashes with the following error:

RTA: dataProvider fails: textToReplace is null Check the documentation or create issue if you think it's bug. https://github.com/webscopeio/react-textarea-autocomplete/issues
index.js:2178
TypeError: textToReplace is null

Other question:

How do i remove the space of the "next" caretPosition of the ouput ? I don't figure it out, even with the docs.

Thanks in advance,

Best regards.

UMD build so I won't have to use es6 and 'require'?

Hi, I'm building my React.js app by concatenating a bunch of JS files, using gulp.concat(...); I don't use require .... What about creating an UMD build? Or something transpiled to ES5 that works directly in the browser without a module loader? Which is included in react-textarea-autocomplete's npm distribution?

Anyway this looks like a nice library, I like the demos.

Trigger output does nothing in case of string-based items

Hi,

I'm having issues with configuring trigger output, whatever I put in that function, all I get as a result is the value of selected item. My guess is that output field gets ignored when I assign trigger prop.

Here's the code:

          <ReactTextareaAutocomplete
            className="ant-select-auto-complete.ant-select ant-input"
            loadingComponent={Spin}
            trigger={{
              '#': {
                dataProvider: (token) => {
                  if (!token || !token.length) {
                    return this.allProperties
                  }
                  return this.allProperties.filter(prop => {
                    if (prop.search(new RegExp(token, "i")) !== -1) {
                      return prop
                    }
                    return null
                  })
                },
                component: ItemComponent,
                output: (item, trigger) => `#${item}#`
                },
              },
            }}
          />

Thanks

Feature request: IDE like auto suggest

I desperately search for a function like this:

  1. no trigger char (any char in the auto suggest list opens suggestions)
  2. filter suggest list by what is typed (types ja => only show "java" and "jabber" in the list)

Is it hard to implement sth. like this?

image

What's new in v2?

Hi! I was thinking about upgrading, in case of bugs & security fixes, and noticed that now there's a v2.2.2 β€” I'm using v1.4.x. I didn't find any changelog or release notes for 1.5 or 2.x β€” are they available somewhere or maybe if you have time would you like to write a bit about what's changed? can I upgrade from 1.4 to 2.2.2 without errors? or maybe I need to rewrite how I use react-texta.-autoc.?

Ability to position the cursor in the output string

A customizable final position of the cursor in the outputted string

Options could be "start" | "end" | number (position in the final string). Default should be "end"

Proposal:

type Output = (item: Object | string, trigger?: string) => 
    string | { text: string, caretPosition: "start" | "end" | number }

type triggerType = {
    [triggerChar: string]: {
        ?output: Output,
        dataProvider: (token: string) => Promise<Array<Object | string>> | Array<Object | string>,
        component: ReactClass<*>,
    },
}

Any thoughts?

Selection resets after new props are passed

If there is any change to the container component while the autocomplete dropdown is opened the selected item is reset to the first in the list. It happens even if the list did not change.

Possible IE issue with an Event object

I'm trying to create a higher abstraction on top of this awesome plugin. Something not that low level - OOTB solution with support for emojis & markdown.

However, in IE I experience this issue.

Steps to reproduce:

  1. Clone https://github.com/webscopeio/react-markdown-editor
  2. yarn && yarn start
  3. In a second terminal, cd example && yarn && yarn start
  4. Open page in IE11

I've included babel-polyfill in my example project.

bug

Custom callback-based trigger

This looks like a very nicely done component. I wondered if there is a more general way to trigger an autocomplete than using string matching, like a function that would take current text and caret position and returns a boolean e.g.

 trigger: (text, caretPosition) => {
   // some code that computes if autocomplete should trigger or not
}

As I want to provide grammar-based autocomplete rather than character-based one.

Keep the position of the popup at the beginning of the phrase

I'm trying to create a markdown editor around this tool and I want to replicate the one Github has. I'm trying to focus on detail and UX and one of the things that bothers me that popup moves as I type. I find it quite distracting.

If you notice, the one on Github stays positioned at the place where I started typing triggerChar

Don't you think it would be nicer / more user friendly?

PS: API is pretty low level, but well-structured. I got basically everything I needed for the wrapper. πŸ₯‡

The doc about trigger option `output` does not match actual code.

The doc about trigger option output does not match actual code.

The doc says that item must be unique. And the item unique id is received as result of calling function specified in trigger option output. This function must return object with optional field named key wich will be considered as item unique id. Doc declares a prototype:

      output?: (
        item: Object | string,
        trigger?: string
      ) =>
        | {|
            key?: ?string,
            text: string,
            caretPosition: "start" | "end" | "next" | number
          |}
        | string,

But the code currently ignore field key from object returned by this function. Same time code
actually use field key of item itself instead of result of that function in the line:

Selected item replaces from last space rather than the last trigger

Hi there,

Thanks for putting this together! I was wondering if there is a way to prevent the following behaviour:

screencast 2018-02-19 15-41

Hello :world # Ouputs => Hello :earth_americas:
Hello:world # Outputs => :earth_americas: but expected Hello:earth_americas:

Looks like everything from/including the last space is replaced but I was expect everything from/including the last trigger to be replaced.

This seems related to the resolved issue #43.

Error when try trigger by '['

There is js error during select item when trigger character is "[".

Uncaught SyntaxError: Invalid regular expression: /[\S*$/: Unterminated character class

Allow to pass className to List and Item

I use bootstrap for styling my app and it would be great if I could pass a css class for:

  • the <ul> element in the List component (in addition to the rta__list class)
  • the <li> element in the Item component (in addition to the rta__item class)

Any experiences using this with nested data (i.e. populating triggers in a tree structure)?

For instance, I'm using this in a markdown editor to populate JSON data that gets transformed like a variable. So if I have:

  user: {
    name: {
      first "John",
      last: "Doe"
    },
    age: ...
  },
  location: {
    address: ...
  }
}

and my triggers are { and ., I want users to be able to type
{user.
and have the next autocomplete populate with name and age.

So far I'm dynamically populating the list of triggers but they're all on the top level. I was thinking about keeping a string of the current "selection" in state and updating triggers every time there's an update, but there are a ton of edge cases with that and I'm wondering if anyone has any experiencing doing this kind of thing.

Edit: I just realized if there were a way to use a string as a trigger instead of a character I could populate my triggers with my entire JSON tree. Any chance of this or some sort of regex matching becoming a thing with this library?

Whitespace in token

Hey there! Thanks so much for this library. I'm trying to use this to implement @ mentions to mention other people. However, since our community works on full names instead of usernames, there is generally a whitespace in the name in question; eg. "Bob Smith". Is there a way I can configure this library to accept one whitespace and pass it on to my dataProvider? Thanks!

Option to tweak token regexp

I'd like to be able to use tokens that look like this: :This/That:.

Unfortunately, the default regexp uses \w for the "wordy" part of the token, which means at the moment my autocompletes only receive :This.

I'd like to be able to override the latter part of the token regexp. Is there a sketchy way for me to do this? I've tried overriding this.tokenRegExp in a parent components' componentDidMount but that doesn't seem to work. (For reasons that a more seasoned React developer would have to explain to me).

If there's not a sketchy way for me to get this working, what could I do in a PR for this sort of option to make it upstream? Would it be a per trigger override or some sort of global option?

Thanks for your time, and the effort you've already put into making this an ace component.

Show popup only if trigger is after a whitespace (like Github)

Hi,

Thanks for this library. It saves me a lot of work πŸ˜„

But, I have a problem. Is it possible to show popup only if trigger is after a whitespace ?
Basically, I want to prevent popup fired when I'm typing something like

hello:smile

Instead, I only want to fire popup when there is a space before the trigger, like this:

hello :smile

Github works like that.

Thanks in advance for your help πŸ˜‰

Text touching inserted content is replaced.

Hello, first of all, thank you for this great component! It has been incredibly useful for me. I'm using it as part of a latex editor plugin for draft js. Users can add variables into the latex using @mentions. The issue I'm having is that when a mention is used, any text after it that is not separated by a space, is removed. Here's a gif demonstrating the problem:
word replaced

Use `loose` flag in Babel settings

As Andarist correctly suggested in his PR #47 I would be nice if you could use loose to achieve more performant code.

Unfortunately, the preset preset-react-create-app what we've used don't support it. We should find a replacement for it.

How does one actually get a content from this component?

I want to create a wrapper around this component and I'm struggling with how to use some getter/setter for a content.

I'm missing something as value and onChange properties. How could one let's say use this with Redux?

Or maybe it's just missing in a docs?

Cancel loading when we are already in other word context

Discussion: #33

Not so important, maybe not worth fixing. But anyway, if it takes long before the promise gets resolved, because the sever is slow β€” then, when I continue typing, the "Loading..." box doesn't go away, although I've typed "@username and more other stuff afterwards" already. β€” But in reality, the server will "always" be fast & this won't happen :- )

Provide getters/setters and listener for the caret position

Based on the idea from #23

It would be nice to provide getter and setter for caret position.

<ReactTextareaAutocomplete 
    onCaretPositionChange={(position: integer, ref: React$Class) => void}}
    ref={ref => {this.textarea = ref}}
    ...
/>

...

// Getter:

this.textarea.getCaretPosition(): integer;

// Setter:

this.textarea.setCaretPosition(position: integer);

We should use our dependency textarea-caret as much as possible.

Could help:
https://stackoverflow.com/questions/36978192/how-to-get-text-cursor-position-after-keypress-event-happened

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.