Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
@tiptap/suggestion
Advanced tools
@tiptap/suggestion is a plugin for the Tiptap editor that provides a way to add suggestions to your editor. This can be used for implementing features like mentions, hashtags, or any other type of inline suggestions.
Basic Suggestion Setup
This code sets up a basic suggestion plugin that triggers on the '@' character. When a suggestion is selected, it inserts a mention node at the current position.
import { Suggestion } from '@tiptap/suggestion';
const suggestion = Suggestion({
char: '@',
startOfLine: false,
command: ({ editor, range, props }) => {
editor.chain().focus().insertContentAt(range, [
{
type: 'mention',
attrs: props,
},
{
type: 'text',
text: ' ',
},
]).run();
},
});
Customizing Suggestion Menu
This code customizes the suggestion menu to trigger on the '#' character and filter items based on the query. It uses Vue and Tippy.js to render and manage the suggestion list.
import { Suggestion } from '@tiptap/suggestion';
const suggestion = Suggestion({
char: '#',
startOfLine: false,
items: ({ query }) => {
return [
{ title: 'JavaScript', id: 1 },
{ title: 'TypeScript', id: 2 },
{ title: 'React', id: 3 },
].filter(item => item.title.toLowerCase().includes(query.toLowerCase()));
},
render: () => {
let component;
let popup;
return {
onStart: props => {
component = new Vue({
render: h => h(SuggestionList, { props }),
}).$mount();
popup = tippy('body', {
getReferenceClientRect: props.clientRect,
appendTo: () => document.body,
content: component.$el,
showOnCreate: true,
});
},
onUpdate: props => {
component.$props = props;
popup[0].setProps({
getReferenceClientRect: props.clientRect,
});
},
onExit: () => {
popup[0].destroy();
component.$destroy();
},
};
},
});
prosemirror-suggest is a plugin for ProseMirror that provides similar functionality to @tiptap/suggestion. It allows you to create suggestions for mentions, hashtags, and other inline elements. Compared to @tiptap/suggestion, it is more tightly integrated with ProseMirror and may require more setup.
Tribute.js is a lightweight, vanilla JavaScript library for adding autocomplete/suggestions to input fields and textareas. It is not specifically designed for rich text editors like Tiptap but can be adapted for use with them. It offers a flexible API and is easy to integrate.
quill-mention is a module for the Quill rich text editor that provides mention suggestions. It is similar to @tiptap/suggestion but is designed specifically for Quill. It offers a straightforward way to add mention functionality to Quill editors.
Tiptap is a headless wrapper around ProseMirror – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as New York Times, The Guardian or Atlassian.
Documentation can be found on the Tiptap website.
Tiptap is open sourced software licensed under the MIT license.
FAQs
suggestion plugin for tiptap
We found that @tiptap/suggestion demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.