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

xqeditor

v0.0.2

Published

This is a simplify markdown editor.

Downloads

5

Readme

xqeditor

This is a simplify markdown editor.

View Chinese documents

Install

  • import cdn package
<!-- index.html -->
<!-- css -->
<link href="https://cdn.bootcdn.net/ajax/libs/font-awesome/6.2.0/css/all.min.css" rel="stylesheet">
<link href="https://cdn.bootcdn.net/ajax/libs/github-markdown-css/5.1.0/github-markdown.min.css" rel="stylesheet">
<link href="https://cdn.bootcdn.net/ajax/libs/highlight.js/11.6.0/styles/default.min.css" rel="stylesheet">
<!-- js -->
<script src="https://cdn.bootcdn.net/ajax/libs/markdown-it/13.0.1/markdown-it.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/highlight.js/11.6.0/highlight.min.js"></script>
  • Browser
<!-- CSS -->
<link rel="stylesheet" href="https://xqgj.cc/xqcdn/libs/xqeditor/css/xqeditor.min.css">
<!-- Browser -->
<script src="https://xqgj.cc/xqcdn/libs/xqeditor/js/xqeditor.min.js"></script>
<!-- es module -->
<script type="module">
    import xqgjs from '../lib/js/xqeditor-esm.min.js';
</script>
  • Vue
npm i xqeditor

Usage

Browser

  • html
<div id="myEditor"></div>
<div class="myeditor-btns">
    <button id="myeditor-btn-set">Set</button>
    <button id="myeditor-btn-get">Get</button>
    <button id="myeditor-btn-img">Img</button>
</div>
  • js
// init editor
let myEditor = new XqEditor({
    el: '#myEditor',
});

// setting
let setBtn = document.getElementById('myeditor-btn-set');
let getBtn = document.getElementById('myeditor-btn-get');
let imgBtn = document.getElementById('myeditor-btn-img');
let url = '';

console.log(myEditor);

// set value
setBtn.addEventListener('click', setVal, false);
function setVal () {  
    let val = '# hello \n\n';
    myEditor.setVal(val);
}

// get value
getBtn.addEventListener('click', getVal, false);
function getVal () {
    let result = myEditor.getVal();
    alert('result is '+JSON.stringify(result));
}

// get image
imgBtn.addEventListener('click', getImg, false);
function getImg () {
    let result = myEditor.editor.files;
    if (!result) {
        alert('请先上传图片!');
        return;
    }
    if (url) { 
        URL.revokeObjectURL(url);
    } else {
        url = URL.createObjectURL(result[0]);
    }
    myEditor.addEditor('image', url);
    alert('result is '+JSON.stringify(result));
}

Vue

  • import
import xqeditor from 'xqeditor';
Vue.use(xqeditor);
  • component
<xq-editor
    ref="xqeditor"
    :content="editor.content" 
    :url="editor.uploadUrl" 
    @uploadImg="uploadImg"
>
</xq-editor>
<button @click="setVal">Set Value</button>
<button @click="getVal">get Value</button>
export default {
    name: 'demo',
    data () {
        return {
            editor: {
                content: '', // editor content
                uploadUrl: '', // upload file addr
            }
        }
    },
    methods: {
        // upload image
        uploadImg (files) {
            // your upload method
            // ...

            // upload success
            let url = 'https://xxx.xxx/xxx.jpg';
            this.editor.uploadUrl = url;
        },
        // set Value
        setVal () {
            this.$refs.xqeditor.setVal('# hello');
        },
        // get value
        getVal () {
            this.$refs.xqeditor.getVal();
            // { text: '# hello \n\n ...', html: '<h1>hello</h1>...' }
        },
    }
}

View xqeditor

Run this script to view the demonstration case: npm run test:browser.

【Demo Preview】

Preview Image

ask questions

submit your question

Author

@gitguanqi