# j-ContentEditable

> j-ContentEditable: easy usage; supports great features

Framework: jcomponent20
Product: jComponent 20 (jcomponent@20)
Language: en
Content-SHA256: 5e4a42aa60e661bcabf702e258a5acf50ba893ddf2e673b6914984750f02662d
Snapshot: c0700e321579725c5cf4f5ace1ad7d2866d1b4f93c24a63c0b41b6b7998e976c
Sources: components@910ed1a86f6e72b4f031d3ad0dc7844f9fc5cb8e
Review: not-recorded

- supports great features
- works with Bootstrap Grid System
- easy for customization
- supports basic shortcuts `CMD+B` __bold__, `CMD+U` __underline__, `CMD+I` __italic__ and `CMD+L` __creates a link__

__Attributes__:
- `data-required="true"` optional, default `false`
- `data-clipboard="text/plain"` optional, default `text/plain` (for support of `html` use `text/html`)

__Methods__:
- `component.getNode()` returns a select `node` in text `{Object}`
- `component.getSelection()` returns a current selection `{String}`
- `component.insert(value, [encode])` inserts a custom HTML or PLAIN text to the current cursor position, `encode` (optional) is by default `false`
- `component.exec('Bold', false, null)` has same functionality as `document.execCommand()`

__Handlers__:
`component.event(type, value)` handles all events from the editor.

```html
type = bold          - when a text is bolded (value is boolean)
type = italic        - when a text is italic (value is boolean)
type = underline     - when a text is underlined (value is boolean)
type = link          - when a link is created (value is a temporary URL)
type = current       - when a current element is changed in the text (value is NODE)
type = paste         - when the clipboard is used (value is a clipboard value)
type = select        - when a text is selected (value is selected text)
type = focus         - editor is focused (value is undefined)
type = blur          - editor is not focused (value is undefined)
type = click         - click on the specific element in the text (value is NODE)
```

__Default declaration__:

```javascript
self.event = function(type, value) {
    if (type === 'paste')
        self.insert(value, true);
};
```

Use it with `<ui-component name="contenteditable">`. When the component is not loaded yet, jComponent downloads it on first use from the address in `DEF.fallback` (the Componentator CDN by default). Author: Peter Širka. Source: the Componentator components repository, MIT license.

```html example.html
<div class="container">
	<div class="row">
		<div class="col-md-6">
			<ui-component name="contenteditable" path="myhtml"></ui-component>
		</div>
	</div>
</div>
```
