Package-level declarations

Markdown import and export: withMarkdown, MarkdownExtension, the syntax choices in MarkdownConfiguration, and the AnnotatedString to Markdown converters.

Types

Link copied to clipboard

The markdown written for a highlight. Both forms are read on import.

Link copied to clipboard
data class MarkdownConfiguration(val highlightSyntax: HighlightSyntax = HighlightSyntax.DOUBLE_EQUALS, val paragraphSeparator: ParagraphSeparator = ParagraphSeparator.BLANK_LINE)

The markdown syntax choices: which of the forms CommonMark leaves open a document is written in. The styles the document is rendered and recognised with are the editor's RichTextStyles, on TextEditorState.richTextStyles.

Link copied to clipboard
class MarkdownExtension(val editorState: TextEditorState, initialConfiguration: MarkdownConfiguration = MarkdownConfiguration.DEFAULT, var imageProvider: ImageProvider? = null)

Reads and writes the document as markdown: the entry point for using the editor as a markdown editor. The styles the document is rendered and recognised with are the state's richTextStyles; markdownConfiguration holds the syntax choices. The block toggles and queries live on the state (toggleBulletList, headerLevel, setLink and the rest, in com.darkrockstudios.texteditor.state); the members here forward to them for one release.

Link copied to clipboard
data class MarkdownShortcuts(val blocks: Boolean = true, val inline: Boolean = true) : EditBehavior

Markdown typed into a rich text editor becomes the formatting it stands for, the markers disappearing, as Notion, Typora and Google Docs' autoformat do:

Link copied to clipboard
data class MarkdownStyles(styles: RichTextStyles = RichTextStyles.DEFAULT)

The styles under their old names; read RichTextStyles directly.

Link copied to clipboard

What an editor line is in markdown terms.

Functions

Link copied to clipboard
fun String.toAnnotatedStringFromMarkdown(styles: RichTextStyles = RichTextStyles.DEFAULT, allowedLinkSchemes: Set<String> = DEFAULT_LINK_SCHEMES): AnnotatedString

Parses this string as GitHub Flavored Markdown and renders it into a styled AnnotatedString.

Link copied to clipboard
fun AnnotatedString.toMarkdown(configuration: MarkdownConfiguration = MarkdownConfiguration.DEFAULT, links: List<Pair<IntRange, String>> = emptyList(), styles: RichTextStyles = RichTextStyles.DEFAULT): String

Converts an AnnotatedString to a markdown string, handling supported markdown styles. Only converts styles that match our supported markdown styles, dropping any unsupported styles.

Link copied to clipboard
fun TextEditorState.withMarkdown(initialConfiguration: MarkdownConfiguration = MarkdownConfiguration.DEFAULT, imageProvider: ImageProvider? = null): MarkdownExtension

Wraps this TextEditorState in a MarkdownExtension, the entry point for markdown import and export. The styles are the state's richTextStyles; assign them before importing.