statamic / cms

The core Laravel CMS Composer package
https://statamic.com
Other
4.11k stars 538 forks source link

Wrapping multiline text in markdown editor #11076

Open andreas-eisenmann opened 2 weeks ago

andreas-eisenmann commented 2 weeks ago

Bug description

Our customer found two issues when trying to wrap multiline text in the markdown editor:

Toggle issue

Have a look:

Peek_2024-11-06_20-49

I think the root cause lies here:

https://github.com/statamic/cms/blob/f01281268ae2fec73d52954dc536998db7d9c2a1/resources/js/components/fieldtypes/markdown/MarkdownFieldtype.vue#L291

The RegEx pattern /^\*{2}(.*)\*{2}$/ doesn't match multiline text. If you add the ms flags, everything works fine:

Peek_2024-11-06_20-54

New RegEx pattern: /^\*{2}(.*)\*{2}$/ms.

Empty line at the end of the text

If you mark an empty line at the end of the text (or paragraph) to wrap, the empty line is also being wrapped, so there will be a line at the end of the paragraph which only contains e.g. **. This won't be rendered as expected in the frontend. So you have to be veeery very careful which lines have to marked and which lines should not. It's very easy to mark too much by mistake. This is really annoying. Is it possible to "trim" the marked text block which should be wrapped e.g. by ** when applying bold mode?

Peek_2024-11-06_20-59

How to reproduce

See description.

Logs

No response

Environment

Environment
Application Name: **************
Laravel Version: 10.48.22
PHP Version: 8.2.12
Composer Version: 2.6.5
Environment: local
Debug Mode: ENABLED
URL: localhost
Maintenance Mode: OFF

Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: statamic
Database: pgsql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file

Locales
Installed
Locales Version: 1.9.0
Protected

Localization
Installed: de, en
LaravelLang\Attributes\Plugin: 2.9.4
LaravelLang\HttpStatuses\Plugin: 3.8.2
LaravelLang\Lang\Plugin: 13.12.0
Protected Locales: de, en
Publisher Version: 14.7.1

Livewire
Livewire: v3.5.4

Statamic
Addons: 3
Antlers: runtime
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 4.53.2 PRO

Statamic Addons
anakadote/statamic-recaptcha: 1.0.14
statamic-rad-pack/runway: 6.6.2
statamic/eloquent-driver: 3.3.3

Statamic Eloquent Driver
Asset Containers: eloquent
Assets: eloquent
Blueprints: eloquent
Collection Trees: eloquent
Collections: eloquent
Entries: eloquent
Forms: eloquent
Global Sets: eloquent
Global Variables: eloquent
Navigation Trees: eloquent
Navigations: eloquent
Revisions: eloquent
Taxonomies: eloquent
Terms: eloquent

Installation

Fresh statamic/statamic site via CLI

Additional details

No response