vue editor js
Can change holder ID
Vue-Editor-JSはEditorJSラッパーコンポーネントです。
これを最初に確認してください。 https://editorjs.io/
このプラグインは、editorJSのラッパーコンポーネントです。 editor.jsにプラグインを使用する必要がある場合は、インポートして構成プロパティを設定します。
demo.vueをご覧ください
Vue.use vue-editor-jsをmain.jsで使用してください。
# NPM
npm install --save vue-editor-js
# or Yarn
yarn add vue-editor-js // ...
import Editor from 'vue-editor-js'
Vue . use ( Editor )
// ... // in nuxt.config.js
plugins: [
{
src : '~/plugins/vue-editor.js' , ssr : false
}
] ,
// in ~/plugins/vue-editor.js
import Vue from 'vue'
import Editor from 'vue-editor-js'
Vue . use ( Editor ) < editor ref="editor" : config = " config " : initialized = " onInitialized " />初期化のインスタンスを取得するための初期化関数を定義します。初期化時に
Nuxtで使用することと混同している場合は、こちらをご覧ください
単一のコンポーネントにエディターをインポートする場合は、以下の手順に従ってください。
@vue/composition-apiをインストールしてください # NPM
npm i --save @vue/composition-api
# or Yarn
yarn add @vue/composition-api import Vue from 'vue'
import VueCompositionApi from '@vue/composition-api'
Vue . use ( VueCompositionApi )'vue-editor-js'から何もインポートしないでください import { Editor } from 'vue-editor-js'
export default {
// ...
components : {
Editor ,
} ,
// ...
} サポートされているプラグインと同じですが、命名が異なります
# NPM
npm install --save @editorjs/header
# or Yarn
yarn add @editorjs/header< editor
...
: config = " {
tools: {
header: require ( ' @editorjs/header ' )
}
} "
/>< template >
< div id = " app " >
< Editor ref = " editor " :config = " config " />
< button @click = " invokeSave " >Save</ button >
</ div >
</ template >
< script >
export default {
methods : {
invokeSave () {
this . $refs . editor . _data . state . editor . save ()
. then (( data ) => {
// Do what you want with the data here
console . log (data)
})
. catch ( err => { console . log (err) })
}
},
}
</ script >画像をアップロードするには、画像を処理するためのバックエンドが必要です。 Vue-Editor-JSは、可用性のための特別なconfigプロップを提供します。サーバーをテストして画像をアップロードする場合は、サーバーの例を参照してください。
< editor : config = " config " />
< script >
...
data () {
return {
config : {
image : {
// Like in https://github.com/editor-js/image#config-params
endpoints : {
byFile : ' http://localhost:8090/image ' ,
byUrl : ' http://localhost:8090/image-by-url ' ,
},
field : ' image ' ,
types : ' image/* ' ,
},
}
}
}
</ script > config: {
personality: {
endpoints: 'http://localhost:8090/image'
} 
vue.jsプロジェクトでeditorjsをお楽しみください。
または
このリポジトリの貢献者は、wallaby.js ossライセンスを使用して、入力するときにすぐにテスト結果を取得し、コードのすぐ隣のエディターに結果を確認できます。