mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-01-24 05:42:10 +08:00
If the user doesn't have ManageMedia permissions, the markdown editor will use a specific image editor.
44 lines
1.6 KiB
Plaintext
44 lines
1.6 KiB
Plaintext
@using Orchard.Environment.Descriptor.Models
|
|
|
|
@{
|
|
Script.Require("OrchardMarkdown");
|
|
Style.Require("OrchardMarkdown");
|
|
|
|
var idPostfix = Html.FieldIdFor(m => m);
|
|
var shellDescriptor = WorkContext.Resolve<ShellDescriptor>();
|
|
var mediaLibraryEnabled = shellDescriptor.Features.Any(x => x.Name == "Orchard.MediaLibrary");
|
|
|
|
if (mediaLibraryEnabled) {
|
|
Script.Require("jQueryColorBox");
|
|
Script.Require("OrchardMarkdown-MediaLibrary");
|
|
Style.Require("jQueryColorBox");
|
|
}
|
|
else {
|
|
Script.Require("OrchardMarkdown-MediaPicker");
|
|
}
|
|
|
|
var textAreaAttributes = new Dictionary<string, object> {
|
|
{"id", "wmd-input" + "-" + idPostfix},
|
|
{"class", "wmd-input"},
|
|
{"data-mediapicker-uploadpath", Model.AddMediaPath},
|
|
{"data-mediapicker-title", T("Insert/Update Media")},
|
|
{"data-manage-media", AuthorizedFor(Orchard.MediaLibrary.Permissions.ManageMediaContent) ? "true" : "false" }
|
|
};
|
|
|
|
// The markdown editor itself doesn't seem to (yet) support autofocus, but we'll set it on the textarea nonetheless.
|
|
if (Model.AutoFocus == true) {
|
|
textAreaAttributes["autofocus"] = "autofocus";
|
|
}
|
|
}
|
|
|
|
<div class="wmd-box has-grip">
|
|
<div class="wmd-innerbox">
|
|
<div class="wmd-editor-box">
|
|
<div id="wmd-button-bar-@idPostfix" class="wmd-button-bar"></div>
|
|
@Html.TextArea("Text", (string)Model.Text, 25, 80, textAreaAttributes)
|
|
</div>
|
|
<div class="wmd-preview-box">
|
|
<div id="wmd-preview-@idPostfix" class="wmd-panel wmd-preview"></div>
|
|
</div>
|
|
</div>
|
|
</div> |