Skip to content

Commit

Permalink
Fix TinyMCE config loading from skin config
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephMDavis committed Jun 6, 2024
1 parent 9081adc commit eaccaec
Show file tree
Hide file tree
Showing 7 changed files with 210 additions and 554 deletions.
42 changes: 42 additions & 0 deletions Web/Controls/Editors/TinyMCE/ITinyMceSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
namespace mojoPortal.Web.Editor;

public interface ITinyMceSettings
{
bool Inline { get; set; }
bool AutoFocus { get; set; }
string Menubar { get; set; }
bool DisableMenuBar { get; set; }
string Plugins { get; set; }
string Toolbar1Buttons { get; set; }
string Toolbar2Buttons { get; set; }
string Toolbar3Buttons { get; set; }
string ExtendedValidElements { get; set; }
bool ForcePasteAsPlainText { get; set; }
bool ConvertUrls { get; set; }
bool EnableObjectResizing { get; set; }
int UnDoLevels { get; set; }
string Theme { get; set; }
string Skin { get; set; }
bool AutoLocalize { get; set; }
string Language { get; set; }
string TextDirection { get; set; }
bool EnableBrowserSpellCheck { get; set; }
string EditorBodyCssClass { get; set; }
bool NoWrap { get; set; }
string RemovedMenuItems { get; set; }
int FileDialogHeight { get; set; }
int FileDialogWidth { get; set; }
bool EnableImageAdvancedTab { get; set; }
bool ShowStatusbar { get; set; }
string CustomToolbarElementClientId { get; set; }
string EditorAreaCSS { get; set; }
string TemplatesUrl { get; set; }
string StyleFormats { get; set; }
string EmotionsBaseUrl { get; set; }
string FileManagerUrl { get; set; }
string GlobarVarToAssignEditor { get; set; }
string OnSaveCallback { get; set; }
bool SaveEnableWhenDirty { get; set; }
bool PromptOnNavigationWithUnsavedChanges { get; set; }
string ImagesUploadUrl { get; set; }
}
90 changes: 45 additions & 45 deletions Web/Controls/Editors/TinyMCE/TinyMCE.cs
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,11 @@ protected override void Render(HtmlTextWriter writer)

writer.Write(
"<textarea id=\"{0}\" name=\"{1}\" rows=\"4\" cols=\"40\" style=\"width: {2}; height: {3}\" >{4}</textarea>",
this.ClientID,
this.UniqueID,
this.Width,
this.Height,
System.Web.HttpUtility.HtmlEncode(this.Text));
ClientID,
UniqueID,
Width,
Height,
System.Web.HttpUtility.HtmlEncode(Text));


}
Expand All @@ -558,23 +558,23 @@ private void SetupScripts()
{
if (BasePath.Contains("tiny_mce"))
{
this.Page.ClientScript.RegisterClientScriptBlock(
this.GetType(),
Page.ClientScript.RegisterClientScriptBlock(
GetType(),
"tinymcemain",
"<script data-loader=\"TinyMCE\" src=\""
+ ResolveUrl(this.BasePath + "tiny_mce.js") + "\"></script>");
+ ResolveUrl(BasePath + "tiny_mce.js") + "\"></script>");
}
else
{
this.Page.ClientScript.RegisterClientScriptBlock(
this.GetType(),
Page.ClientScript.RegisterClientScriptBlock(
GetType(),
"tinymcemain",
"<script data-loader=\"TinyMCE\" src=\""
+ ResolveUrl(this.BasePath + "tinymce.min.js") + "\"></script>");
+ ResolveUrl(BasePath + "tinymce.min.js") + "\"></script>");

}

StringBuilder setupScript = new StringBuilder();
var setupScript = new StringBuilder();

setupScript.Append("function mojoTinyMCEOnChangeHandler(inst) {");
//setupScript.Append("hookupGoodbyePrompt(\"" + Page.Server.HtmlEncode(Resource.UnSavedChangesPrompt) + "\"); ");
Expand All @@ -597,7 +597,7 @@ private void SetupScripts()
//if (BasePath.Contains("tiny_mce"))
//{

setupScript.Append(" var ed" + this.ClientID + " = new tinymce.Editor('" + this.ClientID + "', { ");
setupScript.Append($" var ed{ClientID} = new tinymce.Editor('{ClientID}', {{ ");
//}
//else
//{
Expand All @@ -612,7 +612,7 @@ private void SetupScripts()
//waiting for the 3.5 branch of TinyMCE to comeout of beta
// it has more support for html 5

setupScript.Append(", schema :'" + WebConfigSettings.TinyMceSchema + "' ");
setupScript.Append($", schema :'{WebConfigSettings.TinyMceSchema}' ");
//http://www.tinymce.com/tryit/html5_formats.php
// setupScript.Append(",style_formats :[{title : 'section', block : 'section', wrapper: true, merge_siblings: false},");
// setupScript.Append("{title : 'article', block : 'article', wrapper: true, merge_siblings: false},");
Expand All @@ -630,7 +630,7 @@ private void SetupScripts()
setupScript.Append(", accessibility_warnings : false ");
}

setupScript.Append(", browsers : \"" + this.Browsers + "\"");
setupScript.Append(", browsers : \"" + Browsers + "\"");

setupScript.Append(",forced_root_block:'" + ForcedRootBlock + "'");

Expand All @@ -649,7 +649,7 @@ private void SetupScripts()

//setupScript.Append(",encoding :'xml'");

setupScript.Append(", dialog_type : \"" + this.DialogType + "\"");
setupScript.Append(", dialog_type : \"" + DialogType + "\"");

CultureInfo culture;
if (WebConfigSettings.UseCultureOverride)
Expand All @@ -674,9 +674,9 @@ private void SetupScripts()

//extended_valid_elements

setupScript.Append(",directionality:\"" + this.TextDirection + "\"");
setupScript.Append(",directionality:\"" + TextDirection + "\"");

setupScript.Append(",editor_deselector:\"" + this.DeSelectorCSSClass + "\"");
setupScript.Append(",editor_deselector:\"" + DeSelectorCSSClass + "\"");



Expand All @@ -697,7 +697,7 @@ private void SetupScripts()

if (Plugins.Length > 0)
{
setupScript.Append(", plugins : \"" + this.Plugins + "\"");
setupScript.Append(", plugins : \"" + Plugins + "\"");
if (Plugins.Contains("preview"))
{
setupScript.Append(",plugin_preview_width:'850'");
Expand All @@ -713,7 +713,7 @@ private void SetupScripts()
// setupScript.Append(", strict_loading_mode : true ");
//}

setupScript.Append(", theme : \"" + this.Theme + "\"");
setupScript.Append(", theme : \"" + Theme + "\"");

if (!EnableUndoRedo)
{
Expand All @@ -722,34 +722,34 @@ private void SetupScripts()

if (EnableUndoRedo)
{
setupScript.Append(", custom_undo_redo_levels : " + this.UnDoLevels.ToString());
setupScript.Append(", custom_undo_redo_levels : " + UnDoLevels.ToString());
}

if (Theme == "advanced")
{
setupScript.Append(", layout_manager : \"" + this.AdvancedLayoutManager + "\"");
setupScript.Append(", theme_advanced_blockformats : \"" + this.AdvancedBlockFormats + "\"");
setupScript.Append(", layout_manager : \"" + AdvancedLayoutManager + "\"");
setupScript.Append(", theme_advanced_blockformats : \"" + AdvancedBlockFormats + "\"");
if (AdvancedStyles.Length > 0)
{
setupScript.Append(", theme_advanced_styles : \"" + this.AdvancedStyles + "\"");
setupScript.Append(", theme_advanced_styles : \"" + AdvancedStyles + "\"");
}

setupScript.Append(", theme_advanced_source_editor_width : \"" + this.AdvancedSourceEditorWidth + "\"");
setupScript.Append(", theme_advanced_source_editor_height : \"" + this.AdvancedSourceEditorHeight + "\"");
setupScript.Append(", theme_advanced_source_editor_width : \"" + AdvancedSourceEditorWidth + "\"");
setupScript.Append(", theme_advanced_source_editor_height : \"" + AdvancedSourceEditorHeight + "\"");
if (!AdvancedSourceEditorWrap)
{
setupScript.Append(", theme_advanced_source_editor_wrap : false ");
}

if (AdvancedLayoutManager == "SimpleLayout")
{
setupScript.Append(", theme_advanced_toolbar_location : \"" + this.AdvancedToolbarLocation + "\"");
setupScript.Append(", theme_advanced_toolbar_align : \"" + this.AdvancedToolbarAlign + "\"");
setupScript.Append(", theme_advanced_statusbar_location : \"" + this.AdvancedStatusBarLocation + "\"");
setupScript.Append(", theme_advanced_toolbar_location : \"" + AdvancedToolbarLocation + "\"");
setupScript.Append(", theme_advanced_toolbar_align : \"" + AdvancedToolbarAlign + "\"");
setupScript.Append(", theme_advanced_statusbar_location : \"" + AdvancedStatusBarLocation + "\"");

setupScript.Append(", theme_advanced_buttons1 : \"" + this.AdvancedRow1Buttons + "\"");
setupScript.Append(", theme_advanced_buttons2 : \"" + this.AdvancedRow2Buttons + "\"");
setupScript.Append(", theme_advanced_buttons3 : \"" + this.AdvancedRow3Buttons + "\"");
setupScript.Append(", theme_advanced_buttons1 : \"" + AdvancedRow1Buttons + "\"");
setupScript.Append(", theme_advanced_buttons2 : \"" + AdvancedRow2Buttons + "\"");
setupScript.Append(", theme_advanced_buttons3 : \"" + AdvancedRow3Buttons + "\"");

//setupScript.Append(", theme_advanced_buttons1_add : \"pastetext,pasteword,selectall\"");

Expand Down Expand Up @@ -790,7 +790,7 @@ private void SetupScripts()

if (TemplatesUrl.Length > 0)
{
setupScript.Append(",template_external_list_url: \"" + this.TemplatesUrl + "\"");
setupScript.Append(",template_external_list_url: \"" + TemplatesUrl + "\"");
}

if (!Cleanup)
Expand All @@ -812,7 +812,7 @@ private void SetupScripts()

if (EditorAreaCSS.Length > 0)
{
setupScript.Append(", content_css : \"" + this.EditorAreaCSS + "\"");
setupScript.Append(", content_css : \"" + EditorAreaCSS + "\"");
}

if (EmotionsBaseUrl.Length > 0)
Expand All @@ -822,7 +822,7 @@ private void SetupScripts()

if (AutoFocus)
{
setupScript.Append(", auto_focus : \"" + this.ClientID + "\" ");
setupScript.Append(", auto_focus : \"" + ClientID + "\" ");
}

if ((EnableFileBrowser) && (FileManagerUrl.Length > 0))
Expand Down Expand Up @@ -876,22 +876,22 @@ private void SetupScripts()

supScript.Append("</script>");

this.Page.ClientScript.RegisterClientScriptBlock(
Page.ClientScript.RegisterClientScriptBlock(
typeof(Page),
"tmcfpfix",
supScript.ToString());

setupScript.Append("ed" + this.ClientID + ".onBeforeSetContent.add(function(ed, o) {");
setupScript.Append("ed" + ClientID + ".onBeforeSetContent.add(function(ed, o) {");
setupScript.Append("o.content = editorContentFilter.setContent(o.content);");
setupScript.Append(" });");

setupScript.Append("ed" + this.ClientID + ".onGetContent.add(function(ed, o) {");
setupScript.Append("ed" + ClientID + ".onGetContent.add(function(ed, o) {");
setupScript.Append("o.content = editorContentFilter.getContent(o.content);");
setupScript.Append(" });");

}

setupScript.Append("ed" + this.ClientID + ".render(); ");
setupScript.Append("ed" + ClientID + ".render(); ");

//if (forcePasteAsPlainText)
//{
Expand All @@ -907,9 +907,9 @@ private void SetupScripts()

setupScript.Append("</script>");

this.Page.ClientScript.RegisterStartupScript(
this.GetType(),
this.UniqueID,
Page.ClientScript.RegisterStartupScript(
GetType(),
UniqueID,
setupScript.ToString());


Expand Down Expand Up @@ -954,7 +954,7 @@ private void SetupFileBrowserScript()
script.Append("}");
script.Append("\n</script>");

this.Page.ClientScript.RegisterClientScriptBlock(
Page.ClientScript.RegisterClientScriptBlock(
typeof(Page),
"tmcfb",
script.ToString());
Expand All @@ -969,9 +969,9 @@ public bool LoadPostData(string postDataKey, NameValueCollection postCollection)
if (postCollection[postDataKey] == null) { return false; }

string newContent = postCollection[postDataKey];
if (newContent != this.Text)
if (newContent != Text)
{
this.Text = newContent;
Text = newContent;
return true;
}

Expand Down
Loading

0 comments on commit eaccaec

Please sign in to comment.