This repository contains source code and development environment for a Draftail spelling and grammar annotation plugin for use with the Wagtail CMS admin interface, configured for Icelandic.
The plugin uses the Yfirlestur.is API for spelling and grammar correction, which runs GreynirCorrect. Both are maintained by Miðeind.
The plugin was developed for, and is configured for use with, the Kjarninn editorial environment, which uses a standard Wagtail admin interface.
The annotation functionality of the plugin and interactive UI is based on pre-existing in line entity frameworks of the Draftail editor, written in React. As Draftail is based on the widely used Draft.js editor, functionality more specific to Draft.js is used where possible.
The custom entity functionality of the plugin is contained within a specific Django app. This is labeled ui_test
.
The plugin technically consists of two sub-plugins: one for the general functionality of in-line annotations and the other for the removal of all annotations in the text. These sub-plugins each consist of a source and an entity, which are registered to the DOM through the app's Wagtail hooks.
The annotation functionality of the plugin is contained within a specific entity, with it's source contained separately. Necessary utilities are contained in a separate directory.
This entity handles most functionality of the in line annotations:
- API interaction
- UI rendering
- Text substitution
The annotation source is registered to the DOM as a toolbar button, which is the standard approach for Wagtail Plugins. Wider functionality is controlled through rendered UI, contained within the annotation entity.
The second sub-plugin controls the removal of all annotation entities present in the editor. This should be thought of as a "clear all" functionality, used after checking the editor text for errors.
Like the wider annotation functionality, it consists of a specific source file and an entity which are registered through Wagtail hooks. However, the entity for annotation removal does not render anything and only the entity source is run when called.
For the end user, this functionality is controlled through a separate editor toolbar button.
The in-line entity functionality of Draftail, used here for rendering annotations, is intended for end user use, with specific functionality and rendering in the respective website's front end. This was not the goal of this project, as the in-line spelling and grammar annotations only serve a purpose within the Wagtail admin interface.
For this reason, the plugin consists of the two sub-plugins described above, with the "annotation removal" functionality integral to the workflow of the plugin. This is to ensure that no annotation entities are rendered in the end application of the text being annotated.
A rework of this system would be beneficial for future applications of this plugin.
- University of Iceland
This project was funded by the Language Technology Programme for Icelandic 2019-2023. The programme, which is managed and coordinated by Almannarómur, is funded by the Icelandic Ministry of Education, Science and Culture.
This software is licensed under the MIT License:
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.