GlossaryEntryForm.svelte

GlossaryEntryForm.svelte

Create/edit form for glossary entries with 8 collapsible sections covering all 30+ entry fields. Handles validation, save, and post-save event dispatch.

Source: src/lib/components/glossary/GlossaryEntryForm.svelte

Exports

Export Kind Description
GlossaryEntryForm default Svelte component Create/edit form with 8 collapsible sections

Props

Prop Type Required Description
mode 'create' | 'edit' yes Form behavior mode — determines save action and field initialization
entry GlossaryEntry | null no Entry to edit (edit mode); null for create mode
projectSlug string yes Current project slug for API calls
initialTerm string no Pre-populated term value (from context menu "Add to Glossary")

8 Collapsible Sections

Each section is a collapsible accordion. Sections 1 and 2 are open by default; the rest are collapsed.

1. Basic (open by default)

2. Categorization (open by default)

3. Linguistic

4. Scope

5. Examples

6. Visual

7. Marking

8. Relationships

Each relationship field uses a GlossaryTermPicker sub-component:

Save Flow

  1. Validate: term must be non-empty, shortDefinition must be non-empty. If validation fails, display inline error messages and prevent submission.
  2. Build input DTO: In edit mode, build a partial DTO with only changed fields. In create mode, include all fields.
  3. Call store method: glossaryStore.createEntry() for create mode, glossaryStore.updateEntry() for edit mode.
  4. Dispatch event: Emit glossary:entry-saved event via moduleEventBus with the entry ID.
  5. Spellcheck integration: Auto-add invented terms to the spellcheck dictionary after a 2-second delay via dictionaryStore.addWordIfMisspelled() for the term and all aliases.

Sub-components

Component Count Purpose
GlossaryTermPicker x6 Search-and-select for each relationship field
ScopeTreePicker x1 Content scope selection tree for the Scope section

Dependencies

Dependency Type Purpose
glossaryStore internal Create/update entry methods
moduleEventBus internal Dispatch glossary:entry-saved event
dictionaryStore internal Add invented terms to spellcheck dictionary
GlossaryTermPicker child component Relationship field search-and-select
ScopeTreePicker child component Content scope tree selection

Side Effects