苏科夫纳耶夫 / aceeditor-bundle
将优秀的JavaScript ace编辑器集成到Symfony表单的包。
3.0.0
2017-07-07 08:57 UTC
Requires
- php: >=5.6
- symfony/asset: ^3.0
- symfony/expression-language: ^3.0
- symfony/form: ^3.0
- symfony/framework-bundle: ^3.0
- symfony/twig-bridge: ^3.0
- twig/twig: ^1.23|^2.0
Requires (Dev)
- phpunit/phpunit: ^5.7
- satooshi/php-coveralls: ^1.0
This package is not auto-updated.
Last update: 2024-09-29 05:01:33 UTC
README
该包提供了Ace编辑器到Symfony表单组件的集成。它将自动注册ace_editor表单类型。
Symfony
该包支持以下Symfony版本
Composer
要使用此包与Symfony ^3.0,请在Composer中要求它
composer require "sukovanej/aceeditor-bundle" ^3.0
在AppKernel.php中注册包
// app/AppKernel.php public function registerBundles() { return array( new Sukovanej\AceEditorBundle\SukovanejAceEditorBundle(), // ... ); }
Ace编辑器
除非您进行了一些配置,否则此包期望Ace编辑器文件位于web/vendor/ace
cd your_project_root/web mdkir vendor && cd vendor wget https://github.com/ajaxorg/ace-builds/archive/v1.2.6.tar.gz tar -xvf v1.2.6.tar.gz mv ace-builds-1.2.6 ace rm v1.2.6.tar.gz
用法
use Sukovanej\AceEditorBundle\Form\Type\AceEditorType; /* @var $builder \Symfony\Component\Form\FormBuilderInterface */ $builder->add('description', AceEditorType::class, array( 'wrapper_attr' => array(), // aceeditor wrapper html attributes. 'width' => '100%', 'height' => 250, 'font_size' => 12, 'mode' => 'ace/mode/html', // every single default mode must have ace/mode/* prefix 'theme' => 'ace/theme/monokai', // every single default theme must have ace/theme/* prefix 'tab_size' => null, 'read_only' => null, 'use_soft_tabs' => null, 'use_wrap_mode' => null, 'show_print_margin' => null, 'show_invisibles' => null, 'highlight_active_line' => null, 'options_enable_basic_autocompletion' => true, 'options_enable_live_autocompletion' => true, 'options_enable_snippets' => false 'keyboard_handler' => null ));
上面的代码将创建一个textarea元素,该元素将被ace编辑器实例替换。textarea值会在ace编辑器每次单独更改时更新。
配置
本节是可选的,您无需配置任何内容,表单类型仍将正常工作得很好
默认配置
# app/config/config.yml
sukovanej_ace_editor:
base_path: "vendor/ace" # notice! this is starting from "your_project_root/web"!
autoinclude: true
debug: false # sources not minified, based on kernel.debug but it can force it
noconflict: true # uses ace.require instead of require
您也可以直接从与https://github.com/ajaxorg/ace-builds具有相同目录布局的位置包含Ace编辑器,您只需要设置base_path选项即可。
sukovanej_ace_editor:
base_path: "http://rawgithub.com/ajaxorg/ace-builds/master"