mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Merged 1.9.x into dev.
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using Orchard.Layouts.Elements;
|
||||||
|
using Orchard.Layouts.Framework.Display;
|
||||||
|
using Orchard.Layouts.Framework.Drivers;
|
||||||
|
using Orchard.Layouts.ViewModels;
|
||||||
|
using Orchard.Services;
|
||||||
|
|
||||||
|
namespace Orchard.Layouts.Drivers {
|
||||||
|
public class HeadingElementDriver : ElementDriver<Heading> {
|
||||||
|
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
|
||||||
|
public HeadingElementDriver(IEnumerable<IHtmlFilter> htmlFilters) {
|
||||||
|
_htmlFilters = htmlFilters;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override EditorResult OnBuildEditor(Heading element, ElementEditorContext context) {
|
||||||
|
var viewModel = new HeadingEditorViewModel {
|
||||||
|
Text = element.Content,
|
||||||
|
Level = element.Level
|
||||||
|
};
|
||||||
|
var editor = context.ShapeFactory.EditorTemplate(TemplateName: "Elements.Heading", Model: viewModel);
|
||||||
|
|
||||||
|
if (context.Updater != null) {
|
||||||
|
context.Updater.TryUpdateModel(viewModel, context.Prefix, null, null);
|
||||||
|
element.Content = viewModel.Text;
|
||||||
|
element.Level = viewModel.Level;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Editor(context, editor);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnDisplaying(Heading element, ElementDisplayContext context) {
|
||||||
|
var text = element.Content;
|
||||||
|
var flavor = "html";
|
||||||
|
var processedText = ApplyHtmlFilters(text, flavor);
|
||||||
|
|
||||||
|
context.ElementShape.ProcessedText = processedText;
|
||||||
|
context.ElementShape.Level = element.Level;
|
||||||
|
}
|
||||||
|
|
||||||
|
private string ApplyHtmlFilters(string content, string flavor) {
|
||||||
|
return _htmlFilters.Aggregate(content, (t, filter) => filter.ProcessContent(t, flavor));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -8,11 +8,6 @@ using Orchard.Services;
|
|||||||
|
|
||||||
namespace Orchard.Layouts.Drivers {
|
namespace Orchard.Layouts.Drivers {
|
||||||
public class ParagraphElementDriver : ElementDriver<Paragraph> {
|
public class ParagraphElementDriver : ElementDriver<Paragraph> {
|
||||||
private readonly IEnumerable<IHtmlFilter> _htmlFilters;
|
|
||||||
public ParagraphElementDriver(IEnumerable<IHtmlFilter> htmlFilters) {
|
|
||||||
_htmlFilters = htmlFilters;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override EditorResult OnBuildEditor(Paragraph element, ElementEditorContext context) {
|
protected override EditorResult OnBuildEditor(Paragraph element, ElementEditorContext context) {
|
||||||
var viewModel = new ParagraphEditorViewModel {
|
var viewModel = new ParagraphEditorViewModel {
|
||||||
Text = element.Content
|
Text = element.Content
|
||||||
@@ -26,17 +21,5 @@ namespace Orchard.Layouts.Drivers {
|
|||||||
|
|
||||||
return Editor(context, editor);
|
return Editor(context, editor);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnDisplaying(Paragraph element, ElementDisplayingContext context) {
|
|
||||||
var text = element.Content;
|
|
||||||
var flavor = "html";
|
|
||||||
var processedText = ApplyHtmlFilters(text, flavor);
|
|
||||||
|
|
||||||
context.ElementShape.ProcessedText = processedText;
|
|
||||||
}
|
|
||||||
|
|
||||||
private string ApplyHtmlFilters(string content, string flavor) {
|
|
||||||
return _htmlFilters.Aggregate(content, (t, filter) => filter.ProcessContent(t, flavor));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
24
src/Orchard.Web/Modules/Orchard.Layouts/Elements/Heading.cs
Normal file
24
src/Orchard.Web/Modules/Orchard.Layouts/Elements/Heading.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using Orchard.Layouts.Helpers;
|
||||||
|
using Orchard.Localization;
|
||||||
|
|
||||||
|
namespace Orchard.Layouts.Elements {
|
||||||
|
public class Heading : ContentElement {
|
||||||
|
|
||||||
|
public override string Category {
|
||||||
|
get { return "Content"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override LocalizedString DisplayText {
|
||||||
|
get { return T("Heading h1-h6"); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToolboxIcon {
|
||||||
|
get { return "\uf1dc"; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Level {
|
||||||
|
get { return this.Retrieve(h => h.Level); }
|
||||||
|
set { this.Store(h => h.Level, value);}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -320,6 +320,7 @@
|
|||||||
<Compile Include="Drivers\CanvasElementDriver.cs" />
|
<Compile Include="Drivers\CanvasElementDriver.cs" />
|
||||||
<Compile Include="Drivers\MenuElementDriver.cs" />
|
<Compile Include="Drivers\MenuElementDriver.cs" />
|
||||||
<Compile Include="Drivers\NotificationsElementDriver.cs" />
|
<Compile Include="Drivers\NotificationsElementDriver.cs" />
|
||||||
|
<Compile Include="Drivers\HeadingElementDriver.cs" />
|
||||||
<Compile Include="Drivers\ShapeElementDriver.cs" />
|
<Compile Include="Drivers\ShapeElementDriver.cs" />
|
||||||
<Compile Include="Drivers\BreakElementDriver.cs" />
|
<Compile Include="Drivers\BreakElementDriver.cs" />
|
||||||
<Compile Include="Elements\Breadcrumbs.cs" />
|
<Compile Include="Elements\Breadcrumbs.cs" />
|
||||||
@@ -327,6 +328,7 @@
|
|||||||
<Compile Include="Elements\ContentElement.cs" />
|
<Compile Include="Elements\ContentElement.cs" />
|
||||||
<Compile Include="Elements\Menu.cs" />
|
<Compile Include="Elements\Menu.cs" />
|
||||||
<Compile Include="Elements\Notifications.cs" />
|
<Compile Include="Elements\Notifications.cs" />
|
||||||
|
<Compile Include="Elements\Heading.cs" />
|
||||||
<Compile Include="Elements\Shape.cs" />
|
<Compile Include="Elements\Shape.cs" />
|
||||||
<Compile Include="Elements\Break.cs" />
|
<Compile Include="Elements\Break.cs" />
|
||||||
<Compile Include="Elements\UIElement.cs" />
|
<Compile Include="Elements\UIElement.cs" />
|
||||||
@@ -427,6 +429,7 @@
|
|||||||
<Compile Include="ViewModels\LayoutEditor.cs" />
|
<Compile Include="ViewModels\LayoutEditor.cs" />
|
||||||
<Compile Include="ViewModels\LayoutEditorPropertiesViewModel.cs" />
|
<Compile Include="ViewModels\LayoutEditorPropertiesViewModel.cs" />
|
||||||
<Compile Include="ViewModels\MenuEditorViewModel.cs" />
|
<Compile Include="ViewModels\MenuEditorViewModel.cs" />
|
||||||
|
<Compile Include="ViewModels\HeadingEditorViewModel.cs" />
|
||||||
<Compile Include="ViewModels\VectorImageEditorViewModel.cs" />
|
<Compile Include="ViewModels\VectorImageEditorViewModel.cs" />
|
||||||
<Compile Include="ViewModels\ImageEditorViewModel.cs" />
|
<Compile Include="ViewModels\ImageEditorViewModel.cs" />
|
||||||
<Compile Include="ViewModels\MarkdownEditorViewModel.cs" />
|
<Compile Include="ViewModels\MarkdownEditorViewModel.cs" />
|
||||||
@@ -568,6 +571,12 @@
|
|||||||
<Content Include="Views\Elements\Notifications.cshtml" />
|
<Content Include="Views\Elements\Notifications.cshtml" />
|
||||||
<Content Include="Views\Elements\Notifications.Design.cshtml" />
|
<Content Include="Views\Elements\Notifications.Design.cshtml" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Views\Elements\Heading.cshtml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Views\EditorTemplates\Elements.Heading.cshtml" />
|
||||||
|
</ItemGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -114,8 +114,16 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
$(document).on("cut copy paste", function (e) {
|
$(document).on("cut copy paste", function (e) {
|
||||||
// The real clipboard is supported, so disable the peudo clipboard.
|
// If the pseudo clipboard was already invoked (which happens on the first clipboard
|
||||||
clipboard.disable();
|
// operation after page load even if native clipboard support exists) then sit this
|
||||||
|
// one operation out, but make sure whatever is on the pseudo clipboard gets migrated
|
||||||
|
// to the native clipboard for subsequent operations.
|
||||||
|
if (clipboard.wasInvoked()) {
|
||||||
|
e.originalEvent.clipboardData.setData("text/plain", clipboard.getData("text/plain"));
|
||||||
|
e.originalEvent.clipboardData.setData("text/json", clipboard.getData("text/json"));
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
else {
|
||||||
var focusedElement = $scope.element.focusedElement;
|
var focusedElement = $scope.element.focusedElement;
|
||||||
if (!!focusedElement) {
|
if (!!focusedElement) {
|
||||||
$scope.$apply(function () {
|
$scope.$apply(function () {
|
||||||
@@ -142,6 +150,10 @@
|
|||||||
|
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Native clipboard support obviously exists, so disable the peudo clipboard from now on.
|
||||||
|
clipboard.disable();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -3,17 +3,29 @@
|
|||||||
|
|
||||||
var Clipboard = function () {
|
var Clipboard = function () {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.clipboardData = {};
|
this._clipboardData = {};
|
||||||
this.setData = function(contentType, data, realClipBoard) {
|
this._isDisabled = false;
|
||||||
self.clipboardData[contentType] = data;
|
this._wasInvoked = false;
|
||||||
};
|
|
||||||
this.getData = function (contentType, realClipBoard) {
|
|
||||||
return self.clipboardData[contentType];
|
|
||||||
};
|
|
||||||
|
|
||||||
this.disable = function() {
|
this.setData = function(contentType, data) {
|
||||||
this.disabled = true;
|
self._clipboardData[contentType] = data;
|
||||||
|
self._wasInvoked = true;
|
||||||
};
|
};
|
||||||
|
this.getData = function (contentType) {
|
||||||
|
return self._clipboardData[contentType];
|
||||||
|
self._wasInvoked = true;
|
||||||
|
};
|
||||||
|
this.disable = function() {
|
||||||
|
self._isDisabled = true;
|
||||||
|
self._wasInvoked = false;
|
||||||
|
self._clipboardData = {};
|
||||||
|
};
|
||||||
|
this.isDisabled = function () {
|
||||||
|
return self._isDisabled;
|
||||||
|
}
|
||||||
|
this.wasInvoked = function () {
|
||||||
|
return self._wasInvoked;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
LayoutEditor.Clipboard = new Clipboard();
|
LayoutEditor.Clipboard = new Clipboard();
|
||||||
@@ -25,7 +37,9 @@
|
|||||||
return {
|
return {
|
||||||
setData: LayoutEditor.Clipboard.setData,
|
setData: LayoutEditor.Clipboard.setData,
|
||||||
getData: LayoutEditor.Clipboard.getData,
|
getData: LayoutEditor.Clipboard.getData,
|
||||||
disable: LayoutEditor.Clipboard.disable
|
disable: LayoutEditor.Clipboard.disable,
|
||||||
|
isDisabled: LayoutEditor.Clipboard.isDisabled,
|
||||||
|
wasInvoked: LayoutEditor.Clipboard.wasInvoked
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -15,12 +15,11 @@
|
|||||||
var resetFocus = false;
|
var resetFocus = false;
|
||||||
var element = $scope.element;
|
var element = $scope.element;
|
||||||
|
|
||||||
|
|
||||||
if (element.editor.isDragging || element.editor.inlineEditingIsActive)
|
if (element.editor.isDragging || element.editor.inlineEditingIsActive)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// If the "real" clipboard works, then the pseudo-clipboard will have been disabled.
|
// If native clipboard support exists, the pseudo-clipboard will have been disabled.
|
||||||
if (!clipboard.disabled) {
|
if (!clipboard.isDisabled()) {
|
||||||
var focusedElement = element.editor.focusedElement;
|
var focusedElement = element.editor.focusedElement;
|
||||||
if (!!focusedElement) {
|
if (!!focusedElement) {
|
||||||
// Pseudo clipboard handling for browsers not allowing real clipboard operations.
|
// Pseudo clipboard handling for browsers not allowing real clipboard operations.
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -167,7 +167,6 @@
|
|||||||
this.copy = function (clipboardData) {
|
this.copy = function (clipboardData) {
|
||||||
var text = this.getInnerText();
|
var text = this.getInnerText();
|
||||||
clipboardData.setData("text/plain", text);
|
clipboardData.setData("text/plain", text);
|
||||||
console.log(text);
|
|
||||||
|
|
||||||
var data = this.toObject();
|
var data = this.toObject();
|
||||||
var json = JSON.stringify(data, null, "\t");
|
var json = JSON.stringify(data, null, "\t");
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -1,7 +1,8 @@
|
|||||||
@import "Variables.less";
|
@import "Variables.less";
|
||||||
|
@import "Reset.less";
|
||||||
|
|
||||||
.layout-editor {
|
.layout-editor {
|
||||||
.layout-content {
|
.layout-content, .layout-html {
|
||||||
min-height: 1em;
|
min-height: 1em;
|
||||||
|
|
||||||
> .layout-element-wrapper {
|
> .layout-element-wrapper {
|
||||||
@@ -12,7 +13,7 @@
|
|||||||
line-height: normal;
|
line-height: normal;
|
||||||
|
|
||||||
// Reset to HTML5 W3C standard default styling within content.
|
// Reset to HTML5 W3C standard default styling within content.
|
||||||
@import "Reset.less";
|
.reset();
|
||||||
|
|
||||||
> *:first-child {
|
> *:first-child {
|
||||||
margin-top: 0 !important; // Important because site.css of the admin theme styles heading margins with a very high specificity.
|
margin-top: 0 !important; // Important because site.css of the admin theme styles heading margins with a very high specificity.
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
* {
|
.reset() {
|
||||||
|
|
||||||
|
* {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
box-sizing: content-box;
|
box-sizing: content-box;
|
||||||
@@ -229,12 +231,10 @@ dir, dl, ol, ul {
|
|||||||
dd {
|
dd {
|
||||||
margin-left: 40px;
|
margin-left: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LTR-specific: use 'margin-right' for rtl elements */
|
/* LTR-specific: use 'margin-right' for rtl elements */
|
||||||
dir, ol, ul {
|
dir, ol, ul {
|
||||||
padding-left: 40px;
|
padding-left: 40px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* LTR-specific: use 'padding-right' for rtl elements */
|
/* LTR-specific: use 'padding-right' for rtl elements */
|
||||||
ol {
|
ol {
|
||||||
list-style-type: decimal;
|
list-style-type: decimal;
|
||||||
@@ -333,7 +333,6 @@ table, td, th {
|
|||||||
thead, tbody, tfoot, tr {
|
thead, tbody, tfoot, tr {
|
||||||
border-color: inherit;
|
border-color: inherit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*table[rules=none i], table[rules=groups i], table[rules=rows i],
|
/*table[rules=none i], table[rules=groups i], table[rules=rows i],
|
||||||
table[rules=cols i], table[rules=all i], table[frame=void i],
|
table[rules=cols i], table[rules=all i], table[frame=void i],
|
||||||
table[frame=above i], table[frame=below i], table[frame=hsides i],
|
table[frame=above i], table[frame=below i], table[frame=hsides i],
|
||||||
@@ -361,7 +360,6 @@ table[rules=cols i] > tfoot > tr > td, table[rules=cols i] > tfoot > tr > th,
|
|||||||
table[rules=all i] > tfoot > tr > td, table[rules=all i] > tfoot > tr > th {
|
table[rules=all i] > tfoot > tr > td, table[rules=all i] > tfoot > tr > th {
|
||||||
border-color: black;
|
border-color: black;
|
||||||
}*/
|
}*/
|
||||||
|
|
||||||
input, select, option, optgroup, button, textarea, keygen {
|
input, select, option, optgroup, button, textarea, keygen {
|
||||||
text-indent: initial;
|
text-indent: initial;
|
||||||
}
|
}
|
||||||
@@ -397,3 +395,4 @@ legend {
|
|||||||
padding-left: 2px;
|
padding-left: 2px;
|
||||||
padding-right: 2px;
|
padding-right: 2px;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
&.sticky-top {
|
&.sticky-top {
|
||||||
position: fixed;
|
position: fixed;
|
||||||
top: 0;
|
top: 0;
|
||||||
|
max-height: 100%;
|
||||||
|
overflow-y: auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
&.sticky-bottom {
|
&.sticky-bottom {
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,6 @@
|
|||||||
|
namespace Orchard.Layouts.ViewModels {
|
||||||
|
public class HeadingEditorViewModel {
|
||||||
|
public string Text { get; set; }
|
||||||
|
public int Level { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
@model Orchard.Layouts.ViewModels.HeadingEditorViewModel
|
||||||
|
@{
|
||||||
|
Script.Include("AutoFocus.js");
|
||||||
|
}
|
||||||
|
<fieldset>
|
||||||
|
<legend>@T("Level")</legend>
|
||||||
|
<ul>
|
||||||
|
@for (var i = 1; i <= 6; i++) {
|
||||||
|
<li>
|
||||||
|
@Html.RadioButtonFor(m => m.Level, i, new {id = "h" + i})
|
||||||
|
<label for="@("h" + i)" class="forcheckbox">@T("<h{0}/>", i)</label>
|
||||||
|
</li>
|
||||||
|
}
|
||||||
|
</ul>
|
||||||
|
</fieldset>
|
||||||
|
<fieldset class="autofocus">
|
||||||
|
@Html.LabelFor(m => m.Text, T("Text"))
|
||||||
|
@Html.TextBoxFor(m => m.Text, new { @class = "text large tokenized", autofocus = "autofocus" })
|
||||||
|
@Html.Hint(T("Note: HTML markup will be rendered unencoded."))
|
||||||
|
</fieldset>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
@using Orchard.Layouts.Helpers
|
||||||
|
@{
|
||||||
|
var tagBuilder = TagBuilderExtensions.CreateElementTagBuilder(Model, "h" + (Model.Level >= 1 && Model.Level <= 6 ? Model.Level : 1));
|
||||||
|
tagBuilder.InnerHtml = Model.ProcessedText;
|
||||||
|
}
|
||||||
|
@tagBuilder.ToHtmlString()
|
||||||
@@ -1 +1 @@
|
|||||||
@Html.Raw((string)Model.Element.Content)
|
<p>@Html.Raw((string)Model.Element.Content)</p>
|
||||||
@@ -1,6 +1 @@
|
|||||||
@using Orchard.Layouts.Helpers
|
<p>@Html.Raw((string)Model.Element.Content)</p>
|
||||||
@{
|
|
||||||
var tagBuilder = TagBuilderExtensions.CreateElementTagBuilder(Model, "p");
|
|
||||||
tagBuilder.InnerHtml = Model.ProcessedText;
|
|
||||||
}
|
|
||||||
@tagBuilder.ToHtmlString()
|
|
||||||
Reference in New Issue
Block a user