[EXTENSION] TinyMCE using jQuery

Well, after a loooooong time (so sorry for the delay), a new release of my TinyMCE-based extension, this time including TinyMCE 3.4.3.2. It also fixes a silly bug.

need to change folder assets permission to 755

http://www.yiiframework.com/forum/index.php?/topic/20358-php-scripts-in-assets/

i got the same problem as the topic above.

tinymce doesn’t work if folder assets/xxxxx/tinymce is not set to 755 permission

or perhaps I’m missing something…

got this error "r is undefined" and textare getting blur

when you add script to add custom button like this…


 

'theme_advanced_buttons1' => "undo,redo,|,cut,copy,paste,pastetext,pasteword,|,bold,italic,underline,strikethrough,|,sub,sup,|,justifyleft,justifycenter,justifyright,justifyfull,|,outdent,indent,blockquote,|,image,cleanup,|, preview,",

                'theme_advanced_buttons2' => "mymenubutton,styleselect,formatselect,fontselect,fontsizeselect,|,charmap,bullist,numlist,|,forecolor,backcolor,emotions, ",

                'theme_advanced_buttons3' => "",

                'theme_advanced_toolbar_location' => "top",

                'theme_advanced_toolbar_align' => "left",

                'setup'=> 'function(ed){

                           ed.addButton("mybutton", {

                               title : "My button",

                               image : "img/example.gif",

                               onclick : function() {

                                     // Add you own code to execute something on click

                                     ed.focus();

                                     ed.selection.setContent("<strong>Hello world!</strong>");

                                }

                            });

                        }'



i was trying to add my own button, those i ve wrote was from other forum tutorial about putting additional button.

the previous EtinyMCE was havind problem with eval. and the new one just those error no other clue.

Hi guys!

I followed the example on http://www.yiiframework.com/extension/tinymce/ but I got the following error when switching to Text mode.

$("#html").toggleModeTinyMCE is not a function

I searched through the source code and I couldn’t find such a function defined anywhere.

Do you know what this problem is?

Thanks.

Hello,

how to turn on advanced mode?

I write this code:

<?php

/**

  • SiteController is the default controller to handle user requests.

*/

class SiteController extends CController

{

/**


 * Index action is the default action in a controller.


 */


public function actionIndex()


{


	echo '&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;&lt;div&gt;abc';


	&#036;this-&gt;widget('application.extensions.tinymce.ETinyMce', array(


		'name'=&gt;'htmlxz',


		'editorTemplate'=&gt;'full',


		'mode'=&gt; 'html', 


		'plugins' =&gt; array('safari','pagebreak','style','layer','table','save','advhr','advimage','advlink','emotions','iespell','inlinepopups','insertdatetime','preview','media','searchreplace','print','contextmenu','paste','directionality','fullscreen','noneditable','visualchars','nonbreaking','xhtmlxtras','template'),


		'value'=&gt;'default value',


		'options' =&gt; array(


                    'theme' =&gt; 'advanced',


                    'skin' =&gt; 'o2k7',


                    'theme_advanced_buttons1' =&gt; 'preview,bold,italic,underline,fontselect,fontsizeselect,link,justifyfull,justifyleft,justifycenter,justifyright,pasteword,pastetext,table,image,|,bullist,numlist,|,undo,redo,|,code,fullscreen',


                    'theme_advanced_buttons2' =&gt; '',


                    'theme_advanced_buttons3' =&gt; '',


                ),));


	echo &quot;zxc&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;&quot;;


}

}

?>

but shows simple textarea.

Please help me to integrate this extension.

Thanks.

Hi all,

I have a question with extension that is when I google to add an on key press event to my textarea in TinyMce, it show me like this (google result):




tinyMCE.init({

   ...

   setup : function(ed) {

      ed.onKeyPress.add(function(ed, e) {

          console.debug('Key press event: ' + e.keyCode);

      });

   }

});



When I use in view, my code like this:




$this->widget('application.extension.tinymce.ETinyMce', array(

   'name' => 'box',

   .....           // theme advanced options

   'setup' => 'function(ed){

        ed.onKeyPress.add(function(ed, e){

            $("div#mydiv").html("<p>On Key Press Event </p>");

        })

   }'

))



Is there somethings wrong in my code, I want to when people press key in the text area, it will trigger a predefined function.

Any idea for this topic :D, thanks ;D ;D

regards

Dear all,

Does every one can modify TinyMce in Yii extension?

I would like to add my event in key press event, so, if I add a new ‘setup’ options in ETinyMce.php like this:




$options['setup'] = 'function (ed){

                      ed.onKeyPress.add(

                        function(ed, e){

                          alert(1)

                        })

                      }';



not thing happen and a error "r is undefined",

any idea, thanks

i ve found it, i dont know how to make it beutiful, i just hack it that way,

hopefully hte creator of this extention read this and find better way to do it,

toogleModeTinyMCE are no longger exist, but in the EtinyMCE.php there is still these link,

and snip to tinyMCE example and do little change on EtinyMCE.php




//these code wrote in the end of the file , make it some thing like this

$label = $this->switchLabels[($this->mode=='html'?0:1)];

         $css = ($this->labelClass !== '') ? array('class'=>$this->labelClass) : array('style'=>$this->labelStyle);

         $switchOptions = array_merge(array('id'=>$id.self::SWITCH_SUFFIX,

             'onclick'=>"tinymce.execCommand('mceToggleEditor',false,'$id')"), $css);

         //$uri = rawurlencode('$("#'.$id.'").toggleModeTinyMCE('.$jsToggleLabels.')');

         $uri=";"; 

         $link = CHtml::link($label, 'javascript:'.$uri, $switchOptions);

         $switch = CHtml::tag('div', array(), CHtml::tag('span', array(), $link));

         $html = CHtml::tag('div', array(), $textarea.$switch);




to support the $id variable, you need to pass it on the widget wrote becamoe somethin glike this




 <?php $this->widget('application.extensions.tinymce.ETinyMce',

                            array(  'name'=>'NotesModel[note_desc]',

                                    'id'=>'NotesModel_note_desc',  //see right here, the toggle mode need this textatrea id

                                    'value' => $model->note_desc,

                                    'options'=> array(  'mode' =>"textareas",

                                                        'theme' => 'advanced',

                                                        'height' => '500',                                                

                                                                  



hope fully it jhelp, and dear extention writer may this give aclue,

regard…

to integrate it in an active form:




		<?php echo $form->labelEx($model,'attribute_name'); ?>

		<?php $this->widget('application.extensions.tinymce.ETinyMce', array(

		 'model'     =>  $model,

		 'attribute' => 'attribute_name',

		 'height'    =>  '200px',

		 'width'     =>  '100%',

		)); ?>



I’ve been publishing a 99% finished app from in-house servers (MAMP on OS X and XAMPP on OS X) to a new shared web hosting account. This is my first experience with shared hosting. Always before I’ve had dedicated servers, either physical or virtual.

Here’s my last issue that I can’t seem to figure out on my own. I’m using TinyMce for a couple of form fields in a couple of content types. On the Mac servers, it works great. On the Arvixe shared hosting account, no go. I don’t get an error message. Firebug shows that it’s just not there except for the little button on the bottom that says Text Mode.

I’m imagining this has nothing to do with TinyMce itself, but is something different in regards to the shared hosting?

Any ideas?

Alex

Hi Alex, I really think it’s a matter of the browser, but: which OS is Arvixe using? are the tinymce’s javascript files accessible from the web?

You saved my Day … It got into my attention when my client just told me if he can’t change the mode to text mode, I just can’t figured out by myself because it’s my first time use TinyMCE …

Currently we don’t need to write id explicitly … here the simple mode …




 <?php $this->widget('application.extensions.tinymce.ETinyMce',

                            array(  'model'=>$model,

                                    'attribute'=>'note_desc', 

                                    'options'=> array(  'mode' =>"textareas",

                                                        'theme' => 'advanced',

                                                        'height' => '500',                                                

                                                                  



hi,

you could use the standard way to remove that




<?php $this->widget('application.extensions.tinymce.ETinyMce', 

            array(

                'name'=>'editor', 

                'useSwitch'=>false

                )); ?>



‘useSwitch’=>false will skip the deprecated code

defined in ETinyMCE.php




/**

    * Wheter to use the HTML->plain text mode switch.

    *

    * Note: if useSwitch==true then the editor will be inside a <div> tag. Else

    * it will be a normal <textarea> tag. Take this in account when designing

    * your form.

    *

    * @var boolean

    */

   private $useSwitch = true;



_

adis

TinyMCE allows to set auto_focus to that element when page is loaded. I believe this is not supported in ETinyMCE, is it?

hi, i am using tinymce extension, it’s work well in my local, but when i deploy code to my host,I got error when js call any php file in assets folder. I changed all php file to 755, but still can not run these file.

Does anyone know about the problem, what the config (may be htaccess ) ,and how to enable execute php file in assets folder.

Thank !

Try to turn off compression using ‘useCompression’=>false like:




$this->widget('application.modules.content.extensions.tinymce.ETinyMce', array(

				'name'=>'Post[content]',

				'id'=>'Post_content',

				'width'=>'560px',

				'contentCSS'=>$this->module->cssAssetUrl . '/tinyContent.css',

				'value'=>$model->content,

				'plugins'=>array('preview, spellchecker'),

                'useSwitch'=>false,

                'useCompression'=>false,

				'options'=>array(

					'theme'=>'advanced',

					'skin'=>'o2k7',

					'theme_advanced_toolbar_location'=>'top',

				)

			));



The idea is that if your server already compresses the data, this extension tries to compress again and the browser does not understand it. I had the same problem. Also make sure your .php file exists in that asset directory you are trying to call.

hi, thank you for your reply.

I changed “‘useCompression’=>false” ,and it worked well, but because i was using imagemanager tinymce plugin( the plugin have some php files in asset folder ), so i got the problem with them.

I checked and saw these php file in asset folder, but dont know why can not access them.

I was using same code in my pc (window/xampp), and it’s work well,but i got the problem in my host (linux).

If i use this stright out of the box, the textarea is hidden…?

using <?php $this->widget(‘application.extensions.tinymce.ETinyMce’, array(‘name’=>‘html’)); ?>

Same if I change html to the correct value

Am i missing something? chrome and firefox tested so far…

All i see is a DIV with ‘Text Mode’ in it.

I have got the same problem, someone know to fix it?

EDIT: This tinymce extension works for me: http://www.yiiframework.com/extension/krichtexteditor

Instead of using


'name'=>'Post[content]',

				'id'=>'Post_content',

You should use:




'model'=>$model,

'attribute'=>'content'