diff --git a/README.md b/README.md index d0cfe629..b0c55e66 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@

Markdown Editor built on Vue

+

This is a fork of the original project

+

Downloads @@ -6,12 +8,70 @@ License

+## What this fork adds + +This fork adds the possibility to use any custom component as a toolbar button. For example, we can obtain a customized toolbar like the one below: + +![image](https://user-images.githubusercontent.com/4061104/144724202-d9b679f1-78b4-4b25-82f0-ff70efa7da4a.png) + + +by using a `toolbar` config like this: + +```js +const customToolbar = { + myButton: { + title: 'Options', + slot: true, // this tells the editor to render the button using our custom template + preventNativeClick: false, // this allows elements like a select to work correctly + }, + my2ndButton: { + title: 'Settings', + slot: true, + action() { // you can still define the onClick action via the usual function + console.log('opening the settings..'); + }, + }, +}; +``` + +Then we can provide custom templates for `myButton` and `my2ndButton`, like this: + +```js + + + + +``` + + ## Links - [Demo](https://code-farmer-i.github.io/vue-markdown-editor/examples/base-editor.html) - [Documentation](https://code-farmer-i.github.io/vue-markdown-editor/) -- [中文文档](https://code-farmer-i.github.io/vue-markdown-editor/zh/) -- [国内文档镜像](http://ckang_1229.gitee.io/vue-markdown-editor/zh/) +- [中文文档](http://ckang1229.gitee.io/vue-markdown-editor/zh/) - [Changelog](https://code-farmer-i.github.io/vue-markdown-editor/changelog.html) ## Communication @@ -21,11 +81,15 @@ qq group: 798884474 ## Install ```bash -# use npm +# Vue 2 use npm npm i @kangc/v-md-editor -S - -# use yarn +# Vue 2 use yarn yarn add @kangc/v-md-editor + +# Vue 3 use npm +npm i @kangc/v-md-editor@next -S +# Vue 3 use yarn +yarn add @kangc/v-md-editor@next ``` ## Quick Start @@ -37,11 +101,41 @@ import '@kangc/v-md-editor/lib/style/base-editor.css'; import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js'; import '@kangc/v-md-editor/lib/theme/style/vuepress.css'; -VueMarkdownEditor.use(vuepressTheme); +// Prism +import Prism from 'prismjs'; +// highlight code +import 'prismjs/components/prism-json'; + +VueMarkdownEditor.use(vuepressTheme, { + Prism, +}); Vue.use(VueMarkdownEditor); ``` +## Quick Start In Vue3 + +```js +import { createApp } from 'vue'; +import VMdEditor from '@kangc/v-md-editor'; +import '@kangc/v-md-editor/lib/style/base-editor.css'; +import vuepressTheme from '@kangc/v-md-editor/lib/theme/vuepress.js'; +import '@kangc/v-md-editor/lib/theme/style/vuepress.css'; + +// Prism +import Prism from 'prismjs'; +// highlight code +import 'prismjs/components/prism-json'; + +VMdEditor.use(vuepressTheme, { + Prism, +}); + +const app = createApp(/*...*/); + +app.use(VMdEditor); +``` + ## Usage ```html @@ -60,6 +154,42 @@ Vue.use(VueMarkdownEditor); ``` +## Usage Composition Api + +```html + + + +``` + +## Sponsor + +Paypal + +[PayPal.Me](https://paypal.me/codefarmeri?locale.x=zh_XC) + +Alipay 支付宝 + + + +WeChat Pay 微信 + + + ## Refrence - [ElementUi Utils clickoutside](https://github.com/ElemeFE/element/blob/dev/src/utils/clickoutside.js) diff --git a/dev/App.vue b/dev/App.vue index 6f7ba2bb..73c2aab1 100644 --- a/dev/App.vue +++ b/dev/App.vue @@ -11,7 +11,31 @@ @save="handleSave" @copy-code-success="handleCopyCodeSuccess" ref="editor" - /> + :toolbar="customToolbar" + left-toolbar="undo redo | myButton my2ndButton" + > + + + +