2.3.2 • Published 5 years ago

@teamhive/rich-text-editor v2.3.2

Weekly downloads
97
License
MIT
Repository
github
Last release
5 years ago

Built With Stencil

Hive Rich Text Editor

This web component allows you to add rich text editing to your applications.

 

Features

  • Add styling to your text inputs
  • Fully customizable toolbar
  • Flexbox based

 

Installation

  • npm i @teamhive/rich-text-editor

 

Usage

Somewhere in your project (e.g. main.ts):

import { defineCustomElements } from '@teamhive/rich-text-editor/dist/loader';
defineCustomElements(window);
<hive-rich-text [options]="options"></hive-rich-text>

Where options can be populated with any of the following properties:

 

Properties

PropertyDefaultDescriptionValues
toolbar['bold', 'italic', 'underline', 'strikethrough', '\|', 'link', '\|', 'color', 'highlight']The components that will show up in the toolbar.bold, italic, underline, strikethrough, link, color, highlight, undo, redo, superscript, subscript, orderedList, unorderedList, removeFormat, -, \|
colors['#FF4541', '#E65100', '#43A047', '#1C9BE6', '#6446EB', '#ACACC2', '#626272']The colors that will show up for a quick selection when formating text color.Any valid hex code
highlights['#f3f315', '#ff0099', '#83f52c', '#ff6600', '#6e0dd0']The colors that will show up for a quick selection when formating highlight color.Any valid hex code
positiontopThe position of the toolbar in relation to the text container.top or bottom
contentnullThe content that will be loaded into the text container upon loading.plain text and/or html text as a string
placeholderInsert text...The text that will display when the rich editor is unfocused in the empty state.string
maxLengthundefinedThe maximum number of available characters, if set.number
showToolbaralwaysHow the toolbar should be shown or hidden based on user actionsalways, onHover, or onSelect
autoFocusfalseTo focus on the text component upon init.boolean
font: {family,size,color,faces};family: Arialsize: 12pxcolor: #626272faces: nullTo set what the font variables will be in the rich text editor.family: stringsize: stringcolor: stringfaces: FontFace[]

The font option allows for custom FontFace to be configured like this:

faces: [
    {
        weight: 400,
        style: 'normal',
        src: ['./SomeFont.ttf', './SomeFont.woff']
    },
    {
        weight: 400,
        style: 'italic',
        src: ['./SomeFont-Italic.ttf', './SomeFont-Italic.woff']
    },
    {
        weight: 500,
        style: 'normal',
        src: './SomeFont-Bold.ttf'
    },
    ...
]

You should define each weight and style separately similar to how you would define them in CSS using @font-face. You can also specific multiple file urls for src and they will each be specified in the font-face rule. If you just set src to a single url, it will be the only one used.

 

Custom Styling

PropertyDefault
--hive-rte-backgroundnone
--hive-rte-button-size25px
--hive-rte-border1px solid #d1d1d1
--hive-rte-focus-border1px solid #d1d1d1
--hive-rte-border-radius0
--hive-rte-font-familyArial
--hive-rte-font-size14px
--hive-rte-font-color#626272
--hive-rte-placeholder-color#ccc
--hive-rte-placeholder-position-top10px
--hive-rte-placeholder-position-left10px
--hive-rte-placeholder-position-rightnone
--hive-rte-placeholder-position-bottomnone
--hive-rte-max-heightnone
--hive-rte-height100%
--hive-rte-min-height0
--hive-rte-max-widthnone
--hive-rte-width100%
--hive-rte-min-width0
--hive-rte-toolbar-padding10px 5px
--hive-rte-body-padding10px

 

Methods

EventDescriptionValuesReturn
getContent()To return the current contents of the editor.nullreturn: { text: 'Hive Rich Text Editor', html: '<b>Hive Rich Text Editor</b> }'
setContent(value: string)To set the content within the editor at any given time. Will override any and all values within the text editor.plain text and/or html text as a stringnull

 

Events

EventDescriptionReturn
textChangeKey-up event hook when the user types in the editor.KeyboardEvent
styleChangeStyle change event hook when user selects a style from the toolbar.CustomEvent

 

Contributors

| :---: |Austin Miller|

2.3.2

5 years ago

2.3.1

5 years ago

2.3.0

5 years ago

2.2.2

5 years ago

2.2.1

5 years ago

2.2.0

5 years ago

2.1.0

5 years ago

2.0.0

5 years ago

1.5.2

5 years ago

1.5.1

6 years ago

1.5.0

6 years ago

1.5.0-0

6 years ago

1.4.4

6 years ago

1.4.3

6 years ago

1.4.2

6 years ago

1.4.1

6 years ago

1.3.3

6 years ago

1.3.2

6 years ago

1.3.1

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.7.2

6 years ago

0.7.1

6 years ago

0.7.0

6 years ago

0.6.2

6 years ago

0.6.1

6 years ago

0.6.0

6 years ago

0.5.0

6 years ago

0.4.1

6 years ago

0.4.0

6 years ago

0.3.1

6 years ago

0.3.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago