wysihtml-rails 0.5.0.beta7 → 0.5.0.beta8

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: 64f3d46ae259b28d6540ada222ddc2254e450305
4
- data.tar.gz: b6124307107e3a712ad473e5461da9ca128c1e8d
3
+ metadata.gz: ad7139f85a6baa918d3ccb084f49bd310c7e3422
4
+ data.tar.gz: c11cfb988f9d9428426283ca244c7d47253401ef
5
5
  SHA512:
6
- metadata.gz: d741717b1e1b496c1f3073f6b7a1ed16bd891ef69d5712342a860befc67880cef51e5e630dbd7cea70f48d7517404d065ceabb4671b0863e9a3e8088c44d8890
7
- data.tar.gz: 1eca60fa61f5ef49a5e21873ff6a5610622b059a1e06687c0776215e489d62344fc9c43d716ff1d1343ce8bdbeca8ae880aaebeb4683948031587f8da3732dcd
6
+ metadata.gz: 4de3c6dde3a86c14dc00968bd912c76f977630649f1db2ce3987a0a05386eac89f4039e178286a5ddd6eedfe851f67e8b84dfc3138eade2a6740a45c85c08331
7
+ data.tar.gz: 1a1ed7532158cd3a900554727d6b75bacc1647dc26470b13853b34faf8a957649daa9c182350bbd92e1d8e7d8cce85ed60d98dbdf9f5f0f32ead6b5c190b26c8
@@ -1,5 +1,5 @@
1
1
  module Wysihtml
2
2
  module Rails
3
- VERSION = "0.5.0.beta7"
3
+ VERSION = "0.5.0.beta8"
4
4
  end
5
5
  end
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license wysihtml v0.5.0-beta7
2
+ * @license wysihtml v0.5.0-beta8
3
3
  * https://github.com/Voog/wysihtml
4
4
  *
5
5
  * Author: Christopher Blum (https://github.com/tiff)
@@ -10,7 +10,7 @@
10
10
  *
11
11
  */
12
12
  var wysihtml5 = {
13
- version: "0.5.0-beta7",
13
+ version: "0.5.0-beta8",
14
14
 
15
15
  // namespaces
16
16
  commands: {},
@@ -4684,8 +4684,8 @@ wysihtml5.browser = (function() {
4684
4684
  // When inserting unordered or ordered lists in Firefox, Chrome or Safari, the current selection or line gets
4685
4685
  // converted into a list (<ul><li>...</li></ul>, <ol><li>...</li></ol>)
4686
4686
  // IE and Opera act a bit different here as they convert the entire content of the current block element into a list
4687
- "insertUnorderedList": isIE(),
4688
- "insertOrderedList": isIE()
4687
+ "insertUnorderedList": isIE(9, ">="),
4688
+ "insertOrderedList": isIE(9, ">=")
4689
4689
  };
4690
4690
 
4691
4691
  // Firefox throws errors for queryCommandSupported, so we have to build up our own object of supported commands
@@ -5146,7 +5146,7 @@ wysihtml5.browser = (function() {
5146
5146
  },
5147
5147
 
5148
5148
  isPlainObject: function () {
5149
- return obj && Object.prototype.toString.call(obj) === '[object Object]';
5149
+ return obj && Object.prototype.toString.call(obj) === '[object Object]' && !(("Node" in window) ? obj instanceof Node : obj instanceof Element || obj instanceof Text);
5150
5150
  }
5151
5151
  };
5152
5152
  };
@@ -7227,12 +7227,15 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
7227
7227
  var doc = list.ownerDocument,
7228
7228
  fragment = doc.createDocumentFragment(),
7229
7229
  previousSibling = wysihtml5.dom.domNode(list).prev({ignoreBlankTexts: true}),
7230
+ nextSibling = wysihtml5.dom.domNode(list).next({ignoreBlankTexts: true}),
7230
7231
  firstChild,
7231
7232
  lastChild,
7232
7233
  isLastChild,
7233
7234
  shouldAppendLineBreak,
7234
7235
  paragraph,
7235
- listItem;
7236
+ listItem,
7237
+ lastListItem = list.lastElementChild || list.lastChild,
7238
+ isLastItem;
7236
7239
 
7237
7240
  if (useLineBreaks) {
7238
7241
  // Insert line break if list is after a non-block element
@@ -7242,10 +7245,11 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
7242
7245
 
7243
7246
  while (listItem = (list.firstElementChild || list.firstChild)) {
7244
7247
  lastChild = listItem.lastChild;
7248
+ isLastItem = listItem === lastListItem;
7245
7249
  while (firstChild = listItem.firstChild) {
7246
7250
  isLastChild = firstChild === lastChild;
7247
7251
  // This needs to be done before appending it to the fragment, as it otherwise will lose style information
7248
- shouldAppendLineBreak = isLastChild && !_isBlockElement(firstChild) && !_isLineBreak(firstChild);
7252
+ shouldAppendLineBreak = (!isLastItem || (nextSibling && !_isBlockElement(nextSibling))) && isLastChild && !_isBlockElement(firstChild) && !_isLineBreak(firstChild);
7249
7253
  fragment.appendChild(firstChild);
7250
7254
  if (shouldAppendLineBreak) {
7251
7255
  _appendLineBreak(fragment);
@@ -8990,7 +8994,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
8990
8994
  }
8991
8995
 
8992
8996
  var handleMouseDown = function(event) {
8993
- var target = wysihtml5.dom.getParentElement(event.target, { query: "td, th" });
8997
+ var target = wysihtml5.dom.getParentElement(event.target, { query: "td, th" }, false, editable);
8994
8998
  if (target) {
8995
8999
  handleSelectionMousedown(target);
8996
9000
  }
@@ -9000,7 +9004,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
9000
9004
  select.start = target;
9001
9005
  select.end = target;
9002
9006
  select.cells = [target];
9003
- select.table = dom.getParentElement(select.start, { query: "table" });
9007
+ select.table = dom.getParentElement(select.start, { query: "table" }, false, editable);
9004
9008
 
9005
9009
  if (select.table) {
9006
9010
  removeCellSelections();
@@ -9031,11 +9035,11 @@ wysihtml5.quirks.ensureProperClearing = (function() {
9031
9035
 
9032
9036
  function handleMouseMove (event) {
9033
9037
  var curTable = null,
9034
- cell = dom.getParentElement(event.target, { query: "td, th" }),
9038
+ cell = dom.getParentElement(event.target, { query: "td, th" }, false, editable),
9035
9039
  oldEnd;
9036
9040
 
9037
9041
  if (cell && select.table && select.start) {
9038
- curTable = dom.getParentElement(cell, { query: "table" });
9042
+ curTable = dom.getParentElement(cell, { query: "table" }, false, editable);
9039
9043
  if (curTable && curTable === select.table) {
9040
9044
  removeCellSelections();
9041
9045
  oldEnd = select.end;
@@ -9063,7 +9067,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
9063
9067
 
9064
9068
  var sideClickHandler = function(event) {
9065
9069
  editable.ownerDocument.removeEventListener("click", sideClickHandler);
9066
- if (dom.getParentElement(event.target, { query: "table" }) != select.table) {
9070
+ if (dom.getParentElement(event.target, { query: "table" }, false, editable) != select.table) {
9067
9071
  removeCellSelections();
9068
9072
  select.table = null;
9069
9073
  select.start = null;
@@ -9079,7 +9083,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
9079
9083
  function selectCells (start, end) {
9080
9084
  select.start = start;
9081
9085
  select.end = end;
9082
- select.table = dom.getParentElement(select.start, { query: "table" });
9086
+ select.table = dom.getParentElement(select.start, { query: "table" }, false, editable);
9083
9087
  selectedCells = dom.table.getCellsBetween(select.start, select.end);
9084
9088
  addSelections(selectedCells);
9085
9089
  bindSideclick();
@@ -12132,7 +12136,7 @@ wysihtml5.Commands = Base.extend(
12132
12136
  };
12133
12137
 
12134
12138
  if (node) {
12135
- var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }),
12139
+ var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }, false, composer.element),
12136
12140
  otherNodeName = (nodeName === "UL") ? "OL" : "UL";
12137
12141
 
12138
12142
  if (isNode(node, nodeName)) {
@@ -12169,8 +12173,9 @@ wysihtml5.Commands = Base.extend(
12169
12173
  // <ul><li>foo</li><li>bar</li></ul>
12170
12174
  // becomes:
12171
12175
  // foo<br>bar<br>
12172
- composer.selection.executeAndRestore(function() {
12173
- var otherLists = getListsInSelection(otherNodeName, composer);
12176
+
12177
+ composer.selection.executeAndRestoreRangy(function() {
12178
+ otherLists = getListsInSelection(otherNodeName, composer);
12174
12179
  if (otherLists.length) {
12175
12180
  for (var l = otherLists.length; l--;) {
12176
12181
  wysihtml5.dom.renameElement(otherLists[l], nodeName.toLowerCase());
@@ -12192,7 +12197,7 @@ wysihtml5.Commands = Base.extend(
12192
12197
  // becomes:
12193
12198
  // <ul><li>foo</li><li>bar</li></ul>
12194
12199
  // Also rename other lists in selection
12195
- composer.selection.executeAndRestore(function() {
12200
+ composer.selection.executeAndRestoreRangy(function() {
12196
12201
  var renameLists = [el].concat(getListsInSelection(otherNodeName, composer));
12197
12202
 
12198
12203
  // All selection inner lists get renamed too
@@ -12246,6 +12251,7 @@ wysihtml5.Commands = Base.extend(
12246
12251
  selectedNode = composer.selection.getSelectedNode(),
12247
12252
  list = findListEl(selectedNode, nodeName, composer);
12248
12253
 
12254
+
12249
12255
  if (!list.el) {
12250
12256
  if (composer.commands.support(cmd)) {
12251
12257
  doc.execCommand(cmd, false, null);
@@ -14395,12 +14401,12 @@ wysihtml5.views.View = Base.extend(
14395
14401
  /** @scope wysihtml5.Editor.prototype */ {
14396
14402
  constructor: function(editableElement, config) {
14397
14403
  this.editableElement = typeof(editableElement) === "string" ? document.getElementById(editableElement) : editableElement;
14398
- this.config = wysihtml5.lang.object({}).merge(defaultConfig).merge(config, true).get();
14404
+ this.config = wysihtml5.lang.object({}).merge(defaultConfig).merge(config).get();
14399
14405
  this._isCompatible = wysihtml5.browser.supported();
14400
14406
 
14401
- // make sure that rules override instead of extend
14402
- if (config && config.parserRules) {
14403
- this.config.parserRules = wysihtml5.lang.object(config.parserRules).clone(true);
14407
+ // merge classNames
14408
+ if (config && config.classNames) {
14409
+ wysihtml5.lang.object(this.config.classNames).merge(config.classNames);
14404
14410
  }
14405
14411
 
14406
14412
  if (this.editableElement.nodeName.toLowerCase() != "textarea") {
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @license wysihtml v0.5.0-beta7
2
+ * @license wysihtml v0.5.0-beta8
3
3
  * https://github.com/Voog/wysihtml
4
4
  *
5
5
  * Author: Christopher Blum (https://github.com/tiff)
@@ -10,7 +10,7 @@
10
10
  *
11
11
  */
12
12
  var wysihtml5 = {
13
- version: "0.5.0-beta7",
13
+ version: "0.5.0-beta8",
14
14
 
15
15
  // namespaces
16
16
  commands: {},
@@ -4684,8 +4684,8 @@ wysihtml5.browser = (function() {
4684
4684
  // When inserting unordered or ordered lists in Firefox, Chrome or Safari, the current selection or line gets
4685
4685
  // converted into a list (<ul><li>...</li></ul>, <ol><li>...</li></ol>)
4686
4686
  // IE and Opera act a bit different here as they convert the entire content of the current block element into a list
4687
- "insertUnorderedList": isIE(),
4688
- "insertOrderedList": isIE()
4687
+ "insertUnorderedList": isIE(9, ">="),
4688
+ "insertOrderedList": isIE(9, ">=")
4689
4689
  };
4690
4690
 
4691
4691
  // Firefox throws errors for queryCommandSupported, so we have to build up our own object of supported commands
@@ -5146,7 +5146,7 @@ wysihtml5.browser = (function() {
5146
5146
  },
5147
5147
 
5148
5148
  isPlainObject: function () {
5149
- return obj && Object.prototype.toString.call(obj) === '[object Object]';
5149
+ return obj && Object.prototype.toString.call(obj) === '[object Object]' && !(("Node" in window) ? obj instanceof Node : obj instanceof Element || obj instanceof Text);
5150
5150
  }
5151
5151
  };
5152
5152
  };
@@ -7227,12 +7227,15 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
7227
7227
  var doc = list.ownerDocument,
7228
7228
  fragment = doc.createDocumentFragment(),
7229
7229
  previousSibling = wysihtml5.dom.domNode(list).prev({ignoreBlankTexts: true}),
7230
+ nextSibling = wysihtml5.dom.domNode(list).next({ignoreBlankTexts: true}),
7230
7231
  firstChild,
7231
7232
  lastChild,
7232
7233
  isLastChild,
7233
7234
  shouldAppendLineBreak,
7234
7235
  paragraph,
7235
- listItem;
7236
+ listItem,
7237
+ lastListItem = list.lastElementChild || list.lastChild,
7238
+ isLastItem;
7236
7239
 
7237
7240
  if (useLineBreaks) {
7238
7241
  // Insert line break if list is after a non-block element
@@ -7242,10 +7245,11 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
7242
7245
 
7243
7246
  while (listItem = (list.firstElementChild || list.firstChild)) {
7244
7247
  lastChild = listItem.lastChild;
7248
+ isLastItem = listItem === lastListItem;
7245
7249
  while (firstChild = listItem.firstChild) {
7246
7250
  isLastChild = firstChild === lastChild;
7247
7251
  // This needs to be done before appending it to the fragment, as it otherwise will lose style information
7248
- shouldAppendLineBreak = isLastChild && !_isBlockElement(firstChild) && !_isLineBreak(firstChild);
7252
+ shouldAppendLineBreak = (!isLastItem || (nextSibling && !_isBlockElement(nextSibling))) && isLastChild && !_isBlockElement(firstChild) && !_isLineBreak(firstChild);
7249
7253
  fragment.appendChild(firstChild);
7250
7254
  if (shouldAppendLineBreak) {
7251
7255
  _appendLineBreak(fragment);
@@ -8990,7 +8994,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
8990
8994
  }
8991
8995
 
8992
8996
  var handleMouseDown = function(event) {
8993
- var target = wysihtml5.dom.getParentElement(event.target, { query: "td, th" });
8997
+ var target = wysihtml5.dom.getParentElement(event.target, { query: "td, th" }, false, editable);
8994
8998
  if (target) {
8995
8999
  handleSelectionMousedown(target);
8996
9000
  }
@@ -9000,7 +9004,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
9000
9004
  select.start = target;
9001
9005
  select.end = target;
9002
9006
  select.cells = [target];
9003
- select.table = dom.getParentElement(select.start, { query: "table" });
9007
+ select.table = dom.getParentElement(select.start, { query: "table" }, false, editable);
9004
9008
 
9005
9009
  if (select.table) {
9006
9010
  removeCellSelections();
@@ -9031,11 +9035,11 @@ wysihtml5.quirks.ensureProperClearing = (function() {
9031
9035
 
9032
9036
  function handleMouseMove (event) {
9033
9037
  var curTable = null,
9034
- cell = dom.getParentElement(event.target, { query: "td, th" }),
9038
+ cell = dom.getParentElement(event.target, { query: "td, th" }, false, editable),
9035
9039
  oldEnd;
9036
9040
 
9037
9041
  if (cell && select.table && select.start) {
9038
- curTable = dom.getParentElement(cell, { query: "table" });
9042
+ curTable = dom.getParentElement(cell, { query: "table" }, false, editable);
9039
9043
  if (curTable && curTable === select.table) {
9040
9044
  removeCellSelections();
9041
9045
  oldEnd = select.end;
@@ -9063,7 +9067,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
9063
9067
 
9064
9068
  var sideClickHandler = function(event) {
9065
9069
  editable.ownerDocument.removeEventListener("click", sideClickHandler);
9066
- if (dom.getParentElement(event.target, { query: "table" }) != select.table) {
9070
+ if (dom.getParentElement(event.target, { query: "table" }, false, editable) != select.table) {
9067
9071
  removeCellSelections();
9068
9072
  select.table = null;
9069
9073
  select.start = null;
@@ -9079,7 +9083,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
9079
9083
  function selectCells (start, end) {
9080
9084
  select.start = start;
9081
9085
  select.end = end;
9082
- select.table = dom.getParentElement(select.start, { query: "table" });
9086
+ select.table = dom.getParentElement(select.start, { query: "table" }, false, editable);
9083
9087
  selectedCells = dom.table.getCellsBetween(select.start, select.end);
9084
9088
  addSelections(selectedCells);
9085
9089
  bindSideclick();
@@ -12132,7 +12136,7 @@ wysihtml5.Commands = Base.extend(
12132
12136
  };
12133
12137
 
12134
12138
  if (node) {
12135
- var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }),
12139
+ var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }, false, composer.element),
12136
12140
  otherNodeName = (nodeName === "UL") ? "OL" : "UL";
12137
12141
 
12138
12142
  if (isNode(node, nodeName)) {
@@ -12169,8 +12173,9 @@ wysihtml5.Commands = Base.extend(
12169
12173
  // <ul><li>foo</li><li>bar</li></ul>
12170
12174
  // becomes:
12171
12175
  // foo<br>bar<br>
12172
- composer.selection.executeAndRestore(function() {
12173
- var otherLists = getListsInSelection(otherNodeName, composer);
12176
+
12177
+ composer.selection.executeAndRestoreRangy(function() {
12178
+ otherLists = getListsInSelection(otherNodeName, composer);
12174
12179
  if (otherLists.length) {
12175
12180
  for (var l = otherLists.length; l--;) {
12176
12181
  wysihtml5.dom.renameElement(otherLists[l], nodeName.toLowerCase());
@@ -12192,7 +12197,7 @@ wysihtml5.Commands = Base.extend(
12192
12197
  // becomes:
12193
12198
  // <ul><li>foo</li><li>bar</li></ul>
12194
12199
  // Also rename other lists in selection
12195
- composer.selection.executeAndRestore(function() {
12200
+ composer.selection.executeAndRestoreRangy(function() {
12196
12201
  var renameLists = [el].concat(getListsInSelection(otherNodeName, composer));
12197
12202
 
12198
12203
  // All selection inner lists get renamed too
@@ -12246,6 +12251,7 @@ wysihtml5.Commands = Base.extend(
12246
12251
  selectedNode = composer.selection.getSelectedNode(),
12247
12252
  list = findListEl(selectedNode, nodeName, composer);
12248
12253
 
12254
+
12249
12255
  if (!list.el) {
12250
12256
  if (composer.commands.support(cmd)) {
12251
12257
  doc.execCommand(cmd, false, null);
@@ -14395,12 +14401,12 @@ wysihtml5.views.View = Base.extend(
14395
14401
  /** @scope wysihtml5.Editor.prototype */ {
14396
14402
  constructor: function(editableElement, config) {
14397
14403
  this.editableElement = typeof(editableElement) === "string" ? document.getElementById(editableElement) : editableElement;
14398
- this.config = wysihtml5.lang.object({}).merge(defaultConfig).merge(config, true).get();
14404
+ this.config = wysihtml5.lang.object({}).merge(defaultConfig).merge(config).get();
14399
14405
  this._isCompatible = wysihtml5.browser.supported();
14400
14406
 
14401
- // make sure that rules override instead of extend
14402
- if (config && config.parserRules) {
14403
- this.config.parserRules = wysihtml5.lang.object(config.parserRules).clone(true);
14407
+ // merge classNames
14408
+ if (config && config.classNames) {
14409
+ wysihtml5.lang.object(this.config.classNames).merge(config.classNames);
14404
14410
  }
14405
14411
 
14406
14412
  if (this.editableElement.nodeName.toLowerCase() != "textarea") {
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wysihtml-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.beta7
4
+ version: 0.5.0.beta8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tanel Jakobsoo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-06 00:00:00.000000000 Z
11
+ date: 2015-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties