An Ace Editor that works in Wagtail CMS
Project description
wagtail-custom-code-editor
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
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
Hashes for wagtail_custom_code_editor-1.0.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | d66d65df7e633cbff5e330abbd4cb73a699da4cbd1ce7a875d585329d84606fe |
|
MD5 | 19f8a92f93ee3ac890a872fde3b69fc9 |
|
BLAKE2b-256 | 2d017c1cf3731add5392cf8804ac327e00c1614dfe7fb98ba930cb8722de69fd |