Skip to content

Commit

Permalink
Fix: Added schemas for AAT support (fixes #12)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverfoster authored Dec 4, 2024
2 parents 9d76b11 + 6835066 commit 5f819c2
Show file tree
Hide file tree
Showing 3 changed files with 176 additions and 9 deletions.
11 changes: 5 additions & 6 deletions js/adapt-definitions.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,13 @@ class Definitions extends Backbone.Controller {
const title = Handlebars.compile(this.model.get('title'))(json);
const body = Handlebars.compile(this.model.get('body'))(json);

notify.popup({
const promptText = this.model.get('confirmText');
const hasPromptText = Boolean(promptText);
const type = hasPromptText ? 'prompt' : 'popup';
notify[type]({
title,
body: '<div no-definition="true">' + body + '</div>',
_prompts: [
{
promptText: this.model.get('confirmText') || 'Close'
}
],
_prompts: [{ promptText }],
_showIcon: this.model.get('_showIcon'),
_classes: 'is-extension is-definitions'
});
Expand Down
91 changes: 88 additions & 3 deletions properties.schema
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,100 @@
"type": "object",
"$schema": "http://json-schema.org/draft-04/schema",
"id": "http://jsonschema.net",
"required": false,
"properties": {
"pluginLocations": {
"type": "object",
"required": true,
"properties": {
"config": {
"course": {
"type": "object",
"properties": {}
"properties": {
"_definitions": {
"type": "object",
"required": false,
"legend": "Definitions",
"properties": {
"_isEnabled": {
"type": "boolean",
"required": true,
"default": false,
"title": "Add definition links to course words",
"inputType": "Checkbox",
"validators": [],
"help": "Controls whether the Definitions extension is enabled or disabled."
},
"title": {
"type": "string",
"default": "Definition",
"required": true,
"title": "Title",
"inputType": "Text",
"validators": ["required"],
"help": "The title for the pop up which displays when a definitions link is selected.",
"translatable": true
},
"body": {
"type": "string",
"default": "{{{word}}}: {{{definition}}}",
"required": false,
"title": "Body",
"inputType": "Text",
"validators": [],
"help": "The body content for the pop up which displays when a definitions link is selected.",
"translatable": true
},
"confirmText": {
"type": "string",
"default": "Close",
"required": false,
"title": "Confirm Text",
"inputType": "Text",
"validators": [],
"help": "Show a close button at the bottom of the popup rather than a cross at the top right.",
"translatable": true
},
"_items": {
"type": "array",
"required": true,
"title": "Items",
"items": {
"type": "object",
"required": false,
"properties": {
"_words": {
"type": "array",
"required": false,
"title": "Words",
"items": {
"type": "string",
"required": false,
"default": "",
"title": "Word",
"inputType": "Text",
"validators": [],
"help": "The collection of word(s) to attach the associated definition to.",
"translatable": true
}
},
"definition": {
"type": "string",
"default": "",
"required": false,
"title": "Definition",
"inputType": "Text",
"validators": [],
"help": "The definition for the associated word(s).",
"translatable": true
}
}
}
}
}
}
}
}
}
}
}
}
}
83 changes: 83 additions & 0 deletions schema/course.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
{
"$anchor": "definitions-course",
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "object",
"$patch": {
"source": {
"$ref": "course"
},
"with": {
"properties": {
"_definitions": {
"type": "object",
"title": "Definitions",
"default": {},
"required": [
"title"
],
"properties": {
"_isEnabled": {
"type": "boolean",
"title": "Add definition links to course words",
"description": "Controls whether the Definitions extension is enabled or disabled.",
"default": false
},
"title": {
"type": "string",
"title": "Title",
"default": "Definition",
"description": "The title for the pop up which displays when a definitions link is selected.",
"_adapt": {
"translatable": true
}
},
"body": {
"type": "string",
"title": "Body",
"default": "{{{word}}}: {{{definition}}}",
"description": "The body content for the pop up which displays when a definitions link is selected.",
"_adapt": {
"translatable": true
}
},
"confirmText": {
"type": "string",
"title": "Confirm Text",
"default": "Close",
"description": "Show a close button at the bottom of the popup rather than a cross at the top right.",
"_adapt": {
"translatable": true
}
},
"_items": {
"type": "array",
"title": "Items",
"items": {
"type": "object",
"properties": {
"_words": {
"type": "array",
"title": "Words",
"description": "The collection of word(s) to attach the associated definition to.",
"items": {
"type": "string"
}
},
"definition": {
"type": "string",
"title": "Definition",
"default": "",
"description": "The definition for the associated word(s).",
"_adapt": {
"translatable": true
}
}
}
}
}
}
}
}
}
}
}

0 comments on commit 5f819c2

Please sign in to comment.