yuanqing / create-figma-plugin

:battery: The comprehensive toolkit for developing plugins and widgets for Figma and FigJam
https://yuanqing.github.io/create-figma-plugin/
MIT License
902 stars 85 forks source link

Uncaught Error: No UI defined for command 'generate' #220

Open zicen opened 5 months ago

zicen commented 5 months ago

image main.ts:

import { showUI } from '@create-figma-plugin/utilities'

export default function () {
  figma.codegen.on('preferenceschange', (event: CodegenPreferencesEvent) => {
    console.log("preferenceschange", event);
    if (event.propertyName === 'editor') {
      showUI({ height: 240, width: 320 })
    } 
    return Promise.resolve();
  });
}

package.json:

{
  "dependencies": {
    "@create-figma-plugin/ui": "^3.1.0",
    "@create-figma-plugin/utilities": "^3.1.0",
    "preact": ">=10",
    "prismjs": "1.29.0",
    "react-simple-code-editor": "0.13.1"
  },
  "devDependencies": {
    "@create-figma-plugin/build": "^3.1.0",
    "@create-figma-plugin/tsconfig": "^3.1.0",
    "@figma/plugin-typings": "1.82.0",
    "@types/prismjs": "1.26.3",
    "typescript": ">=4"
  },
  "scripts": {
    "build": "build-figma-plugin --typecheck --minify",
    "watch": "build-figma-plugin --typecheck --watch"
  },
  "figma-plugin": {
    "editorType": [
      "figma",
      "dev"
    ],
    "id": "react-editor",
    "name": "React Editor2",
    "main": "src/main.ts",
    "ui": "src/ui.tsx",
    "capabilities": [
      "codegen",
      "inspect"
    ],
    "codegenLanguages": [
      {
        "label": "Snippets",
        "value": "snippets"
      }
    ],
    "codegenPreferences": [
      {
        "itemType": "action",
        "propertyName": "editor",
        "label": "编辑"
      }
    ]
  }
}
zicen commented 5 months ago

I have an existing plugin and I'm planning to migrate it to React. Therefore, I used this plugin, but I encountered an issue with the UI display when clicking on the options in the 'generate' menu. The code above is my modification based on the plugin/react-editor template. Could you help me identify the problem?

zicen commented 5 months ago

I have uploaded the code here. https://github.com/zicen/react-editor-2

anas-araid commented 3 months ago

I have the same issue, in the manifest.json i have this command

  "relaunchButtons": [
    {
      "command": "open",
      "name": "Open Rive to Figma"
    }
  ],

and in main.ts this one: figma.root.setRelaunchData({ open: "Description" });

but when i try to open the plugin from the sidebar, it throws me this error:

Uncaught Error: No UI defined for command 'open'

Docs