Giter VIP home page Giter VIP logo

yii2-tinymce-widget's Introduction

TinyMCE Widget for Yii2

Latest Version Software License Build Status Coverage Status Quality Score Total Downloads

Renders a TinyMCE WYSIWYG text editor plugin widget.

Installation

The preferred way to install this extension is through composer.

Either run

composer require 2amigos/yii2-tinymce-widget:~1.1

or add

"2amigos/yii2-tinymce-widget" : "~1.1"

to the require section of your application's composer.json file.

Usage


use dosamigos\tinymce\TinyMce;

<?= $form->field($model, 'text')->widget(TinyMce::className(), [
    'options' => ['rows' => 6],
    'language' => 'es',
    'clientOptions' => [
        'plugins' => [
            "advlist autolink lists link charmap print preview anchor",
            "searchreplace visualblocks code fullscreen",
            "insertdatetime media table contextmenu paste"
        ],
        'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
    ]
]);?>

About ClientOptions

Please, remember that if you are required to add javascript to the configuration of the js plugin and is required to be plain JS, make use of JsExpression. That class was made by Yii for that specific purpose. For example:

// Having the following scenario
<script> 
    function jsFunctionToBeCalled() {
        // ...
    }
</script>

<?= $form->field($model, 'content')->widget(TinyMce::className(), [
    'options' => ['rows' => 16],
    'language' => 'en_GB',
    'clientOptions' => 
        // ...
        // this will render the function name without quotes on the configuration options of the plugin
        'file_picker_callback' => new JsExpression('jsFunctionToBeCalled'),
        // ...
    ]
]); ?>

Testing

$ phpunit

Further Information

Please, check the TinyMCE plugin site documentation for further information about its configuration options.

Contributing

Please see CONTRIBUTING for details.

Credits

License

The BSD License (BSD). Please see License File for more information.

2amigOS!
Web development has never been so fun!
www.2amigos.us

yii2-tinymce-widget's People

Contributors

astronin avatar beaten-sect0r avatar creocoder avatar denisdangerous avatar eseperio avatar tonydspaniard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-tinymce-widget's Issues

how integer with image upload?

I follow the documents and here http://pixabay.com/zh/blog/posts/direct-image-uploads-in-tinymce-4-42/

    <?= $form->field($model, 'content')->widget(TinyMce::className(), [
        'options' => ['rows' => 6],
        'language' => 'zh_CN',
        'clientOptions' => [
            'plugins' => [
                "advlist autolink lists link charmap print preview anchor",
                "searchreplace visualblocks code fullscreen",
                "insertdatetime media table contextmenu paste image"
            ],
            'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify |  bullist numlist outdent indent | link image",
        'file_browser_callback'=>"function(field_name, url, type, win) {
            if(type=='image') $('#my_form input').click();
        }",
        ]
    ]);?>
    <iframe id="form_target" name="form_target" style="display:none">
    <form id="my_form" action="/upload/" target="form_target" method="post" enctype="multipart/form-data"          style="width:0px;height:0;overflow:hidden">
        <input name="image" type="file" onchange="$('#my_form').submit();this.value='';">
    </form>
    </iframe>

but not work,errors occurs when I click the upload button:

Uncaught TypeError: string is not a function

Updating jumps major versions

In the composor.json file, the dependency for TinyMCE is defined as '>4'.
This results in TinyMCE jumping from version 4.* to 5.* without any way block this because this package doesn't define a major version update to handle this.

My suggestion would be to release a 1.1.4 that locks TinyMCE down to version 4 and release a 2.0 version which installs version 5. This way your users can choose themselves which versions works for them and can update their systems before loading TinyMCE 5, which contains breaking changes.

Not saving data in single click

Hi ,
Greetings!

I am using this editor in my web app. When i click submit button first time to submit form, text editor field says 'Description can not be blank'. Even it has already filled value. When i click submit button. It save the value.

In short, Text editor shows error for first submission.
Please help me.

Thanks
Hari

Suggestion for reinit tinymce

when you combine tabular form and widget tinymce like this
<attribute> => [ 'type' => TabularForm::INPUT_WIDGET, 'widgetClass'=>\dosamigos\tinymce\TinyMce::classname(), ],

the old tinymce will not appear when you click add, so I suggest to add this code to reinit the tinymce
$js[] = "tinymce.EditorManager.execCommand('mceRemoveEditor',true, '$id');";

in dosamigos\tinymce\TinyMce

right above the
$js[] = "tinymce.init($options);";

thank you

how can i add rtl and ltr to toolbar

I can add 'directionality' => 'rtl' to clientOptions for support rtl languages
but dont show btn rtl and ltr on toolbar
whene i add rtl ltr to toolbar config dont show buttons in toolbar

Problem while using bootstrap

I use bootstrap in my yii2 application. When I use yii2-tinymce widget I get the the modal window with breaked styles (shown on the picture). After searching the solution, I found that bootstrap styles rewrite tynimce styles.
incorrect image
When I clear bootstrap.css file in assets, tinymce works perfect (shown on the picture).
correct image
What are the solutions to solve this problem? Thanks.

TinyMce via ajax

Estou com um problema ao usar o tinymce via o ajax do yii2, quando eu abro uma modal com tinymce, fecho e abro de novo ele não inicializa pela segunda vez, alguém sabe como resolver esse tipo de problema?

Outdated german translation

The german translation is outdated. It's missing the "table of contents" translation.

Could you update the translations, or explain how I can include the translation without loosing the file when updating the extension?

Thanks!

Add callback?

How do I add callbacks? I am trying this:

<?php
    $func = "function(editor) {editor.addButton('languages', {text : 'Language', type : 'menubutton', icon : false});}";
    echo $form->field($model, 'content')->widget(TinyMce::className(), [
    'clientOptions' => [
    'plugins' => [
    "advlist autolink lists link charmap print preview anchor",
    "searchreplace visualblocks code fullscreen",
    "insertdatetime media table contextmenu paste"
    ],
    'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | languages",
    'setup' => $func

],
    'options' => ['rows' => 12],
    ]);
    ?>

Output is
tinymce.init({ "plugins": ["advlist autolink lists link charmap print preview anchor", "searchreplace visualblocks code fullscreen", "insertdatetime media table contextmenu paste"], "toolbar": "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | languages", "setup": "function(editor) {editor.addButton('languages', {text : 'Language', type : 'menubutton', icon : false});}", "selector": "#pages-content" });
Which should have been:
tinymce.init({ "plugins": ["advlist autolink lists link charmap print preview anchor", "searchreplace visualblocks code fullscreen", "insertdatetime media table contextmenu paste"], "toolbar": "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image | languages", "setup": function(editor) {editor.addButton('languages', {text : 'Language', type : 'menubutton', icon : false});}, "selector": "#pages-content" });

Why only first run display editor with ajax?

Use ActiveForm on CRUD in Yii2
$form->field($model, 'main_text_promo')->widget(\dosamigos\tinymce\TinyMce::className());

TinyMce configured at bootstrap.php

Yii::$container->set('dosamigos\tinymce\TinyMce', [
	'language' => 'ru',
	'options' => ['rows' => 10],
	'clientOptions' => [
		'plugins' => [
			'advlist autolink lists link charmap hr preview pagebreak',
			'searchreplace wordcount textcolor visualblocks visualchars code fullscreen nonbreaking',
			'save insertdatetime media table contextmenu template paste image responsivefilemanager filemanager',
		],
		'toolbar' => 'undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | responsivefilemanager link image media',
		'external_filemanager_path' => '/plugins/responsivefilemanager/filemanager/',
		'filemanager_title' => 'Responsive Filemanager',
		'external_plugins' => [
			'filemanager' => '/plugins/responsivefilemanager/filemanager/plugin.min.js',
			'responsivefilemanager' => '/plugins/responsivefilemanager/tinymce/plugins/responsivefilemanager/plugin.min.js',
		],
		'relative_urls' => 0,
	]
]);

TinyMCE is disappeared when I use Pjax plugin

Hello!

I use dosamigos\tinymce\TinyMce plugin in yii\bootstrap4\ActiveForm with yii\widgets\Pjax.

TinyMCE is disappeared when I push the submit button but I need that it is not disappeared.

How to fix it?

Here is the code:

in the view:

<?php Pjax::begin(); ?>
<?php if(!empty($message)): ?>
    <p><code>We got this!</code></p>
<?php endif; ?>
<?php $form = ActiveForm::begin([
        'options' => ['data-pjax' => true],
]); ?>

<?= $form->field($commentForm, 'comment')->widget(TinyMce::class, [
    'options' => ['id' => 'foobartiny'],
    'language' => Yii::$app->language,
    'clientOptions' => [
        'branding' => false, // To show or not who powered (TinyMCE label)
        'menubar' => false, // To show or not the highest menu, but can use for layout of this menu
        'plugins' => [
            'advlist', 'autolink', 'lists', 'link', 'charmap', 'print', 'preview', 'anchor',
            'searchreplace', 'visualblocks', 'fullscreen', 'wordcount',
            'insertdatetime', 'contextmenu', 'paste', 'autoresize'
        ],
        'toolbar' => "undo redo | forecolor backcolor | bold italic underline strikethrough  | bullist numlist",
        'fontsize_formats' => '11px 12px 14px 16px 18px 24px 36px 48px',
        'min_height' => 10,
        'max_height' => 500,
    ]
])->label(Yii::t('x', 'Leave a comment')) ?>

<?= Html::submitButton(Yii::t('x', 'Send'), ['class' => 'btn btn-green mb-3']) ?>

<?php ActiveForm::end(); ?>
<?php Pjax::end(); ?>

in the action:

public function actionSingle($slug)
{
    $event = Event::find()->active()->one();

    if (!$event) {
        throw new NotFoundHttpException(Yii::t('x', 'Not found'));
    }

    $message = '';
    if ($commentForm->load(Yii::$app->request->post())) {
        if (Yii::$app->request->isPjax) {
            $message = Yii::t('x', 'Thank you');
        }
    }

    return $this->render('single', [
        'event' => $event,
        'commentForm' => $commentForm,
    ]);
}

Dealing with with required field.

Using the latest Yii2 with your plugin. I have a form rule set with the text field as required. When I try to create a new record and type text in the editor then save I get a message that the text field is empty but I have text in the editor. Can you advise?

Work for the first call, but not subsequent call when using modal

The TinyMCE renders properly the first time, but calling the modal window again, it doesn't render at all.

I've seen a few posts about the issue, but never found a complete solution.

I tried calling the init() when the modal is shown from the index view (where the modal is opened from) but it doesn't seem to work?

    $("#modal").on("shown.bs.modal",function(){
        tinymce.init({
            "plugins":["advlist autolink lists link charmap print preview anchor","searchreplace visualblocks code fullscreen","insertdatetime media table contextmenu paste","textcolor"],
            "toolbar":"undo redo | styleselect forecolor backcolor | bold italic underline | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
            "selector":"#tickets-details"
        });
    });

Can anyone shed some light on the matter?

Some icons not show in toolbar

For ex not show "image" icon.
Code:

<?=$form->field($model, 'name')->widget(TinyMce::class, [
      'options' => ['rows' => 10],
      'language' => 'ru',
      'clientOptions' => [
            'plugins' => [
                "advlist autolink lists link charmap print preview anchor",
                "searchreplace visualblocks code fullscreen",
                "insertdatetime media table contextmenu paste image"
            ],
            'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image code",
       ]
])?>

"image" exists in "plugins" and "toolbar" sections.

No Javascript imports

Hi,

I can't get extension work. It was correctly installed via composer, no php error appear but also no javascript imports are added to my template and my form look like this (content field):
Form
What is wrong?

Validation Problem when set as required field

I have experienced this with yii1.1 plugin also, when we set the tinymce field as required the field gives an error that xyzfield cannot be blank even when I the user has filled that field.

Plugins

How can I add another plugin into yii2-tinymce-widget?

have problem with elfinder and tinymce

Hi, I have problem with url of selected image in tiny mce . https://github.com/2amigos/yii2-tinymce-widget
el finder work correctly It's upload image in the correct folder and show in elfinder , after I am choosing picture and show the url in modal like this:
untitled
the url is like this: ../../uploads/tinymce/2.jpg
when I am in module my structure is like this: app/admin/
two dot came back to correct url and show picture in admin module but when I want to show picture with text in front end the url is not correct how can I fix this?

Tag new version?

Would it be possible to tag and release the current master as 1.1.4?

How to use CDN in configure file ?

Thanks to create the widget, it's very useful.

I found a Issue maybe, it's hard to change the URL of tinymce.min.js when using CDN.
In the config file, i try to set the assetManager params, like this:

$config = [
    ...
    'components' => [
        'assetManager' => [
            'bundles' => [
                // working.
                'yii\web\JqueryAsset' => [
                    'js' => ['//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js']
                ],
                //  working too, but got JS file in twice
                'dosamigos\tinymce\TinyMceAsset' => [
                    'js'    => ['//cdn.bootcss.com/tinymce/4.4.0/tinymce.min.js'],
                ],
            ],
        ],
    ],
    ...
]

So, I read the JqueryAsset.php in /yii2/web/JqueryAsset.php, and edit the TinyMceAsset.php from:

class TinyMceAsset extends AssetBundle
{
    public $sourcePath = '@vendor/tinymce/tinymce';

    public function init()
    {
        parent::init();
        $this->js[] = YII_DEBUG ? 'tinymce.js' : 'tinymce.min.js';
    }
}

to:

class TinyMceAsset extends AssetBundle
{
    public $sourcePath = '@vendor/tinymce/tinymce';
    public $js = [
        'tinymce.js'
    ];
}

the configure is working.

So, I think it's better to give a chance to config.

Insallation issue

I have done a fresh installation of yii2basic latest using composer and after that I tried to install this widget as per the instruction, but getting the error like below.

How I can fix this?

C:\wamp64\www>composer require 2amigos/yii2-tinymce-widget:~1.1
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- 2amigos/yii2-tinymce-widget 1.1.0 requires yiisoft/yii2 ~2.0.0 -> satisfiable by yiisoft/yii2[2.0.0, 2.0.1, 2.0.10, 2.0.11, 2.0.11.1, 2.0.11.2, 2.0.12, 2.0.12.1, 2.0.12.2, 2.0.13, 2.0.13.1, 2.0.13.2, 2.0.13.3, 2.0.14, 2.0.14.1, 2.0.14.2, 2.0.15, 2.0.15.1, 2.0.16, 2.0.16.1, 2.0.17, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9].
- 2amigos/yii2-tinymce-widget 1.1.1 requires yiisoft/yii2 ~2.0.0 -> satisfiable by yiisoft/yii2[2.0.0, 2.0.1, 2.0.10, 2.0.11, 2.0.11.1, 2.0.11.2, 2.0.12, 2.0.12.1, 2.0.12.2, 2.0.13, 2.0.13.1, 2.0.13.2, 2.0.13.3, 2.0.14, 2.0.14.1, 2.0.14.2, 2.0.15, 2.0.15.1, 2.0.16, 2.0.16.1, 2.0.17, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9].
- 2amigos/yii2-tinymce-widget 1.1.2 requires yiisoft/yii2 ~2.0.0 -> satisfiable by yiisoft/yii2[2.0.0, 2.0.1, 2.0.10, 2.0.11, 2.0.11.1, 2.0.11.2, 2.0.12, 2.0.12.1, 2.0.12.2, 2.0.13, 2.0.13.1, 2.0.13.2, 2.0.13.3, 2.0.14, 2.0.14.1, 2.0.14.2, 2.0.15, 2.0.15.1, 2.0.16, 2.0.16.1, 2.0.17, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9].
- 2amigos/yii2-tinymce-widget 1.1.3 requires yiisoft/yii2 ^2.0 -> satisfiable by yiisoft/yii2[2.0.0, 2.0.1, 2.0.10, 2.0.11, 2.0.11.1, 2.0.11.2, 2.0.12, 2.0.12.1, 2.0.12.2, 2.0.13, 2.0.13.1, 2.0.13.2, 2.0.13.3, 2.0.14, 2.0.14.1, 2.0.14.2, 2.0.15, 2.0.15.1, 2.0.16, 2.0.16.1, 2.0.17, 2.0.2, 2.0.3, 2.0.4, 2.0.5, 2.0.6, 2.0.7, 2.0.8, 2.0.9].
- yiisoft/yii2 2.0.9 requires bower-asset/jquery 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.8 requires bower-asset/jquery 2.2.@stable | 2.1.@stable | 1.11.@stable -> no matching package found.
- yiisoft/yii2 2.0.7 requires bower-asset/jquery 2.2.
@stable | 2.1.@stable | 1.11.@stable -> no matching package found.
- yiisoft/yii2 2.0.6 requires bower-asset/jquery 2.1.@stable | 1.11.@stable -> no matching package found.
- yiisoft/yii2 2.0.5 requires bower-asset/jquery 2.1.@stable | 1.11.@stable -> no matching package found.
- yiisoft/yii2 2.0.4 requires bower-asset/jquery 2.1.@stable | 1.11.@stable -> no matching package found.
- yiisoft/yii2 2.0.3 requires bower-asset/jquery 2.1.@stable | 1.11.@stable -> no matching package found.
- yiisoft/yii2 2.0.2 requires bower-asset/jquery 2.1.@stable | 1.11.@stable -> no matching package found.
- yiisoft/yii2 2.0.17 requires bower-asset/jquery 3.3.@stable | 3.2.@stable | 3.1.@stable | 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.16.1 requires bower-asset/jquery 3.3.
@stable | 3.2.@stable | 3.1.@stable | 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.16 requires bower-asset/jquery 3.3.@stable | 3.2.@stable | 3.1.@stable | 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.15.1 requires bower-asset/jquery 3.2.
@stable | 3.1.@stable | 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.15 requires bower-asset/jquery 3.2.
@stable | 3.1.@stable | 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.14.2 requires bower-asset/jquery 3.2.
@stable | 3.1.@stable | 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.14.1 requires bower-asset/jquery 3.2.
@stable | 3.1.@stable | 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.14 requires bower-asset/jquery 3.2.
@stable | 3.1.@stable | 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.13.3 requires bower-asset/jquery 3.2.
@stable | 3.1.@stable | 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.13.2 requires bower-asset/jquery 3.2.
@stable | 3.1.@stable | 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.13.1 requires bower-asset/jquery 3.2.
@stable | 3.1.@stable | 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.13 requires bower-asset/jquery 3.2.
@stable | 3.1.@stable | 2.2.@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.12.2 requires bower-asset/jquery 2.2.
@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.12.1 requires bower-asset/jquery 2.2.
@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.12 requires bower-asset/jquery 2.2.
@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.11.2 requires bower-asset/jquery 2.2.
@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.11.1 requires bower-asset/jquery 2.2.
@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.11 requires bower-asset/jquery 2.2.
@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.10 requires bower-asset/jquery 2.2.
@stable | 2.1.@stable | 1.11.@stable | 1.12.@stable -> no matching package found.
- yiisoft/yii2 2.0.1 requires bower-asset/jquery 2.1.
@stable | 1.11.@stable -> no matching package found.
- yiisoft/yii2 2.0.0 requires bower-asset/jquery 2.1.
@stable | 1.11.*@stable -> no matching package found.
- Installation request for 2amigos/yii2-tinymce-widget ~1.1 -> satisfiable by 2amigos/yii2-tinymce-widget[1.1.0, 1.1.1, 1.1.2, 1.1.3].

Potential causes:

Read https://getcomposer.org/doc/articles/troubleshooting.md for further common problems.

Installation failed, reverting ./composer.json to its original content.

C:\wamp64\www>

language files

if you set up language to 'en' there is no en.js file at langs folder of corresponding asset but only en_CA.js and en_GB.js, so if I try to use ISO-639 two-letters language variable at multilanguage site I will get error everytime I switch to English.

Facing issue when the plugin is used in Modal

I am using this plugin in a form and the fom is loaded in a modal dialog. If the modal is loaded for the first time the plaugin works fine. The problem occures when the modal is opened more than once. The plugin does not get initialised perhaps.
capture1
capture2

Failed to load plugin: print preview paste importcss searchreplace autolink ... emoticons/plugin.js

Hi! If you have problems loading plugins and some buttons are not shown on the panel, then change the widget code a little. I separated plugins into array elements and everything worked

<?= $form->field($model, 'text')->widget(TinyMce::className(), [
        'options' => ['rows' => 6],
        'language' => 'ru',
        'clientOptions' => [
            'plugins' => [
                "advlist", "autolink", "lists", "link", "charmap", "anchor",
                "searchreplace", "visualblocks", "code", "fullscreen",
                "insertdatetime", "media", "table", "image", "preview",
            ],
            'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
        ]
    ]);?>

Plugins: print, paste, contextmenu, don't support anymore

Few tinyMCE on page

Trying to call tinyMCE like in code below. Not working. If i will change first line to
$form->field($item, 'filledTemplate')->widget(TinyMce::className(), [
it will work

$form->field($item, '['.$key.']filledTemplate')->widget(TinyMce::className(), [
                                        'options' => [
                                            'rows' => 26
                                        ],
                                        'clientOptions' => [
                                            'plugins' => [
                                                "advlist autolink lists link charmap preview anchor textcolor image",
                                                "searchreplace visualblocks code fullscreen",
                                                "insertdatetime media table contextmenu paste"
                                            ],
                                            'toolbar' => "undo redo | styleselect | fontsizeselect bold italic | forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image",
                                            'fontsize_formats'=> '8pt 10pt 12pt 14pt 18pt 24pt 36pt',
                                            'remove_linebreaks' => false,
                                            'convert_newlines_to_brs' => true,
                                            'remove_redundant_brs' => false,
                                            'allow_html_in_named_anchor' => true,
                                            'allow_conditional_comments' => true,
                                            'allow_script_urls' => true,
                                            'inline_styles'=>true,
                                            'relative_urls' => false,
                                            'remove_script_host' => false,
                                            'verify_html' => false,             
                                            'extended_valid_elements' => "script[language|type],p[style]",
                                            'valid_children' => "+body[style|link]",
                                            'valid_elements' => '*[*]',                                            
                                        ]
                                    ])->label(false);

file_picker_callback / file_browser_callback

Hi,
I found problem with assign tinymce to file browser (function)
sample code:

<script>function nameJsFunction().....</script>
 
 <?= $form->field($model, 'content')->widget(TinyMce::className(), [
         'options' => ['rows' => 16],
         'language' => 'en_GB',
         'clientOptions' => 
             'file_picker_callback' => 'nameJsFunction',
         ]
     ]); ?>

this generate something like this:
"file_picker_callback":"nameJsFunction" but nameJsFunction, can't be in quotations.

Sample solution, maybe is something better, but that works for me:

TinyMce.php
after $options

// @codeCoverageIgnoreEnd
$options = Json::encode($this->clientOptions);

  //check is there editor and replace "function" to function 
    if(isset($this->clientOptions['file_picker_callback']))
        $options = str_replace('"'.$this->clientOptions['file_picker_callback'].'"', $this->clientOptions['file_picker_callback'], $options);

i guess something like this is should be for "file_browser_callback" too,

if(isset($this->clientOptions['file_browser_callback']))
$options = str_replace('"'.$this->clientOptions['file_browser_callback'].'"', $this->clientOptions['file_picker_callback'], $options);

TinyMCE Not shown on renderAjax()

Hi guys,
The widget works correcty but on views rendered using renderAjax() method I just have a textarea (with the HTML tags and text)

[BUG] Uncaught TypeError: rawToolbar.replace is not a function

I am getting an issue "Uncaught TypeError: rawToolbar.replace is not a function" from theme.js (Version: 5.0.7). This is only reproducible when we load on mobile environment. Desktop environment works fine.

Uncaught TypeError: rawToolbar.replace is not a function
at extract$1 (theme.js:10428)
at identify (theme.js:10438)
at Object.detect$4 [as detect] (theme.js:10536)
at Editor. (theme.js:14296)
at EventDispatcher.fire (tinymce.js:25608)
at Editor.fire (tinymce.js:25714)
at initEditor (tinymce.js:23786)
at tinymce.js:23900
at tinymce.js:4479
at tinymce.js:4136

how to add mention plugin

Hi can you add mention plugin in this repository , I added manual in vendor and its work prefect,

Fill textarea onkeyup

Is it possible to change de textarea value onkeyup event?

I'm trying to save a text via AJAX but the textarea isn't changing whem I'm editing it.

Yii2 "paste_preprocess" and "deny images to save in DB"

<?= $form->field($model, 'description')->widget(TinyMce::className(), [
    'options' => [
        'id' => 'descript_tinyMce',
        'rows' => 15
    ],
    'language' => 'en_CA', 
    'clientOptions' => [
        'plugins' => [
            "advlist autolink lists link charmap print preview anchor",
            "searchreplace visualblocks code fullscreen",
            "insertdatetime media table contextmenu paste",
            "responsivefilemanager filemanager image",
        ],
        'toolbar' => "undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent | link responsivefilemanager image",
        'external_filemanager_path' => '/web/js/plugins/responsivefilemanager/filemanager/',
        'filemanager_title' => 'Responsive Filemanager',
        'external_plugins' => [
            'filemanager' => '/web/js/plugins/responsivefilemanager/filemanager/plugin.min.js',
            'responsivefilemanager' => '/web/js/plugins/responsivefilemanager/tinymce/plugins/responsivefilemanager/plugin.min.js',
        ],
        'inline_styles' => false,  
        'convert_fonts_to_spans' => true,
        'element_format' => 'html',
        'invalid_elements' => 'em,font', 
        // 'paste_preprocess' => 'MY FUNCTION ???',
    ]
])->label(false);?>

The plugin works very well.

  1. How can I write "invalid_elements" function to execute,
    or How I can initialize a separate JavaScript file where to write the given function ?

  2. How can I set the pictures copied from Microsoft Word to upload on the server but not in the database?

Sorry my bad english.
Thanks so much for plugin.

How to turn on Inline mode ?

Hello, it's my code:

`\dosamigos\tinymce\TinyMce::widget([
    'name' => 'test',
    'language' => 'ru',
    'clientOptions' => [
        'selector' => 'div.test',
        'inline' => true,
        'plugins' => [
            'advlist autolink lists link image charmap print preview anchor',
            'searchreplace visualblocks code fullscreen',
            'insertdatetime media table contextmenu paste'
        ],
        'toolbar' => 'insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image'
    ]
]);
<div class = "test"></div>`

but only clean textarea

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.