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

vueditor-fork

v0.3.13

Published

a wysiwyg editor based on Vue.js and Vuex

Downloads

9

Readme

Fork ReadMe

This is a fork of Vueditor by +v

Added

  • Added props 'content' to set default content of editor.
  • Added @changed emit event to get content changed.
<vueditor :content="content" @changed="getVal"></vueditor>
export default {
    data () {
      return {
        content: 'I am default content'
      }
    },
    methods: {
      getVal: function (newVal) {
        console.log(newVal)
      }
    }
  }

Vueditor

vueditor vueditor JavaScript Style Guide

中文文档

A wysiwyg editor written in Vue.js and Vuex.js, require Vue.js 2.0.0, Vuex.js 2.0.0 and above.

Browser compatibility: Chrome, Firefox, Safari, IE 9+.

Online DEMO

Screenshot

vueditor

Features

  • Customizable
  • Light weighted, very few dependencies
  • Plugin support

Installation

npm install vueditor

If you prefer to use it via script tag, download the last release package and add vueditor.min.js, vueditor.min.css to your page.

Usage

Vue.use(Vueditor, config)

Use it in the following cases:

  1. Only one editor required
  2. Multiple editors required but shared the same config
import Vue from 'vue'
import Vuex from 'vuex'
import Vueditor from 'vueditor'

import 'vueditor/dist/style/vueditor.min.css'

// your config here
let config = {
  toolbar: [
    'removeFormat', 'undo', '|', 'elements', 'fontName', 'fontSize', 'foreColor', 'backColor'
  ],
  fontName: [
    {val: 'arial black'}, 
    {val: 'times new roman'}, 
    {val: 'Courier New'}
  ],
  fontSize: ['12px', '14px', '16px', '18px', '0.8rem', '1.0rem', '1.2rem', '1.5rem', '2.0rem'],
  uploadUrl: ''
};

Vue.use(Vuex);
Vue.use(Vueditor, config);
// create a root instance
new Vue({
  el: '#editorContainer'
});

Then in your vue template somewhere:

<template>
  <div>
    ...
    <Vueditor></Vueditor>
  </div>
</template>

To get and set content you need to acquire the Vueditor component, you can use $children[index] or ref to do that.

let parent = new Vue({
  el: '#editor1'
});
let editor = parent.$children[0];
editor.setContent('your content here');
editor.getContent();

createEditor(selector, config)

Call createEditor and pass specific config as parameter respectively for multiple editors in a page.


  import Vue from 'vue'
  import Vuex from 'vuex'
  import { createEditor } from 'vueditor'

  import 'vueditor/dist/style/vueditor.min.css'
  
  Vue.use(Vuex);

  createEditor('#editorContainer', {
    toolbar: [
      'removeFormat', 'undo', '|', 'elements', 'fontName', 'fontSize', 'foreColor', 'backColor', 
    ],
    uploadUrl: '',
    id: '',
    classList: []
  });

The initialized element will be replaced in this case, you can add classList or id to the config for adding styles, the rendered element will have these attributes. createEditor returns a vueditor instance, you can set and get content with it:

let inst = createEditor(...);
inst.setContent('your content here');
inst.getContent();

File upload

You can set uploadUrl attribute in config when you initialize an editor, all the upload stuffs will be handled automatically. If you perfer do it yourself or has some authrization to do before uploading, just add a function upload to the instance returned by createEditor. When an upload action triggered, vueditor will call this function instead of the build-in function. The upload function has two arguments: obj refer to the file input element, callback requires the uploaded file url as argument for inserting content to the editor, See the example below:

editor.upload = function (obj, callback) {
  let formData = new FormData();
  let xhr = new XMLHttpRequest();
  formData.append('fieldName', obj.files[0]);
  xhr.open('POST', 'upload/url');
  xhr.send(formData);
  xhr.onload = function () {
    callback(xhr.responseText);
  };
  xhr.onerror = function (err) {
    console.log(err);
  }
}

language setting

The editor's default language is English, to set to other language, you will need to translate for your own. The dist/language folder has an full example inside. Adding a script tag or use import, require to
bring the language object in, then make it an attribute of the config for initialize. See the example below:

Vue.use(Vueditor, {
  ...
  lang: languageObject,
});

Options for configuration:

| Name | Type | Description | | --------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------- | | spellcheck | Boolean | Check spell or not, default is false | | lang | Object | Interface language, default is English | | toolbar | Array | Buttons on the toolbar, use | or divider as separator for grouping | | fontName | Array | The font-family select's options, val refer to the actual css value, abbr refer to the option's text, abbr is optional when equals to val | | fontSize | Array | The font-size select's options | | uploadUrl | String | File upload url, the return result of this must be a string refer to the uploaded file url, leave it empty will end up with local preview | | id | String | id for the rendered editor element | | classList | Array | className for the rendered editor element | | plugins | Array | plugins for editor |

Default value of the above fields:

{
  toolbar: [
    'removeFormat', 'undo', '|', 'elements', 'fontName', 'fontSize', 'foreColor', 'backColor', 'divider',
    'bold', 'italic', 'underline', 'strikeThrough', 'links', 'divider', 'subscript', 'superscript',
    'divider', 'justifyLeft', 'justifyCenter', 'justifyRight', 'justifyFull', '|', 'indent', 'outdent',
    'insertOrderedList', 'insertUnorderedList', '|', 'picture', 'tables', '|', 'switchView'
  ],
  fontName: [
    {val: 'arial black'}, 
    {val: 'times new roman'}, 
    {val: 'Courier New'}
  ],
  fontSize: [
    '12px', '14px', '16px', '18px', '20px', '24px', '28px', '32px', '36px'
  ],
  uploadUrl: ''
  id: '',
  classList: []
};

Change log

See change log

Bug confirmed

TODO

  • [x] Markdown support
  • [x] Full screen and fixed toolbar features
  • [x] Popup menu position auto adjust
  • [ ] Advanced table options
  • [ ] Code highlight
  • [ ] Plugin support
  • [ ] XSS prevention
  • [ ] Test

License

MIT

Copyright (c) 2016 hifarer