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

More robust Rich Text and Title mock values #5

Open
angeloashmore opened this issue Oct 14, 2021 · 0 comments
Open

More robust Rich Text and Title mock values #5

angeloashmore opened this issue Oct 14, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@angeloashmore
Copy link
Member

angeloashmore commented Oct 14, 2021

Is your feature request related to a problem? Please describe.

Creating Rich Text and Title mock values is currently limited. It generates values for most block types, such as headings and images, but does not include some like links.

Rich Text and Title mock values can be customized using "pattern" option. Depending on the selected pattern, such as "short" and "long", the length of the value can be loosely determined. This gives some control of the output, but does not allow for custom patterns.

Describe the solution you'd like

To give more control over the created mock value, access to individual block value generators can be provided by the library. This allows users to create custom values like:

  • Heading 1
  • Paragraph
  • Paragraph

This can be useful when you have a general idea of the type of content that will be provided by editors.

This requires all block types to be supported, including links.

Someone could use the individual value generators like this:

import * as prismicT from '@prismicio/types'
import * as prismicM from '@prismicio/mock'

const richTextValue: prismicT.RichTextField = [
  prismicM.value.richTextBlocks.heading1({ pattern: 'medium' }),
  prismicM.value.richTextBlocks.paragraph(),
  prismicM.value.richTextBlocks.paragraph(),
]

Describe alternatives you've considered

Mock values can be constructed by hand. Some guidance is provided thanks to @prismicio/types. Manually creating mock values is not ideal for obvious reasons.

Additional context

N/A

@angeloashmore angeloashmore added the enhancement New feature or request label Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant