Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to draftail #29

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
aa6e70e
Wagtail version bump
May 23, 2021
f013253
Frontend version bumps
May 23, 2021
9fa2689
Frontend version bumps 2: package-lock update
May 23, 2021
a1c234f
Switching from wagtaildraftail to upstream wagtail's draftail
May 23, 2021
6f37cc8
Test libs bump
May 24, 2021
ab29db1
Black run
May 24, 2021
025f275
Frontend test deps bump
May 24, 2021
b9d7d44
Frontend test deps bump 2: package-lock
May 24, 2021
b2ff8ba
Eslint --fix run
May 24, 2021
5e22421
Remove flake8-colors because it's broken
May 24, 2021
b4a1211
Tox test env updates
May 24, 2021
400719d
Isort and Flake8 py fixes
May 24, 2021
f9d8836
Testapp and test fixes from wagtail bump
May 24, 2021
13a03bf
UglifyJS bump
May 24, 2021
a9573da
UglifyJS bump 2: package-lock
May 24, 2021
acead70
Remove fontawesome icon support for now
May 25, 2021
b6d73c1
Improvements to draftail option handling
May 30, 2021
aebdc94
Construct draftail DB conversion rules for models
May 31, 2021
0f3dfeb
Removing unused packages
May 31, 2021
f764ddb
Major frontend version bumps: DraftJS and React
May 31, 2021
cb0950e
first draft readme update for draftail
May 31, 2021
d6cc6e1
Add typescript and ts-ify new files
liamjohnston Jun 1, 2021
1318f59
Adapt code injection for telepath
Jun 2, 2021
c20ad5a
Converted draftailmodelchoosers.js to tsx. Added some draft js typing…
liamjohnston Jun 2, 2021
07f47c7
Move to wagtail 2.13
Jun 9, 2021
134bbd6
WagtailModelChoosers version bump 0.1.2 -> 0.2.0
May 24, 2021
be6d2f3
Replacing fstrs with .format for 3.5 compatibility
Nov 3, 2021
a02b546
Making telepath hooks optional if telepath doesn't exist
Nov 3, 2021
f02a684
Instantiate type returned by bind_model in edit_handlers
Nov 3, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6
10
12 changes: 5 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ cache:
matrix:
# See `Which version combinations to include in Travis test matrix?` in `/docs/README.md`.
include:
- env: TOXENV=py34-dj111-wt113
python: 3.4
- env: TOXENV=py35-dj111-wt113
python: 3.5
- env: TOXENV=py36-dj111-wt112
python: 3.6
- env: TOXENV=py36-dj111-wt113
- env: TOXENV=py36-dj31-wt212
python: 3.6
- env: TOXENV=py37-dj31-wt212
python: 3.7
- env: TOXENV=py38-dj31-wt212
python: 3.8
# - env: TOXENV=py36-dj111-wt2b
# python: 3.6
# - env: TOXENV=py36-dj2-wt2b
Expand Down
21 changes: 18 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,21 @@ Usage

To select a model from a remote API, respectively use ``RemoteModelChooserBlock`` and ``RemoteModelChooserPanel`` instead.

If you have `WagtailDraftail <https://github.com/springload/wagtaildraftail>`_ installed, it will automatically register the ``ModelSource`` and ``RemoteModelSource`` to the JS. Refer to ``WagtailDraftail``'s `documentation <https://github.com/springload/wagtaildraftail#configuration>`_ to hook it up properly.
If you want a chooser to be available in draftail, put a unique 'draftail_type' into its configuration dict in ``MODEL_CHOOSER_OPTIONS``, then add the chooser name to rich text features. You can do the latter either by adding it explicitly in a feature list like this:

.. code:: python

rich_text_block = RichTextBlock(features=["custom_model"])

Or adding it to the list of default features for all rich text blocks like this:

.. code:: python

@hooks.register("register_rich_text_features")
def register_rich_text_features(features):
features.default_features.append("custom_model")

Note: It's easy to confuse draftail_type with the chooser's name. See the Configuration section if you're not sure which is which. The only place you need to put the draftail_type is in settings. The value you put there gets passed into draftail as an entity type, so the blocks created by that modelchooser toolbar option have the block type equal to the draftail_type you declared. This is useful if you're doing something custom with the contentstate.

Configuration
~~~~~~~~~~~~~
Expand All @@ -63,7 +77,7 @@ The ModelChooser and RemoteModelChooser share a similar base configuration and o
.. code:: python

MODEL_CHOOSERS_OPTIONS = {
'navigation': {
'navigation': { # The chooser name
'label': 'Navigation', # The label to use for buttons or modal title
'display': 'name', # The field to display when selecting an object
'list_display': [ # The fields to display in the chooser
Expand All @@ -75,9 +89,10 @@ The ModelChooser and RemoteModelChooser share a similar base configuration and o
'fields_to_save': ['id'] + RATE_CHOOSER_DISPLAY_FIELDS, # ONLY FOR REMOTE: The remote objects fields to save to the DB. Leave empty to save the whole object.
'remote_endpoint': 'http://...' # ONLY FOR REMOTE: The remote API endpoint.
'pk_name': 'uuid', # The primary key name of the model
'draftail_type': 'NAV', # Only add this if you want the model available in draftail. Must be unique and can't clash with any default wagtail types.
}
}

In addition, you can customise the mapping of the key of the API, see the configuration key names being used for the `query <https://github.com/springload/wagtailmodelchoosers/blob/c36bb877eef4ac4af6b221f0d7ff7416354754c7/wagtailmodelchoosers/utils.py#L107-L112>`_ and the `response <https://github.com/springload/wagtailmodelchoosers/blob/c36bb877eef4ac4af6b221f0d7ff7416354754c7/wagtailmodelchoosers/utils.py#L115-L123>`_.


Expand Down
Loading