Plugins API
All available plugins in the @likhaeditor/plugins package.
Built-in Plugins
HeadingPlugin
Adds support for headings (H1-H6).
import { HeadingPlugin } from '@likhaeditor/plugins';Commands:
toggleHeading(level: number)- Toggle heading level (1-6)setParagraph()- Convert to paragraph
Keyboard Shortcuts:
Ctrl-Alt-1toCtrl-Alt-6- Set heading level
BulletListPlugin
Adds unordered (bullet) list support.
import { BulletListPlugin } from '@likhaeditor/plugins';Commands:
toggleBulletList()- Toggle bullet listisBulletListActive()- Check if in bullet list
Keyboard Shortcuts:
Ctrl-Shift-8- Toggle bullet list
OrderedListPlugin
Adds ordered (numbered) list support.
import { OrderedListPlugin } from '@likhaeditor/plugins';Commands:
toggleOrderedList()- Toggle ordered listisOrderedListActive()- Check if in ordered list
Keyboard Shortcuts:
Ctrl-Shift-9- Toggle ordered list
BlockquotePlugin
Adds blockquote support.
import { BlockquotePlugin } from '@likhaeditor/plugins';Commands:
toggleBlockquote()- Toggle blockquote
Keyboard Shortcuts:
Ctrl-Shift-B- Toggle blockquote
LinkPlugin
Adds hyperlink support.
import { LinkPlugin } from '@likhaeditor/plugins';Commands:
setLink(url: string)- Insert/update linkunsetLink()- Remove link
Keyboard Shortcuts:
Ctrl-K- Insert/edit link
TextColorPlugin
Adds text color support with 80-color palette.
import { TextColorPlugin } from '@likhaeditor/plugins';Commands:
setTextColor(color: string)- Set text colorremoveTextColor()- Remove text color
HighlightPlugin
Adds background highlight color with 80-color palette.
import { HighlightPlugin } from '@likhaeditor/plugins';Commands:
setHighlight(color: string)- Set background colorremoveHighlight()- Remove highlight
TextAlignmentPlugin
Adds text alignment (left, center, right, justify).
import { TextAlignmentPlugin } from '@likhaeditor/plugins';Commands:
setTextAlign(alignment: 'left' | 'center' | 'right' | 'justify')- Set alignment
Keyboard Shortcuts:
Ctrl-Shift-L- Align leftCtrl-Shift-E- Align centerCtrl-Shift-R- Align rightCtrl-Shift-J- Justify
TablePlugin
Adds table support.
import { TablePlugin } from '@likhaeditor/plugins';Commands:
insertTable(rows: number, cols: number)- Insert tabledeleteTable()- Delete tableaddRowBefore()- Add row before currentaddRowAfter()- Add row after currentdeleteRow()- Delete current rowaddColumnBefore()- Add column before currentaddColumnAfter()- Add column after currentdeleteColumn()- Delete current column
ImagePlugin
Adds image support.
import { ImagePlugin } from '@likhaeditor/plugins';Commands:
insertImage(src: string, alt?: string, title?: string)- Insert imageupdateImage(src: string, alt?: string, title?: string)- Update image attributes
CodeBlockPlugin
Adds code block support.
import { CodeBlockPlugin } from '@likhaeditor/plugins';Commands:
toggleCodeBlock()- Toggle code block
Keyboard Shortcuts:
Ctrl-Alt-C- Toggle code block
StrikethroughPlugin
Adds strikethrough formatting.
import { StrikethroughPlugin } from '@likhaeditor/plugins';Commands:
toggleStrikethrough()- Toggle strikethrough
SubscriptPlugin
Adds subscript formatting.
import { SubscriptPlugin } from '@likhaeditor/plugins';Commands:
toggleSubscript()- Toggle subscript
SuperscriptPlugin
Adds superscript formatting.
import { SuperscriptPlugin } from '@likhaeditor/plugins';Commands:
toggleSuperscript()- Toggle superscript
ClearFormattingPlugin
Removes all formatting from selection.
import { ClearFormattingPlugin } from '@likhaeditor/plugins';Commands:
clearFormat()- Remove all formatting
PlaceholderPlugin
Adds placeholder text when editor is empty.
import { PlaceholderPlugin } from '@likhaeditor/plugins';Options:
new PlaceholderPlugin({
placeholder: 'Start typing...'
})CharacterCountPlugin
Tracks character and word count.
import { CharacterCountPlugin } from '@likhaeditor/plugins';Commands:
getCharacterCount()- Get character countgetWordCount()- Get word count
Creating Custom Plugins
import { Plugin } from '@likhaeditor/core';
export class MyCustomPlugin extends Plugin {
name = 'myCustom';
commands() {
return {
myCommand: (editor) => {
// Your command logic
return true;
}
};
}
keymap() {
return {
'Ctrl-M': (editor, state, dispatch) => {
// Your keymap logic
return true;
}
};
}
init(editor) {
// Initialization logic
}
destroy() {
// Cleanup logic
}
}See Creating Plugins for detailed guide.