instance-oom/ngx-markdown-editor

OnRenderFinishedEvent

Opened this issue ยท 8 comments

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)

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

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.

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)

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

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

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.

Please upgrade to 3.1.0.

  • [@input] postRender: Change the html souce code generated by marked before update the dom
  • [@output] onPreviewDomChanged: EventEmitter<HTMLElement>: Fires when the preview dom updated

That worked a treat - legend! Thanks so much ๐Ÿ‘ ๐Ÿ‘ ๐Ÿ‘