New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

vuetify-pro-tiptap

Package Overview
Dependencies
Maintainers
1
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vuetify-pro-tiptap

tiptap text editor on vuejs and vuetify

1.0.1
Source
npm
Version published
Weekly downloads
1.4K
-11.33%
Maintainers
1
Weekly downloads
 
Created
Source

Vuetify Pro Tiptap

一个 Vue.js 的基于 tiptapvuetify 的 「所见即所得」 富文本编辑器

semantic-release: angular

Demo

👉https://yikoyu.github.io/vuetify-pro-tiptap/

特色

  • 使用 vuetify 组件
  • 支持 markdown 语法
  • TypeScript 支持
  • 支持 i18n
  • Vuetify 2.x 和 Vue 2.x 支持

安装

NPM安装

pnpm add vuetify-pro-tiptap

或者

yarn add vuetify-pro-tiptap

或者

npm i vuetify-pro-tiptap -S

安装插件

import Vue from 'vue'
import VCA, { createApp, h } from '@vue/composition-api'

import Vuetify from 'vuetify/lib'

import { createVuetifyProTipTap } from 'vuetify-pro-tiptap'
import 'vuetify-pro-tiptap/style.css'

import App from './App.vue'

Vue.use(VCA)
Vue.use(Vuetify)

const vuetify = new Vuetify()

const VuetifyProTipTap = createVuetifyProTipTap({
  vuetify,
  lang: 'zhHans'
})
Vue.use(VuetifyProTipTap)

createApp({
  vuetify,
  render: () => h(App)
}).mount('#app')

国际化

设置语言

你可以在安装插件的时候声明

import { createVuetifyProTipTap } from 'vuetify-pro-tiptap'

const VuetifyProTipTap = createVuetifyProTipTap({
  lang: 'zhHans'
})

或者调用方法动态修改

import { locale } from 'vuetify-pro-tiptap'

locale.setLang('en')

可用的语言:

  • en (默认)
  • zhHans

加载新语言

当前语言暂未提供时,可以使用 setMessage 进行设置

import { locale } from 'vuetify-pro-tiptap'

locale.setMessage('zhHant', {
  // 国际化文本
})
locale.setLang('zhHant')

用法

<script lang="ts">
import { defineComponent, ref, type Ref } from '@vue/composition-api'
import { mdiDeleteCircleOutline, mdiSend, mdiFileCodeOutline } from '@mdi/js'
import { VuetifyTiptap, VuetifyViewer, type ToolbarType, type StarterKitOptions, locale } from 'vuetify-pro-tiptap'
import SelectImage from './components/SelectImage.vue'

export default defineComponent({
  components: {
    VuetifyTiptap,
    VuetifyViewer
  },
  setup() {
    const content = ref(`<h2 style="text-align: center">Welcome To Vuetify Tiptap Editor Demo</h2>`)

    const config: Ref<Partial<StarterKitOptions>> = ref<Partial<StarterKitOptions>>({
      image: {
        upload: uploadImage, // 图片上传方法
        imageTabs: [{ name: 'SELECT', component: SelectImage }] // 自定义 tab
        hiddenTabs: ['upload'] // 需要隐藏的 tab
      }
    })

    // 自定义工具栏
    const toolbar = ref<ToolbarType[]>([
      'bold',
      'italic',
      'underline',
      'strike',
      'color',
      'highlight',
      '|',
      'h1',
      'h2',
      'h3',
      'h4',
      'h5',
      'h6',
      'p',
      '|',
      'left',
      'center',
      'right',
      'justify',
      '|',
      'bulletList',
      'orderedList',
      'taskList',
      'indent',
      'outdent',
      '|',
      'link',
      'image',
      'video',
      '|',
      'blockquote',
      'rule',
      'code',
      '|',
      'clear',
      'fullscreen',
      'undo',
      'redo',
      '#preview'
    ])

    function uploadImage(file: File): Promise<string> {
      return Promise.resolve('https://img-prod-cms-rt-microsoft-com.akamaized.net/cms/api/am/imageFileData/RE4wE9P?ver=e767')
    }

    return {
      mdiDeleteCircleOutline,
      mdiFileCodeOutline,
      mdiSend,
      content,
      config,
      toolbar,
      dialog: ref(false)
    }
  }
})
</script>

<template>
  <div>
    <vuetify-tiptap
      v-model="content"
      label="Title"
      :config="config"
      :toolbar="toolbar"
      :dark="$vuetify.theme.dark"
      placeholder="Enter some text..."
      rounded
      :maxHeight="465"
    >
      <template #preview="{ attrs }">
        <v-dialog v-model="dialog" fullscreen hide-overlay>
          <template #activator="{ on, attrs: dialog }">
            <v-btn v-bind="{ ...attrs, ...dialog }" v-on="on">
              <v-icon>{{ mdiFileCodeOutline }}</v-icon>
            </v-btn>
          </template>

          <v-card>
            <v-toolbar dark color="primary">
              <v-btn icon dark @click="dialog = false">
                <v-icon>$close</v-icon>
              </v-btn>
            </v-toolbar>

            <v-container>
              <vuetify-viewer :value="content" />
            </v-container>
          </v-card>
        </v-dialog>
      </template>
    </vuetify-tiptap>
  </div>
</template>

Props

VuetifyTiptap

名称类型默认值说明
valuestring''输入的值
darkbooleanfalse是否为深色主题
densebooleanfalse是否为紧凑模式
outlinedbooleantrue将轮廓样式应用于输入
disabledbooleanfalse禁用输入
labelstringundefined设置输入标签
placeholderstringundefined设置输入的占位符文本
toolbarToolbarType[]展示所有组件工具栏组件配置
hideToolbarbooleanfalse隐藏工具栏
disableToolbarbooleanfalse禁用工具栏
minHeightstring | booleanundefined输入框最小高度
maxHeightstring | booleanundefined输入框最大高度
extensionsAnyExtension[][]tiptap插件
configPartial<StarterKitOptions>{}编辑器配置
editorClassstring | string[] | Record<string, any>undefined编辑器class

VuetifyViewer

名称类型默认值说明
valuevalue''预览的值
densebooleanfalse是否为紧凑模式
xssbooleantrue是否开启xss过滤
xssOptionsxss.IWhiteList内置默认规则xss过滤规则配置

Keywords

vue

FAQs

Package last updated on 12 Jun 2022

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