Toast UI Editor Vueラッパーは、Toast UIエディターリポジトリとは別に管理されています。これらの問題の配布の結果、各ラッパーリポジトリを廃止し、トーストUIエディターリポジトリのモノレポとしてリポジトリを管理することにしました。
これからは、トーストUI Reactラッパーに関連する問題または貢献をToast UI Editorリポジトリに送信してください。ありがとう?。
これは、トーストUIエディターをラッピングするVUEコンポーネントです。
Toast UI EditorのVueラッパーは、Google Analytics(GA)を適用して、世界中でUIエディターがどの程度広く使用されているかを特定するために、オープンソースの使用に関する統計を収集します。また、プロジェクトの将来のコースを決定するための重要なインデックスとしても機能します。 location.hostname(eg>“ ui.toast.com ")は収集され、唯一の目的は使用に関する統計を測定するだけです。 GAを無効にするには、VUEラッパーコンポーントを宣言するときに、次のusageStatisticsオプションを使用します。
var options = {
...
usageStatistics : false
}または、 tui-code-snippet.js ( v1.4.0以降)を含めてから、すぐに次のようにオプションを書き込みます。
tui . usageStatistics = false ; npm install --save @toast-ui/vue-editorVueのToast UIエディターをMoudule形式または名前空間として使用できます。また、シングルファイルコンポーネント(VUEのSFC)を使用できます。モジュール形式とSFCを使用する場合、スクリプトにtui-editor.css 、 tui-editor-contents.css 、 codemirror.cssロードする必要があります。
ECMAScriptモジュールの使用
import 'tui-editor/dist/tui-editor.css' ;
import 'tui-editor/dist/tui-editor-contents.css' ;
import 'codemirror/lib/codemirror.css' ;
import { Editor } from '@toast-ui/vue-editor'CommonJSモジュールを使用します
require ( 'tui-editor/dist/tui-editor.css' ) ;
require ( 'tui-editor/dist/tui-editor-contents.css' ) ;
require ( 'codemirror/lib/codemirror.css' ) ;
var toastui = require ( '@toast-ui/vue-editor' ) ;
var Editor = toastui . Editor ;単一のファイルコンポーネントを使用します
import 'tui-editor/dist/tui-editor.css' ;
import 'tui-editor/dist/tui-editor-contents.css' ;
import 'codemirror/lib/codemirror.css' ;
import Editor from '@toast-ui/vue-editor/src/Editor.vue'名前空間を使用します
var Editor = toastui . Editor ;最初にテンプレートに<editor/>を実装します。
< template >
< editor />
</ template >次に、このようなコンポーネントまたはVUEインスタンスのcomponentsにEditorを追加します。
import { Editor } from '@toast-ui/vue-editor'
export default {
components : {
'editor' : Editor
}
}または
import { Editor } from '@toast-ui/vue-editor'
new Vue ( {
el : '#app' ,
components : {
'editor' : Editor
}
} ) ;V-Modelを使用する場合、バインディングのdataを宣言する必要があります。 (amyty wysiwygモードでエディターを使用する場合、 v-modelパフォーマンスの劣化を引き起こす可能性があります。)
以下の例では、 editorTextはエディターのテキストに拘束されています。
< template >
< editor v-model =" editorText " />
</ template >
< script >
import { Editor } from '@toast-ui/vue-editor'
export default {
components : {
'editor' : Editor
} ,
data ( ) {
return {
editorText : ''
}
}
}
</ script >| 名前 | タイプ | デフォルト | 説明 |
|---|---|---|---|
| 価値 | 弦 | '' | この小道具は、編集者のコンテンツを変更できます。 v-modelを使用している場合は、使用しないでください。 |
| オプション | 物体 | 次のdefaultOptions | tui.editorのオプション。これは、tui.editorを開始するためです。 |
| 身長 | 弦 | 「300px」 | この小道具は、編集者の高さを制御できます。 |
| プレビュースタイル | 弦 | 'タブ' | この小道具は、編集者のプレビュースタイルを変更できます。 ( tabまたはvertical ) |
| モード | 弦 | 「マークダウン」 | この小道具は、エディターのモードを変更できます。 ( markdownまたはwysiwyg ) |
| HTML | 弦 | - | HTML形式を使用してエディターのコンテンツを変更する場合は、この小道具を使用してください。 |
| 見える | ブール | 真実 | この小道具は、エイディターの見える制御できます。 |
const defaultOptions = {
minHeight : '200px' ,
language : 'en_US' ,
useCommandShortcut : true ,
useDefaultHTMLSanitizer : true ,
usageStatistics : true ,
hideModeSwitch : false ,
toolbarItems : [
'heading' ,
'bold' ,
'italic' ,
'strike' ,
'divider' ,
'hr' ,
'quote' ,
'divider' ,
'ul' ,
'ol' ,
'task' ,
'indent' ,
'outdent' ,
'divider' ,
'table' ,
'image' ,
'link' ,
'divider' ,
'code' ,
'codeblock'
]
} ;例 :
< template >
< editor
:value =" editorText "
:options =" editorOptions "
:html =" editorHtml "
:visible =" editorVisible "
previewStyle =" vertical "
height =" 500px "
mode =" wysiwyg "
/>
</ template >
< script >
import { Editor } from '@toast-ui/vue-editor'
export default {
components : {
'editor' : Editor
} ,
data ( ) {
return {
editorText : 'This is initialValue.' ,
editorOptions : {
hideModeSwitch : true
} ,
editorHtml : '' ,
editorVisible : true
} ;
} ,
} ;
</ script >例 :
< template >
< editor
@load =" onEditorLoad "
@focus =" onEditorFocus "
@blur =" onEditorBlur "
@change =" onEditorChange "
@stateChange =" onEditorStateChange "
/>
</ template >
< script >
import { Editor } from '@toast-ui/vue-editor'
export default {
components : {
'editor' : Editor
} ,
methods : {
onEditorLoad ( ) {
// implement your code
} ,
onEditorFocus ( ) {
// implement your code
} ,
onEditorBlur ( ) {
// implement your code
} ,
onEditorChange ( ) {
// implement your code
} ,
onEditorStateChange ( ) {
// implement your code
} ,
}
} ;
</ script >編集者をもっと操作する場合は、 invokeメソッドを使用してtui.editorのメソッドを呼び出すことができます。メソッドの詳細については、tui.editorの方法を参照してください。
まず、 <editor/>のref属性を割り当てる必要がありますthis.$refsを使用してinvokeメソッドを使用できます。
< template >
< editor ref =" tuiEditor " />
</ template >
< script >
import { Editor } from '@toast-ui/vue-editor'
export default {
components : {
'editor' : Editor
} ,
methods : {
scroll ( ) {
this . $refs . tuiEditor . invoke ( 'scrollTop' , 10 ) ;
} ,
moveTop ( ) {
this . $refs . tuiEditor . invoke ( 'moveCursorToStart' ) ;
} ,
getHtml ( ) {
let html = this . $refs . tuiEditor . invoke ( 'getHtml' ) ;
}
}
} ;
</ script > ECMAScriptモジュールの使用
import 'tui-editor/dist/tui-editor-contents.css' ;
import 'highlight.js/styles/github.css' ;
import { Viewer } from '@toast-ui/vue-editor'CommonJSモジュールを使用します
require ( 'tui-editor/dist/tui-editor-contents.css' ) ;
require ( 'highlight.js/styles/github.css' ) ;
var toastui = require ( '@toast-ui/vue-editor' ) ;
var Viewer = toastui . Viewer ;単一のファイルコンポーネントを使用します
import 'tui-editor/dist/tui-editor-contents.css' ;
import 'highlight.js/styles/github.css' ;
import Viewer from '@toast-ui/vue-editor/src/Viewer.vue'名前空間を使用します
var Viewer = toastui . Viewer ;最初にテンプレートに<viewer/>を実装します。
< template >
< viewer />
</ template >次に、コンポーネントのコンポーネントまたはこのようなVueインスタンスのcomponentsにViewerを追加します。
import { Viewer } from '@toast-ui/vue-editor'
export default {
components : {
'viewer' : Viewer
}
}または
import { Viewer } from '@toast-ui/vue-editor'
new Vue ( {
el : '#app' ,
components : {
'viewer' : Viewer
}
} ) ;| 名前 | タイプ | デフォルト | 説明 |
|---|---|---|---|
| 価値 | 弦 | '' | この小道具は、視聴者のコンテンツを変更できます。 |
| 身長 | 弦 | 「300px」 | この小道具は、視聴者の高さを制御できます。 |
| exts | 配列 | この小道具は、視聴者の拡張機能を適用できます。 |
例 :
< template >
< viewer
:value =" viewerText "
height =" 500px "
/>
</ template >
< script >
import { Viewer } from '@toast-ui/vue-editor'
export default {
components : {
'viewer' : Viewer
} ,
data ( ) {
return {
viewerText : '# This is Viewer.n Hello World.' ,
} ;
} ,
} ;
</ script >例 :
< template >
< viewer
@load =" onEditorLoad "
@focus =" onEditorFocus "
@blur =" onEditorBlur "
@change =" onEditorChange "
@stateChange =" onEditorStateChange "
/>
</ template >
< script >
import { Viewer } from '@toast-ui/vue-editor'
export default {
components: {
'viewer': Viewer
},
methods: {
onEditorLoad() {
// implement your code
},
onEditorFocus() {
// implement your code
},
onEditorBlur() {
// implement your code
},
onEditorChange() {
// implement your code
},
onEditorStateChange() {
// implement your code
},
}
};トーストUI製品はオープンソースであるため、問題を修正した後、プルリクエスト(PR)を作成できます。 NPMスクリプトを実行し、次のプロセスで自分自身を開発します。
フォークは、あなたの個人リポジトリへのブランチdevelop 。それをローカルコンピューターにクローンします。ノードモジュールをインストールします。開発を開始する前に、Haveanyエラーを確認する必要があります。
$ git clone https://github.com/{your-personal-repo}/[[repo name]].git
$ cd [[repo name]]
$ npm install開発を始めましょう!
PRの前に、最後にテストするために確認し、エラーを確認してください。エラーがない場合は、コミットしてからプッシュしてください!
PRのステップの詳細については、貢献セクションのリンクを参照してください。
このソフトウェアは、MIT©NHNの下でライセンスされています。