Skip to content

Conversation

@KCLAnthonyDiaz
Copy link

Description

Replaces #702

Adds 2 new props to the Rich text Editor:

  1. customPlugins
  2. customToolbars

These properties aim to make it more simple to add custom Plate plugins and add custom Toolbar elements to the existing Rich Text editors without needing to maintain a separate, modified, fork of the Rich text editor perpetually.

Notes

  • These new props are fully backwards compatible, meaning there is no change whatsoever to dcustomers using the native Rich Text Editor.
  • Plugins are registered with access to the SDK to enable features that require SDK assistance, such as lookups, etc.
  • Plugins are registered after Contentful's list of native plugins to ensure that they are in the correct state before custom features are registrered.
  • Custom toolbars are placed below Contentful's native one, within the sticky toolbar wrapper, to keep custom functionality separate from Contentful's native toolbar while enabling customers to enable quick access to custom tooling.
  • There is a new 3 test test suite added to ensure that the capabilities of the new props are operating properly (The tests do not aim to test that the custom slate plugin operates correctly in all cases. Instead, the tests just aim to ensure that a toolbar and a custom plate plugin can be registered and operates accordingly).
  • Storybook was modified to accept a new parameter, ctflRichTextAddon, that will attempt to load up a custom toolbar and plugin from the specified export name. Currently, the example lipsum plugin is the only one that exists.
    • Providing this parameter, even if there is no plugin to load by that name, will display a warning that the validator for the Rich text events stream is disabled.
    • This new parameter was chosen over putting another custom toolbar into the Rich Text Editor in Storybook to ensure that Contentful doesn't need to work around the functionality when developing updates to the editor.

Screenshots

Default Rich Text Editor in Storybook (Unchanged default behavior confirmation):

89fd30ec-5860-e37e-e493-ae8505efb1e3

Rich Text Editor with custom features enabled in Storybook:

c0cedda1-acd6-2d31-e301-db271c0a702f

Rendered custom Plate plugin contents in Storybook:

5421f3ed-4536-40e2-f744-1bc6304c8cb8

Adds access to the current SDK instance should a plugin require that
Adds access to the restricted marks configuration should a plugin require that
Makes sure to not touch the default test and default Storybook implementation since custom addons are an op-in
@KCLAnthonyDiaz KCLAnthonyDiaz requested a review from a team as a code owner August 14, 2023 15:57
@z0al
Copy link
Member

z0al commented Aug 14, 2023

Thank you so much for the great work @KCLAnthonyDiaz.

While we appreciate the contribution, unfortunately, we won't be moving forward with this PR. The need for supporting custom plugins in the Rich Text has been brought up a few times internally, and the team explored the topic. We hope to work on it in the future but have yet to make concrete plans.

The main issue with your approach here is that it exposes the internals of a 3rd-party library - Plate - that we have no control over and can't guarantee backward compatibility once exposed to customers.

For example, the RT editor currently is on Plate v18.x, but the latest version is v23.x as of today. In theory, any of these version bumps could break existing plugins. That can be a painful experience trying to keep up with these upgrades (which we try to do often). It's something we want our users to avoid dealing with.

Ideally, we want to abstract away the internal complexity and offer Contentful's own way of defining plugins in the future.

Thank you for your understanding.

@z0al z0al closed this Aug 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants