Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@tiptap/vue-2
Advanced tools
@tiptap/vue-2 is a renderless and extensible rich-text editor for Vue 2. It is built on top of ProseMirror and provides a highly customizable and flexible way to create rich-text editing experiences in Vue.js applications.
Basic Setup
This code sets up a basic Tiptap editor with the StarterKit extension, which includes common features like bold, italic, and bullet lists. The editor is rendered using the `EditorContent` and `EditorMenuBar` components.
```javascript
import Vue from 'vue';
import { EditorContent, EditorMenuBar, Editor } from '@tiptap/vue-2';
import StarterKit from '@tiptap/starter-kit';
new Vue({
el: '#app',
components: {
EditorContent,
EditorMenuBar
},
data() {
return {
editor: new Editor({
extensions: [StarterKit],
content: '<p>Hello World!</p>',
}),
};
},
beforeDestroy() {
this.editor.destroy();
},
template: `
<div>
<editor-menu-bar :editor="editor" />
<editor-content :editor="editor" />
</div>
`,
});
```
Custom Extensions
This code demonstrates how to create a custom extension for Tiptap. The `CustomExtension` is a simple block node that renders a `div` with a custom data attribute.
```javascript
import { Node, mergeAttributes } from '@tiptap/core';
const CustomExtension = Node.create({
name: 'customExtension',
group: 'block',
content: 'inline*',
parseHTML() {
return [
{
tag: 'div[data-type="customExtension"]',
},
];
},
renderHTML({ HTMLAttributes }) {
return ['div', mergeAttributes(HTMLAttributes, { 'data-type': 'customExtension' }), 0];
},
});
new Vue({
el: '#app',
data() {
return {
editor: new Editor({
extensions: [StarterKit, CustomExtension],
content: '<div data-type="customExtension">Custom Content</div>',
}),
};
},
beforeDestroy() {
this.editor.destroy();
},
template: `
<div>
<editor-content :editor="editor" />
</div>
`,
});
```
Using Plugins
This code shows how to add a custom ProseMirror plugin to the Tiptap editor. The `customPlugin` logs a message to the console whenever the Enter key is pressed.
```javascript
import { Plugin } from 'prosemirror-state';
const customPlugin = new Plugin({
props: {
handleKeyDown(view, event) {
if (event.key === 'Enter') {
console.log('Enter key pressed');
return true;
}
return false;
},
},
});
new Vue({
el: '#app',
data() {
return {
editor: new Editor({
extensions: [StarterKit],
content: '<p>Press Enter</p>',
plugins: [customPlugin],
}),
};
},
beforeDestroy() {
this.editor.destroy();
},
template: `
<div>
<editor-content :editor="editor" />
</div>
`,
});
```
Quill is a modern WYSIWYG editor built for compatibility and extensibility. It provides a rich API and a wide range of features out of the box. Compared to @tiptap/vue-2, Quill is more opinionated and less flexible in terms of customization and extending functionality.
Slate is a completely customizable framework for building rich text editors. It provides a lot of flexibility and control over the editor's behavior and appearance. Slate is more low-level compared to @tiptap/vue-2, requiring more effort to set up and customize.
Draft.js is a framework for building rich text editors in React, developed by Facebook. It offers a lot of control and customization options. However, it is React-specific and may require more boilerplate code compared to @tiptap/vue-2.
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
Vue components for tiptap
We found that @tiptap/vue-2 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
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.