Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bo Jacobsen 610 posts 2409 karma points
    Jun 20, 2018 @ 07:41
    Bo Jacobsen
    0

    Use grid-rte in umb-overlay with working link selector.

    Hi All.

    Umbraco version 7.7.9

    I am using grid-rte inside an umb-overlay. But the link picker do not work. Do anyone know what to do or a workaround?

    editor.html - Just to show i am using umb-overlay

    <umb-overlay
        ng-if="overlay.show"
        model="overlay"
        view="overlay.view"
        position="right">
    </umb-overlay>
    

    overlay.html - I have set a background color on, based on a selectable color, in case you wonder :)

    <div ng-style="{'background-color': options.text.backgroundColor }">
        <div unique-id="$id"
             value="dialogModel.text"
             grid-rte configuration="rteconfig">
        </div>
    </div>
    

    overlay.js - The configuration i use for the grid-rte

    $scope.rteconfig =
            {
                "toolbar": ["code", "removeformat", "styleselect", "bold", "italic", "underline", "forecolor", "alignleft", "aligncenter", "alignright", "bullist", "numlist", "link", "unlink"],
                "stylesheets": ["RTE_Base"],
                "dimensions":
                {
                    "height": 350
                }
            };
    

    Nothing happens when i click the link icon. enter image description here

  • Malte 7 posts 107 karma points
    Aug 13, 2018 @ 09:13
    Malte
    0

    Hello, you could have a look at this workaround. https://our.umbraco.com/forum/umbraco-7/using-umbraco-7/50241-Im-not-able-to-insert-a-new-link-with-the-RTE-editor-in-umbraco-711#comment-286668

    But as soon as you are updating your Umbraco you have to redo the change.

  • Bo Jacobsen 610 posts 2409 karma points
    Nov 27, 2018 @ 11:25
    Bo Jacobsen
    0

    Hi Malte.

    Yes, this seems to fix it. But as far as i know, it is a bad practice to use $scope.$digest(); because you dont know if a $digest already is in progress.

    https://stackoverflow.com/questions/12729122/angularjs-prevent-error-digest-already-in-progress-when-calling-scope-apply

    But the big problem here is that we use it on Umbraco Cloud, so we need a permenent fix. But thanks for posting.

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Nov 27, 2018 @ 11:48
  • Bo Jacobsen 610 posts 2409 karma points
    Nov 27, 2018 @ 14:04
    Bo Jacobsen
    0

    Hi Dave.

    It seems to work :)

    I will try play around with it and post my results here.

    Btw. Both your link was the same, but i guess you where thinking of https://github.com/dawoe/umbraco-tour-editor/blob/develop/Source/Our.Umbraco.TourEditor/Web/App_Plugins/TourEditor/scripts/controllers/step-details-controller.js

  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Nov 27, 2018 @ 14:13
    Dave Woestenborghs
    0

    Yep you are correct. I pasted the same link twice by accident. Glad to hear you got it working.

    Dave

  • Bo Jacobsen 610 posts 2409 karma points
    Nov 28, 2018 @ 08:07
    Bo Jacobsen
    1

    Thanks to Dave I got it working in the umb-overlay.

    Overlay View

    <umb-property property="property.rte">
        <umb-property-editor model="rte" />
    </umb-property>
    

    Overlay Controller

    // Normal there would be more properties. (This is simplyfied)
    $scope.property = {
        rte: {}
    }
    
    // Get all label and descriptions.
    localizationService.localizeMany(["general_label", "general_description"]).then(function (data) {
        $scope.property.rte.label = data[0];
        $scope.property.rte.description = data[1];
    });
    
    // rte config.
    $scope.rte = {
        view: 'rte',
        config: {
            editor: {
                toolbar: [
                    "code",
                    "removeformat",
                    "styleselect",
                    "bold",
                    "italic",
                    "underline",
                    "forecolor",
                    "alignleft",
                    "aligncenter",
                    "alignright",
                    "bullist",
                    "numlist",
                    "link",
                    "unlink"
                ],
                stylesheets: ["custom_rte"],
                dimensions: {
                    height: 250,
                    width: "100%"
                }
            }
        },
        value: $scope.model.dialogModel.text
    };
    
    // I had to add this in order to save the text entered.
    $scope.$watch('rte.value', function (newVal, oldVal) {
        $scope.model.dialogModel.text = newVal;
    });
    
  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Nov 28, 2018 @ 09:09
    Dave Woestenborghs
    0

    hi bo,

    Nice to see you got it working.

    Dave

  • Paul de Quant 403 posts 1521 karma points
    Feb 27, 2019 @ 10:28
    Paul de Quant
    0

    Hi bo,

    I'm trying to do something similar in that I have a grid control, which opens an overlay but I need to add an RTE editor to it. Doesn't seem to load at all for me. Is there a fuller code example you can post, so I can see where I'm going wrong.

    Thanks

  • Bo Jacobsen 610 posts 2409 karma points
    Feb 27, 2019 @ 18:44
    Bo Jacobsen
    1

    Hi Paul.

    Here is a full exsample:

    Grid Controller:

    (function () {
        "use strict";
    
        function gridController($scope) {
    
            $scope.control.value = $scope.control.value || {};
    
            $scope.openOverlay = function () {
                $scope.overlay = {
                    view: "/App_Plugins/MyOwnPlugin/PathTo/overlayView.html",
                    show: true,
                    title: "general_edit",
                    submitButtonLabelKey: "general_approve",
                    closeButtonLabelKey: "general_closewindow",
                    submit: function (model) {
                        $scope.control.value = model.dialogModel;
                        closeOverlay();
                    },
                    close: function (oldModel) {
                        $scope.control.value = oldModel.dialogModel;
                        closeOverlay();
                    },
                    dialogModel: $scope.control.value
                };
            };
    
            if ($scope.control.$initializing) {
                $scope.openOverlay();
            }
    
            function closeOverlay() {
                $scope.overlay.show = false;
                $scope.overlay = null;
            }
        }
    
        angular.module("umbraco").controller("My.Own.GridController", gridController);
    })(); 
    

    Grid View:

    <div ng-controller="My.Own.GridController">
        <umb-overlay ng-if="overlay.show"
                     model="overlay"
                     view="overlay.view"
                     position="right">
        </umb-overlay>
    </div>
    

    Overlay Controller:

    (function () {
        "use strict";
    
        function overlayController($scope, localizationService) {
    
            // Normal there would be more properties. (This is simplyfied)
            $scope.property = {
                rte: {}
            }
    
            // Get all label and descriptions.
            localizationService.localizeMany(["general_label", "general_description"]).then(function (data) {
                $scope.property.rte.label = data[0];
                $scope.property.rte.description = data[1];
            });
    
            // rte config.
            $scope.rte = {
                view: 'rte',
                config: {
                    editor: {
                        toolbar: [
                            "code",
                            "removeformat",
                            "styleselect",
                            "bold",
                            "italic",
                            "underline",
                            "forecolor",
                            "alignleft",
                            "aligncenter",
                            "alignright",
                            "bullist",
                            "numlist",
                            "link",
                            "unlink"
                        ],
                        stylesheets: ["custom_rte"],
                        dimensions: {
                            height: 250,
                            width: "100%"
                        }
                    }
                },
                value: $scope.model.dialogModel.text
            };
    
            // I had to add this in order to save the text entered.
            $scope.$watch('rte.value', function (newVal, oldVal) {
                $scope.model.dialogModel.text = newVal;
            });
        }
    
        angular.module("umbraco").controller("My.Own.OverlayController", overlayController);
    })();
    

    Overlay View:

    <umb-panel ng-controller="My.Own.OverlayController">
        <umb-pane>
            <umb-property property="property.rte">
                <umb-property-editor model="rte" />
            </umb-property>
        </umb-pane>
    </umb-panel>
    

    Razor View:

    @using Umbraco.Web.Templates
    @using Umbraco.Web
    @inherits Umbraco.Web.Mvc.UmbracoViewPage<dynamic>
    
    @if (Model.value != null && !string.IsNullOrEmpty(Model.value.text.ToString()))
    {
        var textWithLinks = TemplateUtilities.ParseInternalLinks(Model.value.text.ToString(), UmbracoContext.Current.UrlProvider);  
        @Html.Raw(textWithLinks)
    }
    

    Package Manifest:

    {
      "gridEditors": [
        {
          "name": "My own Rte Editor",
          "alias": "My.Own.RteEditor",
          "view": "~/App_Plugins/MyOwnPlugin/PathTo/GridView.html",
          "render": "~/App_Plugins/MyOwnPlugin/PathTo/RazorView.cshtml",
          "icon": "icon-browser-window"
        }
      ],
      "javascript": [
        "~/App_Plugins/MyOwnPlugin/PathTo/GridController.js",
        "~/App_Plugins/MyOwnPlugin/PathTo/OverlayController.js"
      ],
      "css": [ "~/App_Plugins/MyOwnPlugin/PathTo/stylesheet.css" ]
    }
    
  • Paul de Quant 403 posts 1521 karma points
    Feb 28, 2019 @ 09:33
    Paul de Quant
    0

    Hi Bo,

    This is amazing and works a treat. You saved the day.

    Cheers

    Paul

  • Jonathan Roberts 409 posts 1063 karma points
    Jun 03, 2019 @ 11:22
    Jonathan Roberts
    0

    Hi,

    How do you set the content - so when the user comes back to edit the panel? Currently the content of the RTE is empty and I wondered how I can set the content of the RTE.

    Thanks,

    Jon

  • Bo Jacobsen 610 posts 2409 karma points
    Jun 13, 2019 @ 12:35
    Bo Jacobsen
    0

    Hi Jonathan.

    This part is where you get the entered value from the RTE.

    $scope.$watch('rte.value', function (newVal, oldVal) {
        $scope.model.dialogModel.text = newVal;
    });
    

    This is the part where you save the value from the overlay

    submit: function (model) {
       $scope.control.value = model.dialogModel;
       ...
    },
    
  • James 1 post 21 karma points
    Nov 07, 2022 @ 12:34
    James
    0

    Hello Bo, I did following your code example but link tool can’t be used. It can open linkpicker overlay but when I inserted link and submitted, it’s throwing me an error: Cannot read properties of null ( reading ‘getContent’ ) Do you know how to fix this?

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies