getkirby / kirby

Kirby's core application folder
https://getkirby.com
Other
1.27k stars 167 forks source link

Writer field: Option to disable markdown input #3138

Open mlthrk opened 3 years ago

mlthrk commented 3 years ago

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 commented 3 years ago
  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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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

lukasbestle commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

mlthrk commented 2 years ago

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

distantnative commented 2 years ago

@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 commented 2 years ago

@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 commented 2 years ago

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 commented 1 year ago

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 commented 1 year ago

@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 commented 1 year ago

@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 commented 5 months ago

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