medium-editor-rails 0.13.0 → 0.13.1

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: 188188505037fdee5c1e46704ea790ebafbcb4bc
4
- data.tar.gz: c5b6e9ea9d4f8887b8ca9b2aadcd19ca93c0af6d
3
+ metadata.gz: 4e58ad4295ca847f565b03e3c537da4d2fa9b4a0
4
+ data.tar.gz: 6bbe1f8535d6757f37740b147eee020dadee37a6
5
5
  SHA512:
6
- metadata.gz: a98514788486bbd56270b777592373c754984c65a2e318d1ffabc17a66b10de6b34a059854ffa37eb2077e574b87a4e05ef21170883b3a615f484ad44df602d6
7
- data.tar.gz: 12af5954c85d0320b6c1737ce954ce2b7dba19bd707b96d2dcd87a212d6153eaa76ff14ee35756b9d0f8fe71b72bee5458e22c94f1e63839052ef4e1b3494f1e
6
+ metadata.gz: 313670ac55305d945bf64f6a0cc0daa22df1bd4079534594983270dc70a8965014101016321423cee63aedaf54b88e164c476c66d2c01133671ab7ad7c36d277
7
+ data.tar.gz: d327eaf5023ee301711ec2c814a199e6943f736206fdde1ca81b93b3f0526200d1ab6af1b503f472bb34ceef1d41f59a0ee2d3b62b3a55eefe4de492c460cb4a
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
 
2
2
  #### [Current]
3
+ * [c6b96b2](../../commit/c6b96b2) - __(Ahmet Sezgin Duran)__ Update Medium Editor files
4
+ * [8c242a1](../../commit/8c242a1) - __(Ahmet Sezgin Duran)__ Merge tag '0.13.0' into develop
5
+
6
+ 0.13.0
7
+
8
+ #### 0.13.0
9
+ * [5721891](../../commit/5721891) - __(Ahmet Sezgin Duran)__ Bump versions 0.13.0 and 1.9.10
3
10
  * [fdb732b](../../commit/fdb732b) - __(Ahmet Sezgin Duran)__ Update Medium Editor files
4
11
 
5
12
  #### 0.12.0
data/README.md CHANGED
@@ -8,7 +8,7 @@ This gem integrates [Medium Editor](https://github.com/daviferreira/medium-edito
8
8
 
9
9
  ## Version
10
10
 
11
- The latest version of Medium Editor bundled by this gem is [1.9.10](https://github.com/daviferreira/medium-editor/releases)
11
+ The latest version of Medium Editor bundled by this gem is [1.9.13](https://github.com/daviferreira/medium-editor/releases)
12
12
 
13
13
  ## Installation
14
14
 
@@ -1,6 +1,6 @@
1
1
  module MediumEditorRails
2
2
  module Rails
3
- VERSION = '0.13.0'
4
- MEDIUM_EDITOR_VERSION = '1.9.10'
3
+ VERSION = '0.13.1'
4
+ MEDIUM_EDITOR_VERSION = '1.9.13'
5
5
  end
6
6
  end
@@ -152,11 +152,15 @@ else if (typeof define === 'function' && define.amd) {
152
152
  return;
153
153
  }
154
154
  this.parentElements = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'pre'];
155
- this.id = document.querySelectorAll('.medium-editor-toolbar').length + 1;
155
+ if (!this.options.elementsContainer) {
156
+ this.options.elementsContainer = document.body;
157
+ }
158
+ this.id = this.options.elementsContainer.querySelectorAll('.medium-editor-toolbar').length + 1;
156
159
  return this.setup();
157
160
  },
158
161
 
159
162
  setup: function () {
163
+ this.events = [];
160
164
  this.isActive = true;
161
165
  this.initElements()
162
166
  .bindSelect()
@@ -166,6 +170,28 @@ else if (typeof define === 'function' && define.amd) {
166
170
  .passInstance();
167
171
  },
168
172
 
173
+ on: function(target, event, listener, useCapture) {
174
+ target.addEventListener(event, listener, useCapture);
175
+ this.events.push([target, event, listener, useCapture]);
176
+ },
177
+
178
+ off: function(target, event, listener, useCapture) {
179
+ var index = this.events.indexOf([target, event, listener, useCapture]),
180
+ e;
181
+ if(index !== -1) {
182
+ e = this.events.splice(index, 1);
183
+ e[0].removeEventListener(e[1], e[2], e[3]);
184
+ }
185
+ },
186
+
187
+ removeAllEvents: function() {
188
+ var e = this.events.pop();
189
+ while(e) {
190
+ e[0].removeEventListener(e[1], e[2], e[3]);
191
+ e = this.events.pop();
192
+ }
193
+ },
194
+
169
195
  initElements: function () {
170
196
  this.updateElementList();
171
197
  var i,
@@ -185,9 +211,6 @@ else if (typeof define === 'function' && define.amd) {
185
211
  }
186
212
  // Init toolbar
187
213
  if (addToolbar) {
188
- if (!this.options.elementsContainer) {
189
- this.options.elementsContainer = document.body;
190
- }
191
214
  this.initToolbar()
192
215
  .bindButtons()
193
216
  .bindAnchorForm()
@@ -272,7 +295,7 @@ else if (typeof define === 'function' && define.amd) {
272
295
 
273
296
  bindParagraphCreation: function (index) {
274
297
  var self = this;
275
- this.elements[index].addEventListener('keypress', function (e) {
298
+ this.on(this.elements[index], 'keypress', function (e) {
276
299
  var node = getSelectionStart.call(self),
277
300
  tagName;
278
301
  if (e.which === 32) {
@@ -283,7 +306,7 @@ else if (typeof define === 'function' && define.amd) {
283
306
  }
284
307
  });
285
308
 
286
- this.elements[index].addEventListener('keyup', function (e) {
309
+ this.on(this.elements[index], 'keyup', function (e) {
287
310
  var node = getSelectionStart.call(self),
288
311
  tagName,
289
312
  editorElement;
@@ -329,7 +352,7 @@ else if (typeof define === 'function' && define.amd) {
329
352
 
330
353
  bindReturn: function (index) {
331
354
  var self = this;
332
- this.elements[index].addEventListener('keypress', function (e) {
355
+ this.on(this.elements[index], 'keypress', function (e) {
333
356
  if (e.which === 13) {
334
357
  if (self.options.disableReturn || this.getAttribute('data-disable-return')) {
335
358
  e.preventDefault();
@@ -346,7 +369,7 @@ else if (typeof define === 'function' && define.amd) {
346
369
 
347
370
  bindTab: function (index) {
348
371
  var self = this;
349
- this.elements[index].addEventListener('keydown', function (e) {
372
+ this.on(this.elements[index], 'keydown', function (e) {
350
373
  if (e.which === 9) {
351
374
  // Override tab only for pre nodes
352
375
  var tag = getSelectionStart.call(self).tagName.toLowerCase();
@@ -377,7 +400,7 @@ else if (typeof define === 'function' && define.amd) {
377
400
  'bold': '<button class="medium-editor-action medium-editor-action-bold" data-action="bold" data-element="b">' + buttonLabels.bold + '</button>',
378
401
  'italic': '<button class="medium-editor-action medium-editor-action-italic" data-action="italic" data-element="i">' + buttonLabels.italic + '</button>',
379
402
  'underline': '<button class="medium-editor-action medium-editor-action-underline" data-action="underline" data-element="u">' + buttonLabels.underline + '</button>',
380
- 'strikethrough': '<button class="medium-editor-action medium-editor-action-strikethrough" data-action="strikethrough" data-element="strike"><strike>A</strike></button>',
403
+ 'strikethrough': '<button class="medium-editor-action medium-editor-action-strikethrough" data-action="strikethrough" data-element="strike">' + buttonLabels.strikethrough +'</button>',
381
404
  'superscript': '<button class="medium-editor-action medium-editor-action-superscript" data-action="superscript" data-element="sup">' + buttonLabels.superscript + '</button>',
382
405
  'subscript': '<button class="medium-editor-action medium-editor-action-subscript" data-action="subscript" data-element="sub">' + buttonLabels.subscript + '</button>',
383
406
  'anchor': '<button class="medium-editor-action medium-editor-action-anchor" data-action="anchor" data-element="a">' + buttonLabels.anchor + '</button>',
@@ -406,6 +429,7 @@ else if (typeof define === 'function' && define.amd) {
406
429
  'bold': '<b>B</b>',
407
430
  'italic': '<b><i>I</i></b>',
408
431
  'underline': '<b><u>U</u></b>',
432
+ 'strikethrough': '<s>A</s>',
409
433
  'superscript': '<b>x<sup>1</sup></b>',
410
434
  'subscript': '<b>x<sub>1</sub></b>',
411
435
  'anchor': '<b>#</b>',
@@ -428,6 +452,7 @@ else if (typeof define === 'function' && define.amd) {
428
452
  'bold': '<i class="fa fa-bold"></i>',
429
453
  'italic': '<i class="fa fa-italic"></i>',
430
454
  'underline': '<i class="fa fa-underline"></i>',
455
+ 'strikethrough': '<i class="fa fa-strikethrough"></i>',
431
456
  'superscript': '<i class="fa fa-superscript"></i>',
432
457
  'subscript': '<i class="fa fa-subscript"></i>',
433
458
  'anchor': '<i class="fa fa-link"></i>',
@@ -586,11 +611,11 @@ else if (typeof define === 'function' && define.amd) {
586
611
  }, self.options.delay);
587
612
  };
588
613
 
589
- document.documentElement.addEventListener('mouseup', this.checkSelectionWrapper);
614
+ this.on(document.documentElement, 'mouseup', this.checkSelectionWrapper);
590
615
 
591
616
  for (i = 0; i < this.elements.length; i += 1) {
592
- this.elements[i].addEventListener('keyup', this.checkSelectionWrapper);
593
- this.elements[i].addEventListener('blur', this.checkSelectionWrapper);
617
+ this.on(this.elements[i], 'keyup', this.checkSelectionWrapper);
618
+ this.on(this.elements[i], 'blur', this.checkSelectionWrapper);
594
619
  }
595
620
  return this;
596
621
  },
@@ -772,7 +797,7 @@ else if (typeof define === 'function' && define.amd) {
772
797
  }
773
798
  };
774
799
  for (i = 0; i < buttons.length; i += 1) {
775
- buttons[i].addEventListener('click', triggerAction);
800
+ this.on(buttons[i], 'click', triggerAction);
776
801
  }
777
802
  this.setFirstAndLastItems(buttons);
778
803
  return this;
@@ -934,12 +959,12 @@ else if (typeof define === 'function' && define.amd) {
934
959
  linkSave = this.anchorForm.querySelector('a.medium-editor-toobar-anchor-save'),
935
960
  self = this;
936
961
 
937
- this.anchorForm.addEventListener('click', function (e) {
962
+ this.on(this.anchorForm, 'click', function (e) {
938
963
  e.stopPropagation();
939
964
  self.keepToolbarAlive = true;
940
965
  });
941
966
 
942
- this.anchorInput.addEventListener('keyup', function (e) {
967
+ this.on(this.anchorInput, 'keyup', function (e) {
943
968
  var button = null,
944
969
  target;
945
970
 
@@ -960,7 +985,7 @@ else if (typeof define === 'function' && define.amd) {
960
985
  }
961
986
  });
962
987
 
963
- linkSave.addEventListener('click', function(e) {
988
+ this.on(linkSave, 'click', function(e) {
964
989
  var button = null,
965
990
  target;
966
991
  e.preventDefault();
@@ -978,27 +1003,27 @@ else if (typeof define === 'function' && define.amd) {
978
1003
  self.createLink(self.anchorInput, target, button);
979
1004
  }, true);
980
1005
 
981
- this.anchorInput.addEventListener('click', function (e) {
1006
+ this.on(this.anchorInput, 'click', function (e) {
982
1007
  // make sure not to hide form when cliking into the input
983
1008
  e.stopPropagation();
984
1009
  self.keepToolbarAlive = true;
985
1010
  });
986
1011
 
987
1012
  // Hide the anchor form when focusing outside of it.
988
- this.options.ownerDocument.body.addEventListener('click', function (e) {
1013
+ this.on(this.options.ownerDocument.body, 'click', function (e) {
989
1014
  if (e.target !== self.anchorForm && !isDescendant(self.anchorForm, e.target) && !isDescendant(self.toolbarActions, e.target)) {
990
1015
  self.keepToolbarAlive = false;
991
1016
  self.checkSelection();
992
1017
  }
993
1018
  }, true);
994
- this.options.ownerDocument.body.addEventListener('focus', function (e) {
1019
+ this.on(this.options.ownerDocument.body, 'focus', function (e) {
995
1020
  if (e.target !== self.anchorForm && !isDescendant(self.anchorForm, e.target) && !isDescendant(self.toolbarActions, e.target)) {
996
1021
  self.keepToolbarAlive = false;
997
1022
  self.checkSelection();
998
1023
  }
999
1024
  }, true);
1000
1025
 
1001
- linkCancel.addEventListener('click', function (e) {
1026
+ this.on(linkCancel, 'click', function (e) {
1002
1027
  e.preventDefault();
1003
1028
  self.showToolbarActions();
1004
1029
  restoreSelection.call(self, self.savedSelection);
@@ -1078,18 +1103,18 @@ else if (typeof define === 'function' && define.amd) {
1078
1103
 
1079
1104
  // cleanup
1080
1105
  clearInterval(interval_timer);
1081
- self.anchorPreview.removeEventListener('mouseover', stamp);
1082
- self.anchorPreview.removeEventListener('mouseout', unstamp);
1083
- anchorEl.removeEventListener('mouseover', stamp);
1084
- anchorEl.removeEventListener('mouseout', unstamp);
1106
+ self.off(self.anchorPreview, 'mouseover', stamp);
1107
+ self.off(self.anchorPreview, 'mouseout', unstamp);
1108
+ self.off(anchorEl, 'mouseover', stamp);
1109
+ self.off(anchorEl, 'mouseout', unstamp);
1085
1110
 
1086
1111
  }
1087
1112
  }, 200);
1088
1113
 
1089
- self.anchorPreview.addEventListener('mouseover', stamp);
1090
- self.anchorPreview.addEventListener('mouseout', unstamp);
1091
- anchorEl.addEventListener('mouseover', stamp);
1092
- anchorEl.addEventListener('mouseout', unstamp);
1114
+ this.on(self.anchorPreview, 'mouseover', stamp);
1115
+ this.on(self.anchorPreview, 'mouseout', unstamp);
1116
+ this.on(anchorEl, 'mouseover', stamp);
1117
+ this.on(anchorEl, 'mouseout', unstamp);
1093
1118
  },
1094
1119
 
1095
1120
  createAnchorPreview: function () {
@@ -1101,7 +1126,7 @@ else if (typeof define === 'function' && define.amd) {
1101
1126
  anchorPreview.innerHTML = this.anchorPreviewTemplate();
1102
1127
  this.options.elementsContainer.appendChild(anchorPreview);
1103
1128
 
1104
- anchorPreview.addEventListener('click', function () {
1129
+ this.on(anchorPreview, 'click', function () {
1105
1130
  self.anchorPreviewClickHandler();
1106
1131
  });
1107
1132
 
@@ -1142,7 +1167,7 @@ else if (typeof define === 'function' && define.amd) {
1142
1167
  leaveAnchor = function () {
1143
1168
  // mark the anchor as no longer hovered, and stop listening
1144
1169
  overAnchor = false;
1145
- self.activeAnchor.removeEventListener('mouseout', leaveAnchor);
1170
+ self.off(self.activeAnchor, 'mouseout', leaveAnchor);
1146
1171
  };
1147
1172
 
1148
1173
  if (e.target && e.target.tagName.toLowerCase() === 'a') {
@@ -1160,7 +1185,7 @@ else if (typeof define === 'function' && define.amd) {
1160
1185
  return true;
1161
1186
  }
1162
1187
  this.activeAnchor = e.target;
1163
- this.activeAnchor.addEventListener('mouseout', leaveAnchor);
1188
+ this.on(this.activeAnchor, 'mouseout', leaveAnchor);
1164
1189
  // show the anchor preview according to the configured delay
1165
1190
  // if the mouse has not left the anchor tag in that time
1166
1191
  setTimeout(function () {
@@ -1179,7 +1204,7 @@ else if (typeof define === 'function' && define.amd) {
1179
1204
  self.editorAnchorObserver(e);
1180
1205
  };
1181
1206
  for (i = 0; i < this.elements.length; i += 1) {
1182
- this.elements[i].addEventListener('mouseover', this.editorAnchorObserverWrapper);
1207
+ this.on(this.elements[i], 'mouseover', this.editorAnchorObserverWrapper);
1183
1208
  }
1184
1209
  return this;
1185
1210
  },
@@ -1196,6 +1221,7 @@ else if (typeof define === 'function' && define.amd) {
1196
1221
  el.target = '_blank';
1197
1222
  } else {
1198
1223
  el = el.getElementsByTagName('a');
1224
+
1199
1225
  for (i = 0; i < el.length; i += 1) {
1200
1226
  el[i].target = '_blank';
1201
1227
  }
@@ -1268,7 +1294,7 @@ else if (typeof define === 'function' && define.amd) {
1268
1294
  }
1269
1295
  }, 100);
1270
1296
  };
1271
- this.options.contentWindow.addEventListener('resize', this.windowResizeHandler);
1297
+ this.on(this.options.contentWindow, 'resize', this.windowResizeHandler);
1272
1298
  return this;
1273
1299
  },
1274
1300
 
@@ -1295,18 +1321,12 @@ else if (typeof define === 'function' && define.amd) {
1295
1321
  delete this.anchorPreview;
1296
1322
  }
1297
1323
 
1298
- this.options.ownerDocument.documentElement.removeEventListener('mouseup', this.checkSelectionWrapper);
1299
- this.options.contentWindow.removeEventListener('resize', this.windowResizeHandler);
1300
-
1301
1324
  for (i = 0; i < this.elements.length; i += 1) {
1302
- this.elements[i].removeEventListener('mouseover', this.editorAnchorObserverWrapper);
1303
- this.elements[i].removeEventListener('keyup', this.checkSelectionWrapper);
1304
- this.elements[i].removeEventListener('blur', this.checkSelectionWrapper);
1305
- this.elements[i].removeEventListener('paste', this.pasteWrapper);
1306
1325
  this.elements[i].removeAttribute('contentEditable');
1307
1326
  this.elements[i].removeAttribute('data-medium-element');
1308
1327
  }
1309
1328
 
1329
+ this.removeAllEvents();
1310
1330
  },
1311
1331
 
1312
1332
  htmlEntities: function (str) {
@@ -1352,7 +1372,7 @@ else if (typeof define === 'function' && define.amd) {
1352
1372
  }
1353
1373
  };
1354
1374
  for (i = 0; i < this.elements.length; i += 1) {
1355
- this.elements[i].addEventListener('paste', this.pasteWrapper);
1375
+ this.on(this.elements[i], 'paste', this.pasteWrapper);
1356
1376
  }
1357
1377
  return this;
1358
1378
  },
@@ -1374,8 +1394,8 @@ else if (typeof define === 'function' && define.amd) {
1374
1394
  };
1375
1395
  for (i = 0; i < this.elements.length; i += 1) {
1376
1396
  activatePlaceholder(this.elements[i]);
1377
- this.elements[i].addEventListener('blur', placeholderWrapper);
1378
- this.elements[i].addEventListener('keypress', placeholderWrapper);
1397
+ this.on(this.elements[i], 'blur', placeholderWrapper);
1398
+ this.on(this.elements[i], 'keypress', placeholderWrapper);
1379
1399
  }
1380
1400
  return this;
1381
1401
  },
@@ -99,8 +99,7 @@
99
99
  font-size: 14px;
100
100
  line-height: 1.33;
101
101
  text-decoration: none;
102
- -moz-box-sizing: border-box;
103
- box-sizing: border-box; }
102
+ box-sizing: border-box; }
104
103
  .medium-editor-toolbar li .medium-editor-action-underline, .medium-editor-anchor-preview li .medium-editor-action-underline {
105
104
  text-decoration: underline; }
106
105
  .medium-editor-toolbar li .medium-editor-action-pre, .medium-editor-anchor-preview li .medium-editor-action-pre {
@@ -140,8 +139,7 @@
140
139
  width: 316px;
141
140
  border: none;
142
141
  font-size: 14px;
143
- -moz-box-sizing: border-box;
144
- box-sizing: border-box; }
142
+ box-sizing: border-box; }
145
143
  .medium-editor-toolbar-form-anchor .medium-editor-toolbar-anchor-input:focus, .medium-editor-toolbar-form-anchor label:focus {
146
144
  outline: 0;
147
145
  border: none;
@@ -18,8 +18,7 @@
18
18
  border-right: 1px solid #357ebd;
19
19
  background-color: transparent;
20
20
  color: #fff;
21
- -moz-box-sizing: border-box;
22
- box-sizing: border-box;
21
+ box-sizing: border-box;
23
22
  -webkit-transition: background-color 0.2s ease-in, color 0.2s ease-in;
24
23
  transition: background-color 0.2s ease-in, color 0.2s ease-in; }
25
24
  .medium-editor-toolbar li button:hover {
@@ -52,8 +52,7 @@
52
52
  height: 50px;
53
53
  background: #242424;
54
54
  color: #ccc;
55
- -moz-box-sizing: border-box;
56
- box-sizing: border-box; }
55
+ box-sizing: border-box; }
57
56
  .medium-editor-toolbar-form-anchor a {
58
57
  color: #fff; }
59
58
 
@@ -14,13 +14,13 @@
14
14
  min-width: 60px;
15
15
  height: 60px;
16
16
  border: none;
17
- border-right: 1px solid #9ccea5;
17
+ border-right: 1px solid #9ccea6;
18
18
  background-color: transparent;
19
19
  color: #fff;
20
20
  -webkit-transition: background-color 0.2s ease-in, color 0.2s ease-in;
21
21
  transition: background-color 0.2s ease-in, color 0.2s ease-in; }
22
22
  .medium-editor-toolbar li button:hover {
23
- background-color: #346a3e;
23
+ background-color: #346a3f;
24
24
  color: #fff; }
25
25
  .medium-editor-toolbar li .medium-editor-button-active {
26
26
  background-color: #23482a;
@@ -43,8 +43,7 @@
43
43
  height: 50px;
44
44
  background: #dee7f0;
45
45
  color: #40648a;
46
- -moz-box-sizing: border-box;
47
- box-sizing: border-box; }
46
+ box-sizing: border-box; }
48
47
  .medium-editor-toolbar-form-anchor a {
49
48
  color: #40648a; }
50
49
 
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.13.0
4
+ version: 0.13.1
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-11-19 00:00:00.000000000 Z
11
+ date: 2014-11-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties