Skip to content

Macro not working in content block with rich text editor #31

Closed

Description

@patrickdemooij9

I noticed that macro's aren't working like they should. It renders the exact same content as the one in the richtext editor instead of it creating the content when it's rendering it.

This is how normal tinymce content is saved in the database:
<?UMBRACO_MACRO macroAlias=\"VideoImageWithCaption\" image=\"umb://media/ea0e3fe8608d46638dc1ff274aee5d51\" videoUrl=\"\" caption=\"\" />\n<p>Teeshfjkhdkjh aldjfk ajsd</p>\n<p>f ajksdfk ashdfjkhaskldjflsadf</p>

And this is how the content is saved in the content blocks:
<p>Testdf asdf asdfasdfasdf adfasdfasdfasdfasdf </p>\n<div class=\"umb-macro-holder Button umb-macro-mce_1 mceNonEditable\"><!-- <?UMBRACO_MACRO macroAlias=\"Button\" text=\"Contact specialist\" link=\"umb://document/f000a85417174839b304b0c98254f629\" /> --><ins><a href=\"/\" class=\"button is-brand\"> <span>Contact specialist</span> <span class=\"icon \"> <span class=\"material-icons\">arrow_forward</span> </span> </a></ins></div>

The <?UMBRACO_MACRO> element is hidden in the comment for the content blocks, so it doesn't get rendered correctly.

Activity

  1. PerplexDaniel commented on Aug 7, 2020

    @PerplexDaniel
    Member

    Can you check how macros are saved in Nested Content (i.e. just add your Content Block dataType to the Homepage or so)? That should be the same as in ContentBlocks. If it does work in NestedContent then I can have a look. If it doesn't work in NestedContent then there is not much we can do either.

  2. patrickdemooij9 commented on Aug 7, 2020

    @patrickdemooij9
    ContributorAuthor

    Hey @PerplexDaniel,
    Yeah, that's one of the things I also checked. This is the full textValue that gets stored in the database when using nested content:

    [
      {
        "key": "3748c52e-3b0e-400e-9403-253e7e3d2cdd",
        "name": "Item 1",
        "ncContentTypeAlias": "financialResultsWebcast",
        "title": null,
        "description": "<?UMBRACO_MACRO macroAlias=\"VideoImageWithCaption\" image=\"umb://media/ea0e3fe8608d46638dc1ff274aee5d51\" videoUrl=\"\" caption=\"\" />\n<p>Teeshfjkhdkjh aldjfk ajsd</p>\n<p>f ajksdfk ashdfjkhaskldjflsadf</p>",
        "video": null,
        "videoBackground": null
      }
    ]
    

    And this is the full textValue that is stored for the contentBlocks:

    {
      "version": 2,
      "header": null,
      "blocks": [
        {
          "id": "428c0aff-6601-484c-b1aa-f37e3eaa8e5c",
          "definitionId": "615ce491-9551-47e6-bc1a-5e0116804dcf",
          "layoutId": "08574c01-53e9-40d2-aa77-d6997ec1bd1b",
          "content": [
            {
              "key": "123f851e-53af-4a89-9f73-9be743da0a7c",
              "name": "Working towards transformation",
              "ncContentTypeAlias": "textSection",
              "title": "Working towards transformation",
              "text": "<p>Test content</p>"
            }
          ]
        },
        {
          "id": "7c0d2c92-d360-45ab-aacf-fdd24ca21ea6",
          "definitionId": "615ce491-9551-47e6-bc1a-5e0116804dcf",
          "layoutId": "08574c01-53e9-40d2-aa77-d6997ec1bd1b",
          "content": [
            {
              "key": "72d768d8-ebb4-4de1-9b9c-150e6f269fa2",
              "name": "A successful launch",
              "ncContentTypeAlias": "textSection",
              "title": "A successful launch",
              "text": "<p>Test Content with Macro</p>\n<div class=\"umb-macro-holder Button umb-macro-mce_1 mceNonEditable\"><!-- <?UMBRACO_MACRO macroAlias=\"Button\" text=\"Contact specialist\" link=\"umb://document/f000a85417174839b304b0c98254f629\" /> --><ins><a href=\"/\" class=\"button is-brand\"> <span>Contact specialist</span> <span class=\"icon  \"> <span class=\"material-icons\">arrow_forward</span> </span> </a></ins></div>"
            }
          ]
        },
        {
          "id": "f41e0d6d-7dfc-4f73-ac47-0cd8e07460d6",
          "definitionId": "615ce491-9551-47e6-bc1a-5e0116804dcf",
          "layoutId": "08574c01-53e9-40d2-aa77-d6997ec1bd1b",
          "content": [
            {
              "key": "67495fb1-40fa-40b0-9f62-d27a9773f043",
              "name": "The future of Marel Live",
              "ncContentTypeAlias": "textSection",
              "title": "The future of Marel Live",
              "text": "<div class=\"umb-macro-holder mceNonEditable\"><!-- <?UMBRACO_MACRO macroAlias=\"VideoImageWithCaption\" image=\"umb://media/ea0e3fe8608d46638dc1ff274aee5d51\" videoUrl=\"\" caption=\"Test\" /> --><ins>Macro alias: <strong>VideoImageWithCaption</strong></ins></div>\n<p>Another test content with macro</p>"
            }
          ]
        }
      ]
    }
    
  3. PerplexDaniel commented on Aug 7, 2020

    @PerplexDaniel
    Member

    Strange, it shouldn't really store anything differently than Nested Content but apparently it does. Will try to have a look at this soon.

  4. self-assigned this
    on Aug 7, 2020
  5. PerplexDaniel commented on Aug 7, 2020

    @PerplexDaniel
    Member

    Well it seems Umbraco uses a MacroTagParser in their Rich Text Editor property editor to parse their macro tags back and forth. I suppose we will have to somehow call these methods as well for our editor.

    Seems like IDataValueEditor.FromEditor() & IDataValueEditor.ToEditor() are probably the place for this, considering this is also where the Rich Text Editor itself does that. So our editor should implement these methods and call Nested Content's FromEditor / ToEditor() methods.

    This is similar to how we already implement Validation at this moment. We also call Nested Content's validation method and go from there.

    Just putting this info here for later when I'll try if that fixes this. Assuming it will.

  6. added
    accepted
    bug
    on Aug 7, 2020
  7. added a commit that references this issue on Aug 16, 2020
  8. PerplexDaniel commented on Aug 16, 2020

    @PerplexDaniel
    Member

    @patrickdemooij9 I have included a fix for this issue in 1.5.2-rc.1 which is on NuGet now. Make sure to tick "Include prerelease" to find it. Seems to work now. If you find any issues let me know and I'll fix them before 1.5.2 final.

  9. linked a pull request that will close this issueFix macro issues inside RTE (#31) #34on Aug 16, 2020
  10. added a commit that references this issue on Aug 17, 2020
  11. PerplexDaniel commented on Aug 24, 2020

    @PerplexDaniel
    Member

    @patrickdemooij9 FYI I have released 1.5.2. If you didn't have the chance to test it yet and still find issues just let me know and we'll fix in a next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

acceptedbug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions