Skip to content

A small library to split text and add additional words under the condition of Specified lines

License

Notifications You must be signed in to change notification settings

freeeeaker/text-overflow

Repository files navigation

text-overflow

一个小库,以指定行数切割文本并在后面添加额外的html

A small library to split text and add additional html under the condition of Specified lines

how to use

npm install text-overflow

const textOverflow = require('text-overflow')
textOverflow(node, options)

demo website

 演示网址

node

 容器节点,需要被文本截断的元素

a container node which the html will be cutted

options

str: String

 容器节点中应该被插入的html文本

the html which should be inserted to the container node

addedStr: String

 需要被补全的html文本

the html which should be added to the origin html

maxWidth: Number

 容器节点的最大宽度

the max width of the container node

maxLine: Number

 允许的最大行数

the max line number

emptyLine:? Boolean

 是否允许有空行

is empty line should be allowed

caution

 容器节点的css样式必须设置以下属性

the css of the container node must have following props

  .container-node {
    white-space: pre-wrap;
    word-break: break-all;
    word-wrap: break-word;
     // you alse should to set an accuralte width
  }

About

A small library to split text and add additional words under the condition of Specified lines

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published