Copied to clipboard

Flag this post as spam?

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


  • Angelo 111 posts 260 karma points
    May 05, 2023 @ 11:42
    Angelo
    0

    macroPicker

    Hello

    im triyng to develop a new package for may upwest bundle products and i want to add a macro to my richtext builder but when i open the macroPicker nothing appears and it gives an error

    "Cannot read properties of undefined (reading 'allowedMacros')"

    i am using this code to open macroPicker

        function openMacroPicker(e) {
    
            var macroPickerOptions = {        
                submit: function (model) {
    
                    //do something
    
                },
                close: function () {
                     editorService.close();
                }
            };
    
        editorService.macroPicker(macroPickerOptions);
    
        };
    

    probably is some missig parameter but i could not find any documentation about theis macroPicker ... so im stucked here :(

    any help would be welcome ! ... thank you

    no macro appears

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    May 06, 2023 @ 12:33
    Marc Goodson
    1

    HI Angelo

    It looks like the Macro picker needs the configuration to exist for which macros are allowed to be inserted (not all macros have the checkboxes enabled to allow them to be inserted into Rich Text Editors).

    Looking at the source, it seems to read it here in the macropicker.controller.js

    https://github.com/umbraco/Umbraco-CMS/blob/f3668e0aabee6c4ff7c3ed0dea55fd2421a79fc4/src/Umbraco.Web.UI.Client/src/views/common/infiniteeditors/macropicker/macropicker.controller.js#L137

    It looks like there needs to be a string array of 'macro alias' or an empty string array present on the dialogData model when the Macro Picker dialog is opened:

      if (Utilities.isArray($scope.model.dialogData.allowedMacros) && $scope.model.dialogData.allowedMacros.length > 0) {
    

    so think you would need to add a dialogData property to your macroPickerOptions model, with an allowedMacros property being an empty array of alias or a list of alias you want to allow...

    regards

    Marc

  • Angelo 111 posts 260 karma points
    May 07, 2023 @ 18:50
    Angelo
    100

    Hello Marc ...yes thats it ... :D

         var macroPickerOptions = {        
                dialogData:  {
                    allowedMacros: [],  < -------------------------  LIKE THIS IF YOU WANT TO SHOW ALL ALLOWED MACROS 
                },
                submit: function (model) {
    
    
                },
                close: function () {
                        editorService.close();
                }
            };
    

    and it worked ... thank you a lot Marc unfortunately there is no documentation about this macro Picker :( ... but you helped a lot :)

    all the best

    Angelo

Please Sign in or register to post replies

Write your reply to:

Draft