angular-medium-editor icon indicating copy to clipboard operation
angular-medium-editor copied to clipboard

Q / feature request: Can contents be compiled?

Open stevie-p opened this issue 9 years ago • 0 comments
trafficstars

Hi. I am road-testing angular-medium-editor to see whether I can use (and extend) it to deliver an online editing capability for users to add custom angular directives to their content.

Using the highlighter example, I can see how I can add custom HTML tags, attributes and classes - so I think I'm half-way there!

But is it possible for the contents of the medium-editor (and the custom directives inserted within it) to be compiled when they're changed?

I have tried editing angular-medium-editor.js to compile the contents as part of the ngModel.$render function:

    ngModel.$render = function() {
      iElement.html(ngModel.$viewValue || "");
      $compile(iElement.contents())(scope);
      var placeholder = ngModel.editor.getExtensionByName('placeholder');
      if (placeholder) {
        placeholder.updatePlaceholder(iElement[0]);
      }
    };

This works for custom directives that are already in the medium-editor's HTML model, but does not get re-compiled when the model changes (i.e. directives are added). Any ideas?

stevie-p avatar Aug 25 '16 14:08 stevie-p