mirror of
https://github.com/ShareX/ShareX.git
synced 2024-09-30 01:07:21 +13:00
Added custom text support for text uploading.
Example: <html> <body style="background-color:#333333"> <pre class="prettyprint"> %input </pre> <script src="https://google-code-prettify.googlecode.com/svn/loader/run_prettify.js?skin=desert"></script> </body> </html> Will add syntax highlighting to uploaded text.
This commit is contained in:
parent
53bbeece19
commit
0005eaf9aa
2 changed files with 13 additions and 3 deletions
|
@ -31,6 +31,7 @@ You should have received a copy of the GNU General Public License
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.Design;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Design;
|
||||
using System.Globalization;
|
||||
|
@ -436,6 +437,10 @@ public Size ToastWindowSize
|
|||
[Category("Upload text"), DefaultValue("text"), Description("Text format e.g. csharp, cpp, etc.")]
|
||||
public string TextFormat { get; set; }
|
||||
|
||||
[Category("Upload text"), DefaultValue(""), Description("Custom text input. Use %input for text input. Example you can create web page with your text in it."),
|
||||
Editor(typeof(MultilineStringEditor), typeof(UITypeEditor))]
|
||||
public string TextCustom { get; set; }
|
||||
|
||||
[Category("Name pattern"), DefaultValue(100), Description("Maximum name pattern length for file name.")]
|
||||
public int NamePatternMaxLength { get; set; }
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ public static void ClipboardUpload(TaskSettings taskSettings = null)
|
|||
}
|
||||
else
|
||||
{
|
||||
UploadText(text, taskSettings);
|
||||
UploadText(text, taskSettings, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ public static void DragDropUpload(IDataObject data, TaskSettings taskSettings =
|
|||
else if (data.GetDataPresent(DataFormats.Text, false))
|
||||
{
|
||||
string text = data.GetData(DataFormats.Text, false) as string;
|
||||
UploadText(text, taskSettings);
|
||||
UploadText(text, taskSettings, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -347,12 +347,17 @@ public static void UploadImage(Image img, ImageDestination imageDestination, Fil
|
|||
}
|
||||
}
|
||||
|
||||
public static void UploadText(string text, TaskSettings taskSettings = null)
|
||||
public static void UploadText(string text, TaskSettings taskSettings = null, bool allowCustomText = false)
|
||||
{
|
||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
if (allowCustomText && !string.IsNullOrEmpty(taskSettings.AdvancedSettings.TextCustom))
|
||||
{
|
||||
text = taskSettings.AdvancedSettings.TextCustom.Replace("%input", text);
|
||||
}
|
||||
|
||||
UploadTask task = UploadTask.CreateTextUploaderTask(text, taskSettings);
|
||||
TaskManager.Start(task);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue