Configure markup editing

This guide will walk through the steps required to get your Next.js site built, editable and live on CloudCannon.

The other type of content you can edit in CloudCannon is markup. Markup is in Markup files (HTML, Markdown, MDX), or combination files (HTML, Markdown, or MDX with front matter).

In this step of the guide we'll focus on configuring the appearance and functionality of markup editing interfaces in the Visual Editor, the Content Editor, the Data Editor.

You can familiarize yourself these settings by browsing your CloudCannon configuration file in the Data Editor. If you want to undertake some self-directed exploration you can open your CloudCannon configuration file by clicking on Site Settings in your Site Navigation, opening the Editing page, and clicking the Edit your configuration file button.

We'll cover how to configure the WYSIWYG toolbar for Rich Text editors, the markdown engine, Snippets, and visual previews.

WYSIWYG toolbar configuration#

Markdown is used in the Content, Visual, and Data Editors. The Content Editor is a rich text editor for Markdown files. The Visual Editor can edit Markdown files if they are wrapped in an HTML element. Markdown is also used in the Data Editor if you have a rich text area for one of your inputs. To customize your experience using these editors, you should configure your WYSIWYG toolbar.

Let’s go over an example of how you would customize the toolbar. We want to allow our content team to add a table to Markdown files. In our global configuration file, we have complete control over the WYSIWYG toolbar.

You can define the _editables for each editor type in the global configuration file. These sections look like this in the configuration GUI:

A screenshot of the CloudCannon configuration GUI shows the section allowing users to configure the toolbar for each editor.

Select all the editable options you would like in your WYSIWYG toolbar.

When you have created your CloudCannon global configuration file, your _editables will look something like this:

cloudcannon.config.yaml
copied
_editables:
  content:
    bold: true
    italic: true
    bulletedlist: true
    numberedlist: true
    image: true
    table: true
    undo: true
    redo: true
cloudcannon.config.json
copied
{
  "_editables": {
    "content": {
      "bold": true,
      "italic": true,
      "bulletedlist": true,
      "numberedlist": true,
      "image": true,
      "table": true,
      "undo": true,
      "redo": true
    }
  }
}

As you can see, we have enabled many of the common functions your team would expect in a content editor. But that’s not all! Check out our documentation for many more ways to configure the WYSIWYG toolbar.

Markdown engine configuration#

Your Markdown engine will process Markdown into HTML, making it editable. You can use any Markdown engine when building your site; this only covers the Markdown content you edit inside CloudCannon.

CloudCannon supports the CommonMark and Kramdown specifications. These implementations are markdown-it (JavaScript) and kramdown (Ruby). markdown-it is the default Markdown processor in CloudCannon.

Currently, you cannot configure the Markdown engine through the Configuration GUI, however, it is easy to do manually. Navigate to your CloudCannon global configuration file through the Files tab in your navigation sidebar. The configuration file will be in the root of your directory.

Your generator code should look something like this:

cloudcannon.config.yaml
copied
generator:
  metadata:
    markdown: markdown-it
    markdown-it:
      html: true
      linkify: true
cloudcannon.config.json
copied
{
  "generator": {
    "metadata": {
      "markdown": "markdown-it",
      "markdown-it": {
        "html": true,
        "linkify": true
      }
    }
  }
}

The default configuration is { html: true } to allow the images with width and height attributes the Rich Text editors create. However, you can update this to match your site by setting the generator.metadata in your global configuration file as shown above.

Visual Editor Previews#

In a previous section of this guide, we talked about the Visual Editor — an intuitive way to edit your site by clicking directly on a preview of your page. But how do you make each region editable in the Visual Editor?

React Connector#

The React Connector is our open-source tool which listens for live editing events in the Visual Editor. CloudCannon will re-render your page as changes occur, generating a preview of your page as you edit.

CloudCannon React Connector is available on npm. To install it, run the following terminal command:

copied
    npm i @cloudcannon/react-connector

Update the code in pages/_app.jsx from:

copied
    export default function App({ Component, pageProps }) {
    	return <Component {...pageProps} />
    }

to:

copied
import { CloudCannonConnect } from '@cloudcannon/react-connector'

export default function App({ Component, pageProps }) {
	const AppComponent = CloudCannonConnect(Component);
	return <AppComponent {...pageProps}/>
}

CloudCannon will now push changes made to front matter in the Visual Editor directly into page props. This will display the new values in the Visual Editor immediately.

For more react connector options, read our GitHub React Connector guide, or reach out to our support team.

Save your markup editing configuration#

Once you have finished editing your CloudCannon configuration file, you can save your changes using the Save button at the top right of the Data Editor.

CloudCannon will push your cloudcannon.config.yml file back to your repository.

Open in a new tab