resolve #566 by moving Bootstrap declaration into theme

This commit is contained in:
Shaun Walker
2020-06-16 17:38:06 -04:00
parent 71b3b695fc
commit 7c24bae753
10 changed files with 110 additions and 39 deletions

View File

@ -198,12 +198,30 @@ Oqtane.Interop = {
script.onerror = rej();
});
},
loadScript: async function (path) {
loadScript: async function (url, integrity, crossorigin) {
const promise = new Promise((resolve, reject) => {
loadjs(path, { returnPromise: true })
.then(function () { resolve(true) })
.catch(function (pathsNotFound) { reject(false) });
if (loadjs.isDefined(url)) {
resolve(true);
return;
}
loadjs(url, url, {
async: false,
returnPromise: true,
before: function (path, element) {
if (path === url && integrity !== '') {
element.integrity = integrity;
}
if (path === url && crossorigin !== '') {
element.crossOrigin = crossorigin;
}
}
})
.then(function () { resolve(true) })
.catch(function (pathsNotFound) { reject(false) });
});
const result = await promise;
return;
},
@ -325,5 +343,31 @@ Oqtane.Interop = {
setInterval(function () {
window.location.href = url;
}, wait * 1000);
},
loadBootstrapJS: async function () {
if (!loadjs.isDefined('Bootstrap')) {
const bootstrap = loadjs(['https://code.jquery.com/jquery-3.3.1.slim.min.js', 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js', 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js'], 'Bootstrap', {
async: false,
returnPromise: true,
before: function (path, element) {
if (path === 'https://code.jquery.com/jquery-3.3.1.slim.min.js') {
element.integrity = 'sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo';
element.crossOrigin = 'anonymous';
}
if (path === 'https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js') {
element.integrity = 'sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1';
element.crossOrigin = 'anonymous';
}
if (path === 'https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js') {
element.integrity = 'sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM';
element.crossOrigin = 'anonymous';
}
}
})
.then(function () { })
.catch(function (pathsNotFound) { });
await bootstrap;
}
}
};

View File

@ -5,27 +5,28 @@ Oqtane.RichTextEditor = {
quillElement, toolBar, readOnly,
placeholder, theme, debugLevel) {
const loadQuill = loadjs(['js/quill1.3.6.min.js', 'js/quill-blot-formatter.min.js'], 'Quill',
{ async: true, returnPromise: true })
.then(function () {
Quill.register('modules/blotFormatter', QuillBlotFormatter.default);
if (!loadjs.isDefined('Quill')) {
const loadQuill = loadjs(['js/quill1.3.6.min.js', 'js/quill-blot-formatter.min.js'], 'Quill',
{ async: true, returnPromise: true })
.then(function () {
Quill.register('modules/blotFormatter', QuillBlotFormatter.default);
})
.catch(function (pathsNotFound) { });
await loadQuill;
}
var options = {
debug: debugLevel,
modules: {
toolbar: toolBar,
blotFormatter: {}
},
placeholder: placeholder,
readOnly: readOnly,
theme: theme
};
var options = {
debug: debugLevel,
modules: {
toolbar: toolBar,
blotFormatter: {}
},
placeholder: placeholder,
readOnly: readOnly,
theme: theme
};
new Quill(quillElement, options);
})
.catch(function (pathsNotFound) { });
await loadQuill;
new Quill(quillElement, options);
},
getQuillContent: function (editorElement) {
return JSON.stringify(editorElement.__quill.getContents());