繁体   English   中英

Umbraco 7-自定义宏参数编辑器-RTE

[英]Umbraco 7 - Custom Macro Parameter Editor - RTE

我希望这也能对其他人有所帮助,因为确切的文档很多。

我想在我创建的宏中使用RTE(富文本编辑器)来处理页面部分。

我已经在宏中成功渲染了RTE。 我可以从宏参数面板中选择我的macroRte。 它甚至在我编辑页面部分的值的地方进行渲染。 我已将“ macroRte”的别名归因于该参数。

但是,它不存储值。 每次我按提交,它都会擦除内容。

我不是Angular专家,但我认为这就是问题所在。 下面的代码。 谢谢。

视图

<div ng-controller="CustomSectionEditController" class="umb-editor umb-rte">
<umb-editor model="macroRte">
    <div ng-model="model.value">{{model.value}}</div>
</umb-editor>  

调节器

angular.module("umbraco").controller("CustomSectionEditController", function ($scope) {
$scope.macroRte = {
    label: 'bodyText',
    description: 'Load some stuff here',
    view: 'rte',
    config: {
        editor: {
            toolbar: ["code", "undo", "redo", "cut", "styleselect", "bold", "italic", "alignleft", "aligncenter", "alignright", "bullist", "numlist", "link", "umbmediapicker", "table", "umbembeddialog"],
            stylesheets: ["rte"],
            dimensions: { height: 400 },
            valueType:"STRING"
        }
    }
};
});

给予

@inherits Umbraco.Web.Macros.PartialViewMacroPage  
<div class="lh-text">
    @Model.MacroParameters["macroRte"];
</div>

有任何想法吗? :)

使用这个, https://github.com/engern/Umbraco-custom-macro-parameters/tree/master/App_Plugins/MacroRichText-我能够解决我的问题。

该视图需要更改为以下内容

<div ng-controller="CustomSectionEditController">
    <ng-form>
        <umb-editor model="macroRte"></umb-editor>
    </ng-form>
</div>

控制器需要以下代码(在视图下添加)

value: $scope.model.value,

和附加的范围控制

$scope.$watch("macroRte.value", function (newValue, oldValue) {
    $scope.model.value = newValue;
});

控制器现在看起来像这样

angular.module("umbraco").controller("CustomSectionEditController", function ($scope) {
$scope.macroRte = {
    label: 'bodyText',
    description: 'Load some stuff here',
    view: 'rte',
    value: $scope.model.value,
    config: {
        editor: {
            toolbar: ["code", "undo", "redo", "cut", "styleselect", "bold", "italic", "alignleft", "aligncenter", "alignright", "bullist", "numlist", "link", "umbmediapicker", "table", "umbembeddialog"],
            stylesheets: ["rte"],
            dimensions: { height: 400 },
            valueType:"STRING"
        }
    }
},
$scope.$watch("macroRte.value", function (newValue, oldValue) {
    $scope.model.value = newValue;
});
});

希望这对其他人有帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM