2013-07-11 00:39:33 +00:00
|
|
|
# angular-contenteditable
|
2014-06-24 15:29:39 +00:00
|
|
|
[![Build Status](https://img.shields.io/travis/akatov/angular-contenteditable.svg)](https://travis-ci.org/akatov/angular-contenteditable)
|
|
|
|
[![Dependency Status](https://img.shields.io/gemnasium/akatov/angular-contenteditable.svg)](https://gemnasium.com/akatov/angular-contenteditable)
|
2013-11-01 16:45:39 +00:00
|
|
|
[![endorse](https://api.coderwall.com/akatov/endorsecount.png)](https://coderwall.com/akatov)
|
2013-07-11 00:39:33 +00:00
|
|
|
|
|
|
|
An AngularJS directive to bind html tags with the `contenteditable` attribute to models.
|
|
|
|
|
2013-07-11 02:32:35 +00:00
|
|
|
## Install
|
|
|
|
|
|
|
|
```bash
|
|
|
|
bower install angular-contenteditable
|
|
|
|
```
|
|
|
|
|
2013-07-11 00:39:33 +00:00
|
|
|
## Usage
|
|
|
|
|
2013-07-16 01:40:53 +00:00
|
|
|
```javascript
|
|
|
|
angular.module('myapp', ['contenteditable'])
|
2013-11-02 23:54:28 +00:00
|
|
|
.controller('Ctrl', ['$scope', function($scope) {
|
|
|
|
$scope.model="<i>interesting</i> stuff"
|
|
|
|
}])
|
2013-07-16 01:40:53 +00:00
|
|
|
```
|
|
|
|
|
2013-07-11 00:39:33 +00:00
|
|
|
```html
|
2013-07-16 01:40:53 +00:00
|
|
|
<div ng-controller="Ctrl">
|
|
|
|
<span contenteditable="true"
|
|
|
|
ng-model="model"
|
|
|
|
strip-br="true"
|
2013-11-02 23:54:28 +00:00
|
|
|
select-non-editable="true">
|
|
|
|
</span>
|
|
|
|
</div>
|
2013-07-11 00:39:33 +00:00
|
|
|
```
|
|
|
|
|
2013-07-17 04:48:43 +00:00
|
|
|
## Notice
|
|
|
|
|
2013-11-22 09:20:47 +00:00
|
|
|
The directive currently does not work in any version of Internet Explorer or Opera < 15.
|
|
|
|
Both browsers don't fire the `input` event for contenteditable fields.
|
|
|
|
|
2013-07-17 04:48:43 +00:00
|
|
|
In Chrome, when a contenteditable element X contains a non-contenteditable
|
|
|
|
element Y as the last element, then the behaviour of the caret is the following:
|
|
|
|
|
2013-11-22 09:20:47 +00:00
|
|
|
* When X has style `display` set to `block` or `inline-block`, then the caret
|
2013-07-17 04:48:43 +00:00
|
|
|
moves to the very far right edge of X when it is _immediately_ at the end of X
|
|
|
|
(inserting spaces moves the caret back).
|
|
|
|
|
|
|
|
* When X has style `display` set to `inline`, then the caret disappears instead.
|
|
|
|
|
2013-07-11 00:39:33 +00:00
|
|
|
## Development
|
|
|
|
|
|
|
|
```bash
|
|
|
|
npm install
|
2013-10-14 04:02:12 +00:00
|
|
|
bower install
|
|
|
|
grunt
|
2013-07-11 00:39:33 +00:00
|
|
|
```
|