Giter Club home page Giter Club logo

yii2-imperavi-redactor's Introduction

Imperavi Redactor 10.2.3 Widget For Yii2

Created for Experitus

ImperaviRedactorWidget is a wrapper for Imperavi Redactor, a high quality WYSIWYG editor.

Note that Imperavi Redactor itself is a proprietary commercial copyrighted software but since Yii community bought OEM license you can use it for free with Yii.

Using model

yii\imperavi\Widget::widget([
	// You can either use it for model attribute
	'model' => $my_model,
	'attribute' => 'my_field',

	// or just for input field
	'attribute' => 'my_input_name',

	// Some options, see http://imperavi.com/redactor/docs/
	'options' => [
		'toolbar' => false,
		'css' => 'wym.css',
	],
]);

Using ActiveForm

use yii\imperavi\Widget;
use yii\widgets\ActiveForm;

$form = ActiveForm::begin();

echo $form->field($model, 'my_field')->widget(Widget::classname(), 'options' => []);

Alternatively you can attach Redactor to already existing DOM element by calling:

yii\imperavi\Widget::widget([
	// Some options, see http://imperavi.com/redactor/docs/
	'options' => [],
]);

The redactor plugins plugged in with packages of resources.

yii\imperavi\Widget::widget([
	'options' => [
		'lang' => 'ru',
	],
	'plugins' => [
		'fullscreen',
		'clips'
	]
]);

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require asofter/yii2-imperavi-redactor "*"

or add

"asofter/yii2-imperavi-redactor": "*"

to the require section of your composer.json file.

yii2-imperavi-redactor's People

Contributors

adamasantares avatar ajithlalps avatar alfredleo avatar asofter avatar bzzim avatar dasturchiuz avatar elaps avatar hamrak avatar itzen avatar kayalion avatar kfreiman avatar richweber avatar sleptor avatar st1gz avatar tvdavid 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

yii2-imperavi-redactor's Issues

Problem with callbacks

<?=$form->field($model, 'text')->widget(yii\imperavi\Widget::className(), [
            'id' => Html::getInputId($model, 'text'),
            'model' => $model,
            'attribute' => 'text',
            'options' => [
                //... other options
                'imageUpload' => '/upload',
                'imageUploadParam' => 'file',
                'imageUploadErrorCallback' => 'function(json) { console.log(json); }',
                'uploadFields' => [
                    Yii::$app->request->csrfParam => Yii::$app->request->getCsrfToken()
                ]
            ]
]);?>

any callbacks don't work. i think problem in generated js

jQuery(document).ready(function () {
    jQuery('#post-text').redactor({
    "imageUpload":"\/upload",
    "imageUploadParam":"file",
    "imageUploadErrorCallback":"function(json) { console.log(json); }",
    "uploadFields":{"_csrf":"bWdXVTlTWEQjBghkYDEXARsjFBZNYiESPBUgPW9qPDEeFD8lCSYbLQ=="},"lang":"ru"});
});;

I do not understand JS but I think that the problem is in this place

 "imageUploadErrorCallback":"function(json) { console.log(json); }",

if I'm wrong, then tell me what I'm doing wrong and what needs to be done to start working callbacks

Installing through composer isn't working

The require section of my composer.json:

"require": {
    "php": ">=5.4.0",
    "yiisoft/yii2": "*",
    "yiisoft/yii2-bootstrap": "*",
    "yiisoft/yii2-swiftmailer": "*",
    "yiisoft/yii2-gii": "*",
    "asofter/yii2-imperavi-redactor": "*"
},

Here is what I'm seeing when I run composer to install the package:

brian@ubuntu:/var/www/vhosts/iassidd$ php composer.phar update
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
    - The requested package asofter/yii2-imperavi-redactor could not be found in any version, there may be a typo in the package name.

Potential causes:
 - A typo in the package name
 - The package is not available in a stable-enough version according to your minimum-stability setting
   see <https://groups.google.com/d/topic/composer-dev/_g3ASeIFlrc/discussion> for more details.

Read <http://getcomposer.org/doc/articles/troubleshooting.md> for further common problems.

Languages

Привет.
Есть небольшая просьба - можно ли дописать проверку существования файла перевода языка приложения?
Если файл перевода не удается загрузить (в случае его отсутствия) - падает весь скрипт редактора.

плюс к этому - код украинского языка - "uk", можно ли переименовать файл перевода?

Спасибо

help to use imageUpload Option

Please can you provide some help how to upload images as part of editor?
Is it possible to call a action like below?
'imageUpload' => Yii::$app->urlManager->createAbsoluteUrl('/upload'),

I am trying to use it, but getting the below error
TypeError: rawString.match(...) is null

imageUpload error with Browse button

@asofter
I am using 'imageUpload'.
if I drag and drop images, it is working fine, but when I select an image with "Browse" button, below error is showing in firebug console.
I have tried a lot but no luck.
any idea how it works?

TypeError: rawString.match(...) is null

var jsonString = rawString.match(/\{(.|\n)*\}/)[0];
redactor.js (line 6893)

Tag/make a release

It would be great if you can tag/make a release for this repo, Using stability level "*" / or "dev-master" via composer can break projects on a single commit going wrong .

Removing Div

Hello,

When I try to insert div in code section and switch back to Html. It removes div tag.
I user following settings but didn't work
\yii\imperavi\Widget::className(), [ 'plugins' => ['fullscreen', 'fontcolor', 'video'], 'options' => [ "allowedTags" => ['div','p', 'h1', 'h2', 'h3', 'img', 'pre', 'span'], 'minHeight' => 400, 'maxHeight' => 400, 'replaceTags'=> false, 'structure' => true, 'buttonSource' => true, 'convertDivs' => false, 'replaceDivs' => false, 'removeEmptyTags' => true, 'imageUpload' => Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi']) ] ]
Allowtags and replace divs option didn't work.

Setting language

For languages like pt_pt or pt_br the logic in ImperaviRedactorAsset init() method fails because it gets only the first 2 letters of Yii language. In this case there will be no pt.js in redactor to publish and the widget fails to load.

Also, Yii uses pt-BR and redactor pt_br for setting language so an inconsistence exists. You should convert Yii format to redactor format.

Error after jquery update

After updating the jquery in yii2 to version 3, the widget stopped working. Screenshot with errors attached

image

Language issue

I'm from portugal I have my language set to pt but in this script I should set it to pt_pt.

Since you have this code
appLanguage = strtolower(substr(Yii::$app->language , 0, 2)); //First 2 letters
if($appLanguage != 'en') // By default $language = 'en-US', someone use underscore
$this->options['lang'] = $appLanguage;

in Widget.php I am unable to set the 'lang' option I think you should remove this 3 lines and every user set the 'lang' option everytime.

Missing language en.js

Hey Guys,

I've been using this extension for a while. Recently I started seeing 404 not found for when the widget is attempting to load lang/en.js. There is no lang/en.js. Can I disable looking up en.js as this is causing an error with the 404 on Modal redactor widgets,

Not a bug in extns but Imperavi issue

I am using S3 Upload in redactor.
S3 Upload should go through "POST" method, but it was hardcoded as "PUT"
and there is no way to send "POST" request and/or custom "policy" as part of "Signed Urls".
As Yii has OEM license, can we raise it to Imperavi? to facilitate "Post" requests with Signed Urls as per the Amazon docs?
Because there is no way to restrict file-size to upload as part of S3 uploads

ImperaviRedactorAsset.php lang file path

Lang file path param in ImperaviRedactorAsset.php contain root-path instead of relative-path. As result browser generate 404 error for lang file.

Correct path should be 'lang/en.js' instead of '/lang/en.js'

Stable version

dev-master doesn't fit minimum-stability: "stable", unless we explicitly require it with dev-master@dev. Do you plan to release a 1.0.0?

Problems switching between ordered and unordered lists

Hello, I'm using the latest version of the redactor library that can be found in your repo here:

https://github.com/asofter/yii2-imperavi-redactor/blob/master/assets/redactor.js

When you add some text to the editor, let's say for example:

aaaa
bbbb
cccc
dddd

... and then select it and decide to convert that text into an ordered list the first time you click the ordered list button you will get the ordered list, as expected, but if you click again that same button, you would expect the order list to disappear but that doesn't happen, what happens is that it becomes an unordered list.

Are you aware of this bug?

Do you have any ideas on how to implement a workaround?

I'm using the following code:

https://jsfiddle.net/jpruiz114/71uwpazo/

<!DOCTYPE html>
<html>
    <head>
        <title>Test 1</title>

        <meta charset="utf-8">

        <script src="https://code.jquery.com/jquery-1.12.2.min.js"></script>

        <link rel="stylesheet" href="assets/redactor.css" />

        <script src="assets/redactor.js"></script>

        <script type="text/javascript">
            $(
                function() {
                    $('#content').redactor();
                }
            );
        </script>
    </head>

    <body>
        <textarea id="content" name="content"></textarea
    </body>
</html>

Thanks!

Edit 1:

I have tested with the version 10.2.5 Updated on October 1, 2015 and with the version 10.2.2 Updated on July 15, 2015 and the same behaviour happens.

How to set redactor callback in widget options

Hello, I can't seem to understand how we can use the widget and be able to set redactor callback functions. The redactor callback functions are javascript functions, but we are configuring the redactor options in the php widget. Therefore, the javascript function becomes a string when it is json encoded and is not executable as a javascript function.

It seems like there must be a way to address this challenge. Any guidance you can offer is greatly appreciated! Many thanks for all you do!

Maintanance Question

Is this repo still maintained?
Am thinking of using redactorjs and would like to know sustainability here

Language issue

The problem with the languages still happened.

Now the problem is in ImperaviRedactorAsset.php, this file use everytime the Yii::$app->language, and not the redactor language that we set.

For example in Portuguese the Yii::$app->language is 'pt' and in the redactor is 'pt_pt'.

Doesn't appear in modal

I have 3 tabs in view. When i click on button which call for a modal with imperavi widget, doesn appear in modal, but appear in first tab. What can be problem?

Setting language option causes a javascript error

Good afternoon.

I tried setting a language in the options array to Russian, but this action causes a javascript error which prevents Redactor from loading.

redactor.js:4887 Uncaught TypeError: Cannot read property 'html' of undefined

Sample PHP code:

echo $form->field($model, 'content')->widget(\yii\imperavi\Widget::className(), [
        'options' => [
            'lang' => 'ru',
        ],
]);

The problem happens with just the widget without activeField as well:

echo \yii\imperavi\Widget::widget([
        'options' => [
            'lang' => 'it',
        ],
]);

It seems the error occurs with any language except English.

Options not set to redactor

i try this:
$form->field($model,'content')->widget(yii\imperavi\Widget::className(),[
'id'=>'html-content',
'options' => [
'buttonSource' => 'true',
'lang' => 'ru',
'minHeight' => 350,
'convertDivs' => false,
'paragraphize' => false,
'removeDataAttr' => false,
'cleanOnPaste' => false,
],
]);

but options convertDivs, paragraphize, removeDataAttr, cleanOnPaste is not set to redactor and redactor use default options

Widget having strange behaviour - not all features work properly. Conflicts maybe?

Hey guys!
I'm having some problems with - maybe you've heard of it yii2-starter-kit - which uses yii2-imperavi-redactor. In the beginning it worked fine, but now (later on in the development) it seems that it behaves strangely.
Not all hover texts appear, selected text is not getting transformed to bold, italic or underline; many features work though, like image upload, setting the text types (code, quote...) - but the dropdown looks crazy.
Oh and if i just select bold and/or italic and just setup my style before writing anything, if I start typing, all the styles are working. It looks like only when I select something its not working.

In my little experience it seems that it is having some conflicts with the other assets I am using.

Note: I double and triple checked with the yii2-starter-kit demo (username: manager password: manager) but it doesn't seem to be differences in the necessary assets for redactor...

I'll show you here the assets that are currently loading in the page
This is the head of the page:
image

And this is after body:
image

If you have any suggestions, I am all eyes and ears 👍

cannot install via composer

I follow the installation instructions and get this error

*Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package asofter/yii2-imperavi-redactor could not be found in any version, there may be a typo in the package name.*

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.