discourse/plugins/chat/assets/javascripts/discourse/components
Régis Hanol 7bb363b4cb
FIX: preserve selection formatting in link-insertion modal (#39374)
When CMD+K is pressed (or the link toolbar button clicked) with a
non-empty selection, the modal now only asks for the URL — the existing
selection is wrapped as the link's display content, keeping every inline
mark and block context under it.

Previously the modal pre-filled a "Link text" field from the selection.
In the rich-text editor this serialized the selected slice to markdown
and leaked syntax the user never typed: selecting a word inside an H2
produced `## word`, selecting text inside an inline code span produced
backticks, selecting inside a list produced `- word`, and so on.

The new behavior wraps the selection directly instead of replacing it:

- Rich-text editor: adds a `link` mark over the selection range,
preserving every underlying mark (bold, italic, code, emoji, mentions,
…) and every surrounding block (heading, list, blockquote, …).
- Markdown editor: inserts `[` at the selection start and `](url)` at
the end, preserving any literal characters in between.

Both editors now behave identically for the common "select then link"
flow. The link-text field is still shown when:

- Inserting a link with no selection (the user needs to provide display
text).
- Editing an existing link via the link-toolbar (the user may want to
change the displayed text).

A small `applyLink(url)` method is exposed on the text-manipulation API
of each editor, and `toolbarEvent.applyLink` lets the modal pick the
right path without knowing which editor is active. The chat composer is
wired through the same path.

Ref - t/182095
2026-05-20 11:22:35 +02:00
..
channel-icon DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
channel-name DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
channel-title DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat DEV: Remove ember-template-lint (#40077) 2026-05-15 20:54:13 +01:00
chat-message/blocks DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
reviewable DEV: Remove reviewable_ui_refresh feature flag and legacy code (#36752) 2026-02-23 10:45:36 +08:00
styleguide DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
svg REFACTOR: consolidate empty states, add invite variant (#33455) 2025-07-09 12:34:04 -04:00
thread-title DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
thread-unread-indicator FEATURE: add mention count to threads (#29739) 2024-11-14 14:10:12 +04:00
upsert-category DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
user-menu DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
user-threads DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
browse-channels.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
channels-list-direct.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
channels-list-public.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
channels-list-starred.gjs FIX: regression in channel list and make improvements (#36436) 2025-12-03 13:28:36 -08:00
channels-list.gjs DEV: Consolidate i18n import paths (#29804) 2024-11-19 20:45:18 +00:00
chat-channel-archive-status.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-channel-card.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-channel-chooser-header.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-channel-chooser-row.gjs DEV: Update lint-config and apply autofixes (#35991) 2025-11-12 14:48:49 +01:00
chat-channel-chooser.js FIX: Chat webhook channel chooser filter always returns no matches (#38427) 2026-03-10 17:49:21 +01:00
chat-channel-filter.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-channel-leave-btn.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-channel-metadata.gjs FIX: chat: shows placeholder instead of timer for empty chats (#33105) 2025-06-09 15:59:04 +08:00
chat-channel-preview-card.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-channel-row.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-channel-sidebar-context-menu.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-channel-sidebar-context-notification-submenu.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-channel-status.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-channel-title.gjs
chat-channel-unread-indicator.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-channel.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-composer-dropdown.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-composer-message-details.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-composer-upload.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-composer-uploads.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-composer.gjs FIX: preserve selection formatting in link-insertion modal (#39374) 2026-05-20 11:22:35 +02:00
chat-drawer.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-emoji-avatar.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-footer.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-header.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-mention-warnings.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-message-actions-desktop.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-message-actions-mobile.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-message-collapser.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-message-in-reply-to-indicator.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-message-reaction.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-message-separator.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-message-text.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-message-thread-indicator.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-message.gjs DEV: Remove ember-template-lint (#40077) 2026-05-15 20:54:13 +01:00
chat-messages-container.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-messages-scroller.gjs DEV: Replace popperjs with floating-ui (#35492) 2025-12-09 01:23:46 +01:00
chat-notice.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-notices.gjs DEV: Use the "new" service import (#26059) 2024-03-06 18:05:11 +01:00
chat-pinned-messages-list.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-replying-indicator.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-retention-reminder-text.gjs DEV: Rename htmlSafe to trustHTML from @ember/template (#38465) 2026-03-11 18:57:22 -03:00
chat-retention-reminder.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-search.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-side-panel-resizer.gjs
chat-side-panel.gjs FIX: do not store 0 has min width for thead panel (#30818) 2025-01-16 16:03:35 +01:00
chat-sidebar-indicators.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-skeleton.gjs DEV: Rename htmlSafe to trustHTML from @ember/template (#38465) 2026-03-11 18:57:22 -03:00
chat-thread-heading.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-thread-list.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-thread-participants.gjs DEV: Consolidate i18n import paths (#29804) 2024-11-19 20:45:18 +00:00
chat-thread-title-prompt.js DEV: standardise toasts duration (#32741) 2025-05-15 14:59:37 +02:00
chat-thread.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-to-topic-selector.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-upload-drop-zone.gjs DEV: Consolidate i18n import paths (#29804) 2024-11-19 20:45:18 +00:00
chat-upload.gjs DEV: Rename htmlSafe to trustHTML from @ember/template (#38465) 2026-03-11 18:57:22 -03:00
chat-user-avatar.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-user-display-name.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
chat-user-info.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
collapser.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00
full-page-chat.gjs FEATURE: Add full-text search for chat messages (#34704) 2025-10-22 11:30:35 +02:00
thread-notifications-tracking.gjs DEV: replaces topic-notifications-options by DMenu (#30298) 2024-12-16 19:59:18 +01:00
toggle-channel-membership-button.gjs DEV: Consolidate reusable components into ui-kit (#38703) 2026-05-11 18:07:36 -03:00