Skip to content

Commit ad2d246

Browse files
author
Oliver Pulges
committed
Update version
1 parent 3c5047b commit ad2d246

9 files changed

+79
-62
lines changed

CHANGELOG.textile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
*wysihtml5x 0.5.0-beta8* (March 16, 2015)
2+
* Fixes table cell selector escaping editable context
3+
* Fixes some list toggling issues
4+
* Fixes object merge for ie8 and its usage on init
5+
16
*wysihtml5x 0.5.0-beta7* (March 6, 2015)
27
* Makes maine element classnames including placeholder configurable and prefixed (NB! .placeholder class is now .wysihtml5-placeholder)
38
* Changes API by grouping class names under classNames option

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wysihtml",
3-
"version": "0.5.0-beta7",
3+
"version": "0.5.0-beta8",
44
"main": "dist/wysihtml-toolbar.js",
55
"dependencies": {
66
},

dist/wysihtml-toolbar.js

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license wysihtml v0.5.0-beta7
2+
* @license wysihtml v0.5.0-beta8
33
* https://github.com/Voog/wysihtml
44
*
55
* Author: Christopher Blum (https://github.com/tiff)
@@ -10,7 +10,7 @@
1010
*
1111
*/
1212
var wysihtml5 = {
13-
version: "0.5.0-beta7",
13+
version: "0.5.0-beta8",
1414

1515
// namespaces
1616
commands: {},
@@ -4684,8 +4684,8 @@ wysihtml5.browser = (function() {
46844684
// When inserting unordered or ordered lists in Firefox, Chrome or Safari, the current selection or line gets
46854685
// converted into a list (<ul><li>...</li></ul>, <ol><li>...</li></ol>)
46864686
// 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, ">=")
46894689
};
46904690

46914691
// Firefox throws errors for queryCommandSupported, so we have to build up our own object of supported commands
@@ -5146,7 +5146,7 @@ wysihtml5.browser = (function() {
51465146
},
51475147

51485148
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);
51505150
}
51515151
};
51525152
};
@@ -7227,12 +7227,15 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
72277227
var doc = list.ownerDocument,
72287228
fragment = doc.createDocumentFragment(),
72297229
previousSibling = wysihtml5.dom.domNode(list).prev({ignoreBlankTexts: true}),
7230+
nextSibling = wysihtml5.dom.domNode(list).next({ignoreBlankTexts: true}),
72307231
firstChild,
72317232
lastChild,
72327233
isLastChild,
72337234
shouldAppendLineBreak,
72347235
paragraph,
7235-
listItem;
7236+
listItem,
7237+
lastListItem = list.lastElementChild || list.lastChild,
7238+
isLastItem;
72367239

72377240
if (useLineBreaks) {
72387241
// Insert line break if list is after a non-block element
@@ -7242,10 +7245,11 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
72427245

72437246
while (listItem = (list.firstElementChild || list.firstChild)) {
72447247
lastChild = listItem.lastChild;
7248+
isLastItem = listItem === lastListItem;
72457249
while (firstChild = listItem.firstChild) {
72467250
isLastChild = firstChild === lastChild;
72477251
// 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);
72497253
fragment.appendChild(firstChild);
72507254
if (shouldAppendLineBreak) {
72517255
_appendLineBreak(fragment);
@@ -8990,7 +8994,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
89908994
}
89918995

89928996
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);
89948998
if (target) {
89958999
handleSelectionMousedown(target);
89969000
}
@@ -9000,7 +9004,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
90009004
select.start = target;
90019005
select.end = target;
90029006
select.cells = [target];
9003-
select.table = dom.getParentElement(select.start, { query: "table" });
9007+
select.table = dom.getParentElement(select.start, { query: "table" }, false, editable);
90049008

90059009
if (select.table) {
90069010
removeCellSelections();
@@ -9031,11 +9035,11 @@ wysihtml5.quirks.ensureProperClearing = (function() {
90319035

90329036
function handleMouseMove (event) {
90339037
var curTable = null,
9034-
cell = dom.getParentElement(event.target, { query: "td, th" }),
9038+
cell = dom.getParentElement(event.target, { query: "td, th" }, false, editable),
90359039
oldEnd;
90369040

90379041
if (cell && select.table && select.start) {
9038-
curTable = dom.getParentElement(cell, { query: "table" });
9042+
curTable = dom.getParentElement(cell, { query: "table" }, false, editable);
90399043
if (curTable && curTable === select.table) {
90409044
removeCellSelections();
90419045
oldEnd = select.end;
@@ -9063,7 +9067,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
90639067

90649068
var sideClickHandler = function(event) {
90659069
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) {
90679071
removeCellSelections();
90689072
select.table = null;
90699073
select.start = null;
@@ -9079,7 +9083,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
90799083
function selectCells (start, end) {
90809084
select.start = start;
90819085
select.end = end;
9082-
select.table = dom.getParentElement(select.start, { query: "table" });
9086+
select.table = dom.getParentElement(select.start, { query: "table" }, false, editable);
90839087
selectedCells = dom.table.getCellsBetween(select.start, select.end);
90849088
addSelections(selectedCells);
90859089
bindSideclick();
@@ -12132,7 +12136,7 @@ wysihtml5.Commands = Base.extend(
1213212136
};
1213312137

1213412138
if (node) {
12135-
var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }),
12139+
var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }, false, composer.element),
1213612140
otherNodeName = (nodeName === "UL") ? "OL" : "UL";
1213712141

1213812142
if (isNode(node, nodeName)) {
@@ -12169,8 +12173,9 @@ wysihtml5.Commands = Base.extend(
1216912173
// <ul><li>foo</li><li>bar</li></ul>
1217012174
// becomes:
1217112175
// 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);
1217412179
if (otherLists.length) {
1217512180
for (var l = otherLists.length; l--;) {
1217612181
wysihtml5.dom.renameElement(otherLists[l], nodeName.toLowerCase());
@@ -12192,7 +12197,7 @@ wysihtml5.Commands = Base.extend(
1219212197
// becomes:
1219312198
// <ul><li>foo</li><li>bar</li></ul>
1219412199
// Also rename other lists in selection
12195-
composer.selection.executeAndRestore(function() {
12200+
composer.selection.executeAndRestoreRangy(function() {
1219612201
var renameLists = [el].concat(getListsInSelection(otherNodeName, composer));
1219712202

1219812203
// All selection inner lists get renamed too
@@ -12246,6 +12251,7 @@ wysihtml5.Commands = Base.extend(
1224612251
selectedNode = composer.selection.getSelectedNode(),
1224712252
list = findListEl(selectedNode, nodeName, composer);
1224812253

12254+
1224912255
if (!list.el) {
1225012256
if (composer.commands.support(cmd)) {
1225112257
doc.execCommand(cmd, false, null);
@@ -14395,12 +14401,12 @@ wysihtml5.views.View = Base.extend(
1439514401
/** @scope wysihtml5.Editor.prototype */ {
1439614402
constructor: function(editableElement, config) {
1439714403
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();
1439914405
this._isCompatible = wysihtml5.browser.supported();
1440014406

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);
1440414410
}
1440514411

1440614412
if (this.editableElement.nodeName.toLowerCase() != "textarea") {

dist/wysihtml-toolbar.min.js

Lines changed: 8 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/wysihtml-toolbar.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/wysihtml.js

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* @license wysihtml v0.5.0-beta7
2+
* @license wysihtml v0.5.0-beta8
33
* https://github.com/Voog/wysihtml
44
*
55
* Author: Christopher Blum (https://github.com/tiff)
@@ -10,7 +10,7 @@
1010
*
1111
*/
1212
var wysihtml5 = {
13-
version: "0.5.0-beta7",
13+
version: "0.5.0-beta8",
1414

1515
// namespaces
1616
commands: {},
@@ -4684,8 +4684,8 @@ wysihtml5.browser = (function() {
46844684
// When inserting unordered or ordered lists in Firefox, Chrome or Safari, the current selection or line gets
46854685
// converted into a list (<ul><li>...</li></ul>, <ol><li>...</li></ol>)
46864686
// 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, ">=")
46894689
};
46904690

46914691
// Firefox throws errors for queryCommandSupported, so we have to build up our own object of supported commands
@@ -5146,7 +5146,7 @@ wysihtml5.browser = (function() {
51465146
},
51475147

51485148
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);
51505150
}
51515151
};
51525152
};
@@ -7227,12 +7227,15 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
72277227
var doc = list.ownerDocument,
72287228
fragment = doc.createDocumentFragment(),
72297229
previousSibling = wysihtml5.dom.domNode(list).prev({ignoreBlankTexts: true}),
7230+
nextSibling = wysihtml5.dom.domNode(list).next({ignoreBlankTexts: true}),
72307231
firstChild,
72317232
lastChild,
72327233
isLastChild,
72337234
shouldAppendLineBreak,
72347235
paragraph,
7235-
listItem;
7236+
listItem,
7237+
lastListItem = list.lastElementChild || list.lastChild,
7238+
isLastItem;
72367239

72377240
if (useLineBreaks) {
72387241
// Insert line break if list is after a non-block element
@@ -7242,10 +7245,11 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
72427245

72437246
while (listItem = (list.firstElementChild || list.firstChild)) {
72447247
lastChild = listItem.lastChild;
7248+
isLastItem = listItem === lastListItem;
72457249
while (firstChild = listItem.firstChild) {
72467250
isLastChild = firstChild === lastChild;
72477251
// 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);
72497253
fragment.appendChild(firstChild);
72507254
if (shouldAppendLineBreak) {
72517255
_appendLineBreak(fragment);
@@ -8990,7 +8994,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
89908994
}
89918995

89928996
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);
89948998
if (target) {
89958999
handleSelectionMousedown(target);
89969000
}
@@ -9000,7 +9004,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
90009004
select.start = target;
90019005
select.end = target;
90029006
select.cells = [target];
9003-
select.table = dom.getParentElement(select.start, { query: "table" });
9007+
select.table = dom.getParentElement(select.start, { query: "table" }, false, editable);
90049008

90059009
if (select.table) {
90069010
removeCellSelections();
@@ -9031,11 +9035,11 @@ wysihtml5.quirks.ensureProperClearing = (function() {
90319035

90329036
function handleMouseMove (event) {
90339037
var curTable = null,
9034-
cell = dom.getParentElement(event.target, { query: "td, th" }),
9038+
cell = dom.getParentElement(event.target, { query: "td, th" }, false, editable),
90359039
oldEnd;
90369040

90379041
if (cell && select.table && select.start) {
9038-
curTable = dom.getParentElement(cell, { query: "table" });
9042+
curTable = dom.getParentElement(cell, { query: "table" }, false, editable);
90399043
if (curTable && curTable === select.table) {
90409044
removeCellSelections();
90419045
oldEnd = select.end;
@@ -9063,7 +9067,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
90639067

90649068
var sideClickHandler = function(event) {
90659069
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) {
90679071
removeCellSelections();
90689072
select.table = null;
90699073
select.start = null;
@@ -9079,7 +9083,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
90799083
function selectCells (start, end) {
90809084
select.start = start;
90819085
select.end = end;
9082-
select.table = dom.getParentElement(select.start, { query: "table" });
9086+
select.table = dom.getParentElement(select.start, { query: "table" }, false, editable);
90839087
selectedCells = dom.table.getCellsBetween(select.start, select.end);
90849088
addSelections(selectedCells);
90859089
bindSideclick();
@@ -12132,7 +12136,7 @@ wysihtml5.Commands = Base.extend(
1213212136
};
1213312137

1213412138
if (node) {
12135-
var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }),
12139+
var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }, false, composer.element),
1213612140
otherNodeName = (nodeName === "UL") ? "OL" : "UL";
1213712141

1213812142
if (isNode(node, nodeName)) {
@@ -12169,8 +12173,9 @@ wysihtml5.Commands = Base.extend(
1216912173
// <ul><li>foo</li><li>bar</li></ul>
1217012174
// becomes:
1217112175
// 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);
1217412179
if (otherLists.length) {
1217512180
for (var l = otherLists.length; l--;) {
1217612181
wysihtml5.dom.renameElement(otherLists[l], nodeName.toLowerCase());
@@ -12192,7 +12197,7 @@ wysihtml5.Commands = Base.extend(
1219212197
// becomes:
1219312198
// <ul><li>foo</li><li>bar</li></ul>
1219412199
// Also rename other lists in selection
12195-
composer.selection.executeAndRestore(function() {
12200+
composer.selection.executeAndRestoreRangy(function() {
1219612201
var renameLists = [el].concat(getListsInSelection(otherNodeName, composer));
1219712202

1219812203
// All selection inner lists get renamed too
@@ -12246,6 +12251,7 @@ wysihtml5.Commands = Base.extend(
1224612251
selectedNode = composer.selection.getSelectedNode(),
1224712252
list = findListEl(selectedNode, nodeName, composer);
1224812253

12254+
1224912255
if (!list.el) {
1225012256
if (composer.commands.support(cmd)) {
1225112257
doc.execCommand(cmd, false, null);
@@ -14395,12 +14401,12 @@ wysihtml5.views.View = Base.extend(
1439514401
/** @scope wysihtml5.Editor.prototype */ {
1439614402
constructor: function(editableElement, config) {
1439714403
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();
1439914405
this._isCompatible = wysihtml5.browser.supported();
1440014406

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);
1440414410
}
1440514411

1440614412
if (this.editableElement.nodeName.toLowerCase() != "textarea") {

dist/wysihtml.min.js

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/wysihtml.min.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "wysihtml",
3-
"version": "0.5.0-beta7",
3+
"version": "0.5.0-beta8",
44
"devDependencies": {
55
"grunt": "~0.4.4",
66
"grunt-contrib-concat": "~0.4.0",
@@ -15,7 +15,7 @@
1515
"dependencies": {
1616
"rangy": "^1.3.0-alpha.20140921"
1717
},
18-
"description": "h1. wysihtml 0.5.0-beta7",
18+
"description": "h1. wysihtml 0.5.0-beta8",
1919
"main": "Gruntfile.js",
2020
"directories": {
2121
"example": "examples",

0 commit comments

Comments
 (0)