Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
loadFormRevision(vid, query, opts) {
if (!this.formUrl && !this.vUrl) {
return NativePromise.reject('No form url set.');
}
// Set the version url if not set.
if (vid && !this.vUrl) {
this.vId = vid;
this.vUrl = `${this.formUrl}/v/${vid}`;
}
// If they specified a revision form, load the revised form components.
if (query && isObject(query)) {
query = Formio.serialize(query.params);
}
if (query) {
query = this.query ? (`${this.query}&${query}`) : (`?${query}`);
}
else {
static ssoInit(type, options) {
switch (type) {
case 'saml':
return Formio.samlInit(options);
case 'okta':
return Formio.oktaInit(options);
default:
console.warn('Unknown SSO type');
return NativePromise.reject('Unknown SSO type');
}
}
.catch((err) => {
if (err === 'Bad Token') {
Formio.setToken(null, opts);
Formio.events.emit('formio.badToken', err);
}
if (err.message) {
err.message = `Could not connect to API server (${err.message})`;
err.networkError = true;
}
if (method === 'GET') {
delete Formio.cache[cacheKey];
}
return NativePromise.reject(err);
});
.then((error) => {
return NativePromise.reject(error);
});
}
.catch((err) => Promise.reject(this.onSubmissionError(err)));
}
.then(() => {
if (!element.parentNode) {
return NativePromise.reject();
}
this.quill = new Quill(element, settings);
/** This block of code adds the [source] capabilities. See https://codepen.io/anon/pen/ZyEjrQ **/
const txtArea = document.createElement('textarea');
txtArea.setAttribute('class', 'quill-source-code');
this.quill.addContainer('ql-custom').appendChild(txtArea);
const qlSource = element.parentNode.querySelector('.ql-source');
if (qlSource) {
this.addEventListener(qlSource, 'click', (event) => {
event.preventDefault();
if (txtArea.style.display === 'inherit') {
this.quill.setContents(this.quill.clipboard.convert(txtArea.value));
}
txtArea.style.display = (txtArea.style.display === 'none') ? 'inherit' : 'none';
});
Component.libraryReady = function(name) {
if (
Component.externalLibraries.hasOwnProperty(name) &&
Component.externalLibraries[name].ready
) {
return Component.externalLibraries[name].ready;
}
return NativePromise.reject(`${name} library was not required.`);
};
static libraryReady(name) {
if (
Formio.libraries.hasOwnProperty(name) &&
Formio.libraries[name].ready
) {
return Formio.libraries[name].ready;
}
return NativePromise.reject(`${name} library was not required.`);
}
}
load(type, query, opts) {
const _id = `${type}Id`;
const _url = `${type}Url`;
if (query && isObject(query)) {
query = Formio.serialize(query.params);
}
if (query) {
query = this.query ? (`${this.query}&${query}`) : (`?${query}`);
}
else {
query = this.query;
}
if (!this[_id]) {
return NativePromise.reject(`Missing ${_id}`);
}
return this.makeRequest(type, this[_url] + query, 'get', null, opts);
}