feat: relaunch button in right panel + drag-resize window

- package.json: add relaunchButtons (runAI) for right-panel shortcut
- main.ts: setRelaunchData + RESIZE_WINDOW handler (figma.ui.resize)
- ui.tsx: useWindowResize native drag handle + expand/collapse toggle
- .gitignore: exclude _reference/ (temp old-plugin copy)
- IDEA.md: commit+push to Gitea is mandatory workflow
This commit is contained in:
Hermes committed 2026-09-09 12:38:13 +02:00
1 parent 4507162f42
commit 6c7be98a82
6 files changed
+89 -8

No files matched your search

+1
View File
@@ -1,3 +1,4 @@
node_modules/
build/
*.log
_reference/
+6
View File
@@ -41,6 +41,12 @@
5. В Figma: Plugins → Development → Import plugin from manifest → выбрать `manifest.json` из папки Matebook
6. Запуск плагина для теста
## Правила ведения репозитория
- **Коммит + пуш в Gitea — обязательная часть рабочего флоу.** Любое осмысленное изменение в коде/доках коммитится и пушится в `origin/main` сразу по завершении задачи (не копить локально).
- `_reference/` — временные копии чужих/старых плагинов для сверки; в git не попадают (в `.gitignore`).
- `build/` и `node_modules/` не коммитятся (собираются локально / на Matebook), см. синхронизацию через tar в KNOWLEDGE.md.
## Правила ведения KNOWLEDGE.md
- KNOWLEDGE.md — живая копилка gotcha/решений. Hermes (агент) **имеет право дописывать и править KNOWLEDGE.md самостоятельно, без вопросов к пользователю**, когда находит новую проблему и её решение по ходу работы над проектом.
+1 -1
View File
@@ -1 +1 @@
{"api":"1.0.0","editorType":["figma"],"id":"ai-plugin-mvp","name":"AI assistant (MVP)","main":"build/main.js","ui":"build/ui.js"}
{"api":"1.0.0","editorType":["figma"],"id":"ai-plugin-mvp","name":"AI assistant (MVP)","main":"build/main.js","ui":"build/ui.js","relaunchButtons":[{"name":"Запустить AI assistant","command":"runAI"}]}
+8 -1
View File
@@ -22,6 +22,13 @@
"id": "ai-plugin-mvp",
"name": "AI assistant (MVP)",
"main": "src/main.ts",
"ui": "src/ui.tsx"
"ui": "src/ui.tsx",
"relaunchButtons": {
"runAI": {
"name": "Запустить AI assistant",
"main": "src/main.ts",
"ui": "src/ui.tsx"
}
}
}
}
+10 -1
View File
@@ -1,5 +1,14 @@
import { showUI } from '@create-figma-plugin/utilities'
import { emit, on, showUI } from '@create-figma-plugin/utilities'
export default function () {
// Глобальный ярлык relaunch в правой панели Figma (команда runAI из manifest.json)
figma.root.setRelaunchData({ runAI: '' })
// Ресайз окна плагина (drag за угол в UI -> useWindowResize -> RESIZE_WINDOW)
on('RESIZE_WINDOW', function (windowSize: { width: number; height: number }) {
const { width, height } = windowSize
figma.ui.resize(width, height)
})
showUI({ width: 320, height: 200, themeColors: true })
}
+63 -5
View File
@@ -1,12 +1,70 @@
import { render, Container, Text, Muted, VerticalSpace } from '@create-figma-plugin/ui'
import {
render,
Container,
Text,
Muted,
VerticalSpace,
IconButton,
IconExpand24,
IconCollapse24,
useWindowResize
} from '@create-figma-plugin/ui'
import { emit } from '@create-figma-plugin/utilities'
import { h } from 'preact'
import { useState } from 'preact/hooks'
const MIN_WINDOW_SIZE = { width: 320, height: 200 }
const MAX_WINDOW_SIZE = { width: 800, height: 800 }
function Plugin () {
const [currentWindowSize, setCurrentWindowSize] = useState(MIN_WINDOW_SIZE)
// Нативный drag-ресайз окна Figma (тянуть за правый нижний угол)
useWindowResize(function (windowSize: { width: number; height: number }) {
setCurrentWindowSize(windowSize)
emit('RESIZE_WINDOW', windowSize)
})
function toggleWindowSize () {
const isMaximized =
currentWindowSize.width >= MAX_WINDOW_SIZE.width &&
currentWindowSize.height >= MAX_WINDOW_SIZE.height
const next = isMaximized ? MIN_WINDOW_SIZE : MAX_WINDOW_SIZE
setCurrentWindowSize(next)
emit('RESIZE_WINDOW', next)
}
const isMaximized =
currentWindowSize.width >= MAX_WINDOW_SIZE.width &&
currentWindowSize.height >= MAX_WINDOW_SIZE.height
return (
<Container space="medium" style={{ height: '100%', display: 'flex', alignItems: 'center', justifyContent: 'center', flexDirection: 'column' }}>
<Text style={{ fontSize: '13px', fontWeight: 600 }}>Hello, Figma ✦</Text>
<VerticalSpace space="small" />
<Muted>AI assistant (MVP) — bootstrap</Muted>
<Container space="medium" style={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
<div style={{ display: 'flex', justifyContent: 'flex-end' }}>
<IconButton
title={isMaximized ? 'Свернуть окно' : 'Развернуть окно'}
onClick={toggleWindowSize}
>
{isMaximized ? <IconCollapse24 /> : <IconExpand24 />}
</IconButton>
</div>
<div
style={{
flex: 1,
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
flexDirection: 'column'
}}
>
<Text style={{ fontSize: '13px', fontWeight: 600 }}>Hello, Figma ✦</Text>
<VerticalSpace space="small" />
<Muted>AI assistant (MVP) — bootstrap</Muted>
<VerticalSpace space="small" />
<Muted>
{currentWindowSize.width} × {currentWindowSize.height}
</Muted>
</div>
</Container>
)
}