From 5bb613c48e4eb37f9bd1152d15f26090c1aaf066 Mon Sep 17 00:00:00 2001 From: Henriette Rudi Moe Date: Wed, 23 Mar 2022 17:05:40 +0100 Subject: [PATCH] Add label to dialog links --- .storybook/helpers/h5p.utils.ts | 38 +++++++++++++++++++++++++++++---- library.json | 2 +- src/types/DialogContent.ts | 3 ++- src/types/Link.ts | 4 ++++ 4 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 src/types/Link.ts diff --git a/.storybook/helpers/h5p.utils.ts b/.storybook/helpers/h5p.utils.ts index 0797c420..c842172d 100644 --- a/.storybook/helpers/h5p.utils.ts +++ b/.storybook/helpers/h5p.utils.ts @@ -17,7 +17,10 @@ export const params: Params = { topicImage: { path: "", alt: "" }, dialog: { hasNote: true, - links: ["https://example.com", "https://example.com/2"], + links: [ + { label: "Example", url: "https://example.com" }, + { label: "Example 2", url: "https://example.com/2" }, + ], }, description: "", }, @@ -37,7 +40,10 @@ export const params: Params = { id: "arrow-1", dialog: { hasNote: true, - links: ["https://example.com", "https://example.com/2"], + links: [ + { label: "Example", url: "https://example.com" }, + { label: "Example 2", url: "https://example.com/2" }, + ], }, arrowType: ArrowType.Directional, startElementId: "box-1", @@ -180,7 +186,19 @@ export const semantics: H5PFieldGroup = { field: { label: "Link", name: "link", - type: H5PFieldType.Text, + type: H5PFieldType.Group, + fields: [ + { + label: "Label", + name: "label", + type: H5PFieldType.Text, + }, + { + label: "Url", + name: "url", + type: H5PFieldType.Text, + }, + ], }, }, ], @@ -318,7 +336,19 @@ export const semantics: H5PFieldGroup = { field: { label: "Link", name: "link", - type: H5PFieldType.Text, + type: H5PFieldType.Group, + fields: [ + { + label: "Label", + name: "label", + type: H5PFieldType.Text, + }, + { + label: "Url", + name: "url", + type: H5PFieldType.Text, + }, + ], }, }, ], diff --git a/library.json b/library.json index 4db9a9f4..62f6fd2e 100644 --- a/library.json +++ b/library.json @@ -3,7 +3,7 @@ "machineName": "H5PEditor.TopicMap", "majorVersion": 0, "minorVersion": 1, - "patchVersion": 47, + "patchVersion": 48, "runnable": 0, "preloadedJs": [ { diff --git a/src/types/DialogContent.ts b/src/types/DialogContent.ts index abe6d837..c554686f 100644 --- a/src/types/DialogContent.ts +++ b/src/types/DialogContent.ts @@ -1,9 +1,10 @@ import { Audio } from "./H5P/Audio"; import { Video } from "./H5P/Video"; +import { Link } from "./Link"; export type DialogContent = { hasNote: boolean; - links?: Array; + links?: Array; text?: string; video?: Video; audio?: { diff --git a/src/types/Link.ts b/src/types/Link.ts new file mode 100644 index 00000000..0f94afdc --- /dev/null +++ b/src/types/Link.ts @@ -0,0 +1,4 @@ +export type Link = { + label: string; + url: string; +};