diff --git a/.gitignore b/.gitignore
index 971b25d..318cde2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,3 +29,8 @@ yarn.lock
package-lock.json
coverage/
.doc
+# umi
+.umi
+.umi-production
+.umi-test
+.env.local
diff --git a/.umirc.ts b/.umirc.ts
new file mode 100644
index 0000000..f7f456e
--- /dev/null
+++ b/.umirc.ts
@@ -0,0 +1,22 @@
+// more config: https://d.umijs.org/config
+import { defineConfig } from 'dumi';
+
+const name = 'textarea';
+
+export default defineConfig({
+ title: 'rc-textarea',
+ favicon: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
+ logo: 'https://avatars0.githubusercontent.com/u/9441414?s=200&v=4',
+ outputPath: '.doc',
+ exportStatic: {},
+ base: `/${name}/`,
+ publicPath: `/${name}/`,
+ styles: [
+ `
+ .markdown table {
+ width: auto !important;
+ }
+ `,
+ ],
+ mfsu: {},
+});
diff --git a/HISTORY.md b/CHANGELOG.md
similarity index 100%
rename from HISTORY.md
rename to CHANGELOG.md
diff --git a/README.md b/README.md
index d844907..21e1a13 100644
--- a/README.md
+++ b/README.md
@@ -1,12 +1,6 @@
# rc-textarea
-[![NPM version][npm-image]][npm-url]
-[![npm download][download-image]][download-url]
-[![build status][github-actions-image]][github-actions-url]
-[![Codecov][codecov-image]][codecov-url]
-[![Dependencies][david-image]](david-url)
-[![DevDependencies][david-dev-image]][david-dev-url]
-[![bundle size][bundlephobia-image]][bundlephobia-url]
+[![NPM version][npm-image]][npm-url] [](https://github.com/umijs/dumi) [![npm download][download-image]][download-url] [![build status][github-actions-image]][github-actions-url] [![Codecov][codecov-image]][codecov-url] [![Dependencies][david-image]](david-url) [![DevDependencies][david-dev-image]][david-dev-url] [![bundle size][bundlephobia-image]][bundlephobia-url]
[npm-image]: http://img.shields.io/npm/v/rc-textarea.svg?style=flat-square
[npm-url]: http://npmjs.org/package/rc-textarea
diff --git a/docs/demo/autoSize.md b/docs/demo/autoSize.md
new file mode 100644
index 0000000..a2dfa90
--- /dev/null
+++ b/docs/demo/autoSize.md
@@ -0,0 +1,3 @@
+## autoSize
+
+
diff --git a/docs/demo/simple.md b/docs/demo/simple.md
new file mode 100644
index 0000000..34a6d23
--- /dev/null
+++ b/docs/demo/simple.md
@@ -0,0 +1,3 @@
+## simple
+
+
diff --git a/examples/autoSize.js b/docs/examples/autoSize.jsx
similarity index 95%
rename from examples/autoSize.js
rename to docs/examples/autoSize.jsx
index f3c906b..814de0e 100644
--- a/examples/autoSize.js
+++ b/docs/examples/autoSize.jsx
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import React, { useState } from 'react';
-import Textarea from '../src/index';
+import Textarea from 'rc-textarea';
export default function App() {
const [value, setValue] = useState('hello\nworld');
diff --git a/examples/simple.js b/docs/examples/simple.jsx
similarity index 95%
rename from examples/simple.js
rename to docs/examples/simple.jsx
index 50c5eae..29d5cd7 100644
--- a/examples/simple.js
+++ b/docs/examples/simple.jsx
@@ -1,6 +1,6 @@
/* eslint-disable no-console */
import React, { useState } from 'react';
-import Textarea from '../src/index';
+import Textarea from 'rc-textarea';
export default function App() {
const [value, setValue] = useState('');
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 0000000..56fc654
--- /dev/null
+++ b/docs/index.md
@@ -0,0 +1,5 @@
+---
+title: rc-textarea
+---
+
+
diff --git a/index.js b/index.js
deleted file mode 100644
index fd4d7e5..0000000
--- a/index.js
+++ /dev/null
@@ -1 +0,0 @@
-module.exports = require('./src/');
diff --git a/package.json b/package.json
index bfacde8..d9d148c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "rc-textarea",
- "version": "0.3.4",
+ "version": "0.3.5",
"description": "Pretty Textarea react component used in used in ant.design",
"keywords": [
"react",
@@ -29,10 +29,11 @@
},
"license": "MIT",
"scripts": {
- "start": "cross-env NODE_ENV=development father doc dev --storybook",
- "build": "father doc build --storybook",
+ "start": "dumi dev",
+ "docs:build": "dumi build",
+ "docs:deploy": "gh-pages -d .doc",
"compile": "father build && lessc assets/index.less assets/index.css",
- "gh-pages": "npm run build && father doc deploy",
+ "gh-pages": "npm run docs:build && npm run docs:deploy",
"prepublishOnly": "npm run compile && np --yolo --no-publish && npm run gh-pages",
"lint": "eslint src/ --ext .ts,.tsx,.jsx,.js,.md",
"prettier": "prettier --write \"**/*.{ts,tsx,js,jsx,json,md}\"",
@@ -53,11 +54,13 @@
"@umijs/fabric": "^2.0.8",
"coveralls": "^3.0.6",
"cross-env": "^7.0.2",
+ "dumi": "^1.1.0",
"enzyme": "^3.0.0",
"enzyme-adapter-react-16": "^1.0.1",
"enzyme-to-json": "^3.4.0",
"eslint": "^7.0.0",
"father": "^2.13.4",
+ "gh-pages": "^3.1.0",
"husky": "^4.2.5",
"less": "^3.10.3",
"np": "^5.1.0",
diff --git a/src/calculateNodeHeight.tsx b/src/calculateNodeHeight.tsx
index b4b518f..486f199 100644
--- a/src/calculateNodeHeight.tsx
+++ b/src/calculateNodeHeight.tsx
@@ -33,6 +33,7 @@ const SIZING_STYLE = [
'padding-right',
'border-width',
'box-sizing',
+ 'word-break',
];
export interface NodeType {
@@ -113,12 +114,8 @@ export default function calculateNodeHeight(
// Copy all CSS properties that have an impact on the height of the content in
// the textbox
- const {
- paddingSize,
- borderSize,
- boxSizing,
- sizingStyle,
- } = calculateNodeStyling(uiTextNode, useCache);
+ const { paddingSize, borderSize, boxSizing, sizingStyle } =
+ calculateNodeStyling(uiTextNode, useCache);
// Need to have the overflow attribute to hide the scrollbar otherwise
// text-lines will not calculated properly as the shadow will technically be
diff --git a/src/index.tsx b/src/index.tsx
index 18371e2..5ae01b5 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -1,9 +1,9 @@
import * as React from 'react';
-import ResizableTextArea, { AutoSizeType } from './ResizableTextArea';
+import ResizableTextArea from './ResizableTextArea';
+import type { AutoSizeType } from './ResizableTextArea';
-export type HTMLTextareaProps = React.TextareaHTMLAttributes<
- HTMLTextAreaElement
->;
+export type HTMLTextareaProps =
+ React.TextareaHTMLAttributes;
export interface TextAreaProps extends HTMLTextareaProps {
prefixCls?: string;
@@ -92,6 +92,7 @@ class TextArea extends React.Component {
}
}
-export { ResizableTextArea, AutoSizeType };
+export { ResizableTextArea };
+export type { AutoSizeType };
export default TextArea;
diff --git a/tests/index.spec.js b/tests/index.spec.js
index caba8dc..3e12ede 100644
--- a/tests/index.spec.js
+++ b/tests/index.spec.js
@@ -1,6 +1,6 @@
import React from 'react';
import { mount } from 'enzyme';
-import TextArea from '../index';
+import TextArea from '../src';
import { focusTest, sleep } from './utils';
import calculateNodeHeight, {
calculateNodeStyling,
@@ -110,7 +110,7 @@ describe('TextArea', () => {
boxSizing: 'border-box',
paddingSize: 4,
sizingStyle:
- 'letter-spacing:normal;line-height:normal;padding-top:2px;padding-bottom:2px;font-family:-webkit-small-control;font-weight:;font-size:;font-variant:;text-rendering:auto;text-transform:none;width:;text-indent:0;padding-left:2px;padding-right:2px;border-width:1px;box-sizing:border-box',
+ 'letter-spacing:normal;line-height:normal;padding-top:2px;padding-bottom:2px;font-family:-webkit-small-control;font-weight:;font-size:;font-variant:;text-rendering:auto;text-transform:none;width:;text-indent:0;padding-left:2px;padding-right:2px;border-width:1px;box-sizing:border-box;word-break:',
});
});
diff --git a/tsconfig.json b/tsconfig.json
index bba2297..4da5e9f 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -6,6 +6,11 @@
"jsx": "preserve",
"declaration": true,
"skipLibCheck": true,
- "esModuleInterop": true
+ "esModuleInterop": true,
+ "paths": {
+ "@/*": ["src/*"],
+ "@@/*": ["src/.umi/*"],
+ "rc-textarea": ["src/index.tsx"]
+ }
}
-}
\ No newline at end of file
+}