Change: drop .last and .rotate
This commit is contained in:
parent
85e70491e4
commit
d4ddfcc713
|
@ -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');
|
||||
|
|
|
@ -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();
|
||||
|
|
17
js/dom.js
17
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]) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user