@nuasite/cms 0.36.0 → 0.36.1

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.
package/dist/editor.js CHANGED
@@ -381,7 +381,7 @@ function PS(t, e) {
381
381
  function LS(t, e) {
382
382
  return typeof e == "function" ? e(t) : e;
383
383
  }
384
- const o3 = "0.36.0", a3 = o3, nt = {
384
+ const o3 = "0.36.1", a3 = o3, nt = {
385
385
  /** Highlight overlay for hovered elements */
386
386
  HIGHLIGHT: 2147483644,
387
387
  /** Hover outline for elements/components */
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "directory": "packages/astro-cms"
15
15
  },
16
16
  "license": "Apache-2.0",
17
- "version": "0.36.0",
17
+ "version": "0.36.1",
18
18
  "module": "src/index.ts",
19
19
  "types": "src/index.ts",
20
20
  "type": "module",
@@ -23,6 +23,7 @@ import {
23
23
  findTemplateElementUsingStringLiteral,
24
24
  findTranslationByKeyAndText,
25
25
  initializeSearchIndex,
26
+ isTranslationFilePath,
26
27
  } from './search-index'
27
28
  import type { CachedParsedFile, ImageMatch, SourceLocation } from './types'
28
29
 
@@ -502,9 +503,9 @@ async function applyTranslationSource(
502
503
  let resolvedAttributes = attributes
503
504
  let resolvedColorClasses = colorClasses
504
505
 
505
- // When the hit comes from a JSON dictionary, look up the template element
506
+ // When the hit comes from an i18n dictionary, look up the template element
506
507
  // that references the translation key so attr/class edits can target it.
507
- const needsTemplateLookup = indexHit.file.endsWith('.json')
508
+ const needsTemplateLookup = isTranslationFilePath(indexHit.file)
508
509
  && ((attributes && !hasAnySourcePath(attributes)) || (colorClasses && !hasAnySourcePath(colorClasses)))
509
510
 
510
511
  if (needsTemplateLookup && entry.tag) {
@@ -849,14 +850,28 @@ export async function enhanceManifestWithSourceSnippets(
849
850
  }
850
851
 
851
852
  // Missing source info — try the text search index as a last resort.
852
- // Templates that render text through helpers (e.g. `{t(locale, 'key')}`)
853
- // don't get resolved to the originating i18n JSON in the marking phase,
854
- // so the entry arrives here without a sourcePath/sourceLine.
855
- if (!entry.sourceSnippet && entry.text?.trim() && entry.tag && (!entry.sourcePath || !entry.sourceLine)) {
856
- const indexHit = findInTextIndex(entry.text.trim(), entry.tag)
853
+ // Two cases reach here without a sourcePath/sourceLine:
854
+ // (1) text rendered through a translation helper (e.g. `{t(locale, 'key')}`),
855
+ // which the marking phase can't trace to the originating i18n JSON;
856
+ // (2) static template text under runtimes that don't inject
857
+ // `data-astro-source-*` attributes. Only (1) needs the translation
858
+ // treatment (text edits target the JSON, styling disabled); (2) just
859
+ // needs source coordinates so standard snippet extraction below picks
860
+ // up the full element.
861
+ const trimmedEntryText = entry.text?.trim()
862
+ if (!entry.sourceSnippet && trimmedEntryText && entry.tag && (!entry.sourcePath || !entry.sourceLine)) {
863
+ const indexHit = findInTextIndex(trimmedEntryText, entry.tag)
857
864
  if (indexHit) {
858
- const resolved = await applyTranslationSource(entry, indexHit, entry.attributes, entry.colorClasses)
859
- return [id, resolved] as const
865
+ if (isTranslationFilePath(indexHit.file)) {
866
+ const resolved = await applyTranslationSource(entry, indexHit, entry.attributes, entry.colorClasses)
867
+ return [id, resolved] as const
868
+ }
869
+ entry = {
870
+ ...entry,
871
+ sourcePath: indexHit.file,
872
+ sourceLine: indexHit.line,
873
+ ...(indexHit.variableName ? { variableName: indexHit.variableName } : {}),
874
+ }
860
875
  }
861
876
  }
862
877