main

mattermost/focalboard

Last updated at: 28/12/2023 01:37

index.tsx

TLDR

The index.tsx file in the blocks/divider directory defines a React component called Divider that represents a horizontal divider. It also includes a method called runSlashCommand that is used to handle slash commands related to the Divider component.

Methods

runSlashCommand

This method is used to handle slash commands related to the Divider component. It takes three arguments: changeType, changeValue, and ...args. The changeType argument is a function that changes the content type of the editor to Divider. The changeValue argument is a function that changes the value of the editor to the provided args joined with whitespace.

Classes

None

// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import React, {useEffect} from 'react'

import {BlockInputProps, ContentType} from '../types'

import './divider.scss'

const Divider: ContentType = {
    name: 'divider',
    displayName: 'Divider',
    slashCommand: '/divider',
    prefix: '--- ',
    runSlashCommand: (): void => {},
    editable: false,
    Display: () => <hr className='Divider'/>,
    Input: (props: BlockInputProps) => {
        useEffect(() => {
            props.onSave(props.value)
        }, [])
        return null
    },
}

Divider.runSlashCommand = (changeType: (contentType: ContentType) => void, changeValue: (value: string) => void, ...args: string[]): void => {
    changeType(Divider)
    changeValue(args.join(' '))
}

export default Divider