trix 0.10.0 → 0.11.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fd05f0b81cf9aae8d6c0d1f29431581fcbbf47ca
4
- data.tar.gz: f2dc048be340742b3463aa8b45987416e7dfa991
3
+ metadata.gz: 2ece98d65e59234a3f9d0ec7d73935f8d4d0b4f2
4
+ data.tar.gz: bc96359cfe7b562cc7c128b79b92f47206f7985a
5
5
  SHA512:
6
- metadata.gz: 5bec6aed655ce1e6202c826efd7356c339a60c455f7af5d1d40b52a38eb47cd10e3c91a86869ec568cb0c0e8b110a5639f644ecea9495cbdfd1c8b3057faa634
7
- data.tar.gz: 9a445c47c83b3647ea21d92df45c494d0c182459e4630b0897589e03a505936526334ac198b008c0521bbbe8c649067328648730fe2066e69bdb3e715f330fe8
6
+ metadata.gz: a321171c18443d9a262495a5fdedc3eb16292cbd1a56ff9a939c3f7a6ed21f8bf861e911ea968362878913b010644f83a62ee75251538b1409e828b03f2e0452
7
+ data.tar.gz: eab4fbb25c47d9dacc9ba464df93a34a31f2383c3dd4a073dafe178d5cc0efe2d0d94292946c3961923d49fff8a0d73fcb715a943fd0bfa885f9e5b4e09836b0
data/.gitignore CHANGED
@@ -7,3 +7,5 @@
7
7
  /pkg/
8
8
  /spec/reports/
9
9
  /tmp/
10
+ /gemfiles/*.gemfile.lock
11
+ .ruby-version
data/.rubocop_todo.yml CHANGED
@@ -1,6 +1,41 @@
1
+ # This configuration was generated by
2
+ # `rubocop --auto-gen-config`
3
+ # on 2017-07-16 12:30:37 -0300 using RuboCop version 0.35.1.
4
+ # The point is for the user to remove these configuration records
5
+ # one by one as the offenses are removed from the code base.
6
+ # Note that changes in the inspected code, or installation of new
7
+ # versions of RuboCop, may require this file to be generated again.
8
+
9
+ # Offense count: 1
1
10
  Metrics/AbcSize:
2
- Enabled: false
11
+ Max: 22
12
+
13
+ # Offense count: 10
14
+ # Configuration parameters: AllowURI, URISchemes.
3
15
  Metrics/LineLength:
4
- Max: 110
16
+ Max: 104
17
+
18
+ # Offense count: 1
19
+ # Configuration parameters: CountComments.
20
+ Metrics/MethodLength:
21
+ Max: 11
22
+
23
+ # Offense count: 10
24
+ # Configuration parameters: Exclude.
5
25
  Style/Documentation:
6
- Enabled: false
26
+ Exclude:
27
+ - 'spec/**/*'
28
+ - 'test/**/*'
29
+ - 'lib/formtastic/inputs/trix_editor_input.rb'
30
+ - 'lib/trix.rb'
31
+ - 'lib/trix/engine.rb'
32
+ - 'lib/trix/form.rb'
33
+ - 'lib/trix/simple_form/trix_editor_input.rb'
34
+ - 'lib/trix/version.rb'
35
+
36
+ # Offense count: 1
37
+ # Cop supports --auto-correct.
38
+ # Configuration parameters: PreferredDelimiters.
39
+ Style/PercentLiteralDelimiters:
40
+ Exclude:
41
+ - 'spec/trix_editor_helper_spec.rb'
data/.travis.yml CHANGED
@@ -1,10 +1,14 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.2.4
4
- - 2.3.0
3
+ - 2.2.7
4
+ - 2.3.4
5
+ - 2.4.1
5
6
  gemfile:
6
- - gemfiles/rails_4.0.gemfile
7
- - gemfiles/rails_4.1.gemfile
8
7
  - gemfiles/rails_4.2.gemfile
8
+ - gemfiles/rails_5.0.gemfile
9
+ - gemfiles/rails_5.1.gemfile
9
10
  - gemfiles/rails_master.gemfile
11
+ matrix:
12
+ allow_failures:
13
+ - gemfile: 'gemfiles/rails_master.gemfile'
10
14
  before_install: gem install bundler -v 1.11.2
data/Appraisals CHANGED
@@ -1,18 +1,19 @@
1
- appraise "rails-4.0" do
2
- gem "rails", "~> 4.0.0"
1
+ appraise "rails-4.2" do
2
+ gem "rails", "~> 4.2.0"
3
3
  end
4
4
 
5
- appraise "rails-4.1" do
6
- gem "rails", "~> 4.1.0"
5
+ appraise "rails-5.0" do
6
+ gem "rails", "~> 5.0.0"
7
7
  end
8
8
 
9
- appraise "rails-4.2" do
10
- gem "rails", "~> 4.2.0"
9
+ appraise "rails-5.1" do
10
+ gem "rails", "~> 5.1.0"
11
11
  end
12
12
 
13
13
  appraise "rails-master" do
14
14
  gem "rails", git: "https://github.com/rails/rails.git", branch: "master"
15
+ gem "arel", git: "https://github.com/rails/arel.git", branch: "master"
15
16
  %w[rspec-core rspec-expectations rspec-mocks rspec-rails rspec-support].each do |lib|
16
- gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'master'
17
+ gem lib, git: "https://github.com/rspec/#{lib}.git", branch: 'master'
17
18
  end
18
- end
19
+ end
data/README.md CHANGED
@@ -41,13 +41,12 @@ forms, just use the `trix_editor` helper:
41
41
  f.trix_editor :body
42
42
  ```
43
43
 
44
- Or if you are using the [formtastic](https://github.com/justinfrench/formtastic) gem:
44
+ If you are using the [Formtastic](https://github.com/justinfrench/formtastic) gem or the [Simple Form](https://github.com/plataformatec/simple_form) gem, you can do this:
45
45
 
46
46
  ```ruby
47
47
  f.input :body, as: :trix_editor
48
48
  ```
49
49
 
50
-
51
50
  ## Trix
52
51
 
53
52
  For the official Trix Github repository, go
data/Rakefile CHANGED
@@ -8,4 +8,4 @@ RSpec::Core::RakeTask.new(:spec)
8
8
  require 'rubocop/rake_task'
9
9
  RuboCop::RakeTask.new
10
10
 
11
- task default: [:rubocop, :spec]
11
+ task default: %i(rubocop spec)
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 4.0.0"
5
+ gem "rails", "~> 5.0.0"
6
6
 
7
7
  gemspec :path => "../"
@@ -2,6 +2,6 @@
2
2
 
3
3
  source "https://rubygems.org"
4
4
 
5
- gem "rails", "~> 4.1.0"
5
+ gem "rails", "~> 5.1.0"
6
6
 
7
7
  gemspec :path => "../"
@@ -3,6 +3,7 @@
3
3
  source "https://rubygems.org"
4
4
 
5
5
  gem "rails", :git => "https://github.com/rails/rails.git", :branch => "master"
6
+ gem "arel", :git => "https://github.com/rails/arel.git", :branch => "master"
6
7
  gem "rspec-core", :git => "https://github.com/rspec/rspec-core.git", :branch => "master"
7
8
  gem "rspec-expectations", :git => "https://github.com/rspec/rspec-expectations.git", :branch => "master"
8
9
  gem "rspec-mocks", :git => "https://github.com/rspec/rspec-mocks.git", :branch => "master"
@@ -2,8 +2,10 @@ class TrixEditorInput < Formtastic::Inputs::StringInput
2
2
  def to_html
3
3
  input_wrapping do
4
4
  editor_tag_params = {
5
- input: input_html_options[:id]
5
+ input: input_html_options[:id],
6
+ class: 'trix-content'
6
7
  }
8
+
7
9
  editor_tag = template.content_tag('trix-editor', '', editor_tag_params)
8
10
  hidden_field = builder.hidden_field(method, input_html_options)
9
11
 
data/lib/trix/engine.rb CHANGED
@@ -4,6 +4,14 @@ module Trix
4
4
  ActiveSupport.on_load(:action_view) do
5
5
  require 'trix/form'
6
6
  end
7
+
8
+ if defined? ::SimpleForm
9
+ require 'trix/simple_form/trix_editor_input'
10
+
11
+ ::SimpleForm.setup do |config|
12
+ config.custom_inputs_namespaces << 'Trix::SimpleForm'
13
+ end
14
+ end
7
15
  end
8
16
  end
9
17
  end
data/lib/trix/form.rb CHANGED
@@ -8,18 +8,18 @@ module TrixEditorHelper
8
8
  def trix_editor_tag(name, value = nil, options = {})
9
9
  options.symbolize_keys!
10
10
 
11
- attributes = { class: "formatted_content #{options[:class]}".squish }
12
-
11
+ css_class = Array.wrap(options[:class]).join(' ')
12
+ attributes = { class: "formatted_content trix-content #{css_class}".squish }
13
13
  attributes[:autofocus] = true if options[:autofocus]
14
- attributes[:placeholder] = options[:placeholder] if options[:placeholder]
15
- attributes[:spellcheck] = options[:spellcheck] if options[:spellcheck]
16
14
  attributes[:input] = options[:input] || "trix_input_#{TrixEditorHelper.id += 1}"
17
- attributes[:toolbar] = options[:toolbar] if options[:toolbar]
15
+
16
+ valid_html_options = [:placeholder, :spellcheck, :toolbar, :tabindex]
17
+ attributes.merge!(options.slice(*valid_html_options))
18
18
 
19
19
  editor_tag = content_tag('trix-editor', '', attributes)
20
20
  input_tag = hidden_field_tag(name, value, id: attributes[:input])
21
21
 
22
- editor_tag + input_tag
22
+ input_tag + editor_tag
23
23
  end
24
24
  end
25
25
 
@@ -0,0 +1,12 @@
1
+ module Trix
2
+ module SimpleForm
3
+ class TrixEditorInput < ::SimpleForm::Inputs::Base
4
+ def input(_wrapper_options)
5
+ editor_tag = template.content_tag('trix-editor', '', input: input_class, class: 'trix-content')
6
+ hidden_field = @builder.hidden_field(attribute_name, input_html_options)
7
+
8
+ template.content_tag('div', editor_tag + hidden_field, class: 'trix-editor-wrapper')
9
+ end
10
+ end
11
+ end
12
+ end
data/lib/trix/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Trix
2
- VERSION = '0.10.0'.freeze
2
+ VERSION = '0.11.0'.freeze
3
3
  end
data/trix.gemspec CHANGED
@@ -1,4 +1,5 @@
1
1
  # coding: utf-8
2
+
2
3
  lib = File.expand_path('../lib', __FILE__)
3
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
5
  require 'trix/version'
@@ -19,13 +20,14 @@ Gem::Specification.new do |spec|
19
20
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
21
  spec.require_paths = ['lib']
21
22
 
22
- spec.add_runtime_dependency 'rails'
23
+ spec.add_runtime_dependency 'rails', ['> 4.1', '< 5.2']
23
24
 
24
25
  spec.add_development_dependency 'appraisal'
25
26
  spec.add_development_dependency 'bundler', '~> 1.10'
26
27
  spec.add_development_dependency 'formtastic', '~> 3.0'
28
+ spec.add_development_dependency 'simple_form', '~> 3.5'
27
29
  spec.add_development_dependency 'rake', '~> 10.0'
28
30
  spec.add_development_dependency 'rspec-rails'
29
31
  spec.add_development_dependency 'rspec-activemodel-mocks'
30
- spec.add_development_dependency 'rubocop'
32
+ spec.add_development_dependency 'rubocop', '0.35.1'
31
33
  end