Open source website builder and Webflow alternative. Webstudio is an advanced visual builder that connects to any headless CMS, supports all CSS properties, and can be hosted anywhere, including with us.
TypeScript accessibilityalternativecloudflarecloudflare-workersdesignfreefrontendopen-sourceradix-uireactremixweb-developmentwebflowwebsite-builderwebsite-developmentwebsiteswebstudio
import { nativeClient } from "../trpc/trpc-client";
import { $project } from "../sync/data-stores";
import { isLikelyWebstudioJsxFragment } from "@webstudio-is/project-build/transfer";
import { pasteHandled, pasteIgnored, type Plugin } from "./copy-paste";
import { insertFragmentWithBreakpointWarning } from "./fragment-utils";
export const isLikelyWebstudioJsx = isLikelyWebstudioJsxFragment;
const handlePasteJsx = async (source: string) => {
if (isLikelyWebstudioJsx(source) === false) {
return pasteIgnored;
}
const project = $project.get();
if (project === undefined) {
return pasteIgnored;
}
try {
const fragment = await nativeClient.build.createJsxFragment.query({
projectId: project.id,
source,
});
await insertFragmentWithBreakpointWarning(fragment);
return pasteHandled;
} catch (error) {
return {
success: false,
error:
error instanceof Error
? error.message
: "Could not paste Webstudio JSX fragment.",
} as const;
}
};
export const jsx: Plugin = {
name: "jsx",
mimeType: "text/plain",
onPaste: handlePasteJsx,
};
export const __testing__ = {
handlePasteJsx,
};