morrigan_editor_rails 0.0.12 → 0.0.13

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 213aa860f47ef0f027b88399c86ced7e7abe7f79
4
- data.tar.gz: ea4af3ee1d455306dc5561bc45a7ec5f070f8839
3
+ metadata.gz: 45b15d3ca9d70fbce311f65c661b4e99b33216d8
4
+ data.tar.gz: c2d8ddebccdb8183f61f27037b8a8dd6e866aa11
5
5
  SHA512:
6
- metadata.gz: 58110fcf076585a0b158c13ad7e811f0bbeaf816e5e49092572a167c4e7bd1a06e2b7a02c39936dc935bc633a93efd0eaf861ec780ced8056a54c553e8135573
7
- data.tar.gz: f11a04972efab0ccd8927b5dcef6a0e3d6940ca336a5ef69d79015df3d41bbdb7a00d988aea19fb0b810bba2454f13260ae47dc3a73a31fea2f3413fce3f6496
6
+ metadata.gz: 632c57ed9043d8ca283042eb1c0732f7011bc1e412349ea88c014e232b86a5883d5c21ffaf6cc9c7a20f7d0ec2a555df282050b3ff1f738105152fb96170f4f1
7
+ data.tar.gz: 222dea1317b95f43f5f0c301bf99d3f8d54bc24f87374740ad24ef75b3a92c6f08ec60279e14bbab28d3a7340a56a60d22e4cbe07128cd6854e0b465a07eb940
data/README.md CHANGED
@@ -1,3 +1,71 @@
1
1
  # Morrigan Editor for Ruby on Rails
2
2
 
3
- During development.
3
+ ## Installation
4
+ 1. Add it to your `Gemfile`:
5
+
6
+ ```ruby
7
+ gem 'morrigan_editor_rails'
8
+ ```
9
+ 2. Add to `routes.rb`:
10
+
11
+ ```ruby
12
+ mount MorriganEditorRails::Engine => "/morrigan_editor_rails"
13
+ ```
14
+ 3. Create table for editor's uploaded images:
15
+
16
+ ```bash
17
+ rake morrigan_editor_rails:install:migrations
18
+ rake db:migrate
19
+ ```
20
+ 4. Add to `application.js`:
21
+
22
+ ```ruby
23
+ //= require 'morrigan_editor_rails/application'
24
+ ```
25
+ 5. Add to 'application.css':
26
+
27
+ ```ruby
28
+ *= require 'morrigan_editor_rails/application.css'
29
+ ```
30
+
31
+ ## Usage
32
+ Add to your HTML:
33
+ ```html
34
+ <div morrigan-editor="true" id="editor" editor-width="100%" editor-height="300px" editor-bound-textarea="#textarea"></div>
35
+ ```
36
+ where `editor-bound-textarea` attribute is contains of selector of bound textarea (generated in editor html code will be passed in this textarea before form submit).
37
+
38
+ ## Custom stylesheet
39
+ To add custom stylesheet to editor:
40
+
41
+ 1. Add initializer `morrigan_editor.rb` with next code:
42
+
43
+ ```ruby
44
+ module MorriganEditorRails
45
+ class Engine < Rails::Engine
46
+ config.iframe_css_file_name = 'your_file_name.css'
47
+ end
48
+ end
49
+ ```
50
+ 2. Add initializer `assets.rb` with next code (or add next code to this file if it is exists):
51
+
52
+ ```ruby
53
+ Rails.application.config.assets.precompile += %w( your_file_name.css )
54
+ ```
55
+
56
+ ## Custom uploader
57
+ You can use your uploader by put it in initializers with `MorriganEditorImageUploader` class name:
58
+
59
+ ```ruby
60
+ class MorriganEditorImageUploader < CarrierWave::Uploader::Base
61
+ # your code here
62
+ end
63
+ ```
64
+
65
+ ## Sanitization
66
+ ```ruby
67
+ MorriganEditorRails::Editor.sanitize(html)
68
+ ```
69
+
70
+ ## License
71
+ © 2014 Sergey Sokolov. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file.
@@ -10,7 +10,7 @@ $.widget( "morrigan.morrigan_editor", {
10
10
  spellCheck: true,
11
11
  toolbox: [
12
12
  [
13
- ['format'],
13
+ ['format', 'clearFormat'],
14
14
  ['bold', 'italy', 'strike'],
15
15
  ['img', 'video'],
16
16
  ['alignLeft', 'alignCenter', 'alignRight'],
@@ -56,6 +56,40 @@ $.widget( "morrigan.morrigan_editor", {
56
56
  _options: {},
57
57
 
58
58
  _actions: {
59
+ clearFormat: {
60
+ name: 'clearFormat',
61
+ view: {
62
+ activeBackground: '#aaa',
63
+ inactiveBackground: '#eee',
64
+ title: 'Clear format',
65
+ classes: 'fa fa-times'
66
+ },
67
+ onClickHandler: function (editor, action) {
68
+ var normalizeBlocks = function (element) {
69
+ if (element.nodeName == 'UL' || element.nodeName == 'OL') {
70
+ removeInlineStyles(element);
71
+ } else {
72
+ var text = $(element).text();
73
+ $(element).replaceWith('<p>' + text + '</p>');
74
+ }
75
+ };
76
+ var removeInlineStyles = function (element) {
77
+ $(element).removeAttr('style');
78
+ $(element).children().each(function() {
79
+ removeInlineStyles(this);
80
+ });
81
+ };
82
+ var cSelection = editor._selectionManager.getCustomSelection();
83
+ var isCaret = editor._selectionManager.isCaret(cSelection);
84
+ var topElements = editor._selectionManager.getTopSelectedElements(cSelection, isCaret);
85
+ var topElementsWithoutBlocks = $(topElements).filter(function () {
86
+ return !$(this).hasClass('mrge-content-block');
87
+ });
88
+ topElementsWithoutBlocks.each(function () {
89
+ normalizeBlocks(this);
90
+ });
91
+ }
92
+ },
59
93
  video: {
60
94
  name: 'video',
61
95
  view: {
@@ -1447,5 +1481,4 @@ $.widget( "morrigan.morrigan_editor", {
1447
1481
  return contentClone.html();
1448
1482
  }
1449
1483
  }
1450
-
1451
1484
  });
@@ -1,5 +1,5 @@
1
1
  body.mrge-iframe-body {
2
- white-space: pre-line; /* CSS 3.0 */
2
+ /*white-space: pre-line; *//* CSS 3.0 */
3
3
  word-wrap: break-word; /* IE 5+ */
4
4
  padding: 10px;
5
5
  }
@@ -1,3 +1,3 @@
1
1
  module MorriganEditorRails
2
- VERSION = '0.0.12'
2
+ VERSION = '0.0.13'
3
3
  end
@@ -12279,3 +12279,51 @@ Started GET "/assets/editor_iframe.css" for 127.0.0.1 at 2014-08-18 13:33:50 +04
12279
12279
 
12280
12280
 
12281
12281
  Started GET "/assets/fontawesome-webfont.woff" for 127.0.0.1 at 2014-08-18 13:33:50 +0400
12282
+
12283
+
12284
+ Started GET "/" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12285
+ Processing by TestController#index as HTML
12286
+ Rendered test/index.html.erb within layouts/application (1.8ms)
12287
+ Completed 200 OK in 6ms (Views: 6.2ms | ActiveRecord: 0.0ms)
12288
+
12289
+
12290
+ Started GET "/assets/editor_iframe.css?body=1" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12291
+
12292
+
12293
+ Started GET "/assets/morrigan_editor_rails/morrigan-jquery-editor.css?body=1" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12294
+
12295
+
12296
+ Started GET "/assets/font-awesome.css?body=1" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12297
+
12298
+
12299
+ Started GET "/assets/morrigan_editor_rails/application.css?body=1" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12300
+
12301
+
12302
+ Started GET "/assets/application.css?body=1" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12303
+
12304
+
12305
+ Started GET "/assets/jquery.js?body=1" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12306
+
12307
+
12308
+ Started GET "/assets/jquery-ui/core.js?body=1" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12309
+
12310
+
12311
+ Started GET "/assets/jquery-ui/widget.js?body=1" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12312
+
12313
+
12314
+ Started GET "/assets/morrigan_editor_rails/main.js?body=1" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12315
+
12316
+
12317
+ Started GET "/assets/morrigan_editor_rails/morrigan-jquery-editor.js?body=1" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12318
+
12319
+
12320
+ Started GET "/assets/morrigan_editor_rails/application.js?body=1" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12321
+
12322
+
12323
+ Started GET "/assets/application.js?body=1" for 127.0.0.1 at 2014-12-21 14:22:26 +0400
12324
+
12325
+
12326
+ Started GET "/assets/editor_iframe.css" for 127.0.0.1 at 2014-12-21 14:22:27 +0400
12327
+
12328
+
12329
+ Started GET "/assets/fontawesome-webfont.woff" for 127.0.0.1 at 2014-12-21 14:22:27 +0400
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: morrigan_editor_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergey Sokolov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-18 00:00:00.000000000 Z
11
+ date: 2014-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -199,7 +199,6 @@ files:
199
199
  - test/dummy/public/uploads/morrigan_editor_rails/editor_image/image/4/22129_b.jpeg
200
200
  - test/dummy/public/uploads/morrigan_editor_rails/editor_image/image/5/22129_b.jpeg
201
201
  - test/dummy/public/uploads/morrigan_editor_rails/editor_image/image/6/22129_b.jpeg
202
- - test/dummy/tmp/pids/server.pid
203
202
  - test/integration/navigation_test.rb
204
203
  - test/morrigan_editor_rails_test.rb
205
204
  - test/test_helper.rb
@@ -258,7 +257,6 @@ test_files:
258
257
  - test/dummy/public/uploads/morrigan_editor_rails/editor_image/image/4/22129_b.jpeg
259
258
  - test/dummy/public/500.html
260
259
  - test/dummy/Rakefile
261
- - test/dummy/tmp/pids/server.pid
262
260
  - test/dummy/bin/rails
263
261
  - test/dummy/bin/rake
264
262
  - test/dummy/bin/bundle
@@ -1 +0,0 @@
1
- 8964