@farming-labs/theme 0.2.15 → 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/docs-feedback.d.mts +2 -0
- package/dist/docs-feedback.mjs +6 -3
- package/dist/docs-layout.mjs +8 -1
- package/dist/docs-page-client.d.mts +9 -1
- package/dist/docs-page-client.mjs +11 -1
- package/dist/index.d.mts +2 -2
- package/dist/page-actions.d.mts +7 -0
- package/dist/page-actions.mjs +8 -4
- package/dist/tanstack-layout.mjs +7 -1
- package/package.json +2 -2
package/dist/docs-feedback.d.mts
CHANGED
|
@@ -8,6 +8,7 @@ interface DocsFeedbackProps {
|
|
|
8
8
|
locale?: string;
|
|
9
9
|
question?: string;
|
|
10
10
|
placeholder?: string;
|
|
11
|
+
requireComment?: boolean;
|
|
11
12
|
positiveLabel?: string;
|
|
12
13
|
negativeLabel?: string;
|
|
13
14
|
submitLabel?: string;
|
|
@@ -20,6 +21,7 @@ declare function DocsFeedback({
|
|
|
20
21
|
locale,
|
|
21
22
|
question,
|
|
22
23
|
placeholder,
|
|
24
|
+
requireComment,
|
|
23
25
|
positiveLabel,
|
|
24
26
|
negativeLabel,
|
|
25
27
|
submitLabel,
|
package/dist/docs-feedback.mjs
CHANGED
|
@@ -116,12 +116,13 @@ function CheckIcon() {
|
|
|
116
116
|
})
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
function DocsFeedback({ pathname, entry, locale, question = "How is this guide?", placeholder = "Leave your feedback...", positiveLabel = "Good", negativeLabel = "Bad", submitLabel = "Submit", onFeedback, analytics = false }) {
|
|
119
|
+
function DocsFeedback({ pathname, entry, locale, question = "How is this guide?", placeholder = "Leave your feedback...", requireComment = false, positiveLabel = "Good", negativeLabel = "Bad", submitLabel = "Submit", onFeedback, analytics = false }) {
|
|
120
120
|
const [selected, setSelected] = useState(null);
|
|
121
121
|
const [comment, setComment] = useState("");
|
|
122
122
|
const [status, setStatus] = useState("idle");
|
|
123
123
|
const normalizedPathname = useMemo(() => normalizePathname(pathname), [pathname]);
|
|
124
124
|
const showForm = selected !== null;
|
|
125
|
+
const commentRequired = requireComment && comment.trim().length === 0;
|
|
125
126
|
const submitButtonLabel = status === "submitted" ? "Submitted" : submitLabel;
|
|
126
127
|
useEffect(() => {
|
|
127
128
|
setSelected(null);
|
|
@@ -151,7 +152,7 @@ function DocsFeedback({ pathname, entry, locale, question = "How is this guide?"
|
|
|
151
152
|
}
|
|
152
153
|
}
|
|
153
154
|
async function handleSubmit() {
|
|
154
|
-
if (!selected || status === "submitting") return;
|
|
155
|
+
if (!selected || status === "submitting" || commentRequired) return;
|
|
155
156
|
setStatus("submitting");
|
|
156
157
|
const payload = buildFeedbackPayload(selected, normalizedPathname, entry, comment, locale);
|
|
157
158
|
try {
|
|
@@ -221,6 +222,8 @@ function DocsFeedback({ pathname, entry, locale, question = "How is this guide?"
|
|
|
221
222
|
className: "fd-feedback-input",
|
|
222
223
|
"aria-label": "Additional feedback",
|
|
223
224
|
placeholder,
|
|
225
|
+
required: requireComment,
|
|
226
|
+
"aria-required": requireComment,
|
|
224
227
|
value: comment,
|
|
225
228
|
disabled: status === "submitting",
|
|
226
229
|
onChange: (event) => {
|
|
@@ -233,7 +236,7 @@ function DocsFeedback({ pathname, entry, locale, question = "How is this guide?"
|
|
|
233
236
|
children: [/* @__PURE__ */ jsxs("button", {
|
|
234
237
|
type: "button",
|
|
235
238
|
className: "fd-page-action-btn fd-feedback-submit",
|
|
236
|
-
disabled: status === "submitting" || status === "submitted",
|
|
239
|
+
disabled: status === "submitting" || status === "submitted" || commentRequired,
|
|
237
240
|
onClick: () => void handleSubmit(),
|
|
238
241
|
children: [
|
|
239
242
|
status === "submitting" && /* @__PURE__ */ jsx("span", {
|
package/dist/docs-layout.mjs
CHANGED
|
@@ -652,6 +652,7 @@ function createDocsLayout(config, options) {
|
|
|
652
652
|
const layoutDimensions = config.theme?.ui?.layout;
|
|
653
653
|
const pageActions = config.pageActions;
|
|
654
654
|
const copyMarkdownEnabled = resolveBool(pageActions?.copyMarkdown);
|
|
655
|
+
const copyMarkdownConfig = pageActions?.copyMarkdown && typeof pageActions.copyMarkdown === "object" ? pageActions.copyMarkdown : void 0;
|
|
655
656
|
const openDocsEnabled = resolveBool(pageActions?.openDocs);
|
|
656
657
|
const pageActionsPosition = pageActions?.position ?? "below-title";
|
|
657
658
|
const pageActionsAlignment = pageActions?.alignment ?? "left";
|
|
@@ -790,6 +791,9 @@ function createDocsLayout(config, options) {
|
|
|
790
791
|
publicPath: localeContext.publicPath,
|
|
791
792
|
locale: activeLocale,
|
|
792
793
|
copyMarkdown: copyMarkdownEnabled,
|
|
794
|
+
copyMarkdownFormat: copyMarkdownConfig?.format,
|
|
795
|
+
copyMarkdownLabel: copyMarkdownConfig?.label,
|
|
796
|
+
copyMarkdownCopiedLabel: copyMarkdownConfig?.copiedLabel,
|
|
793
797
|
openDocs: openDocsEnabled,
|
|
794
798
|
openDocsProviders,
|
|
795
799
|
openDocsTarget: openDocsConfig?.target,
|
|
@@ -812,6 +816,7 @@ function createDocsLayout(config, options) {
|
|
|
812
816
|
feedbackEnabled: feedbackConfig.enabled,
|
|
813
817
|
feedbackQuestion: feedbackConfig.question,
|
|
814
818
|
feedbackPlaceholder: feedbackConfig.placeholder,
|
|
819
|
+
feedbackRequireComment: feedbackConfig.requireComment,
|
|
815
820
|
feedbackPositiveLabel: feedbackConfig.positiveLabel,
|
|
816
821
|
feedbackNegativeLabel: feedbackConfig.negativeLabel,
|
|
817
822
|
feedbackSubmitLabel: feedbackConfig.submitLabel,
|
|
@@ -839,6 +844,7 @@ function resolveFeedbackConfig(feedback) {
|
|
|
839
844
|
enabled: false,
|
|
840
845
|
question: "How is this guide?",
|
|
841
846
|
placeholder: "Leave your feedback...",
|
|
847
|
+
requireComment: false,
|
|
842
848
|
positiveLabel: "Good",
|
|
843
849
|
negativeLabel: "Bad",
|
|
844
850
|
submitLabel: "Submit"
|
|
@@ -848,11 +854,12 @@ function resolveFeedbackConfig(feedback) {
|
|
|
848
854
|
...defaults,
|
|
849
855
|
enabled: true
|
|
850
856
|
};
|
|
851
|
-
const hasHumanFeedbackConfig = feedback.enabled !== void 0 || feedback.question !== void 0 || feedback.placeholder !== void 0 || feedback.positiveLabel !== void 0 || feedback.negativeLabel !== void 0 || feedback.submitLabel !== void 0 || feedback.onFeedback !== void 0;
|
|
857
|
+
const hasHumanFeedbackConfig = feedback.enabled !== void 0 || feedback.question !== void 0 || feedback.placeholder !== void 0 || feedback.requireComment !== void 0 || feedback.positiveLabel !== void 0 || feedback.negativeLabel !== void 0 || feedback.submitLabel !== void 0 || feedback.onFeedback !== void 0;
|
|
852
858
|
return {
|
|
853
859
|
enabled: feedback.enabled === true || feedback.enabled !== false && hasHumanFeedbackConfig,
|
|
854
860
|
question: feedback.question ?? defaults.question,
|
|
855
861
|
placeholder: feedback.placeholder ?? defaults.placeholder,
|
|
862
|
+
requireComment: feedback.requireComment ?? defaults.requireComment,
|
|
856
863
|
positiveLabel: feedback.positiveLabel ?? defaults.positiveLabel,
|
|
857
864
|
negativeLabel: feedback.negativeLabel ?? defaults.negativeLabel,
|
|
858
865
|
submitLabel: feedback.submitLabel ?? defaults.submitLabel
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from "react";
|
|
2
|
-
import { DocsFeedbackData, ReadingTimeFormat } from "@farming-labs/docs";
|
|
2
|
+
import { CopyMarkdownFormat, DocsFeedbackData, ReadingTimeFormat } from "@farming-labs/docs";
|
|
3
3
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
4
4
|
|
|
5
5
|
//#region src/docs-page-client.d.ts
|
|
@@ -23,6 +23,9 @@ interface DocsPageClientProps {
|
|
|
23
23
|
/** Active locale (used for llms.txt links) */
|
|
24
24
|
locale?: string;
|
|
25
25
|
copyMarkdown?: boolean;
|
|
26
|
+
copyMarkdownFormat?: CopyMarkdownFormat;
|
|
27
|
+
copyMarkdownLabel?: string;
|
|
28
|
+
copyMarkdownCopiedLabel?: string;
|
|
26
29
|
openDocs?: boolean;
|
|
27
30
|
openDocsProviders?: SerializedProvider[];
|
|
28
31
|
openDocsTarget?: "markdown" | "page" | "source" | "github";
|
|
@@ -74,6 +77,7 @@ interface DocsPageClientProps {
|
|
|
74
77
|
feedbackEnabled?: boolean;
|
|
75
78
|
feedbackQuestion?: string;
|
|
76
79
|
feedbackPlaceholder?: string;
|
|
80
|
+
feedbackRequireComment?: boolean;
|
|
77
81
|
feedbackPositiveLabel?: string;
|
|
78
82
|
feedbackNegativeLabel?: string;
|
|
79
83
|
feedbackSubmitLabel?: string;
|
|
@@ -90,6 +94,9 @@ declare function DocsPageClient({
|
|
|
90
94
|
publicPath,
|
|
91
95
|
locale,
|
|
92
96
|
copyMarkdown,
|
|
97
|
+
copyMarkdownFormat,
|
|
98
|
+
copyMarkdownLabel,
|
|
99
|
+
copyMarkdownCopiedLabel,
|
|
93
100
|
openDocs,
|
|
94
101
|
openDocsProviders,
|
|
95
102
|
openDocsTarget,
|
|
@@ -117,6 +124,7 @@ declare function DocsPageClient({
|
|
|
117
124
|
feedbackEnabled,
|
|
118
125
|
feedbackQuestion,
|
|
119
126
|
feedbackPlaceholder,
|
|
127
|
+
feedbackRequireComment,
|
|
120
128
|
feedbackPositiveLabel,
|
|
121
129
|
feedbackNegativeLabel,
|
|
122
130
|
feedbackSubmitLabel,
|
|
@@ -255,7 +255,7 @@ function findThreadlineTocActionsContainer() {
|
|
|
255
255
|
}
|
|
256
256
|
return toc.parentElement ?? toc;
|
|
257
257
|
}
|
|
258
|
-
function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled = true, changelogBasePath, entry = "docs", publicPath, locale, copyMarkdown = false, openDocs = false, openDocsProviders, openDocsTarget, openDocsPrompt, pageActionsPosition = "below-title", pageActionsAlignment = "left", githubUrl, contentDir, githubBranch = "main", githubDirectory, editOnGithubUrl, lastModifiedMap, lastModified: lastModifiedProp, readingTimeMap, readingTime: readingTimeProp, readingTimeFormat = "long", structuredDataMap, structuredData: structuredDataProp, readingTimeEnabled = false, lastUpdatedEnabled = true, lastUpdatedPosition = "footer", llmsTxtEnabled = false, descriptionMap, description, feedbackEnabled = false, feedbackQuestion, feedbackPlaceholder, feedbackPositiveLabel, feedbackNegativeLabel, feedbackSubmitLabel, feedbackOnFeedback, analytics = false, children }) {
|
|
258
|
+
function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled = true, changelogBasePath, entry = "docs", publicPath, locale, copyMarkdown = false, copyMarkdownFormat, copyMarkdownLabel, copyMarkdownCopiedLabel, openDocs = false, openDocsProviders, openDocsTarget, openDocsPrompt, pageActionsPosition = "below-title", pageActionsAlignment = "left", githubUrl, contentDir, githubBranch = "main", githubDirectory, editOnGithubUrl, lastModifiedMap, lastModified: lastModifiedProp, readingTimeMap, readingTime: readingTimeProp, readingTimeFormat = "long", structuredDataMap, structuredData: structuredDataProp, readingTimeEnabled = false, lastUpdatedEnabled = true, lastUpdatedPosition = "footer", llmsTxtEnabled = false, descriptionMap, description, feedbackEnabled = false, feedbackQuestion, feedbackPlaceholder, feedbackRequireComment, feedbackPositiveLabel, feedbackNegativeLabel, feedbackSubmitLabel, feedbackOnFeedback, analytics = false, children }) {
|
|
259
259
|
const fdTocStyle = tocStyle === "directional" ? "clerk" : void 0;
|
|
260
260
|
const [toc, setToc] = useState([]);
|
|
261
261
|
const [titlePortalHost, setTitlePortalHost] = useState(null);
|
|
@@ -465,6 +465,9 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
465
465
|
"data-actions-alignment": pageActionsAlignment,
|
|
466
466
|
children: /* @__PURE__ */ jsx(PageActions, {
|
|
467
467
|
copyMarkdown,
|
|
468
|
+
copyMarkdownFormat,
|
|
469
|
+
copyMarkdownLabel,
|
|
470
|
+
copyMarkdownCopiedLabel,
|
|
468
471
|
openDocs,
|
|
469
472
|
providers: openDocsProviders,
|
|
470
473
|
openDocsTarget,
|
|
@@ -508,6 +511,9 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
508
511
|
className: "fd-actions-toc-portal not-prose",
|
|
509
512
|
children: /* @__PURE__ */ jsx(PageActions, {
|
|
510
513
|
copyMarkdown,
|
|
514
|
+
copyMarkdownFormat,
|
|
515
|
+
copyMarkdownLabel,
|
|
516
|
+
copyMarkdownCopiedLabel,
|
|
511
517
|
openDocs,
|
|
512
518
|
providers: openDocsProviders,
|
|
513
519
|
openDocsTarget,
|
|
@@ -560,6 +566,9 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
560
566
|
"data-actions-alignment": pageActionsAlignment,
|
|
561
567
|
children: /* @__PURE__ */ jsx(PageActions, {
|
|
562
568
|
copyMarkdown,
|
|
569
|
+
copyMarkdownFormat,
|
|
570
|
+
copyMarkdownLabel,
|
|
571
|
+
copyMarkdownCopiedLabel,
|
|
563
572
|
openDocs,
|
|
564
573
|
providers: openDocsProviders,
|
|
565
574
|
openDocsTarget,
|
|
@@ -589,6 +598,7 @@ function DocsPageClient({ tocEnabled, tocStyle = "default", breadcrumbEnabled =
|
|
|
589
598
|
locale: activeLocale,
|
|
590
599
|
question: feedbackQuestion,
|
|
591
600
|
placeholder: feedbackPlaceholder,
|
|
601
|
+
requireComment: feedbackRequireComment,
|
|
592
602
|
positiveLabel: feedbackPositiveLabel,
|
|
593
603
|
negativeLabel: feedbackNegativeLabel,
|
|
594
604
|
submitLabel: feedbackSubmitLabel,
|
package/dist/index.d.mts
CHANGED
|
@@ -16,8 +16,8 @@ import { HoverLink, HoverLinkProps } from "./hover-link.mjs";
|
|
|
16
16
|
import { Prompt, PromptProps } from "./prompt.mjs";
|
|
17
17
|
import { Agent, CodeGroup } from "./mdx.mjs";
|
|
18
18
|
import { DocsLayout } from "fumadocs-ui/layouts/docs";
|
|
19
|
-
import { AIConfig, BreadcrumbConfig, ChangelogConfig, ChangelogFrontmatter, CopyMarkdownConfig, DocsConfig, DocsFeedbackData, DocsFeedbackValue, DocsMetadata, DocsNav, DocsTheme, FeedbackConfig, FontStyle, OGConfig, OpenDocsConfig, OpenDocsProvider, PageActionsConfig, PageFrontmatter, SidebarConfig, ThemeToggleConfig, TypographyConfig, UIConfig, createTheme, deepMerge, defineDocs, extendTheme } from "@farming-labs/docs";
|
|
19
|
+
import { AIConfig, BreadcrumbConfig, ChangelogConfig, ChangelogFrontmatter, CopyMarkdownConfig, CopyMarkdownFormat, DocsConfig, DocsFeedbackData, DocsFeedbackValue, DocsMetadata, DocsNav, DocsTheme, FeedbackConfig, FontStyle, OGConfig, OpenDocsConfig, OpenDocsProvider, PageActionsConfig, PageFrontmatter, SidebarConfig, ThemeToggleConfig, TypographyConfig, UIConfig, createTheme, deepMerge, defineDocs, extendTheme } from "@farming-labs/docs";
|
|
20
20
|
import { DocsBody, DocsPage } from "fumadocs-ui/layouts/docs/page";
|
|
21
21
|
import { Tab, Tabs } from "fumadocs-ui/components/tabs";
|
|
22
22
|
import { CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, Pre } from "fumadocs-ui/components/codeblock";
|
|
23
|
-
export { type AIConfig, Agent, type BreadcrumbConfig, type ChangelogConfig, type ChangelogFrontmatter, CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, CodeGroup, CommandGridUIDefaults, ConcreteUIDefaults, type CopyMarkdownConfig, DocsBody, DocsClientHooks, DocsCommandSearch, type DocsConfig, DocsFeedback, type DocsFeedbackData, type DocsFeedbackProps, type DocsFeedbackValue, DocsLayout, type DocsMetadata, type DocsNav, DocsPage, DocsPageClient, type DocsTheme, type FeedbackConfig, type FontStyle, DefaultUIDefaults as FumadocsUIDefaults, HardlineUIDefaults, HoverLink, type HoverLinkProps, LedgerUIDefaults, type OGConfig, type OpenDocsConfig, type OpenDocsProvider, PageActions, type PageActionsConfig, type PageFrontmatter, Pre, Prompt, type PromptProps, RootProvider, type SidebarConfig, Tab, Tabs, type ThemeToggleConfig, ThreadlineUIDefaults, type TypographyConfig, type UIConfig, commandGrid, concrete, createDocsLayout, createDocsMetadata, createPageMetadata, createTheme, deepMerge, defineDocs, extendTheme, fumadocs, hardline, ledger, threadline, threadlinePageActions, withLangInUrl };
|
|
23
|
+
export { type AIConfig, Agent, type BreadcrumbConfig, type ChangelogConfig, type ChangelogFrontmatter, CodeBlock, CodeBlockTab, CodeBlockTabs, CodeBlockTabsList, CodeBlockTabsTrigger, CodeGroup, CommandGridUIDefaults, ConcreteUIDefaults, type CopyMarkdownConfig, type CopyMarkdownFormat, DocsBody, DocsClientHooks, DocsCommandSearch, type DocsConfig, DocsFeedback, type DocsFeedbackData, type DocsFeedbackProps, type DocsFeedbackValue, DocsLayout, type DocsMetadata, type DocsNav, DocsPage, DocsPageClient, type DocsTheme, type FeedbackConfig, type FontStyle, DefaultUIDefaults as FumadocsUIDefaults, HardlineUIDefaults, HoverLink, type HoverLinkProps, LedgerUIDefaults, type OGConfig, type OpenDocsConfig, type OpenDocsProvider, PageActions, type PageActionsConfig, type PageFrontmatter, Pre, Prompt, type PromptProps, RootProvider, type SidebarConfig, Tab, Tabs, type ThemeToggleConfig, ThreadlineUIDefaults, type TypographyConfig, type UIConfig, commandGrid, concrete, createDocsLayout, createDocsMetadata, createPageMetadata, createTheme, deepMerge, defineDocs, extendTheme, fumadocs, hardline, ledger, threadline, threadlinePageActions, withLangInUrl };
|
package/dist/page-actions.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CopyMarkdownFormat } from "@farming-labs/docs";
|
|
1
2
|
import * as react_jsx_runtime0 from "react/jsx-runtime";
|
|
2
3
|
|
|
3
4
|
//#region src/page-actions.d.ts
|
|
@@ -11,6 +12,9 @@ interface SerializedProvider {
|
|
|
11
12
|
}
|
|
12
13
|
interface PageActionsProps {
|
|
13
14
|
copyMarkdown?: boolean;
|
|
15
|
+
copyMarkdownFormat?: CopyMarkdownFormat;
|
|
16
|
+
copyMarkdownLabel?: string;
|
|
17
|
+
copyMarkdownCopiedLabel?: string;
|
|
14
18
|
openDocs?: boolean;
|
|
15
19
|
providers?: SerializedProvider[];
|
|
16
20
|
openDocsTarget?: "markdown" | "page" | "source" | "github";
|
|
@@ -23,6 +27,9 @@ interface PageActionsProps {
|
|
|
23
27
|
}
|
|
24
28
|
declare function PageActions({
|
|
25
29
|
copyMarkdown,
|
|
30
|
+
copyMarkdownFormat,
|
|
31
|
+
copyMarkdownLabel,
|
|
32
|
+
copyMarkdownCopiedLabel,
|
|
26
33
|
openDocs,
|
|
27
34
|
providers,
|
|
28
35
|
openDocsTarget,
|
package/dist/page-actions.mjs
CHANGED
|
@@ -132,7 +132,7 @@ function pageUrlToMarkdownUrl(pageUrl) {
|
|
|
132
132
|
function fillPromptTemplate(template, values) {
|
|
133
133
|
return template.replace(/\{pageUrl\}/g, values.pageUrl).replace(/\{markdownUrl\}/g, values.markdownUrl).replace(/\{sourceUrl\}/g, values.sourceUrl).replace(/\{mdxUrl\}/g, values.sourceUrl).replace(/\{githubUrl\}/g, values.githubUrl).replace(/\{url\}/g, values.url);
|
|
134
134
|
}
|
|
135
|
-
function PageActions({ copyMarkdown, openDocs, providers, openDocsTarget = DEFAULT_OPEN_DOCS_TARGET, openDocsPrompt = DEFAULT_OPEN_DOCS_PROMPT, alignment = "left", variant = "default", githubFileUrl, analytics = false }) {
|
|
135
|
+
function PageActions({ copyMarkdown, copyMarkdownFormat = "markdown", copyMarkdownLabel = "Copy page", copyMarkdownCopiedLabel = "Copied!", openDocs, providers, openDocsTarget = DEFAULT_OPEN_DOCS_TARGET, openDocsPrompt = DEFAULT_OPEN_DOCS_PROMPT, alignment = "left", variant = "default", githubFileUrl, analytics = false }) {
|
|
136
136
|
const [copied, setCopied] = useState(false);
|
|
137
137
|
const [dropdownOpen, setDropdownOpen] = useState(false);
|
|
138
138
|
const dropdownRef = useRef(null);
|
|
@@ -143,7 +143,7 @@ function PageActions({ copyMarkdown, openDocs, providers, openDocsTarget = DEFAU
|
|
|
143
143
|
const handleCopyMarkdown = useCallback(async () => {
|
|
144
144
|
try {
|
|
145
145
|
let content = "";
|
|
146
|
-
try {
|
|
146
|
+
if (copyMarkdownFormat === "markdown") try {
|
|
147
147
|
const response = await fetch(markdownHref, { headers: { Accept: "text/markdown" } });
|
|
148
148
|
if (response.ok) content = await response.text();
|
|
149
149
|
} catch {}
|
|
@@ -154,6 +154,7 @@ function PageActions({ copyMarkdown, openDocs, providers, openDocsTarget = DEFAU
|
|
|
154
154
|
type: "page_action_copy_markdown",
|
|
155
155
|
properties: {
|
|
156
156
|
contentLength: content.length,
|
|
157
|
+
format: copyMarkdownFormat,
|
|
157
158
|
pathname
|
|
158
159
|
}
|
|
159
160
|
});
|
|
@@ -162,6 +163,7 @@ function PageActions({ copyMarkdown, openDocs, providers, openDocsTarget = DEFAU
|
|
|
162
163
|
} catch {}
|
|
163
164
|
}, [
|
|
164
165
|
analytics,
|
|
166
|
+
copyMarkdownFormat,
|
|
165
167
|
markdownHref,
|
|
166
168
|
pathname
|
|
167
169
|
]);
|
|
@@ -238,7 +240,8 @@ function PageActions({ copyMarkdown, openDocs, providers, openDocsTarget = DEFAU
|
|
|
238
240
|
onClick: handleCopyMarkdown,
|
|
239
241
|
className: "fd-page-action-btn",
|
|
240
242
|
"data-copied": copied,
|
|
241
|
-
|
|
243
|
+
"data-copy-markdown-format": copyMarkdownFormat,
|
|
244
|
+
children: [copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}), /* @__PURE__ */ jsx("span", { children: copied ? copyMarkdownCopiedLabel : copyMarkdownLabel })]
|
|
242
245
|
}),
|
|
243
246
|
openDocs && /* @__PURE__ */ jsxs("a", {
|
|
244
247
|
className: "fd-page-action-btn",
|
|
@@ -271,7 +274,8 @@ function PageActions({ copyMarkdown, openDocs, providers, openDocsTarget = DEFAU
|
|
|
271
274
|
onClick: handleCopyMarkdown,
|
|
272
275
|
className: "fd-page-action-btn",
|
|
273
276
|
"data-copied": copied,
|
|
274
|
-
|
|
277
|
+
"data-copy-markdown-format": copyMarkdownFormat,
|
|
278
|
+
children: [copied ? /* @__PURE__ */ jsx(CheckIcon, {}) : /* @__PURE__ */ jsx(CopyIcon, {}), /* @__PURE__ */ jsx("span", { children: copied ? copyMarkdownCopiedLabel : copyMarkdownLabel })]
|
|
275
279
|
}), openDocs && resolvedProviders.length > 0 && /* @__PURE__ */ jsxs("div", {
|
|
276
280
|
ref: dropdownRef,
|
|
277
281
|
className: "fd-page-action-dropdown",
|
package/dist/tanstack-layout.mjs
CHANGED
|
@@ -193,6 +193,7 @@ function resolveFeedbackConfig(feedback) {
|
|
|
193
193
|
enabled: false,
|
|
194
194
|
question: "How is this guide?",
|
|
195
195
|
placeholder: "Leave your feedback...",
|
|
196
|
+
requireComment: false,
|
|
196
197
|
positiveLabel: "Good",
|
|
197
198
|
negativeLabel: "Bad",
|
|
198
199
|
submitLabel: "Submit"
|
|
@@ -202,11 +203,12 @@ function resolveFeedbackConfig(feedback) {
|
|
|
202
203
|
...defaults,
|
|
203
204
|
enabled: true
|
|
204
205
|
};
|
|
205
|
-
const hasHumanFeedbackConfig = feedback.enabled !== void 0 || feedback.question !== void 0 || feedback.placeholder !== void 0 || feedback.positiveLabel !== void 0 || feedback.negativeLabel !== void 0 || feedback.submitLabel !== void 0 || feedback.onFeedback !== void 0;
|
|
206
|
+
const hasHumanFeedbackConfig = feedback.enabled !== void 0 || feedback.question !== void 0 || feedback.placeholder !== void 0 || feedback.requireComment !== void 0 || feedback.positiveLabel !== void 0 || feedback.negativeLabel !== void 0 || feedback.submitLabel !== void 0 || feedback.onFeedback !== void 0;
|
|
206
207
|
return {
|
|
207
208
|
enabled: feedback.enabled === true || feedback.enabled !== false && hasHumanFeedbackConfig,
|
|
208
209
|
question: feedback.question ?? defaults.question,
|
|
209
210
|
placeholder: feedback.placeholder ?? defaults.placeholder,
|
|
211
|
+
requireComment: feedback.requireComment ?? defaults.requireComment,
|
|
210
212
|
positiveLabel: feedback.positiveLabel ?? defaults.positiveLabel,
|
|
211
213
|
negativeLabel: feedback.negativeLabel ?? defaults.negativeLabel,
|
|
212
214
|
submitLabel: feedback.submitLabel ?? defaults.submitLabel
|
|
@@ -238,6 +240,7 @@ function TanstackDocsLayout({ config, tree, locale, description, readingTime, la
|
|
|
238
240
|
const layoutDimensions = config.theme?.ui?.layout;
|
|
239
241
|
const pageActions = config.pageActions;
|
|
240
242
|
const copyMarkdownEnabled = resolveBool(pageActions?.copyMarkdown);
|
|
243
|
+
const copyMarkdownConfig = pageActions?.copyMarkdown && typeof pageActions.copyMarkdown === "object" ? pageActions.copyMarkdown : void 0;
|
|
241
244
|
const openDocsEnabled = resolveBool(pageActions?.openDocs);
|
|
242
245
|
const pageActionsPosition = pageActions?.position ?? "below-title";
|
|
243
246
|
const pageActionsAlignment = pageActions?.alignment ?? "left";
|
|
@@ -354,6 +357,8 @@ function TanstackDocsLayout({ config, tree, locale, description, readingTime, la
|
|
|
354
357
|
entry: config.entry ?? "docs",
|
|
355
358
|
locale,
|
|
356
359
|
copyMarkdown: copyMarkdownEnabled,
|
|
360
|
+
copyMarkdownLabel: copyMarkdownConfig?.label,
|
|
361
|
+
copyMarkdownCopiedLabel: copyMarkdownConfig?.copiedLabel,
|
|
357
362
|
openDocs: openDocsEnabled,
|
|
358
363
|
openDocsProviders,
|
|
359
364
|
openDocsTarget: openDocsConfig?.target,
|
|
@@ -372,6 +377,7 @@ function TanstackDocsLayout({ config, tree, locale, description, readingTime, la
|
|
|
372
377
|
feedbackEnabled: feedbackConfig.enabled,
|
|
373
378
|
feedbackQuestion: feedbackConfig.question,
|
|
374
379
|
feedbackPlaceholder: feedbackConfig.placeholder,
|
|
380
|
+
feedbackRequireComment: feedbackConfig.requireComment,
|
|
375
381
|
feedbackPositiveLabel: feedbackConfig.positiveLabel,
|
|
376
382
|
feedbackNegativeLabel: feedbackConfig.negativeLabel,
|
|
377
383
|
feedbackSubmitLabel: feedbackConfig.submitLabel,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@farming-labs/theme",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.17",
|
|
4
4
|
"description": "Theme package for @farming-labs/docs — layout, provider, MDX components, and styles",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"docs",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"tsdown": "^0.20.3",
|
|
146
146
|
"typescript": "^5.9.3",
|
|
147
147
|
"vitest": "^4.1.8",
|
|
148
|
-
"@farming-labs/docs": "0.2.
|
|
148
|
+
"@farming-labs/docs": "0.2.17"
|
|
149
149
|
},
|
|
150
150
|
"peerDependencies": {
|
|
151
151
|
"@farming-labs/docs": ">=0.0.1",
|