text info data text my seflt
text
Currently, we provide some out-of-the-box plugins that not only implement basic functionality, but also provide support for keyboard shortcuts, Markdown syntax, Markdown serialization, Markdown deserialization, HTML serialization, and HTML deserialization.
@editablejs/plugin-context-menuprovides a right-click menu. Since we do not use some of the functionality of the native contenteditable menu, we need to define our own right-click menu functionality.@editablejs/plugin-alignfor text alignment@editablejs/plugin-blockquotefor block quotes@editablejs/plugin-codeblockfor code blocks@editablejs/plugin-fontincludes font color, background color, and font size@editablejs/plugin-headingfor headings@editablejs/plugin-hrfor horizontal lines@editablejs/plugin-imagefor images@editablejs/plugin-indentfor indentation@editablejs/plugin-leadingfor line spacing@editablejs/plugin-linkfor links@editablejs/plugin-listincludes ordered lists, unordered lists, and task lists@editablejs/plugin-markincludesbold,italic,strikethrough,underline,superscript,subscript, andcode@editablejs/plugin-mentionfor mentions@editablejs/plugin-tablefor tables
The usage method of a single plugin, taking plugin-mark as an example:
import { withMark } from '@editablejs/mark'
const editor = React.useMemo(() => {
const editor = withEditable(createEditor())
return withMark(editor)
}, [])You can also use the following method to quickly use the above common plugins via withPlugins in @editablejs/plugins:
import { withPlugins } from '@editablejs/plugins'
const editor = React.useMemo(() => {
const editor = withEditable(createEditor())
return withPlugins(editor)
}, [])The @editablejs/plugin-history plugin provides undo and redo functionality.
import { withHistory } from '@editablejs/plugin-history'
const editor = React.useMemo(() => {
const editor = withEditable(createEditor())
return withHistory(editor)
}, [])When developing document or blog applications, we usually have a separate title and main content, which is often implemented using an input or textarea outside of the editor. If in a collaborative environment, since it is independent of the editor, additional work is required to achieve real-time synchronization of the title.
The @editablejs/plugin-title plugin solves this problem by using the editor's first child node as the title, integrating it into the editor's entire data structure so that it can have the same features as the editor.
import { withTitle } from '@editablejs/plugin-title'
const editor = React.useMemo(() => {
const editor = withEditable(createEditor())
return withTitle(editor)
}, [])It also has a separate placeholder property for setting the placeholder for the title.
return withTitle(editor, {
placeholder: 'Please enter a title'
})