mirror of
https://github.com/webstudio-is/webstudio.git
synced 2026-10-28 23:57:17 +09:00
22 lines
750 B
TypeScript
22 lines
750 B
TypeScript
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";
|
|
|
|
const inceptionMark = `<!-- @webstudio/inception/1 -->`;
|
|
|
|
export const html: Plugin = {
|
|
name: "html",
|
|
mimeType: "text/plain",
|
|
onPaste: async (html: string) => {
|
|
let fragment = generateFragmentFromHtml(html);
|
|
fragment = await denormalizeSrcProps(fragment);
|
|
if (html.includes(inceptionMark)) {
|
|
fragment = await generateFragmentFromTailwind(fragment);
|
|
}
|
|
const result = insertWebstudioFragmentAt(fragment);
|
|
return result;
|
|
},
|
|
};
|