activeadmin_ckeditor5 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a5a7fd340d3e084dd71d0f9b4b88d71c4fa5505b9c4a97acc745829eb8b40e48
4
+ data.tar.gz: a4ee062638a26c8dc37a3a1f84603ade5fc06ac9b8b8d7a40a6505bef32734dd
5
+ SHA512:
6
+ metadata.gz: '09275daa69176302f3f2bfc5e3ae79adf3253259e3bb2f8b3e72a72d92b0c0d89230636bb503756ac2c80af37d045539b8d07195438ed7ab3cee4926d4b4a53c'
7
+ data.tar.gz: 64909501835fec9bed8c41a2820b89533e5a1fe51949ac7502777104a0988935ef386151850be8b8f27f3d06172777bdfe88aa337556dac5af1e2553d3e6c7a9
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-01-06
4
+
5
+ - Initial release
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 MingXuanSu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ ## ActiveadminCkeditor
2
+
3
+ Rails [activeadmin](https://github.com/activeadmin/activeadmin) integrated [CKEditor 5](https://ckeditor.com/docs/ckeditor5/latest/installation/index.html)
4
+ ### Reference
5
+
6
+ [CKEditor5](https://github.com/SuMingXuan/ckeditor5-build-classic-for-rails/blob/master/build/ckeditor.js)
7
+
8
+ [activeadmin](https://github.com/activeadmin/activeadmin)
9
+
10
+ ### Installation
11
+
12
+ Add this line to your application's Gemfile:
13
+
14
+ ```ruby
15
+ gem 'activeadmin_ckeditor5'
16
+ ```
17
+
18
+ And then execute:
19
+
20
+ $ bundle install
21
+
22
+ Or install it yourself as:
23
+
24
+ $ gem install activeadmin_ckeditor5
25
+
26
+ ### Usage
27
+
28
+ ```ruby
29
+ ActiveAdmin.register Article do
30
+ #...
31
+ form do |f|
32
+ f.inputs 'Article' do
33
+ f.input :title, label: 'title'
34
+ f.input :content, as: :ckeditor, label: 'content'
35
+ end
36
+ actions
37
+ end
38
+ #...
39
+ end
40
+ ```
41
+
42
+ Define uploading route
43
+
44
+ ```ruby
45
+ #config/routes.rb
46
+ post :uploads, to: 'uploads#create'
47
+ ```
48
+
49
+ Then define upload controller
50
+
51
+ ```ruby
52
+ class UploadsController < ApplicationController
53
+ def create
54
+ #TODO
55
+ end
56
+ end
57
+ ```
58
+
59
+
60
+ You will get a `Can't verify CSRF token authenticity` error when you uploading image
61
+
62
+ You can redefine `csrf_meta_tag` location
63
+
64
+ ```ruby
65
+ # config/initializers/active_admin_layout.rb
66
+ module AdminPageLayoutOverride
67
+ def build_active_admin_head
68
+ within head do
69
+ # CKEditor simpleUpload components will use csrfToken, but can't find csrf_meta_tag when loading js
70
+ # so the csrf_meta_tag is generated in advance here.
71
+ text_node csrf_meta_tag
72
+ end
73
+
74
+ super
75
+ end
76
+ end
77
+ ActiveAdmin::Views::Pages::Base.send :prepend, AdminPageLayoutOverride
78
+ ```
79
+
80
+ Or skip verify authenticity token
81
+
82
+ ```ruby
83
+ class AdminUploadsController < AdminApplicationController
84
+ skip_forgery_protection
85
+ def create
86
+ #TODO
87
+ end
88
+ end
89
+ ```
90
+
91
+
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/activeadmin/ckeditor/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "activeadmin_ckeditor5"
7
+ spec.version = Activeadmin::Ckeditor::VERSION
8
+ spec.authors = ["MingXuanSu"]
9
+ spec.email = ["ohmyhysss@gmail.com"]
10
+
11
+ spec.summary = "Rails activeadmin integrated CKEditor 5"
12
+ spec.description = "Rails activeadmin integrated CKEditor 5"
13
+ spec.homepage = "https://github.com/SuMingXuan/activeadmin_ckeditor5"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.4.0"
16
+
17
+
18
+ spec.metadata["homepage_uri"] = spec.homepage
19
+ spec.metadata["source_code_uri"] = "https://github.com/SuMingXuan/activeadmin_ckeditor5"
20
+
21
+ # Specify which files should be added to the gem when it is released.
22
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
24
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
25
+ end
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ # Uncomment to register a new dependency of your gem
31
+ # spec.add_dependency "example-gem", "~> 1.0"
32
+
33
+ # For more information and examples about making a new gem, checkout our
34
+ # guide at: https://bundler.io/guides/creating_gem.html
35
+ end
@@ -0,0 +1,12 @@
1
+ //= require ./ckeditor
2
+
3
+ (function () {
4
+ function initCkeditors() {
5
+ ClassicEditor.create(
6
+ document.querySelector("[data-activeadmin-ckcontent]")
7
+ );
8
+ }
9
+ $(document).ready(initCkeditors);
10
+ $(document).on("has_many_add:after", ".has_many_container", initCkeditors);
11
+ $(document).on("turbolinks:load", initCkeditors);
12
+ })();