Skip to content

Commit

Permalink
Code Mirror assets (#8125)
Browse files Browse the repository at this point in the history
  • Loading branch information
agriffard authored Dec 23, 2020
1 parent 253567d commit 203d9ca
Show file tree
Hide file tree
Showing 10 changed files with 57 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace OrchardCore.Resources
public class ResourceManifest : IResourceManifestProvider
{
// CDNs
private const string jsDelivrUrl = "https://cdnjs.cloudflare.com/ajax/libs/";
private const string jsDelivrUrl = "https://cdn.jsdelivr.net/npm/";
// Versions
private const string codeMirrorVersion = "5.59.0";
// URLs
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi

// CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: https://codemirror.net/LICENSE
// declare global: DOMRect
(function (mod) {
if ((typeof exports === "undefined" ? "undefined" : _typeof(exports)) == "object" && (typeof module === "undefined" ? "undefined" : _typeof(module)) == "object") // CommonJS
mod(require("../../lib/codemirror"));else if (typeof define == "function" && define.amd) // AMD
Expand Down Expand Up @@ -96,7 +97,10 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
CodeMirror.signal(data, "pick", completion);
self.cm.scrollIntoView();
});
this.close();

if (this.options.closeOnPick) {
this.close();
}
},
cursorActivity: function cursorActivity() {
if (this.debounce) {
Expand All @@ -114,7 +118,9 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
line = this.cm.getLine(pos.line);

if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch || pos.ch < identStart.ch || this.cm.somethingSelected() || !pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1))) {
this.close();
if (this.options.closeOnCursorActivity) {
this.close();
}
} else {
var self = this;
this.debounce = requestAnimationFrame(function () {
Expand Down Expand Up @@ -283,10 +289,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
var winW = parentWindow.innerWidth || Math.max(ownerDocument.body.offsetWidth, ownerDocument.documentElement.offsetWidth);
var winH = parentWindow.innerHeight || Math.max(ownerDocument.body.offsetHeight, ownerDocument.documentElement.offsetHeight);
container.appendChild(hints);
var box = hints.getBoundingClientRect(),
overlapY = box.bottom - winH;
var scrolls = hints.scrollHeight > hints.clientHeight + 1;
var startScroll = cm.getScrollInfo();
var box = completion.options.moveOnOverlap ? hints.getBoundingClientRect() : new DOMRect();
var scrolls = completion.options.paddingForScrollbar ? hints.scrollHeight > hints.clientHeight + 1 : false; // Compute in the timeout to avoid reflow on init

var startScroll;
setTimeout(function () {
startScroll = cm.getScrollInfo();
});
var overlapY = box.bottom - winH;

if (overlapY > 0) {
var height = box.bottom - box.top,
Expand Down Expand Up @@ -385,8 +395,14 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
setTimeout(function () {
cm.focus();
}, 20);
});
this.scrollToActive();
}); // The first hint doesn't need to be scrolled to on init

var selectedHintRange = this.getSelectedHintRange();

if (selectedHintRange.from !== 0 || selectedHintRange.to !== 0) {
this.scrollToActive();
}

CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]);
return true;
}
Expand Down Expand Up @@ -430,14 +446,21 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
},
scrollToActive: function scrollToActive() {
var margin = this.completion.options.scrollMargin || 0;
var node1 = this.hints.childNodes[Math.max(0, this.selectedHint - margin)];
var node2 = this.hints.childNodes[Math.min(this.data.list.length - 1, this.selectedHint + margin)];
var selectedHintRange = this.getSelectedHintRange();
var node1 = this.hints.childNodes[selectedHintRange.from];
var node2 = this.hints.childNodes[selectedHintRange.to];
var firstNode = this.hints.firstChild;
if (node1.offsetTop < this.hints.scrollTop) this.hints.scrollTop = node1.offsetTop - firstNode.offsetTop;else if (node2.offsetTop + node2.offsetHeight > this.hints.scrollTop + this.hints.clientHeight) this.hints.scrollTop = node2.offsetTop + node2.offsetHeight - this.hints.clientHeight + firstNode.offsetTop;
},
screenAmount: function screenAmount() {
return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
},
getSelectedHintRange: function getSelectedHintRange() {
var margin = this.completion.options.scrollMargin || 0;
return {
from: Math.max(0, this.selectedHint - margin),
to: Math.min(this.data.list.length - 1, this.selectedHint + margin)
};
}
};

Expand Down Expand Up @@ -533,11 +556,15 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
completeSingle: true,
alignWithWord: true,
closeCharacters: /[\s()\[\]{};:>,]/,
closeOnCursorActivity: true,
closeOnPick: true,
closeOnUnfocus: true,
completeOnSingleClick: true,
container: null,
customKeys: null,
extraKeys: null
extraKeys: null,
paddingForScrollbar: true,
moveOnOverlap: true
};
CodeMirror.defineOption("hintOptions", null);
});

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
var safari = /Apple Computer/.test(navigator.vendor);
var mac_geMountainLion = /Mac OS X 1\d\D([8-9]|\d\d)\D/.test(userAgent);
var phantom = /PhantomJS/.test(userAgent);
var ios = !edge && /AppleWebKit/.test(userAgent) && /Mobile\/\w+/.test(userAgent);
var ios = !edge && /AppleWebKit/.test(userAgent) && (/Mobile\/\w+/.test(userAgent) || navigator.maxTouchPoints > 2);
var android = /Android/.test(userAgent); // This is woefully incomplete. Suggestions for alternative methods welcome.

var mobile = ios || android || /webOS|BlackBerry|Opera Mini|Opera Mobi|IEMobile/i.test(userAgent);
Expand Down Expand Up @@ -14649,6 +14649,6 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi

CodeMirror.fromTextArea = fromTextArea;
addLegacyProps(CodeMirror);
CodeMirror.version = "5.58.3";
CodeMirror.version = "5.59.0";
return CodeMirror;
});

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,7 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
if (value == "|" || value == "&") return cont(typeexpr);
if (type == "string" || type == "number" || type == "atom") return cont(afterType);
if (type == "[") return cont(pushlex("]"), commasep(typeexpr, "]", ","), poplex, afterType);
if (type == "{") return cont(pushlex("}"), commasep(typeprop, "}", ",;"), poplex, afterType);
if (type == "{") return cont(pushlex("}"), typeprops, poplex, afterType);
if (type == "(") return cont(commasep(typearg, ")"), maybeReturnType, afterType);
if (type == "<") return cont(commasep(typeexpr, ">"), typeexpr);
}
Expand All @@ -806,6 +806,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
if (type == "=>") return cont(typeexpr);
}

function typeprops(type) {
if (type == "}") return cont();
if (type == "," || type == ";") return cont(typeprops);
return pass(typeprop, typeprops);
}

function typeprop(type, value) {
if (type == "variable" || cx.style == "keyword") {
cx.marked = "property";
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}

.CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
background-color: white; /* The little square between H and V scrollbars */
background-color: transparent; /* The little square between H and V scrollbars */
}

/* GUTTER */
Expand Down
Loading

4 comments on commit 203d9ca

@giannik
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting this error from dev branch in the admin :
image

@Skrypt
Copy link
Contributor

@Skrypt Skrypt commented on 203d9ca Dec 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this issue. It might be network related. Try disabling your CDN in the mean time.

@agriffard
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also had errors yesterday to get jQuery and jQuery UI.

@giannik
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok disabling cdn fixed it.
Did'nt even know it was turned on.

Please sign in to comment.