Skip to content

Commit adad5e6

Browse files
committed
init project.
0 parents  commit adad5e6

24 files changed

+783
-0
lines changed

.babelrc

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"env": {
3+
"cjs": {
4+
"plugins": [
5+
[
6+
"babel-plugin-transform-remove-imports",
7+
{ "test": "(less|css)$" }
8+
]
9+
]
10+
},
11+
"esm": {
12+
"plugins": [
13+
[
14+
"babel-plugin-transform-rename-import",
15+
{ "original": "^(.+?)\\.less$", "replacement": "$1.css" }
16+
]
17+
]
18+
},
19+
"esm:dev": {
20+
"presets": [
21+
"@babel/preset-react",
22+
[
23+
"@tsbb/babel-preset-tsbb",
24+
{
25+
"modules": false,
26+
"targets": {
27+
"browsers": [ "last 2 versions" ]
28+
},
29+
"transformRuntime": {
30+
"useESModules": true
31+
}
32+
}
33+
]
34+
]
35+
}
36+
}
37+
}

.gitignore

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
lib
2+
build
3+
node_modules
4+
npm-debug.log*
5+
package-lock.json
6+
7+
.eslintcache
8+
.DS_Store
9+
.cache
10+
.vscode
11+
12+
*.bak
13+
*.tem
14+
*.temp
15+
#.swp
16+
*.*~
17+
~*.*

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install lint-staged

.kktrc.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import path from 'path';
2+
import webpack, { Configuration } from 'webpack';
3+
import { LoaderConfOptions } from 'kkt';
4+
import WebpackDevServer from 'webpack-dev-server';
5+
import lessModules from '@kkt/less-modules';
6+
import rawModules from '@kkt/raw-modules';
7+
import scopePluginOptions from '@kkt/scope-plugin-options';
8+
import pkg from './package.json';
9+
10+
export default (conf: Configuration, env: 'development' | 'production', options: LoaderConfOptions) => {
11+
conf = rawModules(conf, env, { ...options, test: /\.(txt|md)$/i });
12+
conf = scopePluginOptions(conf, env, {
13+
...options,
14+
allowedFiles: [path.resolve(process.cwd(), 'README.md'), path.resolve(process.cwd(), 'src')],
15+
});
16+
conf = lessModules(conf, env, options);
17+
// Get the project version.
18+
conf.plugins!.push(
19+
new webpack.DefinePlugin({
20+
VERSION: JSON.stringify(pkg.version),
21+
}),
22+
);
23+
if (env === 'production') {
24+
conf.output = { ...conf.output, publicPath: './' };
25+
}
26+
return conf;
27+
};
28+
29+
/**
30+
* Modify WebpackDevServer Configuration Example
31+
*/
32+
export const devServer = (config: WebpackDevServer.Configuration) => {
33+
// Return your customised Webpack Development Server config.
34+
return config;
35+
};

.prettierignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
**/*.md
2+
**/*.svg
3+
**/*.ejs
4+
**/*.yml
5+
package.json
6+
node_modules
7+
dist
8+
build
9+
lib
10+
test

.prettierrc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "all",
4+
"printWidth": 120,
5+
"endOfLine": "auto",
6+
"overrides": [
7+
{
8+
"files": ".prettierrc",
9+
"options": { "parser": "json" }
10+
}
11+
]
12+
}

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
React Textarea Code Editor
2+
===
3+
<!--rehype:style=display:none;-->
4+
5+
A simple no-frills code editor with syntax highlighting.
6+
7+
## Install
8+
9+
```bash
10+
$ npm i @uiw/react-textarea-code-editor
11+
```
12+
13+
## Usage
14+
15+
```jsx
16+
import CodeEditor from '@uiw/react-textarea-code-editor';
17+
18+
function App() {
19+
const [code, setCode] = React.useState(
20+
`function add(a, b) {\n return a + b;\n}`
21+
);
22+
return (
23+
<CodeEditor
24+
value={code}
25+
onChange={(env) => setCode(evn.target.value)}
26+
padding={24}
27+
style={{
28+
fontFamily: '"Fira code", "Fira Mono", monospace',
29+
fontSize: 12,
30+
}}
31+
/>
32+
);
33+
}
34+
```
35+
36+
## Props
37+
38+
```ts
39+
interface TextareaCodeEditorProps extends React.TextareaHTMLAttributes<HTMLTextAreaElement> {
40+
prefixCls?: string;
41+
/**
42+
* Set what programming language the code belongs to.
43+
*/
44+
language?: string;
45+
/**
46+
* Optional padding for code. Default: `10`.
47+
*/
48+
padding?: number;
49+
}
50+
```
51+
52+
## Demo
53+
54+
https://uiwjs.github.io/react-textarea-code-editor/
55+
56+
## Development
57+
58+
Runs the project in development mode.
59+
60+
```bash
61+
# Step 1, run first, listen to the component compile and output the .js file
62+
# listen for compilation output type .d.ts file
63+
npm run watch
64+
# Step 2, development mode, listen to compile preview website instance
65+
npm run start
66+
```
67+
68+
**`production`**
69+
70+
Builds the app for production to the build folder.
71+
72+
```bash
73+
npm run build
74+
```
75+
76+
The build is minified and the filenames include the hashes.
77+
Your app is ready to be deployed!

package.json

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"name": "@uiw/react-textarea-code-editor",
3+
"version": "6.10.4",
4+
"description": "A simple no-frills code editor with syntax highlighting.",
5+
"homepage": "https://uiwjs.github.io/react-textarea-code-editor/",
6+
"private": true,
7+
"main": "lib/cjs/index.js",
8+
"module": "lib/esm/index.js",
9+
"scripts": {
10+
"prepare": "husky install && npm run build:lib",
11+
"doc": "kkt build --app-src ./website",
12+
"start": "kkt start --app-src ./website",
13+
"build": "npm run build:lib && npm run doc",
14+
"build:lib": "npm run ts:build && npm run types:esm && npm run types:cjs && npm run css:build && npm run css:build:dist",
15+
"watch": "npm run ts:watch & npm run types:watch & npm run css:watch",
16+
"types:build": "tsbb types --sourceRoot src --target ESNEXT --jsx --emitDeclarationOnly false",
17+
"types:watch": "npm run types:esm -- --watch & npm run types:cjs -- --watch",
18+
"types:esm": "npm run types:build -- --outDir ../lib/esm",
19+
"types:cjs": "npm run types:build -- --outDir ../lib/cjs",
20+
"css:build": "compile-less -d src -o lib/esm",
21+
"css:watch": "compile-less -d src -o lib/esm --watch",
22+
"css:build:dist": "compile-less -d src --combine lib/dist.css --rm-global",
23+
"ts:watch": "tsbb watch --env-name esm:dev --env-name cjs --target react",
24+
"ts:build": "tsbb build --target react",
25+
"prettier": "prettier --write \"**/*.{js,jsx,tsx,ts,less,md,json}\"",
26+
"test": "kkt test --env=jsdom --app-src=./website",
27+
"test:coverage": "kkt test --env=jsdom --coverage --app-src=./website"
28+
},
29+
"repository": {
30+
"type": "git",
31+
"url": "https://github.com/uiwjs/react-textarea-code-editor.git"
32+
},
33+
"author": "Kenny Wong <wowohoo@qq.com>",
34+
"license": "MIT",
35+
"files": [
36+
"lib",
37+
"src"
38+
],
39+
"lint-staged": {
40+
"*.{js,jsx,tsx,ts,less,md,json}": [
41+
"prettier --write"
42+
]
43+
},
44+
"peerDependencies": {
45+
"@babel/runtime": ">=7.10.0",
46+
"react": ">=16.9.0",
47+
"react-dom": ">=16.9.0"
48+
},
49+
"devDependencies": {
50+
"@kkt/less-modules": "6.10.4",
51+
"@kkt/raw-modules": "6.10.4",
52+
"@kkt/scope-plugin-options": "6.10.4",
53+
"@mapbox/rehype-prism": "0.6.0",
54+
"@types/react": "17.0.11",
55+
"@types/react-dom": "17.0.8",
56+
"@types/react-test-renderer": "17.0.1",
57+
"@uiw/react-github-corners": "1.4.0",
58+
"@uiw/react-markdown-preview": "3.1.1",
59+
"code-example": "3.0.4",
60+
"compile-less-cli": "1.8.0",
61+
"husky": "6.0.0",
62+
"kkt": "6.10.4",
63+
"lint-staged": "11.0.0",
64+
"prettier": "2.3.1",
65+
"react": "17.0.2",
66+
"react-dom": "17.0.2",
67+
"react-test-renderer": "17.0.2",
68+
"rehype": "11.0.0",
69+
"rehype-attr": "1.3.2",
70+
"rehype-parse": "7.0.1",
71+
"tsbb": "2.2.1"
72+
},
73+
"eslintConfig": {
74+
"extends": [
75+
"react-app",
76+
"react-app/jest"
77+
]
78+
},
79+
"browserslist": {
80+
"production": [
81+
">0.2%",
82+
"not dead",
83+
"not op_mini all"
84+
],
85+
"development": [
86+
"last 1 chrome version",
87+
"last 1 firefox version",
88+
"last 1 safari version"
89+
]
90+
}
91+
}

public/favicon.ico

3.78 KB
Binary file not shown.

0 commit comments

Comments
 (0)