@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,513 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ページ設定の型定義
|
|
3
|
+
* プロジェクトレベルのデフォルト設定とページ単位の上書き設定をサポート
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* OGP (Open Graph Protocol) 設定
|
|
8
|
+
*/
|
|
9
|
+
export interface OgpSettings {
|
|
10
|
+
/** og:title */
|
|
11
|
+
title?: string;
|
|
12
|
+
/** og:description */
|
|
13
|
+
description?: string;
|
|
14
|
+
/** og:image URL */
|
|
15
|
+
image?: string;
|
|
16
|
+
/** og:type (website, article, product など) */
|
|
17
|
+
type?: 'website' | 'article' | 'product' | 'profile' | string;
|
|
18
|
+
/** og:url */
|
|
19
|
+
url?: string;
|
|
20
|
+
/** og:site_name */
|
|
21
|
+
siteName?: string;
|
|
22
|
+
/** og:locale */
|
|
23
|
+
locale?: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Twitter Card 設定
|
|
28
|
+
*/
|
|
29
|
+
export interface TwitterCardSettings {
|
|
30
|
+
/** twitter:card (summary, summary_large_image, app, player) */
|
|
31
|
+
card?: 'summary' | 'summary_large_image' | 'app' | 'player';
|
|
32
|
+
/** twitter:site (@username) */
|
|
33
|
+
site?: string;
|
|
34
|
+
/** twitter:creator (@username) */
|
|
35
|
+
creator?: string;
|
|
36
|
+
/** twitter:title */
|
|
37
|
+
title?: string;
|
|
38
|
+
/** twitter:description */
|
|
39
|
+
description?: string;
|
|
40
|
+
/** twitter:image URL */
|
|
41
|
+
image?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 外部リソース
|
|
46
|
+
*/
|
|
47
|
+
export interface ExternalResource {
|
|
48
|
+
/** リソースID */
|
|
49
|
+
id: string;
|
|
50
|
+
/** リソースURL */
|
|
51
|
+
url: string;
|
|
52
|
+
/** リソースタイプ */
|
|
53
|
+
type: 'css' | 'js';
|
|
54
|
+
/** 読み込み位置 (JSのみ) */
|
|
55
|
+
position?: 'head' | 'body-start' | 'body-end';
|
|
56
|
+
/** async属性 (JSのみ) */
|
|
57
|
+
async?: boolean;
|
|
58
|
+
/** defer属性 (JSのみ) */
|
|
59
|
+
defer?: boolean;
|
|
60
|
+
/** 説明・メモ */
|
|
61
|
+
description?: string;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Favicon設定
|
|
66
|
+
*/
|
|
67
|
+
export interface FaviconSettings {
|
|
68
|
+
/** 標準favicon (ICO/PNG) */
|
|
69
|
+
ico?: string;
|
|
70
|
+
/** Apple Touch Icon */
|
|
71
|
+
appleTouchIcon?: string;
|
|
72
|
+
/** 32x32 PNG */
|
|
73
|
+
png32?: string;
|
|
74
|
+
/** 16x16 PNG */
|
|
75
|
+
png16?: string;
|
|
76
|
+
/** SVG favicon */
|
|
77
|
+
svg?: string;
|
|
78
|
+
/** manifest.json URL */
|
|
79
|
+
manifest?: string;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* プロジェクト/プレゼンテーション レベルのデフォルト設定
|
|
84
|
+
*/
|
|
85
|
+
export interface ProjectPageSettings {
|
|
86
|
+
// ===== 基本SEO =====
|
|
87
|
+
/** デフォルトのtitleテンプレート (例: "{page} | サイト名") */
|
|
88
|
+
titleTemplate?: string;
|
|
89
|
+
/** デフォルトのdescription */
|
|
90
|
+
defaultDescription?: string;
|
|
91
|
+
/** デフォルトのkeywords */
|
|
92
|
+
defaultKeywords?: string;
|
|
93
|
+
/** 言語設定 */
|
|
94
|
+
language?: string;
|
|
95
|
+
/** 文字エンコーディング */
|
|
96
|
+
charset?: string;
|
|
97
|
+
|
|
98
|
+
// ===== OGP デフォルト =====
|
|
99
|
+
ogp?: OgpSettings;
|
|
100
|
+
|
|
101
|
+
// ===== Twitter Card デフォルト =====
|
|
102
|
+
twitter?: TwitterCardSettings;
|
|
103
|
+
|
|
104
|
+
// ===== Favicon =====
|
|
105
|
+
favicon?: FaviconSettings;
|
|
106
|
+
|
|
107
|
+
// ===== 共通挿入コンテンツ =====
|
|
108
|
+
/** 全ページ共通の<head>追加HTML (analytics, fonts等) */
|
|
109
|
+
commonHeadHtml?: string;
|
|
110
|
+
/** 全ページ共通の<body>開始直後HTML */
|
|
111
|
+
commonBodyStartHtml?: string;
|
|
112
|
+
/** 全ページ共通の</body>直前HTML */
|
|
113
|
+
commonBodyEndHtml?: string;
|
|
114
|
+
|
|
115
|
+
// ===== 外部リソース =====
|
|
116
|
+
/** 全ページ共通の外部CSS */
|
|
117
|
+
externalCss?: ExternalResource[];
|
|
118
|
+
/** 全ページ共通の外部JS */
|
|
119
|
+
externalJs?: ExternalResource[];
|
|
120
|
+
|
|
121
|
+
// ===== 共通スタイル・スクリプト =====
|
|
122
|
+
/** 全ページ共通のカスタムCSS */
|
|
123
|
+
commonCss?: string;
|
|
124
|
+
/** 全ページ共通のカスタムJS */
|
|
125
|
+
commonJs?: string;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* ページ/スライド レベルの設定(プロジェクト設定を上書き可能)
|
|
130
|
+
*/
|
|
131
|
+
export interface PageSettings {
|
|
132
|
+
// ===== 継承設定 =====
|
|
133
|
+
/** プロジェクト設定を継承するか (default: true) */
|
|
134
|
+
inheritProjectSettings?: boolean;
|
|
135
|
+
|
|
136
|
+
// ===== 基本SEO =====
|
|
137
|
+
/** ページタイトル */
|
|
138
|
+
title?: string;
|
|
139
|
+
/** ページ説明文 */
|
|
140
|
+
description?: string;
|
|
141
|
+
/** キーワード */
|
|
142
|
+
keywords?: string;
|
|
143
|
+
/** canonical URL */
|
|
144
|
+
canonicalUrl?: string;
|
|
145
|
+
/** robots設定 */
|
|
146
|
+
robots?: string;
|
|
147
|
+
|
|
148
|
+
// ===== OGP (上書き) =====
|
|
149
|
+
ogp?: OgpSettings;
|
|
150
|
+
|
|
151
|
+
// ===== Twitter Card (上書き) =====
|
|
152
|
+
twitter?: TwitterCardSettings;
|
|
153
|
+
|
|
154
|
+
// ===== ページ固有の挿入コンテンツ =====
|
|
155
|
+
/** ページ固有の<head>追加HTML */
|
|
156
|
+
customHeadHtml?: string;
|
|
157
|
+
/** ページ固有の<body>開始直後HTML */
|
|
158
|
+
bodyStartHtml?: string;
|
|
159
|
+
/** ページ固有の</body>直前HTML */
|
|
160
|
+
bodyEndHtml?: string;
|
|
161
|
+
|
|
162
|
+
// ===== ページ固有リソース =====
|
|
163
|
+
/** ページ固有の外部CSS */
|
|
164
|
+
externalCss?: ExternalResource[];
|
|
165
|
+
/** ページ固有の外部JS */
|
|
166
|
+
externalJs?: ExternalResource[];
|
|
167
|
+
|
|
168
|
+
// ===== カスタムコード =====
|
|
169
|
+
/** ページ固有のカスタムCSS (インポートCSSもここに統合) */
|
|
170
|
+
customCss?: string;
|
|
171
|
+
/** カスタムCSSのStorage URL (大きい場合) */
|
|
172
|
+
customCssUrl?: string;
|
|
173
|
+
/** カスタムCSSのStorage Path (削除用) */
|
|
174
|
+
customCssPath?: string;
|
|
175
|
+
/** カスタムCSSのサイズ */
|
|
176
|
+
customCssSize?: number;
|
|
177
|
+
/** ページ固有のカスタムJS (インポートJSもここに統合) */
|
|
178
|
+
customJs?: string;
|
|
179
|
+
/** カスタムJSのStorage URL (大きい場合) */
|
|
180
|
+
customJsUrl?: string;
|
|
181
|
+
/** カスタムJSのStorage Path (削除用) */
|
|
182
|
+
customJsPath?: string;
|
|
183
|
+
/** カスタムJSのサイズ */
|
|
184
|
+
customJsSize?: number;
|
|
185
|
+
|
|
186
|
+
// ===== 更新日時 =====
|
|
187
|
+
updatedAt?: Date;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* マージされた最終設定
|
|
192
|
+
* プロジェクト設定とページ設定をマージした結果
|
|
193
|
+
*/
|
|
194
|
+
export interface MergedPageSettings {
|
|
195
|
+
title: string;
|
|
196
|
+
description: string;
|
|
197
|
+
keywords: string;
|
|
198
|
+
canonicalUrl?: string;
|
|
199
|
+
robots?: string;
|
|
200
|
+
language: string;
|
|
201
|
+
charset: string;
|
|
202
|
+
ogp: OgpSettings;
|
|
203
|
+
twitter: TwitterCardSettings;
|
|
204
|
+
favicon: FaviconSettings;
|
|
205
|
+
headHtml: string;
|
|
206
|
+
bodyStartHtml: string;
|
|
207
|
+
bodyEndHtml: string;
|
|
208
|
+
externalCss: ExternalResource[];
|
|
209
|
+
externalJs: ExternalResource[];
|
|
210
|
+
customCss: string;
|
|
211
|
+
customJs: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* プロジェクト設定とページ設定をマージする
|
|
216
|
+
*/
|
|
217
|
+
export function mergePageSettings(
|
|
218
|
+
projectSettings: ProjectPageSettings | null | undefined,
|
|
219
|
+
pageSettings: PageSettings | null | undefined,
|
|
220
|
+
pageTitle?: string
|
|
221
|
+
): MergedPageSettings {
|
|
222
|
+
const project = projectSettings || {};
|
|
223
|
+
const page = pageSettings || {};
|
|
224
|
+
|
|
225
|
+
// 継承しない場合はページ設定のみを使用
|
|
226
|
+
const inherit = page.inheritProjectSettings !== false;
|
|
227
|
+
|
|
228
|
+
// タイトルのマージ(テンプレート適用)
|
|
229
|
+
let finalTitle = page.title || pageTitle || '';
|
|
230
|
+
if (inherit && project.titleTemplate && finalTitle) {
|
|
231
|
+
finalTitle = project.titleTemplate.replace('{page}', finalTitle);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
return {
|
|
235
|
+
title: finalTitle,
|
|
236
|
+
description: page.description || (inherit ? project.defaultDescription : '') || '',
|
|
237
|
+
keywords: page.keywords || (inherit ? project.defaultKeywords : '') || '',
|
|
238
|
+
canonicalUrl: page.canonicalUrl,
|
|
239
|
+
robots: page.robots,
|
|
240
|
+
language: (inherit ? project.language : undefined) || 'ja',
|
|
241
|
+
charset: (inherit ? project.charset : undefined) || 'UTF-8',
|
|
242
|
+
|
|
243
|
+
ogp: {
|
|
244
|
+
...(inherit ? project.ogp : {}),
|
|
245
|
+
...page.ogp,
|
|
246
|
+
title: page.ogp?.title || page.title || (inherit ? project.ogp?.title : undefined) || finalTitle,
|
|
247
|
+
description: page.ogp?.description || page.description || (inherit ? project.ogp?.description : undefined),
|
|
248
|
+
},
|
|
249
|
+
|
|
250
|
+
twitter: {
|
|
251
|
+
...(inherit ? project.twitter : {}),
|
|
252
|
+
...page.twitter,
|
|
253
|
+
title: page.twitter?.title || page.title || (inherit ? project.twitter?.title : undefined) || finalTitle,
|
|
254
|
+
description: page.twitter?.description || page.description || (inherit ? project.twitter?.description : undefined),
|
|
255
|
+
},
|
|
256
|
+
|
|
257
|
+
favicon: inherit ? (project.favicon || {}) : {},
|
|
258
|
+
|
|
259
|
+
// HTML挿入コンテンツ(共通 + ページ固有を結合)
|
|
260
|
+
headHtml: [
|
|
261
|
+
inherit ? project.commonHeadHtml : '',
|
|
262
|
+
page.customHeadHtml
|
|
263
|
+
].filter(Boolean).join('\n'),
|
|
264
|
+
|
|
265
|
+
bodyStartHtml: [
|
|
266
|
+
inherit ? project.commonBodyStartHtml : '',
|
|
267
|
+
page.bodyStartHtml
|
|
268
|
+
].filter(Boolean).join('\n'),
|
|
269
|
+
|
|
270
|
+
bodyEndHtml: [
|
|
271
|
+
page.bodyEndHtml,
|
|
272
|
+
inherit ? project.commonBodyEndHtml : ''
|
|
273
|
+
].filter(Boolean).join('\n'),
|
|
274
|
+
|
|
275
|
+
// 外部リソース(共通 + ページ固有)
|
|
276
|
+
externalCss: [
|
|
277
|
+
...(inherit ? (project.externalCss || []) : []),
|
|
278
|
+
...(page.externalCss || [])
|
|
279
|
+
],
|
|
280
|
+
|
|
281
|
+
externalJs: [
|
|
282
|
+
...(inherit ? (project.externalJs || []) : []),
|
|
283
|
+
...(page.externalJs || [])
|
|
284
|
+
],
|
|
285
|
+
|
|
286
|
+
// カスタムコード(共通 + ページ固有)
|
|
287
|
+
customCss: [
|
|
288
|
+
inherit ? project.commonCss : '',
|
|
289
|
+
page.customCss
|
|
290
|
+
].filter(Boolean).join('\n\n'),
|
|
291
|
+
|
|
292
|
+
customJs: [
|
|
293
|
+
inherit ? project.commonJs : '',
|
|
294
|
+
page.customJs
|
|
295
|
+
].filter(Boolean).join('\n\n'),
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* 完全なHTMLドキュメントを生成する
|
|
301
|
+
*/
|
|
302
|
+
export function generateFullHtml(
|
|
303
|
+
bodyContent: string,
|
|
304
|
+
settings: MergedPageSettings
|
|
305
|
+
): string {
|
|
306
|
+
const lines: string[] = [];
|
|
307
|
+
|
|
308
|
+
lines.push('<!DOCTYPE html>');
|
|
309
|
+
lines.push(`<html lang="${settings.language}">`);
|
|
310
|
+
lines.push('<head>');
|
|
311
|
+
lines.push(` <meta charset="${settings.charset}">`);
|
|
312
|
+
lines.push(' <meta name="viewport" content="width=device-width, initial-scale=1.0">');
|
|
313
|
+
|
|
314
|
+
// Title
|
|
315
|
+
if (settings.title) {
|
|
316
|
+
lines.push(` <title>${escapeHtml(settings.title)}</title>`);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// Description
|
|
320
|
+
if (settings.description) {
|
|
321
|
+
lines.push(` <meta name="description" content="${escapeHtml(settings.description)}">`);
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// Keywords
|
|
325
|
+
if (settings.keywords) {
|
|
326
|
+
lines.push(` <meta name="keywords" content="${escapeHtml(settings.keywords)}">`);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// Robots
|
|
330
|
+
if (settings.robots) {
|
|
331
|
+
lines.push(` <meta name="robots" content="${escapeHtml(settings.robots)}">`);
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Canonical
|
|
335
|
+
if (settings.canonicalUrl) {
|
|
336
|
+
lines.push(` <link rel="canonical" href="${escapeHtml(settings.canonicalUrl)}">`);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
// OGP
|
|
340
|
+
if (settings.ogp.title) {
|
|
341
|
+
lines.push(` <meta property="og:title" content="${escapeHtml(settings.ogp.title)}">`);
|
|
342
|
+
}
|
|
343
|
+
if (settings.ogp.description) {
|
|
344
|
+
lines.push(` <meta property="og:description" content="${escapeHtml(settings.ogp.description)}">`);
|
|
345
|
+
}
|
|
346
|
+
if (settings.ogp.image) {
|
|
347
|
+
lines.push(` <meta property="og:image" content="${escapeHtml(settings.ogp.image)}">`);
|
|
348
|
+
}
|
|
349
|
+
if (settings.ogp.type) {
|
|
350
|
+
lines.push(` <meta property="og:type" content="${escapeHtml(settings.ogp.type)}">`);
|
|
351
|
+
}
|
|
352
|
+
if (settings.ogp.url) {
|
|
353
|
+
lines.push(` <meta property="og:url" content="${escapeHtml(settings.ogp.url)}">`);
|
|
354
|
+
}
|
|
355
|
+
if (settings.ogp.siteName) {
|
|
356
|
+
lines.push(` <meta property="og:site_name" content="${escapeHtml(settings.ogp.siteName)}">`);
|
|
357
|
+
}
|
|
358
|
+
if (settings.ogp.locale) {
|
|
359
|
+
lines.push(` <meta property="og:locale" content="${escapeHtml(settings.ogp.locale)}">`);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
// Twitter Card
|
|
363
|
+
if (settings.twitter.card) {
|
|
364
|
+
lines.push(` <meta name="twitter:card" content="${escapeHtml(settings.twitter.card)}">`);
|
|
365
|
+
}
|
|
366
|
+
if (settings.twitter.site) {
|
|
367
|
+
lines.push(` <meta name="twitter:site" content="${escapeHtml(settings.twitter.site)}">`);
|
|
368
|
+
}
|
|
369
|
+
if (settings.twitter.creator) {
|
|
370
|
+
lines.push(` <meta name="twitter:creator" content="${escapeHtml(settings.twitter.creator)}">`);
|
|
371
|
+
}
|
|
372
|
+
if (settings.twitter.title) {
|
|
373
|
+
lines.push(` <meta name="twitter:title" content="${escapeHtml(settings.twitter.title)}">`);
|
|
374
|
+
}
|
|
375
|
+
if (settings.twitter.description) {
|
|
376
|
+
lines.push(` <meta name="twitter:description" content="${escapeHtml(settings.twitter.description)}">`);
|
|
377
|
+
}
|
|
378
|
+
if (settings.twitter.image) {
|
|
379
|
+
lines.push(` <meta name="twitter:image" content="${escapeHtml(settings.twitter.image)}">`);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Favicon
|
|
383
|
+
if (settings.favicon.ico) {
|
|
384
|
+
lines.push(` <link rel="icon" href="${escapeHtml(settings.favicon.ico)}">`);
|
|
385
|
+
}
|
|
386
|
+
if (settings.favicon.svg) {
|
|
387
|
+
lines.push(` <link rel="icon" type="image/svg+xml" href="${escapeHtml(settings.favicon.svg)}">`);
|
|
388
|
+
}
|
|
389
|
+
if (settings.favicon.png32) {
|
|
390
|
+
lines.push(` <link rel="icon" type="image/png" sizes="32x32" href="${escapeHtml(settings.favicon.png32)}">`);
|
|
391
|
+
}
|
|
392
|
+
if (settings.favicon.png16) {
|
|
393
|
+
lines.push(` <link rel="icon" type="image/png" sizes="16x16" href="${escapeHtml(settings.favicon.png16)}">`);
|
|
394
|
+
}
|
|
395
|
+
if (settings.favicon.appleTouchIcon) {
|
|
396
|
+
lines.push(` <link rel="apple-touch-icon" href="${escapeHtml(settings.favicon.appleTouchIcon)}">`);
|
|
397
|
+
}
|
|
398
|
+
if (settings.favicon.manifest) {
|
|
399
|
+
lines.push(` <link rel="manifest" href="${escapeHtml(settings.favicon.manifest)}">`);
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
// External CSS
|
|
403
|
+
for (const css of settings.externalCss) {
|
|
404
|
+
lines.push(` <link rel="stylesheet" href="${escapeHtml(css.url)}">`);
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// External JS (head position)
|
|
408
|
+
for (const js of settings.externalJs.filter(j => j.position === 'head')) {
|
|
409
|
+
const attrs = [
|
|
410
|
+
`src="${escapeHtml(js.url)}"`,
|
|
411
|
+
js.async ? 'async' : '',
|
|
412
|
+
js.defer ? 'defer' : ''
|
|
413
|
+
].filter(Boolean).join(' ');
|
|
414
|
+
lines.push(` <script ${attrs}></script>`);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
// Custom CSS
|
|
418
|
+
if (settings.customCss) {
|
|
419
|
+
lines.push(' <style>');
|
|
420
|
+
lines.push(settings.customCss);
|
|
421
|
+
lines.push(' </style>');
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
// Custom head HTML
|
|
425
|
+
if (settings.headHtml) {
|
|
426
|
+
lines.push(settings.headHtml);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
lines.push('</head>');
|
|
430
|
+
lines.push('<body>');
|
|
431
|
+
|
|
432
|
+
// Body start HTML
|
|
433
|
+
if (settings.bodyStartHtml) {
|
|
434
|
+
lines.push(settings.bodyStartHtml);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
// External JS (body-start position)
|
|
438
|
+
for (const js of settings.externalJs.filter(j => j.position === 'body-start')) {
|
|
439
|
+
const attrs = [
|
|
440
|
+
`src="${escapeHtml(js.url)}"`,
|
|
441
|
+
js.async ? 'async' : '',
|
|
442
|
+
js.defer ? 'defer' : ''
|
|
443
|
+
].filter(Boolean).join(' ');
|
|
444
|
+
lines.push(`<script ${attrs}></script>`);
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
// Body content
|
|
448
|
+
lines.push(bodyContent);
|
|
449
|
+
|
|
450
|
+
// External JS (body-end position or default)
|
|
451
|
+
for (const js of settings.externalJs.filter(j => !j.position || j.position === 'body-end')) {
|
|
452
|
+
const attrs = [
|
|
453
|
+
`src="${escapeHtml(js.url)}"`,
|
|
454
|
+
js.async ? 'async' : '',
|
|
455
|
+
js.defer ? 'defer' : ''
|
|
456
|
+
].filter(Boolean).join(' ');
|
|
457
|
+
lines.push(`<script ${attrs}></script>`);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
// Custom JS
|
|
461
|
+
if (settings.customJs) {
|
|
462
|
+
lines.push('<script>');
|
|
463
|
+
lines.push(settings.customJs);
|
|
464
|
+
lines.push('</script>');
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Body end HTML
|
|
468
|
+
if (settings.bodyEndHtml) {
|
|
469
|
+
lines.push(settings.bodyEndHtml);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
lines.push('</body>');
|
|
473
|
+
lines.push('</html>');
|
|
474
|
+
|
|
475
|
+
return lines.join('\n');
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
/**
|
|
479
|
+
* HTML特殊文字をエスケープ
|
|
480
|
+
*/
|
|
481
|
+
function escapeHtml(text: string): string {
|
|
482
|
+
return text
|
|
483
|
+
.replace(/&/g, '&')
|
|
484
|
+
.replace(/</g, '<')
|
|
485
|
+
.replace(/>/g, '>')
|
|
486
|
+
.replace(/"/g, '"')
|
|
487
|
+
.replace(/'/g, ''');
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/**
|
|
491
|
+
* デフォルトのプロジェクト設定
|
|
492
|
+
*/
|
|
493
|
+
export const DEFAULT_PROJECT_SETTINGS: ProjectPageSettings = {
|
|
494
|
+
titleTemplate: '{page}',
|
|
495
|
+
defaultDescription: '',
|
|
496
|
+
defaultKeywords: '',
|
|
497
|
+
language: 'ja',
|
|
498
|
+
charset: 'UTF-8',
|
|
499
|
+
ogp: {
|
|
500
|
+
type: 'website',
|
|
501
|
+
locale: 'ja_JP',
|
|
502
|
+
},
|
|
503
|
+
twitter: {
|
|
504
|
+
card: 'summary_large_image',
|
|
505
|
+
},
|
|
506
|
+
};
|
|
507
|
+
|
|
508
|
+
/**
|
|
509
|
+
* デフォルトのページ設定
|
|
510
|
+
*/
|
|
511
|
+
export const DEFAULT_PAGE_SETTINGS: PageSettings = {
|
|
512
|
+
inheritProjectSettings: true,
|
|
513
|
+
};
|