Thanks to visit codestin.com
Credit goes to github.com

Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
bower_components/
node_modules/
node_modules/
/*.iml
/.idea
36 changes: 36 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Got a question or problem?

Please, do not open issues for the general support questions as we want to keep GitHub issues for bug reports and feature requests. You've got much better chances of getting your question answered on [StackOverflow](http://stackoverflow.com/questions/tagged/angular-ui-tinymce) where maintainers are looking at questions questions tagged with `angular-ui-tinymce`.

StackOverflow is a much better place to ask questions since:
* there are hundreds of people willing to help on StackOverflow
* questions and answers stay available for public viewing so your question / answer might help someone else
* SO voting system assures that the best answers are prominently visible.

To save your and our time we will be systematically closing all the issues that are requests for general support and redirecting people to StackOverflow.

## You think you've found a bug?

Oh, we are ashamed and want to fix it asap! But before fixing a bug we need to reproduce and confirm it. In order to reproduce bugs we will systematically ask you to provide a _minimal_ reproduce scenario using http://plnkr.co/. Having a live reproduce scenario gives us wealth of important information without going back & forth to you with additional questions like:
* version of AngularJS used
* version of this library that you are using
* 3rd-party libraries used, if any
* and most importantly - a use-case that fails

A minimal reproduce scenario using http://plnkr.co/ allows us to quickly confirm a bug (or point out coding problem) as well as confirm that we are fixing the right problem.

We will be insisting on a minimal reproduce scenario in order to save maintainers time and ultimately be able to fix more bugs. Interestingly, from our experience users often find coding problems themselves while preparing a minimal plunk. We understand that sometimes it might be hard to extract essentials bits of code from a larger code-base but we really need to isolate the problem before we can fix it.

Unfortunately we are not able to investigate / fix bugs without a minimal reproduce scenario using http://plnkr.co/, so if we don't hear back from you we are going to close an issue that don't have enough info to be reproduced.


## You want to contribute some code?

We are always looking for the quality contributions and will be happy to accept your Pull Requests as long as those adhere to some basic rules:

* Please open all pull requests against the `dev` branch.
* Please assure that you are submitting quality code, specifically make sure that:
* You have accompanying tests and all the tests are passing.
* Your PR doesn't break the build; check the Travis-CI build status after opening a PR and push corrective commits if anything goes wrong
* You are using 2 space indentation
* Your commits conform to the conventions established [here](https://github.com/ajoslin/conventional-changelog/blob/master/conventions/angular.md)
17 changes: 14 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ bower install
This will copy the ui-tinymce files into your `components` folder, along with its dependencies. Load the script files in your application:

```html
<script type="text/javascript" src="app/bower_components/tinymce/tinymce.js"></script>
<script type="text/javascript" src="app/bower_components/tinymce-dist/tinymce.js"></script>
<script type="text/javascript" src="app/bower_components/angular/angular.js"></script>
<script type="text/javascript" src="app/bower_components/angular-ui-tinymce/tinymce.js"></script>
<script type="text/javascript" src="app/bower_components/angular-ui-tinymce/src/tinymce.js"></script>
```

Add the tinymce module as a dependency to your application module:
Expand Down Expand Up @@ -69,6 +69,10 @@ If you add the ng-model directive to same the element as ui-tinymce then the tex

_The ui-tinymce directive stores the configuration options as specified in the [TinyMCE documentation](http://www.tinymce.com/wiki.php/Configuration) and expects the model value to be a html string or raw text, depending on whether `raw` is `true` (default value is `false`)._

**Note:** Make sure you using scopes correctly by following [this wiki page](https://github.com/angular/angular.js/wiki/Understanding-Scopes). If you are having issues with your model not updating, make sure you have a '.' in your model.

> This issue with primitives can be easily avoided by following the "best practice" of always have a '.' in your ng-models – watch 3 minutes worth. Misko demonstrates the primitive binding issue with ng-switch.

## Options

The directive supports all of the standard TinyMCE initialization options as listed [here](http://www.tinymce.com/wiki.php/Configuration).
Expand Down Expand Up @@ -99,4 +103,11 @@ myAppModule.controller('MyController', function($scope) {
<form method="post">
<textarea ui-tinymce="tinymceOptions" ng-model="tinymceModel"></textarea>
</form>
```documentation
```

----


# Contributing to the project

We are always looking for the quality contributions! Please check the [CONTRIBUTING.md](CONTRIBUTING.md) for the contribution guidelines.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
],
"dependencies": {
"angular": "~1.x",
"tinymce-dist": "~4.1.0"
"tinymce-dist": "~4.2.0"
},
"devDependencies": {
"angular-mocks": "~1.x"
Expand Down
12 changes: 6 additions & 6 deletions src/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ angular.module('ui.tinymce', [])
var ngModel = ctrls[0],
form = ctrls[1] || null;

var expression, options, tinyInstance,
var expression, options = {}, tinyInstance,
updateView = function(editor) {
var content = editor.getContent({format: options.format}).trim();
content = $sce.trustAsHtml(content);
Expand All @@ -42,7 +42,7 @@ angular.module('ui.tinymce', [])
} else {
ensureInstance();

if (tinyInstance) {
if (tinyInstance && !tinyInstance.settings.readonly) {
tinyInstance.getBody().setAttribute('contenteditable', true);
}
}
Expand All @@ -55,7 +55,7 @@ angular.module('ui.tinymce', [])

angular.extend(expression, scope.$eval(attrs.uiTinymce));

options = {
var setupOptions = {
// Update model when calling setContent
// (such as from the source editor popup)
setup: function(ed) {
Expand All @@ -74,7 +74,7 @@ angular.module('ui.tinymce', [])
});

// Update model on change
ed.on('change', function(e) {
ed.on('change', function() {
ed.save();
updateView(ed);
});
Expand All @@ -99,12 +99,12 @@ angular.module('ui.tinymce', [])
});
}
},
format: 'raw',
format: expression.format || 'html',
selector: '#' + attrs.id
};
// extend options with initial uiTinymceConfig and
// options from directive attribute value
angular.extend(options, uiTinymceConfig, expression);
angular.extend(options, uiTinymceConfig, expression, setupOptions);
// Wrapped in $timeout due to $tinymce:refresh implementation, requires
// element to be present in DOM before instantiating editor when
// re-rendering directive
Expand Down
11 changes: 8 additions & 3 deletions test/tinymce.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describe('uiTinymce', function () {
* Asynchronously runs the compilation.
*/
function compile() {
element = $compile('<form><textarea ui-tinymce="{foo: \'bar\', setup: setupFooBar() }" ng-model="foo"></textarea></form>')(scope);
element = $compile('<form><textarea ui-tinymce="{foo: \'bar\', setup: setupFooBar }" data-ng-model="foo"></textarea></form>')(scope);
angular.element(document.getElementsByTagName('body')[0]).append(element);
scope.$apply();
$timeout.flush();
Expand Down Expand Up @@ -53,10 +53,15 @@ describe('uiTinymce', function () {
expect(tinymce.init.calls.mostRecent().args[0].tinymce.bar).toBe('baz');
});

it('should execute the passed `setup` option', function() {
it('should execute the passed `setup` option', function(done) {
scope.setupFooBar = jasmine.createSpy('setupFooBar');
compile();
expect(scope.setupFooBar).toHaveBeenCalled();

//TODO: Get rid of timeout
setTimeout(function() {
expect(scope.setupFooBar).toHaveBeenCalled();
done();
}, 100);
});
});

Expand Down