@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 +1 -1
- package/package.json +1 -1
- package/src/source-finder/snippet-utils.ts +24 -9
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.
|
|
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
|
@@ -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
|
|
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
|
|
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
|
-
//
|
|
853
|
-
//
|
|
854
|
-
//
|
|
855
|
-
|
|
856
|
-
|
|
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
|
-
|
|
859
|
-
|
|
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
|
|