Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Question: Is it possible to dynamically generate the options of the editor? #192

Closed
nicolasgarnil opened this issue Nov 12, 2015 · 3 comments
Labels

Comments

@nicolasgarnil
Copy link

I can't initialise the editor with the content_css option set to a value which is obtained from an XHR request because the link function of the directive is called before the callback of the XHR request. As a consequence of this, the options are not passed to the directive.

<textarea ui-tinymce="tinymceOptions" ng-model="email.body"></textarea>
Template.get({ id: $routeParams.id }, function(response) {
  $scope.template = response.attributes;

  $scope.tinymceOptions = {
      inline: false,
      plugins : 'code importcss preview code',
      skin: 'lightgray',
      theme : 'modern',
      content_css: $scope.template.content_css
    };
});

If I broadcast a $tinymce:refresh event after initialising the options, the editor gets re-initialised with the new options, but the old editor is not removed.

I a have little experience in angular directives, is it possible to watch changes in the options and reflect them in the editor? It would be a great feature of this directive.

@deeg deeg added the question label Nov 12, 2015
@deeg
Copy link
Contributor

deeg commented Nov 12, 2015

This is related to issue #158.

In order to not initialize TinyMCE until the options are defined add an ng-if check to the text area:

<textarea ui-tinymce="tinymceOptions" ng-model="email.body" ng-if="tinymceOptions"></textarea>

I am going to close this ticket in favor of #158 for now. I will open a new bug about the refresh event not removing the old editor, as I have seen that too.

In the future please ask any questions you may have using the angular-ui-tinymce tag on StackOverflow.

If you have reproducible bugs, continue opening issues attaching a Plunker describing the issue.

@deeg deeg closed this as completed Nov 12, 2015
@nicolasgarnil
Copy link
Author

That workaround doesn't works when you need to re-initialise the editor more than one time. After the options are defined you can no longer re-initialise the editor. In my example, the template can be changed more than once.

@deeg
Copy link
Contributor

deeg commented Nov 16, 2015

That makes sense. I am hoping this will get fixed by the other bugs open.

I do agree that when the options change the editor should re-initalize, so I hope to get that feature in there.

In the mean time, we welcome all pull requests if you have any time to implement the feature.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants