locaine/lcn-wysihtml5-bundle
Composer 安装命令:
composer require locaine/lcn-wysihtml5-bundle
包简介
WYSIWYG form type for Symfony2 using WYSIHTML5 and HTMLPurifier libraries
README 文档
README
WYSIWYG-Editor form widget for Symfony2 based on wysihtml forked from WYSIHTML5. MIT License.
Installation
Step 1: Install dependencies
Install the required LcnIncludeAssetsBundle.
Step 2: Download the Bundle
Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:
$ composer require locaine/lcn-wysihtml5-bundle "~1.0"
This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.
Step 3: Enable the Bundle
Then, enable the bundle by adding the following line in the app/AppKernel.php
file of your project:
<?php // app/AppKernel.php // ... class AppKernel extends Kernel { public function registerBundles() { $bundles = array( // ... new Lcn\WYSIHTML5Bundle\LcnWYSIHTML5Bundle(), ); // ... } // ... }
Usage
In your Form class, set the field type "lcn_wysihtml5" whenever you want to output the WYSIWYG-Editor.
$form = $this->createFormBuilder($entity)->add('your_html_field', 'lcn_wysihtml5');
That's it. You're done.
Configuration
You can customize the default settings by overriding them in your app/config/parameters.yml or app/config/config.yml file.
Available editor commands
parameters:
# configure the editor commands
lcn_wysihtml5.commands:
- { command: bold }
- { command: italic }
- { command: insertUnorderedList }
- { command: insertOrderedList }
- { command: formatBlock, value: h1 }
- { command: formatBlock, value: h2 }
Use custom Stylsheets and Javascripts for advanced customizations
You can configure the included assets to achieve any configuration provided by the wysihtml editor. For more details, consult the documentation.
parameters:
# stylesheets get included directly in the web page with the form widget
lcn_wysihtml5.stylesheets.controls:
- /bundles/lcnwysihtml5/dist/themes/basic/controls.css
# stylesheets get included in the editor's sandboxed iframe
# and should be included when outputting the generated html code.
# you might want to add some base stylsheets from your own theme
lcn_wysihtml5.stylesheets.content:
- /bundles/lcnwysihtml5/dist/themes/basic/content.css
lcn_wysihtml5.parser_rules: /bundles/lcnwysihtml5/dist/themes/basic/parser_rules.js
Customize HTMLPurifier Options for Server Side Sanitization
parameters:
lcn_wysihtml5.purifier_config:
'Attr.AllowedClasses':
- wysiwyg-color-primary
- wysiwyg-color-secondary
- wysiwyg-float-left
- wysiwyg-float-right
- wysiwyg-clear-left
- wysiwyg-clear-right
Customize existing colors
The editor uses class names to apply pre-defined colors:
You need to adjust the colors in the css file (set your own theme):
parameters:
lcn_wysihtml5.stylesheets.content:
- /bundles/lcnwysihtml5/dist/themes/basic/content.css
This stylesheet gets automatically included in the editor. However, you have to manually include this stylesheet in your page where you output the html code:
<link rel="stylesheet" href="/bundles/lcnwysihtml5/dist/themes/basic/content.css">
Add or remove colors
Configure the available colors in the editor toolbar:
parameters:
# configure the editor commands
lcn_wysihtml5.commands:
...
- { command: foreColor, values: [primary, secondary] }
Configure the allowed color class names for Frontend validation in your own custom parser_rules set:
parameters:
lcn_wysihtml5.parser_rules: /bundles/lcnwysihtml5/dist/themes/basic/parser_rules.js
Configure the allowed color class names for Server-Side validation using HTMLPurifier:
parameters:
lcn_wysihtml5.purifier_config:
'Attr.AllowedClasses':
- wysiwyg-color-primary
- wysiwyg-color-secondary
...
locaine/lcn-wysihtml5-bundle 适用场景与选型建议
locaine/lcn-wysihtml5-bundle 是一款 基于 JavaScript 开发的 Composer 扩展包,目前已累计 2.37k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2015 年 02 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「twig」 「wysiwyg」 「symfony 2」 「Form Type」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 locaine/lcn-wysihtml5-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 locaine/lcn-wysihtml5-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 locaine/lcn-wysihtml5-bundle 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
This Symfony bundle integrates PhpSpreadsheet into Symfony using Twig.
A Twig extension to insert css as inline styles with a tag
Caching and compression for Twig assets (JavaScript and CSS).
The bundle for easy using json-rpc api on your project
Twig extensions for Tracy Debugger
统计信息
- 总下载量: 2.37k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-02-18