2017-03-21 17 views
1

나는 이것에 대해 많은 문서가 없기 때문에 다른 사람들에게도 도움이되기를 바랍니다.Umbraco 7 - 사용자 정의 매크로 매개 변수 편집기 - RTE

페이지 섹션을 처리하기 위해 만든 매크로 내에서 RTE (리치 텍스트 편집기)를 사용하고 싶습니다.

매크로 내에서 RTE를 성공적으로 렌더링했습니다. 매크로 매개 변수 패널에서 내 macroRte를 선택할 수 있습니다. 내 페이지 섹션의 값을 편집하는 곳을 렌더링합니다. "macroRte"의 별칭을 매개 변수에 지정했습니다.

그러나 값을 저장하지 않습니다. 제출을 누를 때마다 콘텐츠가 삭제됩니다.

나는 각도 전문가가 아니지만 그게 문제라고 생각합니다. 아래 코드. 고맙습니다.

보기

<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> 

아이디어가 있으십니까? :)

답변

2

이것을 사용하면 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; 
}); 
}); 

다른 사람들에게 도움이되기를 바랍니다.