Code Monkey home page Code Monkey logo

ckeditor's Introduction

Enhanced CKEditor for Rails

Disclaimer

This is my personal fork of galetahub/ckeditor with some additional plugins, themes and enhancements.

For a couple of years I have searched for ideal WYSIWYG editor. And finally I chose CKEditor with a bunch of plugins and handcrafted configs. I use it with a stable stack of other gems and versions (Rails 5, ActiveRecord, Carrierwave, Turbolinks 5). If your stack is different - you can see original README.md for proper setup guides.

Features

  • CKEditor version 4.6.1 full (08 Dec 2016)
  • Rails 5.0.x, 4.2.x integration
  • Files browser
  • HTML5 file uploader

Installation

  1. Add gems into Gemfile:
gem 'carrierwave'
gem 'ckeditor', github: 'gambala/ckeditor'
gem 'mini_magick'
gem 'non-stupid-digest-assets'
  1. Generate CKEditor configs, uploaders and models
rails generate ckeditor:install --orm=active_record --backend=carrierwave

2a. Change mount syntax style if you want:

mount Ckeditor::Engine, at: '/ckeditor'
  1. Set ckeditor assets as precompiled (in config/initializers/assets.rb):
Rails.application.config.assets.precompile += %w(
  ckeditor/config.js
  ckeditor/filebrowser/*
  ckeditor/plugins/*
  ckeditor/skins/moonocolor/*
)
  1. Set ckeditor assets as non digest (in config/initializers/non_digest_assets.rb):
NonStupidDigestAssets.whitelist += [%r{ckeditor/.*}]
  1. Add styles for js-ckeditor class, like these:
.js-ckeditor
  min-height: 271px
  1. Add scripts for initializing with turbolinks and xhr requests:
#= require ckeditor/loader
#= require ckeditor/plugins/codesnippet/lib/highlight/highlight.pack

$(document).bind 'turbolinks:before-cache ajax:beforeSend', ->
  return unless typeof(CKEDITOR) != 'undefined'
  for name of CKEDITOR.instances
    $(CKEDITOR.instances[name].editable().$).trigger('ckeditor:before-destroy')
    CKEDITOR.instances[name].destroy() if name?

$(document).bind 'turbolinks:load ajax:success', ->
  return unless typeof(CKEDITOR) != 'undefined'
  $('.js-ckeditor').each ->
    CKEDITOR.replace($(this).attr('id'))
  1. Add custom ckeditor/loader.js.erb:
//= require ckeditor/init

CKEDITOR.config.customConfig = '<%= javascript_path 'ckeditor/config.js' %>';
  1. Add custom ckeditor/config.coffee:

See the code.

Using

  1. Add js-ckeditor class to your textarea:
= f.text_area :text, class: 'form-control ui-input js-ckeditor', rows: 4

ckeditor's People

Contributors

galetahub avatar chewi avatar pupeno avatar gambala avatar fxposter avatar musaffa avatar bbenezech avatar maxgronlund avatar nuno84 avatar waynn avatar raffael-sfm avatar edslocomb avatar liubin avatar victor95pc avatar thiagoa avatar jcuervo avatar lenart avatar delwyn avatar davidstosik avatar arturtr avatar panasyuk avatar zhanglinjie avatar kelso avatar silviorelli avatar kaapa avatar pedrocss avatar chipiga avatar patricklindsay avatar stream7 avatar anfinil avatar

Stargazers

Dmitry avatar Maksym Dzhulii avatar Oksana avatar  avatar

Watchers

James Cloos avatar  avatar

Forkers

ahvahsky2008

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.