Commit Graph

63 Commits

Author SHA1 Message Date
a14472606c FEATURE: Tight lists by default on rich composer (#31969)
Tight lists are lists that look like this:

* Item 1
* Item 2
* Item 3

Loose lists look like this:

* Item 1

* Item 2

* Item 3

There is a place for the latter, but the former is more
common default behaviour for writing apps and widgets, so
we are overriding the prosemirror default to use tight lists.

Eventually we will have a shortcut or other special behaviour
to switch between the list styles.
2025-03-25 14:36:47 +10:00
2a73387029 FIX: paste url on rich editor with partial paragraph selected (#31906)
Fixes an incorrect logic on `transformPasted` that was causing a
`TypeError: Cannot read properties of null (reading 'marks')` when only
part of a paragraph was selected.

Adds tests
2025-03-19 17:47:08 -03:00
b1b2b8e4c8 UX: keep existing marks when pasting a url to make a link in rich editor (#31814) 2025-03-18 07:15:35 -03:00
7026134ddd UX: strip partial :emoji when adding emoji from picker (#31810)
When a user typed `:emoji` using the autocomplete on the rich editor,
but then used the "more" option to open the emoji picker and picked an
emoji from there, we were leaving the dangling `:emoji` there and just
added the emoji node after it.

We now check if there's a partial emoji exactly at the caret position,
and replace it too.
2025-03-13 22:01:09 -03:00
47248573fe FIX: copy image from cooked to rich editor (#31804)
When copying images from cooked, we have a `data-base62-sha1` attribute
instead of a `data-orig-src` that we were expecting.

This PR fixes it and adds a system test.
2025-03-13 21:24:24 -03:00
979d0ca731 FIX: Disable composer editor switch when uploading (#31789)
When you are uploading, it just causes weird problems
when you switch between markdown/rich editors, and it's
not something we really want to support. This commit
disables the Composer::ToggleSwitch while uploading.
2025-03-13 13:13:44 +10:00
d1a8ed1beb FEATURE: add horizontal_rule rich editor input rule (#31788)
Adds support to typing `---`, `___` or `***` to create a horizontal
rule.

Converting when typing `---` is actually written here as an en-dash +
`-`, because the typographer replacements extension turns `--` into an
en-dash first.

`___` and `***` are only triggered after a whitespace, because they
could also mean bold+italic.
2025-03-12 22:45:10 -03:00
9b692ede96 UX: make an em-dash from en-dash plus hyphen on rich editor (#31787)
As `--` is converted to an en-dash, we need to make an en-dash plus
another `-` into an em-dash.
2025-03-12 22:22:08 -03:00
6a80c6bf43 UX: remove auto-conversion from .. -> … (#31770) 2025-03-12 15:48:38 -03:00
d56e69e7c0 FEATURE: add trailing-paragraph rich editor extension (#31713)
Continues the work done on
https://github.com/discourse/discourse/pull/30815.

Adds a plugin to enforce an empty trailing paragraph.

---------

Co-authored-by: David Taylor <david@taylorhq.com>
2025-03-11 20:12:31 -03:00
c9518f2384 FEATURE: add onebox rich editor extension (#31691)
Continues the work done on
https://github.com/discourse/discourse/pull/30815.

Adds a `onebox` and an `onebox_inline` node spec, their serializers, and
a plugin that automatically converts links to oneboxes.
2025-03-11 20:09:33 -03:00
b9e037471e FEATURE: add typographer-replacements rich editor extension (#31182)
Continues the work done on
https://github.com/discourse/discourse/pull/30815.

Adds input rules to support the same [custom typographer
replacements](https://github.com/discourse/discourse/blob/main/app/assets/javascripts/discourse-markdown-it/src/features/custom-typographer-replacements.js)
we support when cooking.
2025-03-06 20:56:55 -03:00
a5cacde681 FEATURE: add code-block rich editor extension (#31179)
Continues the work done on
https://github.com/discourse/discourse/pull/30815.

Extends the ProseMirror-markdown `code-block` node by integrating our
existing HighlightJS pipeline for code highlighting and adding a node
view with a `<select>` to change the language of the block.

We're also adding the markdown paste extension, which handles converting
pasted text/plain to rich content if it contains Markdown.

---------

Co-authored-by: Martin Brennan <martin@discourse.org>
2025-03-06 20:43:33 -03:00
f5c2a4dbbd DEV: Drop experimental enable_diffhtml_preview setting (#31306)
This was intended to provide a better UX for interactive elements in the
composer preview. However, the morphing strategy has irreconcilable
conflicts with our `decorateCooked` API, and so we have been unable to
enable this by default.

Going forward, we're focussing efforts on the WYSIWYG composer to
provide this kind of smooth UX, so we're dropping the
`enable_diffhtml_preview` approach.
2025-02-12 15:58:30 +00:00
0e61565b2b FEATURE: introduce a ProseMirror editor (#30815)
This is the first in a series of PRs to introduce a
ProseMirror-based
WYSIWYM editor experience
alongside our current textarea Markdown editor.

Behind a hidden site setting, this PR adds a toggle to the composer
toolbar, allowing users to switch between the two options.

Our implementation builds upon the excellent ProseMirror and its
non-core Markdown
module, using the
module's schema, parsing, and serialization definitions as the base for
further Discourse-specific features.

An extension API is included to enable further customizations.

The necessary extensions to support all Discourse's core and core
plugins features **will be implemented in subsequent PRs**.

---------

Co-authored-by: David Taylor <david@taylorhq.com>
2025-02-04 14:37:18 -03:00
c64b5d6d7a FEATURE: Multiple Draft Topics (#30790)
Allows users to save multiple topic and personal message drafts,
allowing more flexibility around content creation.

The "New Topic" button will now always start a fresh topic. Drafts can
be resumed from the drafts dropdown menu or using the "My Drafts" link
in the sidebar.

Since drafts require a unique `draft_key` and `user_id` combination, we
have updated the format of the draft key for both topics and personal
messages. They will now have a prefix like "new_topic_" or
"new_message_" with the timestamp of when the composer was first opened
appended.
2025-01-29 10:23:26 +04:00
9bdd97db42 FIX: editing post while replying (#29985)
BEFORE: if you click the "reply" button on a post and then decided that you want to "edit" the same post, clicking the "edit" button would do nothing. Clicking "edit" on another post works, but editing the same post would appear broken.

AFTER: if you click the "edit" button, it will properly load the content of the post you're trying to edit. No matter which one it is.

This was somewhat tricky to track down as the system specs seemed to contradict the qunit tests until I realized that the qunit tests were only testing the edit on the 1st post and the system specs were testing on replies.

I improved the qunit tests to test both editing OP and a reply and (hopefully) made the system specs a little bit clearer.

This is a follow up to bbe62d88d2554189e15f407736b1f7a01968c631.
2024-12-02 16:06:36 +01:00
7568e732cc FIX: resume editing when through /new-message (#29637)
"Resume editing" would do nothing when going through the `/new-message` flow.

This seems to be broken since [this commit](b0f6d074be). which moved `this._setModel` calls around – the same we're doing now, but to different places: the first one needs to happen after the `draft.data` has been set , while the second needs to happen before the `this.open` call.
2024-11-07 17:39:58 -03:00
b0f6d074be FIX: Destroy draft when clicking the Discard button (#28552) 2024-08-26 12:49:26 -03:00
cfbbfd177c DEV: move post flags into database (#27125)
This is preparation for a feature that will allow admins to define their custom flags. Current behaviour should stay untouched.
2024-05-23 12:19:07 +10:00
40d65dddf8 Revert "DEV: move post flags into database (#26951)" (#27102)
This reverts commit 7aff9806eb3592767313299d7a0b8c413e328d20.
2024-05-21 16:21:07 +10:00
7aff9806eb DEV: move post flags into database (#26951)
This is preparation for a feature that will allow admins to define their custom flags. Current behaviour should stay untouched.
2024-05-21 13:15:32 +10:00
bbe62d88d2 FIX: prevents showing discard modal on re-edit (#26639)
This commit will now change two behaviors:

- If composer is already opened on a specific post and we click on edit again for the same post, we will do nothing and not show the discard draft modal
- if composer is shrinked and we click on edit for the same currently edited post, we will just open the composer and not show the discard draft modal
2024-04-16 10:34:32 +02:00
4b043a2a82 DEV: refactor morphed preview specs 2024-04-10 10:36:20 +02:00
6c1b320e2e DEV: Fix case inconsistency in translation file (#26456)
Why this change?

Our translation files use the snake case convention.
2024-04-02 14:39:46 +08:00
f0a46f8b6f DEV: Automatically update groups for test users with explicit TL (#25415)
For performance reasons we don't automatically add fabricated users to trust level auto-groups. However, when explicitly passing a trust level to the fabricator, in 99% of cases it means that trust level is relevant for the test, and we need the groups.

This change makes it so that when a trust level is explicitly passed to the fabricator, the auto-groups are refreshed. There's no longer a need to also pass refresh_auto_groups: true, which means clearer tests, fewer mistakes, and less confusion.
2024-01-29 17:52:02 +08:00
08d641d932 DEV: Convert review_media_unless_trust_level to group-based setting (#25201)
This commit moves the review_media_unless_trust_level setting
to skip_review_media_groups as part of our move from TL to group
based settings.

c.f. https://meta.discourse.org/t/changes-coming-to-settings-for-giving-access-to-features-from-trust-levels-to-groups/283408
2024-01-11 13:43:01 +10:00
1f72152e47 DEV: Remove usage of min_trust_to_create_topic SiteSetting (#24887)
Using min_trust_to_create_topic and create_topic_allowed_groups together was part of #24740

Now, when plugins specs are fixed, we can safely remove that part of logic.
2023-12-18 13:39:53 +11:00
702d0620d7 DEV: Convert min_trust_to_create_topic to groups (#24740)
This change converts the min_trust_to_create_topic site setting to
create_topic_allowed_groups.

See: https://meta.discourse.org/t/283408

- Hides the old setting
- Adds the new site setting
- Add a deprecation warning
- Updates to use the new setting
- Adds a migration to fill in the new setting if the old setting was
changed
- Adds an entry to the site_setting.keywords section
- Updates tests to account for the new change
- After a couple of months, we will remove the min_trust_to_create_topicsetting entirely.

Internal ref: /t/117248
2023-12-13 14:50:13 +11:00
447d9b2105 DEV: Convert approve_unless_trust_level to groups (#24357)
This change converts the `approve_unless_trust_level` site setting to
`approve_unless_allowed_groups`.

See: https://meta.discourse.org/t/283408

- Adds the new site setting
- Adds a deprecation warning
- Updates core to use the new settings.
- Adds a migration to fill in the new setting of the old setting was
  changed
- Adds an entry to the site_setting.keywords section
- Updates many tests to account for the new change

After a couple of months we will remove the `approve_unless_trust_level`
setting entirely.

Internal ref: /t/115696
2023-11-21 11:31:42 -07:00
89bd2b7df0 DEV: Remove unnecessary js: true options from specs (#24463) 2023-11-20 17:22:14 +01:00
6e161d3e75 DEV: Allow fab! without block (#24314)
The most common thing that we do with fab! is:

    fab!(:thing) { Fabricate(:thing) }

This commit adds a shorthand for this which is just simply:

    fab!(:thing)

i.e. If you omit the block, then, by default, you'll get a `Fabricate`d object using the fabricator of the same name.
2023-11-09 16:47:59 -06:00
2201f8f7dc FIX: form template upload type validation (#24148)
When submitting files through the form template upload field, we were having an issue where, although a validation error message was being presented to the user, the upload was still coming through, because `PickFilesButton`'s validation happens **after** the Uppy mixin finished the upload and hit `uploadDone`.

This PR adds a new overridable method to the Uppy mixin and overrides it with the custom validation, which now happens before the file is sent.

Additionally, we're now also using `uploadingOrProcessing` as the source of truth to show the upload/uploading label, which seems more reliable.
2023-11-03 10:11:25 -03:00
115a05f37a FIX: Don't show like error on topic creation (#24084) 2023-10-25 08:40:50 -07:00
e31859a33a FIX: Correctly set categoryId on Composer model (#23934) 2023-10-19 10:19:40 -07:00
2443446e62 DEV: Prevent videos from preloading metadata (#23807)
Preloading just metadata is not always respected by browsers, and
sometimes the whole video will be downloaded. This switches to using a
placeholder image for the video and only loads the video when the play
button is clicked.
2023-10-12 13:47:48 -06:00
1d70cf455e FEATURE: support a description attribute on form template fields (#23744)
* FEATURE: support a description attribute on form template fields
2023-10-04 17:51:53 -03:00
3eef3dc88e FIX: form template cooked heading from label (#23359) 2023-08-31 16:58:09 -03:00
58b49bce41 FEATURE: support to initial values for form templates through /new-topic (#23313)
* FEATURE: adds support for initial values through /new-topic to form templates
2023-08-29 18:41:33 -03:00
6de4b3ac3f DEV: Remove OpenComposer mixin and refactor related logic (#23015)
The OpenComposer mixin comes from a time before we had a composer service. As well as being a general cleanup/refactor, this commit aims to removes interlinking between composer APIs and the discovery-related controllers which are being removed as part of #22622.

In summary, this commit:
- Removes OpenComposer mixin
- Adds and updates composer service APIs to support everything that `openComposer` did
- Updates consumers to call the composer service directly, instead of relying on the mixin (either directly, or via a route-action which bubbled up to some parent)
- Deprecates composer-related methods on `DiscourseRoute` and on the application route
2023-08-11 09:53:44 +01:00
282e43d806 DEV: Pluralize support for form template error strings (#22983) 2023-08-04 14:26:27 -07:00
507d705fb5 DEV: Add diffhtml composer preview specs (#22333)
(both fail with the updated diffhtml)
2023-06-29 09:37:44 +02:00
b6f03fcecd DEV: Add support for uploads to form templates (#22232) 2023-06-28 12:49:05 -07:00
75e711284a DEV: Add custom error messages to form template forms (#22169) 2023-06-20 13:45:58 -07:00
93e5272223 FIX: Incompatibility between default_composer_category and default_subcategory_on_read_only_category (#22165) 2023-06-16 15:56:25 -05:00
9dc63c0755 UX: Add required indicator to fields with required validation (#22096) 2023-06-14 11:25:05 -07:00
dae3970bad DEV: Fix random typos (#22078)
Co-authored-by: Penar Musaraj <pmusaraj@gmail.com>
2023-06-13 22:02:21 +02:00
39efa4c32a DEV: Create posts from form templates (#21980) 2023-06-08 12:49:18 -07:00
41f8bff2c3 DEV: Remove superfluous js: true metadata (#21960)
Why this change?

It is very unlikely that we need to ever JS for system tests considering
that we rely on a JS framework on the frontend.
2023-06-07 09:26:58 +08:00
afdf1ac7c3 DEV: Unskip supposedly flaky test (#21922)
We believe the system tests were flaky due to the problem identified in
4dd053av
2023-06-05 17:21:09 +08:00