Skip to content

Commit

Permalink
1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
ShaoGongBra committed May 30, 2022
0 parents commit dfb9e16
Show file tree
Hide file tree
Showing 11 changed files with 616 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

# OSX
#
.DS_Store

# node.js
#
node_modules/
npm-debug.log
yarn-error.log
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Taro RichText
支持将简单的html富文本渲染为Taro组件,支持小程序、H5、ReactNative

## 安装

```bash
yarn add taro-react-native
```

## 使用

```jsx
<RichText html='<p>文本内容</p>' />
```

## 属性

| 属性 | 类型 | 说明 |
| ---- | ---- | ---- |
| html | string | 用于渲染的HTML |
| style | CSSProperties | 用于组件最外层的样式 |

## 说明
- 支持小程序、H5、ReactNative
- 只支持在Taro3上使用
- 支持在小程序上渲染视频
- 此组件的目的是渲染后台编辑器生成的内容,复杂或者ReactNative不支持的样式将不会被渲染
60 changes: 60 additions & 0 deletions components/HtmlView.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
.html-h1 {
font-weight: bold;
font-size: 64px;
margin: 21.44px 0;
}

.html-h2 {
font-weight: bold;
font-size: 48px;
margin: 24px 0;
}

.html-h3 {
font-weight: bold;
font-size: 37.44px;
margin: 26.56px 0;
}

.html-h4 {
font-weight: bold;
margin: 35.84px 0;
}

.html-h5 {
font-weight: bold;
font-size: 26.56px;
margin: 48px 0;
}

.html-h6 {
font-weight: bold;
font-size: 24px;
margin: 53.44px 0;
}

.html-ul {
margin: 35.84px 0;
}
.html-p {
margin: 35.84px 0;
flex-direction: row;
flex-wrap: wrap;
}
.html-b {
font-weight: bold;
}
.html-em {
font-style: italic;
}
.html-strong {
font-weight: bold;
}

.html-img {
width: 750px;
}
.html-video {
width: 750px;
height: 422px;
}
20 changes: 20 additions & 0 deletions components/HtmlView.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { CSSProperties } from 'react'
import { Component } from 'react'

type props = Partial<{
/** html文本 */
html: string,
/**
* 组件样式 应用在最外层
*/
style?: CSSProperties,
}>

/**
* 用于渲染富文本内容 对于复杂的富文本内容可能无法正常渲染 支持ReactNative
* @example
* <RichText html='<p>文本内容</p>' />
*/
export class HtmlView extends Component<props>{

}
Loading

0 comments on commit dfb9e16

Please sign in to comment.