cacko/yii2-widget-monaco

Yii2 widget for Monaco Editor

Fund package maintenance!
cacko

Installs: 89

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 1

Type:yii2-extension

v0.5 2021-04-07 15:57 UTC

This package is auto-updated.

Last update: 2021-04-07 15:59:10 UTC


README

Simplifies adding Monaco Editor if you are screwed having to use Yii2 with its amazing jQuery inhericance.

Install

composer require cacko/yii2-widget-monaco

Demo

Sorta demo and playground - https://cacko-yii2.herokuapp.com/monaco/widget, the source of that is at https://github.com/cacko/yii2-widgets

Usage

Options

  • editorConfig - generally you can pass every option from the API which will override any crap you put before

Editor

with ActiveForm:

use Cacko\Yii2\Widgets\MonacoEditor\Widget\Editor as MonacoEditor;

<?= $form->field($model, 'script')->widget(MonacoEditor::class)->label(t('Code')) ?>

as a standalone widget

use Cacko\Yii2\Widgets\MonacoEditor\Widget\Editor as MonacoEditor;

<?= MonacoEditor::widget([
    'model' => $model,
    'attribute' => 'script',
    'language' => 'javascript',
]) ?>

or without a model

use Cacko\Yii2\Widgets\MonacoEditor\Widget\Editor as MonacoEditor;

<?= MonacoEditor::widget([
   'name' => 'script',
   'language' => 'javascript',
]) ?>

Diff Viewer

use Cacko\Yii2\Widgets\MonacoEditor\Widget\DiffEditor as MonacoDiffEditor;

<?= MonacoDiffEditor::widget([
    'model' => $model,
    'parent' => $parent,
    'attribute' => $attribute,
]) ?>

Persistance

for persisting the editor/diff options not in a cookie, inject your own implementation of Cacko\Yii2\Widgets\MonacoEditor\models\EditorSettingsInterface.

\Yii::$container->set(EditorSettingsInterface::class, MyAmazingShite::class);

there also a controller interface you may want to implement your own controller Cacko\Yii2\Widgets\MonacoEditor\controllers\ControllerInterface.