tinymce-vue(CDNで)
問題
tinymce-vue、CDN環境だとどうやって使うの?
答え
こんな感じでWYSIWYGエディタが動きます。
HTML
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<title>tinymce-vue(CDNで)</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://cdn.jsdelivr.net/npm/vue@2.6.12"></script>
<script src="https://cdn.jsdelivr.net/npm/@tinymce/tinymce-vue@3.0.1/lib/browser/tinymce-vue.js"></script>
</head>
<body>
<div id="app" class="container">
<h1>tinymce-vue Demo</h1>
<p>tinymce-vue のデモです。</p>
<editor
:api-key="apikey"
:initial-value="initialValue"
:init="init"
></editor>
</div>
<script>
Vue.component('editor', Editor);
new Vue({
el: '#app',
data: {
apikey:'[あなたの API KEY]',
init: {
language: 'ja',
// language_url : '/path/to/ja.js', // 日本語化するとき
height: 500,
menubar: false,
table_toolbar: [
'tableprops tabledelete | tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol'
],
plugins: [
'print preview fullpage importcss searchreplace autolink \
autosave save directionality visualblocks visualchars fullscreen image link media template codesample \
table charmap hr pagebreak nonbreaking anchor toc insertdatetime advlist lists wordcount \
imagetools textpattern noneditable help charmap quickbars emoticons code'
],
toolbar:[
'undo redo | formatselect | bold italic backcolor | \
alignleft aligncenter alignright alignjustify | \
bullist numlist outdent indent | removeformat | help table code'
],
},
initialValue: "<p>This is the initial content of the editor</p>"
}
});
</script>
</body>
</html>
デモ
https://tech.softel.co.jp/blog/archives/demo/tinymce-vue-demo

APIキー
APIキーが必要なのでアカウントを作って取得しましょう。
言語ファイル
日本語化するときは、翻訳ファイルをこちらで取得。