@growgroup/visual-editor 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/NOTICE +52 -0
- package/README.md +143 -0
- package/dist/editor.css +2 -0
- package/package.json +94 -0
- package/src/components/DeckSlideRender.tsx +21 -0
- package/src/components/SaveNote.tsx +21 -0
- package/src/components/auth/AuthProvider.tsx +44 -0
- package/src/components/ui/accordion.tsx +57 -0
- package/src/components/ui/alert-dialog.tsx +141 -0
- package/src/components/ui/badge.tsx +36 -0
- package/src/components/ui/button.tsx +56 -0
- package/src/components/ui/card.tsx +76 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/collapsible.tsx +11 -0
- package/src/components/ui/context-menu.tsx +200 -0
- package/src/components/ui/dialog.tsx +122 -0
- package/src/components/ui/dropdown-menu.tsx +201 -0
- package/src/components/ui/input.tsx +22 -0
- package/src/components/ui/label.tsx +26 -0
- package/src/components/ui/popover.tsx +33 -0
- package/src/components/ui/scroll-area.tsx +48 -0
- package/src/components/ui/scrubbable-label.tsx +95 -0
- package/src/components/ui/select.tsx +159 -0
- package/src/components/ui/separator.tsx +31 -0
- package/src/components/ui/slider.tsx +28 -0
- package/src/components/ui/switch.tsx +29 -0
- package/src/components/ui/tabs.tsx +55 -0
- package/src/components/ui/textarea.tsx +22 -0
- package/src/components/ui/tooltip.tsx +32 -0
- package/src/components/viewer/useDeck.ts +58 -0
- package/src/editor/EditorContext.tsx +632 -0
- package/src/editor/EditorToolbar.tsx +446 -0
- package/src/editor/FrontendVisualEditor.tsx +2595 -0
- package/src/editor/autosave.ts +34 -0
- package/src/editor/components/AiPromptPopover.tsx +378 -0
- package/src/editor/components/BreakpointGuides.tsx +323 -0
- package/src/editor/components/BreakpointSelector.tsx +180 -0
- package/src/editor/components/ComponentPropertyEditor.tsx +426 -0
- package/src/editor/components/CssEditorDialog.tsx +168 -0
- package/src/editor/components/EditorCanvas.tsx +987 -0
- package/src/editor/components/EditorContextMenu.tsx +515 -0
- package/src/editor/components/EditorFooter.tsx +81 -0
- package/src/editor/components/EditorHeader.tsx +524 -0
- package/src/editor/components/EditorLayerPanel.tsx +1197 -0
- package/src/editor/components/EditorPropertyPanel.tsx +2996 -0
- package/src/editor/components/EditorSidebar.tsx +226 -0
- package/src/editor/components/FigmaColorPicker.tsx +1577 -0
- package/src/editor/components/HtmlEditorDialog.tsx +71 -0
- package/src/editor/components/HtmlImportDialog.tsx +346 -0
- package/src/editor/components/JsEditorDialog.tsx +175 -0
- package/src/editor/components/LayerTreeItem.tsx +494 -0
- package/src/editor/components/MasterComponentEditor.tsx +846 -0
- package/src/editor/components/MediaLibraryDialog.tsx +447 -0
- package/src/editor/components/PageSettingsDialog.tsx +776 -0
- package/src/editor/components/VariablePicker.tsx +355 -0
- package/src/editor/components/VariablesDialog.tsx +564 -0
- package/src/editor/components/VariantEditor.tsx +687 -0
- package/src/editor/components/VariantMatrix.tsx +507 -0
- package/src/editor/components/component-panel/CategoryAccordion.tsx +139 -0
- package/src/editor/components/component-panel/ComponentGrid.tsx +51 -0
- package/src/editor/components/component-panel/ComponentItem.tsx +368 -0
- package/src/editor/components/component-panel/ComponentPanel.tsx +275 -0
- package/src/editor/components/component-panel/ComponentSearch.tsx +82 -0
- package/src/editor/components/component-panel/VariantList.tsx +260 -0
- package/src/editor/components/component-panel/index.ts +12 -0
- package/src/editor/components/index.ts +48 -0
- package/src/editor/components/multi-page/CanvasZoomControls.tsx +71 -0
- package/src/editor/components/multi-page/InfiniteCanvas.tsx +95 -0
- package/src/editor/components/multi-page/MultiPageCanvasView.tsx +1404 -0
- package/src/editor/components/multi-page/PageFrameOverlay.tsx +76 -0
- package/src/editor/components/multi-page/PageLabel.tsx +34 -0
- package/src/editor/components/multi-page/PageLivePreview.tsx +242 -0
- package/src/editor/components/multi-page/PageThumbnail.tsx +59 -0
- package/src/editor/components/multi-page/index.ts +7 -0
- package/src/editor/components/ppt/PptChrome.tsx +2508 -0
- package/src/editor/components/ppt/PptComments.tsx +589 -0
- package/src/editor/components/ppt/PptDesignProposals.tsx +275 -0
- package/src/editor/components/ppt/PptFormatPane.tsx +320 -0
- package/src/editor/components/ppt/PptNotes.tsx +246 -0
- package/src/editor/components/property-panel/AlignmentPanel.tsx +110 -0
- package/src/editor/components/property-panel/AutoLayoutPanel.tsx +615 -0
- package/src/editor/components/property-panel/BorderSection.tsx +104 -0
- package/src/editor/components/property-panel/CompactNumberInput.tsx +237 -0
- package/src/editor/components/property-panel/CompactSizeInput.tsx +148 -0
- package/src/editor/components/property-panel/EffectSection.tsx +157 -0
- package/src/editor/components/property-panel/FillSection.tsx +69 -0
- package/src/editor/components/property-panel/GoogleFontPicker.tsx +192 -0
- package/src/editor/components/property-panel/ImageSection.tsx +206 -0
- package/src/editor/components/property-panel/ImgSrcSection.tsx +125 -0
- package/src/editor/components/property-panel/InstanceOverrideSection.tsx +413 -0
- package/src/editor/components/property-panel/LayoutSection.tsx +105 -0
- package/src/editor/components/property-panel/LinkSection.tsx +103 -0
- package/src/editor/components/property-panel/PropertyVariablePicker.tsx +311 -0
- package/src/editor/components/property-panel/ScalePanel.tsx +212 -0
- package/src/editor/components/property-panel/TypographySection.tsx +230 -0
- package/src/editor/components/property-panel/UnitAwareNumberInput.tsx +238 -0
- package/src/editor/components/property-panel/VariableAwareColorInput.tsx +477 -0
- package/src/editor/components/property-panel/VariableAwareInput.tsx +606 -0
- package/src/editor/components/property-panel/VariableAwareSizeInput.tsx +588 -0
- package/src/editor/components/property-panel/VariableAwareUnitInput.tsx +546 -0
- package/src/editor/components/property-panel/index.ts +24 -0
- package/src/editor/components/property-panel/unit-utils.ts +261 -0
- package/src/editor/components/shell/EditorTopBar.tsx +392 -0
- package/src/editor/components/shell/LeftPanel.tsx +47 -0
- package/src/editor/components/shell/PagesPanel.tsx +118 -0
- package/src/editor/components/variables-panel/ColorValueCell.tsx +165 -0
- package/src/editor/components/variables-panel/TextValueCell.tsx +116 -0
- package/src/editor/components/variables-panel/VariablesPanel.tsx +518 -0
- package/src/editor/components/variables-panel/index.ts +7 -0
- package/src/editor/constants.ts +468 -0
- package/src/editor/contexts/EditorArtboardContext.tsx +229 -0
- package/src/editor/contexts/EditorComponentsContext.tsx +1320 -0
- package/src/editor/contexts/EditorDocumentContext.tsx +113 -0
- package/src/editor/contexts/EditorHistoryContext.tsx +516 -0
- package/src/editor/contexts/EditorRefsContext.tsx +204 -0
- package/src/editor/contexts/EditorSelectionContext.tsx +54 -0
- package/src/editor/contexts/EditorToolContext.tsx +58 -0
- package/src/editor/contexts/EditorUIStateContext.tsx +122 -0
- package/src/editor/contexts/EditorVariablesContext.tsx +397 -0
- package/src/editor/contexts/EditorViewContext.tsx +101 -0
- package/src/editor/contexts/MultiPageCanvasContext.tsx +498 -0
- package/src/editor/contexts/index.ts +17 -0
- package/src/editor/editor-skin.css +122 -0
- package/src/editor/hooks/index.ts +38 -0
- package/src/editor/hooks/useAiReplace.ts +397 -0
- package/src/editor/hooks/useAltMeasure.ts +67 -0
- package/src/editor/hooks/useBrowserZoomPrevention.ts +121 -0
- package/src/editor/hooks/useCanvasControls.ts +1222 -0
- package/src/editor/hooks/useComponentEditMode.ts +658 -0
- package/src/editor/hooks/useComponentInstances.ts +515 -0
- package/src/editor/hooks/useContextMenuHandler.ts +157 -0
- package/src/editor/hooks/useCoordinateTransform.ts +207 -0
- package/src/editor/hooks/useDragResize.ts +1317 -0
- package/src/editor/hooks/useDrawingMode.ts +472 -0
- package/src/editor/hooks/useEditorColors.ts +144 -0
- package/src/editor/hooks/useEditorMessages.ts +108 -0
- package/src/editor/hooks/useElementActions.ts +1754 -0
- package/src/editor/hooks/useElementSelection.ts +1573 -0
- package/src/editor/hooks/useFocusManagement.ts +249 -0
- package/src/editor/hooks/useGoogleFonts.ts +305 -0
- package/src/editor/hooks/useIframeInitializer.ts +584 -0
- package/src/editor/hooks/useIframeSetup.ts +360 -0
- package/src/editor/hooks/useImageUpload.ts +270 -0
- package/src/editor/hooks/useInfiniteCanvas.ts +301 -0
- package/src/editor/hooks/useKeyboardShortcuts.ts +205 -0
- package/src/editor/hooks/useMarqueeSelection.ts +388 -0
- package/src/editor/hooks/useMediaLibrary.ts +129 -0
- package/src/editor/hooks/usePageSettingsManager.ts +739 -0
- package/src/editor/hooks/useResizablePanel.ts +163 -0
- package/src/editor/hooks/useRichPaste.ts +255 -0
- package/src/editor/hooks/useTouchGestures.ts +197 -0
- package/src/editor/index.ts +27 -0
- package/src/editor/types/page-settings.ts +513 -0
- package/src/editor/types.ts +382 -0
- package/src/editor/utils/align-elements.ts +169 -0
- package/src/editor/utils/api-json.ts +21 -0
- package/src/editor/utils/aspect-lock.ts +50 -0
- package/src/editor/utils/component-renderer.ts +702 -0
- package/src/editor/utils/component-sync.ts +845 -0
- package/src/editor/utils/crop-mode.ts +265 -0
- package/src/editor/utils/dom-utils.ts +2238 -0
- package/src/editor/utils/element-effects.ts +218 -0
- package/src/editor/utils/eyedropper.ts +35 -0
- package/src/editor/utils/figma-export.ts +560 -0
- package/src/editor/utils/figma-kiwi-decoder.ts +722 -0
- package/src/editor/utils/figma-kiwi-encoder.ts +583 -0
- package/src/editor/utils/figma-paste.ts +2262 -0
- package/src/editor/utils/flex-reorder.ts +231 -0
- package/src/editor/utils/flex-utils.ts +1230 -0
- package/src/editor/utils/geometry.ts +232 -0
- package/src/editor/utils/grid-layout.ts +210 -0
- package/src/editor/utils/html-utils.ts +470 -0
- package/src/editor/utils/index.ts +11 -0
- package/src/editor/utils/ink-style.ts +57 -0
- package/src/editor/utils/inline-format.ts +236 -0
- package/src/editor/utils/measure-distance.ts +120 -0
- package/src/editor/utils/override-apply.ts +526 -0
- package/src/editor/utils/override-detection.ts +613 -0
- package/src/editor/utils/paste-processors.ts +609 -0
- package/src/editor/utils/paste-sanitizer.ts +244 -0
- package/src/editor/utils/restore-flow.ts +188 -0
- package/src/editor/utils/shape-library.ts +171 -0
- package/src/editor/utils/slide-root.ts +29 -0
- package/src/editor/utils/smart-guides.ts +218 -0
- package/src/editor/utils/style-utils.ts +685 -0
- package/src/editor/utils/table-edit.ts +151 -0
- package/src/editor/utils/tailwind-mappings.ts +778 -0
- package/src/editor/utils/tailwind-utils.ts +804 -0
- package/src/editor/utils/text-highlight.ts +216 -0
- package/src/editor/utils/theme-to-variables.ts +341 -0
- package/src/editor/utils/variant-resolver.ts +456 -0
- package/src/editor/utils/viewport-utils.ts +295 -0
- package/src/hooks/useEditorHistory.ts +195 -0
- package/src/hooks/useEditorShortcuts.ts +260 -0
- package/src/index.ts +40 -0
- package/src/io.ts +134 -0
- package/src/lib/agent/slide-agent/types.ts +547 -0
- package/src/lib/agent/website-agent/types.ts +805 -0
- package/src/lib/api/auth-fetch.ts +58 -0
- package/src/lib/deck.ts +69 -0
- package/src/lib/export.ts +47 -0
- package/src/lib/firebase/config.ts +29 -0
- package/src/lib/firebase/css-variables.ts +378 -0
- package/src/lib/firebase/editor-components.ts +677 -0
- package/src/lib/firebase/storage.ts +469 -0
- package/src/lib/utils.ts +6 -0
- package/src/styles/editor.css +52 -0
- package/src/styles/skin.css +122 -0
- package/src/types/css-variables.ts +645 -0
- package/src/types/editor-components.ts +944 -0
- package/src/types/editor.ts +420 -0
- package/src/types/page-master.ts +197 -0
- package/src/types/page.ts +419 -0
- package/src/types/slide.ts +402 -0
- package/src/types/website-theme.ts +788 -0
- package/src/types/website.ts +374 -0
- package/src/vendor/firebase-firestore.ts +13 -0
- package/src/vendor/firebase-functions.ts +17 -0
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 座標変換フック
|
|
3
|
+
* - iframe座標 → 親ウィンドウ座標
|
|
4
|
+
* - クライアント座標 → キャンバス座標
|
|
5
|
+
* - ズームを考慮した座標変換
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import { useCallback } from 'react';
|
|
9
|
+
import { useEditorContext } from '../EditorContext';
|
|
10
|
+
|
|
11
|
+
interface Point {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface UseCoordinateTransformReturn {
|
|
17
|
+
/**
|
|
18
|
+
* iframe座標を親ウィンドウ座標に変換
|
|
19
|
+
* iframeがフルスクリーンの場合、オフセットを加えるだけ
|
|
20
|
+
*/
|
|
21
|
+
transformIframeToWindow: (clientX: number, clientY: number) => Point;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 親ウィンドウ座標をiframe座標に変換
|
|
25
|
+
*/
|
|
26
|
+
transformWindowToIframe: (windowX: number, windowY: number) => Point;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* クライアント座標をキャンバス座標に変換(ズーム考慮)
|
|
30
|
+
* @param clientX クライアントX座標
|
|
31
|
+
* @param clientY クライアントY座標
|
|
32
|
+
* @param iframeDoc iframe のドキュメント
|
|
33
|
+
* @returns キャンバス座標
|
|
34
|
+
*/
|
|
35
|
+
transformToCanvasCoords: (
|
|
36
|
+
clientX: number,
|
|
37
|
+
clientY: number,
|
|
38
|
+
iframeDoc: Document
|
|
39
|
+
) => Point;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* キャンバス座標をクライアント座標に変換(ズーム考慮)
|
|
43
|
+
*/
|
|
44
|
+
transformFromCanvasCoords: (
|
|
45
|
+
canvasX: number,
|
|
46
|
+
canvasY: number,
|
|
47
|
+
iframeDoc: Document
|
|
48
|
+
) => Point;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* 座標変換関数を作成(iframeDoc固定版)
|
|
52
|
+
* handleIframeLoad内で使用する
|
|
53
|
+
*/
|
|
54
|
+
createCoordinateTransformer: (iframeDoc: Document) => {
|
|
55
|
+
toWindow: (clientX: number, clientY: number) => Point;
|
|
56
|
+
toCanvas: (clientX: number, clientY: number) => Point;
|
|
57
|
+
fromCanvas: (canvasX: number, canvasY: number) => Point;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* 座標変換フック
|
|
63
|
+
*
|
|
64
|
+
* iframe内の座標と親ウィンドウ座標の相互変換、
|
|
65
|
+
* およびキャンバス座標系の変換を提供する
|
|
66
|
+
*/
|
|
67
|
+
export function useCoordinateTransform(): UseCoordinateTransformReturn {
|
|
68
|
+
const { iframeRef, zoom } = useEditorContext();
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* iframe座標を親ウィンドウ座標に変換
|
|
72
|
+
*/
|
|
73
|
+
const transformIframeToWindow = useCallback(
|
|
74
|
+
(clientX: number, clientY: number): Point => {
|
|
75
|
+
const iframe = iframeRef.current;
|
|
76
|
+
const iframeRect = iframe?.getBoundingClientRect();
|
|
77
|
+
if (!iframeRect) return { x: clientX, y: clientY };
|
|
78
|
+
|
|
79
|
+
// iframeがフルスクリーンなので、オフセットを加えるだけ
|
|
80
|
+
return {
|
|
81
|
+
x: iframeRect.left + clientX,
|
|
82
|
+
y: iframeRect.top + clientY,
|
|
83
|
+
};
|
|
84
|
+
},
|
|
85
|
+
[iframeRef]
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 親ウィンドウ座標をiframe座標に変換
|
|
90
|
+
*/
|
|
91
|
+
const transformWindowToIframe = useCallback(
|
|
92
|
+
(windowX: number, windowY: number): Point => {
|
|
93
|
+
const iframe = iframeRef.current;
|
|
94
|
+
const iframeRect = iframe?.getBoundingClientRect();
|
|
95
|
+
if (!iframeRect) return { x: windowX, y: windowY };
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
x: windowX - iframeRect.left,
|
|
99
|
+
y: windowY - iframeRect.top,
|
|
100
|
+
};
|
|
101
|
+
},
|
|
102
|
+
[iframeRef]
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* クライアント座標をキャンバス座標に変換
|
|
107
|
+
*/
|
|
108
|
+
const transformToCanvasCoords = useCallback(
|
|
109
|
+
(clientX: number, clientY: number, iframeDoc: Document): Point => {
|
|
110
|
+
const artboard = iframeDoc.getElementById('artboard');
|
|
111
|
+
if (!artboard) return { x: clientX, y: clientY };
|
|
112
|
+
|
|
113
|
+
const artboardRect = artboard.getBoundingClientRect();
|
|
114
|
+
const scale = zoom / 100;
|
|
115
|
+
|
|
116
|
+
return {
|
|
117
|
+
x: (clientX - artboardRect.left) / scale,
|
|
118
|
+
y: (clientY - artboardRect.top) / scale,
|
|
119
|
+
};
|
|
120
|
+
},
|
|
121
|
+
[zoom]
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* キャンバス座標をクライアント座標に変換
|
|
126
|
+
*/
|
|
127
|
+
const transformFromCanvasCoords = useCallback(
|
|
128
|
+
(canvasX: number, canvasY: number, iframeDoc: Document): Point => {
|
|
129
|
+
const artboard = iframeDoc.getElementById('artboard');
|
|
130
|
+
if (!artboard) return { x: canvasX, y: canvasY };
|
|
131
|
+
|
|
132
|
+
const artboardRect = artboard.getBoundingClientRect();
|
|
133
|
+
const scale = zoom / 100;
|
|
134
|
+
|
|
135
|
+
return {
|
|
136
|
+
x: canvasX * scale + artboardRect.left,
|
|
137
|
+
y: canvasY * scale + artboardRect.top,
|
|
138
|
+
};
|
|
139
|
+
},
|
|
140
|
+
[zoom]
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* 座標変換関数のファクトリー(iframeDoc固定版)
|
|
145
|
+
*/
|
|
146
|
+
const createCoordinateTransformer = useCallback(
|
|
147
|
+
(iframeDoc: Document) => {
|
|
148
|
+
const iframe = iframeRef.current;
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
/**
|
|
152
|
+
* iframe内のクライアント座標を親ウィンドウ座標に変換
|
|
153
|
+
*/
|
|
154
|
+
toWindow: (clientX: number, clientY: number): Point => {
|
|
155
|
+
const iframeRect = iframe?.getBoundingClientRect();
|
|
156
|
+
if (!iframeRect) return { x: clientX, y: clientY };
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
x: iframeRect.left + clientX,
|
|
160
|
+
y: iframeRect.top + clientY,
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* クライアント座標をキャンバス座標に変換
|
|
166
|
+
*/
|
|
167
|
+
toCanvas: (clientX: number, clientY: number): Point => {
|
|
168
|
+
const artboard = iframeDoc.getElementById('artboard');
|
|
169
|
+
if (!artboard) return { x: clientX, y: clientY };
|
|
170
|
+
|
|
171
|
+
const artboardRect = artboard.getBoundingClientRect();
|
|
172
|
+
const scale = zoom / 100;
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
x: (clientX - artboardRect.left) / scale,
|
|
176
|
+
y: (clientY - artboardRect.top) / scale,
|
|
177
|
+
};
|
|
178
|
+
},
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* キャンバス座標をクライアント座標に変換
|
|
182
|
+
*/
|
|
183
|
+
fromCanvas: (canvasX: number, canvasY: number): Point => {
|
|
184
|
+
const artboard = iframeDoc.getElementById('artboard');
|
|
185
|
+
if (!artboard) return { x: canvasX, y: canvasY };
|
|
186
|
+
|
|
187
|
+
const artboardRect = artboard.getBoundingClientRect();
|
|
188
|
+
const scale = zoom / 100;
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
x: canvasX * scale + artboardRect.left,
|
|
192
|
+
y: canvasY * scale + artboardRect.top,
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
[iframeRef, zoom]
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
return {
|
|
201
|
+
transformIframeToWindow,
|
|
202
|
+
transformWindowToIframe,
|
|
203
|
+
transformToCanvasCoords,
|
|
204
|
+
transformFromCanvasCoords,
|
|
205
|
+
createCoordinateTransformer,
|
|
206
|
+
};
|
|
207
|
+
}
|