mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
#18589: Fixing multiple TextFields with MarkDown flavor
Work Item: 18589 --HG-- branch : 1.x
This commit is contained in:
@@ -1,13 +1,20 @@
|
|||||||
(function () {
|
(function () {
|
||||||
var marker = '<!-- markdown -->';
|
var marker = '<!-- markdown -->';
|
||||||
var converter = Markdown.getSanitizingConverter();
|
var converter = Markdown.getSanitizingConverter();
|
||||||
var editor = new Markdown.Editor(converter, "", {
|
|
||||||
|
var editors = $('.wmd-input');
|
||||||
|
|
||||||
|
editors.each(function () {
|
||||||
|
|
||||||
|
var idPostfix = $(this).attr('id').substr('wmd-input'.length);
|
||||||
|
|
||||||
|
var editor = new Markdown.Editor(converter, idPostfix, {
|
||||||
handler: function () { window.open("http://daringfireball.net/projects/markdown/syntax"); }
|
handler: function () { window.open("http://daringfireball.net/projects/markdown/syntax"); }
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.hooks.set("insertImageDialog", function (callback) {
|
editor.hooks.set("insertImageDialog", function (callback) {
|
||||||
// see if there's an image selected that they intend on editing
|
// see if there's an image selected that they intend on editing
|
||||||
var wmd = $('#wmd-input');
|
var wmd = $('#wmd-input' + idPostfix);
|
||||||
|
|
||||||
var editImage, content = wmd.selection ? wmd.selection.createRange().text : null;
|
var editImage, content = wmd.selection ? wmd.selection.createRange().text : null;
|
||||||
if (content) {
|
if (content) {
|
||||||
@@ -38,6 +45,9 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
editor.run();
|
editor.run();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$('.grippie').TextAreaResizer();
|
$('.grippie').TextAreaResizer();
|
||||||
})();
|
})();
|
||||||
|
|||||||
@@ -1,13 +1,14 @@
|
|||||||
@{
|
@{
|
||||||
Script.Require("OrchardMarkdown");
|
Script.Require("OrchardMarkdown");
|
||||||
Style.Require("OrchardMarkdown");
|
Style.Require("OrchardMarkdown");
|
||||||
|
string idPostfix = @Html.FieldIdFor(m => m);
|
||||||
}
|
}
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<div id="wmd-button-bar" class="wmd-button-bar"></div>
|
<div id="wmd-button-bar-@idPostfix" class="wmd-button-bar"></div>
|
||||||
|
|
||||||
@Html.TextArea("Text", (string)Model.Text, 25, 80,
|
@Html.TextArea("Text", (string)Model.Text, 25, 80,
|
||||||
new Dictionary<string,object> {
|
new Dictionary<string, object> {
|
||||||
{"id", "wmd-input"},
|
{"id", "wmd-input" + "-" + idPostfix},
|
||||||
{"class", "wmd-input grippie"},
|
{"class", "wmd-input grippie"},
|
||||||
{"data-mediapicker-uploadpath", Model.AddMediaPath},
|
{"data-mediapicker-uploadpath", Model.AddMediaPath},
|
||||||
{"data-mediapicker-title", T("Insert/Update Media")}
|
{"data-mediapicker-title", T("Insert/Update Media")}
|
||||||
@@ -16,5 +17,5 @@
|
|||||||
|
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<label>@T("Preview")</label>
|
<label>@T("Preview")</label>
|
||||||
<div id="wmd-preview" class="wmd-panel wmd-preview"></div>
|
<div id="wmd-preview-@idPostfix" class="wmd-panel wmd-preview"></div>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|||||||
Reference in New Issue
Block a user