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-summernote

v1.0.3

Published

A Vue integration summernote rich text plugin

Downloads

122

Readme

Vue summernote plugin

一个Vue集成summernote富文本插件

Requirements

  • jQuery
  • BootStrap
  • summernote

Installation

npm i vue-summernote -S

Usage

使用须知:

插件目前仅支持vue2.0以上版本

Install plugin

编辑main.js

import VueSummernote from 'vue-summernote'

// 载入bootstrap.js
require('bootstrap')

// 载入bootstrap以及summernote的样式
// 这里需要你的脚手架工具具有加载css的能力
require('bootstrap/dist/css/bootstrap.min.css')
require('summernote/dist/summernote.css')

// 这里设置summernote的初始化选项
// 可参考 http://summernote.org/deep-dive/#initialization-options
Vue.use(VueSummernote, {
  dialogsFade: true
})

编辑webpack.base.conf.js

因为summernote依赖于BootStrap,而Bootstrap严重依赖jQuery,这里需要配置jQuery为全局使用,不然会报错,找不到jQuery

var webpack = require('webpack')
var jquery = require('jquery')

module.exports = {
  plugins: [
    new webpack.ProvidePlugin({
      $: "jquery",
      jQuery: "jquery"
    })
  ]
}

Examples

<template>
<div>
  <el-row :gutter="100">
    <vue-summernote ref="editer"></vue-summernote>
    <vue-summernote ref="editer1"></vue-summernote>
  </el-row>
  <button @click="setVal">初始化</button>
  <button @click="getVal">获取</button>
</div>
</template>

<script>
export default {
  name: 'app',
  mounted () {
    const self = this
    const editer = self.$refs.editer
    const editer1 = self.$refs.editer1
    editer.$on('onImageUpload', function (files) {
      // 这里做上传图片的操作,上传成功之后便可以用到下面这句将图片插入到编辑框中
      editer.run('insertImage', 'http://vuefe.cn/images/logo.png')
    })
    editer.$on('onChange', function (contents) {
      // 当富文本框内容发生变化时做什么事
      console.log('onChange:', contents)
    })
    editer1.$on('onImageUpload', function (files) {
      // 这里做上传图片的操作,上传成功之后便可以用到下面这句将图片插入到编辑框中
      editer1.run('insertImage', 'http://vuefe.cn/images/logo.png')
    })
  },
  methods: {
    setVal () {
      // 设置初始值
      this.$refs.editer.run('code', '这里是富文本的初始值')
    },
    getVal () {
      // 获取初始值
      this.$refs.editer.run('code')
    }
  }
}
</script>

Props

| 参数 | 说明 | 类型 | 默认值 | | :---: | :---: | :---: | :---: | | placeholder | 占位符 | String | '请输入内容' | | height | 富文本编辑器高度 | Number | 500 | | minHeight | 富文本编辑器最小高度 | Number | 200 | | maxHeight | 富文本编辑器最大高度 | Number | 700 | | focus | 富文本编辑器焦点 | Boolean | true |

Events

| 事件 | 参数 | | :---: | :---: | | onInit | 无 | | onEnter | 无 | | onFocus | 无 | | onBlur | 无 | | onKeyup | event | | onKeydown | event | | onPaste | event | | onImageUpload | files | | onChange | contents |

Mothods

run(code, value)

参数说明:

| 参数 | 说明 | 类型 | 必需 | | :---: | :---: | :---: | :---: | | code | 对应summernote API的code | String | 是 | | value | 传递的值 | String/Number | 否 |

License

MIT