tinacms / tinacms

A fully open-source headless CMS that supports Markdown and Visual Editing
https://tina.io
Apache License 2.0
11.19k stars 564 forks source link

Escaping does not work properly in mdx editor #4503

Open KVPlotnikov opened 3 weeks ago

KVPlotnikov commented 3 weeks ago

Describe the issue that you're seeing. Any Loom videos or screenshots usually help a lot!

I am experiencing an issue with the MDX editor in TinaCMS where curly braces are not being escaped properly. When I input a string like GET/{uuid} into a rich-text field formatted in MDX, the editor initially adds an escape character (\) before the curly brace ({). However, after saving and reloading the document, the escape character disappears, and the editor throws an error saying "Unexpected expression uuid". 2024-04-23_17-15-45 2024-04-23_17-16-06 2024-04-23_17-16-22 2024-04-23_17-16-48

Reproduction

https://github.com/KVPlotnikov/tina-self-hosted-demo

Steps to reproduce

  1. Open the MDX editor in TinaCMS.
  2. Enter the string GET/{uuid} in a rich-text field.
  3. Switch the view from rich-text editor to MDX format view; observe that the editor automatically adds a \ before the {.
  4. Save the document and reload the page OR just switch to rich-text editor mode and then row-editor again.
  5. The previously added escape character is gone, and an error appears concerning the uuid expression.

System Info

System:
    OS: Windows 11 10.0.22631
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 10.45 GB / 31.85 GB
  Binaries:
    Node: 20.7.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.22 - D:\projects\astral\landing\node_modules\.bin\yarn.CMD
    npm: 10.1.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Chrome: 123.0.6312.123
    Edge: Chromium (123.0.2420.97)
    Internet Explorer: 11.0.22621.1
  npmPackages:
    @tinacms/auth: ^1.0.4 => 1.0.4
    @tinacms/cli: ^1.5.43 => 1.5.43
    @tinacms/datalayer: ^1.2.33 => 1.2.33
    tinacms: ^1.6.1 => 1.6.1

Validations