lotas / contentful-graph

Visual representation of contentful content models in form of graphs
https://www.contentful.com/blog/2017/08/08/how-to-quickly-visualize-your-content-model/
MIT License
59 stars 6 forks source link

Output is missing edges for richtext embedded entries #19

Closed s5no5t closed 3 years ago

s5no5t commented 3 years ago

The graph is really useful, thank you very much for this!

We noticed that embedded entry references within richtext fields aren't picked up yet and hence don't become edges in the graph.

By the way, is this repo still active? Would you also accept PRs?

lotas commented 3 years ago

Hi @jugglingthebits! Thanks for the feedback :)

Yes, this is pretty much active, but I don't work with contentful anymore, so not actively developed, so to say ;) Features and PRs are highly appreciated, thank you.

lotas commented 3 years ago

Can you post an exported json schema? To have a look, why it is not picked up?

Swissbite commented 3 years ago

@lotas I just saw the issue and I added an example contentful export with richtext.

The schema includes two models: Simple Image Caption A simple content model to have a reference / filter for the other schema. It has 3 fields, a name, a caption and an asset reference for images.

Graph Example with Richttext Item It has 4 fields

Title - A basic title, to be able to find it in the overview Richtext all options enabled - All options enabled, no validation set. Therefore, all content models can be referenced in this richtext

{
          "id": "richtextAllOptionsEnabled",
          "name": "Richtext all options enabled",
          "type": "RichText",
          "localized": true,
          "required": true,
          "validations": [
            {
              "nodes": {
              }
            }
          ],
          "disabled": false,
          "omitted": false
}

Richtext only media assets - This has a basic filter to only enable formats, hyperlinks and links / inline reference to assets.

{
          "id": "richtextOnlyMediaAssets",
          "name": "Richtext only media assets",
          "type": "RichText",
          "localized": true,
          "required": false,
          "validations": [
            {
              "enabledNodeTypes": [
                "heading-1",
                "heading-2",
                "heading-3",
                "heading-4",
                "heading-5",
                "heading-6",
                "ordered-list",
                "unordered-list",
                "hr",
                "blockquote",
                "embedded-asset-block",
                "asset-hyperlink",
                "hyperlink"
              ],
              "message": "Only heading 1, heading 2, heading 3, heading 4, heading 5, heading 6, ordered list, unordered list, horizontal rule, quote, asset, link to asset, and link to Url nodes are allowed"
            },
            {
              "nodes": {
              }
            }
          ],
          "disabled": false,
          "omitted": false
        }

Richtext with defined reference to caption - This Richtext definition disabled link and embeding assets and allowing all other node types.

For references / links to content model, the nodeTypes "embedded-entry-block", "entry-hyperlink", "embedded-entry-inline" are possible items. They can be validated against specific content model definition or may have no validation. No validation means that all content models can be referenced.

{
          "id": "richtextWithDefinedReferenceToCaption",
          "name": "Richtext with defined reference to caption",
          "type": "RichText",
          "localized": true,
          "required": false,
          "validations": [
            {
              "enabledNodeTypes": [
                "heading-1",
                "heading-2",
                "heading-3",
                "heading-4",
                "heading-5",
                "heading-6",
                "ordered-list",
                "unordered-list",
                "hr",
                "blockquote",
                "embedded-entry-block",
                "entry-hyperlink",
                "embedded-entry-inline"
              ],
              "message": "Only heading 1, heading 2, heading 3, heading 4, heading 5, heading 6, ordered list, unordered list, horizontal rule, quote, block entry, link to entry, and inline entry nodes are allowed"
            },
            {
              "nodes": {
                "embedded-entry-block": [
                  {
                    "linkContentType": [
                      "simpleImageCaption"
                    ],
                    "message": null
                  }
                ],
                "embedded-entry-inline": [
                  {
                    "linkContentType": [
                      "simpleImageCaption"
                    ],
                    "message": null
                  }
                ],
                "entry-hyperlink": [
                  {
                    "linkContentType": [
                      "graphExampleWithRichttextItem"
                    ],
                    "message": null
                  }
                ]
              }
            }

The attached file contains the complete schema export with the models described above. contentful-export-richtext-example-2020-10-24T18-24-20.json.txt

PS: Github does not allow to upload a file with the ending json, so I added the .txt suffix :-)

lotas commented 3 years ago

@Swissbite I've merged your PR, thank you for the contribution 👍 @jugglingthebits can you please pull latest version and check if the issue was fixed for you?

s5no5t commented 3 years ago

@lotas will do!

s5no5t commented 3 years ago

@lotas @Swissbite this seems to work just fine. Thank you for implementing this!