@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.
Files changed (219) hide show
  1. package/LICENSE +21 -0
  2. package/NOTICE +52 -0
  3. package/README.md +143 -0
  4. package/dist/editor.css +2 -0
  5. package/package.json +94 -0
  6. package/src/components/DeckSlideRender.tsx +21 -0
  7. package/src/components/SaveNote.tsx +21 -0
  8. package/src/components/auth/AuthProvider.tsx +44 -0
  9. package/src/components/ui/accordion.tsx +57 -0
  10. package/src/components/ui/alert-dialog.tsx +141 -0
  11. package/src/components/ui/badge.tsx +36 -0
  12. package/src/components/ui/button.tsx +56 -0
  13. package/src/components/ui/card.tsx +76 -0
  14. package/src/components/ui/checkbox.tsx +30 -0
  15. package/src/components/ui/collapsible.tsx +11 -0
  16. package/src/components/ui/context-menu.tsx +200 -0
  17. package/src/components/ui/dialog.tsx +122 -0
  18. package/src/components/ui/dropdown-menu.tsx +201 -0
  19. package/src/components/ui/input.tsx +22 -0
  20. package/src/components/ui/label.tsx +26 -0
  21. package/src/components/ui/popover.tsx +33 -0
  22. package/src/components/ui/scroll-area.tsx +48 -0
  23. package/src/components/ui/scrubbable-label.tsx +95 -0
  24. package/src/components/ui/select.tsx +159 -0
  25. package/src/components/ui/separator.tsx +31 -0
  26. package/src/components/ui/slider.tsx +28 -0
  27. package/src/components/ui/switch.tsx +29 -0
  28. package/src/components/ui/tabs.tsx +55 -0
  29. package/src/components/ui/textarea.tsx +22 -0
  30. package/src/components/ui/tooltip.tsx +32 -0
  31. package/src/components/viewer/useDeck.ts +58 -0
  32. package/src/editor/EditorContext.tsx +632 -0
  33. package/src/editor/EditorToolbar.tsx +446 -0
  34. package/src/editor/FrontendVisualEditor.tsx +2595 -0
  35. package/src/editor/autosave.ts +34 -0
  36. package/src/editor/components/AiPromptPopover.tsx +378 -0
  37. package/src/editor/components/BreakpointGuides.tsx +323 -0
  38. package/src/editor/components/BreakpointSelector.tsx +180 -0
  39. package/src/editor/components/ComponentPropertyEditor.tsx +426 -0
  40. package/src/editor/components/CssEditorDialog.tsx +168 -0
  41. package/src/editor/components/EditorCanvas.tsx +987 -0
  42. package/src/editor/components/EditorContextMenu.tsx +515 -0
  43. package/src/editor/components/EditorFooter.tsx +81 -0
  44. package/src/editor/components/EditorHeader.tsx +524 -0
  45. package/src/editor/components/EditorLayerPanel.tsx +1197 -0
  46. package/src/editor/components/EditorPropertyPanel.tsx +2996 -0
  47. package/src/editor/components/EditorSidebar.tsx +226 -0
  48. package/src/editor/components/FigmaColorPicker.tsx +1577 -0
  49. package/src/editor/components/HtmlEditorDialog.tsx +71 -0
  50. package/src/editor/components/HtmlImportDialog.tsx +346 -0
  51. package/src/editor/components/JsEditorDialog.tsx +175 -0
  52. package/src/editor/components/LayerTreeItem.tsx +494 -0
  53. package/src/editor/components/MasterComponentEditor.tsx +846 -0
  54. package/src/editor/components/MediaLibraryDialog.tsx +447 -0
  55. package/src/editor/components/PageSettingsDialog.tsx +776 -0
  56. package/src/editor/components/VariablePicker.tsx +355 -0
  57. package/src/editor/components/VariablesDialog.tsx +564 -0
  58. package/src/editor/components/VariantEditor.tsx +687 -0
  59. package/src/editor/components/VariantMatrix.tsx +507 -0
  60. package/src/editor/components/component-panel/CategoryAccordion.tsx +139 -0
  61. package/src/editor/components/component-panel/ComponentGrid.tsx +51 -0
  62. package/src/editor/components/component-panel/ComponentItem.tsx +368 -0
  63. package/src/editor/components/component-panel/ComponentPanel.tsx +275 -0
  64. package/src/editor/components/component-panel/ComponentSearch.tsx +82 -0
  65. package/src/editor/components/component-panel/VariantList.tsx +260 -0
  66. package/src/editor/components/component-panel/index.ts +12 -0
  67. package/src/editor/components/index.ts +48 -0
  68. package/src/editor/components/multi-page/CanvasZoomControls.tsx +71 -0
  69. package/src/editor/components/multi-page/InfiniteCanvas.tsx +95 -0
  70. package/src/editor/components/multi-page/MultiPageCanvasView.tsx +1404 -0
  71. package/src/editor/components/multi-page/PageFrameOverlay.tsx +76 -0
  72. package/src/editor/components/multi-page/PageLabel.tsx +34 -0
  73. package/src/editor/components/multi-page/PageLivePreview.tsx +242 -0
  74. package/src/editor/components/multi-page/PageThumbnail.tsx +59 -0
  75. package/src/editor/components/multi-page/index.ts +7 -0
  76. package/src/editor/components/ppt/PptChrome.tsx +2508 -0
  77. package/src/editor/components/ppt/PptComments.tsx +589 -0
  78. package/src/editor/components/ppt/PptDesignProposals.tsx +275 -0
  79. package/src/editor/components/ppt/PptFormatPane.tsx +320 -0
  80. package/src/editor/components/ppt/PptNotes.tsx +246 -0
  81. package/src/editor/components/property-panel/AlignmentPanel.tsx +110 -0
  82. package/src/editor/components/property-panel/AutoLayoutPanel.tsx +615 -0
  83. package/src/editor/components/property-panel/BorderSection.tsx +104 -0
  84. package/src/editor/components/property-panel/CompactNumberInput.tsx +237 -0
  85. package/src/editor/components/property-panel/CompactSizeInput.tsx +148 -0
  86. package/src/editor/components/property-panel/EffectSection.tsx +157 -0
  87. package/src/editor/components/property-panel/FillSection.tsx +69 -0
  88. package/src/editor/components/property-panel/GoogleFontPicker.tsx +192 -0
  89. package/src/editor/components/property-panel/ImageSection.tsx +206 -0
  90. package/src/editor/components/property-panel/ImgSrcSection.tsx +125 -0
  91. package/src/editor/components/property-panel/InstanceOverrideSection.tsx +413 -0
  92. package/src/editor/components/property-panel/LayoutSection.tsx +105 -0
  93. package/src/editor/components/property-panel/LinkSection.tsx +103 -0
  94. package/src/editor/components/property-panel/PropertyVariablePicker.tsx +311 -0
  95. package/src/editor/components/property-panel/ScalePanel.tsx +212 -0
  96. package/src/editor/components/property-panel/TypographySection.tsx +230 -0
  97. package/src/editor/components/property-panel/UnitAwareNumberInput.tsx +238 -0
  98. package/src/editor/components/property-panel/VariableAwareColorInput.tsx +477 -0
  99. package/src/editor/components/property-panel/VariableAwareInput.tsx +606 -0
  100. package/src/editor/components/property-panel/VariableAwareSizeInput.tsx +588 -0
  101. package/src/editor/components/property-panel/VariableAwareUnitInput.tsx +546 -0
  102. package/src/editor/components/property-panel/index.ts +24 -0
  103. package/src/editor/components/property-panel/unit-utils.ts +261 -0
  104. package/src/editor/components/shell/EditorTopBar.tsx +392 -0
  105. package/src/editor/components/shell/LeftPanel.tsx +47 -0
  106. package/src/editor/components/shell/PagesPanel.tsx +118 -0
  107. package/src/editor/components/variables-panel/ColorValueCell.tsx +165 -0
  108. package/src/editor/components/variables-panel/TextValueCell.tsx +116 -0
  109. package/src/editor/components/variables-panel/VariablesPanel.tsx +518 -0
  110. package/src/editor/components/variables-panel/index.ts +7 -0
  111. package/src/editor/constants.ts +468 -0
  112. package/src/editor/contexts/EditorArtboardContext.tsx +229 -0
  113. package/src/editor/contexts/EditorComponentsContext.tsx +1320 -0
  114. package/src/editor/contexts/EditorDocumentContext.tsx +113 -0
  115. package/src/editor/contexts/EditorHistoryContext.tsx +516 -0
  116. package/src/editor/contexts/EditorRefsContext.tsx +204 -0
  117. package/src/editor/contexts/EditorSelectionContext.tsx +54 -0
  118. package/src/editor/contexts/EditorToolContext.tsx +58 -0
  119. package/src/editor/contexts/EditorUIStateContext.tsx +122 -0
  120. package/src/editor/contexts/EditorVariablesContext.tsx +397 -0
  121. package/src/editor/contexts/EditorViewContext.tsx +101 -0
  122. package/src/editor/contexts/MultiPageCanvasContext.tsx +498 -0
  123. package/src/editor/contexts/index.ts +17 -0
  124. package/src/editor/editor-skin.css +122 -0
  125. package/src/editor/hooks/index.ts +38 -0
  126. package/src/editor/hooks/useAiReplace.ts +397 -0
  127. package/src/editor/hooks/useAltMeasure.ts +67 -0
  128. package/src/editor/hooks/useBrowserZoomPrevention.ts +121 -0
  129. package/src/editor/hooks/useCanvasControls.ts +1222 -0
  130. package/src/editor/hooks/useComponentEditMode.ts +658 -0
  131. package/src/editor/hooks/useComponentInstances.ts +515 -0
  132. package/src/editor/hooks/useContextMenuHandler.ts +157 -0
  133. package/src/editor/hooks/useCoordinateTransform.ts +207 -0
  134. package/src/editor/hooks/useDragResize.ts +1317 -0
  135. package/src/editor/hooks/useDrawingMode.ts +472 -0
  136. package/src/editor/hooks/useEditorColors.ts +144 -0
  137. package/src/editor/hooks/useEditorMessages.ts +108 -0
  138. package/src/editor/hooks/useElementActions.ts +1754 -0
  139. package/src/editor/hooks/useElementSelection.ts +1573 -0
  140. package/src/editor/hooks/useFocusManagement.ts +249 -0
  141. package/src/editor/hooks/useGoogleFonts.ts +305 -0
  142. package/src/editor/hooks/useIframeInitializer.ts +584 -0
  143. package/src/editor/hooks/useIframeSetup.ts +360 -0
  144. package/src/editor/hooks/useImageUpload.ts +270 -0
  145. package/src/editor/hooks/useInfiniteCanvas.ts +301 -0
  146. package/src/editor/hooks/useKeyboardShortcuts.ts +205 -0
  147. package/src/editor/hooks/useMarqueeSelection.ts +388 -0
  148. package/src/editor/hooks/useMediaLibrary.ts +129 -0
  149. package/src/editor/hooks/usePageSettingsManager.ts +739 -0
  150. package/src/editor/hooks/useResizablePanel.ts +163 -0
  151. package/src/editor/hooks/useRichPaste.ts +255 -0
  152. package/src/editor/hooks/useTouchGestures.ts +197 -0
  153. package/src/editor/index.ts +27 -0
  154. package/src/editor/types/page-settings.ts +513 -0
  155. package/src/editor/types.ts +382 -0
  156. package/src/editor/utils/align-elements.ts +169 -0
  157. package/src/editor/utils/api-json.ts +21 -0
  158. package/src/editor/utils/aspect-lock.ts +50 -0
  159. package/src/editor/utils/component-renderer.ts +702 -0
  160. package/src/editor/utils/component-sync.ts +845 -0
  161. package/src/editor/utils/crop-mode.ts +265 -0
  162. package/src/editor/utils/dom-utils.ts +2238 -0
  163. package/src/editor/utils/element-effects.ts +218 -0
  164. package/src/editor/utils/eyedropper.ts +35 -0
  165. package/src/editor/utils/figma-export.ts +560 -0
  166. package/src/editor/utils/figma-kiwi-decoder.ts +722 -0
  167. package/src/editor/utils/figma-kiwi-encoder.ts +583 -0
  168. package/src/editor/utils/figma-paste.ts +2262 -0
  169. package/src/editor/utils/flex-reorder.ts +231 -0
  170. package/src/editor/utils/flex-utils.ts +1230 -0
  171. package/src/editor/utils/geometry.ts +232 -0
  172. package/src/editor/utils/grid-layout.ts +210 -0
  173. package/src/editor/utils/html-utils.ts +470 -0
  174. package/src/editor/utils/index.ts +11 -0
  175. package/src/editor/utils/ink-style.ts +57 -0
  176. package/src/editor/utils/inline-format.ts +236 -0
  177. package/src/editor/utils/measure-distance.ts +120 -0
  178. package/src/editor/utils/override-apply.ts +526 -0
  179. package/src/editor/utils/override-detection.ts +613 -0
  180. package/src/editor/utils/paste-processors.ts +609 -0
  181. package/src/editor/utils/paste-sanitizer.ts +244 -0
  182. package/src/editor/utils/restore-flow.ts +188 -0
  183. package/src/editor/utils/shape-library.ts +171 -0
  184. package/src/editor/utils/slide-root.ts +29 -0
  185. package/src/editor/utils/smart-guides.ts +218 -0
  186. package/src/editor/utils/style-utils.ts +685 -0
  187. package/src/editor/utils/table-edit.ts +151 -0
  188. package/src/editor/utils/tailwind-mappings.ts +778 -0
  189. package/src/editor/utils/tailwind-utils.ts +804 -0
  190. package/src/editor/utils/text-highlight.ts +216 -0
  191. package/src/editor/utils/theme-to-variables.ts +341 -0
  192. package/src/editor/utils/variant-resolver.ts +456 -0
  193. package/src/editor/utils/viewport-utils.ts +295 -0
  194. package/src/hooks/useEditorHistory.ts +195 -0
  195. package/src/hooks/useEditorShortcuts.ts +260 -0
  196. package/src/index.ts +40 -0
  197. package/src/io.ts +134 -0
  198. package/src/lib/agent/slide-agent/types.ts +547 -0
  199. package/src/lib/agent/website-agent/types.ts +805 -0
  200. package/src/lib/api/auth-fetch.ts +58 -0
  201. package/src/lib/deck.ts +69 -0
  202. package/src/lib/export.ts +47 -0
  203. package/src/lib/firebase/config.ts +29 -0
  204. package/src/lib/firebase/css-variables.ts +378 -0
  205. package/src/lib/firebase/editor-components.ts +677 -0
  206. package/src/lib/firebase/storage.ts +469 -0
  207. package/src/lib/utils.ts +6 -0
  208. package/src/styles/editor.css +52 -0
  209. package/src/styles/skin.css +122 -0
  210. package/src/types/css-variables.ts +645 -0
  211. package/src/types/editor-components.ts +944 -0
  212. package/src/types/editor.ts +420 -0
  213. package/src/types/page-master.ts +197 -0
  214. package/src/types/page.ts +419 -0
  215. package/src/types/slide.ts +402 -0
  216. package/src/types/website-theme.ts +788 -0
  217. package/src/types/website.ts +374 -0
  218. package/src/vendor/firebase-firestore.ts +13 -0
  219. package/src/vendor/firebase-functions.ts +17 -0
@@ -0,0 +1,76 @@
1
+ 'use client';
2
+
3
+ import { memo, useCallback } from 'react';
4
+ import { cn } from '../../../lib/utils';
5
+ import type { PageFrame } from '../../contexts/MultiPageCanvasContext';
6
+ import { PageLabel } from './PageLabel';
7
+ import { PageThumbnail } from './PageThumbnail';
8
+
9
+ interface PageFrameOverlayProps {
10
+ page: PageFrame;
11
+ isActive?: boolean;
12
+ onDoubleClick?: (pageId: string) => void;
13
+ onClick?: (pageId: string) => void;
14
+ }
15
+
16
+ /**
17
+ * ページフレームオーバーレイ: 無限キャンバス上の各ページ表示
18
+ * - ページ名ラベル(Figma風、上部)
19
+ * - サムネイルプレビュー
20
+ * - ホバー時のリング表示
21
+ * - ダブルクリックでページフォーカス(Phase 2で完全実装)
22
+ */
23
+ export const PageFrameOverlay = memo(function PageFrameOverlay({
24
+ page,
25
+ isActive = false,
26
+ onDoubleClick,
27
+ onClick,
28
+ }: PageFrameOverlayProps) {
29
+ const handleDoubleClick = useCallback((e: React.MouseEvent) => {
30
+ e.stopPropagation();
31
+ onDoubleClick?.(page.id);
32
+ }, [onDoubleClick, page.id]);
33
+
34
+ const handleClick = useCallback((e: React.MouseEvent) => {
35
+ e.stopPropagation();
36
+ onClick?.(page.id);
37
+ }, [onClick, page.id]);
38
+
39
+ return (
40
+ <div
41
+ className="absolute cursor-pointer group"
42
+ style={{
43
+ left: page.position.x,
44
+ top: page.position.y,
45
+ width: page.size.width,
46
+ height: page.size.height,
47
+ }}
48
+ onDoubleClick={handleDoubleClick}
49
+ onClick={handleClick}
50
+ >
51
+ {/* ページ名ラベル */}
52
+ <PageLabel
53
+ title={page.title}
54
+ isDirty={page.isDirty}
55
+ isActive={isActive}
56
+ />
57
+
58
+ {/* サムネイルコンテナ */}
59
+ <div
60
+ className={cn(
61
+ 'w-full h-full bg-white rounded-sm shadow-lg overflow-hidden',
62
+ 'ring-2 transition-all duration-150',
63
+ isActive
64
+ ? 'ring-[#0d99ff] shadow-blue-500/20'
65
+ : 'ring-transparent group-hover:ring-[#0d99ff]/50'
66
+ )}
67
+ >
68
+ <PageThumbnail
69
+ html={page.thumbnailHtml}
70
+ dataUrl={page.thumbnailDataUrl}
71
+ size={page.size}
72
+ />
73
+ </div>
74
+ </div>
75
+ );
76
+ });
@@ -0,0 +1,34 @@
1
+ 'use client';
2
+
3
+ import { memo } from 'react';
4
+ import { cn } from '../../../lib/utils';
5
+
6
+ interface PageLabelProps {
7
+ title: string;
8
+ isDirty?: boolean;
9
+ isActive?: boolean;
10
+ }
11
+
12
+ /**
13
+ * ページ名ラベル(Figma風: フレーム上部に表示)
14
+ */
15
+ export const PageLabel = memo(function PageLabel({
16
+ title,
17
+ isDirty = false,
18
+ isActive = false,
19
+ }: PageLabelProps) {
20
+ return (
21
+ <div
22
+ className={cn(
23
+ 'absolute -top-7 left-0 px-1.5 py-0.5 text-[11px] font-medium truncate max-w-[200px]',
24
+ 'select-none pointer-events-none',
25
+ 'text-gray-400'
26
+ )}
27
+ >
28
+ {title}
29
+ {isDirty && (
30
+ <span className="ml-1 text-orange-400">*</span>
31
+ )}
32
+ </div>
33
+ );
34
+ });
@@ -0,0 +1,242 @@
1
+ 'use client';
2
+
3
+ import { memo, useRef, useEffect } from 'react';
4
+
5
+ interface PageLivePreviewProps {
6
+ html: string;
7
+ pageId: string;
8
+ /** iframe読み込み完了時にiframe要素を親に通知 */
9
+ onIframeLoad?: (pageId: string, iframe: HTMLIFrameElement) => void;
10
+ }
11
+
12
+ /**
13
+ * Multi-page canvas用のシンプルHTML生成
14
+ * body > #artboard > content のフラット構造
15
+ */
16
+ function generateCanvasPageHtml(content: string): string {
17
+ const baseUrl = typeof window !== 'undefined' ? window.location.origin : '';
18
+ const scriptUrl = baseUrl
19
+ ? `${baseUrl}/vendor/tailwindcss-browser.js`
20
+ : 'https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4';
21
+
22
+ return `<!DOCTYPE html>
23
+ <html lang="ja">
24
+ <head>
25
+ <meta charset="UTF-8">
26
+ <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
27
+ <script src="${scriptUrl}"></script>
28
+ <style type="text/tailwindcss">
29
+ @layer base {}
30
+ @theme { --font-sans: 'Noto Sans JP', system-ui, sans-serif; }
31
+ </style>
32
+ <link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@100..900&display=swap" rel="stylesheet">
33
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
34
+ <link href="https://fonts.googleapis.com/icon?family=Material+Icons+Outlined" rel="stylesheet">
35
+ <style>
36
+ * { box-sizing: border-box; }
37
+ html { margin: 0; padding: 0; touch-action: none; }
38
+ body { margin: 0; padding: 0; width: 100%; background: white; font-family: 'Noto Sans JP', system-ui, sans-serif; overflow: hidden; touch-action: none; }
39
+ #artboard { position: relative; }
40
+ </style>
41
+ </head>
42
+ <body>
43
+ <div id="artboard">${content}</div>
44
+ </body>
45
+ </html>`;
46
+ }
47
+
48
+ /**
49
+ * 全ページ同時編集可能なライブiframeプレビュー
50
+ * - シンプルHTML構造(ラッパーなし)
51
+ * - コンテンツ高さ自動測定 → 親にpostMessage
52
+ * - 編集ロジックは親(MultiPageCanvasView)が管理
53
+ */
54
+ export const PageLivePreview = memo(function PageLivePreview({
55
+ html,
56
+ pageId,
57
+ onIframeLoad,
58
+ }: PageLivePreviewProps) {
59
+ const iframeRef = useRef<HTMLIFrameElement>(null);
60
+ const isLoadedRef = useRef(false);
61
+
62
+ // HTML初回読み込み(一度だけ)
63
+ // 初回ロード後はDOM操作で直接編集されるため、html prop変更でのiframe再読込は不要
64
+ useEffect(() => {
65
+ const iframe = iframeRef.current;
66
+ if (!iframe) return;
67
+ if (!html?.trim()) return;
68
+ if (isLoadedRef.current) return;
69
+
70
+ isLoadedRef.current = true;
71
+ const fullHtml = generateCanvasPageHtml(html);
72
+ const blob = new Blob([fullHtml], { type: 'text/html' });
73
+ const url = URL.createObjectURL(blob);
74
+ iframe.src = url;
75
+
76
+ return () => URL.revokeObjectURL(url);
77
+ }, [html]);
78
+
79
+ // 最小限のスクリプト注入(ID付与・高さ測定・イベント転送のみ)
80
+ useEffect(() => {
81
+ const iframe = iframeRef.current;
82
+ if (!iframe) return;
83
+
84
+ const injectMinimalScripts = (doc: Document) => {
85
+ if (doc.querySelector('[data-canvas-init]')) return;
86
+
87
+ const script = doc.createElement('script');
88
+ script.setAttribute('data-canvas-init', 'true');
89
+ script.textContent = `(function(){
90
+ var PAGE_ID = ${JSON.stringify(pageId)};
91
+ var artboard = document.getElementById('artboard');
92
+ if (!artboard) return;
93
+
94
+ // === Assign data-element-id + data-editable to ALL elements ===
95
+ var idCounter = 0;
96
+ function assignElementIds(parent, isArtboardChild) {
97
+ for (var i = 0; i < parent.children.length; i++) {
98
+ var child = parent.children[i];
99
+ if (child.nodeType !== 1) continue;
100
+ if (child.tagName === 'SCRIPT' || child.tagName === 'STYLE') continue;
101
+ if (!child.getAttribute('data-element-id')) {
102
+ child.setAttribute('data-element-id', 'el-' + (idCounter++));
103
+ }
104
+ // artboard直下の子要素にdata-editableを付与(レイアウトモード変換で必要)
105
+ if (isArtboardChild && !child.hasAttribute('data-editable')) {
106
+ child.setAttribute('data-editable', 'true');
107
+ }
108
+ assignElementIds(child, false);
109
+ }
110
+ }
111
+ assignElementIds(artboard, true);
112
+
113
+ // === Height measurement (one-shot) ===
114
+ var heightReported = false;
115
+ function reportHeight() {
116
+ if (heightReported) return;
117
+ var h = artboard.scrollHeight || document.body.scrollHeight;
118
+ if (h > 0) {
119
+ h = Math.min(h, 8000);
120
+ heightReported = true;
121
+ window.parent.postMessage({ type: 'PAGE_CONTENT_HEIGHT', pageId: PAGE_ID, height: h }, '*');
122
+ }
123
+ }
124
+ setTimeout(reportHeight, 500);
125
+ setTimeout(reportHeight, 1500);
126
+
127
+ // === Disable trackpad/keyboard zoom natively ===
128
+ var preventZoom = function(e) {
129
+ if (e.ctrlKey || e.metaKey) {
130
+ e.preventDefault();
131
+ }
132
+ };
133
+ window.addEventListener('wheel', preventZoom, { passive: false, capture: true });
134
+ document.addEventListener('wheel', preventZoom, { passive: false, capture: true });
135
+
136
+ var preventShortcuts = function(e) {
137
+ if ((e.ctrlKey || e.metaKey) && (e.key === '+' || e.key === '=' || e.key === '-' || e.key === '0')) {
138
+ e.preventDefault();
139
+ }
140
+ };
141
+ window.addEventListener('keydown', preventShortcuts, { passive: false, capture: true });
142
+ document.addEventListener('keydown', preventShortcuts, { passive: false, capture: true });
143
+
144
+ // === Prevent Safari gesture event native behavior ===
145
+ var preventGesture = function(e) {
146
+ e.preventDefault();
147
+ };
148
+ window.addEventListener('gesturestart', preventGesture, { passive: false, capture: true });
149
+ window.addEventListener('gesturechange', preventGesture, { passive: false, capture: true });
150
+ window.addEventListener('gestureend', preventGesture, { passive: false, capture: true });
151
+ document.addEventListener('gesturestart', preventGesture, { passive: false, capture: true });
152
+ document.addEventListener('gesturechange', preventGesture, { passive: false, capture: true });
153
+ document.addEventListener('gestureend', preventGesture, { passive: false, capture: true });
154
+
155
+ // === Wheel forwarding ===
156
+ window.addEventListener('wheel', function(e) {
157
+ window.parent.postMessage({
158
+ type: 'PAGE_PREVIEW_WHEEL',
159
+ deltaX: e.deltaX, deltaY: e.deltaY,
160
+ ctrlKey: e.ctrlKey, metaKey: e.metaKey
161
+ }, '*');
162
+ }, { passive: false });
163
+
164
+ // === Touch forwarding for pinch zoom ===
165
+ var lastTouches = null;
166
+ document.addEventListener('touchstart', function(e) {
167
+ if (e.touches.length >= 2) {
168
+ e.preventDefault();
169
+ lastTouches = [];
170
+ for (var i = 0; i < e.touches.length; i++) {
171
+ lastTouches.push({ clientX: e.touches[i].clientX, clientY: e.touches[i].clientY });
172
+ }
173
+ }
174
+ }, { passive: false });
175
+
176
+ document.addEventListener('touchmove', function(e) {
177
+ if (e.touches.length >= 2) {
178
+ e.preventDefault();
179
+ var touches = [];
180
+ for (var i = 0; i < e.touches.length; i++) {
181
+ touches.push({ clientX: e.touches[i].clientX, clientY: e.touches[i].clientY });
182
+ }
183
+ window.parent.postMessage({
184
+ type: 'PAGE_PREVIEW_TOUCH',
185
+ touchType: 'move',
186
+ touches: touches,
187
+ prevTouches: lastTouches
188
+ }, '*');
189
+ lastTouches = touches;
190
+ }
191
+ }, { passive: false });
192
+
193
+ document.addEventListener('touchend', function() {
194
+ lastTouches = null;
195
+ });
196
+ document.addEventListener('touchcancel', function() {
197
+ lastTouches = null;
198
+ });
199
+
200
+ // === Prevent link navigation ===
201
+ document.addEventListener('click', function(e) {
202
+ var a = e.target.closest('a');
203
+ if (a) e.preventDefault();
204
+ }, true);
205
+ })();`;
206
+ doc.body.appendChild(script);
207
+ };
208
+
209
+ try {
210
+ const doc = iframe.contentDocument;
211
+ if (doc && doc.readyState === 'complete' && doc.body) injectMinimalScripts(doc);
212
+ } catch { /* cross-origin */ }
213
+
214
+ const handleLoad = () => {
215
+ try {
216
+ const doc = iframe.contentDocument;
217
+ if (doc) injectMinimalScripts(doc);
218
+ } catch { /* cross-origin */ }
219
+ if (onIframeLoad && iframe) onIframeLoad(pageId, iframe);
220
+ };
221
+ iframe.addEventListener('load', handleLoad);
222
+ return () => iframe.removeEventListener('load', handleLoad);
223
+ }, [pageId, onIframeLoad]);
224
+
225
+ if (!html?.trim()) {
226
+ return (
227
+ <div className="w-full h-full flex items-center justify-center bg-gray-100">
228
+ <span className="text-gray-400 text-sm">Empty Page</span>
229
+ </div>
230
+ );
231
+ }
232
+
233
+ return (
234
+ <iframe
235
+ ref={iframeRef}
236
+ className="w-full h-full border-0"
237
+ style={{ touchAction: 'none', overscrollBehavior: 'none' }}
238
+ sandbox="allow-same-origin allow-scripts"
239
+ title={`Page ${pageId}`}
240
+ />
241
+ );
242
+ });
@@ -0,0 +1,59 @@
1
+ 'use client';
2
+
3
+ import { memo } from 'react';
4
+ import { WEBPAGE_WIDTH, WEBPAGE_MIN_HEIGHT } from '../../contexts/MultiPageCanvasContext';
5
+
6
+ interface PageThumbnailProps {
7
+ html: string;
8
+ dataUrl: string | null;
9
+ size: { width: number; height: number };
10
+ }
11
+
12
+ /**
13
+ * ページサムネイル: CSS scaleで縮小描画
14
+ * dataUrl(高品質キャプチャ)がある場合はそれを表示、
15
+ * なければHTMLをdangerouslySetInnerHTMLで描画
16
+ */
17
+ export const PageThumbnail = memo(function PageThumbnail({
18
+ html,
19
+ dataUrl,
20
+ size,
21
+ }: PageThumbnailProps) {
22
+ // 高品質サムネイルがあればそれを表示
23
+ if (dataUrl) {
24
+ return (
25
+ <img
26
+ src={dataUrl}
27
+ alt=""
28
+ className="w-full h-full object-cover object-top"
29
+ draggable={false}
30
+ />
31
+ );
32
+ }
33
+
34
+ // HTMLが空の場合はプレースホルダー
35
+ if (!html?.trim()) {
36
+ return (
37
+ <div className="w-full h-full flex items-center justify-center bg-gray-100">
38
+ <span className="text-gray-400 text-sm">Empty Page</span>
39
+ </div>
40
+ );
41
+ }
42
+
43
+ // HTMLをCSS scaleで縮小描画
44
+ const scale = size.width / WEBPAGE_WIDTH;
45
+
46
+ return (
47
+ <div className="w-full h-full overflow-hidden">
48
+ <div
49
+ className="origin-top-left pointer-events-none"
50
+ style={{
51
+ width: WEBPAGE_WIDTH,
52
+ height: WEBPAGE_MIN_HEIGHT,
53
+ transform: `scale(${scale})`,
54
+ }}
55
+ dangerouslySetInnerHTML={{ __html: html }}
56
+ />
57
+ </div>
58
+ );
59
+ });
@@ -0,0 +1,7 @@
1
+ export { InfiniteCanvas } from './InfiniteCanvas';
2
+ export { MultiPageCanvasView } from './MultiPageCanvasView';
3
+ export { PageFrameOverlay } from './PageFrameOverlay';
4
+ export { PageThumbnail } from './PageThumbnail';
5
+ export { PageLivePreview } from './PageLivePreview';
6
+ export { PageLabel } from './PageLabel';
7
+ export { CanvasZoomControls } from './CanvasZoomControls';