joplin icon indicating copy to clipboard operation
joplin copied to clipboard

Rich Text Editor should not destroy markdown

Open schlichtanders opened this issue 1 year ago • 4 comments

Operating system

Linux

Joplin version

2.13.2

Desktop version info

Joplin 2.13.12 (prod, linux)

Client ID: c7dff86521c841b8b1f92fa6239cc51c Sync Version: 3 Profile Version: 44 Keychain Supported: No

Revision: e027cdc

OCR: 0.3.2 Outline: 1.5.13 Typograms: 1.0.0

Current behaviour

  1. install the typogram plugin
  2. put the typogram example in a markdown note using Split Editor, save
```typogram
          +----+     o    |          o       *      *   .----------.
  *-+---. '-* -+-    |    v         ^         \    /    |.--------.|
    |   '--->   +----+  ->*<-      /   .-+->*<-o--+     |'------> ||
  <-'       *---+     |<----->|   +----' |  ^   \       '---------'|
                                         |__|    v      *----------'
```
  1. switch to Rich Text Editor, make a change somewhere else and save
  2. go back to Split Editor, you should already see the destroyed typogram example, save again
  3. go back to Rich Text Editor and see that it finally got destroyed.

Expected behaviour

Even though the Rich Text Editor does not support all plugins smoothly, it should not destroy such information, shouldn't it?

Logs

No response

schlichtanders avatar Feb 12 '24 21:02 schlichtanders

This typogram contains valid Markdown elements so the RTE doesn't "destroy" it, it renders it. To prevent valid Markdown from being rendered, you need to wrap it in a code block (maybe that's something that the plugin needs to fix)

laurent22 avatar Feb 13 '24 12:02 laurent22

@laurent22 Please reopen, I think the issue got misunderstood.

Of course I fenced the typogram - the confusion arose because here in github the fences are not shown. I now managed to show them - see above

schlichtanders avatar Feb 13 '24 14:02 schlichtanders

Would you mind sharing the whole note as a Markdown file so that we can see exactly how it looks?

laurent22 avatar Feb 13 '24 15:02 laurent22

try this one:

my markdown file

```typogram
          +----+     o    |          o       *      *   .----------.
  *-+---. '-* -+-    |    v         ^         \    /    |.--------.|
    |   '--->   +----+  ->*<-      /   .-+->*<-o--+     |'------> ||
  <-'       *---+     |<----->|   +----' |  ^   \       '---------'|
                                         |__|    v      *----------'
```

schlichtanders avatar Feb 19 '24 11:02 schlichtanders

There is now an example available for how to make a renderer plugin work in the rich text editor:

https://github.com/laurent22/joplin/blob/a59ad20bd57981a20f4fa3e66fde05ffe6a08367/packages/app-cli/tests/support/plugins/content_script/src/markdownItTestPlugin.ts#L27-L34

https://github.com/laurent22/joplin/blob/a59ad20bd57981a20f4fa3e66fde05ffe6a08367/packages/app-cli/tests/support/plugins/content_script/src/markdownItTestPlugin.ts#L36-L38

The data-joplin-language, data-joplin-source-open, data-joplin-source-close, class="joplin-editable", and <pre class="joplin-source" elements and attributes help Joplin reconstruct the original markdown that created the diagram.

Edit: See also https://github.com/laurent22/joplin/pull/10178

Since it's not something that we can fixed I reported it on the plugin repository: https://github.com/cwesson/joplin-plugin-typograms/issues/1

laurent22 avatar Apr 15 '24 14:04 laurent22