How to use slate-prop-types - 10 common examples

To help you get started, we’ve selected a few slate-prop-types examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ianstormtaylor / slate / packages / slate-react / src / components / text.js View on Github external
/>
        )
      })}
    
  )
})

/**
 * Prop types.
 *
 * @type {Object}
 */

Text.propTypes = {
  annotations: ImmutableTypes.map.isRequired,
  block: SlateTypes.block,
  decorations: ImmutableTypes.list.isRequired,
  editor: Types.object.isRequired,
  node: SlateTypes.node.isRequired,
  parent: SlateTypes.node.isRequired,
  style: Types.object,
}

/**
 * A memoized version of `Text` that updates less frequently.
 *
 * @type {Component}
 */

const MemoizedText = React.memo(Text, (prev, next) => {
  return (
    // PERF: There are cases where it will have
github ianstormtaylor / slate / packages / slate-react / src / components / default-placeholder.js View on Github external
* @type {Component}
 */

class DefaultPlaceholder extends React.Component {

  /**
   * Property types.
   *
   * @type {Object}
   */

  static propTypes = {
    editor: Types.object.isRequired,
    isSelected: Types.bool.isRequired,
    node: SlateTypes.node.isRequired,
    parent: SlateTypes.node.isRequired,
    readOnly: Types.bool.isRequired,
    state: SlateTypes.state.isRequired,
  }

  /**
   * Render.
   *
   * @return {Element}
   */

  render() {
    const { editor, state } = this.props
    if (!editor.props.placeholder) return null
    if (state.document.getBlocks().size > 1) return null

    const style = {
github ianstormtaylor / slate / packages / slate-react / src / components / placeholder.js View on Github external
*/

class Placeholder extends React.Component {

  /**
   * Property types.
   *
   * @type {Object}
   */

  static propTypes = {
    children: Types.any.isRequired,
    className: Types.string,
    firstOnly: Types.bool,
    node: SlateTypes.node.isRequired,
    parent: SlateTypes.node,
    state: SlateTypes.state.isRequired,
    style: Types.object,
  }

  /**
   * Default properties.
   *
   * @type {Object}
   */

  static defaultProps = {
    firstOnly: true,
  }

  /**
   * Should the placeholder update?
github ianstormtaylor / slate / packages / slate-react / src / components / default-placeholder.js View on Github external
*
 * @type {Component}
 */

class DefaultPlaceholder extends React.Component {

  /**
   * Property types.
   *
   * @type {Object}
   */

  static propTypes = {
    editor: Types.object.isRequired,
    isSelected: Types.bool.isRequired,
    node: SlateTypes.node.isRequired,
    parent: SlateTypes.node.isRequired,
    readOnly: Types.bool.isRequired,
    state: SlateTypes.state.isRequired,
  }

  /**
   * Render.
   *
   * @return {Element}
   */

  render() {
    const { editor, state } = this.props
    if (!editor.props.placeholder) return null
    if (state.document.getBlocks().size > 1) return null
github ianstormtaylor / slate / packages / slate-react / src / components / void.js View on Github external
*
 * @type {Component}
 */

class Void extends React.Component {
  /**
   * Property types.
   *
   * @type {Object}
   */

  static propTypes = {
    block: SlateTypes.block,
    children: Types.any.isRequired,
    editor: Types.object.isRequired,
    node: SlateTypes.node.isRequired,
    parent: SlateTypes.node.isRequired,
    readOnly: Types.bool.isRequired,
  }

  /**
   * Debug.
   *
   * @param {String} message
   * @param {Mixed} ...args
   */

  debug = (message, ...args) => {
    const { node } = this.props
    const { key, type } = node
    const id = `${key} (${type})`
    debug(message, `${id}`, ...args)
github ianstormtaylor / slate / packages / slate-react / src / components / void.js View on Github external
* @type {Component}
 */

class Void extends React.Component {
  /**
   * Property types.
   *
   * @type {Object}
   */

  static propTypes = {
    block: SlateTypes.block,
    children: Types.any.isRequired,
    editor: Types.object.isRequired,
    node: SlateTypes.node.isRequired,
    parent: SlateTypes.node.isRequired,
    readOnly: Types.bool.isRequired,
  }

  /**
   * Debug.
   *
   * @param {String} message
   * @param {Mixed} ...args
   */

  debug = (message, ...args) => {
    const { node } = this.props
    const { key, type } = node
    const id = `${key} (${type})`
    debug(message, `${id}`, ...args)
  }
github orbiting / publikator-frontend / components / editor / utils / OverlayFormManager.js View on Github external
OverlayFormManager.defaultProps = {
  showEditButton: true
}

OverlayFormManager.propTypes = {
  showEditButton: PropTypes.bool.isRequired,
  onChange: PropTypes.func.isRequired,
  children: PropTypes.func.isRequired,
  component: PropTypes.node,
  preview: PropTypes.node,
  extra: PropTypes.node,
  attributes: PropTypes.object,
  editor: PropTypes.shape({
    change: PropTypes.func.isRequired
  }).isRequired,
  node: SlatePropTypes.node.isRequired
}

export default OverlayFormManager
github ianstormtaylor / slate / packages / slate-react / src / components / leaf.js View on Github external
* Prop types.
 *
 * @type {Object}
 */

Leaf.propTypes = {
  annotations: ImmutableTypes.list.isRequired,
  block: SlateTypes.block.isRequired,
  decorations: ImmutableTypes.list.isRequired,
  editor: Types.object.isRequired,
  index: Types.number.isRequired,
  leaves: Types.object.isRequired,
  marks: SlateTypes.marks.isRequired,
  node: SlateTypes.node.isRequired,
  offset: Types.number.isRequired,
  parent: SlateTypes.node.isRequired,
  text: Types.string.isRequired,
}

/**
 * A memoized version of `Leaf` that updates less frequently.
 *
 * @type {Component}
 */

const MemoizedLeaf = React.memo(Leaf, (prev, next) => {
  return (
    next.block === prev.block &&
    next.index === prev.index &&
    next.marks === prev.marks &&
    next.parent === prev.parent &&
    next.text === prev.text &&
github ianstormtaylor / slate / packages / slate-react / src / components / node.js View on Github external
* @type {Component}
 */

class Node extends React.Component {
  /**
   * Property types.
   *
   * @type {Object}
   */

  static propTypes = {
    annotations: ImmutableTypes.map.isRequired,
    block: SlateTypes.block,
    decorations: ImmutableTypes.list.isRequired,
    editor: Types.object.isRequired,
    node: SlateTypes.node.isRequired,
    parent: SlateTypes.node,
    readOnly: Types.bool.isRequired,
    selection: SlateTypes.selection,
  }

  /**
   * Temporary values.
   *
   * @type {Object}
   */

  tmp = {
    nodeRefs: {},
  }

  /**
github ianstormtaylor / slate / packages / slate-react / src / components / leaf.js View on Github external
/**
 * Prop types.
 *
 * @type {Object}
 */

Leaf.propTypes = {
  annotations: ImmutableTypes.list.isRequired,
  block: SlateTypes.block.isRequired,
  decorations: ImmutableTypes.list.isRequired,
  editor: Types.object.isRequired,
  index: Types.number.isRequired,
  leaves: Types.object.isRequired,
  marks: SlateTypes.marks.isRequired,
  node: SlateTypes.node.isRequired,
  offset: Types.number.isRequired,
  parent: SlateTypes.node.isRequired,
  text: Types.string.isRequired,
}

/**
 * A memoized version of `Leaf` that updates less frequently.
 *
 * @type {Component}
 */

const MemoizedLeaf = React.memo(Leaf, (prev, next) => {
  return (
    next.block === prev.block &&
    next.index === prev.index &&
    next.marks === prev.marks &&

slate-prop-types

A set of React prop type checkers for Slate editors.

MIT
Latest version published 5 years ago

Package Health Score

74 / 100
Full package analysis