@tecof/theme-editor 0.0.6 → 0.0.8
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/README.md +343 -128
- package/dist/index.d.mts +207 -11
- package/dist/index.d.ts +207 -11
- package/dist/index.js +12346 -2685
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +12347 -2691
- package/dist/index.mjs.map +1 -1
- package/dist/styles.css +1512 -0
- package/package.json +9 -3
package/README.md
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
# @tecof/theme-editor
|
|
2
2
|
|
|
3
|
-
Tecof platform için Puck CMS tabanlı sayfa
|
|
3
|
+
Tecof platform için Puck CMS tabanlı **sayfa editörü**, **render motoru** ve **gelişmiş alan bileşenleri** kütüphanesi.
|
|
4
|
+
|
|
5
|
+
> API Client, Context Provider, Puck wrapper bileşenleri, çok dilli alan yöneticileri, medya yöneticisi, link seçici, resim görüntüleyici ve tema araçları içerir.
|
|
6
|
+
|
|
7
|
+
---
|
|
4
8
|
|
|
5
9
|
## Kurulum
|
|
6
10
|
|
|
@@ -10,143 +14,383 @@ npm install @tecof/theme-editor @puckeditor/core react react-dom
|
|
|
10
14
|
|
|
11
15
|
## Hızlı Başlangıç
|
|
12
16
|
|
|
13
|
-
### 1.
|
|
17
|
+
### 1. TecofProvider ile Sarma
|
|
14
18
|
|
|
15
19
|
```tsx
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
HeroSection,
|
|
26
|
-
Footer,
|
|
27
|
-
},
|
|
28
|
-
};
|
|
20
|
+
import { TecofProvider } from "@tecof/theme-editor";
|
|
21
|
+
|
|
22
|
+
<TecofProvider
|
|
23
|
+
apiUrl="https://api.example.com"
|
|
24
|
+
secretKey="your-merchant-secret-key"
|
|
25
|
+
config={puckConfig}
|
|
26
|
+
>
|
|
27
|
+
{children}
|
|
28
|
+
</TecofProvider>
|
|
29
29
|
```
|
|
30
30
|
|
|
31
31
|
### 2. Editör Sayfası
|
|
32
32
|
|
|
33
33
|
```tsx
|
|
34
|
-
// app/editor/[slug]/page.tsx
|
|
35
34
|
"use client";
|
|
36
|
-
|
|
37
|
-
import { TecofProvider, TecofEditor } from "@tecof/theme-editor";
|
|
38
|
-
import "@tecof/theme-editor/styles.css";
|
|
39
|
-
import "@puckeditor/core/puck.css";
|
|
35
|
+
import { TecofEditor } from "@tecof/theme-editor";
|
|
40
36
|
import { puckConfig } from "@/puck-config";
|
|
41
37
|
|
|
42
|
-
export default function EditorPage() {
|
|
43
|
-
return
|
|
44
|
-
<TecofProvider
|
|
45
|
-
apiUrl="https://api.example.com"
|
|
46
|
-
accessToken="your-merchant-token"
|
|
47
|
-
config={puckConfig}
|
|
48
|
-
>
|
|
49
|
-
<TecofEditor
|
|
50
|
-
slug="home"
|
|
51
|
-
onSave={(data) => console.log("Saved:", data)}
|
|
52
|
-
/>
|
|
53
|
-
</TecofProvider>
|
|
54
|
-
);
|
|
38
|
+
export default function EditorPage({ params }) {
|
|
39
|
+
return <TecofEditor pageId={params.id} />;
|
|
55
40
|
}
|
|
56
41
|
```
|
|
57
42
|
|
|
58
43
|
### 3. Public Sayfa (Render)
|
|
59
44
|
|
|
60
45
|
```tsx
|
|
61
|
-
|
|
62
|
-
import { TecofProvider, TecofRender } from "@tecof/theme-editor";
|
|
63
|
-
import { puckConfig } from "@/puck-config";
|
|
64
|
-
|
|
65
|
-
export default function PublicPage() {
|
|
66
|
-
return (
|
|
67
|
-
<TecofProvider
|
|
68
|
-
apiUrl="https://api.example.com"
|
|
69
|
-
accessToken="your-merchant-token"
|
|
70
|
-
config={puckConfig}
|
|
71
|
-
>
|
|
72
|
-
<TecofRender slug="home" />
|
|
73
|
-
</TecofProvider>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
```
|
|
46
|
+
import { TecofRender } from "@tecof/theme-editor";
|
|
77
47
|
|
|
78
|
-
|
|
48
|
+
// Slug ile otomatik fetch
|
|
49
|
+
<TecofRender slug="home" />
|
|
79
50
|
|
|
80
|
-
|
|
51
|
+
// Direkt data ile
|
|
81
52
|
<TecofRender data={puckData} />
|
|
82
53
|
```
|
|
83
54
|
|
|
84
|
-
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Bileşenler
|
|
85
58
|
|
|
86
59
|
### `<TecofProvider />`
|
|
87
60
|
|
|
88
|
-
Tüm Tecof bileşenlerini sarar, API client ve
|
|
61
|
+
Tüm Tecof bileşenlerini sarar, API client ve config context'i sağlar.
|
|
89
62
|
|
|
90
63
|
| Prop | Tip | Açıklama |
|
|
91
64
|
|------|-----|----------|
|
|
92
65
|
| `apiUrl` | `string` | Backend API base URL |
|
|
93
|
-
| `
|
|
66
|
+
| `secretKey` | `string` | Merchant secret key |
|
|
94
67
|
| `config` | `Config` | Puck component configuration |
|
|
95
68
|
| `children` | `ReactNode` | Alt bileşenler |
|
|
96
69
|
|
|
97
70
|
### `<TecofEditor />`
|
|
98
71
|
|
|
99
|
-
Puck
|
|
72
|
+
Puck wrapper — sayfa editörü. Otomatik fetch/save ve iframe postMessage desteği.
|
|
100
73
|
|
|
101
74
|
| Prop | Tip | Açıklama |
|
|
102
75
|
|------|-----|----------|
|
|
103
|
-
| `
|
|
76
|
+
| `pageId` | `string` | Düzenlenecek sayfa ID'si |
|
|
104
77
|
| `onSave` | `(data) => void` | Kayıt sonrası callback |
|
|
105
78
|
| `onPublish` | `(data) => void` | Yayınlama sonrası callback |
|
|
106
79
|
| `onChange` | `(data) => void` | Her değişiklikte callback |
|
|
107
80
|
| `overrides` | `object` | Puck UI override'ları |
|
|
108
|
-
| `plugins` | `any[]` | Ek Puck plugin'leri |
|
|
109
|
-
| `className` | `string` | CSS class |
|
|
110
81
|
|
|
111
82
|
### `<TecofRender />`
|
|
112
83
|
|
|
113
|
-
|
|
84
|
+
Yayınlanmış sayfaları render eder.
|
|
114
85
|
|
|
115
86
|
| Prop | Tip | Açıklama |
|
|
116
87
|
|------|-----|----------|
|
|
117
88
|
| `slug` | `string` | Sayfa slug'ı (otomatik fetch) |
|
|
118
89
|
| `data` | `PuckPageData` | Direkt puck data (fetch yapmaz) |
|
|
119
|
-
| `fallback` | `ReactNode` | Yükleme sırasında
|
|
120
|
-
| `className` | `string` | CSS class |
|
|
90
|
+
| `fallback` | `ReactNode` | Yükleme sırasında gösterilen bileşen |
|
|
121
91
|
|
|
122
|
-
###
|
|
92
|
+
### `<TecofPicture />`
|
|
123
93
|
|
|
124
|
-
|
|
94
|
+
Akıllı medya bileşeni — görsel/video otomatik algılama, responsive boyutlar, fancybox desteği.
|
|
125
95
|
|
|
126
96
|
```tsx
|
|
127
|
-
|
|
97
|
+
import { TecofPicture } from "@tecof/theme-editor";
|
|
98
|
+
import Image from "next/image";
|
|
99
|
+
|
|
100
|
+
// Basit kullanım
|
|
101
|
+
<TecofPicture data={file} alt="Hero" />
|
|
102
|
+
|
|
103
|
+
// Fill modu
|
|
104
|
+
<TecofPicture data={file} fill />
|
|
105
|
+
|
|
106
|
+
// Next.js Image ile
|
|
107
|
+
<TecofPicture
|
|
108
|
+
data={file}
|
|
109
|
+
ImageComponent={Image}
|
|
110
|
+
imageProps={{ quality: 85, priority: true }}
|
|
111
|
+
/>
|
|
112
|
+
|
|
113
|
+
// Fancybox lightbox
|
|
114
|
+
<TecofPicture data={file} fancybox fancyboxName="gallery" />
|
|
128
115
|
```
|
|
129
116
|
|
|
130
|
-
|
|
117
|
+
| Prop | Tip | Açıklama |
|
|
118
|
+
|------|-----|----------|
|
|
119
|
+
| `data` | `UploadedFile` | Yüklenen dosya verisi |
|
|
120
|
+
| `alt` | `string` | Alt metin |
|
|
121
|
+
| `size` | `thumbnail \| medium \| large \| full` | Responsive boyut |
|
|
122
|
+
| `fill` | `boolean` | Parent'ı kaplar |
|
|
123
|
+
| `ImageComponent` | `ComponentType` | Özel image bileşeni (örn: Next.js Image) |
|
|
124
|
+
| `imageProps` | `Record<string,any>` | ImageComponent'e ek prop'lar |
|
|
125
|
+
| `fancybox` | `boolean` | Fancybox lightbox desteği |
|
|
126
|
+
|
|
127
|
+
---
|
|
128
|
+
|
|
129
|
+
## Custom Fields (Puck Alanları)
|
|
131
130
|
|
|
132
|
-
|
|
131
|
+
Tüm alanlar `createXField()` factory fonksiyonları ile Puck config'e entegre edilir.
|
|
132
|
+
|
|
133
|
+
### LanguageField — Çok Dilli Metin
|
|
134
|
+
|
|
135
|
+
Sekmeli çok dilli metin girişi. Merchant ayarlarından dilleri otomatik çeker.
|
|
133
136
|
|
|
134
137
|
```tsx
|
|
135
|
-
import {
|
|
138
|
+
import { createLanguageField } from "@tecof/theme-editor";
|
|
139
|
+
|
|
140
|
+
fields: {
|
|
141
|
+
title: createLanguageField({ label: "Başlık" }),
|
|
142
|
+
description: createLanguageField({
|
|
143
|
+
label: "Açıklama",
|
|
144
|
+
isTextarea: true,
|
|
145
|
+
textareaRows: 4,
|
|
146
|
+
}),
|
|
147
|
+
htmlContent: createLanguageField({
|
|
148
|
+
label: "HTML İçerik",
|
|
149
|
+
isHtml: true,
|
|
150
|
+
}),
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
**Özellikler:**
|
|
155
|
+
- 🌐 Otomatik dil algılama (merchant ayarlarından)
|
|
156
|
+
- 📋 **Hızlı Doldur** — Aktif sekmedeki metni tüm dillere kopyalar
|
|
157
|
+
- 🔄 **Çevir** — Aktif metni API üzerinden diğer dillere otomatik çevirir (DeepL / Google / OpenAI / Ollama)
|
|
158
|
+
- `isHtml` desteği — HTML taglarını koruyarak çeviri yapar
|
|
159
|
+
|
|
160
|
+
| Option | Tip | Default | Açıklama |
|
|
161
|
+
|--------|-----|---------|----------|
|
|
162
|
+
| `isTextarea` | `boolean` | `false` | Textarea modu |
|
|
163
|
+
| `textareaRows` | `number` | `3` | Textarea satır sayısı |
|
|
164
|
+
| `placeholder` | `string` | `''` | Placeholder metni |
|
|
165
|
+
| `isHtml` | `boolean` | `false` | HTML içerik çevirisi |
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
### EditorField — Zengin Metin Editörü
|
|
136
170
|
|
|
137
|
-
|
|
171
|
+
TipTap tabanlı, çok dilli WYSIWYG editörü.
|
|
138
172
|
|
|
139
|
-
|
|
140
|
-
|
|
173
|
+
```tsx
|
|
174
|
+
fields: {
|
|
175
|
+
content: createEditorField({ label: "İçerik" }),
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
**Özellikler:** Bold, italic, link, liste, heading ve daha fazlası.
|
|
141
180
|
|
|
142
|
-
|
|
143
|
-
await client.savePage("home", puckData);
|
|
181
|
+
---
|
|
144
182
|
|
|
145
|
-
|
|
146
|
-
|
|
183
|
+
### UploadField — Gelişmiş Medya Yöneticisi
|
|
184
|
+
|
|
185
|
+
FilePond tabanlı dosya yükleme + Vaul Drawer medya kütüphanesi + Doka görseldüzenleyici.
|
|
186
|
+
|
|
187
|
+
```tsx
|
|
188
|
+
fields: {
|
|
189
|
+
images: createUploadField({
|
|
190
|
+
label: "Görseller",
|
|
191
|
+
allowMultiple: true,
|
|
192
|
+
maxFiles: 10,
|
|
193
|
+
maxFileSize: "50MB",
|
|
194
|
+
showUploadedFiles: true,
|
|
195
|
+
}),
|
|
196
|
+
document: createUploadField({
|
|
197
|
+
label: "Doküman",
|
|
198
|
+
allowMultiple: false,
|
|
199
|
+
acceptedTypes: ["application/pdf"],
|
|
200
|
+
}),
|
|
201
|
+
}
|
|
147
202
|
```
|
|
148
203
|
|
|
149
|
-
|
|
204
|
+
**Özellikler:**
|
|
205
|
+
- 📁 **Medya Seç** — Vaul drawer ile sunucudaki mevcut dosyaları seçin
|
|
206
|
+
- 📤 **Yeni Yükle** — FilePond ile sürükle-bırak dosya yükleme
|
|
207
|
+
- 🖼️ **Doka Görsel Düzenleyici** — Kırp, döndür, parlaklık, kontrast, markup, çıkartma
|
|
208
|
+
- 🗜️ **Resim Sıkıştırma** — Otomatik WebP dönüşümü (browser-image-compression)
|
|
209
|
+
- 📄 24+ dosya türü desteği (görseller, PDF, Office, CSV, video)
|
|
210
|
+
- 👁️ Dosya önizleme, indirme ve kaldırma butonları
|
|
211
|
+
- 🇹🇷 Tamamen Türkçe etiketler (FilePond + Doka)
|
|
212
|
+
|
|
213
|
+
| Option | Tip | Default | Açıklama |
|
|
214
|
+
|--------|-----|---------|----------|
|
|
215
|
+
| `allowMultiple` | `boolean` | `true` | Çoklu dosya |
|
|
216
|
+
| `maxFiles` | `number` | `100` | Maksimum dosya sayısı |
|
|
217
|
+
| `maxFileSize` | `string` | `100MB` | Tek dosya limiti |
|
|
218
|
+
| `maxTotalFileSize` | `string` | `200MB` | Toplam limit |
|
|
219
|
+
| `acceptedTypes` | `string[]` | `[all]` | İzin verilen MIME türleri |
|
|
220
|
+
| `showUploadedFiles` | `boolean` | `false` | Başlık göster |
|
|
221
|
+
| `imageCompressionEnabled` | `boolean` | `true` | Sıkıştırma aktif |
|
|
222
|
+
| `allowReorder` | `boolean` | `true` | Sürükle-bırak sıralama |
|
|
223
|
+
|
|
224
|
+
---
|
|
225
|
+
|
|
226
|
+
### LinkField — Sayfa / URL Seçici
|
|
227
|
+
|
|
228
|
+
Mevcut sayfalardan seçim veya manuel URL girişi.
|
|
229
|
+
|
|
230
|
+
```tsx
|
|
231
|
+
fields: {
|
|
232
|
+
link: createLinkField({ label: "Bağlantı" }),
|
|
233
|
+
ctaLink: createLinkField({
|
|
234
|
+
label: "CTA Link",
|
|
235
|
+
showTarget: true,
|
|
236
|
+
placeholder: "https://example.com",
|
|
237
|
+
}),
|
|
238
|
+
}
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
**Özellikler:**
|
|
242
|
+
- 📄 **Sayfa Seç** — Vaul drawer ile merchant sayfalarını listeler, aranabilir
|
|
243
|
+
- 🔗 **Manuel Link** — URL + etiket + hedef (aynı/yeni sekme) girişi
|
|
244
|
+
- 🟢 Durum göstergesi (yayınlanmış / değiştirilmiş / taslak)
|
|
245
|
+
- 🏷️ Tip badge'i (Sayfa / Link)
|
|
246
|
+
|
|
247
|
+
| Option | Tip | Default | Açıklama |
|
|
248
|
+
|--------|-----|---------|----------|
|
|
249
|
+
| `showTarget` | `boolean` | `true` | Hedef sekme seçici |
|
|
250
|
+
| `placeholder` | `string` | `https://...` | URL placeholder |
|
|
251
|
+
|
|
252
|
+
**Değer Tipi (`LinkFieldValue`):**
|
|
253
|
+
```ts
|
|
254
|
+
{
|
|
255
|
+
url: string; // "/about" veya "https://..."
|
|
256
|
+
label?: string; // "Hakkımızda"
|
|
257
|
+
target?: "_self" | "_blank";
|
|
258
|
+
type?: "page" | "custom";
|
|
259
|
+
}
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
---
|
|
263
|
+
|
|
264
|
+
### CodeEditorField — Kod Editörü
|
|
265
|
+
|
|
266
|
+
Monaco Editor tabanlı syntax-highlighted kod editörü.
|
|
267
|
+
|
|
268
|
+
```tsx
|
|
269
|
+
fields: {
|
|
270
|
+
customHtml: createCodeEditorField({
|
|
271
|
+
label: "Özel Kod",
|
|
272
|
+
defaultLanguage: "html",
|
|
273
|
+
}),
|
|
274
|
+
jsonConfig: createCodeEditorField({
|
|
275
|
+
label: "Config",
|
|
276
|
+
defaultLanguage: "json",
|
|
277
|
+
}),
|
|
278
|
+
}
|
|
279
|
+
```
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
### ColorField — Renk Seçici
|
|
284
|
+
|
|
285
|
+
Yerel renk seçici, HEX giriş, hazır palet ve opsiyonel opaklık kaydırıcısı.
|
|
286
|
+
|
|
287
|
+
```tsx
|
|
288
|
+
import { createColorField } from "@tecof/theme-editor";
|
|
289
|
+
|
|
290
|
+
fields: {
|
|
291
|
+
bgColor: createColorField({ label: "Arka Plan Rengi" }),
|
|
292
|
+
textColor: createColorField({
|
|
293
|
+
label: "Metin Rengi",
|
|
294
|
+
showOpacity: true,
|
|
295
|
+
defaultColor: "#18181b",
|
|
296
|
+
}),
|
|
297
|
+
accentColor: createColorField({
|
|
298
|
+
label: "Vurgu Rengi",
|
|
299
|
+
showPresets: false,
|
|
300
|
+
}),
|
|
301
|
+
}
|
|
302
|
+
```
|
|
303
|
+
|
|
304
|
+
**Özellikler:**
|
|
305
|
+
- 🎨 **Yerel Renk Seçici** — Sistem renk picker'ı ile kolay seçim
|
|
306
|
+
- 🔤 **HEX Giriş** — Monospace font ile doğrudan HEX kodu yazma
|
|
307
|
+
- 🎯 **Hazır Palet** — 9×n grid ile hızlı renk seçimi (tamamen özelleştirilebilir)
|
|
308
|
+
- 🔲 **Opaklık** — Opsiyonel alpha/opaklık kaydırıcısı (8-digit hex)
|
|
309
|
+
- ↩️ **Sıfırla** — Varsayılan renge geri dönme butonu
|
|
310
|
+
|
|
311
|
+
| Option | Tip | Default | Açıklama |
|
|
312
|
+
|--------|-----|---------|----------|
|
|
313
|
+
| `showOpacity` | `boolean` | `false` | Opaklık kaydırıcısı |
|
|
314
|
+
| `showPresets` | `boolean` | `true` | Hazır renk paleti göster |
|
|
315
|
+
| `presetColors` | `string[]` | `[built-in]` | Özel hazır renk listesi |
|
|
316
|
+
| `defaultColor` | `string` | `''` | Varsayılan/sıfırlama rengi |
|
|
317
|
+
| `placeholder` | `string` | `#000000` | HEX giriş placeholder |
|
|
318
|
+
| `showReset` | `boolean` | `true` | Sıfırlama butonu göster |
|
|
319
|
+
|
|
320
|
+
---
|
|
321
|
+
|
|
322
|
+
### Ortak Alan Seçenekleri (BaseField)
|
|
323
|
+
|
|
324
|
+
Tüm `create*Field()` factory fonksiyonları aşağıdaki ortak seçenekleri destekler:
|
|
325
|
+
|
|
326
|
+
| Option | Tip | Açıklama |
|
|
327
|
+
|--------|-----|----------|
|
|
328
|
+
| `label` | `string` | Puck sidebar'da görünen alan etiketi |
|
|
329
|
+
| `labelIcon` | `ReactElement` | Etiketin yanında gösterilen ikon (ör: Lucide) |
|
|
330
|
+
| `visible` | `boolean` | Alanın sidebar'da görünür olup olmadığı |
|
|
331
|
+
|
|
332
|
+
```tsx
|
|
333
|
+
import { Globe, Image, Palette } from "lucide-react";
|
|
334
|
+
|
|
335
|
+
fields: {
|
|
336
|
+
title: createLanguageField({
|
|
337
|
+
label: "Başlık",
|
|
338
|
+
labelIcon: <Globe size={16} />,
|
|
339
|
+
}),
|
|
340
|
+
bgColor: createColorField({
|
|
341
|
+
label: "Arka Plan",
|
|
342
|
+
labelIcon: <Palette size={16} />,
|
|
343
|
+
}),
|
|
344
|
+
logo: createUploadField({
|
|
345
|
+
label: "Logo",
|
|
346
|
+
labelIcon: <Image size={16} />,
|
|
347
|
+
visible: true,
|
|
348
|
+
}),
|
|
349
|
+
}
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
---
|
|
353
|
+
|
|
354
|
+
## API Client
|
|
355
|
+
|
|
356
|
+
```tsx
|
|
357
|
+
import { TecofApiClient } from "@tecof/theme-editor";
|
|
358
|
+
|
|
359
|
+
const client = new TecofApiClient("https://api.example.com", "secret-key");
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
| Metot | Açıklama |
|
|
363
|
+
|-------|----------|
|
|
364
|
+
| `getPage(id)` | Sayfa draft'ını getir |
|
|
365
|
+
| `savePage(id, data)` | Sayfa kaydet |
|
|
366
|
+
| `getPublishedPage(slug, locale?)` | Yayınlanmış sayfayı getir |
|
|
367
|
+
| `getMerchantInfo()` | Dil ayarlarını getir |
|
|
368
|
+
| `uploadFile(file, folder?)` | Dosya yükle |
|
|
369
|
+
| `getUploads(page, limit)` | Yüklenen dosyaları listele |
|
|
370
|
+
| `getPages()` | Merchant sayfalarını listele |
|
|
371
|
+
| `translate(text, sourceLang, locales, isHtml?)` | Metni birden çok dile çevir |
|
|
372
|
+
| `cdnUrl` | CDN base URL |
|
|
373
|
+
|
|
374
|
+
---
|
|
375
|
+
|
|
376
|
+
## Backend API Endpoints
|
|
377
|
+
|
|
378
|
+
Kütüphane aşağıdaki endpoint'leri kullanır (`x-secret-key` header ile):
|
|
379
|
+
|
|
380
|
+
| Method | Endpoint | Açıklama |
|
|
381
|
+
|--------|----------|----------|
|
|
382
|
+
| `GET` | `/api/store/editor/:id` | Sayfa draft'ını getir |
|
|
383
|
+
| `PUT` | `/api/store/editor/:id` | Sayfa kaydet |
|
|
384
|
+
| `POST` | `/api/store/render` | Yayınlanmış sayfayı getir (slug + locale) |
|
|
385
|
+
| `GET` | `/api/store/merchant-info` | Merchant dil ayarları |
|
|
386
|
+
| `POST` | `/api/store/upload` | Dosya yükle |
|
|
387
|
+
| `GET` | `/api/store/uploads` | Yüklenen dosyaları listele |
|
|
388
|
+
| `GET` | `/api/store/pages` | Merchant sayfalarını listele |
|
|
389
|
+
| `POST` | `/api/store/translate` | Metni çok dile çevir |
|
|
390
|
+
|
|
391
|
+
---
|
|
392
|
+
|
|
393
|
+
## Utility Fonksiyonları
|
|
150
394
|
|
|
151
395
|
```tsx
|
|
152
396
|
import {
|
|
@@ -162,7 +406,7 @@ import {
|
|
|
162
406
|
|
|
163
407
|
| Fonksiyon | Açıklama |
|
|
164
408
|
|-----------|----------|
|
|
165
|
-
| `getDefaultTheme()` | Varsayılan tema config'i
|
|
409
|
+
| `getDefaultTheme()` | Varsayılan tema config'i |
|
|
166
410
|
| `generateCSSVariables(theme)` | ThemeConfig → CSS custom properties |
|
|
167
411
|
| `mergeTheme(base, overrides)` | Tema config deep-merge |
|
|
168
412
|
| `hexToHsl(hex)` | Hex → HSL dönüşümü |
|
|
@@ -170,44 +414,7 @@ import {
|
|
|
170
414
|
| `lighten(hex, amount)` | Rengi açar |
|
|
171
415
|
| `darken(hex, amount)` | Rengi koyulaştırır |
|
|
172
416
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
Kütüphane içinde Tecof platformuna özel olarak hazırlanmış gelişmiş Puck alanları (`fields`) bulunmaktadır:
|
|
176
|
-
|
|
177
|
-
| Alan Adı | Özellikler |
|
|
178
|
-
|----------|------------|
|
|
179
|
-
| **`LanguageField`** | Çok dilli, sekmeli düz metin girişi. Uygulama ayarlarından tanımlı dilleri otomatik çeker. |
|
|
180
|
-
| **`EditorField`** | Çok dilli, zengin metin editörü (TipTap tabanlı). Bold, italic, link, liste gibi temel araç çubuğuna sahiptir. |
|
|
181
|
-
| **`UploadField`** | FilePond ve Vaul Drawer tabanlı medya yöneticisi. Yeni görsel yükleme ve sunucudaki eski medyaları seçme yeteneğine sahiptir. |
|
|
182
|
-
| **`CodeEditorField`** | Monaco Editor tabanlı kod editörü. HTML, CSS, JSON gibi özel kod alanları eklemek için kullanılır. |
|
|
183
|
-
|
|
184
|
-
**Örnek Kullanım:**
|
|
185
|
-
|
|
186
|
-
```tsx
|
|
187
|
-
import {
|
|
188
|
-
createLanguageField,
|
|
189
|
-
createEditorField,
|
|
190
|
-
createUploadField,
|
|
191
|
-
createCodeEditorField
|
|
192
|
-
} from "@tecof/theme-editor";
|
|
193
|
-
|
|
194
|
-
const myComponent = {
|
|
195
|
-
fields: {
|
|
196
|
-
title: createLanguageField({ label: "Başlık" }),
|
|
197
|
-
content: createEditorField({ label: "İçerik" }),
|
|
198
|
-
images: createUploadField({
|
|
199
|
-
label: "Görseller",
|
|
200
|
-
allowMultiple: true,
|
|
201
|
-
maxFiles: 5
|
|
202
|
-
}),
|
|
203
|
-
customHtml: createCodeEditorField({
|
|
204
|
-
label: "Özel Kod",
|
|
205
|
-
defaultLanguage: "html"
|
|
206
|
-
})
|
|
207
|
-
},
|
|
208
|
-
// ...
|
|
209
|
-
};
|
|
210
|
-
```
|
|
417
|
+
---
|
|
211
418
|
|
|
212
419
|
## iframe postMessage API
|
|
213
420
|
|
|
@@ -215,10 +422,10 @@ const myComponent = {
|
|
|
215
422
|
|
|
216
423
|
```ts
|
|
217
424
|
// Parent → Editor
|
|
218
|
-
iframe.postMessage({ type: "puck:publish" }, "*");
|
|
219
|
-
iframe.postMessage({ type: "puck:undo" }, "*");
|
|
220
|
-
iframe.postMessage({ type: "puck:redo" }, "*");
|
|
221
|
-
iframe.postMessage({ type: "puck:viewport", width: "375px" }, "*");
|
|
425
|
+
iframe.postMessage({ type: "puck:publish" }, "*");
|
|
426
|
+
iframe.postMessage({ type: "puck:undo" }, "*");
|
|
427
|
+
iframe.postMessage({ type: "puck:redo" }, "*");
|
|
428
|
+
iframe.postMessage({ type: "puck:viewport", width: "375px" }, "*");
|
|
222
429
|
|
|
223
430
|
// Editor → Parent
|
|
224
431
|
window.addEventListener("message", (e) => {
|
|
@@ -227,25 +434,33 @@ window.addEventListener("message", (e) => {
|
|
|
227
434
|
});
|
|
228
435
|
```
|
|
229
436
|
|
|
230
|
-
|
|
437
|
+
---
|
|
231
438
|
|
|
232
|
-
|
|
439
|
+
## CSS ve Tema Yapısı
|
|
233
440
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
441
|
+
Kütüphane %100 oranında izole bir CSS altyapısı sunar. Önceden kullanılan inline "CSS-in-JS" tarzı sabit tasarımlar kaldırılmış, field modüllerine ait tüm UI stilleri (EditorField, LinkField, UploadField vs.) merkezi `dist/styles.css` içerisine taşınmıştır.
|
|
442
|
+
|
|
443
|
+
Tasarım çakışmalarını önlemek için kütüphanenin sunduğu tüm CSS sınıfları sadece `.tecof-[component]-[element]` (örnek: `.tecof-upload-file-list`) ön ekini kullanır. `:root` altındaki renk değişkenlerinden (örn: `--tecof-primary-500`) beslenir.
|
|
444
|
+
|
|
445
|
+
Editör alanlarının tam verimle (FilePond, Doka Editor vs.) düzgün işleyebilmesi için bu CSS dosyasını layout ana dosyanıza dahil edin:
|
|
446
|
+
|
|
447
|
+
```tsx
|
|
448
|
+
// Ana Layout / Editor bileşenine yakın
|
|
449
|
+
import "@tecof/theme-editor/dist/styles.css";
|
|
450
|
+
```
|
|
451
|
+
|
|
452
|
+
---
|
|
239
453
|
|
|
240
454
|
## Geliştirme
|
|
241
455
|
|
|
242
456
|
```bash
|
|
243
|
-
npm run dev # Watch mode
|
|
244
|
-
npm run build # Production build
|
|
457
|
+
npm run dev # Watch mode (tsup)
|
|
458
|
+
npm run build # Production build + CSS bundle
|
|
245
459
|
npm run lint # ESLint
|
|
246
460
|
npm run test # Vitest
|
|
461
|
+
npm run storybook # Storybook
|
|
247
462
|
```
|
|
248
463
|
|
|
249
464
|
## Lisans
|
|
250
465
|
|
|
251
|
-
MIT
|
|
466
|
+
MIT © Tecof
|