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-doc-preview

v0.3.2

Published

A vue document preview component

Downloads

6,231

Readme

vue-doc-preview

A vue document preview component, this component will display the contents of the document on the page.

English Readme | 中文说明书

Live Demo

Use

import

First, add this package from yarn or npm.

yarn add vue-doc-preview
or
npm i vue-doc-preview --save

Then, import this component in .vue file.

<template>
  <VueDocPreview :value="docValue" :type="docType" />
</template>

<script>
import VueDocPreview from 'vue-doc-preview'
export default {
  components: {
    VueDocPreview
  }
}
</script>

You also can open demo.vue(which in src) to learn how to use this component, but it is introduced directly to the component from the source code.

Example

<VueDocPreview value="# VueDocPreview\n**Markdown Test**```" type="markdown" />
<VueDocPreview value="newteach.pbworks.com%2Ff%2Fele%2Bnewsletter.docx" type="office" />
<VueDocPreview value="Normal Text" type="text" />
<VueDocPreview value="function () {\n  console.log('VueDocPreview')\n}" type="code" code="javascript"/>

Config

prop | description | type| default :-------: | ------- | :-------: | :-------: value | document contents or office document's url | String | '' type | document type (Now supported types are 'markdown'、'office'、'text' of 'code') | String | 'md' language | code language (It takes effect only when the type is 'code') | String | '' height | when height > 100 it means that the component's height is hight+'px', otherwise it means that the component's height is hight+'%'| Number | 90 mdStyle | markdown view custom style (It takes effect only when the type is 'markdown' or 'code') | Object | null textStyle | text view custom style (It takes effect only when the type is 'text') | Object | null url | document's url, but it only takes effect only when we don't set value (this property can also be used in office documents)| String | '' requestConfig | axios config | Object | {}

Supported document types and their suffix(language)

  • markdown: md
  • office: docx, pptx, xlsx
  • text: txt
  • code: javascript(js)、html、css、java、json、typescript(ts)、cpp、xml、bash、less、nginx、php、powershell、python、scss、shell、sql、yaml、ini

Custom style

Now, we can customize markdown view style by setting mdStyle in props.

These tags can be customized: pre, code, ul, ol, li, hr, blockquote, img, a, table, tr, th, td.

In this example we will customize the style of code block in markdown view.

// template
<VueDocPreview value="# VueDocPreview" type="markdown" :mdStyle="mdStyle" />

// script
export default {
  data: function() {
    return {
      mdStyle: {
        pre: {
          'background-color': 'rgb(187, 255, 255)'
        },
        code: {
          'background-color': 'rgb(187, 255, 255)',
          'line-height': '20px'
        }
      }
    }
  }
}

Development

Compiles and hot-reloads for development

yarn run serve

Compiles and minifies for production

yarn run build-lib

Run test for development

yarn run test

Lints and fixes files

yarn run lint

Some tips

  1. Markdown preview use highlight.js to make code show different colors, you are able to modify src/lib/highlight.js to support more language with code highlight.
  2. You can debug the components after development by running the test environment.
  3. You can show document by a url and this component will automatically download it by the url.
  4. The priority of prop value is higher than that of prop url, if you set prop value with a nonempty value, the prop url will be ignored.

License

MIT