Collection of utility extensions for Tiptap rich text editor including character counting, placeholders, focus management, and history controls
—
Extensions that enhance cursor movement, gap navigation, and user interaction patterns within the editor.
Enables cursor placement in gaps between block nodes where no content normally exists, improving navigation between structural elements.
/**
* Gap cursor extension for cursor placement between block nodes
*/
const Gapcursor: Extension;
declare module '@tiptap/core' {
interface NodeConfig<Options, Storage> {
/** Configure whether this node type allows gap cursor placement */
allowGapCursor?: boolean | null | ((this: {
name: string;
options: Options;
storage: Storage;
parent: ParentConfig<NodeConfig<Options>>['allowGapCursor'];
}) => boolean | null);
}
}Usage Examples:
import { Gapcursor } from "@tiptap/extensions/gap-cursor";
// Enable gap cursor
const editor = new Editor({
extensions: [
Gapcursor,
],
});
// Configure nodes to allow/disallow gap cursor
import { Node } from "@tiptap/core";
const CustomBlock = Node.create({
name: 'customBlock',
addOptions() {
return {
allowGapCursor: true, // Allow gap cursor around this node
};
},
// Node definition...
});
// Dynamic allowGapCursor configuration
const ConditionalNode = Node.create({
name: 'conditionalNode',
addOptions() {
return {
allowGapCursor: function() {
// Custom logic to determine gap cursor allowance
return this.options.someCondition === true;
},
};
},
});Gap Cursor Behavior:
Provides custom styling for text selections when the editor is not focused, enhancing visual feedback for users.
/**
* Selection extension for custom selection styling when unfocused
*/
const Selection: Extension<SelectionOptions> & {
/** Default export variant */
default: Extension<SelectionOptions>;
};
type SelectionOptions = {
/** CSS class name applied to selected text (default: 'selection') */
className: string;
}Usage Examples:
import { Selection } from "@tiptap/extensions/selection";
// Basic selection styling
const editor = new Editor({
extensions: [
Selection.configure({
className: 'unfocused-selection',
}),
],
});
// Using with CSS for visual styling
const styledEditor = new Editor({
extensions: [
Selection.configure({
className: 'custom-highlight',
}),
],
});
// CSS to style the selection
/*
.custom-highlight {
background-color: rgba(0, 123, 255, 0.3);
border-radius: 2px;
}
*/Selection Features:
Both extensions enhance the user interaction model:
Gap Cursor Interaction:
Selection Interaction:
// Combined usage for enhanced navigation
import { Gapcursor, Selection } from "@tiptap/extensions";
const editor = new Editor({
extensions: [
Gapcursor, // Enable gap navigation
Selection.configure({
className: 'persistent-selection', // Show selections when unfocused
}),
],
});
// Enhanced interaction with both extensions
editor.on('focus', () => {
console.log('Editor focused - selection styling removed');
});
editor.on('blur', () => {
console.log('Editor blurred - selection styling applied');
});Install with Tessl CLI
npx tessl i tessl/npm-tiptap--extensions