Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@tiptap/vue-2

Package Overview
Dependencies
Maintainers
2
Versions
212
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tiptap/vue-2

Vue components for tiptap

  • 2.0.0-beta.29
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
133K
decreased by-9.43%
Maintainers
2
Weekly downloads
 
Created

What is @tiptap/vue-2?

@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.

What are @tiptap/vue-2's main functionalities?

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>
  `,
});
```

Other packages similar to @tiptap/vue-2

Keywords

FAQs

Package last updated on 17 May 2021

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc