forked from tiff/wysihtml5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove useless 'state' function from commands
- Loading branch information
Showing
19 changed files
with
166 additions
and
299 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,15 @@ | ||
(function(wysihtml5) { | ||
var undef; | ||
|
||
wysihtml5.commands.bold = { | ||
exec: function(composer, command) { | ||
return wysihtml5.commands.formatInline.exec(composer, command, "b"); | ||
}, | ||
wysihtml5.commands.bold = { | ||
exec: function(composer, command) { | ||
return wysihtml5.commands.formatInline.exec(composer, command, "b"); | ||
}, | ||
|
||
state: function(composer, command) { | ||
// element.ownerDocument.queryCommandState("bold") results: | ||
// firefox: only <b> | ||
// chrome: <b>, <strong>, <h1>, <h2>, ... | ||
// ie: <b>, <strong> | ||
// opera: <b>, <strong> | ||
return wysihtml5.commands.formatInline.state(composer, command, "b"); | ||
}, | ||
|
||
value: function() { | ||
return undef; | ||
} | ||
}; | ||
})(wysihtml5); | ||
state: function(composer, command) { | ||
// element.ownerDocument.queryCommandState("bold") results: | ||
// firefox: only <b> | ||
// chrome: <b>, <strong>, <h1>, <h2>, ... | ||
// ie: <b>, <strong> | ||
// opera: <b>, <strong> | ||
return wysihtml5.commands.formatInline.state(composer, command, "b"); | ||
} | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,13 @@ | ||
(function(wysihtml5) { | ||
var undef; | ||
|
||
wysihtml5.commands.insertHTML = { | ||
exec: function(composer, command, html) { | ||
if (composer.commands.support(command)) { | ||
composer.doc.execCommand(command, false, html); | ||
} else { | ||
composer.selection.insertHTML(html); | ||
} | ||
}, | ||
|
||
state: function() { | ||
return false; | ||
}, | ||
|
||
value: function() { | ||
return undef; | ||
wysihtml5.commands.insertHTML = { | ||
exec: function(composer, command, html) { | ||
if (composer.commands.support(command)) { | ||
composer.doc.execCommand(command, false, html); | ||
} else { | ||
composer.selection.insertHTML(html); | ||
} | ||
}; | ||
})(wysihtml5); | ||
}, | ||
|
||
state: function() { | ||
return false; | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,50 @@ | ||
(function(wysihtml5) { | ||
var undef; | ||
|
||
wysihtml5.commands.insertOrderedList = { | ||
exec: function(composer, command) { | ||
var doc = composer.doc, | ||
selectedNode = composer.selection.getSelectedNode(), | ||
list = wysihtml5.dom.getParentElement(selectedNode, { nodeName: "OL" }), | ||
otherList = wysihtml5.dom.getParentElement(selectedNode, { nodeName: "UL" }), | ||
tempClassName = "_wysihtml5-temp-" + new Date().getTime(), | ||
isEmpty, | ||
tempElement; | ||
|
||
if (composer.commands.support(command)) { | ||
doc.execCommand(command, false, null); | ||
return; | ||
} | ||
|
||
if (list) { | ||
// Unwrap list | ||
// <ol><li>foo</li><li>bar</li></ol> | ||
// becomes: | ||
// foo<br>bar<br> | ||
composer.selection.executeAndRestoreSimple(function() { | ||
wysihtml5.dom.resolveList(list); | ||
}); | ||
} else if (otherList) { | ||
// Turn an unordered list into an ordered list | ||
// <ul><li>foo</li><li>bar</li></ul> | ||
// becomes: | ||
// <ol><li>foo</li><li>bar</li></ol> | ||
composer.selection.executeAndRestoreSimple(function() { | ||
wysihtml5.dom.renameElement(otherList, "ol"); | ||
}); | ||
} else { | ||
// Create list | ||
composer.commands.exec("formatBlock", "div", tempClassName); | ||
tempElement = doc.querySelector("." + tempClassName); | ||
isEmpty = tempElement.innerHTML === "" || tempElement.innerHTML === wysihtml5.INVISIBLE_SPACE; | ||
composer.selection.executeAndRestoreSimple(function() { | ||
list = wysihtml5.dom.convertToList(tempElement, "ol"); | ||
}); | ||
if (isEmpty) { | ||
composer.selection.selectNode(list.querySelector("li")); | ||
} | ||
} | ||
}, | ||
wysihtml5.commands.insertOrderedList = { | ||
exec: function(composer, command) { | ||
var doc = composer.doc, | ||
selectedNode = composer.selection.getSelectedNode(), | ||
list = wysihtml5.dom.getParentElement(selectedNode, { nodeName: "OL" }), | ||
otherList = wysihtml5.dom.getParentElement(selectedNode, { nodeName: "UL" }), | ||
tempClassName = "_wysihtml5-temp-" + new Date().getTime(), | ||
isEmpty, | ||
tempElement; | ||
|
||
state: function(composer) { | ||
var selectedNode = composer.selection.getSelectedNode(); | ||
return wysihtml5.dom.getParentElement(selectedNode, { nodeName: "OL" }); | ||
}, | ||
|
||
value: function() { | ||
return undef; | ||
if (composer.commands.support(command)) { | ||
doc.execCommand(command, false, null); | ||
return; | ||
} | ||
}; | ||
})(wysihtml5); | ||
|
||
if (list) { | ||
// Unwrap list | ||
// <ol><li>foo</li><li>bar</li></ol> | ||
// becomes: | ||
// foo<br>bar<br> | ||
composer.selection.executeAndRestoreSimple(function() { | ||
wysihtml5.dom.resolveList(list); | ||
}); | ||
} else if (otherList) { | ||
// Turn an unordered list into an ordered list | ||
// <ul><li>foo</li><li>bar</li></ul> | ||
// becomes: | ||
// <ol><li>foo</li><li>bar</li></ol> | ||
composer.selection.executeAndRestoreSimple(function() { | ||
wysihtml5.dom.renameElement(otherList, "ol"); | ||
}); | ||
} else { | ||
// Create list | ||
composer.commands.exec("formatBlock", "div", tempClassName); | ||
tempElement = doc.querySelector("." + tempClassName); | ||
isEmpty = tempElement.innerHTML === "" || tempElement.innerHTML === wysihtml5.INVISIBLE_SPACE; | ||
composer.selection.executeAndRestoreSimple(function() { | ||
list = wysihtml5.dom.convertToList(tempElement, "ol"); | ||
}); | ||
if (isEmpty) { | ||
composer.selection.selectNode(list.querySelector("li")); | ||
} | ||
} | ||
}, | ||
|
||
state: function(composer) { | ||
var selectedNode = composer.selection.getSelectedNode(); | ||
return wysihtml5.dom.getParentElement(selectedNode, { nodeName: "OL" }); | ||
} | ||
}; |
Oops, something went wrong.