decaporg / decap-cms

A Git-based CMS for Static Site Generators
https://decapcms.org
MIT License
17.65k stars 3.02k forks source link

show code widget content if initially hidden #7131

Closed hip3r closed 3 months ago

hip3r commented 4 months ago

Summary

fixes #6812 code widgets now shows content if it's inside list.

Test plan

config.yml

local_backend: true

backend:
  name: proxy
  proxy_url: http://localhost:8082/api/v1
  branch: main

# These lines should *not* be indented
media_folder: "static/img" # Media files will be stored in the repo under static/images/uploads
public_folder: "/img/" # The src attribute for uploaded media will begin with /images/uploads

collections:
  - name: docs
    label: Docs
    label_singular: "Doc"
    folder: "docs"
    path: "{{title}}/{{id}}"
    slug: "{{id}}"
    create: true
    nested: { depth: 100 } # accepts an optional summary template
    allow_nesting: true
    meta: { path: { widget: string, label: "Path", index_file: "index" } }
    fields:
      - { label: "title", name: "title", widget: "string" }
      - {
          name: "code test",
          label: "Example Code",
          widget: "code",
          default_language: "jsx",
          output_code_only: true,
          hint: "Add or choose a file with valid React or MUI code. This will render the preview area of the example. Specify imports as needed in your file.",
        }
      - {
        name: "items",
        label: "Examples",
        widget: "list",
        fields: [
          {
            name: "name",
            label: "Name",
            widget: "string",
            hint: "This is used to label the example in the admin area. It does not show on the website.",
          },
          {
            name: "type",
            label: "Type",
            widget: "select",
            options: [
              {
                label: "Theme Preview",
                value: "",
              },
              {
                label: "Do (Success)",
                value: "success",
              },
              {
                label: "Don't (Error)",
                value: "error",
              },
            ],
          },
          {
            name: "code",
            label: "Example Code",
            widget: "code",
            default_language: "jsx",
            output_code_only: true,
            hint: "Add or choose a file with valid React or MUI code. This will render the preview area of the example. Specify imports as needed in your file.",
          },
          {
            name: "description",
            label: "Description",
            widget: "text",
            hint: "Use this area to provide notes and context about this example. Line breaks and code are not supported and will be removed on save.\n ⚠",
          },
          {
            name: "items inside",
            label: "Examples inside",
            widget: "list",
            fields: [
              {
                name: "name",
                label: "Name",
                widget: "string",
                hint: "This is used to label the example in the admin area. It does not show on the website.",
              },
              {
                name: "type",
                label: "Type",
                widget: "select",
                options: [
                  {
                    label: "Theme Preview",
                    value: "",
                  },
                  {
                    label: "Do (Success)",
                    value: "success",
                  },
                  {
                    label: "Don't (Error)",
                    value: "error",
                  },
                ],
              },
              {
                name: "code",
                label: "Example Code",
                widget: "code",
                default_language: "jsx",
                output_code_only: true,
                hint: "Add or choose a file with valid React or MUI code. This will render the preview area of the example. Specify imports as needed in your file.",
              },
              {
                name: "description",
                label: "Description",
                widget: "text",
                hint: "Use this area to provide notes and context about this example. Line breaks and code are not supported and will be removed on save.\n ⚠",
              },
            ]
          }
        ]
      }

Before: image

After: image

Checklist

Please add a x inside each checkbox:

A picture of a cute animal (not mandatory but encouraged) image