tui.editor icon indicating copy to clipboard operation
tui.editor copied to clipboard

Widget syntax is not unwrapped in markdown in WYSIWYG mode

Open mib112 opened this issue 3 years ago • 4 comments

Describe the bug

If you use a widget in WYSIWYG mode and then check the markdown using getMarkdown, you can see that the widget syntax is included in the markdown.

To Reproduce

Steps to reproduce the behavior:

  1. In WYSIWYG mode, use a Widget https://github.com/nhn/tui.editor/blob/master/docs/en/widget.md
  2. check the markdown using getMarkdown
  3. markdown will contain $$widgetN ... $$

Expected behavior

Widget syntax should be unwrapped in WYSIWYG mode.

Screenshots

Bildschirmfoto 2022-08-08 um 13 54 12 Bildschirmfoto 2022-08-08 um 13 54 32

Desktop (please complete the following information):

  • OS: MacOS X
  • Browser Chrome, Safari
  • Version Chrome 103.0.5060.134, Safari 15.6

mib112 avatar Aug 08 '22 12:08 mib112

Steps to reproduce for a default @username behaviour:

    let mentionRule = /(?<before>^|\s+)@(?<username>[a-z]+)(?<after>\s+)/;
    let ownWidgetRules = [
        {
            rule: mentionRule,
            toDOM(text) {
                const rule = mentionRule ;
                const matched = text.match(rule).groups;
                const mentionContainer = document.createElement('span');
                mentionContainer.innerHTML = (matched.before
                                                + '<a href="https://some-domain/profiles/people/'
                                                + matched.username + '" data-username="'
                                                + matched.username + '">@'
                                                + matched.username + '</a>' + matched.after);
                return mentionContainer;
            },
        },
    ];
// add them in tui-editor options with => widgetRules: ownWidgetRules,

It's in general very buggy if you move the cursor! Sometimes it gets replaced and other times not!

But if you change to markdown and then back to WYSIWYG you always will get this content: $$widget0 @usernamegiven $$

renderer-problems

markusbrunner-design avatar Aug 08 '22 14:08 markusbrunner-design

Hi, is there any news regarding this? Or a workaround to avoid having those $$widget text? Thanks!

juanpbarani avatar Dec 05 '22 16:12 juanpbarani

Hey, I have exactly the same problem. In WYSIWYG mode editor#getMarkdown returns the $$ widget $$ wrapper. In MARKDOWN mode this problem does not occur. It is really annoying. Could you please check that?

Thanks in advance, Patrick

paddy1905 avatar Feb 23 '24 11:02 paddy1905