@haklex/rich-ext-gallery 0.42.1 → 0.43.1
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GalleryEditRenderer.d.ts","sourceRoot":"","sources":["../src/GalleryEditRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GalleryEditRenderer.d.ts","sourceRoot":"","sources":["../src/GalleryEditRenderer.tsx"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAA8C,EAAE,EAAE,MAAM,OAAO,CAAC;AAQ5E,OAAO,KAAK,EAA2C,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAwe7F,eAAO,MAAM,mBAAmB,EAAE,EAAE,CAAC,oBAAoB,CA0GxD,CAAC"}
|
|
@@ -6,7 +6,7 @@ import { createElement, useCallback, useRef, useState } from "react";
|
|
|
6
6
|
import { DndContext, DragOverlay, PointerSensor, closestCenter, useSensor, useSensors } from "@dnd-kit/core";
|
|
7
7
|
import { SortableContext, arrayMove, useSortable, verticalListSortingStrategy } from "@dnd-kit/sortable";
|
|
8
8
|
import { CSS } from "@dnd-kit/utilities";
|
|
9
|
-
import { useImageUpload } from "@haklex/rich-editor/plugins";
|
|
9
|
+
import { resolvePreprocessTargets, useImagePreprocess, useImageUpload } from "@haklex/rich-editor/plugins";
|
|
10
10
|
import { useColorScheme } from "@haklex/rich-editor/static";
|
|
11
11
|
import { SegmentedControl, presentDialog } from "@haklex/rich-editor-ui";
|
|
12
12
|
import { usePortalTheme, vars } from "@haklex/rich-style-token";
|
|
@@ -266,7 +266,7 @@ var DragOverlayCard = ({ image }) => /* @__PURE__ */ jsxs("div", {
|
|
|
266
266
|
})
|
|
267
267
|
]
|
|
268
268
|
});
|
|
269
|
-
var GalleryEditorDialogContent = ({ dismiss, initialAspect, initialFit, initialImages, initialLayout, initialMaxItemHeight, uploader, onAspectChange, onFitChange, onImagesChange, onLayoutChange, onMaxItemHeightChange }) => {
|
|
269
|
+
var GalleryEditorDialogContent = ({ dismiss, initialAspect, initialFit, initialImages, initialLayout, initialMaxItemHeight, preprocess, uploader, onAspectChange, onFitChange, onImagesChange, onLayoutChange, onMaxItemHeightChange }) => {
|
|
270
270
|
const { className: portalClassName } = usePortalTheme();
|
|
271
271
|
const [entries, setEntries] = useState(() => initialImages.map((img) => ({
|
|
272
272
|
id: genId(),
|
|
@@ -297,7 +297,8 @@ var GalleryEditorDialogContent = ({ dismiss, initialAspect, initialFit, initialI
|
|
|
297
297
|
const handleRemoveImage = useCallback((index) => {
|
|
298
298
|
setEntries((prev) => prev.filter((_, i) => i !== index));
|
|
299
299
|
}, []);
|
|
300
|
-
const appendFiles = useCallback(async (
|
|
300
|
+
const appendFiles = useCallback(async (picked) => {
|
|
301
|
+
const files = await resolvePreprocessTargets(picked, "gallery", preprocess?.ref.current ?? null);
|
|
301
302
|
if (!files.length) return;
|
|
302
303
|
const fresh = (await Promise.all(files.map(async (file) => {
|
|
303
304
|
try {
|
|
@@ -310,8 +311,10 @@ var GalleryEditorDialogContent = ({ dismiss, initialAspect, initialFit, initialI
|
|
|
310
311
|
image
|
|
311
312
|
}));
|
|
312
313
|
if (fresh.length) setEntries((prev) => [...prev, ...fresh]);
|
|
313
|
-
}, [uploader]);
|
|
314
|
-
const replaceEntryFile = useCallback(async (index,
|
|
314
|
+
}, [preprocess, uploader]);
|
|
315
|
+
const replaceEntryFile = useCallback(async (index, picked) => {
|
|
316
|
+
const [file] = await resolvePreprocessTargets([picked], "gallery", preprocess?.ref.current ?? null);
|
|
317
|
+
if (!file) return;
|
|
315
318
|
try {
|
|
316
319
|
const next = await fileToGalleryImage(file, uploader);
|
|
317
320
|
setEntries((prev) => prev.map((entry, i) => i === index ? {
|
|
@@ -322,7 +325,7 @@ var GalleryEditorDialogContent = ({ dismiss, initialAspect, initialFit, initialI
|
|
|
322
325
|
}
|
|
323
326
|
} : entry));
|
|
324
327
|
} catch {}
|
|
325
|
-
}, [uploader]);
|
|
328
|
+
}, [preprocess, uploader]);
|
|
326
329
|
const handleUpdateImage = useCallback((index, field, value) => {
|
|
327
330
|
setEntries((prev) => prev.map((entry, i) => i === index ? {
|
|
328
331
|
...entry,
|
|
@@ -508,6 +511,7 @@ var GalleryEditRenderer = ({ aspect, fit, images, layout, maxItemHeight, onAspec
|
|
|
508
511
|
const { className: portalClassName } = usePortalTheme();
|
|
509
512
|
const theme = useColorScheme();
|
|
510
513
|
const uploader = useImageUpload();
|
|
514
|
+
const preprocess = useImagePreprocess();
|
|
511
515
|
const handleOpenEditor = useCallback(() => {
|
|
512
516
|
if (!onImagesChange || !onLayoutChange) return;
|
|
513
517
|
presentDialog({
|
|
@@ -518,6 +522,7 @@ var GalleryEditRenderer = ({ aspect, fit, images, layout, maxItemHeight, onAspec
|
|
|
518
522
|
initialImages: images,
|
|
519
523
|
initialLayout: layout,
|
|
520
524
|
initialMaxItemHeight: maxItemHeight,
|
|
525
|
+
preprocess,
|
|
521
526
|
uploader,
|
|
522
527
|
onAspectChange,
|
|
523
528
|
onFitChange,
|
|
@@ -543,6 +548,7 @@ var GalleryEditRenderer = ({ aspect, fit, images, layout, maxItemHeight, onAspec
|
|
|
543
548
|
onLayoutChange,
|
|
544
549
|
onMaxItemHeightChange,
|
|
545
550
|
portalClassName,
|
|
551
|
+
preprocess,
|
|
546
552
|
theme,
|
|
547
553
|
uploader
|
|
548
554
|
]);
|
package/dist/edit.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as __augmentLoaded_gallery } from "./augment-DgwFVGf9.js";
|
|
2
|
-
import { a as GalleryEditRenderer, i as GalleryEditNode, n as $createGalleryEditNode, r as $isGalleryEditNode, t as galleryEditNodes } from "./edit-
|
|
2
|
+
import { a as GalleryEditRenderer, i as GalleryEditNode, n as $createGalleryEditNode, r as $isGalleryEditNode, t as galleryEditNodes } from "./edit-C3Xs9tB8.js";
|
|
3
3
|
export { $createGalleryEditNode, $isGalleryEditNode, GalleryEditNode, GalleryEditRenderer, __augmentLoaded_gallery, galleryEditNodes };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as __augmentLoaded_gallery } from "./augment-DgwFVGf9.js";
|
|
2
2
|
import { t as GalleryRenderer } from "./GalleryRenderer-CHoZMZOz.js";
|
|
3
|
-
import { a as GalleryEditRenderer, i as GalleryEditNode, n as $createGalleryEditNode, r as $isGalleryEditNode, t as galleryEditNodes } from "./edit-
|
|
3
|
+
import { a as GalleryEditRenderer, i as GalleryEditNode, n as $createGalleryEditNode, r as $isGalleryEditNode, t as galleryEditNodes } from "./edit-C3Xs9tB8.js";
|
|
4
4
|
import { a as GALLERY_NODE_KEY, n as $isGalleryNode, r as GalleryNode, t as $createGalleryNode } from "./GalleryNode-i9tdfoY8.js";
|
|
5
5
|
import { galleryNodes } from "./node.mjs";
|
|
6
6
|
import "./renderer.mjs";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-ext-gallery",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.43.1",
|
|
4
4
|
"description": "Image gallery extension with drag-and-drop",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"lucide-react": "^1.0.0",
|
|
61
61
|
"react": ">=19",
|
|
62
62
|
"react-dom": ">=19",
|
|
63
|
-
"@haklex/rich-editor
|
|
64
|
-
"@haklex/rich-editor": "^0.
|
|
65
|
-
"@haklex/rich-style-token": "^0.
|
|
63
|
+
"@haklex/rich-editor": "^0.43.1",
|
|
64
|
+
"@haklex/rich-editor-ui": "^0.43.1",
|
|
65
|
+
"@haklex/rich-style-token": "^0.43.1"
|
|
66
66
|
},
|
|
67
67
|
"publishConfig": {
|
|
68
68
|
"access": "public"
|