Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
@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
The npm package @tiptap/suggestion receives a total of 329,474 weekly downloads. As such, @tiptap/suggestion popularity was classified as popular.
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 6 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.