Cartographer App User and Technical Documentation
Home
User Docs
Technical Docs
Home
User Docs
Technical Docs
  • User Documentation
    • Introduction
    • Getting Started
    • User Interface
    • Actions
  • Technical Documentation
    • GitHub Authentication
    • Components

      • AppFooter Component
      • AppHeader Component
      • AppSidebar Component
      • ContentPreviewMdiv Component
      • Content Preview Measure
      • Content Preview Pane
      • ImageMismatchModal Component
      • ImageSelection Modal
      • LoadGitModal Component
      • LoadIIIFModal Component
      • LoadLocalImage Component
      • LoadXMLModal Component
      • MainMenu Component
      • MeasureModal Component
      • MdivModal Component
      • OsdComponent Component
      • PageImportModal Component
      • PagesListEntry Component
      • PagesModal Component
      • Vuex Store (src/store/index.js)
    • Store
      • Vuex Store (src/store/index.js)
    • Tools
      • IIIF Tools (src/tools/iiif.js)
      • MEI Mapping Tools (src/tools/meiMappings.js)

Vuex Store (src/store/index.js)

Centralized state management for the Cartographer App. This store wires together MEI editing, IIIF ingestion, local image import, GitHub loading, page/zone management, undo/redo history, and UI state.


Overview

  • Framework: Vuex (createStore)
  • External helpers:
    • From @/tools/iiif.js: iiifManifest2mei, checkIiifManifest, getPageArray
    • From @/tools/meiMappings.js: meiZone2annotorious, annotorious2meiZone, measureDetector2meiZone, generateMeasure, insertMeasure, deleteZone, setMultiRest, createNewMdiv, moveContentToMdiv, toggleAdditionalZone, addImportedPage, findZoneInsertionPositionForXmlZone, createAdditionalZone
    • From @/store/constants.js: mode as allowedModes
  • Parsers: DOMParser (XML → DOM), XMLSerializer (DOM → string)
  • Constants: MAX_HISTORY = 50 — maximum number of undo states kept in memory

Module-Level Helpers

formatXml(xmlString)

Formats a serialized XML string with proper two-space indentation. Used by the meiFileForDownload getter so the downloaded MEI file is human-readable.

ParamTypeDescription
xmlStringstringRaw XML string from the serializer

Returns: string — formatted XML with indentation.

saveToHistory(state)

Saves the current xmlDoc to the undo history. Debounced (50 ms) so that multiple mutations occurring together produce a single history entry. If the history pointer is not at the end (i.e. after an undo), all "future" states are discarded before pushing. History is capped at MAX_HISTORY (50) entries.

Every mutation that modifies the MEI document calls this helper before cloning and changing xmlDoc.

getDefaultState()

Returns a fresh copy of the default state object. Used on store creation and by RESET_STATE.


State

KeyTypeDescription
selectedRepoObject | nullCurrently selected GitHub repository
selectedDirectoryObject | nullCurrently selected directory within the repo
directoriesArrayList of directories in the selected repo
reposArray | nullList of available repositories
xmlDocDocument | nullThe loaded MEI XML document (DOM)
currentMdivElement | nullThe current mdiv containing the current measure
nextMdiv / previousMdivElement | nullNeighbouring mdivs (if applicable)
pagesArrayArray of page objects (from MEI, IIIF, or local images)
currentPagenumberIndex of the currently selected page (-1 if none)
historyArray<Document>Snapshots of xmlDoc for undo/redo
historyIndexnumberCurrent position in history
showLoadXMLModalbooleanShow/hide the XML file load modal
showLoadIIIFModalbooleanShow/hide the IIIF manifest load modal
showLoadGitModalbooleanShow/hide the GitHub load modal
showLoadLocalImagebooleanShow/hide the local image load modal
showMeasureModalbooleanShow/hide the measure label/number modal
showMdivModalbooleanShow/hide the movement (mdiv) modal
showPagesModalbooleanShow/hide the page management modal
showPageImportModalbooleanShow/hide the page/image import modal
showMeasureListbooleanShow/hide the measure list panel
showImageMismatchModalbooleanShow/hide the image mismatch warning modal
loadingbooleanApp is currently loading data
processingbooleanApp is currently processing data
logedinbooleanUser is logged in
pageDimensionArray<[number, number]>[width, height] for each page
modestringCurrent editor mode (selection, manualRect, additionalZone, deletion, …)
existingMusicModebooleanTrue if working with existing music content
selectedZoneId / hoveredZoneIdstring | nullxml:id of the selected / hovered zone
currentMdivIdstring | nullxml:id of the currently selected mdiv
currentMeasureIdstring | nullxml:id of the currently selected measure
currentMeasureElement | nullThe current measure object
totalZonesnumberTotal number of zones in the document
deleteZoneIdstring | nullxml:id of the zone to be deleted
annoObject | nullCurrent annotation object (Annotorious)
canvasesArrayIIIF canvases (if loaded)
infoJsonArray<string>IIIF info.json URLs for canvases
importingImagesArrayImages being imported, each with a status
newFirstMeasurestringFirst measure of the old mdiv when creating a new mdiv
oldMdivElement | nullThe mdiv content is being moved from
selectedMdivElement | nullThe mdiv selected in the mdiv modal
insertMdivupbooleanTrue if the new mdiv is inserted before the current one
additionMeasurebooleanTrue while an additional measure is added (prevents recursion)
localImagePagesArrayReferences to local image pages (prevents blob URL garbage collection)
missingImagesArray<string>Image paths referenced in MEI but not found
unreferencedImagesArray<string>Loaded images not referenced in MEI
originalMeiGraphicCountnumberGraphic count of the original MEI, for verification
resultingArrayArrayGeneric array for storing results (usage varies)

Mutations

Mutations synchronously update the state. All mutations that modify the MEI document follow the same pattern: call saveToHistory(state), clone xmlDoc, modify the clone, and commit the clone back to state.xmlDoc.

State & History

MutationDescription
RESET_STATEResets the entire state to its default values
UNDOSteps the history pointer back and restores that xmlDoc snapshot
REDOSteps the history pointer forward and restores that snapshot

Modal & Panel Visibility

MutationDescription
TOGGLE_LOADXML_MODALToggle the XML file load modal
TOGGLE_LOADIIIF_MODALToggle the IIIF manifest load modal
TOGGLE_LOADGIT_MODALToggle the GitHub load modal
TOGGLE_LOADLOCALIMAGE_MODALToggle the local image modal; accepts an optional explicit boolean
TOGGLE_MEASURE_MODALToggle the measure label/number modal
TOGGLE_PAGES_MODALToggle the page management modal
TOGGLE_PAGE_IMPORT_MODALToggle the page/image import modal
TOGGLE_MDIV_MODALToggle the movement (mdiv) modal
TOGGLE_MEASURE_LISTToggle the measure list panel
HIDE_MODALSHide the measure, mdiv, and local-image modals
TOGGLE_IMAGE_MISMATCH_MODALToggle the image mismatch modal
SHOW_IMAGE_MISMATCH_MODALSet the mismatch lists (missing, unreferenced) and show the modal
HIDE_IMAGE_MISMATCH_MODALHide the mismatch modal and clear both lists
SET_IMAGE_MISMATCHESSet the missingImages / unreferencedImages lists

Document & Pages

MutationDescription
SET_XML_DOCSet the loaded MEI document, reset currentPage to 0, and initialize the history with this document
SET_PAGESSet the array of page objects
SET_LOCAL_IMAGE_PAGESStore local image page references (keeps blob URLs alive)
SET_CURRENT_PAGESet the current page index (bounds-checked)
SET_PAGE_LABELSet the label attribute of a specific surface
SET_TOTAL_ZONES_COUNTIncrement the total zone count by a given value
SET_LOADING / SET_PROCESSINGSet the loading / processing flags

Zones

MutationDescription
SELECT_ZONE / HOVER_ZONESet the selected / hovered zone id
CREATE_ZONE_FROM_ANNOTORIOUSCreate a zone from an Annotorious annotation. In standard mode a new measure is created for the zone; in existing-music mode the zone is attached to the first measure without @facs; in additional-zone mode the zone is inserted into the appropriate measure
CREATE_ZONES_FROM_MEASURE_DETECTOR_ON_PAGECreate zones from detected rectangles ({ rects, pageIndex }) and generate/attach measures accordingly
UPDATE_ZONE_FROM_ANNOTORIOUSUpdate an existing zone's coordinates (ulx, uly, lrx, lry) from an annotation
DELETE_ZONEDelete a zone by xml:id
TOGGLE_ADDITIONAL_ZONEToggle a zone's "additional zone" status

Editor Mode & Measures

MutationDescription
SET_MODESet the current editor mode (validated against allowedModes)
TOGGLE_EXISTING_MUSIC_MODEToggle existing-music mode
SET_CURRENT_MEASURE_IDResolve and set the current measure id (accepts a measure id or a zone id via @facs)
SET_CURRENT_MEASURE_LABELSet or remove the label attribute of the current measure
SET_CURRENT_MEASURE_MULTI_RESTSet, update, or remove a multiRest element in the current measure

Movements (mdivs)

MutationDescription
SET_CURRENT_MDIVSet the current mdiv id
SET_CURRENT_MDIV_LABELSet the label attribute of the current mdiv
CREATE_NEW_MDIVCreate a new mdiv and move content (from the current measure onward) into it
SELECT_MDIVMove content to a selected mdiv and update the current mdiv id
CURRENT_MDIV / NEXT_MDIV / PREVIOUS_MDIVSet the current / next / previous mdiv objects

Image Import

MutationDescription
REGISTER_IMAGE_IMPORTRegister an image being imported (status loading)
RECEIVE_IMAGE_IMPORTMark an import as success and store its dimensions
FAILED_IMAGE_IMPORTMark an import as failed
ACCEPT_IMAGE_IMPORTSAdd all successfully imported images as pages to the MEI document and rebuild the page array
CANCEL_IMAGE_IMPORTSDiscard pending imports and hide the import modal

GitHub

MutationDescription
SET_SELECTED_DIRECTORYSet the currently selected directory in the repository
SET_ANNOSet the current annotation object

Actions

Actions perform asynchronous work and coordinate mutations.

Loading & Import

ActionDescription
importXML(mei)Fetches an MEI file, parses it, and dispatches setData
importIIIF(url)Fetches a IIIF manifest, validates it, fetches all info.json files concurrently (Promise.allSettled), stores page dimensions, converts the manifest to MEI via iiifManifest2mei, and dispatches setData
addLocalImagePages(input)Builds a complete MEI document for locally imported images. Loads the standard MEI template (with an inline fallback), creates surface/graphic elements with UUID-based ids for each image, merges zones and body content from an original MEI if one was provided, and verifies that image filenames match the MEI graphic/@target values (by basename). On mismatch, shows the Image Mismatch Modal instead of loading
setData(mei)Sets the MEI document and pages, resets the current page, hides modals, and dispatches verifyImageReferences
verifyImageReferences()Compares MEI graphic/@target basenames against loaded page names; shows the mismatch modal when missing or unreferenced images are found
registerImageImports(urls)Splits a whitespace-separated URL list, registers each image, and fetches its info.json (committing success/failure per image)
acceptImageImports() / cancelImageImports()Commit or discard the pending image imports

Automatic Measure Detection

ActionDescription
autoDetectZonesOnCurrentPage()Fetches the current page image as a blob and POSTs it to the Measure Detector service (https://measure-detector.edirom.de/upload); on success commits CREATE_ZONES_FROM_MEASURE_DETECTOR_ON_PAGE
autoDetectZonesOnAllPage()Runs the same detection for every page

Zones & Measures

ActionDescription
selectZone(id) / hoverZone(id) / unhoverZone(id)Selection and hover handling
clickZone(id)In deletion mode deletes the zone; in additional-zone mode toggles the additional-zone status
createZone(annot) / updateZone(annot) / deleteZone(id)Zone lifecycle from Annotorious annotations
clickMeasureLabel(id) / closeMeasureNumberModal()Open / close the measure modal for a measure
setCurrentMeasureLabel(val) / setCurrentMeasureMultiRest(val)Edit the current measure
setMode(mode) / toggleExistingMusicMode()Editor mode handling

Movements (mdivs)

ActionDescription
createNewMdiv()Create a new mdiv and move content to it
selectMdiv(selectedMdiv)Move content to the selected mdiv
setCurrentMdiv(id) / setCurrentMdivLabel(val)Current mdiv handling
currentMdiv(mdiv) / nextMdiv(mdiv) / previousMdiv(mdiv)Set mdiv navigation objects

UI & Misc

ActionDescription
resetAll()Reset the entire application state
undo() / redo()Step through the document history
toggleLoadXMLModal(), toggleLoadIIIFModal(), toggleLoadLocalImage(), toggleMeasureModal(), togglePagesModal(), togglePageImportModal(), toggleMdivModal(), toggleMeasureList()Modal / panel visibility
closeImageMismatchModal() / cancelImageMismatch()Close the mismatch modal (the latter also closes the local-image modal)
setCurrentPage(i) / setCurrentPageZone(j)Page index / zone count
setPageLabel({ index, val })Page label editing
setDirectory(directory)Set the selected repository directory
fetchDirectories()Fetch directory listings from a GitHub repository (stub — not fully implemented)

Getters

GetterReturns
isReadytrue if an MEI document is loaded
totalZonesTotal number of zones in the document
meiFileForDownloadThe serialized, indented MEI XML string for download (via formatXml), or null
currentPageIndexOneBased / currentPageIndexZeroBasedCurrent page index (1-based / 0-based)
maxPageNumberTotal number of pages
pagesPage objects with tileSource for OpenSeadragon. Local images use { type: 'image', url } tile sources (width/height only included when known); IIIF pages use the info.json URI
pagesDetailedPage objects with tile source, dimensions (dim), page number (n), and label
currentPageObjectThe page object for the current page
zonesOnCurrentPageAnnotorious annotation objects for all zones on the current page except the selected one
measuresAll <measure> elements in the document
mdivsAll mdivs as { id, label, index }
measuresByMdivId(id)Measures of a given mdiv, each with { id, n, label, multiRest, zones, index }
currentMdivThe current mdiv as { id, label, index }, or null
currentMeasureThe current measure as { id, n, label, multiRest, mdiv }, or null
modeThe current editor mode
selectedZoneThe Annotorious annotation for the selected zone, or null
showLoadIIIFModal, showLoadGitModal, showLoadXMLModal, showLoadLocalImage, showMeasureModal, showPagesModal, showPageImportModal, showImageMismatchModal, showMdivModal, showMeasureListModal / panel visibility flags
loadingLoading flag
importingImagesThe array of images currently being imported
readyForImageImporttrue when at least one image is registered and all registered images imported successfully
existingMusicModeExisting-music mode flag
firstMeasureWithoutZonexml:id of the first measure without a zone, or null
canUndo / canRedoWhether an undo / redo step is available

Undo/Redo Behaviour

  • Every document-modifying mutation calls saveToHistory before applying its change, so the history stores the pre-change snapshots plus the state committed via SET_XML_DOC.
  • Saves are debounced by 50 ms: several mutations fired together (e.g. a detector run creating many zones) produce a single undo step.
  • After an undo, committing a new change discards the redo branch.
  • At most 50 states are retained; older ones are dropped.
Prev
PagesModal Component