-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 6f01f9e
Showing
39 changed files
with
2,087 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
[*] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
indent_style = space | ||
indent_size = 2 | ||
|
||
[*.py] | ||
indent_size = 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module.exports = { | ||
root: true, | ||
parser: "@babel/eslint-parser", | ||
env: { | ||
browser: true, | ||
es6: true, | ||
node: true, | ||
}, | ||
extends: ["eslint:recommended", "prettier"], | ||
globals: { | ||
Atomics: "readonly", | ||
SharedArrayBuffer: "readonly", | ||
__API_HOST: "readonly", | ||
}, | ||
parserOptions: { | ||
ecmaFeatures: { | ||
experimentalObjectRestSpread: true, | ||
jsx: true, | ||
}, | ||
ecmaVersion: 2021, | ||
requireConfigFile: false, | ||
sourceType: "module", | ||
}, | ||
rules: { | ||
"no-unused-vars": [ | ||
"error", | ||
{ | ||
argsIgnorePattern: "^_", | ||
varsIgnorePattern: "^_", | ||
}, | ||
], | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
|
||
jobs: | ||
tests: | ||
name: Python ${{ matrix.python-version }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
python-version: | ||
- "3.11" | ||
- "3.12" | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up Python ${{ matrix.python-version }} | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Install dependencies | ||
run: | | ||
python -m pip install --upgrade pip tox | ||
- name: Run tox targets for ${{ matrix.python-version }} | ||
run: | | ||
ENV_PREFIX=$(tr -C -d "0-9" <<< "${{ matrix.python-version }}") | ||
TOXENV=$(tox --listenvs | grep "^py$ENV_PREFIX" | tr '\n' ',') python -m tox |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
*~ | ||
\#*# | ||
/build | ||
/.bundle | ||
.coverage | ||
/data.db | ||
/dist | ||
.DS_Store | ||
/dump.rdb | ||
*.egg-info | ||
/.env | ||
/htdocs/e | ||
/.idea | ||
/log | ||
/media | ||
/node_modules | ||
*.pyc | ||
/static | ||
.*.sw* | ||
/tmp | ||
.tox | ||
/vendor | ||
/venv | ||
/.vscode | ||
yarn-error.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
exclude: ".yarn/|yarn.lock|static" | ||
repos: | ||
- repo: https://github.com/pre-commit/pre-commit-hooks | ||
rev: v4.5.0 | ||
hooks: | ||
- id: check-added-large-files | ||
- id: check-merge-conflict | ||
- id: end-of-file-fixer | ||
- id: trailing-whitespace | ||
- repo: https://github.com/adamchainz/django-upgrade | ||
rev: 1.16.0 | ||
hooks: | ||
- id: django-upgrade | ||
args: [--target-version, "4.2"] | ||
- repo: https://github.com/astral-sh/ruff-pre-commit | ||
rev: "v0.3.2" | ||
hooks: | ||
- id: ruff | ||
- id: ruff-format | ||
- repo: https://github.com/pre-commit/mirrors-prettier | ||
rev: v3.0.3 | ||
hooks: | ||
- id: prettier | ||
args: [--list-different, --no-semi, "--trailing-comma=es5"] | ||
exclude: "^conf/|.*\\.html$" | ||
- repo: https://github.com/pre-commit/mirrors-eslint | ||
rev: v8.48.0 | ||
hooks: | ||
- id: eslint | ||
additional_dependencies: | ||
- eslint | ||
- eslint-config-prettier | ||
- "@babel/core" | ||
- "@babel/eslint-parser" | ||
- "@babel/preset-env" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Change log | ||
========== | ||
|
||
Next version | ||
~~~~~~~~~~~~ | ||
|
||
|
||
`0.1`_ (2024-03-11) | ||
~~~~~~~~~~~~~~~~~~~ | ||
|
||
- Initial public release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
BSD 3-Clause License | ||
|
||
Copyright (c) 2024, Feinheit AG | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
=================== | ||
django-prose-editor | ||
=================== | ||
|
||
Prose editor for the Django admin based on ProseMirror | ||
|
||
|
||
Cookie control | ||
============== | ||
|
||
Some jurisidictions require the the users' consent before adding analytics | ||
scripts and tracking cookies. While it may be best to not use any analytics and | ||
tracking at all this may not be possible or even desirable in all | ||
circumstances. | ||
|
||
Many solutions exist for adding a consent banner to the website. Some of those | ||
banners require loading JavaScript and other assets from external servers. This | ||
raises some questions because loading those scripts may also be seen as | ||
tracking already. It is certainly safer to implement a cookie control panel | ||
locally. It would be boring to start from scratch on each site. | ||
|
||
This guide explains how to use `feincms3-cookiecontrol <https://github.com/feinheit/feincms3-cookiecontrol/>`__. | ||
|
||
Installation | ||
~~~~~~~~~~~~ | ||
|
||
Install the package: | ||
|
||
.. code-block:: shell | ||
venv/bin/pip install django-prose-editor | ||
Add ``django_prose_editor`` to ``INSTALLED_APPS``: | ||
|
||
.. code-block:: python | ||
INSTALLED_APPS = [ | ||
# ... | ||
"django_prose_editor", | ||
] | ||
Replace ``models.TextField`` with ``ProseEditorField`` where appropriate: | ||
|
||
.. code-block:: python | ||
from django_prose_editor.fields import ProseEditorField | ||
class Project(models.Model): | ||
description = ProseEditorField() | ||
Note! No migrations will be generated when switching from and to | ||
``models.TextField``. That's by design. Those migrations are mostly annoying. | ||
|
||
|
||
Customization | ||
~~~~~~~~~~~~~ | ||
|
||
It's not possible (yet), sorry. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lib/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version = "0.1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from django import forms | ||
from django.db import models | ||
|
||
from django_prose_editor.widgets import ProseEditorWidget | ||
|
||
|
||
class ProseEditorField(models.TextField): | ||
def formfield(self, **kwargs): | ||
defaults = {"form_class": ProseEditorFormField} | kwargs | ||
return super().formfield(**defaults) | ||
|
||
def deconstruct(self): | ||
name, _path, args, kwargs = super().deconstruct() | ||
return (name, "django.db.models.TextField", args, kwargs) | ||
|
||
|
||
class ProseEditorFormField(forms.CharField): | ||
widget = ProseEditorWidget | ||
|
||
def __init__(self, *args, **kwargs): | ||
kwargs["widget"] = ProseEditorWidget | ||
super().__init__(*args, **kwargs) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
django_prose_editor/static/django_prose_editor/history-arrow-HHQ2TDW5.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/* global DjangoProseEditor */ | ||
document.addEventListener("DOMContentLoaded", () => { | ||
for (let el of document.querySelectorAll("[data-django-prose-editor]")) { | ||
DjangoProseEditor.createEditor(el) | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from django import forms | ||
|
||
|
||
class ProseEditorWidget(forms.Textarea): | ||
class Media: | ||
css = {"screen": ["django_prose_editor/editor.css"]} | ||
js = ["django_prose_editor/editor.js", "django_prose_editor/init.js"] | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.attrs["data-django-prose-editor"] = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const esbuild = require("esbuild") | ||
const postcss = require("esbuild-postcss") | ||
const watch = process.argv.includes("watch") | ||
? { | ||
onRebuild(error, result) { | ||
if (error) console.error("[Editor part] watch build failed:", error) | ||
else console.log("[Editor part] watch build succeeded:", result) | ||
}, | ||
} | ||
: false | ||
|
||
esbuild | ||
.build({ | ||
entryPoints: ["./src/index.js"], | ||
jsxFactory: "h", | ||
jsxFragment: "Fragment", | ||
loader: { | ||
".js": "jsx", | ||
".svg": "file", | ||
}, | ||
minify: true, | ||
bundle: true, | ||
target: "es6", | ||
format: "iife", | ||
globalName: "DjangoProseEditor", | ||
plugins: [postcss()], | ||
outfile: "django_prose_editor/static/django_prose_editor/editor.js", | ||
// sourcemap: true, | ||
watch, | ||
}) | ||
.then((...args) => { | ||
console.log("[Editor part] build succeeded", args) | ||
}) | ||
.catch(() => process.exit(1)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
.milkdown .ProseMirror { | ||
border: 1px solid var(--border-color); | ||
border-radius: 4px; | ||
padding: 5px 6px; | ||
} | ||
|
||
/* | ||
.milkdown-menu ul[role="menubar"] { | ||
list-style: none; | ||
padding: 0; | ||
margin: 0; | ||
} | ||
/* | ||
.milkdown-menu button[role="menuitem"] { | ||
appearance: none; | ||
background: none; | ||
border: 1px solid; | ||
display: inline-grid; | ||
place-items: center; | ||
padding: 0; | ||
} | ||
.milkdown-menu button[role="menuitem"].active { | ||
background: #abc; | ||
} | ||
*/ |
Oops, something went wrong.