- Notifications
You must be signed in to change notification settings - Fork3
Rails wrapper for Neditorhttps://github.com/notadd/neditor
License
NotificationsYou must be signed in to change notification settings
zcpdog/neditor_rails
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Rails wrapper forneditor, which is a rich text editor based on baidu ueditor
2.1.18
Add this line to your application's Gemfile:
gem 'neditor_rails'
And then execute:
$ bundle update
Usage:
rails g neditor_rails:install
Then add codes in application.js
//= require neditor//= require neditor_custom_config
You can custom config in neditor_custom_config.js, it looks like:
//neditor custom config(function(){window.CUSTOM_CONFIG={// Insert your config code, more details on http://fex.baidu.com/ueditor/#start-configelementPathEnabled:false,wordCount:0,maximumWords:5000,pasteplain:true,initialFrameHeight:300,autoHeightEnabled:true,imageFieldName:'upfile',autoFloatEnabled:false,// toolbars: [// ['Source','Undo','Redo','Cleardoc','SearchReplace','InsertImage','WordImage','Bold','ForeColor','JustifyLeft',// 'JustifyCenter','JustifyRight','JustifyJustify','RemoveFormat','FormatMatch','AutoTypeSet','PastePlain',// 'FontSize','Preview','Link','FullScreen', 'PageBreak', 'InsertTable','Attachment','InsertVideo']// ]};jQuery.extend(window.UEDITOR_CONFIG,window.CUSTOM_CONFIG);})();UE.Editor.prototype.getActionUrl=function(action){/* 按config中的xxxActionName返回对应的接口地址 */if(action=='uploadimage'||action=='uploadscrawl'){return'http://a.b.com/upload.php';}elseif(action=='uploadvideo'){return'http://a.b.com/video.php';}else{returnthis._bkGetActionUrl.call(this,action);}}
classUeditorImagesController <ApplicationControllerskip_before_filter:verify_authenticity_token,:only=>[:create]defcreate@ueditor_image=UeditorImage.new(image:params[:upfile])respond_todo |format|if@ueditor_image.savedata={:url=>@ueditor_image.image.url,:title=>params[:title],:original=>params[:upfile].original_filename,:code=>200}elsedata={:title=>params[:title],:original=>params[:upfile].original_filename,:code=>500}endformat.js{render:json=>data.to_json}endendend
<scripttype="text/javascript"> var editor = new UE.ui.Editor(); editor.render("your_textarea_id");</script>
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
About
Rails wrapper for Neditorhttps://github.com/notadd/neditor
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Releases
No releases published
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.