[completed: 605]Improved html tag support in VisualEditor.

This commit is contained in:
Matteo Tomasini 2011-08-31 12:10:29 +02:00
parent 251731071b
commit ff07e317cd
3 changed files with 39 additions and 43 deletions

View file

@ -16,5 +16,5 @@ using System.Reflection;
// //
// You can specify all the values or you can default the Revision and Build Numbers // You can specify all the values or you can default the Revision and Build Numbers
// by using the '*' as shown below: // by using the '*' as shown below:
[assembly: AssemblyVersion("3.0.5.607")] [assembly: AssemblyVersion("3.0.5.608")]
[assembly: AssemblyFileVersion("3.0.5.607")] [assembly: AssemblyFileVersion("3.0.5.608")]

View file

@ -260,19 +260,14 @@ namespace ScrewTurn.Wiki {
result += "\n== ==\n" + ProcessChild(node.ChildNodes); result += "\n== ==\n" + ProcessChild(node.ChildNodes);
break; break;
case "span": case "span":
if(node.Attributes["style"] != null) { if(node.Attributes["style"] != null && node.Attributes["style"].Value.Replace(" ", "").ToLowerInvariant().Contains("font-weight:normal")) {
if(node.Attributes["style"].Value.Replace(" ", "").ToLowerInvariant().Contains("font-weight:normal")) { result += ProcessChild(node.ChildNodes);
result += ProcessChild(node.ChildNodes);
}
if(node.Attributes["style"].Value.Replace(" ", "").ToLowerInvariant().Contains("white-space:pre")) {
result += ": ";
}
} }
if(node.Attributes.Count > 0) { else if(node.Attributes["style"] != null && node.Attributes["style"].Value.Replace(" ", "").ToLowerInvariant().Contains("white-space:pre")) {
XmlAttributeCollection attributeCollection = node.Attributes; result += ": ";
foreach(XmlAttribute attribute in attributeCollection) { }
if(attribute.Value == "italic") result += "''" + ProcessChild(node.ChildNodes) + "''"; else {
} result += node.OuterXml;
} }
break; break;
case "br": case "br":
@ -327,12 +322,13 @@ namespace ScrewTurn.Wiki {
else result += ProcessChild(node.ChildNodes) + "\n" + (Settings.ProcessSingleLineBreaks ? "" : "\n"); else result += ProcessChild(node.ChildNodes) + "\n" + (Settings.ProcessSingleLineBreaks ? "" : "\n");
break; break;
case "div": case "div":
if(node.Attributes["class"] != null) { if(node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("box")) result += node.HasChildNodes ? "(((" + ProcessChild(node.ChildNodes) + ")))" : "";
if(node.Attributes["class"].Value.Contains("box")) result += node.HasChildNodes ? "(((" + ProcessChild(node.ChildNodes) + ")))" : ""; else if(node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("imageleft")) result += "[imageleft" + ProcessChildImage(node.ChildNodes) + "]";
else if(node.Attributes["class"].Value.Contains("imageleft")) result += "[imageleft" + ProcessChildImage(node.ChildNodes) + "]"; else if(node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("imageright")) result += "[imageright" + ProcessChildImage(node.ChildNodes) + "]";
else if(node.Attributes["class"].Value.Contains("imageright")) result += "[imageright" + ProcessChildImage(node.ChildNodes) + "]"; else if(node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("image")) result += "[image" + ProcessChildImage(node.ChildNodes) + "]";
else if(node.Attributes["class"].Value.Contains("image")) result += "[image" + ProcessChildImage(node.ChildNodes) + "]"; else if(node.Attributes["class"] != null && node.Attributes["class"].Value.Contains("indent")) result += ": " + ProcessChild(node.ChildNodes) + "\n";
else if(node.Attributes["class"].Value.Contains("indent")) result += ": " + ProcessChild(node.ChildNodes) + "\n"; else if(node.Attributes.Count > 0) {
result += node.OuterXml;
} }
else { else {
result += "\n"; result += "\n";

View file

@ -12,7 +12,7 @@ namespace ScrewTurn.Wiki {
public partial class Editor : System.Web.UI.UserControl { public partial class Editor : System.Web.UI.UserControl {
private PageInfo currentPage = null; private PageInfo currentPage = null;
private bool inWYSIWYG = false; private bool inWYSIWYG = false;
protected void Page_Load(object sender, EventArgs e) { protected void Page_Load(object sender, EventArgs e) {
if(!Page.IsPostBack) { if(!Page.IsPostBack) {
@ -32,8 +32,8 @@ namespace ScrewTurn.Wiki {
InitToolbar(); InitToolbar();
} }
if(mlvEditor.ActiveViewIndex == 1) inWYSIWYG = true; if(mlvEditor.ActiveViewIndex == 1) inWYSIWYG = true;
else inWYSIWYG = false; else inWYSIWYG = false;
//SelectTab(0); //SelectTab(0);
if(ViewState["Tab"] != null) SelectTab((int)ViewState["Tab"]); if(ViewState["Tab"] != null) SelectTab((int)ViewState["Tab"]);
@ -132,42 +132,42 @@ namespace ScrewTurn.Wiki {
protected void btnWikiMarkup_Click(object sender, EventArgs e) { protected void btnWikiMarkup_Click(object sender, EventArgs e) {
SelectTab(0); SelectTab(0);
//added for WYSIWYG //added for WYSIWYG
//if last view was WYSIWYG take text from WYSIWYG to Markup //if last view was WYSIWYG take text from WYSIWYG to Markup
if(inWYSIWYG) if(inWYSIWYG)
txtMarkup.Text = ReverseFormatter.ReverseFormat(lblWYSIWYG.Text); txtMarkup.Text = ReverseFormatter.ReverseFormat(lblWYSIWYG.Text);
//end //end
} }
protected void btnVisual_Click(object sender, EventArgs e) { protected void btnVisual_Click(object sender, EventArgs e) {
SelectTab(1); SelectTab(1);
//added for WYSIWYG //added for WYSIWYG
//lblWYSIWYG.Text = FormattingPipeline.FormatWithPhase1And2(txtMarkup.Text, null); //lblWYSIWYG.Text = FormattingPipeline.FormatWithPhase1And2(txtMarkup.Text, null);
string[] links = null; string[] links = null;
lblWYSIWYG.Text = Formatter.Format(txtMarkup.Text.Replace("<", "&lt;").Replace(">", "&gt;"), lblWYSIWYG.Text = Formatter.Format(txtMarkup.Text,
false, FormattingContext.Unknown, null, out links, true); false, FormattingContext.Unknown, null, out links, true);
//end //end
} }
protected void btnPreview_Click(object sender, EventArgs e) { protected void btnPreview_Click(object sender, EventArgs e) {
SelectTab(2); SelectTab(2);
//added for WYSIWYG //added for WYSIWYG
//if last view was WYSIWYG take text from WYSIWYG to Preview //if last view was WYSIWYG take text from WYSIWYG to Preview
//in both cases I need to synchronize WYSIWYG and Markup view //in both cases I need to synchronize WYSIWYG and Markup view
if(inWYSIWYG) { if(inWYSIWYG) {
lblPreview.Text = lblWYSIWYG.Text.Replace("&lt;", "<").Replace("&gt;", ">"); lblPreview.Text = lblWYSIWYG.Text.Replace("&lt;", "<").Replace("&gt;", ">");
txtMarkup.Text = ReverseFormatter.ReverseFormat(lblWYSIWYG.Text); txtMarkup.Text = ReverseFormatter.ReverseFormat(lblWYSIWYG.Text);
} }
else { else {
lblPreview.Text = FormattingPipeline.FormatWithPhase3(FormattingPipeline.FormatWithPhase1And2(txtMarkup.Text, false, FormattingContext.Unknown, null), lblPreview.Text = FormattingPipeline.FormatWithPhase3(FormattingPipeline.FormatWithPhase1And2(txtMarkup.Text, false, FormattingContext.Unknown, null),
FormattingContext.Unknown, null); FormattingContext.Unknown, null);
//lblWYSIWYG.Text = lblPreview.Text; //lblWYSIWYG.Text = lblPreview.Text;
string[] links = null; string[] links = null;
lblWYSIWYG.Text = Formatter.Format(txtMarkup.Text, false, FormattingContext.Unknown, null, out links, true); lblWYSIWYG.Text = Formatter.Format(txtMarkup.Text, false, FormattingContext.Unknown, null, out links, true);
} }
//end //end
} }
#endregion #endregion