How to insert new line 2 times using 'comment.appendText' or 'comment.appendMarkdown'



Publicado 14 oct 2023

I'm trying to edit a comment using the ZAF comment object. I tried to show the comment including new line twice using comment.appendText or comment.appendMarkdown as below examples but these didn't work well:

  • comment.appendText - \n
const client = ZAFClient.init();
client.invoke('comment.appendText', "First line\n\nThird line").then(~~~~~~

First line Third line

  • comment.appendText - separate multiple calls
const client = ZAFClient.init();
client.invoke('comment.appendText', "First line").then(~~~~~~
client.invoke('comment.appendText', "").then(~~~~~~
client.invoke('comment.appendText', "Third line").then(~~~~~~

First line

Third line

  • comment.appendMarkdown - \n
const client = ZAFClient.init();
client.invoke('comment.appendMarkdown', "First line\n\nThird line").then(~~~~~~

First line

Third line

  • comment.appendMarkdown - 2 spaces
const client = ZAFClient.init();
client.invoke('comment.appendMarkdown', "First line Third line").then(~~~~~~

First line Third line

  • comment.appendMarkdown - <br>
const client = ZAFClient.init();
client.invoke('comment.appendMarkdown', "First line<br><br>Third line").then(~~~~~~

First line<br><br>Third line

  • comment.appendMarkdown - separate multiple calls
const client = ZAFClient.init();
client.invoke('comment.appendMarkdown', "First line").then(~~~~~~
client.invoke('comment.appendMarkdown', "").then(~~~~~~
client.invoke('comment.appendMarkdown', "Third line").then(~~~~~~

First line

Third line

 

 

Does anyone know how to achieve inserting new line twice using comment.appendText or comment.appendMarkdown?

Note: As my few times research, I could find the workaround using commnet.appendHtml and <p> tag like below but if anyone has another idea, I would like to know it:

const client = ZAFClient.init();
client.invoke('comment.appendHtml', "First line<p></p><p></p>Third line").then(~~~~~~

First line

 

Third line


0

2

2 comentarios

      Thanks for commenting this!

      I didn't know the workaround you showed (appendMarkdown + &nbsp;), so this workaround is very helpful, thanks!

      Btw, I think we developers expect common newline methods such as appendText + '\n', twice blank space + appendMarkdown, and so on. I hope Zendesk API will be updated in the future to improve the way newlines.

      0


      Hey there!

      This specific problem is related to the way markdown in general treats multiple empty lines. That said, here is one workaround using the &nbsp; character that should get you the results you're looking for:

      const client = ZAFClient.init();

      client.invoke("comment.appendMarkdown",
      `First Line
      &nbsp;
      &nbsp;
      Third Line`
      );

      0


      Iniciar sesión para dejar un comentario.

      ¿No encontró lo que buscaba?

      Nueva publicación