Basic marks plugin for Plate rich text editor providing text formatting capabilities
npx @tessl/cli install tessl/npm-udecode--plate-basic-marks@49.0.0@udecode/plate-basic-marks provides a comprehensive set of basic text formatting mark plugins for the Plate rich text editor. The package includes both base plugins and React-compatible versions, supporting bold, italic, underline, strikethrough, code, subscript, superscript, highlight, and keyboard input formatting.
Note: This package is deprecated as of version 49.0.0. Users should migrate to @platejs/basic-nodes for new projects.
npm install @udecode/plate-basic-marks@platejs/basic-nodes instead)import {
BaseBasicMarksPlugin,
BaseBoldPlugin,
BaseItalicPlugin,
BaseUnderlinePlugin,
BaseStrikethroughPlugin,
BaseCodePlugin,
BaseSubscriptPlugin,
BaseSuperscriptPlugin,
BaseHighlightPlugin,
BaseKbdPlugin
} from "@udecode/plate-basic-marks";import {
BasicMarksPlugin,
BoldPlugin,
ItalicPlugin,
UnderlinePlugin,
StrikethroughPlugin,
CodePlugin,
SubscriptPlugin,
SuperscriptPlugin,
HighlightPlugin,
KbdPlugin
} from "@udecode/plate-basic-marks/react";For CommonJS:
const { BaseBoldPlugin, BaseItalicPlugin } = require("@udecode/plate-basic-marks");
const { BoldPlugin, ItalicPlugin } = require("@udecode/plate-basic-marks/react");import { createPlateEditor } from "@udecode/plate-core";
import {
BasicMarksPlugin,
BoldPlugin,
ItalicPlugin,
UnderlinePlugin
} from "@udecode/plate-basic-marks/react";
// Create editor with basic marks
const editor = createPlateEditor({
plugins: [
BasicMarksPlugin, // Includes all basic marks
// Or use individual plugins:
// BoldPlugin,
// ItalicPlugin,
// UnderlinePlugin,
]
});
// Toggle marks programmatically
BoldPlugin.toggle();
ItalicPlugin.toggle();The package is organized around the SlatePlugin architecture from the Plate ecosystem:
BaseBasicMarksPlugin, BasicMarksPlugin) that bundle all individual mark plugins.toggle() method for applying/removing marksAggregate plugins that include all basic mark functionality in a single import.
/**
* Base plugin collection containing all basic mark plugins
*/
const BaseBasicMarksPlugin: SlatePlugin;
/**
* React plugin collection containing all basic mark plugins with React components
*/
const BasicMarksPlugin: SlatePlugin;Enables bold text formatting with keyboard shortcuts and toggle functionality.
/**
* Base bold formatting plugin
*/
const BaseBoldPlugin: SlatePlugin;
/**
* React bold formatting plugin with component rendering
*/
const BoldPlugin: SlatePlugin & {
/** Toggle bold mark on current selection */
toggle(): void;
};Enables italic text formatting with keyboard shortcuts and toggle functionality.
/**
* Base italic formatting plugin
*/
const BaseItalicPlugin: SlatePlugin;
/**
* React italic formatting plugin with component rendering
*/
const ItalicPlugin: SlatePlugin & {
/** Toggle italic mark on current selection */
toggle(): void;
};Enables underline text formatting with keyboard shortcuts and toggle functionality.
/**
* Base underline formatting plugin
*/
const BaseUnderlinePlugin: SlatePlugin;
/**
* React underline formatting plugin with component rendering
*/
const UnderlinePlugin: SlatePlugin & {
/** Toggle underline mark on current selection */
toggle(): void;
};Enables strikethrough text formatting with keyboard shortcuts and toggle functionality.
/**
* Base strikethrough formatting plugin
*/
const BaseStrikethroughPlugin: SlatePlugin;
/**
* React strikethrough formatting plugin with component rendering
*/
const StrikethroughPlugin: SlatePlugin & {
/** Toggle strikethrough mark on current selection */
toggle(): void;
};Enables inline code text formatting with keyboard shortcuts and toggle functionality.
/**
* Base code formatting plugin
*/
const BaseCodePlugin: SlatePlugin;
/**
* React code formatting plugin with component rendering
*/
const CodePlugin: SlatePlugin & {
/** Toggle code mark on current selection */
toggle(): void;
};Enables subscript text positioning with keyboard shortcuts and toggle functionality.
/**
* Base subscript formatting plugin
*/
const BaseSubscriptPlugin: SlatePlugin;
/**
* React subscript formatting plugin with component rendering
*/
const SubscriptPlugin: SlatePlugin & {
/** Toggle subscript mark on current selection */
toggle(): void;
};Enables superscript text positioning with keyboard shortcuts and toggle functionality.
/**
* Base superscript formatting plugin
*/
const BaseSuperscriptPlugin: SlatePlugin;
/**
* React superscript formatting plugin with component rendering
*/
const SuperscriptPlugin: SlatePlugin & {
/** Toggle superscript mark on current selection */
toggle(): void;
};Enables text highlighting/background color with keyboard shortcuts and toggle functionality.
/**
* Base highlight formatting plugin
*/
const BaseHighlightPlugin: SlatePlugin;
/**
* React highlight formatting plugin with component rendering
*/
const HighlightPlugin: SlatePlugin & {
/** Toggle highlight mark on current selection */
toggle(): void;
};Enables keyboard input representation formatting with keyboard shortcuts and toggle functionality.
/**
* Base keyboard input formatting plugin
*/
const BaseKbdPlugin: SlatePlugin;
/**
* React keyboard input formatting plugin with component rendering
*/
const KbdPlugin: SlatePlugin & {
/** Toggle kbd mark on current selection */
toggle(): void;
};/**
* Base plugin interface from @udecode/plate-core
*/
interface SlatePlugin {
/** Plugin identifier */
key: string;
/** Plugin configuration and handlers */
[key: string]: any;
}import { BoldPlugin, ItalicPlugin } from "@udecode/plate-basic-marks/react";
// Toggle formatting programmatically
const handleBoldClick = () => {
BoldPlugin.toggle();
};
const handleItalicClick = () => {
ItalicPlugin.toggle();
};import { createPlateEditor } from "@udecode/plate-core";
import { BasicMarksPlugin } from "@udecode/plate-basic-marks/react";
// Use all basic marks at once
const editor = createPlateEditor({
plugins: [
BasicMarksPlugin, // Includes all formatting options
]
});import { BaseBoldPlugin, BaseItalicPlugin } from "@udecode/plate-basic-marks";
// For server-side or non-React environments
const editor = createPlateEditor({
plugins: [
BaseBoldPlugin,
BaseItalicPlugin,
]
});This package is deprecated. To migrate to the new @platejs/basic-nodes package:
@udecode/plate-basic-marks with @platejs/basic-nodes@udecode/plate-basic-marks to @platejs/basic-nodesThe core functionality remains similar, but the package structure and some APIs may have evolved in the new namespace.