Copied to clipboard

Flag this post as spam?

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


  • Qaisar 31 posts 77 karma points
    Jun 21, 2019 @ 14:48
    Qaisar
    0

    Approved Color property editor in a Macro umbraco V8

    I want to use approved colors color picker as a macro paramter. I have created a package.manifest file as on

    https://our.umbraco.com/forum/templates-partial-views-and-macros/89150-approved-color-property-editor-in-a-macro

    the code for macrocolorpicker manifest file is

    {
    

    "propertyEditors": [ { "alias": "MacroColorPicker", "name": "Macro Color Picker", "isParameterEditor": true, "editor": { "view": "~/App_Plugins/MacroColorPicker/colorpicker.html" }, "defaultConfig": { "useLabel": true, "items": [ { "id": 1, "value": { "value": "000000", "label": "000000" } }, { "id": 2, "value": { "value": "ffffff", "label": "ffffff" } }, { "id": 6, "value": { "value": "f0f0f0", "label": "f0f0f0" } }, { "id": 4, "value": { "value": "2e8fff", "label": "2e8fff" } }, { "id": 5, "value": { "value": "370037", "label": "370037" } } ] }

    }
    

    ] }

    The Picker is getting created and I am able to set as a macroparameter but when i use the macro in RTE it doesn't show any colours to pick from, instead it only says "You have not configured any approved colours"

    Does anyone knows how it works with Umbraco V8 or it could be great if some one can share some example or code.

    Thanks Qaisar

  • Alexander Gräf 25 posts 131 karma points
    Feb 21, 2021 @ 23:47
    Alexander Gräf
    0

    Use this code:

    {
        "propertyEditors": [
            {
                alias: "ColorPicker",
                name: "Macro Color Picker",
                isParameterEditor: true,
                editor: {
                    view: "~/Umbraco/Views/propertyeditors/colorpicker/colorpicker.html"
                },
                "prevalues": {
                },
                "defaultConfig":{
                    "useLabel": false,
                    "items": [
                            {"id":1,"value":"ffffff","label":"ffffff"},
                            {"id":2,"value":"d9d9d9","label":"d9d9d9"},
                            {"id":3,"value":"919797","label":"919797"},
                            {"id":4,"value":"96b222","label":"96b222"},
                            {"id":5,"value":"f18700","label":"f18700"}
                    ]
                }
            }
        ]
    }
    

    The empty prevalues list is important, as Umbraco will otherwise just ignore the defaultConfig. Yes, it sucks, and there is zero documentation.

Please Sign in or register to post replies

Write your reply to:

Draft