// quote — a pull quote with optional attribution.
const { registerBlock } = require('../registry')
const { requiredText, optionalText, onlyKeys } = require('../propHelpers')

const MAX_TEXT = 1000
const MAX_ATTRIB = 200

registerBlock({
  type: 'quote',
  version: 1,
  cacheTTL: null,
  schema(props) {
    const errors = onlyKeys(props, ['text', 'attribution'])
    const text = requiredText('text', props.text, MAX_TEXT)
    if (text) errors.push(text)
    const attribution = optionalText('attribution', props.attribution, MAX_ATTRIB)
    if (attribution) errors.push(attribution)
    return errors
  },
})
