Skip to content

Commit

Permalink
Wysiwygプラグイン中の URL関係などの変数をPHP側で構築した設定を使用する対応
Browse files Browse the repository at this point in the history
パスの指定がエラーになる場合があるので WysiwygHelper で定義した
nc3Configs 設定を利用する対応
  • Loading branch information
otokomae committed Mar 30, 2016
1 parent 4f339a1 commit b3ff881
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 12 deletions.
13 changes: 13 additions & 0 deletions View/Helper/WysiwygHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function wysiwygScript() {

// 言語情報
'lang' => Current::read('Language.code'),
'lang_js' => $this->NetCommonsHtml->url('/wysiwyg/js/langs/' . Current::read('Language.code') . '.js'),

// wysiwyg で利用するスタイルシート
'content_css' => [
Expand All @@ -52,6 +53,18 @@ public function wysiwygScript() {
// ファイル/画像プラグインアップロード時に必要なデータの用意
'blockKey' => Current::read('Block.key'),
'roomId' => Current::read('Room.id'),

// 独自ツールバーアイコン
'book_icon' => $this->NetCommonsHtml->url('/wysiwyg/img/title_icons/book.svg'),
'fileup_icon' => $this->NetCommonsHtml->url('/wysiwyg/img/title_icons/fileup.svg'),
'tex_icon' => $this->NetCommonsHtml->url('/wysiwyg/img/title_icons/tex.svg'),

// MathJax JSのリンク
'mathjax_js' => $this->NetCommonsHtml->url('/components/MathJax/MathJax.js?config=TeX-MML-AM_CHTML'),

// ファイル・画像アップロードパス
'file_upload_path' => $this->NetCommonsHtml->url('/wysiwyg/file/upload'),
'image_upload_path' => $this->NetCommonsHtml->url('/wysiwyg/image/upload'),
];

// constsnts 設定を JavaScriptで利用するための設定に変換する
Expand Down
6 changes: 3 additions & 3 deletions webroot/js/plugins/booksearch/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ tinymce.PluginManager.add('booksearch', function(editor, url) {
// エラー処理TODO
if (!id) { alert('データが見つかりません'); return false }
if (!currentInsertType) {
alert('画像の表示が選択されていません');
alert('リンク挿入方法が選択されていません');
return false;
}

Expand Down Expand Up @@ -137,7 +137,7 @@ tinymce.PluginManager.add('booksearch', function(editor, url) {
// "画像の表示"セレクトボックス設定
// TODO 多言語化
var insert_type_vals = [{
text: '---',
text: '選択してください',
value: ''
}, {
text: '詳細情報',
Expand Down Expand Up @@ -217,7 +217,7 @@ tinymce.PluginManager.add('booksearch', function(editor, url) {
// windowへのボタン登録
editor.addButton('booksearch', {
tooltip: 'Book search',
image: '/wysiwyg/img/title_icons/book.svg',
image: editor.settings.nc3Configs.book_icon,
// icon: 'newdocument',
onclick: showDialog
});
Expand Down
2 changes: 1 addition & 1 deletion webroot/js/plugins/file/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,6 @@ tinymce.PluginManager.add('file', function(editor, url) {
tooltip: 'Attach file',
id: 'file-btn',
onclick: showDialog,
image: '/wysiwyg/img/title_icons/fileup.svg'
image: editor.settings.nc3Configs.fileup_icon
});
});
4 changes: 1 addition & 3 deletions webroot/js/plugins/nc3_image/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ tinymce.PluginManager.add('nc3Image', function(editor, url) {
// セレクタなど
var vals = {
dispThumArea: 'image-thumb',
img_elm_class: 'nc3-img',
img_basepath: editor.settings.nc3Configs.baseUrl +
'/wysiwyg/image/download/'
img_elm_class: 'nc3-img'
};
var positionFormVals = [{
text: 'Select Position',
Expand Down
2 changes: 1 addition & 1 deletion webroot/js/plugins/nc3_preview/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ tinymce.PluginManager.add('nc3Preview', function(editor) {
'">';
// new add for Mathjax //////////////////////////////////
headHtml += '<script type="text/javascript" async ' +
'src="/components/MathJax/MathJax.js?config=TeX-MML-AM_CHTML"' +
'src="' + editor.settings.nc3Configs.mathjax_js + '"' +
'></script>';
/////////////////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion webroot/js/plugins/tex/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ tinymce.PluginManager.add('tex', function(editor, url) {
id: 'tex-btn',
stateSelector: '.' + vals.tex_elm_class,
onclick: showDialog,
image: '/wysiwyg/img/title_icons/tex.svg'
image: editor.settings.nc3Configs.tex_icon
});

// setWysiwygTextEvent();
Expand Down
2 changes: 1 addition & 1 deletion webroot/js/wysiwyg.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ NetCommonsApp.factory('NetCommonsWysiwyg', function(nc3Configs,

// 言語設定
language: nc3Configs.lang,
language_url: '/wysiwyg/js/langs/' + nc3Configs.lang + '.js'
language_url: nc3Configs.lang_js
};

/**
Expand Down
6 changes: 4 additions & 2 deletions webroot/js/wysiwyg_app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@ var NC3_APP = new (function nc3WysiwygApp() {
var __appURLs = (function() {
return {
uploadImage: function(roomId) {
return '/wysiwyg/image/upload/' + roomId;
return tinymce.editors[0].settings.nc3Configs.image_upload_path +
'/' + roomId;
},
uploadFile: function(roomId) {
return '/wysiwyg/file/upload/' + roomId;
return tinymce.editors[0].settings.nc3Configs.file_upload_path +
'/' + roomId;
},
searchBooks: function(q) {
return 'https://www.googleapis.com/books/v1/volumes?q=' + q;
Expand Down

0 comments on commit b3ff881

Please sign in to comment.