Giter Site home page Giter Site logo

activeadmin_ckeditor5's Introduction

ActiveadminCkeditor

Rails activeadmin integrated CKEditor 5

Reference

CKEditor5

activeadmin

Installation

Add this line to your application's Gemfile:

gem 'activeadmin_ckeditor5'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install activeadmin_ckeditor5

Usage

ActiveAdmin.register Article do
#...
  form do |f|
    f.inputs 'Article' do
      f.input :title, label: 'title'
      f.input :content, as: :ckeditor, label: 'content'
    end
    actions
  end
#...
end

Define uploading route

  #config/routes.rb
  post :uploads, to: 'uploads#create'

Then define upload controller

class UploadsController < ApplicationController
  def create
    #TODO
  end
end

You will get a Can't verify CSRF token authenticity error when you uploading image

You can redefine csrf_meta_tag location

# config/initializers/active_admin_layout.rb
module AdminPageLayoutOverride
  def build_active_admin_head
    within head do
      # CKEditor simpleUpload components will use csrfToken, but can't find csrf_meta_tag when loading js
      # so the csrf_meta_tag is generated in advance here.
      text_node csrf_meta_tag
    end

    super
  end
end
ActiveAdmin::Views::Pages::Base.send :prepend, AdminPageLayoutOverride

Or skip verify authenticity token

class AdminUploadsController < AdminApplicationController
  skip_forgery_protection
  def create
    #TODO
  end
end

activeadmin_ckeditor5's People

Stargazers

MixSu avatar  avatar

Watchers

MixSu avatar

Forkers

john1228

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.