diff --git a/edit/codemirror-factory.js b/edit/codemirror-factory.js index d2b201b3..b1d89f08 100644 --- a/edit/codemirror-factory.js +++ b/edit/codemirror-factory.js @@ -138,10 +138,11 @@ const cmFactory = (() => { } function autocompleteOnTyping(cm, [info], debounced) { + const lastLine = info.text[info.text.length - 1]; if ( cm.state.completionActive || info.origin && !info.origin.includes('input') || - !info.text.last + !lastLine ) { return; } @@ -153,7 +154,7 @@ const cmFactory = (() => { debounce(autocompleteOnTyping, 100, cm, [info], true); return; } - if (info.text.last.match(/[-a-z!]+$/i)) { + if (lastLine.match(/[-a-z!]+$/i)) { cm.state.autocompletePicked = false; cm.options.hintOptions.completeSingle = false; cm.execCommand('autocomplete'); diff --git a/edit/sections-editor.js b/edit/sections-editor.js index 2fb69ada..27607d66 100644 --- a/edit/sections-editor.js +++ b/edit/sections-editor.js @@ -476,6 +476,7 @@ function createSectionsEditor(style) { function removeSection(section) { if (sections.every(s => s.isRemoved() || s === section)) { + // TODO: hide remove button when `#sections[data-section-count=1]` throw new Error('Cannot remove last section'); } if (section.cm.isBlank()) { @@ -534,7 +535,6 @@ function createSectionsEditor(style) { container.appendChild(section.el); } section.render(); - // maximizeCodeHeight(section.el); updateSectionOrder(); section.onChange(updateLivePreview); updateLivePreview(); diff --git a/js/dom.js b/js/dom.js index a1ae0180..86445043 100644 --- a/js/dom.js +++ b/js/dom.js @@ -13,23 +13,6 @@ if (!/^Win\d+/.test(navigator.platform)) { NodeList.prototype[method] = Array.prototype[method]; }); -// eslint-disable-next-line no-extend-native -Object.defineProperties(Array.prototype, { - last: { - get() { - return this[this.length - 1]; - }, - }, - rotate: { - value: function (amount) { - // negative amount == rotate left - const r = this.slice(-amount, this.length); - Array.prototype.push.apply(r, this.slice(0, this.length - r.length)); - return r; - }, - }, -}); - // polyfill for old browsers to enable [...results] and for-of for (const type of [NodeList, NamedNodeMap, HTMLCollection, HTMLAllCollection]) { if (!type.prototype[Symbol.iterator]) {