wbraganca/yii2-ace-widget

Yii2 Ace (Ajax.org Cloud9 Editor) 小部件

安装量: 14,601

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 2

开放问题: 0

类型:yii2-extension

1.0.0 2015-09-11 21:12 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:09:20 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

Ace (Ajax.org Cloud9 Editor) 的源代码仓库可在此找到 - https://github.com/ajaxorg/ace.

原始演示可在此找到 - http://ace.c9.io/#nav=embedding.

安装

安装此扩展的首选方式是通过 composer.

运行以下命令之一

$ php composer.phar require "wbraganca/yii2-ace-widget" "*"

或者将以下内容添加到您的 composer.json 文件的 require 部分。

"wbraganca/yii2-ace-widget": "*"

用法

<?php
use wbraganca\AceEditor\AceEditorWidget;

// For basic usage
echo AceEditorWidget::widget([
    'name' => 'editor_name',
    'value' => 'your text code',
]);

// Ace editor with emmet
$this->registerJsFile('https://cloud9ide.github.io/emmet-core/emmet.js');
echo AceEditorWidget::widget([
    'id' => 'attribute_id',
    'model' => $model,
    'attribute' => 'attribute_name',
    'theme' => 'sqlserver',
    'extensions' => [
        'emmet'
    ],
    'aceOptions' => [
        'showPrintMargin' => false,
        'minLines' => 20,
        'maxLines' => 500,
        'newLineMode' => 'unix'
    ]
]);
?>

选项

  • varNameAceEditor - 全局 JavaScript 变量(默认为 aceEditor)。
  • mode - 代码语言(默认为 php)。
  • theme - 主题(默认为 github)。
  • editable - 是否显示可编辑的文本输入或仅突出显示输出(默认为 true)。
  • autocompletion - 是否启用简单的自动完成功能(仅在 editable = true 时有效)。
  • aceOptions - ACE 编辑器的选项。