@haklex/rich-ext-gallery 0.13.0 → 0.14.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/dist/{GalleryRenderer-C8Tw6IkA.js → GalleryRenderer-qIFakkWM.js} +52 -27
- package/dist/GalleryRenderer.d.ts.map +1 -1
- package/dist/{edit-BdSbkxR4.js → edit-BCgxzZ0R.js} +1 -1
- package/dist/edit.mjs +1 -1
- package/dist/index.mjs +2 -2
- package/dist/renderer.mjs +1 -1
- package/dist/static.mjs +1 -1
- package/dist/types.d.ts +8 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -6
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
2
2
|
import { memo, useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
3
3
|
import { decodeThumbHash } from "@haklex/rich-editor/renderers";
|
|
4
|
-
import "react-photo-view/dist/react-photo-view.css";
|
|
5
4
|
import { useInView } from "react-intersection-observer";
|
|
6
|
-
import { PhotoProvider, PhotoView } from "react-photo-view";
|
|
7
5
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
8
6
|
//#region src/styles.css.ts
|
|
9
7
|
var gallery = "_10ydd1n0";
|
|
@@ -68,7 +66,7 @@ function useThumbhashStyle(image) {
|
|
|
68
66
|
};
|
|
69
67
|
}, [image.thumbhash]);
|
|
70
68
|
}
|
|
71
|
-
var GalleryRenderer = ({ images, layout }) => {
|
|
69
|
+
var GalleryRenderer = ({ images, layout, onImageClick }) => {
|
|
72
70
|
const [containerRef, setContainerRef] = useState(null);
|
|
73
71
|
const [, setUpdated] = useState({});
|
|
74
72
|
const memoedChildContainerWidthRef = useRef(0);
|
|
@@ -130,11 +128,16 @@ var GalleryRenderer = ({ images, layout }) => {
|
|
|
130
128
|
}, []);
|
|
131
129
|
if (images.length === 0) return null;
|
|
132
130
|
const layoutClass = layout === "masonry" ? galleryMasonry : layout === "carousel" ? galleryCarousel : galleryGrid;
|
|
133
|
-
if (images.length === 1 || layout === "grid" || layout === "masonry") return /* @__PURE__ */ jsx(
|
|
131
|
+
if (images.length === 1 || layout === "grid" || layout === "masonry") return /* @__PURE__ */ jsx("div", {
|
|
134
132
|
className: clsx(gallery, layoutClass),
|
|
135
|
-
children: images.map((image, index) => /* @__PURE__ */ jsx(GalleryFigure, {
|
|
136
|
-
|
|
137
|
-
|
|
133
|
+
children: images.map((image, index) => /* @__PURE__ */ jsx(GalleryFigure, {
|
|
134
|
+
image,
|
|
135
|
+
images,
|
|
136
|
+
index,
|
|
137
|
+
onImageClick
|
|
138
|
+
}, index))
|
|
139
|
+
});
|
|
140
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
138
141
|
className: clsx(gallery, galleryCarousel),
|
|
139
142
|
ref,
|
|
140
143
|
onTouchMove: handleCancelAutoplay,
|
|
@@ -147,10 +150,13 @@ var GalleryRenderer = ({ images, layout }) => {
|
|
|
147
150
|
onTouchStart: handleCancelAutoplay,
|
|
148
151
|
children: images.map((image, index) => /* @__PURE__ */ jsx(GalleryFigure, {
|
|
149
152
|
image,
|
|
153
|
+
images,
|
|
154
|
+
index,
|
|
150
155
|
style: {
|
|
151
156
|
width: `calc(100% - ${IMAGE_CONTAINER_MARGIN_INSET}px)`,
|
|
152
157
|
marginRight: `${CHILD_GAP}px`
|
|
153
|
-
}
|
|
158
|
+
},
|
|
159
|
+
onImageClick
|
|
154
160
|
}, index))
|
|
155
161
|
}),
|
|
156
162
|
currentIndex > 0 && /* @__PURE__ */ jsx("button", {
|
|
@@ -171,29 +177,48 @@ var GalleryRenderer = ({ images, layout }) => {
|
|
|
171
177
|
}, i))
|
|
172
178
|
})
|
|
173
179
|
]
|
|
174
|
-
})
|
|
180
|
+
});
|
|
175
181
|
};
|
|
176
|
-
var GalleryFigure = memo(({ image, style }) => {
|
|
182
|
+
var GalleryFigure = memo(({ image, images, index, onImageClick, style }) => {
|
|
177
183
|
const thumbStyle = useThumbhashStyle(image);
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
184
|
+
const imgRef = useRef(null);
|
|
185
|
+
const interactive = Boolean(onImageClick);
|
|
186
|
+
const activate = () => {
|
|
187
|
+
if (imgRef.current) onImageClick?.({
|
|
188
|
+
current: image,
|
|
189
|
+
images,
|
|
190
|
+
index,
|
|
191
|
+
target: imgRef.current
|
|
192
|
+
});
|
|
193
|
+
};
|
|
194
|
+
const handleKeyDown = (e) => {
|
|
195
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
196
|
+
e.preventDefault();
|
|
197
|
+
activate();
|
|
198
|
+
};
|
|
199
|
+
return /* @__PURE__ */ jsx("figure", {
|
|
200
|
+
"aria-label": interactive ? `Open image: ${image.alt || "image"}` : void 0,
|
|
201
|
+
className: galleryItem,
|
|
202
|
+
role: interactive ? "button" : void 0,
|
|
203
|
+
style: {
|
|
204
|
+
...thumbStyle,
|
|
205
|
+
...style,
|
|
206
|
+
...interactive ? null : { cursor: "default" }
|
|
207
|
+
},
|
|
208
|
+
tabIndex: interactive ? 0 : void 0,
|
|
209
|
+
onClick: interactive ? activate : void 0,
|
|
210
|
+
onKeyDown: interactive ? handleKeyDown : void 0,
|
|
211
|
+
children: /* @__PURE__ */ jsx("img", {
|
|
212
|
+
alt: image.alt || "",
|
|
213
|
+
height: image.height,
|
|
214
|
+
loading: "lazy",
|
|
215
|
+
ref: imgRef,
|
|
216
|
+
src: image.src,
|
|
182
217
|
style: {
|
|
183
|
-
|
|
184
|
-
|
|
218
|
+
maxWidth: "100%",
|
|
219
|
+
height: "auto"
|
|
185
220
|
},
|
|
186
|
-
|
|
187
|
-
alt: image.alt || "",
|
|
188
|
-
height: image.height,
|
|
189
|
-
loading: "lazy",
|
|
190
|
-
src: image.src,
|
|
191
|
-
style: {
|
|
192
|
-
maxWidth: "100%",
|
|
193
|
-
height: "auto"
|
|
194
|
-
},
|
|
195
|
-
width: image.width
|
|
196
|
-
})
|
|
221
|
+
width: image.width
|
|
197
222
|
})
|
|
198
223
|
});
|
|
199
224
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GalleryRenderer.d.ts","sourceRoot":"","sources":["../src/GalleryRenderer.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"GalleryRenderer.d.ts","sourceRoot":"","sources":["../src/GalleryRenderer.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,OAAO,CAAC;AAK3D,OAAO,KAAK,EAAqC,oBAAoB,EAAE,MAAM,SAAS,CAAC;AA+BvF,eAAO,MAAM,eAAe,EAAE,aAAa,CAAC,oBAAoB,CA6L/D,CAAC;;AAkDF,wBAAqC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as galleryImageDragHandle, D as galleryImageThumb, E as galleryImageList, O as galleryImageThumbPlaceholder, S as galleryImageDeleteBtn, T as galleryImageInput, _ as galleryFooterInfo, a as galleryDialogEmpty, b as galleryImageActions, c as galleryDialogPopup, d as galleryEditLabel, f as galleryEditOverlay, g as galleryFooterBtnSave, h as galleryFooterBtnCancel, i as galleryDialogBody, l as galleryDialogTitle, m as galleryFooterActions, o as galleryDialogFooter, p as galleryEmptyState, r as galleryAddBtn, s as galleryDialogHeader, t as GalleryRenderer, u as galleryEditContainer, v as galleryHeaderActions, w as galleryImageFields, x as galleryImageCard, y as galleryHeaderClose } from "./GalleryRenderer-
|
|
1
|
+
import { C as galleryImageDragHandle, D as galleryImageThumb, E as galleryImageList, O as galleryImageThumbPlaceholder, S as galleryImageDeleteBtn, T as galleryImageInput, _ as galleryFooterInfo, a as galleryDialogEmpty, b as galleryImageActions, c as galleryDialogPopup, d as galleryEditLabel, f as galleryEditOverlay, g as galleryFooterBtnSave, h as galleryFooterBtnCancel, i as galleryDialogBody, l as galleryDialogTitle, m as galleryFooterActions, o as galleryDialogFooter, p as galleryEmptyState, r as galleryAddBtn, s as galleryDialogHeader, t as GalleryRenderer, u as galleryEditContainer, v as galleryHeaderActions, w as galleryImageFields, x as galleryImageCard, y as galleryHeaderClose } from "./GalleryRenderer-qIFakkWM.js";
|
|
2
2
|
import { i as _defineProperty, r as GalleryNode } from "./GalleryNode-Ne_f5BJ3.js";
|
|
3
3
|
import { $getNodeByKey, $insertNodes } from "lexical";
|
|
4
4
|
import { GripVertical, ImageIcon, Images, Pencil, Plus, Trash2, X } from "lucide-react";
|
package/dist/edit.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as __augmentLoaded_gallery } from "./augment-BXUga8d3.js";
|
|
2
|
-
import { a as GalleryEditNode, i as $isGalleryEditNode, n as GalleryEditRenderer, r as $createGalleryEditNode, t as galleryEditNodes } from "./edit-
|
|
2
|
+
import { a as GalleryEditNode, i as $isGalleryEditNode, n as GalleryEditRenderer, r as $createGalleryEditNode, t as galleryEditNodes } from "./edit-BCgxzZ0R.js";
|
|
3
3
|
export { $createGalleryEditNode, $isGalleryEditNode, GalleryEditNode, GalleryEditRenderer, __augmentLoaded_gallery, galleryEditNodes };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as __augmentLoaded_gallery } from "./augment-BXUga8d3.js";
|
|
2
|
-
import { t as GalleryRenderer } from "./GalleryRenderer-
|
|
2
|
+
import { t as GalleryRenderer } from "./GalleryRenderer-qIFakkWM.js";
|
|
3
3
|
import { a as GALLERY_NODE_KEY, n as $isGalleryNode, r as GalleryNode, t as $createGalleryNode } from "./GalleryNode-Ne_f5BJ3.js";
|
|
4
|
-
import { a as GalleryEditNode, i as $isGalleryEditNode, n as GalleryEditRenderer, r as $createGalleryEditNode, t as galleryEditNodes } from "./edit-
|
|
4
|
+
import { a as GalleryEditNode, i as $isGalleryEditNode, n as GalleryEditRenderer, r as $createGalleryEditNode, t as galleryEditNodes } from "./edit-BCgxzZ0R.js";
|
|
5
5
|
import { galleryNodes } from "./node.mjs";
|
|
6
6
|
import "./renderer.mjs";
|
|
7
7
|
export { $createGalleryEditNode, $createGalleryNode, $isGalleryEditNode, $isGalleryNode, GALLERY_NODE_KEY, GalleryEditNode, GalleryEditRenderer, GalleryNode, GalleryRenderer, __augmentLoaded_gallery, galleryEditNodes, galleryNodes };
|
package/dist/renderer.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { t as __augmentLoaded_gallery } from "./augment-BXUga8d3.js";
|
|
2
|
-
import { n as GalleryRenderer_default, t as GalleryRenderer } from "./GalleryRenderer-
|
|
2
|
+
import { n as GalleryRenderer_default, t as GalleryRenderer } from "./GalleryRenderer-qIFakkWM.js";
|
|
3
3
|
export { GalleryRenderer, __augmentLoaded_gallery, GalleryRenderer_default as default };
|
package/dist/static.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __augmentLoaded_gallery } from "./augment-BXUga8d3.js";
|
|
2
|
-
import { n as GalleryRenderer_default, t as GalleryRenderer } from "./GalleryRenderer-
|
|
2
|
+
import { n as GalleryRenderer_default, t as GalleryRenderer } from "./GalleryRenderer-qIFakkWM.js";
|
|
3
3
|
import { a as GALLERY_NODE_KEY, n as $isGalleryNode, r as GalleryNode, t as $createGalleryNode } from "./GalleryNode-Ne_f5BJ3.js";
|
|
4
4
|
import { galleryNodes } from "./node.mjs";
|
|
5
5
|
import "./renderer.mjs";
|
package/dist/types.d.ts
CHANGED
|
@@ -5,9 +5,17 @@ export interface GalleryImage {
|
|
|
5
5
|
thumbhash?: string;
|
|
6
6
|
width?: number;
|
|
7
7
|
}
|
|
8
|
+
export interface GalleryImageClickPayload {
|
|
9
|
+
current: GalleryImage;
|
|
10
|
+
images: GalleryImage[];
|
|
11
|
+
index: number;
|
|
12
|
+
target: HTMLElement;
|
|
13
|
+
}
|
|
14
|
+
export type GalleryOnImageClick = (payload: GalleryImageClickPayload) => void;
|
|
8
15
|
export interface GalleryRendererProps {
|
|
9
16
|
images: GalleryImage[];
|
|
10
17
|
layout: 'grid' | 'masonry' | 'carousel';
|
|
18
|
+
onImageClick?: GalleryOnImageClick;
|
|
11
19
|
onImagesChange?: (images: GalleryImage[]) => void;
|
|
12
20
|
onLayoutChange?: (layout: 'grid' | 'masonry' | 'carousel') => void;
|
|
13
21
|
}
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;IACxC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IAClD,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,KAAK,IAAI,CAAC;CACpE"}
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,YAAY;IAC3B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,YAAY,CAAC;IACtB,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,WAAW,CAAC;CACrB;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,EAAE,wBAAwB,KAAK,IAAI,CAAC;AAE9E,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;IACxC,YAAY,CAAC,EAAE,mBAAmB,CAAC;IACnC,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,KAAK,IAAI,CAAC;IAClD,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,KAAK,IAAI,CAAC;CACpE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haklex/rich-ext-gallery",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
4
4
|
"description": "Image gallery extension with drag-and-drop",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -40,8 +40,7 @@
|
|
|
40
40
|
"@dnd-kit/core": "^6.3.1",
|
|
41
41
|
"@dnd-kit/sortable": "^10.0.0",
|
|
42
42
|
"@dnd-kit/utilities": "^3.2.2",
|
|
43
|
-
"react-intersection-observer": "^10.0.3"
|
|
44
|
-
"react-photo-view": "^1.2.7"
|
|
43
|
+
"react-intersection-observer": "^10.0.3"
|
|
45
44
|
},
|
|
46
45
|
"devDependencies": {
|
|
47
46
|
"@types/react": "^19.2.14",
|
|
@@ -61,9 +60,9 @@
|
|
|
61
60
|
"lucide-react": "^1.0.0",
|
|
62
61
|
"react": ">=19",
|
|
63
62
|
"react-dom": ">=19",
|
|
64
|
-
"@haklex/rich-editor": "0.
|
|
65
|
-
"@haklex/rich-
|
|
66
|
-
"@haklex/rich-
|
|
63
|
+
"@haklex/rich-editor-ui": "0.14.0",
|
|
64
|
+
"@haklex/rich-editor": "0.14.0",
|
|
65
|
+
"@haklex/rich-style-token": "0.14.0"
|
|
67
66
|
},
|
|
68
67
|
"publishConfig": {
|
|
69
68
|
"access": "public"
|