medium-editor-rails 2.1.0 → 2.2.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: a574a9857fee9f8142288ba6b5bb794fe64a904d
4
- data.tar.gz: 53370bfd3e12c17eab557825b436fedcafc5cb91
3
+ metadata.gz: 7dde5397c49e9ca83dbc11bf66e79b5b4345b057
4
+ data.tar.gz: 4488ea4ce630bbc1d36ed1619575901c8320ac7f
5
5
  SHA512:
6
- metadata.gz: 542c9aec7460f8c1bd10cac25f2b421cb944cabda1f3b43b45efa90d47c1f6b3cbf0e2273625936b763b1f9a3b798e73f3097c9f088719ade2eb4e97bdcc9a97
7
- data.tar.gz: f6fe0b2c151a1b12ab8978f25a914d2a40d300cfb081ad7c8affbd233ee853ed87101215837d673e1d86dc7131c59341c57489545c48e713debd92b1811c8430
6
+ metadata.gz: d8a38f3ba2fccfee0bb0ff99c535b79fe7b424d6500cba782a6620d437ad9bfb1b3b75a355d91606a9f83a8a9e0dbe3c6f627288669a81fb87b69d8bec2cc064
7
+ data.tar.gz: 155235c9e6b70b6ef7ff2138f29fda2fc98146b3dc66bae2904bc3a0f373cb44697a8dcb5313201fc6dd7e2e55f1ccef34bf71f52b17b3814c274dd50bf29850
data/README.md CHANGED
@@ -4,11 +4,11 @@
4
4
  [![Code Climate](https://codeclimate.com/github/marjinal1st/medium-editor-rails.png)](https://codeclimate.com/github/marjinal1st/medium-editor-rails)
5
5
  [![Dependency Status](https://gemnasium.com/marjinal1st/medium-editor-rails.svg)](https://gemnasium.com/marjinal1st/medium-editor-rails)
6
6
 
7
- This gem integrates [Medium Editor](https://github.com/daviferreira/medium-editor) with Rails asset pipeline.
7
+ This gem integrates [Medium Editor](https://github.com/yabwe/medium-editor) with Rails asset pipeline.
8
8
 
9
9
  ## Version
10
10
 
11
- The latest version of Medium Editor bundled by this gem is [5.14.4](https://github.com/daviferreira/medium-editor/releases)
11
+ The latest version of Medium Editor bundled by this gem is [5.14.4](https://github.com/yabwe/medium-editor/releases)
12
12
 
13
13
  ## Installation
14
14
 
@@ -1,6 +1,6 @@
1
1
  module MediumEditorRails
2
2
  module Rails
3
- VERSION = '2.1.0'
4
- MEDIUM_EDITOR_VERSION = '5.14.4'
3
+ VERSION = '2.2.0'
4
+ MEDIUM_EDITOR_VERSION = '5.15.0'
5
5
  end
6
6
  end
@@ -6,9 +6,9 @@ require 'medium-editor-rails/version'
6
6
  Gem::Specification.new do |gem|
7
7
  gem.name = 'medium-editor-rails'
8
8
  gem.version = MediumEditorRails::Rails::VERSION
9
- gem.authors = ['Ahmet Sezgin Duran']
10
- gem.email = ['marjinalist1@gmail.com']
11
- gem.summary = %q{Medium Editor integrated in Rails asset pipeline}
9
+ gem.authors = ['Ahmet Sezgin Duran', 'Gabriel Medina']
10
+ gem.email = ['marjinalist1@gmail.com', 'gmedina.santos@gmail.com']
11
+ gem.summary = %q{Metdium Editor integrated in Rails asset pipeline}
12
12
  gem.description = gem.summary
13
13
  gem.homepage = 'https://github.com/marjinal1st/medium-editor-rails'
14
14
  gem.license = 'MIT'
@@ -2354,6 +2354,20 @@ MediumEditor.extensions = {};
2354
2354
  return range;
2355
2355
  },
2356
2356
 
2357
+ /**
2358
+ * Clear the current highlighted selection and set the caret to the start or the end of that prior selection, defaults to end.
2359
+ *
2360
+ * @param {DomDocument} doc Current document
2361
+ * @param {boolean} moveCursorToStart A boolean representing whether or not to set the caret to the beginning of the prior selection.
2362
+ */
2363
+ clearSelection: function (doc, moveCursorToStart) {
2364
+ if (moveCursorToStart) {
2365
+ doc.getSelection().collapseToStart();
2366
+ } else {
2367
+ doc.getSelection().collapseToEnd();
2368
+ }
2369
+ },
2370
+
2357
2371
  /**
2358
2372
  * Move cursor to the given node with the given offset.
2359
2373
  *
@@ -3409,6 +3423,11 @@ MediumEditor.extensions = {};
3409
3423
  formSaveLabel: '✓',
3410
3424
  formCloseLabel: '×',
3411
3425
 
3426
+ /* activeClass: [string]
3427
+ * set class which added to shown form
3428
+ */
3429
+ activeClass: 'medium-editor-toolbar-form-active',
3430
+
3412
3431
  /* hasForm: [boolean]
3413
3432
  *
3414
3433
  * Setting this to true will cause getForm() to be called
@@ -3431,14 +3450,34 @@ MediumEditor.extensions = {};
3431
3450
  * This function should return true/false reflecting
3432
3451
  * whether the form is currently displayed
3433
3452
  */
3434
- isDisplayed: function () {},
3453
+ isDisplayed: function () {
3454
+ if (this.hasForm) {
3455
+ return this.getForm().classList.contains(this.activeClass);
3456
+ }
3457
+ return false;
3458
+ },
3459
+
3460
+ /* hideForm: [function ()]
3461
+ *
3462
+ * This function should show the form element inside
3463
+ * the toolbar container
3464
+ */
3465
+ showForm: function () {
3466
+ if (this.hasForm) {
3467
+ this.getForm().classList.add(this.activeClass);
3468
+ }
3469
+ },
3435
3470
 
3436
3471
  /* hideForm: [function ()]
3437
3472
  *
3438
3473
  * This function should hide the form element inside
3439
3474
  * the toolbar container
3440
3475
  */
3441
- hideForm: function () {},
3476
+ hideForm: function () {
3477
+ if (this.hasForm) {
3478
+ this.getForm().classList.remove(this.activeClass);
3479
+ }
3480
+ },
3442
3481
 
3443
3482
  /************************ Helpers ************************
3444
3483
  * The following are helpers that are either set by MediumEditor
@@ -3627,11 +3666,11 @@ MediumEditor.extensions = {};
3627
3666
 
3628
3667
  // Used by medium-editor when the default toolbar is to be displayed
3629
3668
  isDisplayed: function () {
3630
- return this.getForm().style.display === 'block';
3669
+ return MediumEditor.extensions.form.prototype.isDisplayed.apply(this);
3631
3670
  },
3632
3671
 
3633
3672
  hideForm: function () {
3634
- this.getForm().style.display = 'none';
3673
+ MediumEditor.extensions.form.prototype.hideForm.apply(this);
3635
3674
  this.getInput().value = '';
3636
3675
  },
3637
3676
 
@@ -3651,7 +3690,7 @@ MediumEditor.extensions = {};
3651
3690
 
3652
3691
  this.base.saveSelection();
3653
3692
  this.hideToolbarDefaultActions();
3654
- this.getForm().style.display = 'block';
3693
+ MediumEditor.extensions.form.prototype.showForm.apply(this);
3655
3694
  this.setToolbarPosition();
3656
3695
 
3657
3696
  input.value = opts.url;
@@ -4125,9 +4164,20 @@ MediumEditor.extensions = {};
4125
4164
  this.document.execCommand('AutoUrlDetect', false, false);
4126
4165
  },
4127
4166
 
4167
+ isLastInstance: function () {
4168
+ var activeInstances = 0;
4169
+ for (var i = 0; i < this.window._mediumEditors.length; i++) {
4170
+ var editor = this.window._mediumEditors[i];
4171
+ if (editor !== null && editor.getExtensionByName('autoLink') !== undefined) {
4172
+ activeInstances++;
4173
+ }
4174
+ }
4175
+ return activeInstances === 1;
4176
+ },
4177
+
4128
4178
  destroy: function () {
4129
4179
  // Turn AutoUrlDetect back on
4130
- if (this.document.queryCommandSupported('AutoUrlDetect')) {
4180
+ if (this.document.queryCommandSupported('AutoUrlDetect') && this.isLastInstance()) {
4131
4181
  this.document.execCommand('AutoUrlDetect', false, true);
4132
4182
  }
4133
4183
  },
@@ -7104,7 +7154,7 @@ MediumEditor.parseVersionString = function (release) {
7104
7154
 
7105
7155
  MediumEditor.version = MediumEditor.parseVersionString.call(this, ({
7106
7156
  // grunt-bump looks for this:
7107
- 'version': '5.14.4'
7157
+ 'version': '5.15.0'
7108
7158
  }).version);
7109
7159
 
7110
7160
  return MediumEditor;
@@ -198,6 +198,9 @@
198
198
  margin: 0 10px;
199
199
  text-decoration: none; }
200
200
 
201
+ .medium-editor-toolbar-form-active {
202
+ display: block; }
203
+
201
204
  .medium-editor-toolbar-actions:after {
202
205
  clear: both;
203
206
  content: "";
metadata CHANGED
@@ -1,14 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: medium-editor-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 2.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmet Sezgin Duran
8
+ - Gabriel Medina
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2016-03-16 00:00:00.000000000 Z
12
+ date: 2016-03-24 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: railties
@@ -38,9 +39,10 @@ dependencies:
38
39
  - - "~>"
39
40
  - !ruby/object:Gem::Version
40
41
  version: '1.0'
41
- description: Medium Editor integrated in Rails asset pipeline
42
+ description: Metdium Editor integrated in Rails asset pipeline
42
43
  email:
43
44
  - marjinalist1@gmail.com
45
+ - gmedina.santos@gmail.com
44
46
  executables: []
45
47
  extensions: []
46
48
  extra_rdoc_files: []
@@ -95,5 +97,5 @@ rubyforge_project:
95
97
  rubygems_version: 2.6.1
96
98
  signing_key:
97
99
  specification_version: 4
98
- summary: Medium Editor integrated in Rails asset pipeline
100
+ summary: Metdium Editor integrated in Rails asset pipeline
99
101
  test_files: []