1.0.11 • Published 4 years ago

mavon-editor-fa v1.0.11

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

mavonEditor-fa

npm

A markdown editor based on Vue

forked from mavonEditor

Example Pictures

PC

PC

PC

more images...

Use Setup

Install mavon-editor

$ npm install mavon-editor-fa --save

Use

index.js:

    // Global Registration
    // import with ES6
    import Vue from 'vue'
    import mavonEditor from 'mavon-editor-fa'
    import 'mavon-editor-fa/dist/css/index.css'

    // use
    Vue.use(mavonEditor)
    new Vue({
        'el': '#main',
        data() {
            return { value: '' }
        }
    })

index.html

// The same below
<div id="main">
    <mavon-editor-fa v-model="value"/>
</div>

Use in nuxt.js

new file: vue-mavon-editor.js

import Vue from 'vue';
import mavonEditorFa from 'mavon-editor-fa';
import 'mavon-editor-fa/dist/css/index.css';

Vue.use(mavonEditorFa);

> nuxt.config.js
``` javascript
  plugins: [
  ...
    { src: '@/plugins/vue-mavon-editor-fa', ssr: false }
  ],

page

<template>
  <div class="mavonEditor">
    <no-ssr>
      <mavon-editor-fa :toolbars="markdownOption" v-model="handbook"/>
    </no-ssr>
  </div>
</template>
<script>
export default {
  data() {
    return {
      markdownOption: {
        bold: true,
        ... // more params
      },
      handbook: "#### how to use mavonEditor in nuxt.js"
    };
  }
};
</script>
> [more ways...](./doc/en/use.md)

> [set markdown-it object...](./doc/en/markdown.md)

## API

### props

| name    | type    |  default value | describe  |
| -------- | :---------: | :------------: | ------- |
| value      | String      |               | Initial value |
| language   | String      |      zh-CN         | Language switch,  zh-CN: Simplified Chinese, zh-TW: Traditional Chinese, en: English, fr: French, pt-BR: Brazilian Portuguese, ru: Russian, de: German, ja: Japanese, fa: Persian |
| fontSize     | String  |     14px      | font-size of edit area  |
| scrollStyle| Boolean     |   true       | Open the scroll bar style(Temp only support chrome) |
| boxShadow     | Boolean  |     true     | css: box-shadow  of mavonEditor              |
| subfield   | Boolean     |   true        | true: Double columns - Edit preview same screen , Single Columns - otherwise not |
| defaultOpen | String |         | edit: default show edit area , preview: default show preview area  , other = edit |
| placeholder | String |    Begin editing...     |  The default prompt text when the textarea is empty  |
| editable | Boolean     |   true       | Edit switch |
| codeStyle | String |    code-github     | markdown Style: default github, [option hljs color scheme](./src/lib/core/hljs/lang.hljs.css.js)  |
| toolbarsFlag | Boolean     |   true       | Show toolbars |
| navigation | Boolean |    false    |  Show navigation  |
| shortCut | Boolean |    true    |  shortcut switch  |
| ishljs       | Boolean |     true     | highlight code switch |
| imageFilter | Function |     null     | Image file filter Function, params is a `File Object`, you should return `Boolean` about the test result |
| imageClick | function |     null     |  Image Click Function |
| tabSize | Number |     null     |  How many spaces equals one tab, default \t |
| toolbars   | Object      |   As in the following example  | toolbars |
| rtl   |  Boolean | false  | Right to left

```javascript
 /*
    The default toolbar properties are all true,
    You can customize the object to cover them.
    eg: {
         bold: true,
         italic: true,
         header: true,
    }
    At this point, the toolbar only displays the three function keys.
 */
toolbars: {
      bold: true,
      italic: true,
      header: true,
      underline: true,
      strikethrough: true,
      mark: true,
      superscript: true,
      subscript: true,
      quote: true,
      ol: true,
      ul: true,
      link: true,
      imagelink: true,
      code: true,
      table: true,
      fullscreen: true,
      readmodel: true,
      htmlcode: true,
      help: true,
      /* 1.3.5 */
      undo: true,
      redo: true,
      trash: true,
      save: true,
      /* 1.4.2 */
      navigation: true,
      /* 2.1.8 */
      alignleft: true,
      aligncenter: true,
      alignright: true,
      /* 2.2.1 */
      subfield: true,
      preview: true
  }

events

nameparamsdescribe
changeString: value , String: rederEdit area change callback event (render: Html source code)
saveString: value , String: rederCtrl+s and click save button
fullScreenBoolean: status , String: valueFullscreen editing toggle callback event(boolean: Fullscreen status)
readModelBoolean: status , String: valueReading mode toggle callback event(boolean: Reading mode status)
htmlCodeBoolean: status , String: valueHtml code mode toggle callback event(boolean: status)
subfieldToggleBoolean: status , String: valueDouble columns edit mode toggle callback event(boolean: double columns status)
previewToggleBoolean: status , String: valuePreview & Edit toggle callback event(boolean: preview status)
helpToggleBoolean: status , String: valueHelp-me toggle callback event(boolean: help status)
navigationToggleBoolean: status , String: valueNavigation mode toggle callback event(boolean: nav status)
imgAddString: filename, File: imgfileAdd image file callback event(filename: write in origin md, File: File Object)
imgDelString: filenameDelete image file callback event(filename: write in origin md)

Hightlight

If you do not need code highlighting, you need set ishljs to false

Set ishljs = true

    // default value is true
    <mavon-editor-fa :ishljs = "true"></mavon-editor-fa>

For optimize the size of pack, since v2.4.2, the following files will default to using cdnjs outside the chain:

  • highlight.js
  • github-markdown-css
  • katex(v2.4.7)

The language parsing files and code highlighting in Code Highlighting highlight.js will be loaded on demand. github-markdown-css andkatex will load only when mounted.

Notice: Option hljs color scheme and Supported language is export from highlight.js/9.12.0

without cdn, Click here to local on-demand loading...

Upload images

<template>
    <mavon-editor-fa ref=md @imgAdd="$imgAdd" @imgDel="$imgDel"></mavon-editor-fa>
</template>
<script>
export default {
    methods: {
        // bind @imgAdd event
        $imgAdd(pos, $file){
            // step 1. upload image to server.
           var formdata = new FormData();
           formdata.append('image', $file);
           axios({
               url: 'server url',
               method: 'post',
               data: formdata,
               headers: { 'Content-Type': 'multipart/form-data' },
           }).then((url) => {
               // step 2. replace url ![...](0) -> ![...](url)
               $vm.$img2Url(pos, url);
           })
        }
    }
}
</script>

more info about upload images ...

Note

  • Default size: min-height: 300px , min-width: 300px , Can be covered
  • z-index: 1500
  • Just for show html of md: toolbarsFlag: false , subfield: false, defaultOpen: "preview"

keyboard shortcuts

keykeycodefun
F8119toggle navigation
F9120toggle edit/preview
F10121toggle fullscreen
F11122toggle readModel
F12123toggle double columns / single column
TAB9\t
CTRL + S17 + 83@save
CTRL + D17 + 68remove selected lines
CTRL + Z17 + 90prev step
CTRL + Y17 + 89next step
CTRL + BreakSpace17 + 8trash
CTRL + B17 + 66Bold
CTRL + I17 + 73Italic
CTRL + H17 + 72# Header
CTRL + U17 + 85++Underline++
CTRL + M17 + 77==Mark==
CTRL + Q17 + 81> Quote
CTRL + O17 + 791. OL
CTRL + L17 + 76link
CTRL + ALT + S17 + 18 + 83^Superscript^
CTRL + ALT + U17 + 18 + 85- UL
CTRL + ALT + C17 + 18 + 67` Code
CTRL + ALT + L17 + 18 + 76Image Link
CTRL + ALT + T17 + 18 + 84Table
CTRL + SHIFT + S17 + 16 + 83~Subscript~
CTRL + SHIFT + D17 + 16 + 68Strikethrough
CTRL + SHIFT + C17 + 16 + 67align center
CTRL + SHIFT + L17 + 16 + 76align left
CTRL + SHIFT + R17 + 16 + 82align right
SHIFT + TAB16 + 9remove \t

Dependencies

Syntax extensions

Collaborators

Licence

mavonEditor-fa is open source and released under the MIT Licence.

Copyright (c) 2017 hinesboy

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago