├── .travis.yml
├── .npmignore
├── .babelrc
├── src
├── index.ts
├── Range.ts
├── nodes
│ ├── EmojiNode.tsx
│ ├── UrlNode.tsx
│ └── Node.tsx
├── helpers.ts
└── Highlightable.tsx
├── tsconfig.json
├── .gitignore
├── test
├── .setup.js
├── Highlightable.test.js
└── __snapshots__
│ └── Highlightable.test.js.snap
├── .eslintrc
├── webpack.config.js
├── LICENSE.txt
├── package.json
└── README.md
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "6"
4 |
--------------------------------------------------------------------------------
/.npmignore:
--------------------------------------------------------------------------------
1 | src
2 | test
3 | webpack.*
4 | .babelrc
5 | .eslintrc
6 |
--------------------------------------------------------------------------------
/.babelrc:
--------------------------------------------------------------------------------
1 | {
2 | "presets": ["@babel/preset-env", "@babel/preset-react", "@babel/preset-typescript"],
3 | "plugins": ["babel-plugin-add-module-exports", "@babel/plugin-transform-arrow-functions"]
4 | }
5 |
--------------------------------------------------------------------------------
/src/index.ts:
--------------------------------------------------------------------------------
1 | import Highlightable from './Highlightable';
2 | import Range from './Range';
3 | import EmojiNode from './nodes/EmojiNode';
4 | import Node from './nodes/Node';
5 | import UrlNode from './nodes/UrlNode';
6 |
7 | export default Highlightable;
8 | export {
9 | Range,
10 | EmojiNode,
11 | UrlNode,
12 | Node
13 | };
--------------------------------------------------------------------------------
/src/Range.ts:
--------------------------------------------------------------------------------
1 | import { HighlightableProps } from "./Highlightable";
2 |
3 | export default class Range {
4 | start: number;
5 | end: number;
6 | text: string;
7 | data: HighlightableProps;
8 |
9 | constructor(start: number, end: number, text: string, data: HighlightableProps) {
10 | this.start = start;
11 | this.end = end;
12 | this.text = text;
13 | this.data = data;
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "declaration": true,
4 | "declarationDir": "./types",
5 | "emitDeclarationOnly": true,
6 | "noImplicitAny": true,
7 | "module": "es6",
8 | "target": "es6",
9 | "jsx": "react",
10 | "allowJs": true,
11 | "moduleResolution": "node",
12 | "skipLibCheck": true,
13 | "allowSyntheticDefaultImports": true
14 | },
15 | "include": ["src"]
16 | }
--------------------------------------------------------------------------------
/src/nodes/EmojiNode.tsx:
--------------------------------------------------------------------------------
1 | import React from 'react';
2 |
3 | import Node, { NodeProps } from './Node';
4 |
5 | export type EmojiNodeType = {
6 | text: string;
7 | } & NodeProps;
8 |
9 | const EmojiNode = (props: EmojiNodeType) => {
10 |
11 | return