Interface: DirectiveDescriptor<T>

Implement this interface to create a custom editor for markdown directives. Pass the object in the directivesPlugin parameters.

Type parameters

NameType
Textends Directives = Directives

Table of contents

Methods

Properties

Methods

testNode

testNode(node): boolean

Whether the descriptor's Editor should be used for the given node.

Parameters

NameTypeDescription
nodeDirectivesThe directive mdast node. You can code your logic against the node's name, type, attributes, children, etc.

Returns

boolean

Properties

Editor

Editor: ComponentType<DirectiveEditorProps<T>>

The React component to be used as an Editor. See DirectiveEditorProps for the props passed to the component.


attributes

attributes: string[]

The attributes that the directive has. This can be used when building the UI for the user to configure a directive. The GenericDirectiveEditor uses those to display a property form.


hasChildren

hasChildren: boolean

Whether or not the directive has inner markdown content as children. Used by the GenericDirectiveEditor to determine whether to show the inner markdown editor.


name

name: string

The name of the descriptor - use this if you're building UI for the user to select a directive.


type

Optional type: "containerDirective" | "leafDirective" | "textDirective"

The type of the supported directive. Can be one of: 'leafDirective' | 'containerDirective' | 'textDirective'.