Add JS dependency manager
Added LoadJS(https://github.com/muicss/loadjs) and migrated Quill interop to use LoadJS.
This commit is contained in:
		| @ -321,5 +321,15 @@ Oqtane.Interop = { | ||||
|         setInterval(function () { | ||||
|             window.location.href = url; | ||||
|         }, wait * 1000); | ||||
|     }, | ||||
|     loadInteropScript: async function (filePath) { | ||||
|         const promise = new Promise((resolve, reject) => { | ||||
|             loadjs(filePath, { returnPromise: true }) | ||||
|                 .then(function () { resolve(true) }) | ||||
|                 .catch(function (pathsNotFound) { reject(false) }); | ||||
|         }); | ||||
|  | ||||
|         const result = await promise; | ||||
|         return; | ||||
|     } | ||||
| }; | ||||
|  | ||||
							
								
								
									
										1
									
								
								Oqtane.Server/wwwroot/js/loadjs.min.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										1
									
								
								Oqtane.Server/wwwroot/js/loadjs.min.js
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1 @@ | ||||
| loadjs=function(){var h=function(){},c={},u={},f={};function o(e,n){if(e){var r=f[e];if(u[e]=n,r)for(;r.length;)r[0](e,n),r.splice(0,1)}}function l(e,n){e.call&&(e={success:e}),n.length?(e.error||h)(n):(e.success||h)(e)}function d(r,t,s,i){var c,o,e=document,n=s.async,u=(s.numRetries||0)+1,f=s.before||h,l=r.replace(/[\?|#].*$/,""),a=r.replace(/^(css|img)!/,"");i=i||0,/(^css!|\.css$)/.test(l)?((o=e.createElement("link")).rel="stylesheet",o.href=a,(c="hideFocus"in o)&&o.relList&&(c=0,o.rel="preload",o.as="style")):/(^img!|\.(png|gif|jpg|svg|webp)$)/.test(l)?(o=e.createElement("img")).src=a:((o=e.createElement("script")).src=r,o.async=void 0===n||n),!(o.onload=o.onerror=o.onbeforeload=function(e){var n=e.type[0];if(c)try{o.sheet.cssText.length||(n="e")}catch(e){18!=e.code&&(n="e")}if("e"==n){if((i+=1)<u)return d(r,t,s,i)}else if("preload"==o.rel&&"style"==o.as)return o.rel="stylesheet";t(r,n,e.defaultPrevented)})!==f(r,o)&&e.head.appendChild(o)}function r(e,n,r){var t,s;if(n&&n.trim&&(t=n),s=(t?r:n)||{},t){if(t in c)throw"LoadJS";c[t]=!0}function i(n,r){!function(e,t,n){var r,s,i=(e=e.push?e:[e]).length,c=i,o=[];for(r=function(e,n,r){if("e"==n&&o.push(e),"b"==n){if(!r)return;o.push(e)}--i||t(o)},s=0;s<c;s++)d(e[s],r,n)}(e,function(e){l(s,e),n&&l({success:n,error:r},e),o(t,e)},s)}if(s.returnPromise)return new Promise(i);i()}return r.ready=function(e,n){return function(e,r){e=e.push?e:[e];var n,t,s,i=[],c=e.length,o=c;for(n=function(e,n){n.length&&i.push(e),--o||r(i)};c--;)t=e[c],(s=u[t])?n(t,s):(f[t]=f[t]||[]).push(n)}(e,function(e){l(n,e)}),r},r.done=function(e){o(e,[])},r.reset=function(){c={},u={},f={}},r.isDefined=function(e){return e in c},r}(); | ||||
| @ -1,24 +1,31 @@ | ||||
| var Oqtane = Oqtane || {}; | ||||
|  | ||||
| Oqtane.RichTextEditor = { | ||||
|     createQuill: function ( | ||||
|     createQuill: async function ( | ||||
|         quillElement, toolBar, readOnly, | ||||
|         placeholder, theme, debugLevel) { | ||||
|  | ||||
|         Quill.register('modules/blotFormatter', QuillBlotFormatter.default); | ||||
|         const loadQuill = loadjs(['js/quill1.3.6.min.js', 'js/quill-blot-formatter.min.js'], 'Quill', | ||||
|             { async: true, returnPromise: true }) | ||||
|             .then(function () { /* foo.js & bar.js loaded */ | ||||
|                 Quill.register('modules/blotFormatter', QuillBlotFormatter.default); | ||||
|  | ||||
|         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); | ||||
|                 new Quill(quillElement, options); | ||||
|             }) | ||||
|             .catch(function (pathsNotFound) { /* at least one didn't load */ }); | ||||
|  | ||||
|         await loadQuill; | ||||
|     }, | ||||
|     getQuillContent: function (editorElement) { | ||||
|         return JSON.stringify(editorElement.__quill.getContents()); | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Jim Spillane
					Jim Spillane