diff --git a/dist/inlineMarkdownEditor.js b/dist/inlineMarkdownEditor.js index 4c77bce..8f97435 100644 --- a/dist/inlineMarkdownEditor.js +++ b/dist/inlineMarkdownEditor.js @@ -10227,6 +10227,28 @@ module.exports = function defaultMarkdown(element) { } },{"megamark":91}],96:[function(require,module,exports){ +// split by double-newline, but preserve HTML blocks as single sections: +module.exports = function divideIntoSections(content) { + var sections = []; + content = content.replace(/[\n]{2,}/g, "\n\n"); // manage double newlines (not sure exactly?) + chunkArray = content.replace(/(<(.+).*>.+<\/\2>)/g,"@@@@@@$1").split(/@@@@@@|\n\n/); + + chunkArray = chunkArray.filter(function (x) { + return (x !== undefined && x !== '' && x.match(/\S/) !== null); // probably overzealous filtering of "empty" sections + }); + + chunkArray.forEach(function(chunk) { + if (chunk.match(/<\w>/)) { + sections.push(chunk); // it's an HTML chunk + } else { + sections = sections.concat(chunk.split("\n\n")); // split by double newline and add + } + }); + + return sections; +} + +},{}],97:[function(require,module,exports){ inlineMarkdownEditor = function inlineMarkdownEditor(o) { o.defaultMarkdown = o.defaultMarkdown || require('./defaultMarkdown.js'); o.buildSectionForm = o.buildSectionForm || require('./buildSectionForm.js'); @@ -10239,7 +10261,8 @@ inlineMarkdownEditor = function inlineMarkdownEditor(o) { o.originalMarkdown = el.html(); o.preProcessor = o.preProcessor || function(m) { return m; } // split by double-newline: - var sections = o.originalMarkdown.replace(/[\n]{2,}/g, "\n\n").split("\n\n"); + o.divideIntoSections = o.divideIntoSections || require('./divideIntoSections.js'); + var sections = o.divideIntoSections(o.originalMarkdown); var editableSections = []; // we also do this inside processSection, but independently track here: sections.forEach(function forEachSection(section, index) { @@ -10258,7 +10281,7 @@ inlineMarkdownEditor = function inlineMarkdownEditor(o) { } module.exports = inlineMarkdownEditor; -},{"./buildSectionForm.js":94,"./defaultMarkdown.js":95,"./insertEditLink.js":97,"./isEditable.js":98,"./onComplete.js":99,"./onFail.js":100,"./processSections.js":102}],97:[function(require,module,exports){ +},{"./buildSectionForm.js":94,"./defaultMarkdown.js":95,"./divideIntoSections.js":96,"./insertEditLink.js":98,"./isEditable.js":99,"./onComplete.js":100,"./onFail.js":101,"./processSections.js":103}],98:[function(require,module,exports){ module.exports = function insertEditLink(uniqueId, el, form, onEdit, editor, o) { var editBtns = ""; editBtns += ""; @@ -10283,11 +10306,11 @@ module.exports = function insertEditLink(uniqueId, el, form, onEdit, editor, o) }); } -},{}],98:[function(require,module,exports){ +},{}],99:[function(require,module,exports){ module.exports = function isEditable(markdown, originalMarkdown) { originalMarkdown = originalMarkdown || markdown; // optional parameter for checking against original complete text // filter? Only p,h1-5,ul? - var editable = markdown.match(/inline-markdown-editor + @@ -40,7 +41,15 @@

* this * is * a -* list +* list + +

+ +

+ +(above, raw HTML blocks should be undisturbed) + +