sanity-plugin-seo-copilot 0.2.16 → 0.2.17

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.d.mts CHANGED
@@ -3,6 +3,7 @@ import * as sanity from 'sanity';
3
3
  interface SEOCopilotConfig {
4
4
  apiUrl: string;
5
5
  publication?: string;
6
+ autoOpen?: boolean;
6
7
  }
7
8
  declare const seoCopilot: sanity.Plugin<SEOCopilotConfig>;
8
9
 
package/dist/index.d.ts CHANGED
@@ -3,6 +3,7 @@ import * as sanity from 'sanity';
3
3
  interface SEOCopilotConfig {
4
4
  apiUrl: string;
5
5
  publication?: string;
6
+ autoOpen?: boolean;
6
7
  }
7
8
  declare const seoCopilot: sanity.Plugin<SEOCopilotConfig>;
8
9
 
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ module.exports = __toCommonJS(index_exports);
36
36
  var import_sanity4 = require("sanity");
37
37
 
38
38
  // src/inspector.ts
39
- var import_react21 = require("react");
39
+ var import_react22 = require("react");
40
40
 
41
41
  // src/components/SEOCopilotPanel.tsx
42
42
  var import_react20 = require("react");
@@ -1624,12 +1624,12 @@ function calculateContentScoreDetailed(content, analysis, documentFields) {
1624
1624
  }
1625
1625
  let wcPts = 0;
1626
1626
  let wcDetail;
1627
- if (words >= 1500) {
1627
+ if (words >= 1e3) {
1628
1628
  wcPts = 15;
1629
- wcDetail = `${words} words - strong length for clinical content`;
1629
+ wcDetail = `${words} words - meets the 1,000-1,200 word target`;
1630
1630
  } else if (words >= 450) {
1631
1631
  wcPts = 11;
1632
- wcDetail = `${words} words - above the 450 floor; 1,500+ is the clinical target`;
1632
+ wcDetail = `${words} words - above the 450 floor; aim for 1,000-1,200`;
1633
1633
  } else if (words >= 200) {
1634
1634
  wcPts = 5;
1635
1635
  wcDetail = `${words} words - below the 450-word floor`;
@@ -3906,13 +3906,13 @@ function buildSummaryItems(input) {
3906
3906
  howToFix: "Add more body text. A link or image on its own doesn't count - the article needs real written substance.",
3907
3907
  jumpTo: { tab: "technical", anchorId: "anchor-word-count" }
3908
3908
  });
3909
- } else if (wordCount2 < 1500 && !isShortForm) {
3909
+ } else if (wordCount2 < 1e3 && !isShortForm) {
3910
3910
  items.push({
3911
3911
  id: "content-short-for-clinical",
3912
3912
  category: "content",
3913
3913
  severity: "opportunity",
3914
3914
  label: "Article could be longer",
3915
- description: `${wordCount2} words. For evergreen clinical topics 1,500+ tends to rank better - news, previews, and briefs are fine shorter.`,
3915
+ description: `${wordCount2} words. Aim for 1,000-1,200 words - news, previews, and briefs are fine shorter.`,
3916
3916
  howToFix: "If this is an in-depth clinical piece, expand with citations, comparative data, or guideline references. For news or previews, this length is appropriate.",
3917
3917
  jumpTo: { tab: "technical", anchorId: "anchor-word-count" }
3918
3918
  });
@@ -6613,11 +6613,11 @@ function TechnicalTab({
6613
6613
  value: `${wordCount2} words`,
6614
6614
  status: "error",
6615
6615
  recommendation: "Body copy should be at least 450 words. Add more written content."
6616
- } : wordCount2 < 1500 ? {
6616
+ } : wordCount2 < 1e3 ? {
6617
6617
  label: "Word Count",
6618
6618
  value: `${wordCount2} words`,
6619
6619
  status: "warning",
6620
- recommendation: "Above the 450-word floor. For competitive clinical content, push past 1,500 words."
6620
+ recommendation: "Above the 450-word floor. Aim for 1,000-1,200 words."
6621
6621
  } : { label: "Word Count", value: `${wordCount2} words`, status: "good" };
6622
6622
  const bodyLinks = documentFields?.bodyLinks || [];
6623
6623
  const bodyLinksDetailed = documentFields?.bodyLinksDetailed;
@@ -7853,47 +7853,46 @@ function LoadingBars({ size = "sm", color = MJH_GOLD }) {
7853
7853
  )) });
7854
7854
  }
7855
7855
 
7856
+ // src/hooks/useAutoOpenInspector.ts
7857
+ var import_react21 = require("react");
7858
+ var import_structure2 = require("sanity/structure");
7859
+ var SEO_COPILOT_INSPECTOR_NAME = "seo-copilot";
7860
+ function useAutoOpenInspector(enabled) {
7861
+ const { ready, documentId, inspector, schemaType, openInspector } = (0, import_structure2.useDocumentPane)();
7862
+ const handledRef = (0, import_react21.useRef)(/* @__PURE__ */ new Set());
7863
+ const hasBody = Boolean(schemaType?.fields?.some((f) => f.name === "body"));
7864
+ const openName = inspector?.name ?? null;
7865
+ (0, import_react21.useEffect)(() => {
7866
+ if (!enabled || !ready || !hasBody || !documentId) return;
7867
+ if (handledRef.current.has(documentId)) return;
7868
+ handledRef.current.add(documentId);
7869
+ if (openName === null) openInspector(SEO_COPILOT_INSPECTOR_NAME);
7870
+ }, [enabled, ready, hasBody, documentId, openName, openInspector]);
7871
+ }
7872
+
7856
7873
  // src/inspector.ts
7857
7874
  function SEOIcon() {
7858
- return (0, import_react21.createElement)(
7875
+ return (0, import_react22.createElement)(
7859
7876
  "svg",
7860
7877
  { viewBox: "0 0 25 25", width: "1em", height: "1em", fill: "none" },
7861
- (0, import_react21.createElement)("circle", { cx: "12.5", cy: "12.5", r: "11.5", fill: "#E6C01B" }),
7862
- (0, import_react21.createElement)("text", {
7863
- x: "12.5",
7864
- y: "7.5",
7865
- textAnchor: "middle",
7866
- dominantBaseline: "central",
7867
- fill: "white",
7868
- fontSize: "7",
7869
- fontWeight: "900",
7870
- fontFamily: "Arial Black, Impact, sans-serif"
7871
- }, "S"),
7872
- (0, import_react21.createElement)("text", {
7873
- x: "12.5",
7874
- y: "12.8",
7875
- textAnchor: "middle",
7876
- dominantBaseline: "central",
7877
- fill: "white",
7878
- fontSize: "7",
7879
- fontWeight: "900",
7880
- fontFamily: "Arial Black, Impact, sans-serif"
7881
- }, "E"),
7882
- (0, import_react21.createElement)("text", {
7878
+ (0, import_react22.createElement)("circle", { cx: "12.5", cy: "12.5", r: "11.5", fill: "#E6C01B" }),
7879
+ (0, import_react22.createElement)("text", {
7883
7880
  x: "12.5",
7884
- y: "18",
7881
+ y: "12.9",
7885
7882
  textAnchor: "middle",
7886
7883
  dominantBaseline: "central",
7887
7884
  fill: "white",
7888
- fontSize: "7",
7885
+ fontSize: "8",
7889
7886
  fontWeight: "900",
7890
- fontFamily: "Arial Black, Impact, sans-serif"
7891
- }, "O")
7887
+ fontFamily: "Arial Black, Impact, sans-serif",
7888
+ textLength: "17",
7889
+ lengthAdjust: "spacingAndGlyphs"
7890
+ }, "SEO")
7892
7891
  );
7893
7892
  }
7894
7893
  function seoCopilotInspector(config) {
7895
7894
  return {
7896
- name: "seo-copilot",
7895
+ name: SEO_COPILOT_INSPECTOR_NAME,
7897
7896
  useMenuItem: () => ({
7898
7897
  title: "SEO Copilot",
7899
7898
  icon: SEOIcon,
@@ -7907,11 +7906,37 @@ function seoCopilotInspector(config) {
7907
7906
  tone: "default"
7908
7907
  }),
7909
7908
  component: function SEOCopilotInspector(props) {
7910
- return (0, import_react21.createElement)(SEOCopilotPanel, { ...props, config });
7909
+ return (0, import_react22.createElement)(SEOCopilotPanel, { ...props, config });
7911
7910
  }
7912
7911
  };
7913
7912
  }
7914
7913
 
7914
+ // src/components/AutoOpenInspector.tsx
7915
+ var import_react23 = require("react");
7916
+ var import_jsx_runtime19 = require("react/jsx-runtime");
7917
+ function AutoOpen({ enabled }) {
7918
+ useAutoOpenInspector(enabled);
7919
+ return null;
7920
+ }
7921
+ var SilentBoundary = class extends import_react23.Component {
7922
+ state = { failed: false };
7923
+ static getDerivedStateFromError() {
7924
+ return { failed: true };
7925
+ }
7926
+ render() {
7927
+ return this.state.failed ? null : this.props.children;
7928
+ }
7929
+ };
7930
+ function createAutoOpenInput(enabled) {
7931
+ return function SEOCopilotAutoOpenInput(props) {
7932
+ if (props.path.length > 0) return props.renderDefault(props);
7933
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsxs)(import_jsx_runtime19.Fragment, { children: [
7934
+ /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(SilentBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(AutoOpen, { enabled }) }),
7935
+ props.renderDefault(props)
7936
+ ] });
7937
+ };
7938
+ }
7939
+
7915
7940
  // src/index.ts
7916
7941
  var seoCopilot = (0, import_sanity4.definePlugin)((config) => {
7917
7942
  return {
@@ -7920,6 +7945,11 @@ var seoCopilot = (0, import_sanity4.definePlugin)((config) => {
7920
7945
  inspectors: (prev) => {
7921
7946
  return [...prev, seoCopilotInspector(config)];
7922
7947
  }
7948
+ },
7949
+ form: {
7950
+ components: {
7951
+ input: createAutoOpenInput(config.autoOpen !== false)
7952
+ }
7923
7953
  }
7924
7954
  };
7925
7955
  });
package/dist/index.mjs CHANGED
@@ -1590,12 +1590,12 @@ function calculateContentScoreDetailed(content, analysis, documentFields) {
1590
1590
  }
1591
1591
  let wcPts = 0;
1592
1592
  let wcDetail;
1593
- if (words >= 1500) {
1593
+ if (words >= 1e3) {
1594
1594
  wcPts = 15;
1595
- wcDetail = `${words} words - strong length for clinical content`;
1595
+ wcDetail = `${words} words - meets the 1,000-1,200 word target`;
1596
1596
  } else if (words >= 450) {
1597
1597
  wcPts = 11;
1598
- wcDetail = `${words} words - above the 450 floor; 1,500+ is the clinical target`;
1598
+ wcDetail = `${words} words - above the 450 floor; aim for 1,000-1,200`;
1599
1599
  } else if (words >= 200) {
1600
1600
  wcPts = 5;
1601
1601
  wcDetail = `${words} words - below the 450-word floor`;
@@ -3872,13 +3872,13 @@ function buildSummaryItems(input) {
3872
3872
  howToFix: "Add more body text. A link or image on its own doesn't count - the article needs real written substance.",
3873
3873
  jumpTo: { tab: "technical", anchorId: "anchor-word-count" }
3874
3874
  });
3875
- } else if (wordCount2 < 1500 && !isShortForm) {
3875
+ } else if (wordCount2 < 1e3 && !isShortForm) {
3876
3876
  items.push({
3877
3877
  id: "content-short-for-clinical",
3878
3878
  category: "content",
3879
3879
  severity: "opportunity",
3880
3880
  label: "Article could be longer",
3881
- description: `${wordCount2} words. For evergreen clinical topics 1,500+ tends to rank better - news, previews, and briefs are fine shorter.`,
3881
+ description: `${wordCount2} words. Aim for 1,000-1,200 words - news, previews, and briefs are fine shorter.`,
3882
3882
  howToFix: "If this is an in-depth clinical piece, expand with citations, comparative data, or guideline references. For news or previews, this length is appropriate.",
3883
3883
  jumpTo: { tab: "technical", anchorId: "anchor-word-count" }
3884
3884
  });
@@ -6579,11 +6579,11 @@ function TechnicalTab({
6579
6579
  value: `${wordCount2} words`,
6580
6580
  status: "error",
6581
6581
  recommendation: "Body copy should be at least 450 words. Add more written content."
6582
- } : wordCount2 < 1500 ? {
6582
+ } : wordCount2 < 1e3 ? {
6583
6583
  label: "Word Count",
6584
6584
  value: `${wordCount2} words`,
6585
6585
  status: "warning",
6586
- recommendation: "Above the 450-word floor. For competitive clinical content, push past 1,500 words."
6586
+ recommendation: "Above the 450-word floor. Aim for 1,000-1,200 words."
6587
6587
  } : { label: "Word Count", value: `${wordCount2} words`, status: "good" };
6588
6588
  const bodyLinks = documentFields?.bodyLinks || [];
6589
6589
  const bodyLinksDetailed = documentFields?.bodyLinksDetailed;
@@ -7819,6 +7819,23 @@ function LoadingBars({ size = "sm", color = MJH_GOLD }) {
7819
7819
  )) });
7820
7820
  }
7821
7821
 
7822
+ // src/hooks/useAutoOpenInspector.ts
7823
+ import { useEffect as useEffect13, useRef as useRef13 } from "react";
7824
+ import { useDocumentPane as useDocumentPane2 } from "sanity/structure";
7825
+ var SEO_COPILOT_INSPECTOR_NAME = "seo-copilot";
7826
+ function useAutoOpenInspector(enabled) {
7827
+ const { ready, documentId, inspector, schemaType, openInspector } = useDocumentPane2();
7828
+ const handledRef = useRef13(/* @__PURE__ */ new Set());
7829
+ const hasBody = Boolean(schemaType?.fields?.some((f) => f.name === "body"));
7830
+ const openName = inspector?.name ?? null;
7831
+ useEffect13(() => {
7832
+ if (!enabled || !ready || !hasBody || !documentId) return;
7833
+ if (handledRef.current.has(documentId)) return;
7834
+ handledRef.current.add(documentId);
7835
+ if (openName === null) openInspector(SEO_COPILOT_INSPECTOR_NAME);
7836
+ }, [enabled, ready, hasBody, documentId, openName, openInspector]);
7837
+ }
7838
+
7822
7839
  // src/inspector.ts
7823
7840
  function SEOIcon() {
7824
7841
  return createElement(
@@ -7827,39 +7844,21 @@ function SEOIcon() {
7827
7844
  createElement("circle", { cx: "12.5", cy: "12.5", r: "11.5", fill: "#E6C01B" }),
7828
7845
  createElement("text", {
7829
7846
  x: "12.5",
7830
- y: "7.5",
7831
- textAnchor: "middle",
7832
- dominantBaseline: "central",
7833
- fill: "white",
7834
- fontSize: "7",
7835
- fontWeight: "900",
7836
- fontFamily: "Arial Black, Impact, sans-serif"
7837
- }, "S"),
7838
- createElement("text", {
7839
- x: "12.5",
7840
- y: "12.8",
7841
- textAnchor: "middle",
7842
- dominantBaseline: "central",
7843
- fill: "white",
7844
- fontSize: "7",
7845
- fontWeight: "900",
7846
- fontFamily: "Arial Black, Impact, sans-serif"
7847
- }, "E"),
7848
- createElement("text", {
7849
- x: "12.5",
7850
- y: "18",
7847
+ y: "12.9",
7851
7848
  textAnchor: "middle",
7852
7849
  dominantBaseline: "central",
7853
7850
  fill: "white",
7854
- fontSize: "7",
7851
+ fontSize: "8",
7855
7852
  fontWeight: "900",
7856
- fontFamily: "Arial Black, Impact, sans-serif"
7857
- }, "O")
7853
+ fontFamily: "Arial Black, Impact, sans-serif",
7854
+ textLength: "17",
7855
+ lengthAdjust: "spacingAndGlyphs"
7856
+ }, "SEO")
7858
7857
  );
7859
7858
  }
7860
7859
  function seoCopilotInspector(config) {
7861
7860
  return {
7862
- name: "seo-copilot",
7861
+ name: SEO_COPILOT_INSPECTOR_NAME,
7863
7862
  useMenuItem: () => ({
7864
7863
  title: "SEO Copilot",
7865
7864
  icon: SEOIcon,
@@ -7878,6 +7877,32 @@ function seoCopilotInspector(config) {
7878
7877
  };
7879
7878
  }
7880
7879
 
7880
+ // src/components/AutoOpenInspector.tsx
7881
+ import { Component } from "react";
7882
+ import { Fragment as Fragment11, jsx as jsx19, jsxs as jsxs18 } from "react/jsx-runtime";
7883
+ function AutoOpen({ enabled }) {
7884
+ useAutoOpenInspector(enabled);
7885
+ return null;
7886
+ }
7887
+ var SilentBoundary = class extends Component {
7888
+ state = { failed: false };
7889
+ static getDerivedStateFromError() {
7890
+ return { failed: true };
7891
+ }
7892
+ render() {
7893
+ return this.state.failed ? null : this.props.children;
7894
+ }
7895
+ };
7896
+ function createAutoOpenInput(enabled) {
7897
+ return function SEOCopilotAutoOpenInput(props) {
7898
+ if (props.path.length > 0) return props.renderDefault(props);
7899
+ return /* @__PURE__ */ jsxs18(Fragment11, { children: [
7900
+ /* @__PURE__ */ jsx19(SilentBoundary, { children: /* @__PURE__ */ jsx19(AutoOpen, { enabled }) }),
7901
+ props.renderDefault(props)
7902
+ ] });
7903
+ };
7904
+ }
7905
+
7881
7906
  // src/index.ts
7882
7907
  var seoCopilot = definePlugin((config) => {
7883
7908
  return {
@@ -7886,6 +7911,11 @@ var seoCopilot = definePlugin((config) => {
7886
7911
  inspectors: (prev) => {
7887
7912
  return [...prev, seoCopilotInspector(config)];
7888
7913
  }
7914
+ },
7915
+ form: {
7916
+ components: {
7917
+ input: createAutoOpenInput(config.autoOpen !== false)
7918
+ }
7889
7919
  }
7890
7920
  };
7891
7921
  });
package/package.json CHANGED
@@ -1,62 +1,62 @@
1
- {
2
- "name": "sanity-plugin-seo-copilot",
3
- "version": "0.2.16",
4
- "description": "AI-powered SEO writing assistant for Sanity Studio",
5
- "keywords": [
6
- "sanity",
7
- "sanity-plugin",
8
- "seo",
9
- "copilot"
10
- ],
11
- "license": "UNLICENSED",
12
- "author": "MJH Life Sciences",
13
- "exports": {
14
- ".": {
15
- "import": "./dist/index.mjs",
16
- "require": "./dist/index.js",
17
- "default": "./dist/index.js"
18
- },
19
- "./package.json": "./package.json"
20
- },
21
- "main": "./dist/index.js",
22
- "module": "./dist/index.mjs",
23
- "types": "./dist/index.d.ts",
24
- "files": [
25
- "dist"
26
- ],
27
- "scripts": {
28
- "build": "tsup",
29
- "prepare": "npm run build",
30
- "prepublishOnly": "npm run build",
31
- "test": "vitest run"
32
- },
33
- "dependencies": {
34
- "react-markdown": "^10.1.0",
35
- "remark-gfm": "^4.0.1"
36
- },
37
- "devDependencies": {
38
- "@sanity/icons": "^3.7.4",
39
- "@sanity/ui": "^3.1.13",
40
- "@testing-library/react": "^16.3.3",
41
- "@types/react": "^19.0.0",
42
- "@types/react-dom": "^19.2.3",
43
- "happy-dom": "^20.14.5",
44
- "react": "^19.2.4",
45
- "react-dom": "^19.2.4",
46
- "sanity": "^5.13.0",
47
- "styled-components": "^6.3.11",
48
- "tsup": "^8.0.0",
49
- "typescript": "^5.9.3",
50
- "vitest": "^4.1.11"
51
- },
52
- "peerDependencies": {
53
- "@sanity/icons": "^3.0.0",
54
- "@sanity/ui": "^2.0.0 || ^3.0.0",
55
- "react": "^18.0.0 || ^19.0.0",
56
- "sanity": "^3.0.0 || ^5.0.0",
57
- "styled-components": "^6.0.0"
58
- },
59
- "engines": {
60
- "node": ">=18"
61
- }
62
- }
1
+ {
2
+ "name": "sanity-plugin-seo-copilot",
3
+ "version": "0.2.17",
4
+ "description": "AI-powered SEO writing assistant for Sanity Studio",
5
+ "keywords": [
6
+ "sanity",
7
+ "sanity-plugin",
8
+ "seo",
9
+ "copilot"
10
+ ],
11
+ "license": "UNLICENSED",
12
+ "author": "MJH Life Sciences",
13
+ "exports": {
14
+ ".": {
15
+ "import": "./dist/index.mjs",
16
+ "require": "./dist/index.js",
17
+ "default": "./dist/index.js"
18
+ },
19
+ "./package.json": "./package.json"
20
+ },
21
+ "main": "./dist/index.js",
22
+ "module": "./dist/index.mjs",
23
+ "types": "./dist/index.d.ts",
24
+ "files": [
25
+ "dist"
26
+ ],
27
+ "scripts": {
28
+ "build": "tsup",
29
+ "prepare": "npm run build",
30
+ "prepublishOnly": "npm run build",
31
+ "test": "vitest run"
32
+ },
33
+ "dependencies": {
34
+ "react-markdown": "^10.1.0",
35
+ "remark-gfm": "^4.0.1"
36
+ },
37
+ "devDependencies": {
38
+ "@sanity/icons": "^3.7.4",
39
+ "@sanity/ui": "^3.1.13",
40
+ "@testing-library/react": "^16.3.3",
41
+ "@types/react": "^19.0.0",
42
+ "@types/react-dom": "^19.2.3",
43
+ "happy-dom": "^20.14.5",
44
+ "react": "^19.2.4",
45
+ "react-dom": "^19.2.4",
46
+ "sanity": "^5.13.0",
47
+ "styled-components": "^6.3.11",
48
+ "tsup": "^8.0.0",
49
+ "typescript": "^5.9.3",
50
+ "vitest": "^4.1.11"
51
+ },
52
+ "peerDependencies": {
53
+ "@sanity/icons": "^3.0.0",
54
+ "@sanity/ui": "^2.0.0 || ^3.0.0",
55
+ "react": "^18.0.0 || ^19.0.0",
56
+ "sanity": "^3.0.0 || ^5.0.0",
57
+ "styled-components": "^6.0.0"
58
+ },
59
+ "engines": {
60
+ "node": ">=18"
61
+ }
62
+ }