question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to insert markdown text when in WYSIWYG mode in v3?

See original GitHub issue

How can you insert markdown text, like an image or code block, when in WYSYWYG mode? Calling editor.insertText() automatically escapes special characters.

For example: Calling editor.insertText('![alt](/shared/some-image.png)' results in !\[alt\](some-image.png) being added.

Prior to upgrading to v3 calling editor.insertText() would work the same in either mode, but now after upgrading to v3 I can’t figure out how to insert markdown text while in WYSIWYG mode.

Is there some alternative method I can use for inserting code blocks or images when in WYSIWYG mode, or some way to make editor.insertText() not escape special characters?

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
js87zzcommented, Feb 2, 2022

@rajtslegr @kevindesousa I’m sorry for the delay because I’m working on another project. I think I can make a work plan within this month. I’ll let you know if there’s anything to do!

2reactions
js87zzcommented, Jul 28, 2021

@houkah26 When I checked, insertText API works the same as 2.x in WYSIWYG. Anyway, you want to insert some nodes like code block or image into WYSIWYG, right? Currently, there is no formal API for creating and inserting nodes in the specific position. However, the desired node can be inserted at the current cursor position using command API as below.

// insert code block
editor.exec('codeBlock');
// insert image node
editor.exec('addImage', {
  altText: 'mytext ()[]<>',
  imageUrl: 'https://picsum.photos/200'
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I insert Markdown in WYSIWYG mode? #1056 - GitHub
Another idea was to insert a custom uid with editor.insertText(...) , read the markdown content with editor.getMarkdown( ) , search & replace ...
Read more >
Display non-markdown content in the WYSIWYG mode of the ...
The problem is that when the Static Site Editor loads the markdown page contents, it expects to be able to render markdown into...
Read more >
How to use WYSIWYG (HTML)& Markdown editor ... - YouTube
With an intuitive interface, our knowledge base editor lets you create incredible documentation with rich text formatting choices.
Read more >
Markdown editor | WYSIWYG (HTML) editor - Document360
In WYSIWYG mode, you would use the formatting toolbar to insert an image, then click on the image to view options to change...
Read more >
Getting Started | Markdown Guide
You can add Markdown formatting elements to a plaintext file using a text editor application. Or you can use one of the many...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found