From ed935bb03b37f4e1b0d499f5ab4a8c310a38eb29 Mon Sep 17 00:00:00 2001 From: will wade Date: Tue, 28 Apr 2026 21:45:34 +0100 Subject: [PATCH 1/2] Merge personalisation WordList into Grid 3 Process WordList items attached to a page (from personalisation) and merge them into the existing Grid.WordList.Items.WordListItem array. Checks for a known symbol key ('wordListItems'), handles casing variations of existing items, ensures an array, and appends new items in Grid 3 format (Text.p.s.r, Image as '', PartOfSpeech 'Unknown'). Skips processing if there is no existing WordList.Items to avoid creating new cells. --- src/processors/gridsetProcessor.ts | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/processors/gridsetProcessor.ts b/src/processors/gridsetProcessor.ts index 7c6102b..fb14ae9 100644 --- a/src/processors/gridsetProcessor.ts +++ b/src/processors/gridsetProcessor.ts @@ -2760,6 +2760,40 @@ class GridsetProcessor extends BaseProcessor { } } + // Process WordList items attached to the page (from personalisation) + // These are tracked separately and shouldn't create new cells + // Use a known symbol key to check for WordList items + const WORDLIST_ITEMS_KEY = 'wordListItems'; + const wordListItems = (page as any)[WORDLIST_ITEMS_KEY] as + | Array<{ label: string; message: string }> + | undefined; + + if (wordListItems && wordListItems.length > 0 && originalGrid.Grid?.WordList?.Items) { + const existingItems = + originalGrid.Grid.WordList.Items.WordListItem || + originalGrid.Grid.WordList.Items.wordlistitem || + []; + const itemsArray = Array.isArray(existingItems) ? existingItems : [existingItems]; + + // Add new WordList items with proper Grid 3 format + for (const item of wordListItems) { + itemsArray.push({ + Text: { + p: { + s: { + r: item.label, + }, + }, + }, + Image: '', + PartOfSpeech: 'Unknown', + }); + } + + // Update the WordList + originalGrid.Grid.WordList.Items.WordListItem = itemsArray; + } + // Build the updated grid XML and format for Grid 3 compatibility let builtXml = gridBuilder.build(originalGrid); builtXml = formatGrid3XmlComplete(builtXml); From 9b3c525ddde1bac4a6f7094b4db21b592508a92a Mon Sep 17 00:00:00 2001 From: will wade Date: Wed, 29 Apr 2026 00:17:47 +0100 Subject: [PATCH 2/2] fix: Ensure WordList structure exists before adding items When personalizing vocabularies with WordList items, the code was checking if originalGrid.Grid.WordList.Items existed before adding items. If the original page didn't have a WordList, items would not be added. This change ensures the WordList structure is created if it doesn't exist, allowing personalization items to be added to pages without existing WordLists. --- src/processors/gridsetProcessor.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/processors/gridsetProcessor.ts b/src/processors/gridsetProcessor.ts index fb14ae9..75e582a 100644 --- a/src/processors/gridsetProcessor.ts +++ b/src/processors/gridsetProcessor.ts @@ -2768,7 +2768,18 @@ class GridsetProcessor extends BaseProcessor { | Array<{ label: string; message: string }> | undefined; - if (wordListItems && wordListItems.length > 0 && originalGrid.Grid?.WordList?.Items) { + if (wordListItems && wordListItems.length > 0) { + // Ensure WordList structure exists + if (!originalGrid.Grid) { + originalGrid.Grid = {}; + } + if (!originalGrid.Grid.WordList) { + originalGrid.Grid.WordList = {}; + } + if (!originalGrid.Grid.WordList.Items) { + originalGrid.Grid.WordList.Items = {}; + } + const existingItems = originalGrid.Grid.WordList.Items.WordListItem || originalGrid.Grid.WordList.Items.wordlistitem ||