npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ckeditor5-build-rails

v18.0.1

Published

CKEditor 5 all in one package for Rails application.

Downloads

9

Readme

CKEditor 5 for Rails

Documentation

CKEditor 5 for Rails application

  • Base on @ckeditor/ckeditor5-build-classic.
  • Default config toolbars.
  • Upload image for Rails applicaiton (CSRF).
  • All-in one file (build/ckeditor.js) for using.

  • 基于 CKEditor 官方的 @ckeditor/ckeditor5-build-classic 实现;
  • 根据实践经验总结出的 Toolbar 配置,具体看图;
  • 上传支持 Rails 应用的(CSRF);
  • 使用需要一个文件即可 (build/ckeditor.js)

Quick start

Put build/ckeditor.js in your Rails application.

public
  js
    ckeditor.js
<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
    <%= csrf_meta_tags %>
    <%= stylesheet_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
    <script type="text/javascript" src="<%= asset_path("/js/ckeditor.js", skip_pipeline: true) %>"></script>
    ...
  </head>
</html>

In your JavaScript application:

# app/javascript/packs/index.js
document.addEventListener('turbolinks:load', () => {
  # Init CKEditor
  ClassicEditor.create(document.querySelector('.ckeditor'), {
    simpleUpload: { uploadUrl: '/uploads' },
  })
})

In your Rails controller:

# app/controllers/uploads_controller.rb
class UploadsController < ApplicationController
  # POST /uploads { upload: <File> }
  def create
    uploader = FileUploader.new
    uploader.store!(params[:upload])
    render json: { url: uploader.url }
  end
end

You need a CarrierWave Uploader:

# app/uploaders/file_uploader.rb
class FileUploader < BaseUploader
  def store_dir
    "uploads"
  end

  def filename
    "files/#{Time.now.strftime("%Y%m")}/#{secure_token}.#{file.extension}" if original_filename.present?
  end

  protected
    # Generate a random key like ActiveStoreage
    def secure_token
      return SecureRandom.base58(32) if model.nil?
      var = :"@#{mounted_as}_secure_token"
      model.instance_variable_get(var) || model.instance_variable_set(var, SecureRandom.base58(32))
    end
end

In your edit form:

<%= form_for @post do |f| %>
  <%= f.text_area :body, class: "ckeditor" %>
<% end %>