From 3d4d7959ac397cd6d06ccb6cccce5501bdd5d542 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Thu, 14 Feb 2019 07:46:54 -0500 Subject: [PATCH 01/10] Bump bootstrap from 3.4.0 to 3.4.1 (#47) Bumps [bootstrap](https://github.com/twbs/bootstrap) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/twbs/bootstrap/releases) - [Commits](https://github.com/twbs/bootstrap/compare/v3.4.0...v3.4.1) Signed-off-by: dependabot[bot] --- package-lock.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 35afdbc..7a91730 100644 --- a/package-lock.json +++ b/package-lock.json @@ -453,9 +453,9 @@ } }, "bootstrap": { - "version": "3.4.0", - "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-3.4.0.tgz", - "integrity": "sha512-F1yTDO9OHKH0xjl03DsOe8Nu1OWBIeAugGMhy3UTIYDdbbIPesQIhCEbj+HEr6wqlwweGAlP8F3OBC6kEuhFuw==" + "version": "3.4.1", + "resolved": "https://registry.npmjs.org/bootstrap/-/bootstrap-3.4.1.tgz", + "integrity": "sha512-yN5oZVmRCwe5aKwzRj6736nSmKDX7pLYwsXiCj/EYmo16hODaBiT4En5btW/jhBF/seV+XMx3aYwukYC3A49DA==" }, "bootstrap-datepicker": { "version": "1.8.0", From 6ad7d1a2ce07eac9262e04ff2fd21db9cac53df4 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Thu, 14 Feb 2019 19:01:43 -0500 Subject: [PATCH 02/10] disable tags module (#48) * disable tags module * Update package.json --- dist/inlineMarkdownEditor.js | 1 + package.json | 2 +- src/processSection.js | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dist/inlineMarkdownEditor.js b/dist/inlineMarkdownEditor.js index 4c77bce..7028011 100644 --- a/dist/inlineMarkdownEditor.js +++ b/dist/inlineMarkdownEditor.js @@ -10353,6 +10353,7 @@ module.exports = function processSection(markdown, o) { // insert rich editor var editorOptions = o.editorOptions || {}; editorOptions.textarea = $('#' + uniqueId + ' textarea')[0]; + editorOptions.tagsModule = (editorOptions.tagsModule === true); // disable this to not require Bloodhound, unless overridden editor = new PL.Editor(editorOptions); } _form.find('.cancel').click(function inlineEditCancelClick(e) { diff --git a/package.json b/package.json index 5dfcb73..3ff6ada 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "inline-markdown-editor", - "version": "0.3.3", + "version": "0.3.4", "description": "An inline wysiwyg markdown document editor based on replacing string subsections. WYSIWYG possible via woofmark.", "main": "dist/inlineMarkdownEditor.js", "scripts": { diff --git a/src/processSection.js b/src/processSection.js index 2ccc887..33f6508 100644 --- a/src/processSection.js +++ b/src/processSection.js @@ -30,6 +30,7 @@ module.exports = function processSection(markdown, o) { // insert rich editor var editorOptions = o.editorOptions || {}; editorOptions.textarea = $('#' + uniqueId + ' textarea')[0]; + editorOptions.tagsModule = (editorOptions.tagsModule === true); // disable this to not require Bloodhound, unless overridden editor = new PL.Editor(editorOptions); } _form.find('.cancel').click(function inlineEditCancelClick(e) { From 0056cab90ee065b366bdc8b464221b5e570e2291 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" Date: Wed, 27 Feb 2019 10:40:08 -0500 Subject: [PATCH 03/10] Bump publiclab-editor from 2.0.0 to 2.0.1 (#50) Bumps [publiclab-editor](https://github.com/publiclab/PublicLab.Editor) from 2.0.0 to 2.0.1. - [Release notes](https://github.com/publiclab/PublicLab.Editor/releases) - [Commits](https://github.com/publiclab/PublicLab.Editor/commits) Signed-off-by: dependabot[bot] --- package-lock.json | 111 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 88 insertions(+), 23 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7a91730..f898532 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "inline-markdown-editor", - "version": "0.3.3", + "version": "0.3.4", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -1239,6 +1239,14 @@ "resolved": "https://registry.npmjs.org/deep-is/-/deep-is-0.1.3.tgz", "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=" }, + "define-properties": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", + "integrity": "sha512-3MqfYKj2lLzdMSf8ZIZE/V+Zuy+BgD6f164e8K2w7dgnpKArBDerGYpM46IYYcjnkdPNMjPk9A6VFB8+3SKlXQ==", + "requires": { + "object-keys": "^1.0.12" + } + }, "define-property": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", @@ -1475,6 +1483,29 @@ "is-arrayish": "^0.2.1" } }, + "es-abstract": { + "version": "1.13.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", + "integrity": "sha512-vDZfg/ykNxQVwup/8E1BZhVzFfBxs9NqMzGcvIJrqg5k2/5Za2bWo40dK2J1pgLngZ7c+Shh8lwYtLGyrwPutg==", + "requires": { + "es-to-primitive": "^1.2.0", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "is-callable": "^1.1.4", + "is-regex": "^1.0.4", + "object-keys": "^1.0.12" + } + }, + "es-to-primitive": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.0.tgz", + "integrity": "sha512-qZryBOJjV//LaxLTV6UC//WewneB3LcXOL9NP++ozKVXsIIIpm/2c13UDiD9Jp2eThsecw9m3jPqDwTyobcdbg==", + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, "es5-shim": { "version": "4.5.12", "resolved": "https://registry.npmjs.org/es5-shim/-/es5-shim-4.5.12.tgz", @@ -1500,9 +1531,9 @@ "dev": true }, "escodegen": { - "version": "1.11.0", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.11.0.tgz", - "integrity": "sha512-IeMV45ReixHS53K/OmfKAIztN/igDHzTJUhZM3k1jMhIZWjk45SMwAtBsEXiJp3vSPmTcu6CXn7mDvFHRN66fw==", + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.11.1.tgz", + "integrity": "sha512-JwiqFD9KdGVVpeuRa68yU3zZnBEOcPs0nKW7wZzXky8Z7tffdYUHbe11bPCV5jYlK6DVdKLWLm0f5I/QlL0Kmw==", "requires": { "esprima": "^3.1.3", "estraverse": "^4.2.0", @@ -2366,8 +2397,7 @@ "function-bind": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", - "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==", - "dev": true + "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, "gaze": { "version": "1.1.3", @@ -2852,7 +2882,6 @@ "version": "1.0.3", "resolved": "https://registry.npmjs.org/has/-/has-1.0.3.tgz", "integrity": "sha512-f2dvO0VU6Oej7RkWJGrehjbzMAjFp5/VKPp5tTpWIV4JHHZK1/BxbFRtf/siA2SWTe09caDmVtYYzWEIbBS4zw==", - "dev": true, "requires": { "function-bind": "^1.1.1" } @@ -2872,6 +2901,11 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, + "has-symbols": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", + "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=" + }, "has-value": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", @@ -3235,6 +3269,11 @@ "kind-of": "^3.0.2" } }, + "is-date-object": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.0.1.tgz", + "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=" + }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", @@ -3351,12 +3390,28 @@ "integrity": "sha1-IHurkWOEmcB7Kt8kCkGochADRXU=", "dev": true }, + "is-regex": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.0.4.tgz", + "integrity": "sha1-VRdIm1RwkbCTDglWVM7SXul+lJE=", + "requires": { + "has": "^1.0.1" + } + }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, + "is-symbol": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", + "integrity": "sha512-HS8bZ9ox60yCJLH9snBpIwv9pYUAkcuLhSA1oero1UB5y9aiQpRA8y2ex945AOtCZL1lJDeIk3G5LthswI46Lw==", + "requires": { + "has-symbols": "^1.0.0" + } + }, "is-typedarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", @@ -3611,9 +3666,9 @@ "integrity": "sha512-x9j9tGY1+PDLN9pcWTx9/y6C5nezoTMB8BLK5jTakx+H7bPlnbCHfi9Hjg+Qt36sgDz/cb9lrSpNQXmk45Tvhw==" }, "leaflet-blurred-location": { - "version": "1.2.6", - "resolved": "https://registry.npmjs.org/leaflet-blurred-location/-/leaflet-blurred-location-1.2.6.tgz", - "integrity": "sha512-NsG5Gi6QX+9C4ldccQEzQqpN0qDilxQrAqje8mdn5yuqRvE88q7eZ/z9gLTPV/4ttObimfrdwv93/ckVhAua5g==", + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/leaflet-blurred-location/-/leaflet-blurred-location-1.2.7.tgz", + "integrity": "sha512-/eckjqt+o4AAoKzROn+Oo/JjD+4HwyFsH4EVS8QW/JgF6/cMz0IVQ1pv0mAoyPIi0+Wv8dzokyuvuqcZFqjm8g==", "requires": { "haversine-distance": "^1.1.4", "jquery": "^3.2.1", @@ -4446,6 +4501,11 @@ } } }, + "object-keys": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.0.tgz", + "integrity": "sha512-6OO5X1+2tYkNyNEx6TsCxEqFfRWaqx6EtMiSbGrw8Ob8v9Ne+Hl8rBAgLBZn5wjEz3s/s6U1WXFUFOcxxAwUpg==" + }, "object-visit": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", @@ -4599,12 +4659,12 @@ } }, "parse-headers": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.1.tgz", - "integrity": "sha1-aug6eqJanZtwCswoaYzR8e1+lTY=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/parse-headers/-/parse-headers-2.0.2.tgz", + "integrity": "sha512-/LypJhzFmyBIDYP9aDVgeyEb5sQfbfY5mnDq4hVhlQ69js87wXfmEI5V3xI6vvXasqebp0oCytYFLxsBVfCzSg==", "requires": { - "for-each": "^0.3.2", - "trim": "0.0.1" + "for-each": "^0.3.3", + "string.prototype.trim": "^1.1.2" } }, "parse-json": { @@ -4826,9 +4886,9 @@ } }, "publiclab-editor": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/publiclab-editor/-/publiclab-editor-2.0.0.tgz", - "integrity": "sha512-AhrF5bkH7I58VXLP+Nnd46FSbvFhZ9Pv3IFgrJYX4pra1v7U8CGuISOexql2QtHDOBPO0bWTqd7pFRE0n+DanQ==", + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/publiclab-editor/-/publiclab-editor-2.0.1.tgz", + "integrity": "sha512-ldOmtaB34fWPAfPOnJiNiK3z+1hVxEvc4QBgQSnQJ6hL5SHNqKoD3wL5dmOYTmsd8i6uFVsSMZ9/dvDbvXYf5A==", "requires": { "at.js": "^1.5.4", "backbone": "~1.3.3", @@ -5932,6 +5992,16 @@ "resolved": "https://registry.npmjs.org/string.prototype.repeat/-/string.prototype.repeat-0.2.0.tgz", "integrity": "sha1-q6Nt4I3O5qWjN9SbLqHaGyj8Ds8=" }, + "string.prototype.trim": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.1.2.tgz", + "integrity": "sha1-0E3iyJ4Tf019IG8Ia17S+ua+jOo=", + "requires": { + "define-properties": "^1.1.2", + "es-abstract": "^1.5.0", + "function-bind": "^1.0.2" + } + }, "string_decoder": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", @@ -6167,11 +6237,6 @@ "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" }, - "trim": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/trim/-/trim-0.0.1.tgz", - "integrity": "sha1-WFhUf2spB1fulczMZm+1AITEYN0=" - }, "trim-newlines": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-1.0.0.tgz", From e2b0c19e1075b475d015df429f1b10f0b6a9ef20 Mon Sep 17 00:00:00 2001 From: Jeffrey Warren Date: Wed, 27 Feb 2019 13:38:47 -0500 Subject: [PATCH 04/10] Fail on false + preserving HTML blocks as single sections (#49) * new test to fail on false * should fail on false * added divideIntoSections * fixes * fixes * some progress * fixes! * bump to 0.4.0 * fixed test * @rexagod adjustments * fixes * added fail() * fixed mostly, need to deal with edge cases * working for all but need to adjust other tests to ignore empty sections * all fixed * version bump --- dist/inlineMarkdownEditor.js | 49 +++++++++++++++++++------ examples/index.html | 10 ++++- package.json | 2 +- spec/javascripts/editor_spec.js | 20 +++++----- spec/javascripts/error_handling_spec.js | 31 ++++++++++++++-- spec/javascripts/replacement_spec.js | 20 ++++++++++ src/divideIntoSections.js | 20 ++++++++++ src/inlineMarkdownEditor.js | 3 +- src/isEditable.js | 2 +- src/processSection.js | 8 +++- 10 files changed, 133 insertions(+), 32 deletions(-) create mode 100644 src/divideIntoSections.js diff --git a/dist/inlineMarkdownEditor.js b/dist/inlineMarkdownEditor.js index 7028011..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(/ * this * is * a -* list +* list + +

+ +

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