@haklex/rich-renderer-image 0.42.0 → 0.43.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/index.mjs CHANGED
@@ -9,7 +9,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
9
  import { ActionBar, ActionButton, Popover, PopoverPanel, PopoverTrigger, SegmentedControl } from "@haklex/rich-editor-ui";
10
10
  import { $getNearestNodeFromDOMNode, $getNodeByKey, COMMAND_PRIORITY_HIGH, DRAGOVER_COMMAND, DRAGSTART_COMMAND, DROP_COMMAND, REDO_COMMAND, UNDO_COMMAND } from "lexical";
11
11
  import { AlignCenterVertical, AlignEndVertical, AlignStartVertical, ArrowLeftToLine, ArrowRightToLine, Captions, CopyPlus, Download, ExternalLink, ImageIcon, Loader2, Replace, Scaling, Trash2, Type, Upload } from "lucide-react";
12
- import { useImageUpload } from "@haklex/rich-editor/plugins";
12
+ import { resolvePreprocessTargets, useImagePreprocess, useImageUpload } from "@haklex/rich-editor/plugins";
13
13
  //#region src/atoms.ts
14
14
  function getCaptionText(altText, caption) {
15
15
  if (caption) return caption;
@@ -174,6 +174,7 @@ function useImageActions() {
174
174
  const store = useStore();
175
175
  const [editor] = useLexicalComposerContext();
176
176
  const uploadImage = useImageUpload();
177
+ const preprocess = useImagePreprocess();
177
178
  const withImageNode = useCallback((updater) => {
178
179
  const wrapperRef = store.get(wrapperRefAtom);
179
180
  if (!wrapperRef.current) return;
@@ -258,8 +259,10 @@ function useImageActions() {
258
259
  return {
259
260
  commitMeta,
260
261
  closeReplacePanel,
261
- handleReplaceFile: useCallback(async (file) => {
262
- if (!file || !file.type.startsWith("image/")) return;
262
+ handleReplaceFile: useCallback(async (picked) => {
263
+ if (!picked || !picked.type.startsWith("image/")) return;
264
+ const [file] = await resolvePreprocessTargets([picked], "replace", preprocess?.ref.current ?? null);
265
+ if (!file) return;
263
266
  store.set(replaceLoadingAtom, true);
264
267
  store.set(replaceErrorAtom, null);
265
268
  try {
@@ -283,6 +286,7 @@ function useImageActions() {
283
286
  }
284
287
  }, [
285
288
  closeReplacePanel,
289
+ preprocess,
286
290
  store,
287
291
  uploadImage,
288
292
  withImageNode
@@ -2,7 +2,7 @@ import { ImageDisplaySize, ImageLayout } from '@haklex/rich-editor/nodes';
2
2
  export declare function useImageActions(): {
3
3
  commitMeta: () => void;
4
4
  closeReplacePanel: () => void;
5
- handleReplaceFile: (file: File | null) => Promise<void>;
5
+ handleReplaceFile: (picked: File | null) => Promise<void>;
6
6
  handlePreviewUrl: () => Promise<void>;
7
7
  handleReplaceByUrl: () => void;
8
8
  handleReplaceOpenChange: (nextOpen: boolean) => void;
@@ -1 +1 @@
1
- {"version":3,"file":"useImageActions.d.ts","sourceRoot":"","sources":["../src/useImageActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAqD/E,wBAAgB,eAAe;;;8BA0Gd,IAAI,GAAG,IAAI;;;wCA6Db,OAAO;;;;;iCA/EX,gBAAgB;+BASb,WAAW;EA2FxB"}
1
+ {"version":3,"file":"useImageActions.d.ts","sourceRoot":"","sources":["../src/useImageActions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AA0D/E,wBAAgB,eAAe;;;gCA2GZ,IAAI,GAAG,IAAI;;;wCAmEf,OAAO;;;;;iCArFX,gBAAgB;+BASb,WAAW;EAiGxB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@haklex/rich-renderer-image",
3
- "version": "0.42.0",
3
+ "version": "0.43.0",
4
4
  "description": "Image renderer with blurhash",
5
5
  "repository": {
6
6
  "type": "git",
@@ -45,9 +45,9 @@
45
45
  "lucide-react": "^1.0.0",
46
46
  "react": ">=19",
47
47
  "react-dom": ">=19",
48
- "@haklex/rich-editor": "^0.42.0",
49
- "@haklex/rich-editor-ui": "^0.42.0",
50
- "@haklex/rich-style-token": "^0.42.0"
48
+ "@haklex/rich-editor": "^0.43.0",
49
+ "@haklex/rich-editor-ui": "^0.43.0",
50
+ "@haklex/rich-style-token": "^0.43.0"
51
51
  },
52
52
  "publishConfig": {
53
53
  "access": "public"