@nuasite/cms 0.29.0 → 0.31.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/dist/editor.js +11397 -11351
  2. package/package.json +1 -1
  3. package/src/collection-scanner.ts +87 -25
  4. package/src/editor/components/attribute-editor.tsx +2 -10
  5. package/src/editor/components/bg-image-overlay.tsx +2 -10
  6. package/src/editor/components/collections-browser.tsx +5 -13
  7. package/src/editor/components/color-toolbar.tsx +2 -9
  8. package/src/editor/components/confirm-dialog.tsx +4 -12
  9. package/src/editor/components/create-page-modal.tsx +1 -9
  10. package/src/editor/components/fields.tsx +134 -116
  11. package/src/editor/components/image-overlay.tsx +3 -14
  12. package/src/editor/components/link-edit-popover.tsx +3 -6
  13. package/src/editor/components/markdown-editor-overlay.tsx +31 -37
  14. package/src/editor/components/markdown-inline-editor.tsx +2 -1
  15. package/src/editor/components/mdx-component-picker.tsx +3 -6
  16. package/src/editor/components/media-library.tsx +15 -37
  17. package/src/editor/components/modal-shell.tsx +34 -5
  18. package/src/editor/components/plain-text-chip-utils.ts +14 -0
  19. package/src/editor/components/plain-text-chip.tsx +61 -0
  20. package/src/editor/components/prop-editor.tsx +67 -68
  21. package/src/editor/components/reference-picker.tsx +6 -24
  22. package/src/editor/components/seo-editor.tsx +4 -10
  23. package/src/editor/components/spinner.tsx +17 -0
  24. package/src/editor/components/text-style-toolbar.tsx +2 -15
  25. package/src/editor/components/toolbar.tsx +2 -1
  26. package/src/editor/constants.ts +33 -0
  27. package/src/editor/dom.ts +37 -0
  28. package/src/editor/editor.ts +90 -5
  29. package/src/editor/hooks/index.ts +4 -0
  30. package/src/editor/hooks/useClickOutsideEscape.ts +43 -0
  31. package/src/editor/hooks/useSearchFilter.ts +21 -0
  32. package/src/editor/index.tsx +9 -0
  33. package/src/handlers/source-writer.ts +75 -21
  34. package/src/html-processor.ts +75 -94
  35. package/src/index.ts +5 -0
  36. package/src/rehype-cms-marker.ts +15 -0
  37. package/src/source-finder/ast-extractors.ts +37 -0
  38. package/src/source-finder/cache.ts +23 -0
  39. package/src/source-finder/search-index.ts +304 -13
  40. package/src/source-finder/snippet-utils.ts +179 -2
  41. package/src/source-finder/types.ts +3 -0
  42. package/src/source-finder/variable-extraction.ts +8 -1
@@ -56,6 +56,9 @@ export interface SearchIndexEntry {
56
56
  definitionLine?: number
57
57
  normalizedText: string
58
58
  tag: string
59
+ /** For i18n JSON entries: the dictionary key (e.g., `nav.prague4`). Enables
60
+ * direct lookups when a template expression references the key by literal. */
61
+ translationKey?: string
59
62
  }
60
63
 
61
64
  export interface ImageIndexEntry {
@@ -2,7 +2,7 @@ import { parse as parseBabel } from '@babel/parser'
2
2
  import fs from 'node:fs/promises'
3
3
  import path from 'node:path'
4
4
 
5
- import { extractArrayElements, extractObjectProperties, getStringValue } from './ast-extractors'
5
+ import { extractArrayElements, extractObjectProperties, extractPossibleStringValues, getStringValue } from './ast-extractors'
6
6
  import type { BabelFile, BabelNode, ImportInfo, VariableDefinition } from './types'
7
7
  import { createFrontmatterLineTransformer, identityLine } from './types'
8
8
 
@@ -37,6 +37,13 @@ export function extractVariableDefinitions(ast: BabelFile, frontmatterStartLine:
37
37
  const stringValue = getStringValue(init)
38
38
  if (stringValue !== null) {
39
39
  definitions.push({ name: varName, value: stringValue, line })
40
+ } else if (init.type === 'ConditionalExpression' || init.type === 'LogicalExpression') {
41
+ // One definition per reachable branch — each carries its own
42
+ // literal's line so edits route to the matching branch.
43
+ const branches = extractPossibleStringValues(init, lineTransformer)
44
+ for (const branch of branches) {
45
+ definitions.push({ name: varName, value: branch.value, line: branch.line })
46
+ }
40
47
  }
41
48
 
42
49
  // Object expression - extract properties recursively