Basic enrichments
Adding and displaying simple enrichments.
Last updated
Adding and displaying simple enrichments.
Last updated
Element eIds.
Adding enrichments to parts of the document.
Showing enrichments in the document gutter.
One of the big benefits of Akoma Ntoso XML is that we can treat a document as data, not just text. This is possible because every element in an AKN document has a well-formed, unique ID called an eId. These eIds are also included in the HTML form of the document, as both the id
and the data-eid
attributes.
We can associate extra data with an element's eId, and then show it along with the document.
In this section, we'll build some interactivity that allows the user to comment on any item in the document, using this eId attributes. We will show the comments in the gutter to the right of the document.
Let's add the Law Widgets <la-gutter> widget to the page, and a floating button to add a comment. We use the .la-akoma-ntoso-with-gutter
helper class to provide styles and spacing for gutter items.
Modify your expression_detail.html
file:
Now we're going to add some javascript to support the following functionality:
The user selects text anywhere in the document
The user clicks on the "Add comment..." button
The user is prompted to type in their comment
We get the best eId for the selection
We create a new <la-gutter-item>
widget that has the comment text, and add it to the gutter.
Add this script block to the bottom of expression_detail.html
:
The user can now link a comment to any portion of the document. This example is very simple, but you can see how you can link arbitrary data to the various portions of the document.
Remember that the Table of Contents JSON object has the titles and eIds of all the hierarchical elements in the document. You can use this to build an interface to help your editors to annotate different parts of the document.
The <la-gutter>
widget makes it easy to show a comment or other information alongside a part of the document. Add a <la-gutter-item>
element to the <la-gutter>
and set its anchor
attribute to the eId of the targeted element.
The gutter positions the gutter item at the correct height of its matching anchor. It will do its best to lay out other gutter items so that they don't overlap.
Clicking on a gutter item activates it, and forces it to be shown alongside its anchor. Surrounding gutter items will move out the way.
Gutter items can be anything: text, images, buttons, or cards. How you style them is up to you.