Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writer field: Option to disable markdown input #3138

Open
mlthrk opened this issue Feb 3, 2021 · 26 comments · Fixed by #4112
Open

Writer field: Option to disable markdown input #3138

mlthrk opened this issue Feb 3, 2021 · 26 comments · Fixed by #4112
Labels
type: bug 🐛 Is a bug; fixes a bug

Comments

@mlthrk
Copy link

mlthrk commented Feb 3, 2021

Describe the bug
When writing in or pasting to a Writer field, text is parsed for the mark characters of the field’s active marks and automatically converted. Thus it is not possible to use these characters for other purposes, e.g. writing the “gender star”. Escaping the mark characters with a backslash seems to be ignored.

To Reproduce
Steps to reproduce the behavior:

  1. Add a Writer field to an existing blueprint
  2. Write or paste text containing more than one asterisk

Expected behavior

  1. Add option to disable markdown input
  2. Escape markdown characters

Screenshots
Gender*

Kirby Version
3.5+

@afbora afbora added the type: bug 🐛 Is a bug; fixes a bug label Feb 5, 2021
@afbora afbora added this to the 3.5.x milestone Feb 5, 2021
@afbora
Copy link
Member

afbora commented Feb 5, 2021

  1. You can disable marks with marks: false witn new 3.5.2 release (still RC, will release Feb 9)
  2. When you disabled marks, you'll still see marks on preview editor, this issue will be fixed 3.5.x.

@mlthrk
Copy link
Author

mlthrk commented Feb 6, 2021

Thanks for looking into this. Not sure if we are talking about the same issue?

Disabling marks completely with marks: false already works for me with the current 3.5.1 release. I just tried out 3.5.2-rc.1 and didn’t notice much of a difference.

In Writer/Editor.js there are two default options that seem to do what I’m after, though. Setting both disableInputRules and disablePasteRules to true, markdown parsing is disabled but it seems still possible to use the marks formatting of the Writer field. If this was an appropriate way to do this, it’d be great to be able to set these options in a blueprint.

@davidjablonski
Copy link

I hope it’s okay for me to add to this – not sure whether this qualifies as an additional issue.
I’m running into the same issue as described above with the default text block in fields:block. I haven’t found a way to disable marks for this block type or am I missing something?
Thanks!

@moritzebeling
Copy link

Since we have text formatting via the tooltip, is the markdown-thing still a feature that is needed in the writer field? Maybe the md parsing can be removed all together?

At least in German the gender-star problem makes it really hard to use the writer field. Thanks for looking into it!

@lukasbestle
Copy link
Member

For power users the Markdown syntax can be really useful as it's much faster than using the tooltip. I agree it's not optimal, but I feel like we cannot make everyone happy at the same time.

@moritzebeling
Copy link

True, but for speed one can easily use cmd+i instead of * to make things italic, which I’d say is equally quick, comfortable and intuitive. While non-power user*innen don’t have such an easy alternative.

It’s fairly easy for power users to adjust to that – while it’s not easy for non-power users to understand why things look weird when they use the gender star and that they have to remember some work around.

@possible-is
Copy link

I second @moritzebeling
I have just worked on a site with a lot of Word-files to copy paste into the writer field and came upon the same annoying behaviour. the gender stars really show an unexpected behaviour, which is hard to understand for editors without the knowledge of markdown. the beauty of the writer field is, that you could now work in there without any markdown skills...

@medienbaecker
Copy link
Contributor

medienbaecker commented Oct 27, 2021

I agree it's not optimal, but I feel like we cannot make everyone happy at the same time.

Maybe you could change the markdown shortcut behavior so the formatting characters need a line break or space.

Look at this, tiptap has markdown shortcuts too and they don't have this issue:
https://tiptap.dev/examples/markdown-shortcuts

Screenshot-27-10-2021_13-29-31 2021-10-27 13_31_34

@moritzebeling
Copy link

As mentioned above, these are working workarounds:

marks: false
# or
marks:
  - bold

Which unfortunately burns the possibility of having italic text. So it would be great to be able to disable the "smart" markdown behaviour, since I think the confusion it generates is by far bigger than the benefits.

@moritzebeling
Copy link

moritzebeling commented Dec 26, 2021

Over the course of this year, I upgraded several Kirby projects to version 3.5 and 3.6, also taking advantage of the writer field and blocks editor.
Since every german-language website needs those asterisks now, clients and editors call me up or send bug reports complaining about that asterisk behavior.
I now find myself explaining regularly to clients that they have to choose for either italics OR Gender-Sternchen. So after they decide for the Gender-Sternchen, I then have to explain to the graphic designer, that we can't have italic text anymore.

Maybe it’s just me, maybe I just haven’t found a way to implement a fix or educate clients, but: this seemingly small thing has a huge impact.

As mentioned above, I don’t think the advantages of printing italic text between 2 asterisks outweighs the requirement to be able to use the asterisk otherwise.

@mlthrk
Copy link
Author

mlthrk commented Dec 26, 2021

Maybe it’s just me, maybe I just haven’t found a way to implement a fix or educate clients, but: this seemingly small thing has a huge impact.

What you can try to do until this is fixed (at least until you perform the next upgrade) is to change disableInputRules:!1 and disablePasteRules:!1 in kirby/panel/dist/js/index.js (and possibly also media/panel/.../js/index.js) to disableInputRules:!0 and disablePasteRules:!0. This seems to disable markdown input but keeps marks formatting active.

@moritzebeling
Copy link

moritzebeling commented Jan 24, 2022

Sorry for being annoying on this topic, but I have regularly people calling me up requesting to "solve that italic-bug"

@lukasbestle
Copy link
Member

Would it make sense to introduce a new field option that completely disables the Markdown syntax for all marks? The keyboard shortcuts would still work, but all text syntax would be ignored and treated as actual text.

@moritzebeling
Copy link

moritzebeling commented Jan 24, 2022

Thank you four sour suggestion, I think that could be nice!
For German language, you could then simply disable it, while all non German users don’t have to do anything and could benefit from markdown input.

The downside would be, that german users would always also have to override the text block then, but maybe that's what it is... the most important thing right now would be to quickly have a working and downwards compatible status quo solution – just as the one you suggested.

@distantnative
Copy link
Member

I'd second @lukasbestle's suggestion.

We can be annoyed by the general issue, but that's where Markdown syntax just collided with a variant of gender neutral script. Nothing really to do about it. Although, I'd think that it'll shift away from using the asterisk and rather using a colon, that's already the trend in academia - probably in 2-3 years the more common variant.

@medienbaecker
Copy link
Contributor

Sorry if I'm being stubborn but wouldn't it be better to improve the shortcut behavior like I suggested in my comment above?

Gender stars are in the middle of words — italic formatting is something you do after a space or line break.

@bastianallgeier
Copy link
Member

@medienbaecker is right. That problem is actually not too hard to fix. The input rule was just outdated. I updated it with the same rule that Tiptap uses and now it works.

@bastianallgeier
Copy link
Member

@afbora afbora modified the milestones: 3.6.x, 3.6.2 Jan 25, 2022
@mlthrk
Copy link
Author

mlthrk commented Jan 25, 2022

Hi, thanks for this! :) Direct input works great! Would it be possible to update pasteRules as well?

@distantnative distantnative reopened this Jan 25, 2022
@distantnative
Copy link
Member

@bastianallgeier I tried with the paste rules from tiptap

pasteRules({ type, utils }) {
    return [
      utils.markPasteRule(/(?:^|\s)((?:_)((?:[^_]+))(?:_))/g, type),
      utils.markPasteRule(/(?:^|\s)((?:\*)((?:[^*]+))(?:\*))/g, type)
    ];
  }

However, if I try to paste Hello*this is really *great* - it removes the gap after really, puts great correctly in italics, but doesn't remove the * on both sides of great. And I can't quite understand if there is a difference in our markPasteRule util function vs. tiptap.

@bastianallgeier bastianallgeier removed this from the 3.6.2 milestone Jan 28, 2022
@bastianallgeier
Copy link
Member

@distantnative our paste rules are indeed not working as the ones in tiptap. They seem to have spent more time on enhancing them. I think we need to take a closer look at their implementation. Right now it does not make sense to update the rules. The result is even worse than before.

@arnaudjuracek
Copy link

Bumping this issue with a different use case which requires the same fix :

Pasting an URL containing at least two _ into a writer field causes the link to be split at the first underscore :

image

(using the URL https://example.com/url_with_underscores on the online Kirby demo @ 3.6.6).

My suggestion would be to add a field option to disable markdown parsing.

@jangoedde
Copy link

jangoedde commented Oct 14, 2022

hey everyone, is there an update or a solution to the asterisk problem? The problem is now appearing in several of our projects, especially when the text block is used...

@moritzebeling
Copy link

moritzebeling commented Oct 14, 2022

@jangoedde Which version are you using? I am in 3.8 and to me it seems that the problem is no longer occurring... both typing and pasting

@jangoedde
Copy link

@moritzebeling:
Tested on different Versions: 3.5.8, 3.7.5, 3.8.0 ...
But you're right, 3.8.0 handles it differently, although it's not 100% working there either.
Maybe disabling markdown manually would be helpful.

@mrflix
Copy link
Contributor

mrflix commented Apr 2, 2024

I'm on Kirby 4.1.2 and text between gender stars gets converted to italics when pasting text.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Is a bug; fixes a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.