@ozguraltan/strapi-content-input 1.0.21 → 1.0.22

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 (24) hide show
  1. package/README.md +33 -7
  2. package/dist/admin/{AnalyticsHubPage-0p0Mx4AU.js → AnalyticsHubPage-B1_chQkG.js} +2 -2
  3. package/dist/admin/{AnalyticsHubPage-DsrcGI_Y.mjs → AnalyticsHubPage-DUj3D2kA.mjs} +2 -2
  4. package/dist/admin/{ContentInputField-CHXrzvE-.mjs → ContentInputField-BrtpTCDd.mjs} +365 -173
  5. package/dist/admin/{ContentInputField-7rWLSx_7.js → ContentInputField-CQFQxxgm.js} +365 -173
  6. package/dist/admin/{SurveyWidgetEditor-BmgYQaQS.js → SurveyWidgetEditor-C5Uvyf_h.js} +81 -31
  7. package/dist/admin/{SurveyWidgetEditor-BVN6X_3G.mjs → SurveyWidgetEditor-DGSwgTzR.mjs} +81 -31
  8. package/dist/admin/{index-hFIuYqu5.mjs → index-Dc7AFLOj.mjs} +2 -2
  9. package/dist/admin/{index-CZAwXCFH.js → index-i0NfSYto.js} +2 -2
  10. package/dist/admin/index.js +1 -1
  11. package/dist/admin/index.mjs +1 -1
  12. package/dist/admin/src/components/common/CIImageSettingsControl.d.ts +17 -0
  13. package/dist/admin/src/components/widgets/CustomCardWidgetEditor.d.ts +1 -0
  14. package/dist/admin/src/components/widgets/HeroSliderStage.d.ts +3 -0
  15. package/dist/admin/src/core/canvasClasses.d.ts +1 -0
  16. package/dist/admin/src/core/types.d.ts +12 -0
  17. package/dist/server/index.js +1176 -184
  18. package/dist/server/index.mjs +1176 -184
  19. package/dist/server/src/config/index.d.ts +4 -0
  20. package/dist/server/src/controllers/ci-image.d.ts +11 -2
  21. package/dist/server/src/controllers/index.d.ts +1 -0
  22. package/dist/server/src/index.d.ts +5 -0
  23. package/dist/server/src/utils/image-variants.d.ts +74 -0
  24. package/package.json +1 -1
package/README.md CHANGED
@@ -40,9 +40,16 @@ npm install git+ssh://git@gitlab.com:ozguraltan/strapi-content-input.git
40
40
  ### Step 2: Enable in `config/plugins.ts` & `config/features.ts`
41
41
  ```ts
42
42
  // config/plugins.ts
43
- export default () => ({
43
+ export default ({ env }) => ({
44
44
  'content-input': {
45
45
  enabled: true,
46
+ config: {
47
+ // Optional — defaults work out of the box even without .env variables:
48
+ imageVariantFolder: env('CI_IMAGE_VARIANT_FOLDER', 'ci-optimized'), // CDN subfolder for sharp WebP variants
49
+ imageVariantFormat: env('CI_IMAGE_VARIANT_FORMAT', 'webp'), // 'webp' (preserves PNG alpha transparency)
50
+ imageVariantQuality: env.int('CI_IMAGE_VARIANT_QUALITY', 85),
51
+ redirectProxyToCdn: env.bool('CI_IMAGE_REDIRECT_CDN', true), // 302 redirect /api/content-input/image -> CDN
52
+ },
46
53
  },
47
54
  });
48
55
  ```
@@ -119,11 +126,18 @@ export default [
119
126
  ![Canvas View](./docs/screenshots/02-canvas-view.png)
120
127
  ![Full-Screen Visual Editor](./docs/screenshots/03-visual-editor-tab-html.png)
121
128
 
122
- ### 2.2 Official Strapi Native Media Library Modal + `sharp` On-the-Fly + CDN Thumbnail Pipeline
123
- - **Official Strapi Media Library Modal (`components['media-library']` in `StrapiMediaPicker`):** Every media field across all 18 widgets and full-screen studios (`heroSlider` background image/video & floating layer, `customCard` media & author avatar, `entityCard`, `survey` image choice, `gallery`, `singleImage`, `youtubeVideo`, `banner`, `button`, `StyleControls`, and `RichHtmlEditor`) opens Strapi's **official native Media Library Dialog** (`z-index: 310` cleanly above all `200–270` ContentInput studios) with full-color thumbnails, pagination, folder navigation/creation, drag-and-drop upload, asset metadata editing, and Strapi's built-in **Cropper.js** cropper — plus an optional 1-click inline `sharp` **Crop & Rotate Studio** (`Free`, `1:1`, `16:9`, `4:3`, `3:2`, `4:5`, `-90°/+90°`, `Duplicate & Crop` or `Crop Original Asset`).
124
- - **On-the-Fly `sharp` Endpoint (`/api/content-input/image`) & Automatic CDN Upload:**
125
- - When a `gallery` widget uses `imageSettings` (`process: 'fit'` for `cWidth × cHeight` crop, or `process: 'widen'` for `cWidth` scaling), `sharp` generates the exact thumbnail on the backend, uploads the generated variant to Strapi's active Upload Provider / CDN (`strapi.plugin('upload').service('provider').upload`), persists the CDN URL in `file.formats['ci_fit_WxH']`, and caches it with immutable HTTP headers.
126
- - Clicking any gallery image opens the **Popup Lightbox** with the **full-resolution uncropped original image**.
129
+ ### 2.2 Universal `sharp` WebP + CDN Variant Engine (`ci-optimized/`) & Native Media Library Modal
130
+ - **Official Strapi Media Library Modal (`components['media-library']` in `StrapiMediaPicker`):** Every media field across all 18 widgets and full-screen studios (`heroSlider` background image/video & floating layer, `customCard` media & author avatar, `entityCard`, `survey` image choice, `dataTable` image cells, `gallery`, `singleImage`, `youtubeVideo`, `banner`, `button`, `StyleControls` Row/Block `bgImage`, and `RichHtmlEditor`) opens Strapi's **official native Media Library Dialog** (`z-index: 310` cleanly above all `200–270` ContentInput studios) with full-color thumbnails, pagination, folder navigation/creation, drag-and-drop upload, asset metadata editing, and Strapi's built-in **Cropper.js** cropper — plus an optional 1-click inline `sharp` **Crop & Rotate Studio** (`Free`, `1:1`, `16:9`, `4:3`, `3:2`, `4:5`, `-90°/+90°`, `Duplicate & Crop` or `Crop Original Asset`).
131
+ - **Default `ci-optimized/` CDN Subfolder & Transparent-Safe WebP Conversion:**
132
+ - All `sharp`-generated variants are uploaded to Strapi's active Upload Provider (Azure Blob Storage, AWS S3, Cloudflare R2, GCS, Cloudinary) inside the **`ci-optimized`** folder **by default** (`https://<your-cdn>/.../ci-optimized/ci_fit_500x500_<hash>.webp`) — even when `CI_IMAGE_VARIANT_FOLDER` is **not** set in `.env` (override via `CI_IMAGE_VARIANT_FOLDER` or set `'/'` to write at the bucket root).
133
+ - Raster images (`JPEG`, `PNG`, `WebP`, `AVIF`, `TIFF`, `BMP`) are converted to **`WebP`** using `sharp.webp({ quality: 85, alphaQuality: 100, effort: 4 })`, preserving **full 8-bit alpha transparency** for transparent PNG logos and floating layers.
134
+ - **`SVG`**, animated **`GIF`**, video (`mp4`, `webm`), audio, and documents (`PDF`, `DOCX`, `XLSX`, `ZIP`) automatically bypass `sharp` untouched.
135
+ - **JSONB `formats` Persistence on Selection + Save/Publish (Zero Storefront Proxy Calls):**
136
+ - Eagerly on Media Library selection (`POST /content-input/media/optimize`) **and** automatically during Strapi `beforeCreate` / `beforeUpdate` lifecycle hooks on **Save / Publish**, ContentInput generates missing `ci_fit_WxH`, `ci_widen_Wx0`, and `ci_auto_Wx0` variants across **all visual media slots** (`gallery`, `singleImage`, `banner`, `youtubeVideo`, Row/Block `bgImage`, `heroSlider`, `customCard`, `entityCard`, `survey`, `dataTable`, and `HtmlEditor` `<img>`), persists them in `plugin::upload.file.formats`, and embeds `optimized_url`, `original_url`, and `formats` directly inside the `ContentInput` JSONB snapshot.
137
+ - Storefront Nuxt renderers read `asset.formats['ci_fit_WxH'].url` / `asset.optimized_url` directly so `<img src>` and CSS `background-image` point straight to your **CDN URL** with **zero** calls to `/api/content-input/image`!
138
+ - Gallery Lightbox Popups use crisp `ci_auto_1920x0` WebP (while `process: 'none'` serves `original_url` untouched).
139
+ - **302 CDN Redirect on `GET /api/content-input/image`:**
140
+ - For legacy un-resaved entries or headless on-the-fly usage, `GET /api/content-input/image` generates/reuses the CDN variant and responds with an **HTTP `302` redirect** to the permanent `https://` CDN URL (or returns `{ url, formatKey }` JSON when `?json=1` or `Accept: application/json` is passed; falls back to immutable byte-stream in local `/uploads/...` setups).
127
141
  - **Official Swiper.js Engine + Native Framework Navigation Buttons (`CISwiperNavButtons`):**
128
142
  - Supports touch/mouse drag-to-swipe (`grabCursor`), mousewheel scrolling (`mousewheel`), transition effects (`slide`, `fade`, `cube`, `coverflow`, `flip`), `slidesPerView`, `spaceBetween`, `loop`, `autoplay`, and `pagination`.
129
143
  - Replaces Swiper's oversized raw `.swiper-button-prev`/`.swiper-button-next` chevrons across `heroSlider`, `gallery`, `entityCard`, and `customCard` with genuine Vuetify `<v-btn>` and Element Plus `<el-button>` components supporting selectable **`navButtonStyle`** (`'fab' | 'outlined' | 'tonal' | 'icon' | 'square'`), **`navButtonSize`** (`'sm' | 'md' | 'lg'`), and Color Codes / `#HEX` / `RGBA` **`navButtonColor`**.
@@ -433,13 +447,25 @@ npm install git+ssh://git@gitlab.com:ozguraltan/strapi-content-input.git
433
447
  ### Adım 2: `config/plugins.ts` ve `config/features.ts` İçinde Etkinleştirin
434
448
  ```ts
435
449
  // config/plugins.ts
436
- export default () => ({
450
+ export default ({ env }) => ({
437
451
  'content-input': {
438
452
  enabled: true,
453
+ config: {
454
+ // Opsiyonel — .env içinde tanımlanmasa bile varsayılan değerler otomatik çalışır:
455
+ imageVariantFolder: env('CI_IMAGE_VARIANT_FOLDER', 'ci-optimized'), // CDN alt klasörü (varsayılan: ci-optimized)
456
+ imageVariantFormat: env('CI_IMAGE_VARIANT_FORMAT', 'webp'), // Transparan PNG destekli WebP
457
+ imageVariantQuality: env.int('CI_IMAGE_VARIANT_QUALITY', 85),
458
+ redirectProxyToCdn: env.bool('CI_IMAGE_REDIRECT_CDN', true), // /api/content-input/image -> 302 CDN yönlendirmesi
459
+ },
439
460
  },
440
461
  });
441
462
  ```
442
463
 
464
+ > **Evrensel `sharp` WebP + `ci-optimized` CDN Varyant Mimarisi:**
465
+ > - `.env` dosyasında `CI_IMAGE_VARIANT_FOLDER` tanımlı **olmasa bile** `sharp` ile üretilen tüm görsel varyantları aktif Upload Provider / CDN üzerinde otomatik olarak **`ci-optimized/`** klasörü altına (`https://<cdn-adresiniz>/.../ci-optimized/ci_*_<hash>.webp`) yüklenir.
466
+ > - **`SVG`** ve animasyonlu **`GIF`** (ayrıca video ve PDF/ofis dokümanları) hariç tüm raster görseller (`JPEG`, `PNG`, `WebP`, `AVIF`, `TIFF`, `BMP`), transparan PNG alfa kanalını tam koruyan (`alphaQuality: 100`) **`WebP`** formatına dönüştürülür.
467
+ > - Yalnızca Galeri değil; **`singleImage`**, **`banner`**, **`youtubeVideo` kapak görseli**, **Satır/Sütun `bgImage`**, **`heroSlider` (`bgImage`, `mobileBgImage`, `floating_image`)**, **`customCard` (`image` & `authorAvatar`)**, **`entityCard`**, **`survey` (`image_choice`)**, **`dataTable` (`image` hücreleri)** ve **`HtmlEditor` (`<img>`)** dahil görsel seçilen tüm alanlar hem seçim anında hem de **Save / Publish** sırasında otomatik optimize edilerek `optimized_url` ve `formats` (`ci_fit_*`, `ci_widen_*`, `ci_auto_*`) bilgisini doğrudan `ContentInput` JSONB içine yazar. Böylece Nuxt vitrin (storefront) uygulamaları `localhost:1337/api/content-input/image` proxy adresine gitmeden **doğrudan CDN URL'lerini** render eder; eski içerikler için `/api/content-input/image` uç noktası da CDN adresine **HTTP `302` Redirect** uygular (`?json=1` ile JSON döner, lokal ortamda byte-stream fallback korunur).
468
+
443
469
  **Strapi v5.61+** sürümlerinde tüm ContentInput bileşenlerinde ve tam ekran stüdyolarda Strapi'nin kendi tam özellikli **Medya Kütüphanesi Modalının** (küçük resimler/thumbnails, sayfalama, klasör yönetimi, çoklu yükleme ve dahili kırpma/crop aracı ile) açılması için `config/features.ts` dosyasına `useLegacyMediaLibrary: true` ekleyin:
444
470
  ```ts
445
471
  // config/features.ts
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const admin = require("@strapi/strapi/admin");
6
- const index = require("./index-CZAwXCFH.js");
7
- const SurveyWidgetEditor = require("./SurveyWidgetEditor-BmgYQaQS.js");
6
+ const index = require("./index-i0NfSYto.js");
7
+ const SurveyWidgetEditor = require("./SurveyWidgetEditor-C5Uvyf_h.js");
8
8
  const AnalyticsHubPage = () => {
9
9
  const { get, post } = admin.useFetchClient();
10
10
  const { locales: strapiLocales } = SurveyWidgetEditor.useStrapiLocales();
@@ -1,8 +1,8 @@
1
1
  import { jsxs, jsx } from "react/jsx-runtime";
2
2
  import { useState, useCallback, useEffect } from "react";
3
3
  import { useFetchClient } from "@strapi/strapi/admin";
4
- import { M as MaterialIcon } from "./index-hFIuYqu5.mjs";
5
- import { h as useStrapiLocales, B as getInitialLocale, F as createBlankSurveyDraft, G as ColorCodesManager, H as pickTextForLocale, I as SurveyAnalyticsView, J as SurveyStudioModal, K as persistLocale } from "./SurveyWidgetEditor-BVN6X_3G.mjs";
4
+ import { M as MaterialIcon } from "./index-Dc7AFLOj.mjs";
5
+ import { h as useStrapiLocales, B as getInitialLocale, F as createBlankSurveyDraft, G as ColorCodesManager, H as pickTextForLocale, I as SurveyAnalyticsView, J as SurveyStudioModal, K as persistLocale } from "./SurveyWidgetEditor-DGSwgTzR.mjs";
6
6
  const AnalyticsHubPage = () => {
7
7
  const { get, post } = useFetchClient();
8
8
  const { locales: strapiLocales } = useStrapiLocales();