sanity-plugin-seo-copilot 0.2.11 → 0.2.13
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/index.js +206 -181
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +206 -181
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/KeywordPanel.tsx +190 -176
- package/src/components/SEOCopilotPanel.tsx +29 -9
- package/src/components/ShimmerLoader.tsx +4 -4
- package/src/components/styles.ts +7 -0
- package/src/components/tabs/AEOTab.tsx +3 -1
- package/src/hooks/useKeywordAnalysis.ts +8 -7
- package/src/lib/api.ts +3 -50
- package/src/lib/summary.ts +4 -4
package/dist/index.mjs
CHANGED
|
@@ -268,16 +268,15 @@ function safeParseJson(text) {
|
|
|
268
268
|
throw new Error("Invalid JSON response from server");
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
|
-
async function fetchAnalysis(apiUrl, content, mode, publication, seedKeywords, documentFields, focusKeyword, signal) {
|
|
271
|
+
async function fetchAnalysis(apiUrl, content, mode, publication, seedKeywords, documentFields, focusKeyword, secondaryKeyword, signal) {
|
|
272
272
|
const response = await fetch(`${apiUrl}/api/seo-copilot/analyze`, {
|
|
273
273
|
method: "POST",
|
|
274
274
|
headers: { "Content-Type": "application/json" },
|
|
275
|
-
body: JSON.stringify({ content, mode, publication, seedKeywords, documentFields, focusKeyword }),
|
|
275
|
+
body: JSON.stringify({ content, mode, publication, seedKeywords, documentFields, focusKeyword, secondaryKeyword }),
|
|
276
276
|
signal
|
|
277
277
|
});
|
|
278
278
|
const text = await response.text();
|
|
279
279
|
if (!response.ok) {
|
|
280
|
-
const err = safeParseJson(text);
|
|
281
280
|
if (response.status === 429) throw new Error("Analysis service is busy. Please try again.");
|
|
282
281
|
if (response.status >= 500) throw new Error("Could not reach the SEO service.");
|
|
283
282
|
throw new Error("Something went wrong analyzing this document.");
|
|
@@ -292,7 +291,6 @@ async function fetchChatStream(apiUrl, messages, documentContext, publication, k
|
|
|
292
291
|
signal
|
|
293
292
|
});
|
|
294
293
|
if (!response.ok) {
|
|
295
|
-
const err = await response.json().catch(() => ({ error: "Request failed" }));
|
|
296
294
|
if (response.status === 429) throw new Error("Analysis service is busy. Please try again.");
|
|
297
295
|
if (response.status >= 500) throw new Error("Could not reach the SEO service.");
|
|
298
296
|
throw new Error("Something went wrong. Please try again.");
|
|
@@ -314,7 +312,6 @@ async function lookupKeywords(apiUrl, keywords, signal) {
|
|
|
314
312
|
signal
|
|
315
313
|
});
|
|
316
314
|
if (!response.ok) {
|
|
317
|
-
const err = await response.json().catch(() => ({ error: "Request failed" }));
|
|
318
315
|
if (response.status === 429) throw new Error("Analysis service is busy. Please try again.");
|
|
319
316
|
if (response.status >= 500) throw new Error("Could not reach the SEO service.");
|
|
320
317
|
throw new Error("Something went wrong. Please try again.");
|
|
@@ -427,7 +424,7 @@ function mergeVolumes(analysis, volumeMap) {
|
|
|
427
424
|
});
|
|
428
425
|
return updated;
|
|
429
426
|
}
|
|
430
|
-
function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFields, focusPrimary, documentId) {
|
|
427
|
+
function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFields, focusPrimary, documentId, focusSecondary) {
|
|
431
428
|
const cacheKey = documentId ? `seo-copilot-cache-${documentId}` : "seo-copilot-cache-v2";
|
|
432
429
|
const loadCached = useCallback(() => {
|
|
433
430
|
try {
|
|
@@ -480,7 +477,7 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
|
|
|
480
477
|
localStorage.setItem(cacheKey, JSON.stringify({ ...prev, analysis: withVolumes }));
|
|
481
478
|
} catch {
|
|
482
479
|
}
|
|
483
|
-
}, [cacheKey]);
|
|
480
|
+
}, [cacheKey, loadCached]);
|
|
484
481
|
const setDeepAnalysis = useCallback((val) => {
|
|
485
482
|
setDeepAnalysisRaw(val);
|
|
486
483
|
try {
|
|
@@ -488,7 +485,7 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
|
|
|
488
485
|
localStorage.setItem(cacheKey, JSON.stringify({ ...prev, deepAnalysis: val }));
|
|
489
486
|
} catch {
|
|
490
487
|
}
|
|
491
|
-
}, [cacheKey]);
|
|
488
|
+
}, [cacheKey, loadCached]);
|
|
492
489
|
const effectiveSeeds = seedKeywords;
|
|
493
490
|
useEffect2(() => {
|
|
494
491
|
if (deepAnalysis && aeoTextSnapshot && text !== aeoTextSnapshot) {
|
|
@@ -556,7 +553,7 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
|
|
|
556
553
|
const controller = new AbortController();
|
|
557
554
|
setIsLoading(true);
|
|
558
555
|
setError(null);
|
|
559
|
-
fetchAnalysis(apiUrl, text, "realtime", publication, effectiveSeeds, documentFields, focusPrimary, controller.signal).then((result) => {
|
|
556
|
+
fetchAnalysis(apiUrl, text, "realtime", publication, effectiveSeeds, documentFields, focusPrimary, focusSecondary, controller.signal).then((result) => {
|
|
560
557
|
if (cancelled) return;
|
|
561
558
|
const analysisResult = result;
|
|
562
559
|
lastAnalysisRef.current = analysisResult;
|
|
@@ -586,7 +583,7 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
|
|
|
586
583
|
cancelled = true;
|
|
587
584
|
controller.abort();
|
|
588
585
|
};
|
|
589
|
-
}, [text, apiUrl, publication, effectiveSeeds?.join(","), focusPrimary, JSON.stringify(documentFields)]);
|
|
586
|
+
}, [text, apiUrl, publication, effectiveSeeds?.join(","), focusPrimary, focusSecondary, JSON.stringify(documentFields)]);
|
|
590
587
|
const refreshVolumes = useCallback(() => {
|
|
591
588
|
const current = lastAnalysisRef.current || analysis;
|
|
592
589
|
if (!current) return;
|
|
@@ -602,7 +599,7 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
|
|
|
602
599
|
deepAbortRef.current?.abort();
|
|
603
600
|
const deepController = new AbortController();
|
|
604
601
|
deepAbortRef.current = deepController;
|
|
605
|
-
fetchAnalysis(apiUrl, text, "deep", publication, effectiveSeeds, documentFields, focusPrimary, deepController.signal).then((result) => {
|
|
602
|
+
fetchAnalysis(apiUrl, text, "deep", publication, effectiveSeeds, documentFields, focusPrimary, focusSecondary, deepController.signal).then((result) => {
|
|
606
603
|
if (docVersionRef.current !== myVersion) return;
|
|
607
604
|
setDeepAnalysis(result);
|
|
608
605
|
setIsDeepLoading(false);
|
|
@@ -612,7 +609,7 @@ function useKeywordAnalysis(text, apiUrl, publication, seedKeywords, documentFie
|
|
|
612
609
|
setError(err.message);
|
|
613
610
|
setIsDeepLoading(false);
|
|
614
611
|
});
|
|
615
|
-
}, [text, apiUrl, publication, effectiveSeeds?.join(","), documentFields, focusPrimary]);
|
|
612
|
+
}, [text, apiUrl, publication, effectiveSeeds?.join(","), documentFields, focusPrimary, focusSecondary]);
|
|
616
613
|
return {
|
|
617
614
|
analysis,
|
|
618
615
|
isLoading,
|
|
@@ -957,6 +954,13 @@ var INJECTED_CSS = `
|
|
|
957
954
|
from { opacity: 1; transform: translateY(0) scale(1); }
|
|
958
955
|
to { opacity: 0; transform: translateY(-6px) scale(0.97); }
|
|
959
956
|
}
|
|
957
|
+
@keyframes seo-copilot-sec-float {
|
|
958
|
+
0%, 100% { transform: translateY(0); }
|
|
959
|
+
50% { transform: translateY(-1.5px); }
|
|
960
|
+
}
|
|
961
|
+
@media (prefers-reduced-motion: reduce) {
|
|
962
|
+
.seo-copilot-sec-circle { animation: none !important; }
|
|
963
|
+
}
|
|
960
964
|
.prose-chat { font-size: 12.5px; line-height: 1.65; color: #475569; font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif; }
|
|
961
965
|
.prose-chat h1 { font-size: 14px; font-weight: 700; color: #1e293b; margin: 10px 0 5px 0; line-height: 1.35; }
|
|
962
966
|
.prose-chat h2, .prose-chat h3 { font-size: 13px; font-weight: 700; color: #1e293b; margin: 10px 0 5px 0; line-height: 1.35; }
|
|
@@ -1706,119 +1710,6 @@ function PrimaryKeywordSelector({
|
|
|
1706
1710
|
}) })
|
|
1707
1711
|
] });
|
|
1708
1712
|
}
|
|
1709
|
-
function SecondaryKeywordSelector({
|
|
1710
|
-
options,
|
|
1711
|
-
selectedTerm,
|
|
1712
|
-
onSelect
|
|
1713
|
-
}) {
|
|
1714
|
-
const [customInputOpen, setCustomInputOpen] = useState8(false);
|
|
1715
|
-
const [customValue, setCustomValue] = useState8("");
|
|
1716
|
-
const handleCustomSubmit = () => {
|
|
1717
|
-
const trimmed = customValue.trim();
|
|
1718
|
-
if (trimmed) {
|
|
1719
|
-
onSelect(trimmed);
|
|
1720
|
-
setCustomValue("");
|
|
1721
|
-
setCustomInputOpen(false);
|
|
1722
|
-
}
|
|
1723
|
-
};
|
|
1724
|
-
const opts = selectedTerm && !options.some((o) => o.term.toLowerCase() === selectedTerm.toLowerCase()) ? [...options, { term: selectedTerm, volume: null }] : options;
|
|
1725
|
-
return /* @__PURE__ */ jsxs4("div", { style: cardStyle, children: [
|
|
1726
|
-
/* @__PURE__ */ jsx5(
|
|
1727
|
-
SectionHeader,
|
|
1728
|
-
{
|
|
1729
|
-
label: "Secondary Keyword",
|
|
1730
|
-
iconColor: MJH_BLUE,
|
|
1731
|
-
actionButton: /* @__PURE__ */ jsxs4("div", { style: { display: "flex", alignItems: "center", gap: 6 }, children: [
|
|
1732
|
-
/* @__PURE__ */ jsx5("span", { style: { fontSize: 9, fontWeight: 700, letterSpacing: "0.05em", textTransform: "uppercase", color: "#9ca3af" }, children: "Optional" }),
|
|
1733
|
-
/* @__PURE__ */ jsx5(PencilButton, { onClick: () => setCustomInputOpen(!customInputOpen), active: customInputOpen })
|
|
1734
|
-
] })
|
|
1735
|
-
}
|
|
1736
|
-
),
|
|
1737
|
-
/* @__PURE__ */ jsx5("div", { style: { fontSize: 11, color: "#4b5563", lineHeight: 1.5, marginBottom: 8 }, children: "Pick one more keyword to optimize for. Copilot then checks your title, meta, URL, headings, and images against both keywords." }),
|
|
1738
|
-
customInputOpen && /* @__PURE__ */ jsxs4("div", { style: { marginBottom: 8, display: "flex", gap: 6 }, children: [
|
|
1739
|
-
/* @__PURE__ */ jsx5(
|
|
1740
|
-
"input",
|
|
1741
|
-
{
|
|
1742
|
-
type: "text",
|
|
1743
|
-
value: customValue,
|
|
1744
|
-
onChange: (e) => setCustomValue(e.target.value),
|
|
1745
|
-
onKeyDown: (e) => {
|
|
1746
|
-
if (e.key === "Enter") handleCustomSubmit();
|
|
1747
|
-
},
|
|
1748
|
-
placeholder: "Type a custom secondary keyword",
|
|
1749
|
-
autoFocus: true,
|
|
1750
|
-
style: { flex: 1, padding: "5px 8px", fontSize: 12, borderRadius: 8, border: "1px solid #e5e7eb", outline: "none", fontFamily: "inherit" }
|
|
1751
|
-
}
|
|
1752
|
-
),
|
|
1753
|
-
/* @__PURE__ */ jsx5(
|
|
1754
|
-
"button",
|
|
1755
|
-
{
|
|
1756
|
-
onClick: handleCustomSubmit,
|
|
1757
|
-
disabled: !customValue.trim(),
|
|
1758
|
-
style: {
|
|
1759
|
-
padding: "5px 10px",
|
|
1760
|
-
fontSize: 11,
|
|
1761
|
-
fontWeight: 600,
|
|
1762
|
-
borderRadius: 6,
|
|
1763
|
-
border: "none",
|
|
1764
|
-
background: customValue.trim() ? MJH_BLUE : "#e5e7eb",
|
|
1765
|
-
color: customValue.trim() ? "#ffffff" : "#9ca3af",
|
|
1766
|
-
cursor: customValue.trim() ? "pointer" : "not-allowed"
|
|
1767
|
-
},
|
|
1768
|
-
children: "Set"
|
|
1769
|
-
}
|
|
1770
|
-
)
|
|
1771
|
-
] }),
|
|
1772
|
-
/* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column", gap: 6 }, children: [
|
|
1773
|
-
/* @__PURE__ */ jsx5(SecondaryOptionRow, { term: "", label: "None", selected: !selectedTerm, onSelect: () => onSelect("") }),
|
|
1774
|
-
opts.map((o) => /* @__PURE__ */ jsx5(
|
|
1775
|
-
SecondaryOptionRow,
|
|
1776
|
-
{
|
|
1777
|
-
term: o.term,
|
|
1778
|
-
label: o.term,
|
|
1779
|
-
volume: o.volume,
|
|
1780
|
-
selected: o.term === selectedTerm,
|
|
1781
|
-
onSelect: () => onSelect(o.term)
|
|
1782
|
-
},
|
|
1783
|
-
o.term
|
|
1784
|
-
))
|
|
1785
|
-
] })
|
|
1786
|
-
] });
|
|
1787
|
-
}
|
|
1788
|
-
function SecondaryOptionRow({ term, label, volume, selected, onSelect }) {
|
|
1789
|
-
return /* @__PURE__ */ jsxs4(
|
|
1790
|
-
"div",
|
|
1791
|
-
{
|
|
1792
|
-
onClick: onSelect,
|
|
1793
|
-
style: {
|
|
1794
|
-
display: "flex",
|
|
1795
|
-
alignItems: "center",
|
|
1796
|
-
gap: 8,
|
|
1797
|
-
padding: "6px 8px",
|
|
1798
|
-
borderRadius: 8,
|
|
1799
|
-
cursor: "pointer",
|
|
1800
|
-
background: selected ? "rgba(0,93,172,0.06)" : "transparent",
|
|
1801
|
-
border: selected ? "1px solid rgba(0,93,172,0.2)" : "1px solid transparent",
|
|
1802
|
-
transition: "all 150ms"
|
|
1803
|
-
},
|
|
1804
|
-
children: [
|
|
1805
|
-
/* @__PURE__ */ jsx5("div", { style: {
|
|
1806
|
-
width: 14,
|
|
1807
|
-
height: 14,
|
|
1808
|
-
borderRadius: "50%",
|
|
1809
|
-
border: selected ? "none" : "2px solid #d1d5db",
|
|
1810
|
-
background: selected ? MJH_BLUE : "transparent",
|
|
1811
|
-
flexShrink: 0,
|
|
1812
|
-
display: "flex",
|
|
1813
|
-
alignItems: "center",
|
|
1814
|
-
justifyContent: "center"
|
|
1815
|
-
}, children: selected && /* @__PURE__ */ jsx5("div", { style: { width: 6, height: 6, borderRadius: "50%", background: "#ffffff" } }) }),
|
|
1816
|
-
/* @__PURE__ */ jsx5("span", { style: { fontSize: 12, fontWeight: selected ? 600 : 400, color: term ? selected ? "#00468a" : "#374151" : "#6b7280", flex: 1, minWidth: 0 }, children: label }),
|
|
1817
|
-
volume != null && /* @__PURE__ */ jsx5("span", { style: { fontSize: 11, fontWeight: 600, color: "#1f2937" }, children: volume === 0 ? "N/A" : `${abbrevVol(volume)}/mo` })
|
|
1818
|
-
]
|
|
1819
|
-
}
|
|
1820
|
-
);
|
|
1821
|
-
}
|
|
1822
1713
|
var PLACEMENT_FILTERS = [
|
|
1823
1714
|
{ key: "inBody", label: "Body", letter: "B" },
|
|
1824
1715
|
{ key: "inTitle", label: "Title", letter: "T" },
|
|
@@ -1837,6 +1728,8 @@ function computePlacementClient(term, content, fields) {
|
|
|
1837
1728
|
inUrl: fields?.slug?.toLowerCase().includes(lower) ?? false
|
|
1838
1729
|
};
|
|
1839
1730
|
}
|
|
1731
|
+
var SECONDARY_PURPLE = "#9B59B6";
|
|
1732
|
+
var SECONDARY_PURPLE_TEXT = "#7D3C98";
|
|
1840
1733
|
function SuggestedKeywordsCard({
|
|
1841
1734
|
keywords,
|
|
1842
1735
|
text,
|
|
@@ -1845,7 +1738,10 @@ function SuggestedKeywordsCard({
|
|
|
1845
1738
|
documentFields,
|
|
1846
1739
|
refreshVolumes,
|
|
1847
1740
|
isVolumesLoading,
|
|
1848
|
-
documentId
|
|
1741
|
+
documentId,
|
|
1742
|
+
secondaryKeyword,
|
|
1743
|
+
onSelectSecondary,
|
|
1744
|
+
primaryTerm
|
|
1849
1745
|
}) {
|
|
1850
1746
|
const docScope = documentId || "default";
|
|
1851
1747
|
const [helpData, setHelpData] = usePersistentState(
|
|
@@ -1866,6 +1762,11 @@ function SuggestedKeywordsCard({
|
|
|
1866
1762
|
[]
|
|
1867
1763
|
);
|
|
1868
1764
|
const [isGeneratingMore, setIsGeneratingMore] = useState8(false);
|
|
1765
|
+
const [secSelecting, setSecSelecting] = useState8(false);
|
|
1766
|
+
const startSecSelecting = () => {
|
|
1767
|
+
setExpanded(true);
|
|
1768
|
+
setSecSelecting(true);
|
|
1769
|
+
};
|
|
1869
1770
|
const [sortAsc, setSortAsc] = usePersistentState("seo-copilot-ui-keywords-sort-asc", false);
|
|
1870
1771
|
const filtersKey = `seo-copilot-ui-keywords-filters-${docScope}`;
|
|
1871
1772
|
const [activeFilters, setActiveFiltersRaw] = useState8(
|
|
@@ -1992,10 +1893,18 @@ function SuggestedKeywordsCard({
|
|
|
1992
1893
|
if (pA !== pB) return pB - pA;
|
|
1993
1894
|
return b.volume - a.volume;
|
|
1994
1895
|
});
|
|
1995
|
-
const
|
|
1896
|
+
const merged = [...sorted, ...extraKeywords.filter((ek) => !sorted.some((s) => s.term.toLowerCase() === ek.term.toLowerCase()))];
|
|
1897
|
+
const hasVol = (k) => k.volume != null && k.volume > 0;
|
|
1898
|
+
const withVol = merged.filter(hasVol);
|
|
1899
|
+
const allKeywords = isVolumesLoading || withVol.length === 0 ? merged : withVol;
|
|
1996
1900
|
const visible = expanded ? allKeywords : allKeywords.slice(0, INITIAL_SHOW);
|
|
1997
1901
|
const hiddenCount = allKeywords.length - INITIAL_SHOW;
|
|
1998
1902
|
const missingCount = keywords.filter((kw) => !kw.inContent).length;
|
|
1903
|
+
const secLower = (secondaryKeyword || "").toLowerCase();
|
|
1904
|
+
const primaryLower = (primaryTerm || "").toLowerCase();
|
|
1905
|
+
const isSecondaryRow = (term) => secLower !== "" && term.toLowerCase() === secLower;
|
|
1906
|
+
const isPrimaryRow = (term) => primaryLower !== "" && term.toLowerCase() === primaryLower;
|
|
1907
|
+
const secondaryInList = secLower !== "" && allKeywords.some((k) => k.term.toLowerCase() === secLower);
|
|
1999
1908
|
const generateMoreKeywords = async () => {
|
|
2000
1909
|
setIsGeneratingMore(true);
|
|
2001
1910
|
try {
|
|
@@ -2018,7 +1927,15 @@ function SuggestedKeywordsCard({
|
|
|
2018
1927
|
}
|
|
2019
1928
|
setIsGeneratingMore(false);
|
|
2020
1929
|
};
|
|
2021
|
-
|
|
1930
|
+
const didBackfillRef = useRef7(false);
|
|
1931
|
+
useEffect6(() => {
|
|
1932
|
+
if (didBackfillRef.current) return;
|
|
1933
|
+
if (isVolumesLoading || isGeneratingMore || keywords.length === 0) return;
|
|
1934
|
+
didBackfillRef.current = true;
|
|
1935
|
+
const volCount = [...keywords, ...extraKeywords].filter((k) => k.volume != null && k.volume > 0).length;
|
|
1936
|
+
if (volCount < 8) generateMoreKeywords();
|
|
1937
|
+
}, [keywords, isVolumesLoading]);
|
|
1938
|
+
return /* @__PURE__ */ jsxs4("div", { style: secSelecting ? { ...cardStyle, border: `1.5px solid ${SECONDARY_PURPLE}`, boxShadow: [cardStyle.boxShadow, `0 0 0 1px rgba(155,89,182,0.25)`].filter(Boolean).join(", ") } : cardStyle, children: [
|
|
2022
1939
|
/* @__PURE__ */ jsxs4("div", { style: { display: "flex", alignItems: "center", gap: 6, marginBottom: 8 }, children: [
|
|
2023
1940
|
/* @__PURE__ */ jsx5("div", { style: { width: 6, height: 6, borderRadius: "50%", background: MJH_BLUE, flexShrink: 0 } }),
|
|
2024
1941
|
/* @__PURE__ */ jsx5("span", { style: { fontSize: 10, textTransform: "uppercase", letterSpacing: "0.05em", color: "#4b5563", fontWeight: 600, flex: 1 }, children: "Supporting Keywords" }),
|
|
@@ -2173,6 +2090,86 @@ function SuggestedKeywordsCard({
|
|
|
2173
2090
|
] }),
|
|
2174
2091
|
/* @__PURE__ */ jsx5(PencilButton, { onClick: () => setManualInputOpen(!manualInputOpen), active: manualInputOpen })
|
|
2175
2092
|
] }),
|
|
2093
|
+
/* @__PURE__ */ jsx5("span", { "aria-live": "polite", style: { position: "absolute", width: 1, height: 1, padding: 0, margin: -1, overflow: "hidden", clip: "rect(0 0 0 0)", whiteSpace: "nowrap", border: 0 }, children: secSelecting ? "Selection mode on. Pick a keyword below to set it as the secondary keyword." : "" }),
|
|
2094
|
+
onSelectSecondary && (secSelecting ? /* @__PURE__ */ jsxs4("div", { style: {
|
|
2095
|
+
display: "flex",
|
|
2096
|
+
alignItems: "center",
|
|
2097
|
+
justifyContent: "space-between",
|
|
2098
|
+
gap: 8,
|
|
2099
|
+
marginBottom: 8,
|
|
2100
|
+
padding: "5px 10px",
|
|
2101
|
+
borderRadius: 8,
|
|
2102
|
+
background: "rgba(155,89,182,0.08)",
|
|
2103
|
+
border: `1px solid rgba(155,89,182,0.35)`
|
|
2104
|
+
}, children: [
|
|
2105
|
+
/* @__PURE__ */ jsx5("span", { style: { fontSize: 11, fontWeight: 600, color: SECONDARY_PURPLE_TEXT }, children: "Pick a keyword below to set as secondary." }),
|
|
2106
|
+
/* @__PURE__ */ jsx5(
|
|
2107
|
+
"button",
|
|
2108
|
+
{
|
|
2109
|
+
onClick: () => setSecSelecting(false),
|
|
2110
|
+
style: { background: "none", border: "none", cursor: "pointer", fontSize: 11, fontWeight: 600, color: "#6b7280", padding: 2, fontFamily: "inherit" },
|
|
2111
|
+
children: "Cancel"
|
|
2112
|
+
}
|
|
2113
|
+
)
|
|
2114
|
+
] }) : secondaryKeyword ? /* @__PURE__ */ jsxs4("div", { style: {
|
|
2115
|
+
display: "flex",
|
|
2116
|
+
alignItems: "center",
|
|
2117
|
+
gap: 8,
|
|
2118
|
+
marginBottom: 8,
|
|
2119
|
+
padding: "5px 10px",
|
|
2120
|
+
borderRadius: 8,
|
|
2121
|
+
background: "rgba(155,89,182,0.08)",
|
|
2122
|
+
border: `1px solid rgba(155,89,182,0.35)`
|
|
2123
|
+
}, children: [
|
|
2124
|
+
/* @__PURE__ */ jsx5("div", { style: { width: 8, height: 8, borderRadius: "50%", background: SECONDARY_PURPLE, flexShrink: 0 } }),
|
|
2125
|
+
/* @__PURE__ */ jsxs4("span", { style: { fontSize: 11, fontWeight: 600, color: SECONDARY_PURPLE_TEXT, flex: 1, minWidth: 0, overflow: "hidden", textOverflow: "ellipsis", whiteSpace: "nowrap" }, children: [
|
|
2126
|
+
"Secondary: ",
|
|
2127
|
+
secondaryKeyword
|
|
2128
|
+
] }),
|
|
2129
|
+
!secondaryInList && /* @__PURE__ */ jsx5("span", { title: "This keyword is no longer in the list below - re-pick or clear it.", style: { fontSize: 9.5, fontWeight: 600, fontStyle: "italic", color: "#9ca3af", flexShrink: 0 }, children: "not in list" }),
|
|
2130
|
+
/* @__PURE__ */ jsx5(
|
|
2131
|
+
"button",
|
|
2132
|
+
{
|
|
2133
|
+
onClick: startSecSelecting,
|
|
2134
|
+
style: { background: "none", border: "none", cursor: "pointer", fontSize: 11, fontWeight: 600, color: SECONDARY_PURPLE_TEXT, padding: 2, fontFamily: "inherit" },
|
|
2135
|
+
children: "Change"
|
|
2136
|
+
}
|
|
2137
|
+
),
|
|
2138
|
+
/* @__PURE__ */ jsx5(
|
|
2139
|
+
"button",
|
|
2140
|
+
{
|
|
2141
|
+
onClick: () => onSelectSecondary(""),
|
|
2142
|
+
title: "Clear secondary keyword",
|
|
2143
|
+
"aria-label": "Clear secondary keyword",
|
|
2144
|
+
style: { background: "none", border: "none", cursor: "pointer", fontSize: 14, lineHeight: 1, color: "#9ca3af", padding: 2, fontFamily: "inherit" },
|
|
2145
|
+
children: "\xD7"
|
|
2146
|
+
}
|
|
2147
|
+
)
|
|
2148
|
+
] }) : /* @__PURE__ */ jsxs4(
|
|
2149
|
+
"button",
|
|
2150
|
+
{
|
|
2151
|
+
onClick: startSecSelecting,
|
|
2152
|
+
style: {
|
|
2153
|
+
display: "inline-flex",
|
|
2154
|
+
alignItems: "center",
|
|
2155
|
+
gap: 6,
|
|
2156
|
+
marginBottom: 8,
|
|
2157
|
+
padding: "4px 10px",
|
|
2158
|
+
borderRadius: 8,
|
|
2159
|
+
cursor: "pointer",
|
|
2160
|
+
background: "rgba(155,89,182,0.08)",
|
|
2161
|
+
border: `1px solid rgba(155,89,182,0.4)`,
|
|
2162
|
+
color: SECONDARY_PURPLE_TEXT,
|
|
2163
|
+
fontSize: 11,
|
|
2164
|
+
fontWeight: 600,
|
|
2165
|
+
fontFamily: "inherit"
|
|
2166
|
+
},
|
|
2167
|
+
children: [
|
|
2168
|
+
/* @__PURE__ */ jsx5("div", { style: { width: 11, height: 11, borderRadius: "50%", border: `2px solid ${SECONDARY_PURPLE}`, flexShrink: 0 } }),
|
|
2169
|
+
"Click to choose a secondary keyword."
|
|
2170
|
+
]
|
|
2171
|
+
}
|
|
2172
|
+
)),
|
|
2176
2173
|
manualInputOpen && /* @__PURE__ */ jsxs4("div", { style: { marginBottom: 8, display: "flex", gap: 6 }, children: [
|
|
2177
2174
|
/* @__PURE__ */ jsx5(
|
|
2178
2175
|
"input",
|
|
@@ -2216,14 +2213,46 @@ function SuggestedKeywordsCard({
|
|
|
2216
2213
|
borderBottom: i < visible.length - 1 ? "1px solid #f3f4f6" : "none",
|
|
2217
2214
|
minHeight: 28
|
|
2218
2215
|
}, children: [
|
|
2219
|
-
|
|
2216
|
+
secSelecting && onSelectSecondary ? isPrimaryRow(kw.term) ? (
|
|
2217
|
+
// The active primary keyword cannot also be the secondary - show a muted,
|
|
2218
|
+
// non-selectable marker instead of a pickable circle.
|
|
2219
|
+
/* @__PURE__ */ jsx5("div", { title: "Already your primary keyword", style: { width: 14, height: 14, borderRadius: "50%", flexShrink: 0, border: "2px solid #e5e7eb", background: "transparent" } })
|
|
2220
|
+
) : /* @__PURE__ */ jsx5(
|
|
2221
|
+
"button",
|
|
2222
|
+
{
|
|
2223
|
+
className: "seo-copilot-sec-circle",
|
|
2224
|
+
onClick: () => {
|
|
2225
|
+
onSelectSecondary(kw.term);
|
|
2226
|
+
setSecSelecting(false);
|
|
2227
|
+
},
|
|
2228
|
+
"aria-label": `Set ${kw.term} as the secondary keyword`,
|
|
2229
|
+
title: `Set "${kw.term}" as the secondary keyword`,
|
|
2230
|
+
style: {
|
|
2231
|
+
width: 14,
|
|
2232
|
+
height: 14,
|
|
2233
|
+
borderRadius: "50%",
|
|
2234
|
+
flexShrink: 0,
|
|
2235
|
+
padding: 0,
|
|
2236
|
+
border: `2px solid ${SECONDARY_PURPLE}`,
|
|
2237
|
+
background: "transparent",
|
|
2238
|
+
cursor: "pointer",
|
|
2239
|
+
animation: "seo-copilot-sec-float 1.8s ease-in-out infinite",
|
|
2240
|
+
animationDelay: `${i % 5 * 0.12}s`
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
) : isSecondaryRow(kw.term) ? /* @__PURE__ */ jsx5("div", { style: { width: 8, height: 8, borderRadius: "50%", background: SECONDARY_PURPLE, flexShrink: 0 } }) : secondaryKeyword ? /* @__PURE__ */ jsx5("div", { style: { width: 8, height: 8, flexShrink: 0 } }) : /* @__PURE__ */ jsx5("div", { style: {
|
|
2220
2244
|
width: 8,
|
|
2221
2245
|
height: 8,
|
|
2222
2246
|
borderRadius: "50%",
|
|
2223
2247
|
flexShrink: 0,
|
|
2224
2248
|
background: kw.inContent ? "#16a34a" : "#d1d5db"
|
|
2225
2249
|
} }),
|
|
2226
|
-
/* @__PURE__ */ jsx5("span", { style: {
|
|
2250
|
+
/* @__PURE__ */ jsx5("span", { style: {
|
|
2251
|
+
fontSize: 12,
|
|
2252
|
+
fontWeight: isSecondaryRow(kw.term) ? 700 : kw.inContent ? 500 : 600,
|
|
2253
|
+
flexGrow: 1,
|
|
2254
|
+
color: !secSelecting && isSecondaryRow(kw.term) ? SECONDARY_PURPLE_TEXT : "#1f2937"
|
|
2255
|
+
}, children: kw.term }),
|
|
2227
2256
|
enrichingTerms.has(kw.term) && /* @__PURE__ */ jsx5(LoadingBars, { size: "xs", color: "#6b7280" }),
|
|
2228
2257
|
!enrichingTerms.has(kw.term) && kw.volume != null && /* @__PURE__ */ jsx5("span", { style: { fontSize: 10.5, fontWeight: 600, color: "#1f2937", flexShrink: 0 }, title: "Monthly searches", children: kw.volume === 0 ? "N/A" : `${abbrevVol(kw.volume)}/mo` }),
|
|
2229
2258
|
kw.placement && /* @__PURE__ */ jsx5(PlacementIndicators, { placement: kw.placement }),
|
|
@@ -2362,26 +2391,10 @@ function KeywordPanel({
|
|
|
2362
2391
|
...c,
|
|
2363
2392
|
placement: computePlacementClient(c.term, text, documentFields)
|
|
2364
2393
|
}));
|
|
2365
|
-
const
|
|
2366
|
-
const
|
|
2367
|
-
const
|
|
2368
|
-
const
|
|
2369
|
-
for (const c of candidates) {
|
|
2370
|
-
const key = c.term.toLowerCase();
|
|
2371
|
-
if (key === activeTermLower) continue;
|
|
2372
|
-
if (!seenSecondary.has(key)) {
|
|
2373
|
-
seenSecondary.add(key);
|
|
2374
|
-
secondaryOptions.push({ term: c.term, volume: c.volume });
|
|
2375
|
-
}
|
|
2376
|
-
}
|
|
2377
|
-
for (const kw of suggestedKeywords) {
|
|
2378
|
-
const key = kw.term.toLowerCase();
|
|
2379
|
-
if (key === activeTermLower) continue;
|
|
2380
|
-
if (!seenSecondary.has(key)) {
|
|
2381
|
-
seenSecondary.add(key);
|
|
2382
|
-
secondaryOptions.push({ term: kw.term, volume: kw.volume });
|
|
2383
|
-
}
|
|
2384
|
-
}
|
|
2394
|
+
const candHasVol = (c) => c.volume != null && c.volume > 0;
|
|
2395
|
+
const candWithVol = candidates.filter(candHasVol);
|
|
2396
|
+
const visibleCandidates = isVolumesLoading || candWithVol.length === 0 ? candidates : candWithVol;
|
|
2397
|
+
const activeTerm = visibleCandidates.find((c) => c.term === selectedPrimaryTerm) ? selectedPrimaryTerm : visibleCandidates[0]?.term ?? "";
|
|
2385
2398
|
return /* @__PURE__ */ jsxs4("div", { style: { padding: 12, display: "flex", flexDirection: "column", gap: 12 }, children: [
|
|
2386
2399
|
/* @__PURE__ */ jsx5("div", { style: {
|
|
2387
2400
|
...cardStyle,
|
|
@@ -2394,13 +2407,13 @@ function KeywordPanel({
|
|
|
2394
2407
|
/* @__PURE__ */ jsx5("strong", { children: "Primary" }),
|
|
2395
2408
|
" keyword (required) and, optionally, one ",
|
|
2396
2409
|
/* @__PURE__ */ jsx5("strong", { children: "Secondary" }),
|
|
2397
|
-
" keyword. Copilot optimizes
|
|
2410
|
+
" keyword. Copilot then optimizes its recommendations toward both."
|
|
2398
2411
|
] }) }),
|
|
2399
2412
|
onSeedsChange && /* @__PURE__ */ jsx5(SeedKeywordInput, { seeds: seedKeywords, onSeedsChange }),
|
|
2400
2413
|
/* @__PURE__ */ jsx5(
|
|
2401
2414
|
PrimaryKeywordSelector,
|
|
2402
2415
|
{
|
|
2403
|
-
candidates,
|
|
2416
|
+
candidates: visibleCandidates,
|
|
2404
2417
|
selectedTerm: activeTerm,
|
|
2405
2418
|
onSelect: (term) => {
|
|
2406
2419
|
setSelectedPrimaryTerm(term);
|
|
@@ -2409,15 +2422,7 @@ function KeywordPanel({
|
|
|
2409
2422
|
publication
|
|
2410
2423
|
}
|
|
2411
2424
|
),
|
|
2412
|
-
|
|
2413
|
-
SecondaryKeywordSelector,
|
|
2414
|
-
{
|
|
2415
|
-
options: secondaryOptions,
|
|
2416
|
-
selectedTerm: secondaryKeyword,
|
|
2417
|
-
onSelect: (term) => onSelectSecondary(term)
|
|
2418
|
-
}
|
|
2419
|
-
),
|
|
2420
|
-
suggestedKeywords.length > 0 && /* @__PURE__ */ jsx5(
|
|
2425
|
+
(suggestedKeywords.length > 0 || !!onSelectSecondary) && /* @__PURE__ */ jsx5(
|
|
2421
2426
|
SuggestedKeywordsCard,
|
|
2422
2427
|
{
|
|
2423
2428
|
keywords: suggestedKeywords,
|
|
@@ -2427,7 +2432,10 @@ function KeywordPanel({
|
|
|
2427
2432
|
documentFields,
|
|
2428
2433
|
refreshVolumes,
|
|
2429
2434
|
isVolumesLoading,
|
|
2430
|
-
documentId
|
|
2435
|
+
documentId,
|
|
2436
|
+
secondaryKeyword,
|
|
2437
|
+
onSelectSecondary,
|
|
2438
|
+
primaryTerm: activeTerm
|
|
2431
2439
|
},
|
|
2432
2440
|
documentId || "default"
|
|
2433
2441
|
),
|
|
@@ -2435,6 +2443,10 @@ function KeywordPanel({
|
|
|
2435
2443
|
/* @__PURE__ */ jsx5(LoadingBars, { size: "xs", color: MJH_GOLD }),
|
|
2436
2444
|
/* @__PURE__ */ jsx5("span", { style: { fontSize: 10, color: "#4b5563" }, children: "Checking search volumes..." })
|
|
2437
2445
|
] }),
|
|
2446
|
+
error && analysis && /* @__PURE__ */ jsxs4("div", { style: { padding: "4px 12px", fontSize: 11, color: "#dc2626" }, children: [
|
|
2447
|
+
"Could not refresh analysis: ",
|
|
2448
|
+
error
|
|
2449
|
+
] }),
|
|
2438
2450
|
isLoading && analysis && /* @__PURE__ */ jsxs4("div", { style: { display: "flex", alignItems: "center", gap: 6, justifyContent: "center" }, children: [
|
|
2439
2451
|
/* @__PURE__ */ jsx5(LoadingBars, { size: "xs", color: "#9ca3af" }),
|
|
2440
2452
|
/* @__PURE__ */ jsx5("span", { style: { fontSize: 10, color: "#4b5563" }, children: "Updating insights..." })
|
|
@@ -3157,13 +3169,6 @@ function ShimmerLoader({
|
|
|
3157
3169
|
style.dataset.seoCopilotKeyframes = "1";
|
|
3158
3170
|
style.innerHTML = KEYFRAMES;
|
|
3159
3171
|
document.head.appendChild(style);
|
|
3160
|
-
return () => {
|
|
3161
|
-
try {
|
|
3162
|
-
document.head.removeChild(style);
|
|
3163
|
-
} catch {
|
|
3164
|
-
}
|
|
3165
|
-
keyframesInjected = false;
|
|
3166
|
-
};
|
|
3167
3172
|
}
|
|
3168
3173
|
}, []);
|
|
3169
3174
|
useEffect9(() => {
|
|
@@ -3460,7 +3465,7 @@ function buildSummaryItems(input) {
|
|
|
3460
3465
|
severity: "warning",
|
|
3461
3466
|
label: "Meta description is short",
|
|
3462
3467
|
description: `Meta description is ${len} characters - below the 120-160 ideal.`,
|
|
3463
|
-
howToFix: "Expand the description to 120-160 characters so
|
|
3468
|
+
howToFix: "Expand the description to 120-160 characters so the full description shows in search.",
|
|
3464
3469
|
jumpTo: { tab: "meta", anchorId: "anchor-meta-description" }
|
|
3465
3470
|
});
|
|
3466
3471
|
} else if (len > 160) {
|
|
@@ -3565,7 +3570,7 @@ function buildSummaryItems(input) {
|
|
|
3565
3570
|
category: "headings",
|
|
3566
3571
|
severity: "error",
|
|
3567
3572
|
label: "Long article without section headings",
|
|
3568
|
-
description: `${wordCount2} words and no H2 headings.`,
|
|
3573
|
+
description: `${wordCount2} words and no H2 or H3 section headings.`,
|
|
3569
3574
|
howToFix: "Add 2-3 H2 headings to break the article into scannable sections.",
|
|
3570
3575
|
jumpTo: { tab: "technical", anchorId: "anchor-headings-structure" }
|
|
3571
3576
|
});
|
|
@@ -3575,7 +3580,7 @@ function buildSummaryItems(input) {
|
|
|
3575
3580
|
category: "headings",
|
|
3576
3581
|
severity: "warning",
|
|
3577
3582
|
label: "Long article could use more section headings",
|
|
3578
|
-
description: `${h2Count}
|
|
3583
|
+
description: `${h2Count} section heading${h2Count === 1 ? "" : "s"} for ${wordCount2} words.`,
|
|
3579
3584
|
howToFix: "Long articles read best with 1 H2 per 300-400 words. Add more named section breaks.",
|
|
3580
3585
|
jumpTo: { tab: "technical", anchorId: "anchor-headings-structure" }
|
|
3581
3586
|
});
|
|
@@ -3585,7 +3590,7 @@ function buildSummaryItems(input) {
|
|
|
3585
3590
|
category: "headings",
|
|
3586
3591
|
severity: "warning",
|
|
3587
3592
|
label: "Article could use more section headings",
|
|
3588
|
-
description: `${h2Count}
|
|
3593
|
+
description: `${h2Count} section heading${h2Count === 1 ? "" : "s"} for ${wordCount2} words.`,
|
|
3589
3594
|
howToFix: "Articles above 1,500 words usually need at least 3 H2 sections. Break the content into more named blocks.",
|
|
3590
3595
|
jumpTo: { tab: "technical", anchorId: "anchor-headings-structure" }
|
|
3591
3596
|
});
|
|
@@ -4520,6 +4525,14 @@ function AEOTab({
|
|
|
4520
4525
|
"div",
|
|
4521
4526
|
{
|
|
4522
4527
|
onClick: runDeepAnalysis,
|
|
4528
|
+
role: "button",
|
|
4529
|
+
tabIndex: 0,
|
|
4530
|
+
onKeyDown: (e) => {
|
|
4531
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
4532
|
+
e.preventDefault();
|
|
4533
|
+
runDeepAnalysis();
|
|
4534
|
+
}
|
|
4535
|
+
},
|
|
4523
4536
|
style: {
|
|
4524
4537
|
padding: "8px 12px",
|
|
4525
4538
|
background: "#fffbeb",
|
|
@@ -6689,7 +6702,6 @@ function PanelContent({
|
|
|
6689
6702
|
text,
|
|
6690
6703
|
deepAnalysis: keywordAnalysisState.deepAnalysis,
|
|
6691
6704
|
isDeepLoading: keywordAnalysisState.isDeepLoading,
|
|
6692
|
-
primaryKeyword: effectivePrimary,
|
|
6693
6705
|
publication,
|
|
6694
6706
|
runDeepAnalysis: keywordAnalysisState.runDeepAnalysis,
|
|
6695
6707
|
aeoContentChanged: keywordAnalysisState.aeoContentChanged,
|
|
@@ -6909,7 +6921,7 @@ function SEOCopilotInner({ config, onClose }) {
|
|
|
6909
6921
|
const [activeTab, setActiveTab] = useState16("keywords");
|
|
6910
6922
|
const [chatOpen, setChatOpen] = usePersistentState("seo-copilot-ui-chat-open-v35", false);
|
|
6911
6923
|
const [splitPercent, setSplitPercent] = usePersistentState("seo-copilot-ui-split", 70);
|
|
6912
|
-
const keywordAnalysisState = useKeywordAnalysis(text, apiUrl, effectivePublication, seedKeywords, documentFields, selectedPrimary, documentId);
|
|
6924
|
+
const keywordAnalysisState = useKeywordAnalysis(text, apiUrl, effectivePublication, seedKeywords, documentFields, selectedPrimary, documentId, selectedSecondary);
|
|
6913
6925
|
const effectivePrimary = selectedPrimary || keywordAnalysisState.analysis?.primaryKeyword?.term || "";
|
|
6914
6926
|
useEffect11(() => {
|
|
6915
6927
|
if (selectedSecondary && effectivePrimary && selectedSecondary.toLowerCase() === effectivePrimary.toLowerCase()) {
|
|
@@ -7091,6 +7103,24 @@ function SEOCopilotInner({ config, onClose }) {
|
|
|
7091
7103
|
linkingAbortRef.current?.abort();
|
|
7092
7104
|
};
|
|
7093
7105
|
}, []);
|
|
7106
|
+
const runAllAnalyses = () => {
|
|
7107
|
+
keywordAnalysisState.runDeepAnalysis();
|
|
7108
|
+
if (text && text.trim().length >= 100) loadContentSuggestions();
|
|
7109
|
+
if (text && text.trim().length >= 50 && effectivePrimary) refreshLinkingSuggestions();
|
|
7110
|
+
if ((documentFields?.bodyLinks || []).length > 0) runLinkCheck();
|
|
7111
|
+
};
|
|
7112
|
+
const runAllRef = useRef11(runAllAnalyses);
|
|
7113
|
+
runAllRef.current = runAllAnalyses;
|
|
7114
|
+
const secAutoRunRef = useRef11({ doc: documentId, sec: selectedSecondary, init: true });
|
|
7115
|
+
useEffect11(() => {
|
|
7116
|
+
const prev = secAutoRunRef.current;
|
|
7117
|
+
const docChanged = prev.doc !== documentId;
|
|
7118
|
+
const secChanged = prev.sec !== selectedSecondary;
|
|
7119
|
+
secAutoRunRef.current = { doc: documentId, sec: selectedSecondary, init: false };
|
|
7120
|
+
if (prev.init || docChanged || !secChanged) return;
|
|
7121
|
+
const t = setTimeout(() => runAllRef.current(), 1500);
|
|
7122
|
+
return () => clearTimeout(t);
|
|
7123
|
+
}, [selectedSecondary, documentId]);
|
|
7094
7124
|
const handleDragStart = useCallback5(
|
|
7095
7125
|
(e) => {
|
|
7096
7126
|
dragOffset.current = {
|
|
@@ -7223,12 +7253,7 @@ function SEOCopilotInner({ config, onClose }) {
|
|
|
7223
7253
|
},
|
|
7224
7254
|
summaryOps: {
|
|
7225
7255
|
isAnyLoading: keywordAnalysisState.isLoading || keywordAnalysisState.isVolumesLoading || keywordAnalysisState.isDeepLoading || isCSLoading || isLinkingLoading || isLinkCheckLoading,
|
|
7226
|
-
onGenerateAll:
|
|
7227
|
-
keywordAnalysisState.runDeepAnalysis();
|
|
7228
|
-
if (text && text.trim().length >= 100) loadContentSuggestions();
|
|
7229
|
-
if (text && text.trim().length >= 50 && effectivePrimary) refreshLinkingSuggestions();
|
|
7230
|
-
if ((documentFields?.bodyLinks || []).length > 0) runLinkCheck();
|
|
7231
|
-
},
|
|
7256
|
+
onGenerateAll: runAllAnalyses,
|
|
7232
7257
|
onItemClick: (item) => {
|
|
7233
7258
|
setActiveTab(item.jumpTo.tab);
|
|
7234
7259
|
const id = item.jumpTo.anchorId;
|