medium-editor-rails 0.12.0 → 0.13.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: e6334aa6f7d7de244f56a2f69a38f76f7ff1e0f4
4
- data.tar.gz: 7bbdaa4722048e7014a1f7f547916c02609ab331
3
+ metadata.gz: 188188505037fdee5c1e46704ea790ebafbcb4bc
4
+ data.tar.gz: c5b6e9ea9d4f8887b8ca9b2aadcd19ca93c0af6d
5
5
  SHA512:
6
- metadata.gz: 5340ce94ec2f120238764d75f94011a81edf06190197efd8e06fff0be2fd77430a127e0ac198d56d46ad4eaddf733226044ca1dc2bad6a4a8e1d0c78fab7287c
7
- data.tar.gz: 7aa1dfda439284dd0c437e8a138c4d27f73420804b35f9fda37b018e0a5d682edecbe447debefb4a7e82be59a08215a2b00a295507821cc8adb79c4af3eaafa8
6
+ metadata.gz: a98514788486bbd56270b777592373c754984c65a2e318d1ffabc17a66b10de6b34a059854ffa37eb2077e574b87a4e05ef21170883b3a615f484ad44df602d6
7
+ data.tar.gz: 12af5954c85d0320b6c1737ce954ce2b7dba19bd707b96d2dcd87a212d6153eaa76ff14ee35756b9d0f8fe71b72bee5458e22c94f1e63839052ef4e1b3494f1e
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
 
2
2
  #### [Current]
3
+ * [fdb732b](../../commit/fdb732b) - __(Ahmet Sezgin Duran)__ Update Medium Editor files
4
+
5
+ #### 0.12.0
6
+ * [ca8041a](../../commit/ca8041a) - __(Ahmet Sezgin Duran)__ Bump versions 0.12.0 and 1.9.8
3
7
  * [3e8148f](../../commit/3e8148f) - __(Ahmet Sezgin Duran)__ Update Medium Editor files
4
8
 
5
9
  #### 0.11.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.8](https://github.com/daviferreira/medium-editor/releases)
11
+ The latest version of Medium Editor bundled by this gem is [1.9.10](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.12.0'
4
- MEDIUM_EDITOR_VERSION = '1.9.8'
3
+ VERSION = '0.13.0'
4
+ MEDIUM_EDITOR_VERSION = '1.9.10'
5
5
  end
6
6
  end
@@ -6,6 +6,13 @@ function MediumEditor(elements, options) {
6
6
  if (typeof module === 'object') {
7
7
  module.exports = MediumEditor;
8
8
  }
9
+ // AMD support
10
+ else if (typeof define === 'function' && define.amd) {
11
+ define(function () {
12
+ 'use strict';
13
+ return MediumEditor;
14
+ });
15
+ }
9
16
 
10
17
  (function (window, document) {
11
18
  'use strict';
@@ -40,7 +47,7 @@ if (typeof module === 'object') {
40
47
  var i,
41
48
  len,
42
49
  ranges,
43
- sel = window.getSelection();
50
+ sel = this.options.contentWindow.getSelection();
44
51
  if (sel.getRangeAt && sel.rangeCount) {
45
52
  ranges = [];
46
53
  for (i = 0, len = sel.rangeCount; i < len; i += 1) {
@@ -54,7 +61,7 @@ if (typeof module === 'object') {
54
61
  function restoreSelection(savedSel) {
55
62
  var i,
56
63
  len,
57
- sel = window.getSelection();
64
+ sel = this.options.contentWindow.getSelection();
58
65
  if (savedSel) {
59
66
  sel.removeAllRanges();
60
67
  for (i = 0, len = savedSel.length; i < len; i += 1) {
@@ -66,7 +73,7 @@ if (typeof module === 'object') {
66
73
  // http://stackoverflow.com/questions/1197401/how-can-i-get-the-element-the-caret-is-in-with-javascript-when-using-contentedi
67
74
  // by You
68
75
  function getSelectionStart() {
69
- var node = document.getSelection().anchorNode,
76
+ var node = this.options.ownerDocument.getSelection().anchorNode,
70
77
  startNode = (node && node.nodeType === 3 ? node.parentNode : node);
71
78
  return startNode;
72
79
  }
@@ -79,18 +86,18 @@ if (typeof module === 'object') {
79
86
  sel,
80
87
  len,
81
88
  container;
82
- if (window.getSelection !== undefined) {
83
- sel = window.getSelection();
89
+ if (this.options.contentWindow.getSelection !== undefined) {
90
+ sel = this.options.contentWindow.getSelection();
84
91
  if (sel.rangeCount) {
85
- container = document.createElement('div');
92
+ container = this.options.ownerDocument.createElement('div');
86
93
  for (i = 0, len = sel.rangeCount; i < len; i += 1) {
87
94
  container.appendChild(sel.getRangeAt(i).cloneContents());
88
95
  }
89
96
  html = container.innerHTML;
90
97
  }
91
- } else if (document.selection !== undefined) {
92
- if (document.selection.type === 'Text') {
93
- html = document.selection.createRange().htmlText;
98
+ } else if (this.options.ownerDocument.selection !== undefined) {
99
+ if (this.options.ownerDocument.selection.type === 'Text') {
100
+ html = this.options.ownerDocument.selection.createRange().htmlText;
94
101
  }
95
102
  }
96
103
  return html;
@@ -118,6 +125,8 @@ if (typeof module === 'object') {
118
125
  disableToolbar: false,
119
126
  disableEditing: false,
120
127
  elementsContainer: false,
128
+ contentWindow: window,
129
+ ownerDocument: document,
121
130
  firstHeader: 'h3',
122
131
  forcePlainText: true,
123
132
  placeholder: 'Type your text',
@@ -137,13 +146,13 @@ if (typeof module === 'object') {
137
146
  isIE: ((navigator.appName === 'Microsoft Internet Explorer') || ((navigator.appName === 'Netscape') && (new RegExp('Trident/.*rv:([0-9]{1,}[.0-9]{0,})').exec(navigator.userAgent) !== null))),
138
147
 
139
148
  init: function (elements, options) {
149
+ this.options = extend(options, this.defaults);
140
150
  this.setElementSelection(elements);
141
151
  if (this.elements.length === 0) {
142
152
  return;
143
153
  }
144
154
  this.parentElements = ['p', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'blockquote', 'pre'];
145
155
  this.id = document.querySelectorAll('.medium-editor-toolbar').length + 1;
146
- this.options = extend(options, this.defaults);
147
156
  return this.setup();
148
157
  },
149
158
 
@@ -193,7 +202,7 @@ if (typeof module === 'object') {
193
202
  },
194
203
 
195
204
  updateElementList: function () {
196
- this.elements = typeof this.elementSelection === 'string' ? document.querySelectorAll(this.elementSelection) : this.elementSelection;
205
+ this.elements = typeof this.elementSelection === 'string' ? this.options.ownerDocument.querySelectorAll(this.elementSelection) : this.elementSelection;
197
206
  if (this.elements.nodeType === 1) {
198
207
  this.elements = [this.elements];
199
208
  }
@@ -264,7 +273,7 @@ if (typeof module === 'object') {
264
273
  bindParagraphCreation: function (index) {
265
274
  var self = this;
266
275
  this.elements[index].addEventListener('keypress', function (e) {
267
- var node = getSelectionStart(),
276
+ var node = getSelectionStart.call(self),
268
277
  tagName;
269
278
  if (e.which === 32) {
270
279
  tagName = node.tagName.toLowerCase();
@@ -275,15 +284,15 @@ if (typeof module === 'object') {
275
284
  });
276
285
 
277
286
  this.elements[index].addEventListener('keyup', function (e) {
278
- var node = getSelectionStart(),
287
+ var node = getSelectionStart.call(self),
279
288
  tagName,
280
289
  editorElement;
281
-
290
+
282
291
  if (node && node.getAttribute('data-medium-element') && node.children.length === 0 && !(self.options.disableReturn || node.getAttribute('data-disable-return'))) {
283
292
  document.execCommand('formatBlock', false, 'p');
284
293
  }
285
294
  if (e.which === 13) {
286
- node = getSelectionStart();
295
+ node = getSelectionStart.call(self);
287
296
  tagName = node.tagName.toLowerCase();
288
297
  editorElement = self.getSelectionElement();
289
298
 
@@ -325,7 +334,7 @@ if (typeof module === 'object') {
325
334
  if (self.options.disableReturn || this.getAttribute('data-disable-return')) {
326
335
  e.preventDefault();
327
336
  } else if (self.options.disableDoubleReturn || this.getAttribute('data-disable-double-return')) {
328
- var node = getSelectionStart();
337
+ var node = getSelectionStart.call(self);
329
338
  if (node && node.innerText === '\n') {
330
339
  e.preventDefault();
331
340
  }
@@ -336,10 +345,11 @@ if (typeof module === 'object') {
336
345
  },
337
346
 
338
347
  bindTab: function (index) {
348
+ var self = this;
339
349
  this.elements[index].addEventListener('keydown', function (e) {
340
350
  if (e.which === 9) {
341
351
  // Override tab only for pre nodes
342
- var tag = getSelectionStart().tagName.toLowerCase();
352
+ var tag = getSelectionStart.call(self).tagName.toLowerCase();
343
353
  if (tag === 'pre') {
344
354
  e.preventDefault();
345
355
  document.execCommand('insertHtml', null, ' ');
@@ -591,7 +601,7 @@ if (typeof module === 'object') {
591
601
 
592
602
  if (this.keepToolbarAlive !== true && !this.options.disableToolbar) {
593
603
 
594
- newSelection = window.getSelection();
604
+ newSelection = this.options.contentWindow.getSelection();
595
605
  if (newSelection.toString().trim() === '' ||
596
606
  (this.options.allowMultiParagraphSelection === false && this.hasMultiParagraphs()) ||
597
607
  this.selectionInContentEditableFalse()) {
@@ -619,7 +629,7 @@ if (typeof module === 'object') {
619
629
  },
620
630
 
621
631
  hasMultiParagraphs: function () {
622
- var selectionHtml = getSelectionHtml().replace(/<[\S]+><\/[\S]+>/gim, ''),
632
+ var selectionHtml = getSelectionHtml.call(this).replace(/<[\S]+><\/[\S]+>/gim, ''),
623
633
  hasMultiParagraphs = selectionHtml.match(/<(p|h[0-6]|blockquote)>([\s\S]*?)<\/(p|h[0-6]|blockquote)>/g);
624
634
 
625
635
  return (hasMultiParagraphs ? hasMultiParagraphs.length : 0);
@@ -641,7 +651,7 @@ if (typeof module === 'object') {
641
651
  },
642
652
 
643
653
  findMatchingSelectionParent: function(testElementFunction) {
644
- var selection = window.getSelection(), range, current;
654
+ var selection = this.options.contentWindow.getSelection(), range, current;
645
655
 
646
656
  if (selection.rangeCount === 0) {
647
657
  return false;
@@ -682,7 +692,7 @@ if (typeof module === 'object') {
682
692
 
683
693
  setToolbarPosition: function () {
684
694
  var buttonHeight = 50,
685
- selection = window.getSelection(),
695
+ selection = this.options.contentWindow.getSelection(),
686
696
  range = selection.getRangeAt(0),
687
697
  boundary = range.getBoundingClientRect(),
688
698
  defaultLeft = (this.options.diffLeft) - (this.toolbar.offsetWidth / 2),
@@ -691,16 +701,16 @@ if (typeof module === 'object') {
691
701
  if (boundary.top < buttonHeight) {
692
702
  this.toolbar.classList.add('medium-toolbar-arrow-over');
693
703
  this.toolbar.classList.remove('medium-toolbar-arrow-under');
694
- this.toolbar.style.top = buttonHeight + boundary.bottom - this.options.diffTop + window.pageYOffset - this.toolbar.offsetHeight + 'px';
704
+ this.toolbar.style.top = buttonHeight + boundary.bottom - this.options.diffTop + this.options.contentWindow.pageYOffset - this.toolbar.offsetHeight + 'px';
695
705
  } else {
696
706
  this.toolbar.classList.add('medium-toolbar-arrow-under');
697
707
  this.toolbar.classList.remove('medium-toolbar-arrow-over');
698
- this.toolbar.style.top = boundary.top + this.options.diffTop + window.pageYOffset - this.toolbar.offsetHeight + 'px';
708
+ this.toolbar.style.top = boundary.top + this.options.diffTop + this.options.contentWindow.pageYOffset - this.toolbar.offsetHeight + 'px';
699
709
  }
700
710
  if (middleBoundary < halfOffsetWidth) {
701
711
  this.toolbar.style.left = defaultLeft + halfOffsetWidth + 'px';
702
- } else if ((window.innerWidth - middleBoundary) < halfOffsetWidth) {
703
- this.toolbar.style.left = window.innerWidth + defaultLeft - halfOffsetWidth + 'px';
712
+ } else if ((this.options.contentWindow.innerWidth - middleBoundary) < halfOffsetWidth) {
713
+ this.toolbar.style.left = this.options.contentWindow.innerWidth + defaultLeft - halfOffsetWidth + 'px';
704
714
  } else {
705
715
  this.toolbar.style.left = defaultLeft + middleBoundary + 'px';
706
716
  }
@@ -784,9 +794,9 @@ if (typeof module === 'object') {
784
794
  } else if (action === 'anchor') {
785
795
  this.triggerAnchorAction(e);
786
796
  } else if (action === 'image') {
787
- document.execCommand('insertImage', false, window.getSelection());
797
+ this.options.ownerDocument.execCommand('insertImage', false, this.options.contentWindow.getSelection());
788
798
  } else {
789
- document.execCommand(action, false, null);
799
+ this.options.ownerDocument.execCommand(action, false, null);
790
800
  this.setToolbarPosition();
791
801
  }
792
802
  },
@@ -816,7 +826,7 @@ if (typeof module === 'object') {
816
826
  var selectedParentElement = this.getSelectedParentElement();
817
827
  if (selectedParentElement.tagName &&
818
828
  selectedParentElement.tagName.toLowerCase() === 'a') {
819
- document.execCommand('unlink', false, null);
829
+ this.options.ownerDocument.execCommand('unlink', false, null);
820
830
  } else {
821
831
  if (this.anchorForm.style.display === 'block') {
822
832
  this.showToolbarActions();
@@ -834,7 +844,7 @@ if (typeof module === 'object') {
834
844
  // https://developer.mozilla.org/en-US/docs/Rich-Text_Editing_in_Mozilla
835
845
  if (el === 'blockquote' && selectionData.el &&
836
846
  selectionData.el.parentNode.tagName.toLowerCase() === 'blockquote') {
837
- return document.execCommand('outdent', false, null);
847
+ return this.options.ownerDocument.execCommand('outdent', false, null);
838
848
  }
839
849
  if (selectionData.tagName === el) {
840
850
  el = 'p';
@@ -845,11 +855,11 @@ if (typeof module === 'object') {
845
855
  // http://stackoverflow.com/questions/1816223/rich-text-editor-with-blockquote-function/1821777#1821777
846
856
  if (this.isIE) {
847
857
  if (el === 'blockquote') {
848
- return document.execCommand('indent', false, el);
858
+ return this.options.ownerDocument.execCommand('indent', false, el);
849
859
  }
850
860
  el = '<' + el + '>';
851
861
  }
852
- return document.execCommand('formatBlock', false, el);
862
+ return this.options.ownerDocument.execCommand('formatBlock', false, el);
853
863
  },
854
864
 
855
865
  getSelectionData: function (el) {
@@ -902,11 +912,11 @@ if (typeof module === 'object') {
902
912
  },
903
913
 
904
914
  saveSelection: function() {
905
- this.savedSelection = saveSelection();
915
+ this.savedSelection = saveSelection.call(this);
906
916
  },
907
917
 
908
918
  restoreSelection: function() {
909
- restoreSelection(this.savedSelection);
919
+ restoreSelection.call(this, this.savedSelection);
910
920
  },
911
921
 
912
922
  showAnchorForm: function (link_value) {
@@ -975,13 +985,13 @@ if (typeof module === 'object') {
975
985
  });
976
986
 
977
987
  // Hide the anchor form when focusing outside of it.
978
- document.body.addEventListener('click', function (e) {
988
+ this.options.ownerDocument.body.addEventListener('click', function (e) {
979
989
  if (e.target !== self.anchorForm && !isDescendant(self.anchorForm, e.target) && !isDescendant(self.toolbarActions, e.target)) {
980
990
  self.keepToolbarAlive = false;
981
991
  self.checkSelection();
982
992
  }
983
993
  }, true);
984
- document.body.addEventListener('focus', function (e) {
994
+ this.options.ownerDocument.body.addEventListener('focus', function (e) {
985
995
  if (e.target !== self.anchorForm && !isDescendant(self.anchorForm, e.target) && !isDescendant(self.toolbarActions, e.target)) {
986
996
  self.keepToolbarAlive = false;
987
997
  self.checkSelection();
@@ -991,7 +1001,7 @@ if (typeof module === 'object') {
991
1001
  linkCancel.addEventListener('click', function (e) {
992
1002
  e.preventDefault();
993
1003
  self.showToolbarActions();
994
- restoreSelection(self.savedSelection);
1004
+ restoreSelection.call(self, self.savedSelection);
995
1005
  });
996
1006
  return this;
997
1007
  },
@@ -1031,11 +1041,11 @@ if (typeof module === 'object') {
1031
1041
 
1032
1042
  self.anchorPreview.classList.add('medium-toolbar-arrow-over');
1033
1043
  self.anchorPreview.classList.remove('medium-toolbar-arrow-under');
1034
- self.anchorPreview.style.top = Math.round(buttonHeight + boundary.bottom - self.options.diffTop + window.pageYOffset - self.anchorPreview.offsetHeight) + 'px';
1044
+ self.anchorPreview.style.top = Math.round(buttonHeight + boundary.bottom - self.options.diffTop + this.options.contentWindow.pageYOffset - self.anchorPreview.offsetHeight) + 'px';
1035
1045
  if (middleBoundary < halfOffsetWidth) {
1036
1046
  self.anchorPreview.style.left = defaultLeft + halfOffsetWidth + 'px';
1037
- } else if ((window.innerWidth - middleBoundary) < halfOffsetWidth) {
1038
- self.anchorPreview.style.left = window.innerWidth + defaultLeft - halfOffsetWidth + 'px';
1047
+ } else if ((this.options.contentWindow.innerWidth - middleBoundary) < halfOffsetWidth) {
1048
+ self.anchorPreview.style.left = this.options.contentWindow.innerWidth + defaultLeft - halfOffsetWidth + 'px';
1039
1049
  } else {
1040
1050
  self.anchorPreview.style.left = defaultLeft + middleBoundary + 'px';
1041
1051
  }
@@ -1084,7 +1094,7 @@ if (typeof module === 'object') {
1084
1094
 
1085
1095
  createAnchorPreview: function () {
1086
1096
  var self = this,
1087
- anchorPreview = document.createElement('div');
1097
+ anchorPreview = this.options.ownerDocument.createElement('div');
1088
1098
 
1089
1099
  anchorPreview.id = 'medium-editor-anchor-preview-' + this.id;
1090
1100
  anchorPreview.className = 'medium-editor-anchor-preview';
@@ -1108,8 +1118,8 @@ if (typeof module === 'object') {
1108
1118
  if (this.activeAnchor) {
1109
1119
 
1110
1120
  var self = this,
1111
- range = document.createRange(),
1112
- sel = window.getSelection();
1121
+ range = this.options.ownerDocument.createRange(),
1122
+ sel = this.options.contentWindow.getSelection();
1113
1123
 
1114
1124
  range.selectNodeContents(self.activeAnchor);
1115
1125
  sel.removeAllRanges();
@@ -1179,9 +1189,9 @@ if (typeof module === 'object') {
1179
1189
  return (re.test(value) ? '' : 'http://') + value;
1180
1190
  },
1181
1191
 
1182
- setTargetBlank: function () {
1183
- var el = getSelectionStart(),
1184
- i;
1192
+ setTargetBlank: function (el) {
1193
+ var i;
1194
+ el = el || getSelectionStart.call(this);
1185
1195
  if (el.tagName.toLowerCase() === 'a') {
1186
1196
  el.target = '_blank';
1187
1197
  } else {
@@ -1193,7 +1203,7 @@ if (typeof module === 'object') {
1193
1203
  },
1194
1204
 
1195
1205
  setButtonClass: function (buttonClass) {
1196
- var el = getSelectionStart(),
1206
+ var el = getSelectionStart.call(this),
1197
1207
  classes = buttonClass.split(' '),
1198
1208
  i, j;
1199
1209
  if (el.tagName.toLowerCase() === 'a') {
@@ -1218,13 +1228,13 @@ if (typeof module === 'object') {
1218
1228
  return;
1219
1229
  }
1220
1230
 
1221
- restoreSelection(this.savedSelection);
1231
+ restoreSelection.call(this, this.savedSelection);
1222
1232
 
1223
1233
  if (this.options.checkLinkFormat) {
1224
1234
  input.value = this.checkLinkFormat(input.value);
1225
1235
  }
1226
1236
 
1227
- document.execCommand('createLink', false, input.value);
1237
+ this.options.ownerDocument.execCommand('createLink', false, input.value);
1228
1238
 
1229
1239
  if (this.options.targetBlank || target === "_blank") {
1230
1240
  this.setTargetBlank();
@@ -1235,8 +1245,8 @@ if (typeof module === 'object') {
1235
1245
  }
1236
1246
 
1237
1247
  if (this.options.targetBlank || target === "_blank" || buttonClass) {
1238
- event = document.createEvent("HTMLEvents");
1239
- event.initEvent("input", true, true, window);
1248
+ event = this.options.ownerDocument.createEvent("HTMLEvents");
1249
+ event.initEvent("input", true, true, this.options.contentWindow);
1240
1250
  for (i = 0; i < this.elements.length; i += 1) {
1241
1251
  this.elements[i].dispatchEvent(event);
1242
1252
  }
@@ -1258,7 +1268,7 @@ if (typeof module === 'object') {
1258
1268
  }
1259
1269
  }, 100);
1260
1270
  };
1261
- window.addEventListener('resize', this.windowResizeHandler);
1271
+ this.options.contentWindow.addEventListener('resize', this.windowResizeHandler);
1262
1272
  return this;
1263
1273
  },
1264
1274
 
@@ -1285,8 +1295,8 @@ if (typeof module === 'object') {
1285
1295
  delete this.anchorPreview;
1286
1296
  }
1287
1297
 
1288
- document.documentElement.removeEventListener('mouseup', this.checkSelectionWrapper);
1289
- window.removeEventListener('resize', this.windowResizeHandler);
1298
+ this.options.ownerDocument.documentElement.removeEventListener('mouseup', this.checkSelectionWrapper);
1299
+ this.options.contentWindow.removeEventListener('resize', this.windowResizeHandler);
1290
1300
 
1291
1301
  for (i = 0; i < this.elements.length; i += 1) {
1292
1302
  this.elements[i].removeEventListener('mouseover', this.editorAnchorObserverWrapper);
@@ -1334,10 +1344,10 @@ if (typeof module === 'object') {
1334
1344
  }
1335
1345
  }
1336
1346
  }
1337
- document.execCommand('insertHTML', false, html);
1347
+ self.options.ownerDocument.execCommand('insertHTML', false, html);
1338
1348
  } else {
1339
1349
  html = self.htmlEntities(e.clipboardData.getData('text/plain'));
1340
- document.execCommand('insertHTML', false, html);
1350
+ self.options.ownerDocument.execCommand('insertHTML', false, html);
1341
1351
  }
1342
1352
  }
1343
1353
  };
@@ -1420,15 +1430,20 @@ if (typeof module === 'object') {
1420
1430
  elList = text.split('<br><br>');
1421
1431
 
1422
1432
  this.pasteHTML('<p>' + elList.join('</p><p>') + '</p>');
1423
- document.execCommand('insertText', false, "\n");
1433
+ this.options.ownerDocument.execCommand('insertText', false, "\n");
1424
1434
 
1425
1435
  // block element cleanup
1426
- elList = el.querySelectorAll('p,div,br');
1436
+ elList = el.querySelectorAll('a,p,div,br');
1427
1437
  for (i = 0; i < elList.length; i += 1) {
1428
1438
 
1429
1439
  workEl = elList[i];
1430
1440
 
1431
1441
  switch (workEl.tagName.toLowerCase()) {
1442
+ case 'a':
1443
+ if (this.options.targetBlank){
1444
+ this.setTargetBlank(workEl);
1445
+ }
1446
+ break;
1432
1447
  case 'p':
1433
1448
  case 'div':
1434
1449
  this.filterCommonBlocks(workEl);
@@ -1450,9 +1465,9 @@ if (typeof module === 'object') {
1450
1465
  },
1451
1466
 
1452
1467
  pasteHTML: function (html) {
1453
- var elList, workEl, i, fragmentBody, pasteBlock = document.createDocumentFragment();
1468
+ var elList, workEl, i, fragmentBody, pasteBlock = this.options.ownerDocument.createDocumentFragment();
1454
1469
 
1455
- pasteBlock.appendChild(document.createElement('body'));
1470
+ pasteBlock.appendChild(this.options.ownerDocument.createElement('body'));
1456
1471
 
1457
1472
  fragmentBody = pasteBlock.querySelector('body');
1458
1473
  fragmentBody.innerHTML = html;
@@ -1474,7 +1489,7 @@ if (typeof module === 'object') {
1474
1489
  }
1475
1490
 
1476
1491
  }
1477
- document.execCommand('insertHTML', false, fragmentBody.innerHTML.replace(/&nbsp;/g, ' '));
1492
+ this.options.ownerDocument.execCommand('insertHTML', false, fragmentBody.innerHTML.replace(/&nbsp;/g, ' '));
1478
1493
  },
1479
1494
  isCommonBlock: function (el) {
1480
1495
  return (el && (el.tagName.toLowerCase() === 'p' || el.tagName.toLowerCase() === 'div'));
@@ -1525,7 +1540,7 @@ if (typeof module === 'object') {
1525
1540
  for (i = 0; i < spans.length; i += 1) {
1526
1541
 
1527
1542
  el = spans[i];
1528
- new_el = document.createElement(el.classList.contains('bold') ? 'b' : 'i');
1543
+ new_el = this.options.ownerDocument.createElement(el.classList.contains('bold') ? 'b' : 'i');
1529
1544
 
1530
1545
  if (el.classList.contains('bold') && el.classList.contains('italic')) {
1531
1546
 
@@ -1550,7 +1565,7 @@ if (typeof module === 'object') {
1550
1565
  if (/^\s*$/.test()) {
1551
1566
  el.parentNode.removeChild(el);
1552
1567
  } else {
1553
- el.parentNode.replaceChild(document.createTextNode(el.innerText), el);
1568
+ el.parentNode.replaceChild(this.options.ownerDocument.createTextNode(el.innerText), el);
1554
1569
  }
1555
1570
 
1556
1571
  }
@@ -58,22 +58,6 @@
58
58
  transform: matrix(1, 0, 0, 1, 0, 0);
59
59
  opacity: 1; } }
60
60
 
61
- .btn {
62
- display: inline-block;
63
- margin-bottom: 0;
64
- font-weight: normal;
65
- text-align: center;
66
- vertical-align: middle;
67
- background: #efefef;
68
- border: 1px solid #ccc;
69
- white-space: nowrap;
70
- padding: 6px 12px;
71
- border-radius: 4px;
72
- color: #333;
73
- text-decoration: none; }
74
- .btn:hover {
75
- text-decoration: underline; }
76
-
77
61
  .medium-toolbar-arrow-under:after, .medium-toolbar-arrow-over:before {
78
62
  position: absolute;
79
63
  left: 50%;
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.12.0
4
+ version: 0.13.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-10-21 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -83,9 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
83
  version: '0'
84
84
  requirements: []
85
85
  rubyforge_project:
86
- rubygems_version: 2.2.2
86
+ rubygems_version: 2.4.2
87
87
  signing_key:
88
88
  specification_version: 4
89
89
  summary: Medium Editor integrated in Rails asset pipeline
90
90
  test_files: []
91
- has_rdoc: