Skip to content

Commit

Permalink
Update version
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Pulges committed Mar 16, 2015
1 parent 3c5047b commit ad2d246
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 62 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.textile
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
*wysihtml5x 0.5.0-beta8* (March 16, 2015)
* Fixes table cell selector escaping editable context
* Fixes some list toggling issues
* Fixes object merge for ie8 and its usage on init

*wysihtml5x 0.5.0-beta7* (March 6, 2015)
* Makes maine element classnames including placeholder configurable and prefixed (NB! .placeholder class is now .wysihtml5-placeholder)
* Changes API by grouping class names under classNames option
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wysihtml",
"version": "0.5.0-beta7",
"version": "0.5.0-beta8",
"main": "dist/wysihtml-toolbar.js",
"dependencies": {
},
Expand Down
48 changes: 27 additions & 21 deletions dist/wysihtml-toolbar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @license wysihtml v0.5.0-beta7
* @license wysihtml v0.5.0-beta8
* https://github.com/Voog/wysihtml
*
* Author: Christopher Blum (https://github.com/tiff)
Expand All @@ -10,7 +10,7 @@
*
*/
var wysihtml5 = {
version: "0.5.0-beta7",
version: "0.5.0-beta8",

// namespaces
commands: {},
Expand Down Expand Up @@ -4684,8 +4684,8 @@ wysihtml5.browser = (function() {
// When inserting unordered or ordered lists in Firefox, Chrome or Safari, the current selection or line gets
// converted into a list (<ul><li>...</li></ul>, <ol><li>...</li></ol>)
// IE and Opera act a bit different here as they convert the entire content of the current block element into a list
"insertUnorderedList": isIE(),
"insertOrderedList": isIE()
"insertUnorderedList": isIE(9, ">="),
"insertOrderedList": isIE(9, ">=")
};

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

isPlainObject: function () {
return obj && Object.prototype.toString.call(obj) === '[object Object]';
return obj && Object.prototype.toString.call(obj) === '[object Object]' && !(("Node" in window) ? obj instanceof Node : obj instanceof Element || obj instanceof Text);
}
};
};
Expand Down Expand Up @@ -7227,12 +7227,15 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
var doc = list.ownerDocument,
fragment = doc.createDocumentFragment(),
previousSibling = wysihtml5.dom.domNode(list).prev({ignoreBlankTexts: true}),
nextSibling = wysihtml5.dom.domNode(list).next({ignoreBlankTexts: true}),
firstChild,
lastChild,
isLastChild,
shouldAppendLineBreak,
paragraph,
listItem;
listItem,
lastListItem = list.lastElementChild || list.lastChild,
isLastItem;

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

while (listItem = (list.firstElementChild || list.firstChild)) {
lastChild = listItem.lastChild;
isLastItem = listItem === lastListItem;
while (firstChild = listItem.firstChild) {
isLastChild = firstChild === lastChild;
// This needs to be done before appending it to the fragment, as it otherwise will lose style information
shouldAppendLineBreak = isLastChild && !_isBlockElement(firstChild) && !_isLineBreak(firstChild);
shouldAppendLineBreak = (!isLastItem || (nextSibling && !_isBlockElement(nextSibling))) && isLastChild && !_isBlockElement(firstChild) && !_isLineBreak(firstChild);
fragment.appendChild(firstChild);
if (shouldAppendLineBreak) {
_appendLineBreak(fragment);
Expand Down Expand Up @@ -8990,7 +8994,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
}

var handleMouseDown = function(event) {
var target = wysihtml5.dom.getParentElement(event.target, { query: "td, th" });
var target = wysihtml5.dom.getParentElement(event.target, { query: "td, th" }, false, editable);
if (target) {
handleSelectionMousedown(target);
}
Expand All @@ -9000,7 +9004,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
select.start = target;
select.end = target;
select.cells = [target];
select.table = dom.getParentElement(select.start, { query: "table" });
select.table = dom.getParentElement(select.start, { query: "table" }, false, editable);

if (select.table) {
removeCellSelections();
Expand Down Expand Up @@ -9031,11 +9035,11 @@ wysihtml5.quirks.ensureProperClearing = (function() {

function handleMouseMove (event) {
var curTable = null,
cell = dom.getParentElement(event.target, { query: "td, th" }),
cell = dom.getParentElement(event.target, { query: "td, th" }, false, editable),
oldEnd;

if (cell && select.table && select.start) {
curTable = dom.getParentElement(cell, { query: "table" });
curTable = dom.getParentElement(cell, { query: "table" }, false, editable);
if (curTable && curTable === select.table) {
removeCellSelections();
oldEnd = select.end;
Expand Down Expand Up @@ -9063,7 +9067,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {

var sideClickHandler = function(event) {
editable.ownerDocument.removeEventListener("click", sideClickHandler);
if (dom.getParentElement(event.target, { query: "table" }) != select.table) {
if (dom.getParentElement(event.target, { query: "table" }, false, editable) != select.table) {
removeCellSelections();
select.table = null;
select.start = null;
Expand All @@ -9079,7 +9083,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
function selectCells (start, end) {
select.start = start;
select.end = end;
select.table = dom.getParentElement(select.start, { query: "table" });
select.table = dom.getParentElement(select.start, { query: "table" }, false, editable);
selectedCells = dom.table.getCellsBetween(select.start, select.end);
addSelections(selectedCells);
bindSideclick();
Expand Down Expand Up @@ -12132,7 +12136,7 @@ wysihtml5.Commands = Base.extend(
};

if (node) {
var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }),
var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }, false, composer.element),
otherNodeName = (nodeName === "UL") ? "OL" : "UL";

if (isNode(node, nodeName)) {
Expand Down Expand Up @@ -12169,8 +12173,9 @@ wysihtml5.Commands = Base.extend(
// <ul><li>foo</li><li>bar</li></ul>
// becomes:
// foo<br>bar<br>
composer.selection.executeAndRestore(function() {
var otherLists = getListsInSelection(otherNodeName, composer);

composer.selection.executeAndRestoreRangy(function() {
otherLists = getListsInSelection(otherNodeName, composer);
if (otherLists.length) {
for (var l = otherLists.length; l--;) {
wysihtml5.dom.renameElement(otherLists[l], nodeName.toLowerCase());
Expand All @@ -12192,7 +12197,7 @@ wysihtml5.Commands = Base.extend(
// becomes:
// <ul><li>foo</li><li>bar</li></ul>
// Also rename other lists in selection
composer.selection.executeAndRestore(function() {
composer.selection.executeAndRestoreRangy(function() {
var renameLists = [el].concat(getListsInSelection(otherNodeName, composer));

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


if (!list.el) {
if (composer.commands.support(cmd)) {
doc.execCommand(cmd, false, null);
Expand Down Expand Up @@ -14395,12 +14401,12 @@ wysihtml5.views.View = Base.extend(
/** @scope wysihtml5.Editor.prototype */ {
constructor: function(editableElement, config) {
this.editableElement = typeof(editableElement) === "string" ? document.getElementById(editableElement) : editableElement;
this.config = wysihtml5.lang.object({}).merge(defaultConfig).merge(config, true).get();
this.config = wysihtml5.lang.object({}).merge(defaultConfig).merge(config).get();
this._isCompatible = wysihtml5.browser.supported();

// make sure that rules override instead of extend
if (config && config.parserRules) {
this.config.parserRules = wysihtml5.lang.object(config.parserRules).clone(true);
// merge classNames
if (config && config.classNames) {
wysihtml5.lang.object(this.config.classNames).merge(config.classNames);
}

if (this.editableElement.nodeName.toLowerCase() != "textarea") {
Expand Down
16 changes: 8 additions & 8 deletions dist/wysihtml-toolbar.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/wysihtml-toolbar.min.map

Large diffs are not rendered by default.

48 changes: 27 additions & 21 deletions dist/wysihtml.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* @license wysihtml v0.5.0-beta7
* @license wysihtml v0.5.0-beta8
* https://github.com/Voog/wysihtml
*
* Author: Christopher Blum (https://github.com/tiff)
Expand All @@ -10,7 +10,7 @@
*
*/
var wysihtml5 = {
version: "0.5.0-beta7",
version: "0.5.0-beta8",

// namespaces
commands: {},
Expand Down Expand Up @@ -4684,8 +4684,8 @@ wysihtml5.browser = (function() {
// When inserting unordered or ordered lists in Firefox, Chrome or Safari, the current selection or line gets
// converted into a list (<ul><li>...</li></ul>, <ol><li>...</li></ol>)
// IE and Opera act a bit different here as they convert the entire content of the current block element into a list
"insertUnorderedList": isIE(),
"insertOrderedList": isIE()
"insertUnorderedList": isIE(9, ">="),
"insertOrderedList": isIE(9, ">=")
};

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

isPlainObject: function () {
return obj && Object.prototype.toString.call(obj) === '[object Object]';
return obj && Object.prototype.toString.call(obj) === '[object Object]' && !(("Node" in window) ? obj instanceof Node : obj instanceof Element || obj instanceof Text);
}
};
};
Expand Down Expand Up @@ -7227,12 +7227,15 @@ wysihtml5.dom.replaceWithChildNodes = function(node) {
var doc = list.ownerDocument,
fragment = doc.createDocumentFragment(),
previousSibling = wysihtml5.dom.domNode(list).prev({ignoreBlankTexts: true}),
nextSibling = wysihtml5.dom.domNode(list).next({ignoreBlankTexts: true}),
firstChild,
lastChild,
isLastChild,
shouldAppendLineBreak,
paragraph,
listItem;
listItem,
lastListItem = list.lastElementChild || list.lastChild,
isLastItem;

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

while (listItem = (list.firstElementChild || list.firstChild)) {
lastChild = listItem.lastChild;
isLastItem = listItem === lastListItem;
while (firstChild = listItem.firstChild) {
isLastChild = firstChild === lastChild;
// This needs to be done before appending it to the fragment, as it otherwise will lose style information
shouldAppendLineBreak = isLastChild && !_isBlockElement(firstChild) && !_isLineBreak(firstChild);
shouldAppendLineBreak = (!isLastItem || (nextSibling && !_isBlockElement(nextSibling))) && isLastChild && !_isBlockElement(firstChild) && !_isLineBreak(firstChild);
fragment.appendChild(firstChild);
if (shouldAppendLineBreak) {
_appendLineBreak(fragment);
Expand Down Expand Up @@ -8990,7 +8994,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
}

var handleMouseDown = function(event) {
var target = wysihtml5.dom.getParentElement(event.target, { query: "td, th" });
var target = wysihtml5.dom.getParentElement(event.target, { query: "td, th" }, false, editable);
if (target) {
handleSelectionMousedown(target);
}
Expand All @@ -9000,7 +9004,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
select.start = target;
select.end = target;
select.cells = [target];
select.table = dom.getParentElement(select.start, { query: "table" });
select.table = dom.getParentElement(select.start, { query: "table" }, false, editable);

if (select.table) {
removeCellSelections();
Expand Down Expand Up @@ -9031,11 +9035,11 @@ wysihtml5.quirks.ensureProperClearing = (function() {

function handleMouseMove (event) {
var curTable = null,
cell = dom.getParentElement(event.target, { query: "td, th" }),
cell = dom.getParentElement(event.target, { query: "td, th" }, false, editable),
oldEnd;

if (cell && select.table && select.start) {
curTable = dom.getParentElement(cell, { query: "table" });
curTable = dom.getParentElement(cell, { query: "table" }, false, editable);
if (curTable && curTable === select.table) {
removeCellSelections();
oldEnd = select.end;
Expand Down Expand Up @@ -9063,7 +9067,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {

var sideClickHandler = function(event) {
editable.ownerDocument.removeEventListener("click", sideClickHandler);
if (dom.getParentElement(event.target, { query: "table" }) != select.table) {
if (dom.getParentElement(event.target, { query: "table" }, false, editable) != select.table) {
removeCellSelections();
select.table = null;
select.start = null;
Expand All @@ -9079,7 +9083,7 @@ wysihtml5.quirks.ensureProperClearing = (function() {
function selectCells (start, end) {
select.start = start;
select.end = end;
select.table = dom.getParentElement(select.start, { query: "table" });
select.table = dom.getParentElement(select.start, { query: "table" }, false, editable);
selectedCells = dom.table.getCellsBetween(select.start, select.end);
addSelections(selectedCells);
bindSideclick();
Expand Down Expand Up @@ -12132,7 +12136,7 @@ wysihtml5.Commands = Base.extend(
};

if (node) {
var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }),
var parentLi = wysihtml5.dom.getParentElement(node, { query: "li" }, false, composer.element),
otherNodeName = (nodeName === "UL") ? "OL" : "UL";

if (isNode(node, nodeName)) {
Expand Down Expand Up @@ -12169,8 +12173,9 @@ wysihtml5.Commands = Base.extend(
// <ul><li>foo</li><li>bar</li></ul>
// becomes:
// foo<br>bar<br>
composer.selection.executeAndRestore(function() {
var otherLists = getListsInSelection(otherNodeName, composer);

composer.selection.executeAndRestoreRangy(function() {
otherLists = getListsInSelection(otherNodeName, composer);
if (otherLists.length) {
for (var l = otherLists.length; l--;) {
wysihtml5.dom.renameElement(otherLists[l], nodeName.toLowerCase());
Expand All @@ -12192,7 +12197,7 @@ wysihtml5.Commands = Base.extend(
// becomes:
// <ul><li>foo</li><li>bar</li></ul>
// Also rename other lists in selection
composer.selection.executeAndRestore(function() {
composer.selection.executeAndRestoreRangy(function() {
var renameLists = [el].concat(getListsInSelection(otherNodeName, composer));

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


if (!list.el) {
if (composer.commands.support(cmd)) {
doc.execCommand(cmd, false, null);
Expand Down Expand Up @@ -14395,12 +14401,12 @@ wysihtml5.views.View = Base.extend(
/** @scope wysihtml5.Editor.prototype */ {
constructor: function(editableElement, config) {
this.editableElement = typeof(editableElement) === "string" ? document.getElementById(editableElement) : editableElement;
this.config = wysihtml5.lang.object({}).merge(defaultConfig).merge(config, true).get();
this.config = wysihtml5.lang.object({}).merge(defaultConfig).merge(config).get();
this._isCompatible = wysihtml5.browser.supported();

// make sure that rules override instead of extend
if (config && config.parserRules) {
this.config.parserRules = wysihtml5.lang.object(config.parserRules).clone(true);
// merge classNames
if (config && config.classNames) {
wysihtml5.lang.object(this.config.classNames).merge(config.classNames);
}

if (this.editableElement.nodeName.toLowerCase() != "textarea") {
Expand Down
14 changes: 7 additions & 7 deletions dist/wysihtml.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/wysihtml.min.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "wysihtml",
"version": "0.5.0-beta7",
"version": "0.5.0-beta8",
"devDependencies": {
"grunt": "~0.4.4",
"grunt-contrib-concat": "~0.4.0",
Expand All @@ -15,7 +15,7 @@
"dependencies": {
"rangy": "^1.3.0-alpha.20140921"
},
"description": "h1. wysihtml 0.5.0-beta7",
"description": "h1. wysihtml 0.5.0-beta8",
"main": "Gruntfile.js",
"directories": {
"example": "examples",
Expand Down

0 comments on commit ad2d246

Please sign in to comment.