J
J
Juniorrrrr2020-04-20 15:01:38
JavaScript
Juniorrrrr, 2020-04-20 15:01:38

How to convert text in google docs to your custom editor?

Good afternoon. The task is to write an editor that will understand links, bold, italics, etc., which are added via Google docs.

That is, it turns out that we added, for example, a test text - which will be a bold link and, in addition, in italics in Google Dock, then copy the entire line and paste it into our editor, this word should be the same link, bold with italics as in Google Docks.
As a text input field, I use div with the contenteditable attribute

. The difficulty arises in the fact that there are a lot of different cases, they are just dark, like Google, depending on the indentation or highlighting of the word, wraps the email.

For example, a link, it can be in the following form

<a><span style="font-weight:bold">Text</span></a>
<a style="font-weight:bold">Text</a>
<span style="font-weight:bold"><a>Text</a></span>

and everything in this spirit. He can mix it up with P or div tags, and the further you go, the more mess you get.

Can you please tell me if there is a less painful way to handle this case?
Maybe there are some ready-made solutions?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question