• Stars
    star
    135
  • Rank 269,297 (Top 6 %)
  • Language Vue
  • License
    MIT License
  • Created over 5 years ago
  • Updated 9 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A medium like text editor for vue js WYSIWYG

npm version npm version npm version

VueJs Medium Editor

Vue 2 and 3 Js component for Medium Editor wrapper with https://github.com/yabwe/medium-editor But all plugins are re-writing in Vue.js All Medium Editor configs are supported

Demo

Demo

Features

  • Medium like editor
  • Image uploader and description
    • Image width configable width for normal / expand / full screen sizing
    • Imgur uploading
  • Embed Gist
  • Inline code syntax highlighting
  • Embed video
    • Youtube video and shorts
    • Vimeo video
    • Loom video

Usage

Installation

yarn add vuejs-medium-editor

# Vue 3
yarn add vuejs-medium-editor@next

OR

npm install vuejs-medium-editor

# Vue 3
npm install vuejs-medium-editor@next

Usage

add to global component in Vue 2

import Vue from 'vue'
import MediumEditor from 'vuejs-medium-editor'

Vue.component('medium-editor', MediumEditor)

OR Vue 3

import { createApp } from 'vue'
import MediumEditor from 'vuejs-medium-editor'
import App from './App.vue'

const app = createApp(App)

app.component('medium-editor', MediumEditor)
app.mount('#app')

Don't forget to include css file in your project For Vue 2

import 'medium-editor/dist/css/medium-editor.css'
import 'vuejs-medium-editor/src/themes/default.css'
// for the code highlighting
import 'highlight.js/styles/github.css'

OR in styles like below

<style lang="css">
@import "~medium-editor/dist/css/medium-editor.css";
@import "~vuejs-medium-editor/src/themes/default.css";
/*@import '~highlight.js/styles/github.css';*/
@import '~highlight.js/styles/github.css';
</style>

For for Vue 3

import 'medium-editor/dist/css/medium-editor.css'
import 'vuejs-medium-editor/dist/themes/default.css'
// for the code highlighting
import 'highlight.js/styles/github.css'

OR in styles like below

<style lang="css">
@import "medium-editor/dist/css/medium-editor.css";
@import "vuejs-medium-editor/dist/themes/default.css";
/*@import '~highlight.js/styles/github.css';*/
@import 'highlight.js/styles/github.css';
</style>

Example

<medium-editor
  v-model="content"
  :options="options"
  :onChange="onChange"
  v-on:uploaded="uploadCallback"
/>

<script>
import Editor from 'vuejs-medium-editor'

export default {
  data() {
    return {
      content: '',
      options: {},
    }
  },
  components: {
    'medium-editor': Editor,
  },
  methods: {
    onChange() {
      console.log(this.content)
    },
    uploadCallback(url) {
      console.log('uploaded url', url)
    },
  },
}
</script>

Available Props

  • prefill(string) - Pre filled editor value - default value,
  • readOnly(boolean) - make the editor read only. Default - false
  • options - used to pass editor options, see below
  • onChange - pass onchange event
  • hideImage - Hides image upload option (default -false)
  • hideGist - Hides gist code embed - default(false)
  • hideVideo - Hides video embed - default(false)

Events

  • uploaded - imgur image upload callback

Options

toolbar

you can customize the toolbar buttons too

options: {
  toolbar: {
    buttons: [
      'bold',
      'italic',
      'underline',
      'quote',
      'h1',
      'h2',
      'h3',
      'pre',
      'unorderedlist',
    ]
  }
}

available options: All options are available here You can also override options like in Medium Editor ;

options: {
  buttons: [
    'anchor',
    {
      name: 'pre',
      action: 'append-pre',
      aria: 'code highlight',
      tagNames: ['pre'],
      contentDefault: '<b><\\></b>',
      contentFA: '<i class="fa fa-code fa-lg"></i>',
    },
  ]
}

images

Using the image option in toolbar, Add image link, highlight to edit, then select image icon

buttons: [
  {
    name: 'image',
    action: 'image',
    aria: 'insert image from url',
    tagNames: ['img'],
    contentDefault: '<b>image</b>',
    contentFA: '<i class="fa fa-picture-o"></i>',
  },
]

Also, available option: thanks to ErgoFriend pull request on the original repo

 options: {
    uploadUrl: "https://api.imgur.com/3/image",
    uploadUrlHeader: {'Authorization': 'Client-ID a3tw6ve4wss3c'},
    file_input_name: "image",
    file_size: 1024 * 1024 * 10,
    imgur: true,
 }

code highlighting

  1. Code highlighting is inbuilt using highlight.js Add code snippet, highlight, then select code in toolbar(you need to add pre in toolbar, see options above)

You should include the highligh.js css file within the styles

<style>
    /*default css  */
    @import 'highlight.js/styles/default.css';
    /* github style */
    @import 'highlight.js/styles/github.css';
</style>

You can get more theme styles here

  1. Code highliting using gist, also inbuilt. Click + button, then click code(Add gist), then add gist URL, click Enter to finish

Read only example

<medium-editor :prefill="defaultValue" :read-only="true" />

Nuxt.js Usage

create a plugin file vuejs-medium-editor.js inside /plugins dir

import Vue from 'vue'
import MediumEditor from 'vuejs-medium-editor'

Vue.component('medium-editor', MediumEditor)

import a plugin in nuxt.config.js with disable ssr mode

plugins: [{ src: '~/plugins/vuejs-medium-editor', ssr: false }]

include a css file For Vue 2

css: [
  'medium-editor/dist/css/medium-editor.css',
  'vuejs-medium-editor/src/themes/default.css',
  'highlight.js/styles/github.css', //if using code highlight
]

For Vue 3

css: [
  'medium-editor/dist/css/medium-editor.css',
  'vuejs-medium-editor/dist/themes/default.css',
  'highlight.js/styles/github.css', //if using code highlight
]

About Me

Magak Emmanuel

License

MIT

license

Open Source Love

Happy coding, Star before Fork 😊💪💯

More Repositories

1

mpesab2c

mpesa b2c laravel implementation
PHP
11
star
2

laravel-graphql

A laravel graphQL API application sample
PHP
6
star
3

devFestWestern

devFest Western Kenya 2019 Presentation and Demo on Firebase with Web Service
Vue
6
star
4

mpesa_elixir

This is wrapper(Elixir) for Daraja Mpesa STK implementation(Lipa na Mpesa Online)
Elixir
4
star
5

Laravel-and-Vue-SPA

A Single Page Application with Vue Js and Laravel
PHP
4
star
6

whatsapp-chatbot

simple whatsapp weather chat bot using Twilio, DialogFlow na OpenweatherMap
PHP
4
star
7

Simple-Blog

a simple Rails auth and blog
Ruby
4
star
8

phoenix-ecomerce

An eCommerce website based on Vue js and Phoenix
Elixir
4
star
9

vue-unit-test

a simple unit test in vue js
JavaScript
3
star
10

droidconKe-Native-script

droidconKe 2020 App Implemetation with Nativescript-vue
Vue
3
star
11

subscription

MailChimp email subscription implementation with laravel
PHP
3
star
12

vue_travis_ci

A simple CI CD implementation in Vue JS to Travis CI
JavaScript
3
star
13

gtt_api

this is a live session code project from gtt, 18th jan 2018
PHP
3
star
14

FarmBase

JavaScript
3
star
15

phx_izitoast

This is a Phoenix Elixir IziToast Notification wrapper by https://izitoast.marcelodolza.com, A JavaScript Notifications Toast Library
Elixir
3
star
16

laravel-bdtask-interview

Laravel Interview
PHP
2
star
17

todo_laravel_vue_app

A simple TODO App in Laravel 8 and Vue 3
PHP
2
star
18

laravel-btoast

A bootstrap 4 toast wrapper for Laravel 5.* #laravel #toast #bootstrap
PHP
2
star
19

phoenix-blog

a blog made with phoenix, for learning
Elixir
2
star
20

phoenix-inertia

A Phoenix App to demonstrate Vue JS SPA with Inertia JS routing
Elixir
2
star
21

Ruby-Blog-beginner-

my first CRUD project in ruby
Ruby
2
star
22

mpesa-testC2B

mpesa api test C2B,
PHP
2
star
23

laravel-inertia

A laravel app to demonstrate use of inertia Js, Vue Js SPA
PHP
2
star
24

LearnRails

a learning tutorial from https://www.freecodecamp.org/news/lets-create-an-intermediate-level-ruby-on-rails-application-d7c6e997c63f/
Ruby
2
star
25

laravel_admin

Laravel 5.6 admin panel simple tutorial
PHP
2
star
26

deezer-vite-react-ts

A deezer like app in react and ts with vite
TypeScript
2
star
27

Chordit

music chords website
CSS
2
star
28

Laravel-Serviside-datatables

a simple example to demonstrate datatables using laravel and yajra laravel package https://github.com/yajra/laravel-datatables
PHP
2
star
29

graphql-nuxt

A sample Nuxt App (Vue) to consume GraphQL API
Vue
2
star
30

TYpescript_TypeORM_TypeGraphQL

Full-Stack / Backend (TypeScript, GraphQL, TypeGraphQL)
TypeScript
2
star
31

nx-vite-infra

Building Vue 3 in Nx with Vite, adding AWS cdk infra
TypeScript
2
star
32

gtt_unit_test

this is a simple laravel unit test examples
PHP
2
star
33

InterSwitch-Laravel

interswitch web pay intergration with lareavel
PHP
1
star
34

PhxTestBed

This is a repo to test different packages implementations, including my own packages.
Elixir
1
star
35

laravel-devkit

This is a module based laravel development kit
PHP
1
star
36

next-tanstack-query

Demonstrate how to set up Tanstack React query with Next server side components
TypeScript
1
star
37

vue3-calendar-application

A sample Vue 3 app to create a calendar with reminders
Vue
1
star
38

chat-app

A simple chat App with mix app
Elixir
1
star
39

react-apollo-graphql

A simple React TS Appp to Consume GrapghQL APIs
TypeScript
1
star
40

raisely

A simple Registration in Nuxt.js
Vue
1
star
41

vue-pwa-firebase

a simple pwa in vue js and firebase connection
Vue
1
star
42

adonis-graphql-with-nexus

An Adonis sample App with graphql, nexus, apollo server
TypeScript
1
star
43

express-graphql-prisma-nexus-app

A sample Express app to demonstrate using Apollo GraphQL with Nexus and Prisma
TypeScript
1
star
44

tdd-in-vue

A simple app to test TDD in Vue
JavaScript
1
star
45

mpesa-b2c

a simple mpesa B2C implementation with Laravel
PHP
1
star
46

manuelgeek.github

My Personal website
1
star
47

Multiple-Image-Upload-and-Ajax-Cropper-Upload

Laravel 5.6 multiple image uploader and ajax image upload tutorial
PHP
1
star
48

Excel_to_Text

decode excel data and create a text file out of it
Python
1
star
49

Music

chordit website
Java
1
star
50

nuxt-tanstack-query

Demonstrate how to set up Tanstack Vue query with Nuxt server side components
Vue
1
star