npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-tik

v1.0.8

Published

Opinionated Tiptap Vue Wrapper Editor

Downloads

2

Readme

Vue Tik

A Opinionated Tiptap Vue Wrapper Editor. This project is simply a wrapper for Tiptap with predesigned and preinstalled module and of course some opinionated customization.

Built on top of UnoCSS, Headless UI, and of course Tiptap.

Installation

Install the package from the NPM:

pnpm i vue-tik

Quick Start

You can install the plugin in your main entry vue files:

import { createApp } from 'vue'
import App from './App.vue'
import { Editor } from 'vue-tik'
import 'vue-tik/dist/style.css'

createApp(App).use(Editor).mount('#app')

After it you can start using it immediately:

<script setup lang="ts">
import { useEditor } from 'vue-tik'

const { editor } = useEditor()
</script>
<template>
  <vue-tik :config="editor" />
</template>

Configuration

The package supports Global and Local scope configuration.

To define a global scope configuration, simply put the configuration right next to your use() statement:

createApp(App)
  .use(Editor, {
    image: {
      strategy: 'string'
    }
  })
  .mount('#app')

And for local scope configuration, you can put the config in useEditor argument:

const { editor } = useEditor({
  image: {
    strategy: 'string'
  }
})

Using local configuration will override the current global configuration for the component.

Here's the full configuration schema:

export interface EditorOptions {
  image?: {
    strategy?: 'string' | 'upload'
    url?: string
    requests?: object
    headers?: HeadersInit
    bindId?: boolean
  }
  initialValue?: string
  highlight?: {
    color?: string
  }
}

| Key | Description | Value | | ----------------- | ---------------------------------------------------------------------------------- | ------------------ | | image.strategy | Set the strategy of how image being uploaded is handled | string \| upload | | image.url | Set the target url of upload strategy (required if image.strategy is upload) | string | | image.requests | Append the requests payload of the image upload (optional) | object | | image.headers | Append the header payload of the image upload (optional) | object | | image.bindId | Bind the unique id from the image upload to the parsed content (optional) | boolean | | initialValue | Set the initial value of the editor. | string | | highlight.color | Set the color of the editor highlight | string |

Handling Image Uploads

VueTik also provide 2 ways of uploading an image. The easiest string method which use base64 by default.

If that's not satisfies you, VueTik also provide upload method which as the name said, it's basically an upload type.

To setup the upload all you need to do is:

import { useEditor } from 'vue-tik'

const { Editor } = useEditor({
  image: {
    strategy: 'upload',
    url: 'http://localhost:3000/upload'
  }
})

The upload will use POST using form-data, and this is the response VueTik will expect from your API:

{
  "image": {
    "url": "https://localhost:3000/img/upload.jpg",
    "id": "bf81cb61-3014-4d23-a029-0bd202396f31"
  },

  "error": false
}

and of course 2xx status code. To simplify the upload there's also the server side integration (Coming Soon).

Twitter Integration

The editor also support twitter embeds. However it's not like full integration yet. I do have a plan for it.

The editor integration requires you to register the peer dependency in order to render the twitter embed:

<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>

There's still a limitation for twitter integeration. Currently if you use getContent or getContentJson the twitter node will only return div with data-twitter-id attribute. This means you have to hydrate it manually using the createTwitter API.

Rendering VueTik

To render the result of VueTik you can use api from useEditor:

  • getContent() return the html content
  • getContentJson() return the json content

Alternatively, you can also use the editor itself Tiptap Docs. The useEditor also exposed the API of the original Tiptap's Editor.

Here's the example:

const { editor } = useEditor()

onMounted(() => {
  editor.editor.value?.setEditable(false)
})

Even though you can do above example, I am still unsure if the menu will also gone? Perhaps I should provide the official API to perform that. Well that's a plan for sure.

The recommended way is of course to use the content from getContent or getContentJson API and transforms it manually or use Server Side Integration to do it automatically for you (Coming Soon).