Commands
All commands are located in commands.
import { commands } from 'purrmd';
// Clear all text formatting for the selected text
commands.clearAllTextFormattingCommand(view);Text Formatting
clearAllTextFormattingCommand(view: EditorView) => boolean- Clears all text formatting (bold、italic、highlight、strikethrough、inline code) for the selected text.isAnyTextFormatting(view: EditorState) => boolean- Checks if the selected text has any text formatting (bold、italic、highlight、strikethrough、inline code).
Bold
toggleStrongCommand(view: EditorView) => boolean- Togglesboldfor the selected text.clearStrongCommand(view: EditorView) => boolean- Clearsboldfor the selected text.isStrong(view: EditorState) => boolean- Checks if the selected text is entirelybold.
Italic
toggleItalicCommand(view: EditorView) => boolean- Togglesitalicfor the selected text.clearItalicCommand(view: EditorView) => boolean- Clearsitalicfor the selected text.isItalic(view: EditorState) => boolean- Checks if the selected text is entirelyitalic.
Highlight
toggleHighlightCommand(view: EditorView) => boolean- Toggleshighlightfor the selected text.clearHighlightCommand(view: EditorView) => boolean- Clearshighlightfor the selected text.isHighlight(view: EditorState) => boolean- Checks if the selected text is entirelyhighlight.
Strikethrough
toggleStrikethroughCommand(view: EditorView) => boolean- Togglesstrikethroughfor the selected text.clearStrikethroughCommand(view: EditorView) => boolean- Clearsstrikethroughfor the selected text.isStrikethrough(view: EditorState) => boolean- Checks if the selected text is entirelystrikethrough.
Inline Code
toggleInlineCodeCommand(view: EditorView) => boolean- Togglesinline codefor the selected text.clearInlineCodeCommand(view: EditorView) => boolean- Clearsinline codefor the selected text.isInlineCode(view: EditorState) => boolean- Checks if the selected text is entirelyinline code.
Paragraphs
Headings
setHeadingCommand(level: number) => ((view: EditorView) => boolean)- Creates a command to set all selected lines to the specifiedheadinglevel.setHeading1Command(view: EditorView) => boolean- Sets all selected lines toheading1level.setHeading2Command(view: EditorView) => boolean- Sets all selected lines toheading2level.setHeading3Command(view: EditorView) => boolean- Sets all selected lines toheading3level.setHeading4Command(view: EditorView) => boolean- Sets all selected lines toheading4level.setHeading5Command(view: EditorView) => boolean- Sets all selected lines toheading5level.setHeading6Command(view: EditorView) => boolean- Sets all selected lines toheading6level.isHeading(view: EditorState, level?: number) => boolean- Checks if all selected lines areheadingsof the specified level (or any level).isHeading1(view: EditorState) => boolean- Checks if all selected lines areheading1.isHeading2(view: EditorState) => boolean- Checks if all selected lines areheading2.isHeading3(view: EditorState) => boolean- Checks if all selected lines areheading3.isHeading4(view: EditorState) => boolean- Checks if all selected lines areheading4.isHeading5(view: EditorState) => boolean- Checks if all selected lines areheading5.isHeading6(view: EditorState) => boolean- Checks if all selected lines areheading6.
Paragraph
setParagraphCommand(view: EditorView) => boolean- Sets all selected lines toparagraphlevel.isParagraph(view: EditorState) => boolean- Checks if all selected lines areparagraph.
Lists
clearAllListCommand(view: EditorView) => boolean- Clears all lists (unordered list,ordered list,task list) for the selected lines.
Unordered List
toggleUnorderedListCommand(view: EditorView) => boolean- Togglesunordered listfor all selected lines.clearUnorderedListCommand(view: EditorView) => boolean- Clearsunordered listfor all selected lines.isUnorderedList(view: EditorState) => boolean- Checks if all selected lines areunordered lists.
Ordered List
toggleOrderedListCommand(view: EditorView) => boolean- Togglesordered listfor all selected lines.clearOrderedListCommand(view: EditorView) => boolean- Clearsordered listfor all selected lines.isOrderedList(view: EditorState) => boolean- Checks if all selected lines areordered lists.
Task List
toggleTaskListCommand(view: EditorView) => boolean- Togglestask listfor all selected lines.clearTaskListCommand(view: EditorView) => boolean- Clearstask listfor all selected lines.isTaskList(view: EditorState) => boolean- Checks if all selected lines aretask lists.
Blockquote
toggleBlockquoteCommand(view: EditorView) => boolean- Togglesblockquotefor all selected lines.clearBlockquoteCommand(view: EditorView) => boolean- Clearsblockquotefor all selected lines.isBlockquote(view: EditorState) => boolean- Checks if all selected lines areblockquote.
Insertion
insertAnyText(text: string, userEvent?: string) => ((view: EditorView) => boolean)- Creates a command to insert the specified text.insertHeading1(view: EditorView) => boolean- Insertsheading1.insertHeading2(view: EditorView) => boolean- Insertsheading2.insertHeading3(view: EditorView) => boolean- Insertsheading3.insertHeading4(view: EditorView) => boolean- Insertsheading4.insertHeading5(view: EditorView) => boolean- Insertsheading5.insertHeading6(view: EditorView) => boolean- Insertsheading6.insertText(view: EditorView) => boolean- Insertsplain text.insertUnorderedList(view: EditorView) => boolean- Insertsunordered list.insertOrderedList(view: EditorView) => boolean- Insertsordered list.insertTaskList(view: EditorView) => boolean- Insertstask list.insertBlockquote(view: EditorView) => boolean- Insertsblockquote.insertHorizontalRule(view: EditorView) => boolean- Insertshorizontal rule.insertCodeBlock(view: EditorView) => boolean- Insertscode block.insertTable(view: EditorView) => boolean- Insertstable.insertLink(view: EditorView) => boolean- Insertslink.insertImage(view: EditorView) => boolean- Insertsimage.