Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an inline/minimal input mode to Bard #6973

Merged
merged 5 commits into from
Nov 30, 2022

Conversation

jacksleight
Copy link
Contributor

Closes statamic/ideas#893. Targets the master branch as this requires Tiptap 2.

This PR adds an inline/minimal input mode to Bard. This allows you to create single line Text-like fields but with formatting and links:

CleanShot.2022-10-28.at.10.07.36.mp4

When augmented only inline HTML is output:

An inline bard <strong>field with</strong> <a href="#">floating</a> toolbar

Notes

Tiptap 2 can support root text nodes, however a temporary paragraph is used as a wrapper during editing because the CP CSS and some extensions (eg. placeholder) expect/target paragraphs.

You can switch between inline and block modes seamlessly. Going from block to inline will only retain the first node’s content.

There are a bunch of features (sets, lists, images etc) that don’t make sense in this mode and won’t work. The fieldtype could switch them off, but to keep things simple I’ve left it to the user to configure the field appropriately. If they are enabled the buttons just do nothing.

@what-the-diff
Copy link

what-the-diff bot commented Oct 31, 2022

  • Added a new config option to allow inline elements only.
  • Updated the Document extension to support both block and inline modes, as well as wrapping/unwrapping values when switching between them.
  • Made some minor CSS changes for better styling of Bard in an inline mode (elements are now 22px tall).

@jacksleight
Copy link
Contributor Author

I think the tests should be fine, looks like Windows has just fallen over.

@jasonvarga
Copy link
Member

Ah yeah that's a github workflow thing we fixed in 3.3 but hasn't been merged into master. I'll sort that out.

@jasonvarga
Copy link
Member

I've updated the master branch if you wouldn't mind merging it back in here and testing it out again.

@jacksleight
Copy link
Contributor Author

Yep all good now.

@jasonvarga jasonvarga merged commit 55a065b into statamic:master Nov 30, 2022
@jacksleight jacksleight deleted the bard-inline branch December 1, 2022 21:13
@jackmcdade jackmcdade added this to the 3.4 milestone Jan 4, 2023
@sjclark
Copy link
Contributor

sjclark commented Jan 18, 2023

LOVE THIS, will officially negate all sorts of stupid hacks I do to circumvent fat fields; my favourite being using square brackets with

{{ hero_heading | regex_replace="\[|<span class='text-rose-550'>" | regex_replace="\]|</span>" }}

Thanks @jacksleight 🔥

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.

4 participants