pluginStrategy.ts
TLDR
This file defines interfaces for two different strategies used in the Live Markdown plugin.
Interfaces
InlineStrategy
This interface defines the structure of an inline strategy used in the Live Markdown plugin. It contains the following properties:
-
style
: A string representing the inline style. -
findStyleRanges
: A function that takes aContentBlock
object and returns an array of arrays containing the start and end positions of style ranges in the text. -
findDelimiterRanges
(optional): A function that takes aContentBlock
object and the style ranges and returns an array of arrays containing the start and end positions of delimiter ranges in the text. -
delimiterStyle
(optional): A string representing the style of delimiters. -
styles
(optional): A CSSProperties object representing the styles to apply to the matched text. -
delimiterStyles
(optional): A CSSProperties object representing the styles to apply to the delimiters.
BlockStrategy
This interface defines the structure of a block strategy used in the Live Markdown plugin. It contains the following properties:
-
type
: A string representing the block type. -
className
: A string representing the class name to apply to the block. -
mapBlockType
: A function that takes aContentState
object and returns a newContentState
object.
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import * as React from 'react'
import {ContentBlock, ContentState} from 'draft-js'
export interface InlineStrategy {
style: string
findStyleRanges: (text: ContentBlock) => number[][]
findDelimiterRanges?: (text: ContentBlock, styleRanges: number[][]) => number[][]
delimiterStyle?: string
styles?: React.CSSProperties
delimiterStyles?: React.CSSProperties
}
export interface BlockStrategy {
type: string
className: string
mapBlockType: (state: ContentState) => ContentState
}