tetrons 2.3.33 → 2.3.35

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.
Files changed (75) hide show
  1. package/dist/index.cjs +47 -8
  2. package/dist/index.d.mts +2 -1
  3. package/dist/index.d.ts +2 -1
  4. package/dist/index.mjs +46 -8
  5. package/dist/src/index.d.ts +7 -0
  6. package/dist/src/index.js +61 -0
  7. package/package.json +1 -1
  8. package/dist/app/api/export/route.js +0 -4
  9. package/dist/app/api/register/route.js +0 -32
  10. package/dist/app/api/save/route.js +0 -15
  11. package/dist/app/api/validate/route.js +0 -58
  12. package/dist/app/layout.d.ts +0 -6
  13. package/dist/app/layout.jsx +0 -30
  14. package/dist/app/page.jsx +0 -51
  15. package/dist/components/UI/Button.d.ts +0 -0
  16. package/dist/components/UI/Button.jsx +0 -1
  17. package/dist/components/UI/Dropdown.d.ts +0 -0
  18. package/dist/components/UI/Dropdown.jsx +0 -1
  19. package/dist/components/tetrons/EditorContent.jsx +0 -209
  20. package/dist/components/tetrons/ResizableVideo.d.ts +0 -12
  21. package/dist/components/tetrons/ResizableVideo.js +0 -61
  22. package/dist/components/tetrons/ResizableVideoComponent.d.ts +0 -4
  23. package/dist/components/tetrons/ResizableVideoComponent.jsx +0 -32
  24. package/dist/components/tetrons/helpers.d.ts +0 -0
  25. package/dist/components/tetrons/helpers.js +0 -1
  26. package/dist/components/tetrons/toolbar/ActionGroup.d.ts +0 -7
  27. package/dist/components/tetrons/toolbar/ActionGroup.jsx +0 -167
  28. package/dist/components/tetrons/toolbar/ClipboardGroup.d.ts +0 -5
  29. package/dist/components/tetrons/toolbar/ClipboardGroup.jsx +0 -36
  30. package/dist/components/tetrons/toolbar/FileGroup.d.ts +0 -7
  31. package/dist/components/tetrons/toolbar/FileGroup.jsx +0 -40
  32. package/dist/components/tetrons/toolbar/FontStyleGroup.d.ts +0 -7
  33. package/dist/components/tetrons/toolbar/FontStyleGroup.jsx +0 -104
  34. package/dist/components/tetrons/toolbar/InsertGroup.d.ts +0 -5
  35. package/dist/components/tetrons/toolbar/InsertGroup.jsx +0 -163
  36. package/dist/components/tetrons/toolbar/ListAlignGroup.d.ts +0 -5
  37. package/dist/components/tetrons/toolbar/ListAlignGroup.jsx +0 -16
  38. package/dist/components/tetrons/toolbar/MiscGroup.d.ts +0 -7
  39. package/dist/components/tetrons/toolbar/MiscGroup.jsx +0 -31
  40. package/dist/components/tetrons/toolbar/TableContextMenu.d.ts +0 -7
  41. package/dist/components/tetrons/toolbar/TableContextMenu.jsx +0 -52
  42. package/dist/components/tetrons/toolbar/TetronsToolbar.d.ts +0 -6
  43. package/dist/components/tetrons/toolbar/TetronsToolbar.jsx +0 -46
  44. package/dist/components/tetrons/toolbar/ToolbarButton.d.ts +0 -12
  45. package/dist/components/tetrons/toolbar/ToolbarButton.jsx +0 -8
  46. package/dist/components/tetrons/toolbar/extensions/Comment.d.ts +0 -17
  47. package/dist/components/tetrons/toolbar/extensions/Comment.js +0 -45
  48. package/dist/components/tetrons/toolbar/extensions/Embed.d.ts +0 -2
  49. package/dist/components/tetrons/toolbar/extensions/Embed.js +0 -90
  50. package/dist/components/tetrons/toolbar/extensions/FontFamily.d.ts +0 -9
  51. package/dist/components/tetrons/toolbar/extensions/FontFamily.js +0 -28
  52. package/dist/components/tetrons/toolbar/extensions/FontSize.d.ts +0 -9
  53. package/dist/components/tetrons/toolbar/extensions/FontSize.js +0 -28
  54. package/dist/components/tetrons/toolbar/extensions/ResizableTable.d.ts +0 -1
  55. package/dist/components/tetrons/toolbar/extensions/ResizableTable.js +0 -11
  56. package/dist/components/tetrons/toolbar/marks/Subscript.d.ts +0 -2
  57. package/dist/components/tetrons/toolbar/marks/Subscript.js +0 -35
  58. package/dist/components/tetrons/toolbar/marks/Superscript.d.ts +0 -2
  59. package/dist/components/tetrons/toolbar/marks/Superscript.js +0 -35
  60. package/dist/lib/db.d.ts +0 -1
  61. package/dist/lib/db.js +0 -15
  62. package/dist/lib/export.d.ts +0 -0
  63. package/dist/lib/export.js +0 -1
  64. package/dist/lib/tiptap-extensions.d.ts +0 -0
  65. package/dist/lib/tiptap-extensions.js +0 -1
  66. package/dist/models/ApiKey.d.ts +0 -2
  67. package/dist/models/ApiKey.js +0 -14
  68. package/dist/src/app/page.d.ts +0 -2
  69. package/dist/src/app/page.jsx +0 -51
  70. package/dist/src/components/tetrons/toolbar/AIGroup.d.ts +0 -5
  71. package/dist/src/components/tetrons/toolbar/AIGroup.jsx +0 -140
  72. package/dist/utils/apiKeyUtils.d.ts +0 -11
  73. package/dist/utils/apiKeyUtils.js +0 -33
  74. package/dist/utils/loadEmojiPicker.d.ts +0 -1
  75. package/dist/utils/loadEmojiPicker.js +0 -12
@@ -1,104 +0,0 @@
1
- "use client";
2
- import { MdFormatBold, MdFormatItalic, MdFormatUnderlined, MdStrikethroughS, MdSubscript, MdSuperscript, MdFormatClear, MdFormatPaint, } from "react-icons/md";
3
- import { ImTextColor } from "react-icons/im";
4
- import { BiSolidColorFill } from "react-icons/bi";
5
- import ToolbarButton from "./ToolbarButton";
6
- import React, { useEffect, useState } from "react";
7
- export default function FontStyleGroup({ editor }) {
8
- const [textColor, setTextColor] = useState("#000000");
9
- const [highlightColor, setHighlightColor] = useState("#ffff00");
10
- const [fontFamily, setFontFamily] = useState("Arial");
11
- const [fontSize, setFontSize] = useState("16px");
12
- useEffect(() => {
13
- if (!editor)
14
- return;
15
- const updateStates = () => {
16
- var _a, _b, _c;
17
- const highlight = editor.getAttributes("highlight");
18
- setHighlightColor((highlight === null || highlight === void 0 ? void 0 : highlight.color) || "#ffff00");
19
- const color = (_a = editor.getAttributes("textStyle")) === null || _a === void 0 ? void 0 : _a.color;
20
- setTextColor(color || "#000000");
21
- const fontAttr = ((_b = editor.getAttributes("fontFamily")) === null || _b === void 0 ? void 0 : _b.font) || "Arial";
22
- setFontFamily(fontAttr);
23
- const sizeAttr = ((_c = editor.getAttributes("fontSize")) === null || _c === void 0 ? void 0 : _c.size) || "16px";
24
- setFontSize(sizeAttr);
25
- };
26
- updateStates();
27
- editor.on("selectionUpdate", updateStates);
28
- editor.on("transaction", updateStates);
29
- return () => {
30
- editor.off("selectionUpdate", updateStates);
31
- editor.off("transaction", updateStates);
32
- };
33
- }, [editor]);
34
- return (<div className="font-style-group">
35
- <select title="Font Family" value={fontFamily} onChange={(e) => {
36
- const value = e.target.value;
37
- setFontFamily(value);
38
- editor.chain().focus().setFontFamily(value).run();
39
- }}>
40
- <option value="Arial">Arial</option>
41
- <option value="Georgia">Georgia</option>
42
- <option value="Times New Roman">Times New Roman</option>
43
- <option value="Courier New">Courier New</option>
44
- <option value="Verdana">Verdana</option>
45
- </select>
46
-
47
- <select title="Font Size" value={fontSize} onChange={(e) => {
48
- const value = e.target.value;
49
- setFontSize(value);
50
- editor.chain().focus().setFontSize(value).run();
51
- }}>
52
- <option value="12px">12</option>
53
- <option value="14px">14</option>
54
- <option value="16px">16</option>
55
- <option value="18px">18</option>
56
- <option value="24px">24</option>
57
- <option value="36px">36</option>
58
- <option value="48px">48</option>
59
- <option value="64px">64</option>
60
- <option value="72px">72</option>
61
- </select>
62
-
63
- <ToolbarButton icon={MdFormatBold} label="Bold" onClick={() => editor.chain().focus().toggleBold().run()} isActive={editor.isActive("bold")}/>
64
- <ToolbarButton icon={MdFormatItalic} label="Italic" onClick={() => editor.chain().focus().toggleItalic().run()} isActive={editor.isActive("italic")}/>
65
- <ToolbarButton icon={MdFormatUnderlined} label="Underline" onClick={() => editor.chain().focus().toggleUnderline().run()} isActive={editor.isActive("underline")}/>
66
- <ToolbarButton icon={MdStrikethroughS} label="Strikethrough" onClick={() => editor.chain().focus().toggleStrike().run()} isActive={editor.isActive("strike")}/>
67
- <ToolbarButton icon={MdSubscript} label="Subscript" onClick={() => editor.chain().focus().toggleSubscript().run()} isActive={editor.isActive("subscript")}/>
68
- <ToolbarButton icon={MdSuperscript} label="Superscript" onClick={() => editor.chain().focus().toggleSuperscript().run()} isActive={editor.isActive("superscript")}/>
69
-
70
- <label title="Font Color" aria-label="Font Color" className="color-label" style={{ "--indicator-color": textColor }}>
71
- <ImTextColor size={20}/>
72
- <div className="color-indicator"/>
73
- <input type="color" value={textColor} onChange={(e) => {
74
- const color = e.target.value;
75
- setTextColor(color);
76
- editor.chain().focus().setColor(color).run();
77
- }}/>
78
- </label>
79
-
80
- <label title="Highlight Color" aria-label="Highlight Color" className="color-label" style={{ "--indicator-color": highlightColor }}>
81
- <BiSolidColorFill size={20}/>
82
- <div className="color-indicator"/>
83
- <input type="color" value={highlightColor} onChange={(e) => {
84
- const color = e.target.value;
85
- setHighlightColor(color);
86
- editor.chain().focus().setHighlight({ color }).run();
87
- }}/>
88
- </label>
89
-
90
- <ToolbarButton icon={MdFormatClear} label="Clear Formatting" onClick={() => editor.chain().focus().unsetAllMarks().run()}/>
91
- <ToolbarButton icon={MdFormatPaint} label="Apply Painter Format" onClick={() => {
92
- const format = JSON.parse(localStorage.getItem("formatPainter") || "{}");
93
- if (format.color)
94
- editor.chain().focus().setColor(format.color).run();
95
- if (format.backgroundColor) {
96
- editor
97
- .chain()
98
- .focus()
99
- .setHighlight({ color: format.backgroundColor })
100
- .run();
101
- }
102
- }}/>
103
- </div>);
104
- }
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- import { Editor } from "@tiptap/react";
3
- export default function InsertGroup({ editor }: {
4
- editor: Editor;
5
- }): React.JSX.Element;
@@ -1,163 +0,0 @@
1
- "use client";
2
- import React, { useRef, useState } from "react";
3
- import { MdTableChart, MdInsertPhoto, MdInsertLink, MdInsertComment, MdInsertEmoticon, MdHorizontalRule, MdVideoLibrary, MdOutlineOndemandVideo, } from "react-icons/md";
4
- import ToolbarButton from "./ToolbarButton";
5
- import Picker from "@emoji-mart/react";
6
- export default function InsertGroup({ editor }) {
7
- const [showTableGrid, setShowTableGrid] = useState(false);
8
- const [selectedRows, setSelectedRows] = useState(1);
9
- const [selectedCols, setSelectedCols] = useState(1);
10
- const imageInputRef = useRef(null);
11
- const videoInputRef = useRef(null);
12
- const [showPicker, setShowPicker] = useState(false);
13
- const addEmoji = (emoji) => {
14
- editor.chain().focus().insertContent(emoji.native).run();
15
- setShowPicker(false);
16
- };
17
- const handleTableCellHover = (row, col) => {
18
- setSelectedRows(row);
19
- setSelectedCols(col);
20
- };
21
- const handleTableInsert = (rows, cols) => {
22
- editor
23
- .chain()
24
- .focus()
25
- .insertTable({
26
- rows: rows || 1,
27
- cols: cols || 1,
28
- withHeaderRow: true,
29
- })
30
- .run();
31
- setShowTableGrid(false);
32
- setSelectedRows(1);
33
- setSelectedCols(1);
34
- };
35
- const handleImageUpload = (e) => {
36
- var _a;
37
- const file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
38
- if (file) {
39
- const reader = new FileReader();
40
- reader.onload = () => {
41
- editor
42
- .chain()
43
- .focus()
44
- .setImage({ src: reader.result })
45
- .run();
46
- };
47
- reader.readAsDataURL(file);
48
- }
49
- };
50
- const handleVideoUpload = (e) => {
51
- var _a;
52
- const file = (_a = e.target.files) === null || _a === void 0 ? void 0 : _a[0];
53
- if (file) {
54
- const reader = new FileReader();
55
- reader.onload = () => {
56
- editor
57
- .chain()
58
- .focus()
59
- .setVideo({ src: reader.result, controls: true })
60
- .run();
61
- };
62
- reader.readAsDataURL(file);
63
- }
64
- };
65
- function normalizeEmbedUrl(url) {
66
- try {
67
- const u = new URL(url);
68
- const hostname = u.hostname.replace("www.", "").toLowerCase();
69
- if (hostname === "youtube.com" || hostname === "youtu.be") {
70
- let videoId = u.searchParams.get("v");
71
- if (!videoId && hostname === "youtu.be") {
72
- videoId = u.pathname.slice(1);
73
- }
74
- if (videoId) {
75
- return `https://www.youtube.com/embed/${videoId}`;
76
- }
77
- }
78
- if (hostname === "vimeo.com") {
79
- const videoId = u.pathname.split("/")[1];
80
- if (videoId) {
81
- return `https://player.vimeo.com/video/${videoId}`;
82
- }
83
- }
84
- if (hostname === "google.com" ||
85
- hostname === "maps.google.com" ||
86
- hostname === "goo.gl") {
87
- if (url.includes("/maps/embed")) {
88
- return url;
89
- }
90
- return url.replace("/maps/", "/maps/embed/");
91
- }
92
- return url;
93
- }
94
- catch (_a) {
95
- return url;
96
- }
97
- }
98
- return (<div className="insert-group">
99
- <input type="file" accept="image/*" ref={imageInputRef} className="hidden-input" onChange={handleImageUpload} aria-label="Upload Image" title="Upload Image"/>
100
- <input type="file" accept="video/*" ref={videoInputRef} className="hidden-input" onChange={handleVideoUpload} aria-label="Upload Video" title="Upload Video"/>
101
-
102
- <ToolbarButton icon={MdTableChart} label="Insert Table" onClick={() => setShowTableGrid(!showTableGrid)}/>
103
- {showTableGrid && (<div className="table-grid-popup" onMouseLeave={() => setShowTableGrid(false)}>
104
- <div className="table-grid">
105
- {[...Array(10)].map((_, row) => [...Array(10)].map((_, col) => {
106
- const isSelected = row < selectedRows && col < selectedCols;
107
- return (<div key={`${row}-${col}`} className={`table-grid-cell ${isSelected ? "selected" : ""}`} onMouseEnter={() => handleTableCellHover(row + 1, col + 1)} onClick={() => handleTableInsert(row + 1, col + 1)}/>);
108
- }))}
109
- </div>
110
- <div className="table-grid-label">
111
- {selectedRows} x {selectedCols}
112
- </div>
113
- </div>)}
114
-
115
- <ToolbarButton icon={MdInsertPhoto} label="Insert Image" onClick={() => { var _a; return (_a = imageInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }}/>
116
- <ToolbarButton icon={MdVideoLibrary} label="Insert Video" onClick={() => { var _a; return (_a = videoInputRef.current) === null || _a === void 0 ? void 0 : _a.click(); }}/>
117
- <ToolbarButton icon={MdInsertLink} label="Insert Link" onClick={() => {
118
- const url = prompt("Enter URL");
119
- if (url) {
120
- editor
121
- .chain()
122
- .focus()
123
- .extendMarkRange("link")
124
- .setLink({ href: url })
125
- .run();
126
- }
127
- }}/>
128
- <ToolbarButton icon={MdInsertComment} label="Insert Comment" onClick={() => {
129
- const comment = prompt("Enter your comment");
130
- if (comment &&
131
- editor.can().chain().focus().setComment(comment).run()) {
132
- editor.chain().focus().setComment(comment).run();
133
- }
134
- else {
135
- console.warn("Cannot apply comment — maybe no selection?");
136
- }
137
- }}/>
138
- <div className="relative">
139
- <ToolbarButton icon={MdInsertEmoticon} label="Emoji" onClick={() => setShowPicker(!showPicker)}/>
140
- {showPicker && (<div className="emoji-picker">
141
- <Picker onEmojiSelect={addEmoji} theme="auto" emoji="point_up" showPreview={false} showSkinTones={true} emojiTooltip={true}/>
142
- </div>)}
143
- </div>
144
- <ToolbarButton icon={MdHorizontalRule} label="Horizontal Line" onClick={() => editor.chain().focus().setHorizontalRule().run()}/>
145
- <ToolbarButton icon={MdOutlineOndemandVideo} label="Embed" onClick={() => {
146
- const url = prompt("Enter embed URL (YouTube, Vimeo, Google Maps, etc.)");
147
- if (!url)
148
- return;
149
- const embedUrl = normalizeEmbedUrl(url);
150
- const width = prompt("Enter width in pixels", "560");
151
- const height = prompt("Enter height in pixels", "315");
152
- editor
153
- .chain()
154
- .focus()
155
- .setEmbed({
156
- src: embedUrl,
157
- width: width ? parseInt(width) : 560,
158
- height: height ? parseInt(height) : 315,
159
- })
160
- .run();
161
- }}/>
162
- </div>);
163
- }
@@ -1,5 +0,0 @@
1
- import React from "react";
2
- import { Editor } from "@tiptap/react";
3
- export default function ListAlignGroup({ editor }: {
4
- editor: Editor;
5
- }): React.JSX.Element;
@@ -1,16 +0,0 @@
1
- "use client";
2
- import React from "react";
3
- import { MdFormatListBulleted, MdFormatListNumbered, MdFormatIndentDecrease, MdFormatIndentIncrease, MdFormatAlignLeft, MdFormatAlignCenter, MdFormatAlignRight, MdFormatAlignJustify, } from "react-icons/md";
4
- import ToolbarButton from "./ToolbarButton";
5
- export default function ListAlignGroup({ editor }) {
6
- return (<div className="list-align-group">
7
- <ToolbarButton icon={MdFormatListBulleted} title="Bulleted List" onClick={() => editor.chain().focus().toggleBulletList().run()} disabled={!editor.can().toggleBulletList()}/>
8
- <ToolbarButton icon={MdFormatListNumbered} title="Numbered List" onClick={() => editor.chain().focus().toggleOrderedList().run()} disabled={!editor.can().toggleOrderedList()}/>
9
- <ToolbarButton icon={MdFormatIndentIncrease} title="Increase Indent" onClick={() => editor.chain().focus().sinkListItem("listItem").run()} disabled={!editor.can().sinkListItem("listItem")}/>
10
- <ToolbarButton icon={MdFormatIndentDecrease} title="Decrease Indent" onClick={() => editor.chain().focus().liftListItem("listItem").run()} disabled={!editor.can().liftListItem("listItem")}/>
11
- <ToolbarButton icon={MdFormatAlignLeft} title="Align Left" onClick={() => editor.chain().focus().setTextAlign("left").run()} disabled={!editor.can().setTextAlign("left")}/>
12
- <ToolbarButton icon={MdFormatAlignCenter} title="Align Center" onClick={() => editor.chain().focus().setTextAlign("center").run()} disabled={!editor.can().setTextAlign("center")}/>
13
- <ToolbarButton icon={MdFormatAlignRight} title="Align Right" onClick={() => editor.chain().focus().setTextAlign("right").run()} disabled={!editor.can().setTextAlign("right")}/>
14
- <ToolbarButton icon={MdFormatAlignJustify} title="Justify" onClick={() => editor.chain().focus().setTextAlign("justify").run()} disabled={!editor.can().setTextAlign("justify")}/>
15
- </div>);
16
- }
@@ -1,7 +0,0 @@
1
- import React from "react";
2
- import { Editor } from "@tiptap/react";
3
- interface MiscGroupProps {
4
- editor: Editor;
5
- }
6
- export default function MiscGroup({ editor }: MiscGroupProps): React.JSX.Element;
7
- export {};
@@ -1,31 +0,0 @@
1
- import React from "react";
2
- import { MdUndo, MdRedo, MdRefresh, MdVisibility, MdCode, } from "react-icons/md";
3
- import ToolbarButton from "./ToolbarButton";
4
- export default function MiscGroup({ editor }) {
5
- const handlePreview = () => {
6
- const html = editor.getHTML();
7
- const previewWindow = window.open("", "_blank");
8
- if (previewWindow) {
9
- previewWindow.document.open();
10
- previewWindow.document.write(`
11
- <html>
12
- <head>
13
- <title>Preview</title>
14
- <style>
15
- body { font-family: sans-serif; padding: 2rem; line-height: 1.6; }
16
- </style>
17
- </head>
18
- <body>${html}</body>
19
- </html>
20
- `);
21
- previewWindow.document.close();
22
- }
23
- };
24
- return (<div className="misc-group">
25
- <ToolbarButton icon={MdUndo} label="Undo" onClick={() => editor.chain().focus().undo().run()} disabled={!editor.can().undo()}/>
26
- <ToolbarButton icon={MdRedo} label="Redo" onClick={() => editor.chain().focus().redo().run()} disabled={!editor.can().redo()}/>
27
- <ToolbarButton icon={MdRefresh} label="Reset Formatting" onClick={() => editor.chain().focus().unsetAllMarks().clearNodes().run()}/>
28
- <ToolbarButton icon={MdCode} label="Toggle Code Block" onClick={() => editor.chain().focus().toggleCodeBlock().run()} isActive={editor.isActive("codeBlock")}/>
29
- <ToolbarButton icon={MdVisibility} label="Preview" onClick={handlePreview}/>
30
- </div>);
31
- }
@@ -1,7 +0,0 @@
1
- import React from "react";
2
- import { Editor } from "@tiptap/react";
3
- interface ContextMenuProps {
4
- editor: Editor;
5
- }
6
- export default function TableContextMenu({ editor }: ContextMenuProps): React.JSX.Element | null;
7
- export {};
@@ -1,52 +0,0 @@
1
- "use client";
2
- import React, { useEffect, useState } from "react";
3
- export default function TableContextMenu({ editor }) {
4
- const [menuPosition, setMenuPosition] = useState(null);
5
- useEffect(() => {
6
- const handleContextMenu = (event) => {
7
- const target = event.target;
8
- if (target.closest("td") || target.closest("th")) {
9
- event.preventDefault();
10
- setMenuPosition({ x: event.pageX, y: event.pageY });
11
- }
12
- else {
13
- setMenuPosition(null);
14
- }
15
- };
16
- const handleClick = () => setMenuPosition(null);
17
- document.addEventListener("contextmenu", handleContextMenu);
18
- document.addEventListener("click", handleClick);
19
- return () => {
20
- document.removeEventListener("contextmenu", handleContextMenu);
21
- document.removeEventListener("click", handleClick);
22
- };
23
- }, []);
24
- const insertRowAbove = () => editor.chain().focus().addRowBefore().run();
25
- const insertRowBelow = () => editor.chain().focus().addRowAfter().run();
26
- const insertColLeft = () => editor.chain().focus().addColumnBefore().run();
27
- const insertColRight = () => editor.chain().focus().addColumnAfter().run();
28
- const deleteRow = () => editor.chain().focus().deleteRow().run();
29
- const deleteCol = () => editor.chain().focus().deleteColumn().run();
30
- if (!menuPosition)
31
- return null;
32
- return (<ul className="absolute bg-white shadow border rounded text-sm z-50" style={{ top: menuPosition.y, left: menuPosition.x }}>
33
- <li className="px-3 py-1 hover:bg-gray-100 cursor-pointer" onClick={insertRowAbove}>
34
- Insert Row Above
35
- </li>
36
- <li className="px-3 py-1 hover:bg-gray-100 cursor-pointer" onClick={insertRowBelow}>
37
- Insert Row Below
38
- </li>
39
- <li className="px-3 py-1 hover:bg-gray-100 cursor-pointer" onClick={insertColLeft}>
40
- Insert Column Left
41
- </li>
42
- <li className="px-3 py-1 hover:bg-gray-100 cursor-pointer" onClick={insertColRight}>
43
- Insert Column Right
44
- </li>
45
- <li className="px-3 py-1 hover:bg-red-100 cursor-pointer" onClick={deleteRow}>
46
- Delete Row
47
- </li>
48
- <li className="px-3 py-1 hover:bg-red-100 cursor-pointer" onClick={deleteCol}>
49
- Delete Column
50
- </li>
51
- </ul>);
52
- }
@@ -1,6 +0,0 @@
1
- import React from "react";
2
- import type { Editor } from "@tiptap/react";
3
- export default function TetronsToolbar({ editor, version, }: {
4
- editor: Editor;
5
- version: "free" | "pro" | "premium" | "platinum";
6
- }): React.JSX.Element;
@@ -1,46 +0,0 @@
1
- "use client";
2
- import React, { useEffect, useState } from "react";
3
- import ActionGroup from "./ActionGroup";
4
- import ClipboardGroup from "./ClipboardGroup";
5
- import FontStyleGroup from "./FontStyleGroup";
6
- import InsertGroup from "./InsertGroup";
7
- import ListAlignGroup from "./ListAlignGroup";
8
- import MiscGroup from "./MiscGroup";
9
- import FileGroup from "./FileGroup";
10
- export default function TetronsToolbar({ editor, version, }) {
11
- const [autoSave, setAutoSave] = useState(false);
12
- useEffect(() => {
13
- if (!editor)
14
- return;
15
- const handleUpdate = () => {
16
- if (!autoSave)
17
- return;
18
- const content = editor.getJSON();
19
- fetch("/api/save", {
20
- method: "POST",
21
- headers: { "Content-Type": "application/json" },
22
- body: JSON.stringify(content),
23
- }).catch((err) => console.error("Auto-save failed:", err));
24
- };
25
- editor.on("update", handleUpdate);
26
- return () => {
27
- editor.off("update", handleUpdate);
28
- };
29
- }, [autoSave, editor]);
30
- return (<div className="tetrons-toolbar">
31
- {version !== "free" && (<div className="group">
32
- <input type="checkbox" id="autoSave" checked={autoSave} onChange={(e) => setAutoSave(e.target.checked)}/>
33
- <label htmlFor="autoSave">Auto Save</label>
34
- </div>)}
35
-
36
- {["pro", "premium", "platinum"].includes(version) && (<FileGroup editor={editor}/>)}
37
- <ClipboardGroup editor={editor}/>
38
- <FontStyleGroup editor={editor}/>
39
- <ListAlignGroup editor={editor}/>
40
- {["premium", "platinum"].includes(version) && (<>
41
- <InsertGroup editor={editor}/>
42
- <ActionGroup editor={editor}/>
43
- </>)}
44
- {version === "platinum" && <MiscGroup editor={editor}/>}
45
- </div>);
46
- }
@@ -1,12 +0,0 @@
1
- import React from "react";
2
- import type { IconType } from "react-icons";
3
- export type ToolbarButtonProps = {
4
- icon: IconType;
5
- onClick: () => void;
6
- disabled?: boolean;
7
- title?: string;
8
- label?: string;
9
- isActive?: boolean;
10
- };
11
- declare const ToolbarButton: React.ForwardRefExoticComponent<ToolbarButtonProps & React.RefAttributes<HTMLButtonElement>>;
12
- export default ToolbarButton;
@@ -1,8 +0,0 @@
1
- import React from "react";
2
- const ToolbarButton = React.forwardRef(({ icon: Icon, onClick, disabled = false, title, label, isActive = false }, ref) => {
3
- return (<button type="button" ref={ref} onClick={onClick} disabled={disabled} title={title !== null && title !== void 0 ? title : label} aria-label={title !== null && title !== void 0 ? title : label} className={`toolbar-button ${isActive ? "active" : ""}`}>
4
- <Icon size={20}/>
5
- </button>);
6
- });
7
- ToolbarButton.displayName = "ToolbarButton";
8
- export default ToolbarButton;
@@ -1,17 +0,0 @@
1
- import { Mark } from "@tiptap/core";
2
- export interface CommentOptions {
3
- HTMLAttributes: {
4
- class?: string;
5
- style?: string;
6
- [key: string]: unknown;
7
- };
8
- }
9
- declare module "@tiptap/core" {
10
- interface Commands<ReturnType> {
11
- comment: {
12
- setComment: (comment: string) => ReturnType;
13
- unsetComment: () => ReturnType;
14
- };
15
- }
16
- }
17
- export declare const Comment: Mark<CommentOptions, any>;
@@ -1,45 +0,0 @@
1
- import { Mark, mergeAttributes } from "@tiptap/core";
2
- export const Comment = Mark.create({
3
- name: "comment",
4
- addOptions() {
5
- return {
6
- HTMLAttributes: {},
7
- };
8
- },
9
- addAttributes() {
10
- return {
11
- comment: {
12
- default: "",
13
- },
14
- };
15
- },
16
- parseHTML() {
17
- return [
18
- {
19
- tag: "span[data-comment]",
20
- },
21
- ];
22
- },
23
- renderHTML({ HTMLAttributes }) {
24
- return [
25
- "span",
26
- mergeAttributes(HTMLAttributes, {
27
- "data-comment": HTMLAttributes.comment,
28
- class: "comment-highlight",
29
- title: HTMLAttributes.comment,
30
- style: "background-color: rgba(255, 230, 0, 0.3);",
31
- }),
32
- 0,
33
- ];
34
- },
35
- addCommands() {
36
- return {
37
- setComment: (comment) => ({ commands }) => {
38
- return commands.setMark(this.name, { comment });
39
- },
40
- unsetComment: () => ({ commands }) => {
41
- return commands.unsetMark(this.name);
42
- },
43
- };
44
- },
45
- });
@@ -1,2 +0,0 @@
1
- import { Node } from "@tiptap/core";
2
- export declare const Embed: Node<any, any>;
@@ -1,90 +0,0 @@
1
- import { Node, mergeAttributes } from "@tiptap/core";
2
- export const Embed = Node.create({
3
- name: "embed",
4
- group: "block",
5
- atom: true,
6
- addAttributes() {
7
- return {
8
- src: { default: null },
9
- width: { default: 560 },
10
- height: { default: 315 },
11
- };
12
- },
13
- parseHTML() {
14
- return [{ tag: "iframe[src]" }];
15
- },
16
- renderHTML({ HTMLAttributes }) {
17
- return ["iframe", mergeAttributes(HTMLAttributes)];
18
- },
19
- addCommands() {
20
- return {
21
- setEmbed: ((attributes) => {
22
- return ({ chain }) => {
23
- return chain()
24
- .insertContent({
25
- type: this.name,
26
- attrs: attributes,
27
- })
28
- .run();
29
- };
30
- }).bind(this),
31
- };
32
- },
33
- addNodeView() {
34
- return ({ node, getPos, editor }) => {
35
- const container = document.createElement('div');
36
- container.style.position = 'relative';
37
- container.style.display = 'inline-block';
38
- container.style.width = node.attrs.width + 'px';
39
- container.style.height = node.attrs.height + 'px';
40
- const iframe = document.createElement('iframe');
41
- iframe.setAttribute('src', node.attrs.src);
42
- iframe.setAttribute('frameborder', '0');
43
- iframe.setAttribute('allowfullscreen', 'true');
44
- iframe.style.width = '100%';
45
- iframe.style.height = '100%';
46
- container.appendChild(iframe);
47
- const handle = document.createElement('div');
48
- handle.style.position = 'absolute';
49
- handle.style.width = '16px';
50
- handle.style.height = '16px';
51
- handle.style.right = '0';
52
- handle.style.bottom = '0';
53
- handle.style.cursor = 'se-resize';
54
- handle.style.background = 'rgba(0,0,0,0.5)';
55
- handle.style.borderRadius = '2px';
56
- container.appendChild(handle);
57
- let startX, startY, startWidth, startHeight;
58
- const onMouseDown = (event) => {
59
- event.preventDefault();
60
- startX = event.clientX;
61
- startY = event.clientY;
62
- startWidth = container.offsetWidth;
63
- startHeight = container.offsetHeight;
64
- window.addEventListener('mousemove', onMouseMove);
65
- window.addEventListener('mouseup', onMouseUp);
66
- };
67
- const onMouseMove = (event) => {
68
- const newWidth = Math.max(100, startWidth + (event.clientX - startX));
69
- const newHeight = Math.max(100, startHeight + (event.clientY - startY));
70
- container.style.width = newWidth + 'px';
71
- container.style.height = newHeight + 'px';
72
- };
73
- const onMouseUp = () => {
74
- window.removeEventListener("mousemove", onMouseMove);
75
- window.removeEventListener("mouseup", onMouseUp);
76
- editor.commands.command(({ tr }) => {
77
- tr.setNodeMarkup(getPos(), undefined, Object.assign(Object.assign({}, node.attrs), { width: container.offsetWidth, height: container.offsetHeight }));
78
- return true;
79
- });
80
- };
81
- handle.addEventListener('mousedown', onMouseDown);
82
- return {
83
- dom: container,
84
- destroy() {
85
- handle.removeEventListener('mousedown', onMouseDown);
86
- }
87
- };
88
- };
89
- },
90
- });
@@ -1,9 +0,0 @@
1
- import { Mark } from '@tiptap/core';
2
- declare module '@tiptap/core' {
3
- interface Commands<ReturnType> {
4
- fontFamily: {
5
- setFontFamily: (font: string) => ReturnType;
6
- };
7
- }
8
- }
9
- export declare const FontFamily: Mark<any, any>;