summernote-ext-addclass-rails 0.8.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 +7 -0
- data/.gitignore +19 -0
- data/CHANGELOG.md +7 -0
- data/Gemfile +4 -0
- data/LICENSE +21 -0
- data/MAINTAIN.md +30 -0
- data/README.md +96 -0
- data/Rakefile +6 -0
- data/lib/summernote-ext-addclass-rails.rb +14 -0
- data/lib/summernote-ext-addclass-rails/engine.rb +15 -0
- data/lib/summernote-ext-addclass-rails/railtie.rb +5 -0
- data/lib/summernote-ext-addclass-rails/version.rb +5 -0
- data/summernote-ext-addclass-rails.gemspec +28 -0
- data/vendor/assets/javascripts/summernote/summernote-ext-addclass.js +130 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 75ed5070c27773c1f598a6e86c3c50a540b1ee44
|
4
|
+
data.tar.gz: 21c3e2aaa39d3c2395b801ede1775d1b78f58665
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2254bf840614c2b618eb5ff3de049c3d0aca06fe5679d674a5a8aae9916fdfe79cdf804caa271734b63bfcbb9820910ab2820dafecc0fea7d614120ef3140153
|
7
|
+
data.tar.gz: 4e3de3de36cfee1792aff121abd060c9a86295eb9ca43e5ea5772cf32936e9dd6c2efeb0962142c7554fb024c1b24d5ddb87ccb67fa222b10e824b9f3eb9a888
|
data/.gitignore
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 Mohamed Ziata
|
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 all
|
13
|
+
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 THE
|
21
|
+
SOFTWARE.
|
data/MAINTAIN.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
## Publish new version
|
2
|
+
|
3
|
+
### 1. Update summernote assets
|
4
|
+
|
5
|
+
```bash
|
6
|
+
bundle exec rake update
|
7
|
+
```
|
8
|
+
// TODO : automation using rake
|
9
|
+
|
10
|
+
### 2. Update gem version number
|
11
|
+
|
12
|
+
Edit `lib/summernote-ext-addclass-rails/version.rb`
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
module SummernoteRails
|
16
|
+
module Rails
|
17
|
+
VERSION = x.y.0
|
18
|
+
end
|
19
|
+
end
|
20
|
+
```
|
21
|
+
|
22
|
+
### 3. Publish
|
23
|
+
|
24
|
+
Publish on rubygems
|
25
|
+
|
26
|
+
```bash
|
27
|
+
bundle exec rake release
|
28
|
+
```
|
29
|
+
|
30
|
+
this command git tagging and publish
|
data/README.md
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# summernote-ext-addclass-rails
|
2
|
+
|
3
|
+
The gemification of the summernote extension [summernote-addclass][summernote-addclass]
|
4
|
+
for Rails >= 3.1.
|
5
|
+
|
6
|
+
<p align="center">
|
7
|
+
<img src="https://cloud.githubusercontent.com/assets/954291/12879122/07e6edd0-ce2f-11e5-94f8-bd630fc7b07a.png" />
|
8
|
+
</p>
|
9
|
+
|
10
|
+
## Demo
|
11
|
+
|
12
|
+
Also, we have a [**live demo**][summernote-addclass-demo] (check the CSS3 icon button).
|
13
|
+
|
14
|
+
## Installation
|
15
|
+
|
16
|
+
Add the following gems to your application's `Gemfile`:
|
17
|
+
|
18
|
+
```ruby
|
19
|
+
gem 'bootstrap-sass' # required
|
20
|
+
gem 'summernote-rails' # required
|
21
|
+
gem 'summernote-ext-addclass-rails'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute on the terminal:
|
25
|
+
|
26
|
+
```sh
|
27
|
+
bundle install
|
28
|
+
```
|
29
|
+
|
30
|
+
## Usage
|
31
|
+
|
32
|
+
### JavaScript
|
33
|
+
|
34
|
+
In `app/assets/javascripts/application.js`, you should add in this order:
|
35
|
+
|
36
|
+
```js
|
37
|
+
//= require bootstrap
|
38
|
+
//= require summernote
|
39
|
+
//= require summernote/summernote-ext-addclass
|
40
|
+
```
|
41
|
+
|
42
|
+
### CoffeeScript
|
43
|
+
|
44
|
+
In `app/assets/javascripts/application.coffee`, you should add in this order:
|
45
|
+
|
46
|
+
```coffeescript
|
47
|
+
#= require bootstrap
|
48
|
+
#= require summernote
|
49
|
+
#= require summernote/summernote-ext-addclass
|
50
|
+
```
|
51
|
+
|
52
|
+
## Customization
|
53
|
+
|
54
|
+
```js
|
55
|
+
$('[data-provider="summernote"]').summernote({
|
56
|
+
addclass: {
|
57
|
+
debug: false,
|
58
|
+
classTags: [
|
59
|
+
{ title: 'My Special style', value: 'kappa-css'},
|
60
|
+
'text-muted',
|
61
|
+
'text-primary'
|
62
|
+
]
|
63
|
+
},
|
64
|
+
height: 300,
|
65
|
+
toolbar: [
|
66
|
+
// ['groupName', ['list-of-button']]
|
67
|
+
['style', ['style', 'addclass', 'clear']],
|
68
|
+
['misc', ['codeview', 'help']]
|
69
|
+
]
|
70
|
+
});
|
71
|
+
```
|
72
|
+
|
73
|
+
More information [**here**][summernote-addclass-wiki].
|
74
|
+
|
75
|
+
## Versioning
|
76
|
+
|
77
|
+
| Major | Minor | Current |
|
78
|
+
|:-------:|:-------:|:---------:|
|
79
|
+
| is the major of [summernote][summernote] | is the minor of [summernote][summernote] | is the vesion of this extension |
|
80
|
+
|
81
|
+
*Example:*
|
82
|
+
|
83
|
+
The compatible versions of this gem with [summernote][summernote] `v0.8.3` are:
|
84
|
+
|
85
|
+
- `summernote-ext-addclass-rails v0.8.X`
|
86
|
+
|
87
|
+
## License
|
88
|
+
|
89
|
+
[MIT][license]
|
90
|
+
|
91
|
+
|
92
|
+
[summernote]: https://github.com/summernote/summernote
|
93
|
+
[summernote-addclass]: https://github.com/creativeprogramming/summernote-addclass
|
94
|
+
[summernote-addclass-wiki]: https://github.com/creativeprogramming/summernote-addclass/wiki
|
95
|
+
[summernote-addclass-demo]: https://jsfiddle.net/rastrano/dtgr5q29/
|
96
|
+
[license]: ./LICENSE
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'rails'
|
2
|
+
require 'summernote-ext-addclass-rails/version'
|
3
|
+
|
4
|
+
autoload :SummernoteInput, 'summernote-ext-addclass-rails/simple_form/summernote_input'
|
5
|
+
|
6
|
+
module SummernoteRails
|
7
|
+
module Rails
|
8
|
+
if ::Rails.version.to_s < 3.1
|
9
|
+
require 'summernote-ext-addclass-rails/railtie'
|
10
|
+
else
|
11
|
+
require 'summernote-ext-addclass-rails/engine'
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module SummernoteExtAddclassRails
|
2
|
+
module Rails
|
3
|
+
class Engine < ::Rails::Engine
|
4
|
+
initializer 'summernote-ext-addclass-rails.assets.precompile' do |app|
|
5
|
+
if defined? Sprockets::Rails
|
6
|
+
# sprockets-rails 3 tracks down the calls to `font_path` and `image_path`
|
7
|
+
# and automatically precompiles the referenced assets.
|
8
|
+
unless Sprockets::Rails::VERSION.starts_with?('3')
|
9
|
+
app.config.assets.precompile << /\.(?:eot|woff|ttf)$/
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require File.expand_path('../lib/summernote-ext-addclass-rails/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = 'summernote-ext-addclass-rails'
|
6
|
+
spec.version = SummernoteExtAddclassRails::Rails::VERSION
|
7
|
+
spec.authors = ['Stefano Gargiulo', 'Mohamed Ziata']
|
8
|
+
spec.email = ['info@creativeprogramming.it']
|
9
|
+
spec.summary = %q{
|
10
|
+
Gemify the summernote extension called "summernote-addclass" for Rails >= 3.1
|
11
|
+
}
|
12
|
+
spec.description = %q{
|
13
|
+
This gem packages the extencion summernote-ext-addclass of Summernote editor
|
14
|
+
for Rails' assets pipeline
|
15
|
+
}
|
16
|
+
spec.homepage = 'https://github.com/WaKeMaTTa/summernote-ext-addclass-rails'
|
17
|
+
spec.license = 'MIT'
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
|
+
f.match(%r{^(test|spec|features)/})
|
21
|
+
end
|
22
|
+
spec.require_paths = ['lib']
|
23
|
+
|
24
|
+
spec.add_dependency 'railties', '>= 3.1'
|
25
|
+
|
26
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
27
|
+
spec.add_development_dependency 'rake'
|
28
|
+
end
|
@@ -0,0 +1,130 @@
|
|
1
|
+
/**
|
2
|
+
*
|
3
|
+
* copyright 2016 creativeprogramming.it di Stefano Gargiulo
|
4
|
+
* email: info@creativeprogramming.it
|
5
|
+
* accepting tips at https://www.paypal.me/creativedotit
|
6
|
+
* license: MIT
|
7
|
+
*
|
8
|
+
*/
|
9
|
+
(function (factory) {
|
10
|
+
/* global define */
|
11
|
+
if (typeof define === 'function' && define.amd) {
|
12
|
+
// AMD. Register as an anonymous module.
|
13
|
+
define(['jquery'], factory);
|
14
|
+
} else if (typeof module === 'object' && module.exports) {
|
15
|
+
// Node/CommonJS
|
16
|
+
module.exports = factory(require('jquery'));
|
17
|
+
} else {
|
18
|
+
// Browser globals
|
19
|
+
factory(window.jQuery);
|
20
|
+
}
|
21
|
+
}(function ($) {
|
22
|
+
|
23
|
+
// Extends plugins for adding hello.
|
24
|
+
// - plugin is external module for customizing.
|
25
|
+
$.extend($.summernote.plugins, {
|
26
|
+
/**
|
27
|
+
* @param {Object} context - context object has status of editor.
|
28
|
+
*/
|
29
|
+
'addclass': function (context) {
|
30
|
+
var self = this;
|
31
|
+
if (typeof context.options.addclass === 'undefined') {
|
32
|
+
context.options.addclass = {};
|
33
|
+
}
|
34
|
+
if (typeof context.options.addclass.classTags === 'undefined') {
|
35
|
+
context.options.addclass.classTags = ["jumbotron", "lead","img-rounded","img-circle", "img-responsive","btn", "btn btn-success","btn btn-danger","text-muted", "text-primary", "text-warning", "text-danger", "text-success", "table-bordered", "table-responsive", "alert", "alert alert-success", "alert alert-info", "alert alert-warning", "alert alert-danger", "visible-sm", "hidden-xs", "hidden-md", "hidden-lg", "hidden-print"];
|
36
|
+
// console.log("Please define your summernote.options.addclass.classTags array");
|
37
|
+
}
|
38
|
+
// ui has renders to build ui elements.
|
39
|
+
// - you can create a button with `ui.button`
|
40
|
+
var ui = $.summernote.ui;
|
41
|
+
|
42
|
+
addStyleString(".scrollable-menu {height: auto; max-height: 200px; max-width:300px; overflow-x: hidden;}");
|
43
|
+
|
44
|
+
context.memo('button.addclass', function () {
|
45
|
+
return ui.buttonGroup([
|
46
|
+
ui.button({
|
47
|
+
className: 'dropdown-toggle',
|
48
|
+
contents: '<i class="fa fa-css3"\/>' + ' ' + ui.icon(context.options.icons.caret, 'span'),
|
49
|
+
//ui.icon(context.options.icons.magic) + ' ' + ui.icon(context.options.icons.caret, 'span'),
|
50
|
+
tooltip: 'toggle CSS class', //lang.style.style,
|
51
|
+
data: {
|
52
|
+
toggle: 'dropdown'
|
53
|
+
}
|
54
|
+
}),
|
55
|
+
ui.dropdown({
|
56
|
+
className: 'dropdown-style scrollable-menu',
|
57
|
+
items: context.options.addclass.classTags,
|
58
|
+
template: function (item) {
|
59
|
+
|
60
|
+
if (typeof item === 'string') {
|
61
|
+
item = {tag: "div", title: item, value: item};
|
62
|
+
}
|
63
|
+
|
64
|
+
var tag = item.tag;
|
65
|
+
var title = item.title;
|
66
|
+
var style = item.style ? ' style="' + item.style + '" ' : '';
|
67
|
+
var cssclass = item.value ? ' class="' + item.value + '" ' : '';
|
68
|
+
|
69
|
+
|
70
|
+
return '<' + tag + ' ' + style + cssclass + '>' + title + '</' + tag + '>';
|
71
|
+
},
|
72
|
+
click: function (event, namespace, value) {
|
73
|
+
|
74
|
+
event.preventDefault();
|
75
|
+
value = value || $(event.target).closest('[data-value]').data('value');
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
var $node = $(context.invoke("restoreTarget"))
|
80
|
+
if ($node.length==0){
|
81
|
+
$node = $(document.getSelection().focusNode.parentElement, ".note-editable");
|
82
|
+
}
|
83
|
+
|
84
|
+
if (typeof context.options.addclass !== 'undefined' && typeof context.options.addclass.debug !== 'undefined' && context.options.addclass.debug) {
|
85
|
+
console.debug(context.invoke("restoreTarget"), $node, "toggling class: " + value, window.getSelection());
|
86
|
+
}
|
87
|
+
|
88
|
+
|
89
|
+
$node.toggleClass(value)
|
90
|
+
|
91
|
+
|
92
|
+
}
|
93
|
+
})
|
94
|
+
]).render();
|
95
|
+
return $optionList;
|
96
|
+
});
|
97
|
+
|
98
|
+
function addStyleString(str) {
|
99
|
+
var node = document.createElement('style');
|
100
|
+
node.innerHTML = str;
|
101
|
+
document.body.appendChild(node);
|
102
|
+
}
|
103
|
+
|
104
|
+
// This events will be attached when editor is initialized.
|
105
|
+
this.events = {
|
106
|
+
// This will be called after modules are initialized.
|
107
|
+
'summernote.init': function (we, e) {
|
108
|
+
//console.log('summernote initialized', we, e);
|
109
|
+
},
|
110
|
+
// This will be called when user releases a key on editable.
|
111
|
+
'summernote.keyup': function (we, e) {
|
112
|
+
// console.log('summernote keyup', we, e);
|
113
|
+
}
|
114
|
+
};
|
115
|
+
|
116
|
+
// This method will be called when editor is initialized by $('..').summernote();
|
117
|
+
// You can create elements for plugin
|
118
|
+
this.initialize = function () {
|
119
|
+
|
120
|
+
};
|
121
|
+
|
122
|
+
// This methods will be called when editor is destroyed by $('..').summernote('destroy');
|
123
|
+
// You should remove elements on `initialize`.
|
124
|
+
this.destroy = function () {
|
125
|
+
/* this.$panel.remove();
|
126
|
+
this.$panel = null; */
|
127
|
+
};
|
128
|
+
}
|
129
|
+
});
|
130
|
+
}));
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: summernote-ext-addclass-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stefano Gargiulo
|
8
|
+
- Mohamed Ziata
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2017-04-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: railties
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '3.1'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '3.1'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: bundler
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.3'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.3'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
description: "\n This gem packages the extencion summernote-ext-addclass of Summernote
|
57
|
+
editor\n for Rails' assets pipeline\n "
|
58
|
+
email:
|
59
|
+
- info@creativeprogramming.it
|
60
|
+
executables: []
|
61
|
+
extensions: []
|
62
|
+
extra_rdoc_files: []
|
63
|
+
files:
|
64
|
+
- ".gitignore"
|
65
|
+
- CHANGELOG.md
|
66
|
+
- Gemfile
|
67
|
+
- LICENSE
|
68
|
+
- MAINTAIN.md
|
69
|
+
- README.md
|
70
|
+
- Rakefile
|
71
|
+
- lib/summernote-ext-addclass-rails.rb
|
72
|
+
- lib/summernote-ext-addclass-rails/engine.rb
|
73
|
+
- lib/summernote-ext-addclass-rails/railtie.rb
|
74
|
+
- lib/summernote-ext-addclass-rails/version.rb
|
75
|
+
- summernote-ext-addclass-rails.gemspec
|
76
|
+
- vendor/assets/javascripts/summernote/summernote-ext-addclass.js
|
77
|
+
homepage: https://github.com/WaKeMaTTa/summernote-ext-addclass-rails
|
78
|
+
licenses:
|
79
|
+
- MIT
|
80
|
+
metadata: {}
|
81
|
+
post_install_message:
|
82
|
+
rdoc_options: []
|
83
|
+
require_paths:
|
84
|
+
- lib
|
85
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 2.6.11
|
98
|
+
signing_key:
|
99
|
+
specification_version: 4
|
100
|
+
summary: Gemify the summernote extension called "summernote-addclass" for Rails >=
|
101
|
+
3.1
|
102
|
+
test_files: []
|