instance-oom / ngx-markdown-editor

Angular markdown editor based on ace editor
http://lon-yang.github.io/markdown-editor/
Apache License 2.0
174 stars 48 forks source link

OnRenderFinishedEvent #61

Closed ghost closed 4 years ago

ghost commented 4 years ago

Hi, Is there a way to get notified when render preview has finished? I want to run some code post-render that will modified the output in preview.

I tried putting an event on the variable changing, but that changes before output preview has finished rendering.

Ideally something like OnRenderFinishedEvent (similiar to onEditorLoaded)

instance-oom commented 4 years ago

I will add this event later, thanks for your feedback.

instance-oom commented 4 years ago

Hi @tank104 , I want to know if you want to change the HTML source code that generated by markdown? There has an preRender input for change the markdown content before reader, maybe I can add a postRender input for that.

ghost commented 4 years ago

I am already using the prerender - so I tag up the HTML that is renderer. Once that output has changed and finished rendering I need to run javascript that changes the output again (but needs the complete output to work)

tank104 commented 4 years ago

unless there is a way I can do it without needing a change from your package? Sorry I am not too familiar with ACE editor

instance-oom commented 4 years ago

It's ok. I will add postRender to solve this issue. Like this:

[postRender]="postRender"
constructor() {
  // If you want access `this` in your function. Please add this line.
  this.postRender = this.postRender.bind(this); 
}

postRender(html) {
  // do something to change the html source
  return html;
}

I will inform you when it is finished

tank104 commented 4 years ago

great! To be clear - this will be called when the DOM Html has changed - i.e. so the scripts we run in this that searches the DOM and makes changes will work on the latest preview.

instance-oom commented 4 years ago

Please upgrade to 3.1.0.

tank104 commented 4 years ago

That worked a treat - legend! Thanks so much 👍 👍 👍