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

v0.0.5

Published

A markdown editor

Downloads

3

Readme

功能介绍

  1. 支持图片上传(允许跨域)
  2. 支持实时预览和全屏模式
  3. 支持通过粘贴键,上传qq截图
  4. 支持快捷键操作,例如撤销,恢复,缩进

安装

npm i

使用

方法一全局引入(推荐)

import vueBlogEditor from 'vueBlogEditor'
Vue.use(vueBlogEditor)

在组件中加载编辑器

<template>
  <vueBlogEditor v-model="content" :options="options" :upload="upload"></vueBlogEditor>
</template>
<script>
  // 代码高亮配置
  import hljs from 'highlight.js'
  export default {
    data () {
      upload: {
        // 如果需要上传图片,在这里填写url
        // vueBlogEditor向该地址发送post请求,上传成功后后台需返回一个src地址  
        url: 'http://127.0.0.1:8080/v1/upload',
        headers: {
          token: 'token value'
        }
      },
      // 这里配置请参考markdown-it
      options: {
        linkify: true,
        highlight(str, lang) {
          lang = lang || 'javascript'
          if (hljs.getLanguage(lang)) {
            try {
              return hljs.highlight(lang, str).value
            } catch (__) {}
          }
          return ''
        }
      }
    }
  }
</script>
<style>
  /* 高亮风格可自己配置 */
  @import '~highlight.js/styles/github.css';
</style>

在前台显示渲染后的文本

当我们把markdown文本存入数据库后,前台需要显示解析后的html,这也是很简单的

<template>
  <top-preview :content="content" :options="options"></top-preview>
</template>
<script>
  export default {
    data () {
      return {
        // content就是从数据库中获取到的markdown文本
        content: this.$store.state.content,
        options: {
          linkify: true,
          highlight(str, lang) {
            lang = lang || 'javascript'
            if (hljs.getLanguage(lang)) {
              try {
                return hljs.highlight(lang, str).value
              } catch (__) {}
            }
            return ''
          }
        }
      }
    }
  }
</script>
<style>
  @import '~highlight.js/styles/github.css';
</style>

说明:为了减小包的体积,没把highlight.js和markdown-it集成到vueBlogEditor

配置项说明

属性:

| 参数 | 说明 | 类型 | 默认值 | | ------- | ------------------- | -------- | ---- | | preview | 是否开启预览模式 | Boolean | true | | v-model | textarea中的值 | String | null | | options | markdown-it的配置项 | Object | 文档 | | zIndex | 编辑器的z-index | number | 99 | | height | 编辑器默认高度 | String | 70vh | | upload | 图片上传配置 | Object | 详情 |

事件:

| 类型 | 说明 | 返回值 | | --- | --- | --- | | save | 当ctrl+s时执行 | true |

upload配置项

{
  // 图片上传api地址,需返回一个图片地址,如'https://test.com/static/a.jpg'
  url: false,
  // 如果需要认证在这里可配置
  headers: {
    token: 'token value'
  }
}

查看演示和贡献代码

git clone [email protected]:LDQ-first/vue-blogEditor.git
npm i

# 修改webpack.config.js
# npm run build时打包文件
entry: './src/lib/index.js',

# npm run dev时查看演示
entry: './src/main.js',

效果图

vue-blogEditor

开源协议

MIT