Metadata-Version: 2.1
Name: wagtail-custom-code-editor
Version: 1.0.2
Summary: An Ace Editor that works in Wagtail CMS
Author-email: Amin Shazrin <aminshazrin@yahoo.com>
License: MIT License
        Copyright (c) 2024 Amin Shazrin Bin Shaharrudean
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/ammein/wagtail-custom-code-editor
Keywords: wagtail,cms,custom-code-editor,editor,code,acejs,wagtailcms,wagtail-cms,field,field-block
Classifier: Environment :: Web Environment
Classifier: Framework :: Django
Classifier: Framework :: Django :: 5.0
Classifier: Framework :: Wagtail
Classifier: Framework :: Wagtail :: 1
Classifier: Framework :: Wagtail :: 2
Classifier: Framework :: Wagtail :: 3
Classifier: Framework :: Wagtail :: 4
Classifier: Framework :: Wagtail :: 5
Classifier: Framework :: Wagtail :: 6
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Internet :: WWW/HTTP
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: django>=4.2
Provides-Extra: testing
Requires-Dist: django>=4.2; extra == "testing"
Requires-Dist: wagtail>=6.2; extra == "testing"
Provides-Extra: dynamic
Requires-Dist: dependencies; extra == "dynamic"

# wagtail-custom-code-editor
![Wagtail Custom Code Editor Workflow](https://github.com/ammein/wagtail-custom-code-editor/actions/workflows/github-actions-check.yml/badge.svg)

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](https://ace.c9.io/)

![intro](https://raw.githubusercontent.com/ammein/wagtail-custom-code-editor/refs/heads/main/docs/intro.gif)

## 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
- [Settings](https://github.com/ammein/wagtail-custom-code-editor/blob/main/docs/settings.md)
- [Widget Options](https://github.com/ammein/wagtail-custom-code-editor/blob/main/docs/options.md)
- [Change Modes](https://github.com/ammein/wagtail-custom-code-editor/blob/main/docs/modes.md)
- [Django Admin](https://github.com/ammein/wagtail-custom-code-editor/blob/main/docs/django-admin.md)
- [Extend JS Functionality](https://github.com/ammein/wagtail-custom-code-editor/blob/main/docs/extend-functionality.md)

## Install
Simply install in your project:
```shell
pip install wagtail-custom-code-editor
```

In your settings, add the package in `INSTALLED_APPS`:
```python
INSTALLED_APPS = [
    ...
    "wagtail_custom_code_editor",
    ...
]
```

### Usage

#### Field
You can easily add the `CustomCodeEditorField` to your model fields like this:
```python
from wagtail_custom_code_editor.fields import CustomCodeEditorField

class MyPage(Page):
    code = CustomCodeEditorField()
    ...
```
> The field is using [Django's JSONField](https://docs.djangoproject.com/en/5.1/ref/models/fields/#django.db.models.JSONField)

#### Panel
Then you add `CustomCodeEditorPanel` like this:

```python
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')
    ]
```

#### Block
You can also add as `CustomCodeEditorBlock` like this:

```python
from wagtail_custom_code_editor.blocks import CustomCodeEditorBlock
from wagtail.blocks import (
    StructBlock,
)

class CodeBlock(StructBlock):
    code = CustomCodeEditorBlock()
```

#### Frontend
You can easily grab the JSON value like this:
```html
<pre><code>{{ page.code.code }}</code></pre>
```

The JSON returns this two key value:
```json
{
  "code": "Any Code here",
  "mode": "html" 
}
```

## License

Wagtail-Geo-Widget is released under the [MIT License](http://www.opensource.org/licenses/MIT).
