Skip to main content

An Ace Editor that works in Wagtail CMS

Project description

wagtail-custom-code-editor

Wagtail Custom Code Editor Workflow

A Wagtail Custom Code Editor Field for your own editor field.

This package adds a full-featured code editor that is perfect for coding tutorials, documentation containing code examples, or any other type of page that needs to display code.

This field uses the open-source Ace Editor library that you may found here Ace Editor

intro

Features

  • Replace traditional textarea to Ace Editor that you can easily check the linting of the codes.
  • Add snippet for better re-usable small region of source code, or any text format.
  • Configure your own Ace Editor Options to your own editor preferences.
  • Easily change mode available on your own default/custom mode's setup.
  • You can save any code highlights so that it can retain the same highlight's code when you change to different mode.

Documentation

Install

In your settings, add the package in INSTALLED_APPS:

INSTALLED_APPS = [
    ...
    "wagtail_custom_code_editor",
    ...
]

Usage

Field

You can easily add the CustomCodeEditorField to your model fields like this:

from wagtail_custom_code_editor.fields import CustomCodeEditorField

class MyPage(Page):
    code = CustomCodeEditorField()
    ...

The field is using Django's JSONField

Panel

Then you add CustomCodeEditorPanel like this:

from wagtail_custom_code_editor.panels import CustomCodeEditorPanel
from wagtail_custom_code_editor.fields import CustomCodeEditorField

class MyPage(Page):
    code = CustomCodeEditorField()

    content_panels = Page.content_panels + [
        CustomCodeEditorPanel('code')
    ]

Frontend

You can easily grab the JSON value like this:

<pre><code>{{ page.code.code }}</code></pre>

The JSON returns this two key value:

{
  "code": "Any Code here",
  "mode": "html" 
}

License

Wagtail-Geo-Widget is released under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

wagtail_custom_code_editor-1.0.0.tar.gz (3.0 MB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page