medium-editor-rails 0.8.0 → 0.9.0

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: c733d77c3745960169613a029d7f9bbc675b21ae
4
- data.tar.gz: 2b3d08541f21c65ba1cc5551a7cf01bdccbe3167
3
+ metadata.gz: ca3c5a67bdf9a7e031605174b1f6e8e21e33c5e7
4
+ data.tar.gz: 34354ac8e82fc28410759f143a7a4841e8fb11ad
5
5
  SHA512:
6
- metadata.gz: ae76fe9f412d723b6b7b1645501067aa87be9fefc84da9f265ad0c82d2c014e8e3b71979ec9e1e020855b214f19130f8df87714e96d23b7844de344f1a8d14f4
7
- data.tar.gz: 4e819110c8fad3e1a4fd2df083a5d322a601c5e730d164a2adb44e82fb7e5c88d632823cb4fdf5b68fde69684dd6a8e981a2ea014a027fd2d63dc3401bda863b
6
+ metadata.gz: e0b48b045340e3edeb01bff8c87c35fd1085c9577b4adf9c6c9de1aba4ba951fa4bc7f6701ead472384fdc38ab94489ab4dd1a3510f4d09b283a0f1809015cc7
7
+ data.tar.gz: cb923bb2e00562718cfcc048c498dee4c866b81de940cc44ca46dd6da4bf369d81b1e7299950f110b52cb52cde7c2f07587afa30056e17c97df81d7df96ef913
@@ -1,5 +1,9 @@
1
1
 
2
2
  #### [Current]
3
+ * [e5c7084](../../commit/e5c7084) - __(Ahmet Sezgin Duran)__ Update Medium Editor files
4
+
5
+ #### 0.8.0
6
+ * [49bc574](../../commit/49bc574) - __(Ahmet Sezgin Duran)__ Bump versions 0.8.0 and 1.8.0
3
7
  * [fe79879](../../commit/fe79879) - __(Ahmet Sezgin Duran)__ Update Medium Editor files
4
8
 
5
9
  #### 0.7.0
data/README.md CHANGED
@@ -7,7 +7,7 @@ This gem integrates [Medium Editor](https://github.com/daviferreira/medium-edito
7
7
 
8
8
  ## Version
9
9
 
10
- The latest version of Medium Editor bundled by this gem is [1.8.0](https://github.com/daviferreira/medium-editor/releases)
10
+ The latest version of Medium Editor bundled by this gem is [1.8.5](https://github.com/daviferreira/medium-editor/releases)
11
11
 
12
12
  ## Installation
13
13
 
@@ -1,6 +1,6 @@
1
1
  module MediumEditorRails
2
2
  module Rails
3
- VERSION = '0.8.0'
4
- MEDIUM_EDITOR_VERSION = '1.8.0'
3
+ VERSION = '0.9.0'
4
+ MEDIUM_EDITOR_VERSION = '1.8.5'
5
5
  end
6
6
  end
@@ -105,6 +105,8 @@ if (typeof module === 'object') {
105
105
  disableReturn: false,
106
106
  disableDoubleReturn: false,
107
107
  disableToolbar: false,
108
+ disableEditing: false,
109
+ elementsContainer: false,
108
110
  firstHeader: 'h3',
109
111
  forcePlainText: true,
110
112
  placeholder: 'Type your text',
@@ -118,10 +120,7 @@ if (typeof module === 'object') {
118
120
  isIE: ((navigator.appName === 'Microsoft Internet Explorer') || ((navigator.appName === 'Netscape') && (new RegExp('Trident/.*rv:([0-9]{1,}[.0-9]{0,})').exec(navigator.userAgent) !== null))),
119
121
 
120
122
  init: function (elements, options) {
121
- this.elements = typeof elements === 'string' ? document.querySelectorAll(elements) : elements;
122
- if (this.elements.nodeType === 1) {
123
- this.elements = [this.elements];
124
- }
123
+ this.setElementSelection(elements);
125
124
  if (this.elements.length === 0) {
126
125
  return;
127
126
  }
@@ -141,10 +140,13 @@ if (typeof module === 'object') {
141
140
  },
142
141
 
143
142
  initElements: function () {
143
+ this.updateElementList();
144
144
  var i,
145
145
  addToolbar = false;
146
146
  for (i = 0; i < this.elements.length; i += 1) {
147
- this.elements[i].setAttribute('contentEditable', true);
147
+ if (!this.options.disableEditing && !this.elements[i].getAttribute('data-disable-editing')) {
148
+ this.elements[i].setAttribute('contentEditable', true);
149
+ }
148
150
  if (!this.elements[i].getAttribute('data-placeholder')) {
149
151
  this.elements[i].setAttribute('data-placeholder', this.options.placeholder);
150
152
  }
@@ -156,6 +158,9 @@ if (typeof module === 'object') {
156
158
  }
157
159
  // Init toolbar
158
160
  if (addToolbar) {
161
+ if (!this.options.elementsContainer) {
162
+ this.options.elementsContainer = document.body;
163
+ }
159
164
  this.initToolbar()
160
165
  .bindButtons()
161
166
  .bindAnchorForm()
@@ -164,6 +169,18 @@ if (typeof module === 'object') {
164
169
  return this;
165
170
  },
166
171
 
172
+ setElementSelection: function (selector) {
173
+ this.elementSelection = selector;
174
+ this.updateElementList();
175
+ },
176
+
177
+ updateElementList: function () {
178
+ this.elements = typeof this.elementSelection === 'string' ? document.querySelectorAll(this.elementSelection) : this.elementSelection;
179
+ if (this.elements.nodeType === 1) {
180
+ this.elements = [this.elements];
181
+ }
182
+ },
183
+
167
184
  serialize: function () {
168
185
  var i,
169
186
  elementid,
@@ -369,7 +386,7 @@ if (typeof module === 'object') {
369
386
  toolbar.className = 'medium-editor-toolbar';
370
387
  toolbar.appendChild(this.toolbarButtons());
371
388
  toolbar.appendChild(this.toolbarFormAnchor());
372
- document.body.appendChild(toolbar);
389
+ this.options.elementsContainer.appendChild(toolbar);
373
390
  return toolbar;
374
391
  },
375
392
 
@@ -782,20 +799,20 @@ if (typeof module === 'object') {
782
799
  },
783
800
 
784
801
  // TODO: break method
785
- showAnchorPreview: function (anchor_el) {
802
+ showAnchorPreview: function (anchorEl) {
786
803
  if (this.anchorPreview.classList.contains('medium-editor-anchor-preview-active')) {
787
804
  return true;
788
805
  }
789
806
 
790
807
  var self = this,
791
808
  buttonHeight = 40,
792
- boundary = anchor_el.getBoundingClientRect(),
809
+ boundary = anchorEl.getBoundingClientRect(),
793
810
  middleBoundary = (boundary.left + boundary.right) / 2,
794
811
  halfOffsetWidth,
795
812
  defaultLeft,
796
813
  timer;
797
814
 
798
- self.anchorPreview.querySelector('i').innerHTML = anchor_el.href;
815
+ self.anchorPreview.querySelector('i').textContent = anchorEl.href;
799
816
  halfOffsetWidth = self.anchorPreview.offsetWidth / 2;
800
817
  defaultLeft = self.options.diffLeft - halfOffsetWidth;
801
818
 
@@ -806,7 +823,7 @@ if (typeof module === 'object') {
806
823
  }
807
824
  }, 100);
808
825
 
809
- self.observeAnchorPreview(anchor_el);
826
+ self.observeAnchorPreview(anchorEl);
810
827
 
811
828
  self.anchorPreview.classList.add('medium-toolbar-arrow-over');
812
829
  self.anchorPreview.classList.remove('medium-toolbar-arrow-under');
@@ -868,7 +885,7 @@ if (typeof module === 'object') {
868
885
  anchorPreview.id = 'medium-editor-anchor-preview-' + this.id;
869
886
  anchorPreview.className = 'medium-editor-anchor-preview';
870
887
  anchorPreview.innerHTML = this.anchorPreviewTemplate();
871
- document.body.appendChild(anchorPreview);
888
+ this.options.elementsContainer.appendChild(anchorPreview);
872
889
 
873
890
  anchorPreview.addEventListener('click', function () {
874
891
  self.anchorPreviewClickHandler();
@@ -1019,8 +1036,8 @@ if (typeof module === 'object') {
1019
1036
  this.isActive = false;
1020
1037
 
1021
1038
  if (this.toolbar !== undefined) {
1022
- document.body.removeChild(this.anchorPreview);
1023
- document.body.removeChild(this.toolbar);
1039
+ this.options.elementsContainer.removeChild(this.anchorPreview);
1040
+ this.options.elementsContainer.removeChild(this.toolbar);
1024
1041
  delete this.toolbar;
1025
1042
  delete this.anchorPreview;
1026
1043
  }
@@ -1063,7 +1080,7 @@ if (typeof module === 'object') {
1063
1080
  if (self.options.cleanPastedHTML && e.clipboardData.getData('text/html')) {
1064
1081
  return self.cleanPaste(e.clipboardData.getData('text/html'));
1065
1082
  }
1066
- if (!self.options.disableReturn) {
1083
+ if (!(self.options.disableReturn || this.getAttribute('data-disable-return'))) {
1067
1084
  paragraphs = e.clipboardData.getData('text/plain').split(/[\r\n]/g);
1068
1085
  for (p = 0; p < paragraphs.length; p += 1) {
1069
1086
  if (paragraphs[p] !== '') {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: medium-editor-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ahmet Sezgin Duran
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-13 00:00:00.000000000 Z
11
+ date: 2014-05-01 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Medium Editor integrated in Rails asset pipeline
14
14
  email:
@@ -17,7 +17,7 @@ executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
- - ".gitignore"
20
+ - .gitignore
21
21
  - CHANGELOG.md
22
22
  - Gemfile
23
23
  - LICENSE.txt
@@ -45,12 +45,12 @@ require_paths:
45
45
  - lib
46
46
  required_ruby_version: !ruby/object:Gem::Requirement
47
47
  requirements:
48
- - - ">="
48
+ - - '>='
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  required_rubygems_version: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - ">="
53
+ - - '>='
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  requirements: []