froala / wysiwyg-editor

The next generation Javascript WYSIWYG HTML Editor.
https://www.froala.com/wysiwyg-editor
Other
5.3k stars 672 forks source link

Links styles #4194

Open AlexeyShaykov opened 3 years ago

AlexeyShaykov commented 3 years ago

Hi!

i`m try to passed multible link Tested on https://froala.com/wysiwyg-editor/ - passed from clipboard few links

Expected behavior.

all links have a tag with link styles

Actual behavior.

link parsed as text

<p>https://froala.com/wysiwyg-editor/</p>
Steps to reproduce the problem.

copy string with few links in clipboard, then passed from clipboard to editor

try this https://froala.com/wysiwyg-editor/docs/events/ https://froala.com/wysiwyg-editor/

Editor version.

last version

OS.

Ubuntu

Browser.

Chrome 88

AlexeyShaykov commented 3 years ago

i ty to fix it something like this:

'paste.before': e => {
            const pastedString = e.clipboardData.getData('text');
            const urlReg = /(http:\/\/|www\.|https:\/\/)\S+/i;
            const isContainURL = urlReg.test(pastedString);

            if (!isContainURL) return;

            this.$nextTick(() => {
              const urlify = text => {
                const isContainURL = urlReg.test(text);

                if (!isContainURL) return `<p>${text}</p>`;

                return text.replace(urlReg, url => {
                  return `<a href="${url}">${url}</a>`;
                });
              };
              that.editor.html.insert(
                pastedString
                  .split('\n')
                  .map(urlify)
                  .filter(it => it !== '')
                  .join(''),
              );
            });
            return false;
          },
MeghashreeAP commented 2 years ago

Thanks for your feedback. This issue is not reproducible or have been found to be fixed on the latest Froala release v4.0.8. Can you please upgrade and check?