
Security News
Open Source Maintainers Demand Ability to Block Copilot-Generated Issues and PRs
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
@cartamd/plugin-component
Advanced tools
This plugin adds support for mapping certain elements to **components** inside the editor.
This plugin adds support for mapping certain elements to components inside the editor.
npm i @cartamd/plugin-component
The first thing to do is to map certain elements(nodes) to their corresponding components. For example, if you want to use a custom renderer for images:
<!-- Image.svelte -->
<script>
export let src;
export let alt;
</script>
<!-- Your custom component... -->
<img {src} {alt} />
import { Carta } from 'carta-md';
import { component } from '@cartamd/plugin-component';
import { svelte, initializeComponents } from '@cartamd/plugin-component/svelte';
import Image from './Image.svelte';
const mapped = [svelte('img', Image) /* other components ... */];
const carta = new Carta({
extensions: [component(mapped, initializeComponents)]
// ...
});
You can use custom logic when selecting which nodes to map:
import { svelteCustom } from '@cartamd/plugin-component/svelte';
import MyComponent from '...';
const mapped = [
svelteCustom(
'my-component-id',
(node) => {
// Do something with the node to determine whether to replace it
},
MyComponent
) /* other components ... */
];
<slot />
To render children, you need to use a custom <Slot />
component:
<!-- Heading.svelte -->
<script>
import { Slot } from '@cartamd/plugin-component/svelte';
</script>
<h1>
<Slot />
</h1>
When pre-rendering content on the server (using the <PreRendered>
component), the components will not be mounted by default. You need to use the initializeComponents
function yourself.
<script>
import { initializeComponents } from '@cartamd/plugin-component/svelte';
import { onMount } from 'svelte';
// ...
export let data;
let container;
// Needs access to the mapped components
const mapped = /* ... */;
onMount(() => {
initializeComponents(mapped, container);
})
</script>
<div bind:this={container}>
<PreRendered html={data.html} />
</div>
<svelte:head>
is not available during server-side rendering.FAQs
This plugin adds support for mapping certain elements to **components** inside the editor.
The npm package @cartamd/plugin-component receives a total of 90 weekly downloads. As such, @cartamd/plugin-component popularity was classified as not popular.
We found that @cartamd/plugin-component demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Research
Security News
Malicious Koishi plugin silently exfiltrates messages with hex strings to a hardcoded QQ account, exposing secrets in chatbots across platforms.
Research
Security News
Malicious PyPI checkers validate stolen emails against TikTok and Instagram APIs, enabling targeted account attacks and dark web credential sales.