diff --git a/View/Elements/wysiwyg_js.ctp b/View/Elements/wysiwyg_js.ctp index 9cd7249..9b8040f 100644 --- a/View/Elements/wysiwyg_js.ctp +++ b/View/Elements/wysiwyg_js.ctp @@ -20,5 +20,6 @@ echo $this->NetCommonsHtml->script( '/wysiwyg/js/plugins/file/plugin.js', '/wysiwyg/js/plugins/nc3_image/plugin.js', '/wysiwyg/js/plugins/nc3_preview/plugin.js', + '/wysiwyg/js/plugins/titleicons/plugin.js', ) ); diff --git a/View/Helper/WysiwygHelper.php b/View/Helper/WysiwygHelper.php index 9a11417..8606482 100644 --- a/View/Helper/WysiwygHelper.php +++ b/View/Helper/WysiwygHelper.php @@ -24,6 +24,8 @@ class WysiwygHelper extends AppHelper { * @var array */ public $helpers = array( + 'NetCommons.NetCommonsHtml', + 'NetCommons.TitleIcon', ); /** @@ -32,6 +34,34 @@ class WysiwygHelper extends AppHelper { * @return String wysiwyg js */ public function wysiwygScript() { + // NetCommonsApp.constant で定義する変数の定義 + $constants = []; + + // タイトルアイコン用のファイルリスト + $constants['title_icon_paths'] = $this->__getTitleIconFiles(); + + $this->NetCommonsHtml->scriptStart(array('inline' => false)); + echo "NetCommonsApp.service('nc3Configs', function() {"; + foreach ($constants as $key => $value) { + if (is_array($value)) { + echo 'this.' . $key . ' = ' . json_encode($value) . ';'; + } else { + echo "this." . $key . " = '" . $value . "';"; + } + } + echo "});"; + $this->NetCommonsHtml->scriptEnd(); + return $this->_View->element('Wysiwyg.wysiwyg_js'); } + +/** + * TitleIconFilesを取得して加工する + * + * @return Array + */ + private function __getTitleIconFiles() { + $files = json_decode($this->TitleIcon->getIconFiles()); + return array_chunk($files, 8); + } } diff --git a/webroot/js/plugins/titleicons/plugin.js b/webroot/js/plugins/titleicons/plugin.js new file mode 100644 index 0000000..39b087f --- /dev/null +++ b/webroot/js/plugins/titleicons/plugin.js @@ -0,0 +1,66 @@ +/** + * plugin.js + * + * Released under LGPL License. + * Copyright (c) 1999-2015 Ephox Corp. All rights reserved + * + * License: http://www.tinymce.com/license + * Contributing: http://www.tinymce.com/contributing + */ + +/*global tinymce:true */ + +tinymce.PluginManager.add('titleicons', function(editor, url) { + var titleicons = editor.settings.nc3Configs.title_icon_paths; + + function getHtml() { + var titleiconsHtml; + + titleiconsHtml = '
' + + ' | '; + }); + + titleiconsHtml += '