Removed unnecessary Html model map.

The Html model mapping was originally needed to support inline editing of Html elements, but that capability has been removed.
This commit is contained in:
Sipke Schoorstra
2015-12-20 16:28:36 +01:00
parent c216480ca0
commit 9715ee88df
5 changed files with 0 additions and 155 deletions

View File

@@ -1,41 +0,0 @@
angular
.module("LayoutEditor")
.directive("orcLayoutHtml", ["$sce", "scopeConfigurator", "environment",
function ($sce, scopeConfigurator, environment) {
return {
restrict: "E",
scope: { element: "=" },
controller: ["$scope", "$element",
function ($scope, $element) {
scopeConfigurator.configureForElement($scope, $element);
$scope.edit = function () {
$scope.$root.editElement($scope.element).then(function (args) {
$scope.$apply(function () {
if (args.cancel)
return;
$scope.element.data = args.element.data;
$scope.element.setHtml(args.element.html);
});
});
};
$scope.updateContent = function (e) {
$scope.element.setHtml(e.target.innerHTML);
};
// Overwrite the setHtml function so that we can use the $sce service to trust the html (and not have the html binding strip certain tags).
$scope.element.setHtml = function (html) {
$scope.element.html = html;
$scope.element.htmlUnsafe = $sce.trustAsHtml(html);
};
$scope.element.setHtml($scope.element.html);
}
],
templateUrl: environment.templateUrl("Html"),
replace: true,
link: function (scope, element) {
}
};
}
]);

View File

@@ -1,70 +0,0 @@
var LayoutEditor;
(function ($, LayoutEditor) {
LayoutEditor.Html = function (data, htmlId, htmlClass, htmlStyle, isTemplated, contentType, contentTypeLabel, contentTypeClass, html, hasEditor, rule) {
LayoutEditor.Element.call(this, "Html", data, htmlId, htmlClass, htmlStyle, isTemplated, rule);
this.contentType = contentType;
this.contentTypeLabel = contentTypeLabel;
this.contentTypeClass = contentTypeClass;
this.html = html;
this.hasEditor = hasEditor;
this.isContainable = true;
this.getInnerText = function () {
return $($.parseHTML("<div>" + this.html + "</div>")).text();
};
// This function will be overwritten by the Content directive.
this.setHtml = function (html) {
this.html = html;
this.htmlUnsafe = html;
}
this.toObject = function () {
return {
"type": "Html"
};
};
this.toObject = function () {
var result = this.elementToObject();
result.contentType = this.contentType;
result.contentTypeLabel = this.contentTypeLabel;
result.contentTypeClass = this.contentTypeClass;
result.html = this.html;
result.hasEditor = hasEditor;
return result;
};
var getEditorObject = this.getEditorObject;
this.getEditorObject = function () {
var dto = getEditorObject();
return $.extend(dto, {
Content: this.html
});
}
this.setHtml(html);
};
LayoutEditor.Html.from = function (value) {
var result = new LayoutEditor.Html(
value.data,
value.htmlId,
value.htmlClass,
value.htmlStyle,
value.isTemplated,
value.contentType,
value.contentTypeLabel,
value.contentTypeClass,
value.html,
value.hasEditor,
value.rule);
return result;
};
LayoutEditor.registerFactory("Html", function(value) { return LayoutEditor.Html.from(value); });
})(jQuery, LayoutEditor || (LayoutEditor = {}));

View File

@@ -94,7 +94,6 @@
<Content Include="Scripts\frame.js" /> <Content Include="Scripts\frame.js" />
<Content Include="Scripts\jquery.browser.js" /> <Content Include="Scripts\jquery.browser.js" />
<Content Include="Scripts\jquery.deserialize.js" /> <Content Include="Scripts\jquery.deserialize.js" />
<Content Include="Assets\JavaScript\LayoutEditor\Directives\Html.js" />
<Content Include="Assets\JavaScript\LayoutEditor\Directives\Editor.js" /> <Content Include="Assets\JavaScript\LayoutEditor\Directives\Editor.js" />
<Content Include="Assets\JavaScript\LayoutEditor\Directives\Canvas.js" /> <Content Include="Assets\JavaScript\LayoutEditor\Directives\Canvas.js" />
<Content Include="Assets\JavaScript\LayoutEditor\Directives\Child.js" /> <Content Include="Assets\JavaScript\LayoutEditor\Directives\Child.js" />
@@ -114,7 +113,6 @@
<Content Include="Assets\JavaScript\Models\Container.js" /> <Content Include="Assets\JavaScript\Models\Container.js" />
<Content Include="Assets\JavaScript\Models\Content.js" /> <Content Include="Assets\JavaScript\Models\Content.js" />
<Content Include="Assets\JavaScript\Models\Element.js" /> <Content Include="Assets\JavaScript\Models\Element.js" />
<Content Include="Assets\JavaScript\Models\Html.js" />
<Content Include="Assets\JavaScript\Models\Grid.js" /> <Content Include="Assets\JavaScript\Models\Grid.js" />
<Content Include="Assets\JavaScript\Models\Helpers.js" /> <Content Include="Assets\JavaScript\Models\Helpers.js" />
<Content Include="Assets\JavaScript\Models\Row.js" /> <Content Include="Assets\JavaScript\Models\Row.js" />
@@ -512,9 +510,6 @@
<ItemGroup> <ItemGroup>
<Content Include="Views\Elements\Shape.Design.cshtml" /> <Content Include="Views\Elements\Shape.Design.cshtml" />
</ItemGroup> </ItemGroup>
<ItemGroup>
<Content Include="Views\LayoutEditor.Template.Html.cshtml" />
</ItemGroup>
<ItemGroup> <ItemGroup>
<Content Include="Views\Elements\Projection.Design.cshtml" /> <Content Include="Views\Elements\Projection.Design.cshtml" />
</ItemGroup> </ItemGroup>

View File

@@ -134,34 +134,6 @@ namespace Orchard.Layouts.Services {
} }
} }
public class HtmlModelMap : ContentModelMap {
public HtmlModelMap(IShapeDisplay shapeDisplay, IElementDisplay elementDisplay)
: base(shapeDisplay, elementDisplay) {
}
public override int Priority {
get { return 1; }
}
public override string LayoutElementType {
get { return "Html"; }
}
public override bool CanMap(Element element) {
return element is Html;
}
public override Element ToElement(IElementManager elementManager, DescribeElementsContext describeContext, JToken node) {
var html = (string)node["html"];
var element = (Html)base.ToElement(elementManager, describeContext, node);
// To support inline editing, we need to update the element's content.
element.Content = html;
return element;
}
}
public class RecycleBinModelMap : ILayoutModelMap { public class RecycleBinModelMap : ILayoutModelMap {
public int Priority { get { return 0; } } public int Priority { get { return 0; } }
public string LayoutElementType { get { return "RecycleBin"; } } public string LayoutElementType { get { return "RecycleBin"; } }

View File

@@ -1,11 +0,0 @@
<div class="layout-element-wrapper">
<ul class="layout-panel layout-panel-main">
<li class="layout-panel-item layout-panel-label">{{::element.contentTypeLabel}}</li>
<li class="layout-panel-item layout-panel-action layout-panel-action-edit" ng-show="{{element.hasEditor}}" title="Edit {{element.contentTypeLabel.toLowerCase()}} content (Enter)" ng-click="edit()"><i class="fa fa-code"></i></li>
@Display(New.LayoutEditor_Template_Properties(ElementTypeName: "{{element.contentTypeLabel.toLowerCase()}}"))
<li class="layout-panel-item layout-panel-action" title="@T("Delete {{element.contentTypeLabel.toLowerCase()}} (Del)")" ng-click="delete(element)" ng-class="{disabled: !element.canDelete()}"><i class="fa fa-remove"></i></li>
<li class="layout-panel-item layout-panel-action" title="@T("Move {{element.contentTypeLabel.toLowerCase()}} up (Ctrl+Up)")" ng-click="element.moveUp()" ng-class="{disabled: !element.canMoveUp()}"><i class="fa fa-chevron-up"></i></li>
<li class="layout-panel-item layout-panel-action" title="@T("Move {{element.contentTypeLabel.toLowerCase()}} down (Ctrl+Down)")" ng-click="element.moveDown()" ng-class="{disabled: !element.canMoveDown()}"><i class="fa fa-chevron-down"></i></li>
</ul>
<div id="layout-content-markup-{{::$id}}" class="layout-content-markup" ng-bind-html="element.htmlUnsafe" ng-blur="updateContent($event)" data-templated="{{element.isTemplated}}"></div>
</div>