tetrons 2.3.26 → 2.3.27

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,15 +1,7 @@
1
- import React, { useRef, useEffect } from "react";
2
- import { NodeViewWrapper, NodeViewRendererProps } from "@tiptap/react";
1
+ import React, { useRef, useEffect, useState } from "react";
2
+ import { NodeViewWrapper, ReactNodeViewProps } from "@tiptap/react";
3
3
 
4
- interface ResizableImageProps extends NodeViewRendererProps {
5
- updateAttributes: (attrs: {
6
- width?: number | null;
7
- height?: number | null;
8
- }) => void;
9
- selected?: boolean;
10
- }
11
-
12
- const ResizableImageComponent: React.FC<ResizableImageProps> = ({
4
+ const ResizableImageComponent: React.FC<ReactNodeViewProps> = ({
13
5
  node,
14
6
  updateAttributes,
15
7
  selected,
@@ -21,22 +13,44 @@ const ResizableImageComponent: React.FC<ResizableImageProps> = ({
21
13
  width?: number | null;
22
14
  height?: number | null;
23
15
  };
16
+
17
+ const defaultWidth = width ?? 300;
18
+ const defaultHeight = height ?? 200;
19
+ const aspectRatio = defaultHeight > 0 ? defaultWidth / defaultHeight : 4 / 3;
20
+
24
21
  const wrapperRef = useRef<HTMLDivElement>(null);
25
- const imgRef = useRef<HTMLImageElement>(null);
22
+ const [isResizing, setIsResizing] = useState(false);
26
23
 
27
24
  useEffect(() => {
28
- const img = imgRef.current;
29
- if (!img) return;
25
+ const handleMouseMove = (e: MouseEvent) => {
26
+ if (!isResizing || !wrapperRef.current) return;
27
+
28
+ const rect = wrapperRef.current.getBoundingClientRect();
29
+ const newWidth = e.clientX - rect.left;
30
+ const newHeight = newWidth / aspectRatio;
31
+
32
+ if (newWidth > 50 && newHeight > 50) {
33
+ updateAttributes({
34
+ width: Math.round(newWidth),
35
+ height: Math.round(newHeight),
36
+ });
37
+ }
38
+ };
39
+
40
+ const handleMouseUp = () => {
41
+ setIsResizing(false);
42
+ };
30
43
 
31
- const observer = new ResizeObserver(() => {
32
- const w = Math.round(img.offsetWidth);
33
- const h = Math.round(img.offsetHeight);
34
- updateAttributes({ width: w, height: h });
35
- });
44
+ if (isResizing) {
45
+ window.addEventListener("mousemove", handleMouseMove);
46
+ window.addEventListener("mouseup", handleMouseUp);
47
+ }
36
48
 
37
- observer.observe(img);
38
- return () => observer.disconnect();
39
- }, [updateAttributes]);
49
+ return () => {
50
+ window.removeEventListener("mousemove", handleMouseMove);
51
+ window.removeEventListener("mouseup", handleMouseUp);
52
+ };
53
+ }, [isResizing, updateAttributes, aspectRatio]);
40
54
 
41
55
  return (
42
56
  <NodeViewWrapper
@@ -46,30 +60,51 @@ const ResizableImageComponent: React.FC<ResizableImageProps> = ({
46
60
  selected ? "ProseMirror-selectednode" : ""
47
61
  }`}
48
62
  style={{
49
- resize: "both",
50
- overflow: "auto",
63
+ position: "relative",
51
64
  border: "1px solid #ccc",
52
- padding: 2,
53
65
  display: "inline-block",
66
+ width: `${defaultWidth}px`,
67
+ height: `${defaultHeight}px`,
68
+ minWidth: "50px",
69
+ minHeight: "50px",
54
70
  maxWidth: "100%",
71
+ userSelect: "none",
72
+ padding: 2,
55
73
  }}
56
74
  >
57
- {/* eslint-disable-next-line @next/next/no-img-element */}
58
75
  <img
59
- ref={imgRef}
60
76
  src={src}
61
77
  alt={alt ?? ""}
62
78
  title={title ?? ""}
63
79
  loading="lazy"
64
80
  style={{
65
- width: width ? `${width}px` : "auto",
66
- height: height ? `${height}px` : "auto",
81
+ width: "100%",
82
+ height: "100%",
83
+ objectFit: "contain",
67
84
  display: "block",
68
85
  userSelect: "none",
69
86
  pointerEvents: "auto",
70
87
  }}
71
88
  draggable={false}
72
89
  />
90
+
91
+ <div
92
+ onMouseDown={(e) => {
93
+ e.preventDefault();
94
+ setIsResizing(true);
95
+ }}
96
+ style={{
97
+ position: "absolute",
98
+ width: "12px",
99
+ height: "12px",
100
+ right: 2,
101
+ bottom: 2,
102
+ background: "#ccc",
103
+ borderRadius: "2px",
104
+ cursor: "nwse-resize",
105
+ zIndex: 10,
106
+ }}
107
+ />
73
108
  </NodeViewWrapper>
74
109
  );
75
110
  };
@@ -8,12 +8,8 @@ export const ResizableImage = Image.extend({
8
8
  addAttributes() {
9
9
  return {
10
10
  ...this.parent?.(),
11
- width: {
12
- default: null,
13
- },
14
- height: {
15
- default: null,
16
- },
11
+ width: { default: null },
12
+ height: { default: null },
17
13
  };
18
14
  },
19
15
 
@@ -1,4 +1,4 @@
1
1
  import React from "react";
2
2
  import { ReactNodeViewProps } from "@tiptap/react";
3
- declare const ResizableImageComponent: React.FC<ReactNodeViewProps<HTMLElement>>;
3
+ declare const ResizableImageComponent: React.FC<ReactNodeViewProps>;
4
4
  export default ResizableImageComponent;
@@ -1,37 +1,73 @@
1
- import React, { useRef, useEffect } from "react";
1
+ import React, { useRef, useEffect, useState } from "react";
2
2
  import { NodeViewWrapper } from "@tiptap/react";
3
3
  const ResizableImageComponent = ({ node, updateAttributes, selected, }) => {
4
4
  const { src, alt, title, width, height } = node.attrs;
5
+ const defaultWidth = width !== null && width !== void 0 ? width : 300;
6
+ const defaultHeight = height !== null && height !== void 0 ? height : 200;
7
+ const aspectRatio = defaultHeight > 0 ? defaultWidth / defaultHeight : 4 / 3;
5
8
  const wrapperRef = useRef(null);
6
- const imgRef = useRef(null);
9
+ const [isResizing, setIsResizing] = useState(false);
7
10
  useEffect(() => {
8
- const img = imgRef.current;
9
- if (!img)
10
- return;
11
- const observer = new ResizeObserver(() => {
12
- const w = Math.round(img.offsetWidth);
13
- const h = Math.round(img.offsetHeight);
14
- updateAttributes({ width: w, height: h });
15
- });
16
- observer.observe(img);
17
- return () => observer.disconnect();
18
- }, [updateAttributes]);
11
+ const handleMouseMove = (e) => {
12
+ if (!isResizing || !wrapperRef.current)
13
+ return;
14
+ const rect = wrapperRef.current.getBoundingClientRect();
15
+ const newWidth = e.clientX - rect.left;
16
+ const newHeight = newWidth / aspectRatio;
17
+ if (newWidth > 50 && newHeight > 50) {
18
+ updateAttributes({
19
+ width: Math.round(newWidth),
20
+ height: Math.round(newHeight),
21
+ });
22
+ }
23
+ };
24
+ const handleMouseUp = () => {
25
+ setIsResizing(false);
26
+ };
27
+ if (isResizing) {
28
+ window.addEventListener("mousemove", handleMouseMove);
29
+ window.addEventListener("mouseup", handleMouseUp);
30
+ }
31
+ return () => {
32
+ window.removeEventListener("mousemove", handleMouseMove);
33
+ window.removeEventListener("mouseup", handleMouseUp);
34
+ };
35
+ }, [isResizing, updateAttributes, aspectRatio]);
19
36
  return (<NodeViewWrapper ref={wrapperRef} contentEditable={false} className={`resizable-image-wrapper ${selected ? "ProseMirror-selectednode" : ""}`} style={{
20
- resize: "both",
21
- overflow: "auto",
37
+ position: "relative",
22
38
  border: "1px solid #ccc",
23
- padding: 2,
24
39
  display: "inline-block",
40
+ width: `${defaultWidth}px`,
41
+ height: `${defaultHeight}px`,
42
+ minWidth: "50px",
43
+ minHeight: "50px",
25
44
  maxWidth: "100%",
45
+ userSelect: "none",
46
+ padding: 2,
26
47
  }}>
27
- {/* eslint-disable-next-line @next/next/no-img-element */}
28
- <img ref={imgRef} src={src} alt={alt !== null && alt !== void 0 ? alt : ""} title={title !== null && title !== void 0 ? title : ""} loading="lazy" style={{
29
- width: width ? `${width}px` : "auto",
30
- height: height ? `${height}px` : "auto",
48
+ <img src={src} alt={alt !== null && alt !== void 0 ? alt : ""} title={title !== null && title !== void 0 ? title : ""} loading="lazy" style={{
49
+ width: "100%",
50
+ height: "100%",
51
+ objectFit: "contain",
31
52
  display: "block",
32
53
  userSelect: "none",
33
54
  pointerEvents: "auto",
34
55
  }} draggable={false}/>
56
+
57
+ <div onMouseDown={(e) => {
58
+ e.preventDefault();
59
+ setIsResizing(true);
60
+ }} style={{
61
+ position: "absolute",
62
+ width: "12px",
63
+ height: "12px",
64
+ right: 2,
65
+ bottom: 2,
66
+ background: "#ccc",
67
+ borderRadius: "2px",
68
+ cursor: "nwse-resize",
69
+ zIndex: 10,
70
+ }}/>
35
71
  </NodeViewWrapper>);
36
72
  };
37
73
  export default ResizableImageComponent;
@@ -1,15 +1,7 @@
1
- import React, { useRef, useEffect } from "react";
2
- import { NodeViewWrapper, NodeViewRendererProps } from "@tiptap/react";
1
+ import React, { useRef, useEffect, useState } from "react";
2
+ import { NodeViewWrapper, ReactNodeViewProps } from "@tiptap/react";
3
3
 
4
- interface ResizableImageProps extends NodeViewRendererProps {
5
- updateAttributes: (attrs: {
6
- width?: number | null;
7
- height?: number | null;
8
- }) => void;
9
- selected?: boolean;
10
- }
11
-
12
- const ResizableImageComponent: React.FC<ResizableImageProps> = ({
4
+ const ResizableImageComponent: React.FC<ReactNodeViewProps> = ({
13
5
  node,
14
6
  updateAttributes,
15
7
  selected,
@@ -21,22 +13,44 @@ const ResizableImageComponent: React.FC<ResizableImageProps> = ({
21
13
  width?: number | null;
22
14
  height?: number | null;
23
15
  };
16
+
17
+ const defaultWidth = width ?? 300;
18
+ const defaultHeight = height ?? 200;
19
+ const aspectRatio = defaultHeight > 0 ? defaultWidth / defaultHeight : 4 / 3;
20
+
24
21
  const wrapperRef = useRef<HTMLDivElement>(null);
25
- const imgRef = useRef<HTMLImageElement>(null);
22
+ const [isResizing, setIsResizing] = useState(false);
26
23
 
27
24
  useEffect(() => {
28
- const img = imgRef.current;
29
- if (!img) return;
25
+ const handleMouseMove = (e: MouseEvent) => {
26
+ if (!isResizing || !wrapperRef.current) return;
27
+
28
+ const rect = wrapperRef.current.getBoundingClientRect();
29
+ const newWidth = e.clientX - rect.left;
30
+ const newHeight = newWidth / aspectRatio;
31
+
32
+ if (newWidth > 50 && newHeight > 50) {
33
+ updateAttributes({
34
+ width: Math.round(newWidth),
35
+ height: Math.round(newHeight),
36
+ });
37
+ }
38
+ };
39
+
40
+ const handleMouseUp = () => {
41
+ setIsResizing(false);
42
+ };
30
43
 
31
- const observer = new ResizeObserver(() => {
32
- const w = Math.round(img.offsetWidth);
33
- const h = Math.round(img.offsetHeight);
34
- updateAttributes({ width: w, height: h });
35
- });
44
+ if (isResizing) {
45
+ window.addEventListener("mousemove", handleMouseMove);
46
+ window.addEventListener("mouseup", handleMouseUp);
47
+ }
36
48
 
37
- observer.observe(img);
38
- return () => observer.disconnect();
39
- }, [updateAttributes]);
49
+ return () => {
50
+ window.removeEventListener("mousemove", handleMouseMove);
51
+ window.removeEventListener("mouseup", handleMouseUp);
52
+ };
53
+ }, [isResizing, updateAttributes, aspectRatio]);
40
54
 
41
55
  return (
42
56
  <NodeViewWrapper
@@ -46,30 +60,51 @@ const ResizableImageComponent: React.FC<ResizableImageProps> = ({
46
60
  selected ? "ProseMirror-selectednode" : ""
47
61
  }`}
48
62
  style={{
49
- resize: "both",
50
- overflow: "auto",
63
+ position: "relative",
51
64
  border: "1px solid #ccc",
52
- padding: 2,
53
65
  display: "inline-block",
66
+ width: `${defaultWidth}px`,
67
+ height: `${defaultHeight}px`,
68
+ minWidth: "50px",
69
+ minHeight: "50px",
54
70
  maxWidth: "100%",
71
+ userSelect: "none",
72
+ padding: 2,
55
73
  }}
56
74
  >
57
- {/* eslint-disable-next-line @next/next/no-img-element */}
58
75
  <img
59
- ref={imgRef}
60
76
  src={src}
61
77
  alt={alt ?? ""}
62
78
  title={title ?? ""}
63
79
  loading="lazy"
64
80
  style={{
65
- width: width ? `${width}px` : "auto",
66
- height: height ? `${height}px` : "auto",
81
+ width: "100%",
82
+ height: "100%",
83
+ objectFit: "contain",
67
84
  display: "block",
68
85
  userSelect: "none",
69
86
  pointerEvents: "auto",
70
87
  }}
71
88
  draggable={false}
72
89
  />
90
+
91
+ <div
92
+ onMouseDown={(e) => {
93
+ e.preventDefault();
94
+ setIsResizing(true);
95
+ }}
96
+ style={{
97
+ position: "absolute",
98
+ width: "12px",
99
+ height: "12px",
100
+ right: 2,
101
+ bottom: 2,
102
+ background: "#ccc",
103
+ borderRadius: "2px",
104
+ cursor: "nwse-resize",
105
+ zIndex: 10,
106
+ }}
107
+ />
73
108
  </NodeViewWrapper>
74
109
  );
75
110
  };
package/dist/index.js CHANGED
@@ -15409,19 +15409,36 @@ var ResizableImageComponent = ({
15409
15409
  selected
15410
15410
  }) => {
15411
15411
  const { src, alt, title, width, height } = node.attrs;
15412
+ const defaultWidth = width ?? 300;
15413
+ const defaultHeight = height ?? 200;
15414
+ const aspectRatio = defaultHeight > 0 ? defaultWidth / defaultHeight : 4 / 3;
15412
15415
  const wrapperRef = (0, import_react2.useRef)(null);
15413
- const imgRef = (0, import_react2.useRef)(null);
15416
+ const [isResizing, setIsResizing] = (0, import_react2.useState)(false);
15414
15417
  (0, import_react2.useEffect)(() => {
15415
- const img = imgRef.current;
15416
- if (!img) return;
15417
- const observer = new ResizeObserver(() => {
15418
- const w = Math.round(img.offsetWidth);
15419
- const h = Math.round(img.offsetHeight);
15420
- updateAttributes({ width: w, height: h });
15421
- });
15422
- observer.observe(img);
15423
- return () => observer.disconnect();
15424
- }, [updateAttributes]);
15418
+ const handleMouseMove2 = (e) => {
15419
+ if (!isResizing || !wrapperRef.current) return;
15420
+ const rect = wrapperRef.current.getBoundingClientRect();
15421
+ const newWidth = e.clientX - rect.left;
15422
+ const newHeight = newWidth / aspectRatio;
15423
+ if (newWidth > 50 && newHeight > 50) {
15424
+ updateAttributes({
15425
+ width: Math.round(newWidth),
15426
+ height: Math.round(newHeight)
15427
+ });
15428
+ }
15429
+ };
15430
+ const handleMouseUp = () => {
15431
+ setIsResizing(false);
15432
+ };
15433
+ if (isResizing) {
15434
+ window.addEventListener("mousemove", handleMouseMove2);
15435
+ window.addEventListener("mouseup", handleMouseUp);
15436
+ }
15437
+ return () => {
15438
+ window.removeEventListener("mousemove", handleMouseMove2);
15439
+ window.removeEventListener("mouseup", handleMouseUp);
15440
+ };
15441
+ }, [isResizing, updateAttributes, aspectRatio]);
15425
15442
  return /* @__PURE__ */ import_react2.default.createElement(
15426
15443
  import_react3.NodeViewWrapper,
15427
15444
  {
@@ -15429,31 +15446,55 @@ var ResizableImageComponent = ({
15429
15446
  contentEditable: false,
15430
15447
  className: `resizable-image-wrapper ${selected ? "ProseMirror-selectednode" : ""}`,
15431
15448
  style: {
15432
- resize: "both",
15433
- overflow: "auto",
15449
+ position: "relative",
15434
15450
  border: "1px solid #ccc",
15435
- padding: 2,
15436
15451
  display: "inline-block",
15437
- maxWidth: "100%"
15452
+ width: `${defaultWidth}px`,
15453
+ height: `${defaultHeight}px`,
15454
+ minWidth: "50px",
15455
+ minHeight: "50px",
15456
+ maxWidth: "100%",
15457
+ userSelect: "none",
15458
+ padding: 2
15438
15459
  }
15439
15460
  },
15440
15461
  /* @__PURE__ */ import_react2.default.createElement(
15441
15462
  "img",
15442
15463
  {
15443
- ref: imgRef,
15444
15464
  src,
15445
15465
  alt: alt ?? "",
15446
15466
  title: title ?? "",
15447
15467
  loading: "lazy",
15448
15468
  style: {
15449
- width: width ? `${width}px` : "auto",
15450
- height: height ? `${height}px` : "auto",
15469
+ width: "100%",
15470
+ height: "100%",
15471
+ objectFit: "contain",
15451
15472
  display: "block",
15452
15473
  userSelect: "none",
15453
15474
  pointerEvents: "auto"
15454
15475
  },
15455
15476
  draggable: false
15456
15477
  }
15478
+ ),
15479
+ /* @__PURE__ */ import_react2.default.createElement(
15480
+ "div",
15481
+ {
15482
+ onMouseDown: (e) => {
15483
+ e.preventDefault();
15484
+ setIsResizing(true);
15485
+ },
15486
+ style: {
15487
+ position: "absolute",
15488
+ width: "12px",
15489
+ height: "12px",
15490
+ right: 2,
15491
+ bottom: 2,
15492
+ background: "#ccc",
15493
+ borderRadius: "2px",
15494
+ cursor: "nwse-resize",
15495
+ zIndex: 10
15496
+ }
15497
+ }
15457
15498
  )
15458
15499
  );
15459
15500
  };
@@ -15465,12 +15506,8 @@ var ResizableImage = import_extension_image.default.extend({
15465
15506
  addAttributes() {
15466
15507
  return {
15467
15508
  ...this.parent?.(),
15468
- width: {
15469
- default: null
15470
- },
15471
- height: {
15472
- default: null
15473
- }
15509
+ width: { default: null },
15510
+ height: { default: null }
15474
15511
  };
15475
15512
  },
15476
15513
  renderHTML({ HTMLAttributes }) {
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  // src/components/tetrons/EditorContent.tsx
2
- import React14, { useEffect as useEffect8, useRef as useRef7, useState as useState8 } from "react";
2
+ import React14, { useEffect as useEffect8, useRef as useRef7, useState as useState9 } from "react";
3
3
  import {
4
4
  useEditor,
5
5
  EditorContent as TiptapEditorContent
@@ -15364,7 +15364,7 @@ import Image from "@tiptap/extension-image";
15364
15364
  import { ReactNodeViewRenderer } from "@tiptap/react";
15365
15365
 
15366
15366
  // src/components/tetrons/ResizableImageComponent.tsx
15367
- import React, { useRef, useEffect as useEffect2 } from "react";
15367
+ import React, { useRef, useEffect as useEffect2, useState as useState2 } from "react";
15368
15368
  import { NodeViewWrapper } from "@tiptap/react";
15369
15369
  var ResizableImageComponent = ({
15370
15370
  node,
@@ -15372,19 +15372,36 @@ var ResizableImageComponent = ({
15372
15372
  selected
15373
15373
  }) => {
15374
15374
  const { src, alt, title, width, height } = node.attrs;
15375
+ const defaultWidth = width ?? 300;
15376
+ const defaultHeight = height ?? 200;
15377
+ const aspectRatio = defaultHeight > 0 ? defaultWidth / defaultHeight : 4 / 3;
15375
15378
  const wrapperRef = useRef(null);
15376
- const imgRef = useRef(null);
15379
+ const [isResizing, setIsResizing] = useState2(false);
15377
15380
  useEffect2(() => {
15378
- const img = imgRef.current;
15379
- if (!img) return;
15380
- const observer = new ResizeObserver(() => {
15381
- const w = Math.round(img.offsetWidth);
15382
- const h = Math.round(img.offsetHeight);
15383
- updateAttributes({ width: w, height: h });
15384
- });
15385
- observer.observe(img);
15386
- return () => observer.disconnect();
15387
- }, [updateAttributes]);
15381
+ const handleMouseMove2 = (e) => {
15382
+ if (!isResizing || !wrapperRef.current) return;
15383
+ const rect = wrapperRef.current.getBoundingClientRect();
15384
+ const newWidth = e.clientX - rect.left;
15385
+ const newHeight = newWidth / aspectRatio;
15386
+ if (newWidth > 50 && newHeight > 50) {
15387
+ updateAttributes({
15388
+ width: Math.round(newWidth),
15389
+ height: Math.round(newHeight)
15390
+ });
15391
+ }
15392
+ };
15393
+ const handleMouseUp = () => {
15394
+ setIsResizing(false);
15395
+ };
15396
+ if (isResizing) {
15397
+ window.addEventListener("mousemove", handleMouseMove2);
15398
+ window.addEventListener("mouseup", handleMouseUp);
15399
+ }
15400
+ return () => {
15401
+ window.removeEventListener("mousemove", handleMouseMove2);
15402
+ window.removeEventListener("mouseup", handleMouseUp);
15403
+ };
15404
+ }, [isResizing, updateAttributes, aspectRatio]);
15388
15405
  return /* @__PURE__ */ React.createElement(
15389
15406
  NodeViewWrapper,
15390
15407
  {
@@ -15392,31 +15409,55 @@ var ResizableImageComponent = ({
15392
15409
  contentEditable: false,
15393
15410
  className: `resizable-image-wrapper ${selected ? "ProseMirror-selectednode" : ""}`,
15394
15411
  style: {
15395
- resize: "both",
15396
- overflow: "auto",
15412
+ position: "relative",
15397
15413
  border: "1px solid #ccc",
15398
- padding: 2,
15399
15414
  display: "inline-block",
15400
- maxWidth: "100%"
15415
+ width: `${defaultWidth}px`,
15416
+ height: `${defaultHeight}px`,
15417
+ minWidth: "50px",
15418
+ minHeight: "50px",
15419
+ maxWidth: "100%",
15420
+ userSelect: "none",
15421
+ padding: 2
15401
15422
  }
15402
15423
  },
15403
15424
  /* @__PURE__ */ React.createElement(
15404
15425
  "img",
15405
15426
  {
15406
- ref: imgRef,
15407
15427
  src,
15408
15428
  alt: alt ?? "",
15409
15429
  title: title ?? "",
15410
15430
  loading: "lazy",
15411
15431
  style: {
15412
- width: width ? `${width}px` : "auto",
15413
- height: height ? `${height}px` : "auto",
15432
+ width: "100%",
15433
+ height: "100%",
15434
+ objectFit: "contain",
15414
15435
  display: "block",
15415
15436
  userSelect: "none",
15416
15437
  pointerEvents: "auto"
15417
15438
  },
15418
15439
  draggable: false
15419
15440
  }
15441
+ ),
15442
+ /* @__PURE__ */ React.createElement(
15443
+ "div",
15444
+ {
15445
+ onMouseDown: (e) => {
15446
+ e.preventDefault();
15447
+ setIsResizing(true);
15448
+ },
15449
+ style: {
15450
+ position: "absolute",
15451
+ width: "12px",
15452
+ height: "12px",
15453
+ right: 2,
15454
+ bottom: 2,
15455
+ background: "#ccc",
15456
+ borderRadius: "2px",
15457
+ cursor: "nwse-resize",
15458
+ zIndex: 10
15459
+ }
15460
+ }
15420
15461
  )
15421
15462
  );
15422
15463
  };
@@ -15428,12 +15469,8 @@ var ResizableImage = Image.extend({
15428
15469
  addAttributes() {
15429
15470
  return {
15430
15471
  ...this.parent?.(),
15431
- width: {
15432
- default: null
15433
- },
15434
- height: {
15435
- default: null
15436
- }
15472
+ width: { default: null },
15473
+ height: { default: null }
15437
15474
  };
15438
15475
  },
15439
15476
  renderHTML({ HTMLAttributes }) {
@@ -15558,9 +15595,9 @@ var ResizableVideo = Node13.create({
15558
15595
  });
15559
15596
 
15560
15597
  // src/components/tetrons/toolbar/TableContextMenu.tsx
15561
- import React3, { useEffect as useEffect4, useState as useState2 } from "react";
15598
+ import React3, { useEffect as useEffect4, useState as useState3 } from "react";
15562
15599
  function TableContextMenu({ editor }) {
15563
- const [menuPosition, setMenuPosition] = useState2(null);
15600
+ const [menuPosition, setMenuPosition] = useState3(null);
15564
15601
  useEffect4(() => {
15565
15602
  const handleContextMenu = (event) => {
15566
15603
  const target = event.target;
@@ -15644,10 +15681,10 @@ function TableContextMenu({ editor }) {
15644
15681
  }
15645
15682
 
15646
15683
  // src/components/tetrons/toolbar/TetronsToolbar.tsx
15647
- import React13, { useEffect as useEffect7, useState as useState7 } from "react";
15684
+ import React13, { useEffect as useEffect7, useState as useState8 } from "react";
15648
15685
 
15649
15686
  // src/components/tetrons/toolbar/ActionGroup.tsx
15650
- import React5, { useEffect as useEffect5, useRef as useRef3, useState as useState3 } from "react";
15687
+ import React5, { useEffect as useEffect5, useRef as useRef3, useState as useState4 } from "react";
15651
15688
  import {
15652
15689
  MdZoomIn,
15653
15690
  MdZoomOut,
@@ -15680,7 +15717,7 @@ var ToolbarButton_default = ToolbarButton;
15680
15717
 
15681
15718
  // src/components/tetrons/toolbar/ActionGroup.tsx
15682
15719
  function ActionGroup({ editor }) {
15683
- const [dropdownOpen, setDropdownOpen] = useState3(false);
15720
+ const [dropdownOpen, setDropdownOpen] = useState4(false);
15684
15721
  const dropdownRef = useRef3(null);
15685
15722
  useEffect5(() => {
15686
15723
  const handleClickOutside = (event) => {
@@ -15925,12 +15962,12 @@ import {
15925
15962
  } from "react-icons/md";
15926
15963
  import { ImTextColor } from "react-icons/im";
15927
15964
  import { BiSolidColorFill } from "react-icons/bi";
15928
- import React7, { useEffect as useEffect6, useState as useState4 } from "react";
15965
+ import React7, { useEffect as useEffect6, useState as useState5 } from "react";
15929
15966
  function FontStyleGroup({ editor }) {
15930
- const [textColor, setTextColor] = useState4("#000000");
15931
- const [highlightColor, setHighlightColor] = useState4("#ffff00");
15932
- const [fontFamily, setFontFamily] = useState4("Arial");
15933
- const [fontSize, setFontSize] = useState4("16px");
15967
+ const [textColor, setTextColor] = useState5("#000000");
15968
+ const [highlightColor, setHighlightColor] = useState5("#ffff00");
15969
+ const [fontFamily, setFontFamily] = useState5("Arial");
15970
+ const [fontSize, setFontSize] = useState5("16px");
15934
15971
  useEffect6(() => {
15935
15972
  if (!editor) return;
15936
15973
  const updateStates = () => {
@@ -16105,7 +16142,7 @@ function FontStyleGroup({ editor }) {
16105
16142
  }
16106
16143
 
16107
16144
  // src/components/tetrons/toolbar/InsertGroup.tsx
16108
- import React8, { useRef as useRef4, useState as useState5 } from "react";
16145
+ import React8, { useRef as useRef4, useState as useState6 } from "react";
16109
16146
  import {
16110
16147
  MdTableChart,
16111
16148
  MdInsertPhoto,
@@ -16118,12 +16155,12 @@ import {
16118
16155
  } from "react-icons/md";
16119
16156
  import Picker from "@emoji-mart/react";
16120
16157
  function InsertGroup({ editor }) {
16121
- const [showTableGrid, setShowTableGrid] = useState5(false);
16122
- const [selectedRows, setSelectedRows] = useState5(1);
16123
- const [selectedCols, setSelectedCols] = useState5(1);
16158
+ const [showTableGrid, setShowTableGrid] = useState6(false);
16159
+ const [selectedRows, setSelectedRows] = useState6(1);
16160
+ const [selectedCols, setSelectedCols] = useState6(1);
16124
16161
  const imageInputRef = useRef4(null);
16125
16162
  const videoInputRef = useRef4(null);
16126
- const [showPicker, setShowPicker] = useState5(false);
16163
+ const [showPicker, setShowPicker] = useState6(false);
16127
16164
  const addEmoji = (emoji) => {
16128
16165
  editor.chain().focus().insertContent(emoji.native).run();
16129
16166
  setShowPicker(false);
@@ -16584,19 +16621,19 @@ function FileGroup({ editor }) {
16584
16621
  }
16585
16622
 
16586
16623
  // src/components/tetrons/toolbar/AIGroup.tsx
16587
- import React12, { useState as useState6, useRef as useRef6 } from "react";
16624
+ import React12, { useState as useState7, useRef as useRef6 } from "react";
16588
16625
  import { FaMicrophone, FaStop } from "react-icons/fa";
16589
16626
  import { Waveform } from "@uiball/loaders";
16590
16627
  import { motion, AnimatePresence } from "framer-motion";
16591
16628
  function AiGroup({ editor }) {
16592
- const [isRecording, setIsRecording] = useState6(false);
16593
- const [audioBlob, setAudioBlob] = useState6(null);
16594
- const [isTranscribing, setIsTranscribing] = useState6(false);
16595
- const [transcriptionError, setTranscriptionError] = useState6("");
16596
- const [showPromptInput, setShowPromptInput] = useState6(false);
16597
- const [prompt2, setPrompt] = useState6("");
16598
- const [isLoadingAI, setIsLoadingAI] = useState6(false);
16599
- const [aiError, setAiError] = useState6("");
16629
+ const [isRecording, setIsRecording] = useState7(false);
16630
+ const [audioBlob, setAudioBlob] = useState7(null);
16631
+ const [isTranscribing, setIsTranscribing] = useState7(false);
16632
+ const [transcriptionError, setTranscriptionError] = useState7("");
16633
+ const [showPromptInput, setShowPromptInput] = useState7(false);
16634
+ const [prompt2, setPrompt] = useState7("");
16635
+ const [isLoadingAI, setIsLoadingAI] = useState7(false);
16636
+ const [aiError, setAiError] = useState7("");
16600
16637
  const mediaRecorderRef = useRef6(null);
16601
16638
  const chunksRef = useRef6([]);
16602
16639
  const startRecording = async () => {
@@ -16750,7 +16787,7 @@ function TetronsToolbar({
16750
16787
  editor,
16751
16788
  version
16752
16789
  }) {
16753
- const [autoSave, setAutoSave] = useState7(false);
16790
+ const [autoSave, setAutoSave] = useState8(false);
16754
16791
  useEffect7(() => {
16755
16792
  if (!editor) return;
16756
16793
  const handleUpdate = () => {
@@ -16784,11 +16821,11 @@ lowlight.register("js", javascript);
16784
16821
  lowlight.register("ts", typescript);
16785
16822
  function EditorContent({ apiKey }) {
16786
16823
  const typo = useTypo();
16787
- const [isValid, setIsValid] = useState8(null);
16788
- const [error, setError] = useState8(null);
16789
- const [versions, setVersions] = useState8([]);
16790
- const [userVersion, setUserVersion] = useState8(null);
16791
- const [currentVersionIndex, setCurrentVersionIndex] = useState8(
16824
+ const [isValid, setIsValid] = useState9(null);
16825
+ const [error, setError] = useState9(null);
16826
+ const [versions, setVersions] = useState9([]);
16827
+ const [userVersion, setUserVersion] = useState9(null);
16828
+ const [currentVersionIndex, setCurrentVersionIndex] = useState9(
16792
16829
  null
16793
16830
  );
16794
16831
  const wrapperRef = useRef7(null);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tetrons",
3
- "version": "2.3.26",
3
+ "version": "2.3.27",
4
4
  "description": "A Next.js project written in TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,36 +0,0 @@
1
- var __rest = (this && this.__rest) || function (s, e) {
2
- var t = {};
3
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
4
- t[p] = s[p];
5
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
6
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
7
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
8
- t[p[i]] = s[p[i]];
9
- }
10
- return t;
11
- };
12
- import Image from "@tiptap/extension-image";
13
- import { ReactNodeViewRenderer } from "@tiptap/react";
14
- import ResizableImageComponent from "./ResizableImageComponent";
15
- export const ResizableImage = Image.extend({
16
- name: "resizableImage",
17
- addAttributes() {
18
- var _a;
19
- return Object.assign(Object.assign({}, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)), { width: { default: null }, height: { default: null } });
20
- },
21
- renderHTML({ HTMLAttributes }) {
22
- const { width, height } = HTMLAttributes, rest = __rest(HTMLAttributes, ["width", "height"]);
23
- const style = [];
24
- if (width)
25
- style.push(`width: ${width}px`);
26
- if (height)
27
- style.push(`height: ${height}px`);
28
- return [
29
- "img",
30
- Object.assign(Object.assign({}, rest), { style: style.join("; ") }),
31
- ];
32
- },
33
- addNodeView() {
34
- return ReactNodeViewRenderer(ResizableImageComponent);
35
- },
36
- });