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

**bold**? becomes <strong>bold</strong>?

Open thojoh opened this issue 3 years ago β€’ 14 comments

Describe the bug

While in WYSIWYG edit type and changing text to bold followed by question-mark will make it change to strong-tag instead. These changes will also follow if you switch from WYSIWYG to Markdown.

Using: @toast-ui/editor 3.2.1

To Reproduce

Steps to reproduce the behavior:

**Test-text**? becomes <strong>Test-text</strong>? **Test-text** ? becomes **Test-text** ? **Test-text?** becomes **Test-text?**

Expected behavior

**Test-text**? becomes **Test-text**?

Screenshots

image image

Desktop (please complete the following information):

  • OS: [osx]
  • Browser [chrome]
  • Version [Version 106.0.5249.119 (Official Build) (arm64)]

thojoh avatar Oct 21 '22 07:10 thojoh

It seems to have something to do with one of the tasks we did. I'll check it out later.

jwlee1108 avatar Oct 27 '22 12:10 jwlee1108

I have the same behavior with the last version of vue-editor.

cgiuliani avatar Oct 27 '22 15:10 cgiuliani

I have the same behaviour with the pure js version. Is there any branch / fix available?

freegroup avatar Feb 09 '23 15:02 freegroup

This feature makes many problem. Due to the structure of the current editor, it is difficult to deal with it. so we'll rollback commit over this issue soon. @jajugoguma takes this issue.

jwlee1108 avatar Feb 09 '23 15:02 jwlee1108

I saw above that you guys are already working on this, but is there any workaround or mitigation available to avoid this error?

  • thanks for this great piece of software

freegroup avatar Feb 16 '23 23:02 freegroup

Also interested in an solution :)

MoritzGlantz avatar Feb 24 '23 16:02 MoritzGlantz

In the meantime I'm using a mitigation in my project. It is not perfect, but works for me

in global scope ( https://github.com/freegroup/electra/blob/main/common/public/js/polyfill.js#L8-L20 )

let tokenMap = {
    "<strong>": "**",
    "</strong>": "**",
    "<em>": "*",
    "</em>": "*"
}
String.prototype.tuiMarkdownFix = function(){
    var re = new RegExp(Object.keys(tokenMap).join("|"),"g");

    return this.replace(re, function(matched){
        return tokenMap[matched];
    });
}

when fetching the markdown from the editor (https://github.com/freegroup/electra/blob/main/author/public/js/editor/wysiwyg/editor.js#L45 )

let markdown = this.tuiEditor.getMarkdown().tuiMarkdownFix()

freegroup avatar Feb 24 '23 16:02 freegroup

That’s cool @freegroup! I thought about doing something similar. This does not consider markdown code blocks and inline code, right?

MoritzGlantz avatar Feb 24 '23 16:02 MoritzGlantz

codeblocks, which contains <strong> or one of the other tags, gets converted...unfortunately. But for my usecase, it is pretty fine.

freegroup avatar Feb 24 '23 16:02 freegroup

We forgot to create a release, see related issues (v3.2.2)

jwlee1108 avatar Feb 24 '23 16:02 jwlee1108

good news! Thanks. is this available via npm as well?

freegroup avatar Feb 24 '23 16:02 freegroup

It was actually published to npm last week. we missed writing the release notes.

jwlee1108 avatar Feb 24 '23 16:02 jwlee1108

3.2.2 seems to fix this. At least in my case.

MoritzGlantz avatar Mar 02 '23 17:03 MoritzGlantz

@jwlee1108 so was it fixed or not? Perhaps we could close this issue if it was?

stukalin avatar May 08 '25 09:05 stukalin