Skip to content

Commit

Permalink
feat: add copy icon for link preview (#1491)
Browse files Browse the repository at this point in the history
* feat: add copy icon for link preview

* chore: changeset

* chore: adjust fill
  • Loading branch information
Saul-Mirone authored Aug 28, 2024
1 parent 06bbe86 commit 8e2c866
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/shiny-spoons-learn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@milkdown/crepe": patch
---

Add copy link button
4 changes: 2 additions & 2 deletions packages/crepe/src/feature/link-tooltip/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { configureLinkTooltip, linkTooltipConfig, linkTooltipPlugin } from '@milkdown/kit/component/link-tooltip'
import type { DefineFeature, Icon } from '../shared'
import { confirmIcon, editIcon, linkIcon, removeIcon } from '../../icons'
import { confirmIcon, copyIcon, editIcon, removeIcon } from '../../icons'

interface LinkTooltipConfig {
linkIcon: Icon
Expand All @@ -19,7 +19,7 @@ export const defineFeature: DefineFeature<LinkTooltipFeatureConfig> = (editor, c
.config((ctx) => {
ctx.update(linkTooltipConfig.key, prev => ({
...prev,
linkIcon: config?.linkIcon ?? (() => linkIcon),
linkIcon: config?.linkIcon ?? (() => copyIcon),
editButton: config?.editButton ?? (() => editIcon),
removeButton: config?.removeButton ?? (() => removeIcon),
confirmButton: config?.confirmButton ?? (() => confirmIcon),
Expand Down
15 changes: 15 additions & 0 deletions packages/crepe/src/icons/copy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { html } from 'atomico'

export const copyIcon = html`
<svg
xmlns="http://www.w3.org/2000/svg"
height="24px"
viewBox="0 -960 960 960"
width="24px"
fill="none"
>
<path
d="M360-240q-33 0-56.5-23.5T280-320v-480q0-33 23.5-56.5T360-880h360q33 0 56.5 23.5T800-800v480q0 33-23.5 56.5T720-240H360Zm0-80h360v-480H360v480ZM200-80q-33 0-56.5-23.5T120-160v-560h80v560h440v80H200Zm160-240v-480 480Z"
/>
</svg>
`
1 change: 1 addition & 0 deletions packages/crepe/src/icons/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export * from './chevronDown'
export * from './clear'
export * from './code'
export * from './confirm'
export * from './copy'
export * from './divider'
export * from './dragHandle'
export * from './edit'
Expand Down
4 changes: 4 additions & 0 deletions packages/crepe/src/theme/common/link-tooltip.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@
color: var(--crepe-color-outline);
fill: var(--crepe-color-outline);
}
border-radius: 8px;
padding: 3px;
line-height: 24px;
&:hover {
background: var(--crepe-color-hover);
}
}

& > .link-display {
Expand Down

0 comments on commit 8e2c866

Please sign in to comment.