leandrogehlen/yii2-codemirror CodeMirror extension for Yii2

extension

CodeMirror

CodeMirror extension for Yii2

Yii2

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist leandrogehlen/yii2-codemirror "*"

or add

"leandrogehlen/yii2-codemirror": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :


<?php 

use leandrogehlen\codemirror\CodeMirror;

<?= $form->field($file, 'description')->widget(CodeMirror::className(), [
    'pluginOptions' => [
        'mode' => 'application/x-httpd-php', 
        'theme' => 'solarized dark',
        ...
    ]
]);

?>

By default, only core javascript and css files are registered:

  • lib/codemirror.js
  • lib/codemirror.css

If it is necessary adds other resource files, then should be used the Dependency Injection concept.

Example:

I want to use php mode in the codemirror editor


  //config/web.php

  $config = [
      'id' => 'my-app',
      'components' => [
        ...
      ]
      ...
  ]

  Yii::$container->set('leandrogehlen\codemirror\CodeMirrorAsset',[
      'js' => [
          'mode/htmlmixed/htmlmixed.js',
          'mode/xml/xml.js',
          'mode/javascript/javascript.js',
          'mode/clike/clike.js',
          'mode/php/php.js',
      ]
  ]);

  return $config;

Changelog

Yii2 CodeMirror Change Log

1.2.0 under development

  • Correct assets usage
  • Removed yii2-krajee-base dependencies
  • Refactored extension

1.1.0 January 14, 2015

  • Minor updates to clarify usage

1.0.0

  • Initial release

Statistics

Downloads
GitHub Stars
GitHub Forks

Releases

Comments



v1.2.0 is the latest of 3 releases



LGPL-3.0+ license
Stats
0 github stars & 0 github forks
0 downloads in the last day
2 downloads in the last 30 days
810 total downloads