mirror of
https://github.com/slint-ui/slint.git
synced 2025-11-03 05:12:55 +00:00
This fixes the project so it can be published. This documents the publishing process. This fixes a few bugs in the plugin, especially for the non dev mode where things would fail to refresh as the Figma file is edited.
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
// Copyright © SixtyFPS GmbH <info@slint.dev>
|
|
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
|
|
// cSpell: ignore codegen
|
|
|
|
import { listenTS, updateUI } from "./utils/code-utils.js";
|
|
import { generateSlintSnippet } from "./utils/property-parsing.js";
|
|
|
|
if (figma.editorType === "dev" && figma.mode === "codegen") {
|
|
figma.codegen.on("generate", async ({ node }) => {
|
|
const slintSnippet = generateSlintSnippet(node);
|
|
return slintSnippet
|
|
? [
|
|
{
|
|
title: "Slint Code: " + node.name,
|
|
language: "CSS",
|
|
code: slintSnippet,
|
|
},
|
|
]
|
|
: [];
|
|
});
|
|
}
|
|
|
|
if (figma.editorType === "figma" && figma.mode === "default") {
|
|
figma.showUI(__html__, {
|
|
themeColors: true,
|
|
width: 400,
|
|
height: 320,
|
|
});
|
|
updateUI();
|
|
}
|
|
|
|
listenTS("copyToClipboard", ({ result }) => {
|
|
if (result) {
|
|
figma.notify("Copied!");
|
|
} else {
|
|
figma.notify("Failed to copy");
|
|
}
|
|
});
|
|
|
|
figma.on("selectionchange", () => {
|
|
if (figma.editorType === "figma" && figma.mode === "default") {
|
|
updateUI();
|
|
}
|
|
});
|