
Security News
RubyGems Adds Cooldown Feature to Bundler for Newly Published Gems
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.
@portabletext/plugin-paste-link
Advanced tools
@portabletext/plugin-paste-linkAllows pasting links in the Portable Text Editor
npm install @portabletext/plugin-paste-link
Import the PasteLinkPlugin React component and place it inside the EditorProvider:
import {
defineSchema,
EditorProvider,
PortableTextEditable,
} from '@portabletext/editor'
import {PasteLinkPlugin} from '@portabletext/plugin-paste-link'
const schemaDefinition = defineSchema({
annotations: [{name: 'link', fields: [{name: 'href', type: 'string'}]}],
})
function App() {
return (
<EditorProvider initialConfig={{schemaDefinition}}>
<PortableTextEditable />
<PasteLinkPlugin />
</EditorProvider>
)
}
By default, the plugin looks for a link annotation with an href field of type string.
Use the guard prop to control when the paste link behavior runs. Return false to skip the behavior and fall through to default paste handling:
import {getActiveStyle} from '@portabletext/editor/selectors'
;<PasteLinkPlugin
guard={({snapshot}) => {
// Skip paste-link on h1 blocks (e.g., document titles)
return getActiveStyle(snapshot) !== 'h1'
}}
/>
You can customize the link annotation with the link prop:
<PasteLinkPlugin
link={({context, value}) => {
const schemaType = context.schema.annotations.find(
(annotation) => annotation.name === 'customLink',
)
if (!schemaType) return undefined
return {_type: schemaType.name, url: value.href}
}}
/>
When text is selected and a URL is pasted, the plugin adds a link annotation to the selection.
When text with an existing link annotation is selected and a URL is pasted, the plugin replaces the existing link with a new one containing the pasted URL.
When the selection is collapsed and a URL is pasted, the plugin inserts the URL text with a link annotation. Existing decorators (bold, italic, etc.) are preserved.
PasteLinkPluginReact component that registers paste behaviors for handling URLs.
guard (optional): A PasteLinkGuard function that controls when the paste link behavior runs.
{snapshot, event, dom} - standard behavior guard parameterstrue to allow the behavior, false to skip and fall through to default paste handling.link (optional): A LinkMatcher function that converts a pasted URL into a link annotation.
context: Contains schema and keyGenerator from the editor contextvalue: Contains href (the pasted URL string)_type (annotation type name), optional _key, and any additional properties. Return undefined to skip the behavior.link annotation with an href field of type string.type PasteLinkGuard = BehaviorGuard<
Extract<NativeBehaviorEvent, {type: 'clipboard.paste'}>,
true
>
type LinkMatcher = (params: {
context: LinkMatcherContext
value: LinkMatcherValue
}) => LinkMatcherResult | undefined
type LinkMatcherContext = Pick<EditorContext, 'schema' | 'keyGenerator'>
type LinkMatcherValue = {href: string}
type LinkMatcherResult = {
_type: string
_key?: string
[other: string]: unknown
}
http:https:mailto:tel:URLs with other protocols are pasted as plain text.
MIT
FAQs
Allows pasting links in the Portable Text Editor
The npm package @portabletext/plugin-paste-link receives a total of 348,337 weekly downloads. As such, @portabletext/plugin-paste-link popularity was classified as popular.
We found that @portabletext/plugin-paste-link demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 11 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
RubyGems and Bundler 4.0.13 introduced an opt-in cooldown feature that delays newly published gems during dependency resolution.

Security News
pnpm 11.5 now recognizes npm staged publish approvals in release metadata, preventing those releases from being mistaken for lower-trust package publishes.

Security News
Federal audit finds NIST lacked a plan to clear the NVD backlog, wasted funds on duplicate work, and delayed use of CISA data.