textcomplete

Autocomplete for textarea elements

Github星跟蹤圖

textcomplete

Autocomplete for textarea elements.

NPM version
Build Status
Code Climate
Test Coverage
Stable Release Size
Analytics

Requirements

Distributed scripts are self-contained.

To require as npm package, textcomplete requires the following to run:

Usage

Textcomplete is easiest to use when installed with npm:

npm install --save textcomplete

Then you can load the module into your code with require call:

var { Textcomplete, Textarea } = require('textcomplete');

The Textarea object is a kind of editor class. An editor encapsulates an HTML element where users input text. The Textarea editor is an editor for textarea element.

You can find some additional editors at List of editors wiki.

The Textcomplete is the core object of textcomplete.

var editor = new Textarea(textareaElement);
var textcomplete = new Textcomplete(editor);

Register series of autocomplete strategies:

textcomplete.register([{
  // Emoji strategy
  match: /(^, \s):(\w+)$/,
  search: function (term, callback) {
    callback(emojies.filter(emoji => { return emoji.startsWith(term); }));
  },
  replace: function (value) {
    return '$1:' + value + ': ';
  }
}, {
  // Another strategy
  ...
}]);

Now, the textcomplete listens keyboard event on the editor and render autocomplete dropdown when one of the strategy matches to the inputted value.

Browser Support

Chrome, Firefox, Internet Explorer, Opera, Safari
:-------:, :--------:, :-----------------:, :-------:, :-------:
Current, Current, 10+, Current, Current

Install

If your project is using npm, you can install textcomplete package by npm command:

npm install --save textcomplete

if not, you can download released packages from the release page which contain bundled scripts in dist directory.

Contributing

To contribute to textcomplte, clone this repo locally and commit your code on a separate branch.
Please write unit tests for your code, and run the linter before opening a pull-request:

npm test # run linter and all tests

You can find more detail in our contributing guide.

License

The MIT License

主要指標

概覽
名稱與所有者yuku/textcomplete
主編程語言TypeScript
編程語言JavaScript (語言數: 2)
平台
許可證MIT License
所有者活动
創建於2013-08-24 06:22:06
推送於2023-12-11 03:25:12
最后一次提交
發布數84
最新版本名稱v0.1.13 (發布於 )
第一版名稱jquery-v0.0.2 (發布於 )
用户参与
星數1.7k
關注者數60
派生數301
提交數504
已啟用問題?
問題數227
打開的問題數14
拉請求數92
打開的拉請求數2
關閉的拉請求數43
项目设置
已啟用Wiki?
已存檔?
是復刻?
已鎖定?
是鏡像?
是私有?