Files
webstudio/apps/builder/app/shared/copy-paste/plugin-html.ts
T
Oleg Isonen d6362b22ba feat: Limit breakpoint amount (#5776)
Limits projects to 8 editable breakpoints, with a toast warning when
users try to add more. Pasted/imported styles that exceed the limit are
merged into the closest existing breakpoint instead of creating new
ones.

Also updates the breakpoint editor UI with required names, hover-only
trash actions, scrolling, and tighter layout polish.


Closes https://github.com/webstudio-is/webstudio/issues/4209
2026-05-26 15:59:18 +02:00

36 lines
1.3 KiB
TypeScript

import type { WebstudioFragment } from "@webstudio-is/sdk";
import { generateFragmentFromHtml } from "../html";
import { insertWebstudioFragmentAt } from "../instance-utils";
import { generateFragmentFromTailwind } from "../tailwind/tailwind";
import { denormalizeSrcProps } from "./asset-upload";
import type { Plugin } from "./init-copy-paste";
import { builderApi } from "../builder-api";
import { breakpointPasteLimitWarning } from "../breakpoints";
const inceptionMark = `<!-- @webstudio/inception/1 -->`;
export const html: Plugin = {
name: "html",
mimeType: "text/plain",
onPaste: async (html: string) => {
const parseResult = generateFragmentFromHtml(html);
const { skippedSelectors } = parseResult;
let fragment: WebstudioFragment = parseResult;
fragment = await denormalizeSrcProps(fragment);
if (html.includes(inceptionMark)) {
fragment = await generateFragmentFromTailwind(fragment);
}
const result = insertWebstudioFragmentAt(fragment, undefined, undefined, {
onBreakpointLimitMerge: () => {
builderApi.toast.warn(breakpointPasteLimitWarning);
},
});
if (skippedSelectors.length > 0) {
builderApi.toast.info(
`Skipped nested selectors (no matching elements): ${skippedSelectors.join(", ")}`
);
}
return result;
},
};