• Stars
    star
    124
  • Rank 288,207 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

textlint editor project.

@textlint/editor

textlint editor is privacy first linting tool on your browser.

Usage

  1. Install Web Extensions
  2. Install your favorites textlint worker scripts
  3. Finally, you can linting any supported textarea with your textlint worker script

📝 @textlint/editor web extension hook the access of https://*/*/textlint-worker.js. If you navigate to https://*/*/textlint-worker.js, the web extension open installation dialog like Greasemonkey Extension.

📝 You want to use your customized rule, please use https://github.com/textlint/editor-script-template.

Supports textarea

  • textarea
  • contenteditable
  • Google Docs
  • Twitter
  • Medium
  • Wordpress
  • CodeMirror
  • ACE

If you want to support new textarea, please create an issues or pull request to textchecker-element.

Purpose

  • Privacy first
    • Offline works
  • Create own textlint that is bundled with own configuration

Grammarly and Microsoft Editor is useful and high-quality linting tools, but these require network access, and you must pass your text to their server.

textlint can be works at offline. Because, textlint is written by JavaScript, textlint rules are also written by JavaScript.

However, textlint is pluggable linting tools and textlint can not provide recommended/default ruleset.

@textlint/editor project resolve this issue using @textlint/script-compiler that generate optimized code from your textlint configuration.

Architecture

For example, WebExtension download own optimized textlint that is generated code @textlint/script-compiler, and use it for linting.

So, we can focus on the compiler and frontend of editor.

Develop

Install with yarn and build before editing files.

yarn install
yarn run build
cd packages/you want to edit

Develop web extension

yarn install
yarn run build
cd packages/webextension
yarn dev chrome # yarn dev firefox

Architecture

  • FrontEnd
    • textchecker-element is general web component implementation.
    • Injectable code
    • View
    • multiple implementations
    • For VSCode, TextArea, Google Docs
  • BackEnd
    • Web Extension: background.js
    • Server: API server
    • Web Worker: thread
    • spellchecker backend api

FrontEnd and BackEnd is separated.

WebComponent

Avoid side-effect on website.

  • TextChecker
  • Controller
  • Portal Overlay

Compiler target

@textlint/script-compiler generate bundled JavaScript code.

Compiler compilertextlint + rule + textlintrc into a single library code.

  • Chrome Extension code
    • chrome.storage.local for cache
    • libraryTarget:
  • Web Worker code
    • kvstorage cache
    • libraryTarget: self
  • Main Thread code(just web)
    • kvstorage cache
    • libraryTarget: web

Also, We can provide @textlint/script-compiler as a service using codesandbox

API

The library has some API

  • update(config): Promise
    • dynamic update textlintrc config
  • lint({text:string}): { range: [number, number], message: string, suggestions: suggesionItem[] };
  • fix({ range: [number,number] }): string;
  • suggest({ range: [number, numbe })`
    • missing parts of textlint
  • ignore({ word:string }): Promise<void>

Changelog

See Releases page.

Running tests

Install devDependencies and Run npm test:

npm test

Contributing

Pull requests and stars are always welcome.

For bugs and feature requests, please create an issue.

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

Author

License

MIT © azu

More Repositories

1

textlint

The pluggable natural language linter for text and markdown.
TypeScript
2,641
star
2

textlint-app

textlint standalone application top on Electron.
JavaScript
67
star
3

textlint-plugin-latex2e

Textlint Plugin LaTeX2ε
TypeScript
67
star
4

markdown-to-ast

[CAUTION] This repository is MOVED to monorepo.
59
star
5

textlint-filter-rule-comments

textlint filter rule that disables all rules between comments directive.
JavaScript
23
star
6

textlint-plugin-html

HTML support for textlint
HTML
20
star
7

textlint-filter-rule-allowlist

textlint filter rule that filters any word by allowing lists.
JavaScript
14
star
8

create-textlint-rule

Create textlint rule project with no configuration.
JavaScript
14
star
9

textlint-rule-helper

This is helper library for creating textlint rule.
TypeScript
13
star
10

textlint.github.io

[Auto Build] website [Do Not Pull Request]
HTML
13
star
11

playground

textlint online playground.
JavaScript
13
star
12

textlint-scripts

Move to textlint monorepo
JavaScript
8
star
13

editor-script-template

@textlint/editor script template
8
star
14

textstat

Plugabble text statistics engine.
TypeScript
8
star
15

regexp-string-matcher

Regexp-like string("/github/i") matcher library.
TypeScript
8
star
16

browser-run

Run textlint rule on browser for testing.
TypeScript
7
star
17

textlint-plugin-mdx

textlint plugin to lint MDX
TypeScript
7
star
18

structured-source

Structured Source code
TypeScript
7
star
19

gulp-textlint

[CAUTION] This repository is MOVED to monorepo.
JavaScript
7
star
20

textlint-rule-template

This is TEMPLATE REPOSITORY for creating textlint rule.
JavaScript
5
star
21

txt-to-ast

[CAUTION] This repository is MOVED to monorepo.
5
star
22

txt-ast-traverse

[CAUTION] This repository has been MOVED to monorepo.
JavaScript
5
star
23

web-api

textlint web api on now
TypeScript
4
star
24

textlint-formatter

[CAUTION] This repository has been MOVED to monorepo.
JavaScript
4
star
25

textlint-tester

[CAUTION] This repository is MOVED to monorepo.
JavaScript
3
star
26

media

Official logo and icon.
3
star
27

testbot

textlint sandbox. Automatically test real examples.
Shell
2
star
28

create-textlint-rule-example

Create textlint rule example from test codes.
JavaScript
2
star
29

textlint-util-to-string

[textlint] Convert Paragraph Node to plain text with Source Map.
JavaScript
2
star
30

textlint-plugin-markdown

[CAUTION] This repository is MOVED to monorepo.
2
star
31

textlint-rule-template-ts

TEMPLATE repository for textlint rule that is written by TypeScript
TypeScript
2
star
32

textlint-rule-report-node-types

textlint rule that report error by node's type for debugging.
JavaScript
1
star
33

.github

.github meta repository
1
star
34

textlint-plugin-text

[CAUTION] This repository is MOVED to monorepo.
JavaScript
1
star
35

txtast-to-html

TxtAST to HTML string.
HTML
1
star
36

textlint-filter-rule-node-types

textlint filter rule that ignore node's type if the type is reported.
JavaScript
1
star
37

migrate-textlint-scripts

migration tool for using textlint-scripts from babel.
JavaScript
1
star
38

textlintrc-to-package-list

Command line util: Listing package name from .textlintrc
JavaScript
1
star
39

textlint-ast-test

[CAUTION] This repository has been MOVED to monorepo.
JavaScript
1
star
40

babel-plugin-textlint-scripts

A babel plugin for textlint-script.
JavaScript
1
star