ist1 / content-editable-bundle
针对 Symfony 的 WYSIWYG 编辑器组件包 - 与 ContentBundle 兼容良好
dev-master
2015-11-10 10:09 UTC
Requires
- doctrine/orm: ^2.4
- jms/translation-bundle: ^1.1
- symfony/class-loader: *
- symfony/yaml: *
This package is not auto-updated.
Last update: 2024-09-18 18:28:32 UTC
README
简单灵活的 WYSIWYG 编辑器组件包,适用于 Symfony - 与 Ist1ContentBundle 兼容良好
安装
-
添加到 composer
$ composer require ist1/content-editable-bundle
-
更新你的 AppKernel
new Ist1\ContentEditableBundle\Ist1ContentEditableBundle(),
-
获取 Aloha 编辑器(http://www.alohaeditor.org/)并安装它
-
更新你的 config.yml,例如
ist1_content_editable: configurations: # with an every day regular entity acme_blog: repository_class: AcmeSampleBundle:Blog # with Ist1ContentBundle ist1_content: repository_class: Ist1ContentBundle:Content id_field: name data_field: content
5. update your routing.yml:
```
ist1_content_editable:
resource: "@Ist1ContentEditableBundle/Controller/"
type: annotation
prefix: /admin/content-editable
```
6. include JS: '@Ist1ContentEditableBundle/Resources/public/js/main.js'
7. invoke init function by passing a base url somehow like this:
```javascript
contentEditable.init('/' + locale + '/admin/content-editable');
```
8. (optional) include CSS. '@Ist1ContentEditableBundle/Resources/public/css/main.css'
### Usage
- sample twig code:
{{ blog.lead }}
```- 带有 Ist1ContentBundle 的示例 Twig 代码
<p {{ content_editable ('ist1_content', 'id_of_the_content') }}>{{ content ('id_of_the_content', 'initial value of the content') }}</p>
- 初始化 ContentEditable 后,只需点击要编辑的元素即可激活 Aloha 编辑器
附录
- 这是一个非常早期的版本,刚刚从我的一个最近的项目中解耦出来
- 当未来的项目需要我添加更多功能时,我会对其进行改进
- 测试覆盖率即将推出
- 函数签名: content_editable (configKey, objectId, dataField = null)