neuphlo-editor 1.8.2 → 1.8.3

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.
@@ -31,7 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  // src/react/index.ts
32
32
  var react_exports = {};
33
33
  __export(react_exports, {
34
- Editor: () => Editor3,
34
+ Editor: () => Editor5,
35
35
  TextMenu: () => TextMenu
36
36
  });
37
37
  module.exports = __toCommonJS(react_exports);
@@ -1167,6 +1167,7 @@ var ExtensionKit = (options) => {
1167
1167
  var extension_kit_default = ExtensionKit;
1168
1168
 
1169
1169
  // src/react/menus/TextMenu.tsx
1170
+ var import_state3 = require("@tiptap/pm/state");
1170
1171
  var import_react14 = require("@tiptap/react");
1171
1172
  var import_menus = require("@tiptap/react/menus");
1172
1173
  var import_icons_react2 = require("@tabler/icons-react");
@@ -1494,7 +1495,7 @@ function TextMenu({
1494
1495
  if (e.isActive("imageBlock")) return false;
1495
1496
  if (e.isActive("videoBlock")) return false;
1496
1497
  const { selection } = state;
1497
- if (selection.constructor.name === "NodeSelection") return false;
1498
+ if (selection instanceof import_state3.NodeSelection) return false;
1498
1499
  if (from === to) return false;
1499
1500
  if (e.isActive("link")) return false;
1500
1501
  let hasImage = false;
@@ -2108,6 +2109,7 @@ function LinkMenu() {
2108
2109
  }
2109
2110
 
2110
2111
  // src/react/menus/ImageMenu.tsx
2112
+ var import_state4 = require("@tiptap/pm/state");
2111
2113
  var import_react19 = require("@tiptap/react");
2112
2114
  var import_menus3 = require("@tiptap/react/menus");
2113
2115
  var import_icons_react5 = require("@tabler/icons-react");
@@ -2169,7 +2171,7 @@ function ImageMenu({
2169
2171
  shouldShow: ({ editor: e, state }) => {
2170
2172
  if (!e.isActive("imageBlock")) return false;
2171
2173
  const { selection } = state;
2172
- const isNodeSelection = selection.constructor.name === "NodeSelection";
2174
+ const isNodeSelection = selection instanceof import_state4.NodeSelection;
2173
2175
  return isNodeSelection;
2174
2176
  },
2175
2177
  updateDelay: 0,
@@ -2281,12 +2283,13 @@ function ImageMenu({
2281
2283
  }
2282
2284
 
2283
2285
  // src/react/menus/ImageBlock/ImageBlockView.tsx
2284
- var import_react24 = require("@tiptap/react");
2285
- var import_react25 = require("react");
2286
+ var import_react25 = require("@tiptap/react");
2287
+ var import_react26 = require("react");
2286
2288
 
2287
2289
  // src/react/menus/ImageBlock/ImageBlockMenu.tsx
2288
- var import_menus4 = require("@tiptap/react/menus");
2289
- var import_react22 = require("react");
2290
+ var import_state5 = require("@tiptap/pm/state");
2291
+ var import_react22 = require("@tiptap/react");
2292
+ var import_react23 = require("react");
2290
2293
 
2291
2294
  // src/react/menus/ImageBlock/ImageBlockWidth.tsx
2292
2295
  var import_react21 = require("react");
@@ -2351,82 +2354,60 @@ ImageBlockWidth.displayName = "ImageBlockWidth";
2351
2354
  // src/react/menus/ImageBlock/ImageBlockMenu.tsx
2352
2355
  var import_icons_react6 = require("@tabler/icons-react");
2353
2356
  var import_jsx_runtime12 = require("react/jsx-runtime");
2354
- var ImageBlockMenu = ({ editor, appendTo }) => {
2355
- const menuRef = (0, import_react22.useRef)(null);
2356
- const [align, setAlign] = (0, import_react22.useState)("center");
2357
- const [width, setWidth] = (0, import_react22.useState)(100);
2358
- (0, import_react22.useEffect)(() => {
2359
- if (!editor) return;
2360
- const update = () => {
2361
- if (!editor.isActive("imageBlock")) return;
2362
- const attrs = editor.getAttributes("imageBlock");
2363
- setAlign(attrs.align || "center");
2364
- const widthStr = attrs.width || "100%";
2365
- setWidth(parseInt(widthStr) || 100);
2366
- };
2367
- update();
2368
- editor.on("selectionUpdate", update);
2369
- editor.on("transaction", update);
2370
- return () => {
2371
- editor.off("selectionUpdate", update);
2372
- editor.off("transaction", update);
2373
- };
2374
- }, [editor]);
2375
- const getReferenceClientRect = (0, import_react22.useCallback)(() => {
2376
- if (!editor) return new DOMRect(-1e3, -1e3, 0, 0);
2377
- const { view } = editor;
2378
- const { state } = view;
2379
- const { selection } = state;
2380
- const node = selection instanceof window.ProseMirror?.state?.NodeSelection ? selection.node : null;
2381
- if (node && node.type.name === "imageBlock") {
2382
- const nodePos = selection.from;
2383
- const domNode = view.nodeDOM(nodePos);
2384
- if (domNode && domNode instanceof HTMLElement) {
2385
- return domNode.getBoundingClientRect();
2386
- }
2387
- }
2388
- const imageBlockElements = document.querySelectorAll("[data-node-view-wrapper]");
2389
- for (const el of Array.from(imageBlockElements)) {
2390
- if (el.querySelector("img")) {
2391
- return el.getBoundingClientRect();
2357
+ var ImageBlockMenu = ({ editor, getPos, appendTo }) => {
2358
+ const menuRef = (0, import_react23.useRef)(null);
2359
+ const { isVisible, align, width } = (0, import_react22.useEditorState)({
2360
+ editor,
2361
+ selector: (ctx) => {
2362
+ if (!ctx.editor) return { isVisible: false, align: "center", width: 100 };
2363
+ const { state } = ctx.editor;
2364
+ const { selection } = state;
2365
+ const isNodeSel = selection instanceof import_state5.NodeSelection;
2366
+ const isThisNode = isNodeSel && selection.from === getPos();
2367
+ const visible = isThisNode;
2368
+ let currentAlign = "center";
2369
+ let currentWidth = 100;
2370
+ if (visible) {
2371
+ const attrs = ctx.editor.getAttributes("imageBlock");
2372
+ currentAlign = attrs.align || "center";
2373
+ const widthStr = attrs.width || "100%";
2374
+ currentWidth = parseInt(widthStr) || 100;
2392
2375
  }
2376
+ return { isVisible: visible, align: currentAlign, width: currentWidth };
2393
2377
  }
2394
- return new DOMRect(-1e3, -1e3, 0, 0);
2395
- }, [editor]);
2396
- const shouldShow = (0, import_react22.useCallback)(() => {
2397
- if (!editor) return false;
2398
- const isActive = editor.isActive("imageBlock");
2399
- if (!isActive) return false;
2400
- const { state } = editor;
2401
- const { selection } = state;
2402
- const isNodeSelection = selection.constructor.name === "NodeSelection";
2403
- return isNodeSelection;
2404
- }, [editor]);
2405
- const onAlignImageLeft = (0, import_react22.useCallback)(() => {
2378
+ });
2379
+ const onAlignImageLeft = (0, import_react23.useCallback)(() => {
2406
2380
  editor.chain().focus(void 0, { scrollIntoView: false }).setImageBlockAlign("left").run();
2407
2381
  }, [editor]);
2408
- const onAlignImageCenter = (0, import_react22.useCallback)(() => {
2382
+ const onAlignImageCenter = (0, import_react23.useCallback)(() => {
2409
2383
  editor.chain().focus(void 0, { scrollIntoView: false }).setImageBlockAlign("center").run();
2410
2384
  }, [editor]);
2411
- const onAlignImageRight = (0, import_react22.useCallback)(() => {
2385
+ const onAlignImageRight = (0, import_react23.useCallback)(() => {
2412
2386
  editor.chain().focus(void 0, { scrollIntoView: false }).setImageBlockAlign("right").run();
2413
2387
  }, [editor]);
2414
- const onWidthChange = (0, import_react22.useCallback)(
2388
+ const onWidthChange = (0, import_react23.useCallback)(
2415
2389
  (value) => {
2416
2390
  editor.chain().focus(void 0, { scrollIntoView: false }).setImageBlockWidth(value).run();
2417
2391
  },
2418
2392
  [editor]
2419
2393
  );
2420
- const onRemoveImage = (0, import_react22.useCallback)(() => {
2394
+ const onRemoveImage = (0, import_react23.useCallback)(() => {
2421
2395
  editor.chain().focus(void 0, { scrollIntoView: false }).deleteSelection().run();
2422
2396
  }, [editor]);
2423
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2424
- import_menus4.BubbleMenu,
2397
+ if (!isVisible) return null;
2398
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
2399
+ "div",
2425
2400
  {
2426
- editor,
2427
- shouldShow,
2428
- updateDelay: 0,
2429
- children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "bubble-menu", ref: menuRef, children: [
2401
+ className: "bubble-menu",
2402
+ ref: menuRef,
2403
+ style: {
2404
+ position: "absolute",
2405
+ top: "-40px",
2406
+ left: "50%",
2407
+ transform: "translateX(-50%)",
2408
+ zIndex: "var(--nph-z, 50)"
2409
+ },
2410
+ children: [
2430
2411
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
2431
2412
  "button",
2432
2413
  {
@@ -2486,14 +2467,14 @@ var ImageBlockMenu = ({ editor, appendTo }) => {
2486
2467
  children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_icons_react6.IconTrash, { size: 16 })
2487
2468
  }
2488
2469
  )
2489
- ] })
2470
+ ]
2490
2471
  }
2491
2472
  );
2492
2473
  };
2493
2474
 
2494
2475
  // src/react/menus/ImageBlock/ImageUploader.tsx
2495
2476
  var import_icons_react8 = require("@tabler/icons-react");
2496
- var import_react23 = require("react");
2477
+ var import_react24 = require("react");
2497
2478
 
2498
2479
  // src/react/menus/ImageBlock/ImageBlockLoading.tsx
2499
2480
  var import_icons_react7 = require("@tabler/icons-react");
@@ -2511,10 +2492,10 @@ var ImageBlockLoading = () => {
2511
2492
  // src/react/menus/ImageBlock/ImageUploader.tsx
2512
2493
  var import_jsx_runtime14 = require("react/jsx-runtime");
2513
2494
  var ImageUploader = ({ onUpload, editor }) => {
2514
- const [loading, setLoading] = (0, import_react23.useState)(false);
2515
- const [draggedInside, setDraggedInside] = (0, import_react23.useState)(false);
2516
- const fileInputRef = (0, import_react23.useRef)(null);
2517
- const uploadFile = (0, import_react23.useCallback)(
2495
+ const [loading, setLoading] = (0, import_react24.useState)(false);
2496
+ const [draggedInside, setDraggedInside] = (0, import_react24.useState)(false);
2497
+ const fileInputRef = (0, import_react24.useRef)(null);
2498
+ const uploadFile = (0, import_react24.useCallback)(
2518
2499
  async (file) => {
2519
2500
  setLoading(true);
2520
2501
  try {
@@ -2536,10 +2517,10 @@ var ImageUploader = ({ onUpload, editor }) => {
2536
2517
  },
2537
2518
  [editor, onUpload]
2538
2519
  );
2539
- const handleUploadClick = (0, import_react23.useCallback)(() => {
2520
+ const handleUploadClick = (0, import_react24.useCallback)(() => {
2540
2521
  fileInputRef.current?.click();
2541
2522
  }, []);
2542
- const onFileChange = (0, import_react23.useCallback)(
2523
+ const onFileChange = (0, import_react24.useCallback)(
2543
2524
  (e) => {
2544
2525
  const file = e.target.files?.[0];
2545
2526
  if (file) {
@@ -2548,7 +2529,7 @@ var ImageUploader = ({ onUpload, editor }) => {
2548
2529
  },
2549
2530
  [uploadFile]
2550
2531
  );
2551
- const onDrop = (0, import_react23.useCallback)(
2532
+ const onDrop = (0, import_react24.useCallback)(
2552
2533
  (e) => {
2553
2534
  e.preventDefault();
2554
2535
  e.stopPropagation();
@@ -2560,12 +2541,12 @@ var ImageUploader = ({ onUpload, editor }) => {
2560
2541
  },
2561
2542
  [uploadFile]
2562
2543
  );
2563
- const onDragEnter = (0, import_react23.useCallback)((e) => {
2544
+ const onDragEnter = (0, import_react24.useCallback)((e) => {
2564
2545
  e.preventDefault();
2565
2546
  e.stopPropagation();
2566
2547
  setDraggedInside(true);
2567
2548
  }, []);
2568
- const onDragLeave = (0, import_react23.useCallback)((e) => {
2549
+ const onDragLeave = (0, import_react24.useCallback)((e) => {
2569
2550
  e.preventDefault();
2570
2551
  e.stopPropagation();
2571
2552
  setDraggedInside(false);
@@ -2618,21 +2599,21 @@ var ImageUploader = ({ onUpload, editor }) => {
2618
2599
  var import_jsx_runtime15 = require("react/jsx-runtime");
2619
2600
  var ImageBlockView = (props) => {
2620
2601
  const { editor, getPos, node, updateAttributes } = props;
2621
- const imageWrapperRef = (0, import_react25.useRef)(null);
2602
+ const imageWrapperRef = (0, import_react26.useRef)(null);
2622
2603
  const { src, width, align, alt, loading } = node.attrs;
2623
- const handleUpload = (0, import_react25.useCallback)(
2604
+ const handleUpload = (0, import_react26.useCallback)(
2624
2605
  (url) => {
2625
2606
  updateAttributes({ src: url, loading: false });
2626
2607
  },
2627
2608
  [updateAttributes]
2628
2609
  );
2629
- const onClick = (0, import_react25.useCallback)(() => {
2610
+ const onClick = (0, import_react26.useCallback)(() => {
2630
2611
  editor.commands.setNodeSelection(getPos());
2631
2612
  }, [getPos, editor.commands]);
2632
2613
  const getWrapperStyle = () => {
2633
2614
  const baseStyle = {
2634
- width: width || "100%",
2635
- maxWidth: "100%"
2615
+ width: "fit-content",
2616
+ maxWidth: width || "100%"
2636
2617
  };
2637
2618
  if (align === "left") {
2638
2619
  return { ...baseStyle, marginLeft: 0, marginRight: "auto" };
@@ -2642,14 +2623,17 @@ var ImageBlockView = (props) => {
2642
2623
  return { ...baseStyle, marginLeft: "auto", marginRight: "auto" };
2643
2624
  }
2644
2625
  };
2626
+ const getContentStyle = () => ({
2627
+ position: "relative"
2628
+ });
2645
2629
  if (!src || src === "") {
2646
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react24.NodeViewWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: getWrapperStyle(), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { ref: imageWrapperRef, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ImageUploader, { onUpload: handleUpload, editor }) }) }) });
2630
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react25.NodeViewWrapper, { style: getWrapperStyle(), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { ref: imageWrapperRef, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ImageUploader, { onUpload: handleUpload, editor }) }) });
2647
2631
  }
2648
2632
  if (loading) {
2649
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react24.NodeViewWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: getWrapperStyle(), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { ref: imageWrapperRef, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ImageBlockLoading, {}) }) }) });
2633
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react25.NodeViewWrapper, { style: getWrapperStyle(), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { ref: imageWrapperRef, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ImageBlockLoading, {}) }) });
2650
2634
  }
2651
- return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_react24.NodeViewWrapper, { children: [
2652
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { style: getWrapperStyle(), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("div", { contentEditable: false, ref: imageWrapperRef, style: { position: "relative" }, children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2635
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_react25.NodeViewWrapper, { style: getWrapperStyle(), children: /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { contentEditable: false, ref: imageWrapperRef, style: getContentStyle(), children: [
2636
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
2653
2637
  "img",
2654
2638
  {
2655
2639
  src,
@@ -2657,75 +2641,75 @@ var ImageBlockView = (props) => {
2657
2641
  onClick,
2658
2642
  className: "nph-image-block"
2659
2643
  }
2660
- ) }) }),
2661
- /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ImageBlockMenu, { editor, appendTo: imageWrapperRef })
2662
- ] });
2644
+ ),
2645
+ /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(ImageBlockMenu, { editor, getPos, appendTo: imageWrapperRef })
2646
+ ] }) });
2663
2647
  };
2664
2648
 
2665
2649
  // src/react/menus/VideoBlock/VideoBlockView.tsx
2666
- var import_react27 = require("@tiptap/react");
2667
- var import_react28 = require("react");
2650
+ var import_state7 = require("@tiptap/pm/state");
2651
+ var import_react29 = require("@tiptap/react");
2652
+ var import_react30 = require("react");
2668
2653
 
2669
2654
  // src/react/menus/VideoBlock/VideoBlockMenu.tsx
2670
- var import_menus5 = require("@tiptap/react/menus");
2671
- var import_react26 = require("react");
2655
+ var import_state6 = require("@tiptap/pm/state");
2656
+ var import_react27 = require("@tiptap/react");
2657
+ var import_react28 = require("react");
2672
2658
  var import_icons_react9 = require("@tabler/icons-react");
2673
2659
  var import_jsx_runtime16 = require("react/jsx-runtime");
2674
- var VideoBlockMenu = ({ editor }) => {
2675
- const menuRef = (0, import_react26.useRef)(null);
2676
- const [align, setAlign] = (0, import_react26.useState)("center");
2677
- const [width, setWidth] = (0, import_react26.useState)(100);
2678
- (0, import_react26.useEffect)(() => {
2679
- if (!editor) return;
2680
- const update = () => {
2681
- if (!editor.isActive("videoBlock")) return;
2682
- const attrs = editor.getAttributes("videoBlock");
2683
- setAlign(attrs.align || "center");
2684
- const widthStr = attrs.width || "100%";
2685
- setWidth(parseInt(widthStr) || 100);
2686
- };
2687
- update();
2688
- editor.on("selectionUpdate", update);
2689
- editor.on("transaction", update);
2690
- return () => {
2691
- editor.off("selectionUpdate", update);
2692
- editor.off("transaction", update);
2693
- };
2694
- }, [editor]);
2695
- const shouldShow = (0, import_react26.useCallback)(() => {
2696
- if (!editor) return false;
2697
- const { state } = editor;
2698
- const { selection } = state;
2699
- if (selection.constructor.name !== "NodeSelection") return false;
2700
- const node = selection.node;
2701
- if (!node || node.type.name !== "videoBlock") return false;
2702
- return true;
2703
- }, [editor]);
2704
- const onAlignLeft = (0, import_react26.useCallback)(() => {
2660
+ var VideoBlockMenu = ({ editor, getPos }) => {
2661
+ const menuRef = (0, import_react28.useRef)(null);
2662
+ const { isVisible, align, width } = (0, import_react27.useEditorState)({
2663
+ editor,
2664
+ selector: (ctx) => {
2665
+ if (!ctx.editor) return { isVisible: false, align: "center", width: 100 };
2666
+ const { state } = ctx.editor;
2667
+ const { selection } = state;
2668
+ const isNodeSel = selection instanceof import_state6.NodeSelection;
2669
+ const isThisNode = isNodeSel && selection.from === getPos();
2670
+ let currentAlign = "center";
2671
+ let currentWidth = 100;
2672
+ if (isThisNode) {
2673
+ const attrs = ctx.editor.getAttributes("videoBlock");
2674
+ currentAlign = attrs.align || "center";
2675
+ const widthStr = attrs.width || "100%";
2676
+ currentWidth = parseInt(widthStr) || 100;
2677
+ }
2678
+ return { isVisible: isThisNode, align: currentAlign, width: currentWidth };
2679
+ }
2680
+ });
2681
+ const onAlignLeft = (0, import_react28.useCallback)(() => {
2705
2682
  editor.chain().focus(void 0, { scrollIntoView: false }).setVideoBlockAlign("left").run();
2706
2683
  }, [editor]);
2707
- const onAlignCenter = (0, import_react26.useCallback)(() => {
2684
+ const onAlignCenter = (0, import_react28.useCallback)(() => {
2708
2685
  editor.chain().focus(void 0, { scrollIntoView: false }).setVideoBlockAlign("center").run();
2709
2686
  }, [editor]);
2710
- const onAlignRight = (0, import_react26.useCallback)(() => {
2687
+ const onAlignRight = (0, import_react28.useCallback)(() => {
2711
2688
  editor.chain().focus(void 0, { scrollIntoView: false }).setVideoBlockAlign("right").run();
2712
2689
  }, [editor]);
2713
- const onWidthChange = (0, import_react26.useCallback)(
2690
+ const onWidthChange = (0, import_react28.useCallback)(
2714
2691
  (value) => {
2715
2692
  editor.chain().focus(void 0, { scrollIntoView: false }).setVideoBlockWidth(value).run();
2716
2693
  },
2717
2694
  [editor]
2718
2695
  );
2719
- const onRemove = (0, import_react26.useCallback)(() => {
2696
+ const onRemove = (0, import_react28.useCallback)(() => {
2720
2697
  editor.chain().focus(void 0, { scrollIntoView: false }).deleteSelection().run();
2721
2698
  }, [editor]);
2722
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2723
- import_menus5.BubbleMenu,
2699
+ if (!isVisible) return null;
2700
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(
2701
+ "div",
2724
2702
  {
2725
- editor,
2726
- shouldShow,
2727
- updateDelay: 0,
2728
- children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "bubble-menu", ref: menuRef, children: [
2703
+ className: "bubble-menu",
2704
+ ref: menuRef,
2705
+ style: {
2706
+ position: "absolute",
2707
+ top: "-40px",
2708
+ left: "50%",
2709
+ transform: "translateX(-50%)",
2710
+ zIndex: "var(--nph-z, 50)"
2711
+ },
2712
+ children: [
2729
2713
  /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
2730
2714
  "button",
2731
2715
  {
@@ -2785,7 +2769,7 @@ var VideoBlockMenu = ({ editor }) => {
2785
2769
  children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_icons_react9.IconTrash, { size: 16 })
2786
2770
  }
2787
2771
  )
2788
- ] })
2772
+ ]
2789
2773
  }
2790
2774
  );
2791
2775
  };
@@ -2808,15 +2792,23 @@ function toEmbedUrl(url) {
2808
2792
  }
2809
2793
  var VideoBlockView = (props) => {
2810
2794
  const { editor, getPos, node, updateAttributes } = props;
2811
- const wrapperRef = (0, import_react28.useRef)(null);
2795
+ const wrapperRef = (0, import_react30.useRef)(null);
2812
2796
  const { src, width, align } = node.attrs;
2813
- const [inputUrl, setInputUrl] = (0, import_react28.useState)("");
2814
- const handleEmbed = (0, import_react28.useCallback)(() => {
2797
+ const [inputUrl, setInputUrl] = (0, import_react30.useState)("");
2798
+ const isSelected = (0, import_react29.useEditorState)({
2799
+ editor,
2800
+ selector: (ctx) => {
2801
+ if (!ctx.editor) return false;
2802
+ const { selection } = ctx.editor.state;
2803
+ return selection instanceof import_state7.NodeSelection && selection.from === getPos();
2804
+ }
2805
+ });
2806
+ const handleEmbed = (0, import_react30.useCallback)(() => {
2815
2807
  if (!inputUrl.trim()) return;
2816
2808
  const embedUrl = toEmbedUrl(inputUrl.trim());
2817
2809
  updateAttributes({ src: embedUrl });
2818
2810
  }, [inputUrl, updateAttributes]);
2819
- const handleKeyDown = (0, import_react28.useCallback)(
2811
+ const handleKeyDown = (0, import_react30.useCallback)(
2820
2812
  (e) => {
2821
2813
  if (e.key === "Enter") {
2822
2814
  e.preventDefault();
@@ -2825,7 +2817,7 @@ var VideoBlockView = (props) => {
2825
2817
  },
2826
2818
  [handleEmbed]
2827
2819
  );
2828
- const onClick = (0, import_react28.useCallback)(() => {
2820
+ const onClick = (0, import_react30.useCallback)(() => {
2829
2821
  editor.commands.setNodeSelection(getPos());
2830
2822
  }, [getPos, editor.commands]);
2831
2823
  const getWrapperStyle = () => {
@@ -2842,7 +2834,7 @@ var VideoBlockView = (props) => {
2842
2834
  }
2843
2835
  };
2844
2836
  if (!src || src === "") {
2845
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react27.NodeViewWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: getWrapperStyle(), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "nph-video-input", ref: wrapperRef, children: [
2837
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react29.NodeViewWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: getWrapperStyle(), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "nph-video-input", ref: wrapperRef, children: [
2846
2838
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "nph-video-input__icon", children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_icons_react10.IconVideo, { size: 24 }) }),
2847
2839
  /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "nph-video-input__content", children: [
2848
2840
  /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
@@ -2869,38 +2861,47 @@ var VideoBlockView = (props) => {
2869
2861
  ] })
2870
2862
  ] }) }) });
2871
2863
  }
2872
- return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_react27.NodeViewWrapper, { children: [
2873
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: getWrapperStyle(), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2874
- "div",
2875
- {
2876
- contentEditable: false,
2877
- ref: wrapperRef,
2878
- style: { position: "relative" },
2879
- children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { className: "nph-video-block", onClick, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2880
- "iframe",
2881
- {
2882
- src,
2883
- className: "nph-video-block__iframe",
2884
- allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
2885
- allowFullScreen: true
2886
- }
2887
- ) })
2888
- }
2889
- ) }),
2890
- /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(VideoBlockMenu, { editor })
2891
- ] });
2864
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react29.NodeViewWrapper, { children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)("div", { style: getWrapperStyle(), children: /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(
2865
+ "div",
2866
+ {
2867
+ contentEditable: false,
2868
+ ref: wrapperRef,
2869
+ style: { position: "relative" },
2870
+ children: [
2871
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "nph-video-block", children: [
2872
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2873
+ "iframe",
2874
+ {
2875
+ src,
2876
+ className: "nph-video-block__iframe",
2877
+ allow: "accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture",
2878
+ allowFullScreen: true
2879
+ }
2880
+ ),
2881
+ !isSelected && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
2882
+ "div",
2883
+ {
2884
+ className: "nph-video-block__overlay",
2885
+ onClick
2886
+ }
2887
+ )
2888
+ ] }),
2889
+ /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(VideoBlockMenu, { editor, getPos })
2890
+ ]
2891
+ }
2892
+ ) }) });
2892
2893
  };
2893
2894
 
2894
2895
  // src/react/Editor.tsx
2895
2896
  var import_jsx_runtime18 = require("react/jsx-runtime");
2896
- function Editor3({
2897
+ function Editor5({
2897
2898
  content,
2898
2899
  className,
2899
2900
  editable = true,
2900
2901
  immediatelyRender = false,
2901
2902
  showTextMenu = true,
2902
2903
  showSlashMenu = true,
2903
- showImageMenu = true,
2904
+ showImageMenu = false,
2904
2905
  extensions,
2905
2906
  bubbleMenuExtras,
2906
2907
  onUpdate,