* Adds TinyMCE JS assets into init page load via script in default.cshtml view for Umbraco backoffice ng-app
* Add TinyMCE JS assets array via NG app.value & uses assetsService to load (if not loaded in time by main init script above)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
angular.module("umbraco")
|
||||
.controller("Umbraco.PropertyEditors.RTEController",
|
||||
function ($scope, $q, assetsService, $timeout, tinyMceService, angularHelper) {
|
||||
function ($scope, $q, assetsService, $timeout, tinyMceService, angularHelper, tinyMceAssets) {
|
||||
|
||||
// TODO: A lot of the code below should be shared between the grid rte and the normal rte
|
||||
|
||||
@@ -30,9 +30,9 @@ angular.module("umbraco")
|
||||
var promises = [];
|
||||
|
||||
//queue file loading
|
||||
if (typeof tinymce === "undefined") { // Don't reload tinymce if already loaded
|
||||
promises.push(assetsService.loadJs("lib/tinymce/tinymce.min.js", $scope));
|
||||
}
|
||||
tinyMceAssets.forEach(function (tinyJsAsset) {
|
||||
promises.push(assetsService.loadJs(tinyJsAsset, $scope));
|
||||
});
|
||||
|
||||
//stores a reference to the editor
|
||||
var tinyMceEditor = null;
|
||||
|
||||
@@ -119,6 +119,8 @@
|
||||
document.angularReady = function(app) {
|
||||
@Html.AngularValueExternalLoginInfoScript(ViewData.GetExternalSignInError())
|
||||
@Html.AngularValueResetPasswordCodeInfoScript(ViewData["PasswordResetCode"])
|
||||
@Html.AngularValueTinyMceAssets()
|
||||
|
||||
//required for the noscript trick
|
||||
document.getElementById("mainwrapper").style.display = "inherit";
|
||||
}
|
||||
@@ -126,6 +128,7 @@
|
||||
|
||||
<script src="lib/lazyload-js/lazyload.min.js"></script>
|
||||
<script src="@Url.GetUrlWithCacheBust("Application", "BackOffice")"></script>
|
||||
<script src="@Url.Action("TinyMceEditor", "BackOffice")" async defer></script>
|
||||
|
||||
@if (isDebug)
|
||||
{
|
||||
|
||||
@@ -28,6 +28,7 @@ using Umbraco.Web.JavaScript;
|
||||
using Umbraco.Web.Security;
|
||||
using Constants = Umbraco.Core.Constants;
|
||||
using JArray = Newtonsoft.Json.Linq.JArray;
|
||||
using System.Text;
|
||||
|
||||
namespace Umbraco.Web.Editors
|
||||
{
|
||||
@@ -210,6 +211,28 @@ namespace Umbraco.Web.Editors
|
||||
return JavaScript(result);
|
||||
}
|
||||
|
||||
[MinifyJavaScriptResult(Order = 0)]
|
||||
[OutputCache(Order = 1, VaryByParam = "none", Location = OutputCacheLocation.Server, Duration = 5000)]
|
||||
public JavaScriptResult TinyMceEditor()
|
||||
{
|
||||
var files = JsInitialization.OptimizeTinyMceScriptFiles(HttpContext);
|
||||
|
||||
var rawJS = new StringBuilder();
|
||||
rawJS.AppendLine("LazyLoad.js([");
|
||||
var first = true;
|
||||
foreach (var file in files)
|
||||
{
|
||||
if (first) first = false;
|
||||
else rawJS.AppendLine(",");
|
||||
rawJS.Append("\"");
|
||||
rawJS.Append(file);
|
||||
rawJS.Append("\"");
|
||||
|
||||
}
|
||||
rawJS.Append("]);");
|
||||
return JavaScript(rawJS.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a js array of all of the manifest assets
|
||||
/// </summary>
|
||||
|
||||
@@ -13,6 +13,7 @@ using Umbraco.Web.Models;
|
||||
namespace Umbraco.Web
|
||||
{
|
||||
using Core.Configuration;
|
||||
using Umbraco.Web.JavaScript;
|
||||
|
||||
/// <summary>
|
||||
/// HtmlHelper extensions for the back office
|
||||
@@ -118,6 +119,21 @@ namespace Umbraco.Web
|
||||
sb.AppendLine(JsonConvert.SerializeObject(resetCodeModel));
|
||||
sb.AppendLine(@"});");
|
||||
|
||||
return html.Raw(sb.ToString());
|
||||
}
|
||||
|
||||
public static IHtmlString AngularValueTinyMceAssets(this HtmlHelper html)
|
||||
{
|
||||
var ctx = new HttpContextWrapper(HttpContext.Current);
|
||||
var files = JsInitialization.OptimizeTinyMceScriptFiles(ctx);
|
||||
|
||||
var sb = new StringBuilder();
|
||||
|
||||
sb.AppendLine(@"app.value(""tinyMceAssets"",");
|
||||
sb.AppendLine(JsonConvert.SerializeObject(files));
|
||||
sb.AppendLine(@");");
|
||||
|
||||
|
||||
return html.Raw(sb.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +60,26 @@ namespace Umbraco.Web.JavaScript
|
||||
return WriteScript(jarray.ToString(), IOHelper.ResolveUrl(SystemDirectories.Umbraco), angularModule);
|
||||
}
|
||||
|
||||
public static string GetTinyJavascriptInitialization(HttpContextBase httpContext, IEnumerable<string> scripts)
|
||||
{
|
||||
var rawJs = new StringBuilder();
|
||||
rawJs.AppendLine("LazyLoad.js([");
|
||||
|
||||
var first = true;
|
||||
foreach (var file in scripts)
|
||||
{
|
||||
if (first) first = false;
|
||||
else rawJs.AppendLine(",");
|
||||
rawJs.Append("\"");
|
||||
rawJs.Append(file);
|
||||
rawJs.Append("\"");
|
||||
|
||||
}
|
||||
rawJs.Append("]);");
|
||||
|
||||
return rawJs.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a list of optimized script paths for the back office
|
||||
/// </summary>
|
||||
@@ -131,6 +151,17 @@ namespace Umbraco.Web.JavaScript
|
||||
return resources.Where(x => x.Type == JTokenType.String).Select(x => x.ToString());
|
||||
}
|
||||
|
||||
internal static IEnumerable<string> GetTinyMceInitialization()
|
||||
{
|
||||
var resources = JsonConvert.DeserializeObject<JArray>(Resources.TinyMceInitialize);
|
||||
return resources.Where(x => x.Type == JTokenType.String).Select(x => x.ToString());
|
||||
}
|
||||
|
||||
internal static IEnumerable<string> OptimizeTinyMceScriptFiles(HttpContextBase httpContext)
|
||||
{
|
||||
return OptimizeScriptFiles(httpContext, GetTinyMceInitialization());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parses the JsResources.Main and replaces the replacement tokens accordingly.
|
||||
/// </summary>
|
||||
|
||||
12
src/Umbraco.Web/JavaScript/Resources.Designer.cs
generated
12
src/Umbraco.Web/JavaScript/Resources.Designer.cs
generated
@@ -146,5 +146,17 @@ namespace Umbraco.Web.JavaScript {
|
||||
return ResourceManager.GetString("ServerVariables", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to [
|
||||
/// '../lib/tinymce/tinymce.min.js',
|
||||
///]
|
||||
///.
|
||||
/// </summary>
|
||||
internal static string TinyMceInitialize {
|
||||
get {
|
||||
return ResourceManager.GetString("TinyMceInitialize", resourceCulture);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,4 +130,7 @@
|
||||
<data name="ServerVariables" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>servervariables.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
</root>
|
||||
<data name="TinyMceInitialize" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||
<value>TinyMceInitialize.js;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;utf-8</value>
|
||||
</data>
|
||||
</root>
|
||||
19
src/Umbraco.Web/JavaScript/TinyMceInitialize.js
Normal file
19
src/Umbraco.Web/JavaScript/TinyMceInitialize.js
Normal file
@@ -0,0 +1,19 @@
|
||||
[
|
||||
'lib/tinymce/tinymce.min.js',
|
||||
|
||||
'lib/tinymce/langs/en_us.js',
|
||||
|
||||
'lib/tinymce/plugins/paste/plugin.min.js',
|
||||
'lib/tinymce/plugins/anchor/plugin.min.js',
|
||||
'lib/tinymce/plugins/charmap/plugin.min.js',
|
||||
'lib/tinymce/plugins/table/plugin.min.js',
|
||||
'lib/tinymce/plugins/lists/plugin.min.js',
|
||||
'lib/tinymce/plugins/advlist/plugin.min.js',
|
||||
'lib/tinymce/plugins/hr/plugin.min.js',
|
||||
'lib/tinymce/plugins/autolink/plugin.min.js',
|
||||
'lib/tinymce/plugins/directionality/plugin.min.js',
|
||||
'lib/tinymce/plugins/tabfocus/plugin.min.js',
|
||||
'lib/tinymce/plugins/searchreplace/plugin.min.js',
|
||||
'lib/tinymce/plugins/fullscreen/plugin.min.js',
|
||||
'lib/tinymce/plugins/noneditable/plugin.min.js'
|
||||
]
|
||||
@@ -1205,6 +1205,7 @@
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="JavaScript\PreviewInitialize.js" />
|
||||
<None Include="JavaScript\TinyMceInitialize.js" />
|
||||
<!--<Content Include="umbraco.presentation\umbraco\users\PermissionEditor.aspx" />-->
|
||||
<Content Include="PublishedCache\NuCache\notes.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
Reference in New Issue
Block a user