Skip to content

Commit

Permalink
Fix uneditable classname passing and add remove to handling methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
Oliver Pulges committed Sep 10, 2014
1 parent 8bab162 commit 8b5d63b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
19 changes: 9 additions & 10 deletions src/dom/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,7 @@ wysihtml5.dom.parse = function(elementOrHtml_current, config_current) {
DEFAULT_NODE_NAME = "span",
WHITE_SPACE_REG_EXP = /\s+/,
defaultRules = { tags: {}, classes: {} },
currentRules = {},
uneditableClass = false;
currentRules = {};

/**
* Iterates over all childs of the element, recreates them, appends them into a document fragment
Expand All @@ -92,10 +91,6 @@ wysihtml5.dom.parse = function(elementOrHtml_current, config_current) {
clearInternals = true;
}

if (config.uneditableClass) {
uneditableClass = config.uneditableClass;
}

if (isString) {
element = wysihtml5.dom.getAsDom(elementOrHtml, context);
} else {
Expand All @@ -108,7 +103,7 @@ wysihtml5.dom.parse = function(elementOrHtml_current, config_current) {

while (element.firstChild) {
firstChild = element.firstChild;
newNode = _convert(firstChild, config.cleanUp, clearInternals);
newNode = _convert(firstChild, config.cleanUp, clearInternals, config.uneditableClass);
if (newNode) {
fragment.appendChild(newNode);
}
Expand All @@ -134,7 +129,7 @@ wysihtml5.dom.parse = function(elementOrHtml_current, config_current) {
return isString ? wysihtml5.quirks.getCorrectInnerHTML(element) : element;
}

function _convert(oldNode, cleanUp, clearInternals) {
function _convert(oldNode, cleanUp, clearInternals, uneditableClass) {
var oldNodeType = oldNode.nodeType,
oldChilds = oldNode.childNodes,
oldChildsLength = oldChilds.length,
Expand All @@ -159,7 +154,7 @@ wysihtml5.dom.parse = function(elementOrHtml_current, config_current) {

for (i = oldChildsLength; i--;) {
if (oldChilds[i]) {
newChild = _convert(oldChilds[i], cleanUp, clearInternals);
newChild = _convert(oldChilds[i], cleanUp, clearInternals, uneditableClass);
if (newChild) {
if (oldChilds[i] === newChild) {
i--;
Expand Down Expand Up @@ -201,7 +196,7 @@ wysihtml5.dom.parse = function(elementOrHtml_current, config_current) {
// Converts all childnodes
for (i=0; i<oldChildsLength; i++) {
if (oldChilds[i]) {
newChild = _convert(oldChilds[i], cleanUp, clearInternals);
newChild = _convert(oldChilds[i], cleanUp, clearInternals, uneditableClass);
if (newChild) {
if (oldChilds[i] === newChild) {
i--;
Expand Down Expand Up @@ -832,6 +827,10 @@ wysihtml5.dom.parse = function(elementOrHtml_current, config_current) {
var elementHandlingMethods = {
unwrap: function (element) {
wysihtml5.dom.unwrap(element);
},

remove: function (element) {
element.parentNode.removeChild(element);
}
};

Expand Down
2 changes: 1 addition & 1 deletion src/quirks/clean_pasted_html.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ wysihtml5.quirks.cleanPastedHTML = (function() {
"rules": rules,
"cleanUp": true, // <span> elements, empty or without attributes, should be removed/replaced with their content
"context": options.referenceNode.ownerDocument,
"uneditableClass": options.uneditableContainerClassname,
"uneditableClass": options.uneditableClass,
"clearInternals" : true, // don't paste temprorary selection and other markings
"unjoinNbsps" : true
});
Expand Down

0 comments on commit 8b5d63b

Please sign in to comment.