Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions packages/kilo-docs/components/CopyLine.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import * as React from "react"
import { Codicon } from "./Codicon"

interface CopyLineProps {
text: string
}

export function CopyLine({ text }: CopyLineProps) {
const timeout = React.useRef(null)
const [copied, setCopied] = React.useState(false)

React.useEffect(() => {
return () => {
if (timeout.current) {
clearTimeout(timeout.current)
}
}
}, [])

const copy = async () => {
try {
await navigator.clipboard.writeText(text)
setCopied(true)
if (timeout.current) {
clearTimeout(timeout.current)
}
timeout.current = setTimeout(() => setCopied(false), 2000)
} catch (err) {
console.error("Failed to copy line:", err)
}
}

return (
<div className="copy-line" aria-live="polite">
<button
type="button"
className="copy-button"
onClick={copy}
aria-label="Copy text to clipboard"
title={copied ? "Copied!" : "Copy text"}
>
{copied ? <Codicon name="check" /> : <Codicon name="copy" />}
</button>
<pre className="language-text">
<code>{text}</code>
</pre>
<style jsx>
{`
.copy-line {
position: relative;
}

.copy-button {
position: absolute;
top: 8px;
right: 8px;
padding: 6px 8px;
background: rgba(0, 0, 0, 0.05);
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 4px;
color: rgba(0, 0, 0, 0.4);
cursor: pointer;
display: flex;
align-items: center;
justify-content: center;
transition: all 0.2s ease;
z-index: 10;
}

.copy-button:hover {
background: rgba(0, 0, 0, 0.1);
color: rgba(0, 0, 0, 0.6);
border-color: rgba(0, 0, 0, 0.2);
}

:global(.dark) .copy-button {
background: rgba(255, 255, 255, 0.05);
border-color: rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.4);
}

:global(.dark) .copy-button:hover {
background: rgba(255, 255, 255, 0.1);
color: rgba(255, 255, 255, 0.7);
border-color: rgba(255, 255, 255, 0.2);
}

.copy-button:active {
transform: scale(0.95);
}

.copy-line :global(pre) {
padding-right: 3.5rem;
}
`}
</style>
</div>
)
}
1 change: 1 addition & 0 deletions packages/kilo-docs/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from "./Callout"
export * from "./CodeBlock"
export * from "./Codicon"
export * from "./CopyPageButton"
export * from "./CopyLine"
export * from "./Heading"
export * from "./Icon"
export * from "./Image"
Expand Down
4 changes: 1 addition & 3 deletions packages/kilo-docs/markdoc/partials/install-jetbrains.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ To install the EAP build and receive updates:
3. Click the gear icon and choose **Manage Plugin Repositories**
4. Add this repository URL:

```text
https://plugins.jetbrains.com/plugins/list?channel=eap&pluginId=28350
```
{% copyLine text="https://plugins.jetbrains.com/plugins/list?channel=eap&pluginId=28350" /%}

5. Return to the **Marketplace** tab
6. Search for **Kilo Code**
Expand Down
13 changes: 13 additions & 0 deletions packages/kilo-docs/markdoc/tags/copy-line.markdoc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { CopyLine } from "../../components"

export const copyLine = {
render: CopyLine,
selfClosing: true,
attributes: {
text: {
type: String,
required: true,
description: "The exact one-line text to display and copy",
},
},
}
1 change: 1 addition & 0 deletions packages/kilo-docs/markdoc/tags/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* Use this file to export your markdoc tags */
export * from "./callout.markdoc"
export * from "./codicon.markdoc"
export * from "./copy-line.markdoc"
export * from "./tabs.markdoc"
export * from "./icon.markdoc"
export * from "./image.markdoc"
Expand Down
Loading