tetrons 2.3.21 → 2.3.23

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 (29) hide show
  1. package/dist/components/UI/Button.tsx +0 -0
  2. package/dist/components/UI/Dropdown.tsx +0 -0
  3. package/dist/components/tetrons/EditorContent.tsx +282 -0
  4. package/dist/components/tetrons/ResizableImage.ts +39 -0
  5. package/dist/components/tetrons/ResizableImageComponent.tsx +77 -0
  6. package/dist/components/tetrons/ResizableVideo.ts +66 -0
  7. package/dist/components/tetrons/ResizableVideoComponent.tsx +56 -0
  8. package/dist/components/tetrons/helpers.ts +0 -0
  9. package/dist/components/tetrons/toolbar/ActionGroup.tsx +218 -0
  10. package/dist/components/tetrons/toolbar/ClipboardGroup.tsx +58 -0
  11. package/dist/components/tetrons/toolbar/FileGroup.tsx +66 -0
  12. package/dist/components/tetrons/toolbar/FontStyleGroup.tsx +194 -0
  13. package/dist/components/tetrons/toolbar/InsertGroup.tsx +267 -0
  14. package/dist/components/tetrons/toolbar/ListAlignGroup.tsx +69 -0
  15. package/dist/components/tetrons/toolbar/MiscGroup.tsx +71 -0
  16. package/dist/components/tetrons/toolbar/TableContextMenu.tsx +91 -0
  17. package/dist/components/tetrons/toolbar/TetronsToolbar.tsx +71 -0
  18. package/dist/components/tetrons/toolbar/ToolbarButton.tsx +36 -0
  19. package/dist/components/tetrons/toolbar/extensions/Comment.ts +72 -0
  20. package/dist/components/tetrons/toolbar/extensions/Embed.ts +113 -0
  21. package/dist/components/tetrons/toolbar/extensions/FontFamily.ts +43 -0
  22. package/dist/components/tetrons/toolbar/extensions/FontSize.ts +43 -0
  23. package/dist/components/tetrons/toolbar/extensions/ResizableTable.ts +16 -0
  24. package/dist/components/tetrons/toolbar/marks/Subscript.ts +45 -0
  25. package/dist/components/tetrons/toolbar/marks/Superscript.ts +45 -0
  26. package/dist/index.js +0 -1
  27. package/dist/index.mjs +0 -1
  28. package/package.json +7 -7
  29. package/dist/tetrons-UCHWNATC.css +0 -372
@@ -0,0 +1,113 @@
1
+ import { Node, mergeAttributes, CommandProps } from "@tiptap/core";
2
+
3
+ export const Embed = Node.create({
4
+ name: "embed",
5
+ group: "block",
6
+ atom: true,
7
+
8
+ addAttributes() {
9
+ return {
10
+ src: { default: null },
11
+ width: { default: 560 },
12
+ height: { default: 315 },
13
+ };
14
+ },
15
+
16
+ parseHTML() {
17
+ return [{ tag: "iframe[src]" }];
18
+ },
19
+
20
+ renderHTML({ HTMLAttributes }) {
21
+ return ["iframe", mergeAttributes(HTMLAttributes)];
22
+ },
23
+
24
+ addCommands() {
25
+ return {
26
+ setEmbed: ((attributes: {
27
+ src: string;
28
+ width?: number;
29
+ height?: number;
30
+ }) => {
31
+ return ({ chain }: CommandProps): boolean => {
32
+ return chain()
33
+ .insertContent({
34
+ type: this.name,
35
+ attrs: attributes,
36
+ })
37
+ .run();
38
+ };
39
+ }).bind(this),
40
+ };
41
+ },
42
+
43
+ addNodeView() {
44
+ return ({ node, getPos, editor }) => {
45
+ const container = document.createElement('div');
46
+ container.style.position = 'relative';
47
+ container.style.display = 'inline-block';
48
+ container.style.width = node.attrs.width + 'px';
49
+ container.style.height = node.attrs.height + 'px';
50
+
51
+ const iframe = document.createElement('iframe');
52
+ iframe.setAttribute('src', node.attrs.src);
53
+ iframe.setAttribute('frameborder', '0');
54
+ iframe.setAttribute('allowfullscreen', 'true');
55
+ iframe.style.width = '100%';
56
+ iframe.style.height = '100%';
57
+ container.appendChild(iframe);
58
+
59
+ const handle = document.createElement('div');
60
+ handle.style.position = 'absolute';
61
+ handle.style.width = '16px';
62
+ handle.style.height = '16px';
63
+ handle.style.right = '0';
64
+ handle.style.bottom = '0';
65
+ handle.style.cursor = 'se-resize';
66
+ handle.style.background = 'rgba(0,0,0,0.5)';
67
+ handle.style.borderRadius = '2px';
68
+ container.appendChild(handle);
69
+
70
+ let startX: number, startY: number, startWidth: number, startHeight: number;
71
+
72
+ const onMouseDown = (event: MouseEvent) => {
73
+ event.preventDefault();
74
+ startX = event.clientX;
75
+ startY = event.clientY;
76
+ startWidth = container.offsetWidth;
77
+ startHeight = container.offsetHeight;
78
+ window.addEventListener('mousemove', onMouseMove);
79
+ window.addEventListener('mouseup', onMouseUp);
80
+ };
81
+
82
+ const onMouseMove = (event: MouseEvent) => {
83
+ const newWidth = Math.max(100, startWidth + (event.clientX - startX));
84
+ const newHeight = Math.max(100, startHeight + (event.clientY - startY));
85
+ container.style.width = newWidth + 'px';
86
+ container.style.height = newHeight + 'px';
87
+ };
88
+
89
+ const onMouseUp = () => {
90
+ window.removeEventListener("mousemove", onMouseMove);
91
+ window.removeEventListener("mouseup", onMouseUp);
92
+
93
+ editor.commands.command(({ tr }) => {
94
+ tr.setNodeMarkup(getPos(), undefined, {
95
+ ...node.attrs,
96
+ width: container.offsetWidth,
97
+ height: container.offsetHeight,
98
+ });
99
+ return true;
100
+ });
101
+ };
102
+
103
+ handle.addEventListener('mousedown', onMouseDown);
104
+
105
+ return {
106
+ dom: container,
107
+ destroy() {
108
+ handle.removeEventListener('mousedown', onMouseDown);
109
+ }
110
+ };
111
+ };
112
+ },
113
+ });
@@ -0,0 +1,43 @@
1
+ import { Mark, mergeAttributes } from '@tiptap/core';
2
+
3
+ declare module '@tiptap/core' {
4
+ interface Commands<ReturnType> {
5
+ fontFamily: {
6
+ setFontFamily: (font: string) => ReturnType;
7
+ };
8
+ }
9
+ }
10
+
11
+ export const FontFamily = Mark.create({
12
+ name: 'fontFamily',
13
+
14
+ addAttributes() {
15
+ return {
16
+ font: {
17
+ default: null,
18
+ parseHTML: element => element.style.fontFamily.replace(/['"]/g, ''),
19
+ renderHTML: attributes => {
20
+ if (!attributes.font) return {};
21
+ return { style: `font-family: ${attributes.font}` };
22
+ },
23
+ },
24
+ };
25
+ },
26
+
27
+ parseHTML() {
28
+ return [{ style: 'font-family' }];
29
+ },
30
+
31
+ renderHTML({ HTMLAttributes }) {
32
+ return ['span', mergeAttributes(HTMLAttributes), 0];
33
+ },
34
+
35
+ addCommands() {
36
+ return {
37
+ setFontFamily:
38
+ font =>
39
+ ({ commands }) =>
40
+ commands.setMark(this.name, { font }),
41
+ };
42
+ },
43
+ });
@@ -0,0 +1,43 @@
1
+ import { Mark, mergeAttributes } from "@tiptap/core";
2
+
3
+ declare module "@tiptap/core" {
4
+ interface Commands<ReturnType> {
5
+ fontSize: {
6
+ setFontSize: (size: string) => ReturnType;
7
+ };
8
+ }
9
+ }
10
+
11
+ export const FontSize = Mark.create({
12
+ name: "fontSize",
13
+
14
+ addAttributes() {
15
+ return {
16
+ size: {
17
+ default: null,
18
+ parseHTML: (element) => element.style.fontSize,
19
+ renderHTML: (attributes) => {
20
+ if (!attributes.size) return {};
21
+ return { style: `font-size: ${attributes.size}` };
22
+ },
23
+ },
24
+ };
25
+ },
26
+
27
+ parseHTML() {
28
+ return [{ style: "font-size" }];
29
+ },
30
+
31
+ renderHTML({ HTMLAttributes }) {
32
+ return ["span", mergeAttributes(HTMLAttributes), 0];
33
+ },
34
+
35
+ addCommands() {
36
+ return {
37
+ setFontSize:
38
+ (size) =>
39
+ ({ commands }) =>
40
+ commands.setMark(this.name, { size }),
41
+ };
42
+ },
43
+ });
@@ -0,0 +1,16 @@
1
+ import { Table } from "@tiptap/extension-table";
2
+ import { columnResizing, tableEditing } from "prosemirror-tables";
3
+ import { Plugin } from "prosemirror-state";
4
+
5
+ export const ResizableTable = Table.extend({
6
+ addOptions() {
7
+ return {
8
+ ...this.parent?.(),
9
+ resizable: true,
10
+ };
11
+ },
12
+
13
+ addProseMirrorPlugins(): Plugin[] {
14
+ return [columnResizing({ handleWidth: 5 }), tableEditing()];
15
+ },
16
+ });
@@ -0,0 +1,45 @@
1
+ import { Mark, markInputRule, markPasteRule } from "@tiptap/core";
2
+
3
+ export const Subscript = Mark.create({
4
+ name: "subscript",
5
+
6
+ excludes: "superscript",
7
+
8
+ parseHTML() {
9
+ return [{ tag: "sub" }, { style: "vertical-align: sub" }];
10
+ },
11
+
12
+ renderHTML() {
13
+ return ["sub", 0];
14
+ },
15
+
16
+ addCommands() {
17
+ return {
18
+ toggleSubscript:
19
+ () =>
20
+ ({ chain }) =>
21
+ chain()
22
+ .unsetMark("superscript")
23
+ .toggleMark(this.name)
24
+ .run(),
25
+ };
26
+ },
27
+
28
+ addInputRules() {
29
+ return [
30
+ markInputRule({
31
+ find: /~([^~]+)~/,
32
+ type: this.type,
33
+ }),
34
+ ];
35
+ },
36
+
37
+ addPasteRules() {
38
+ return [
39
+ markPasteRule({
40
+ find: /~([^~]+)~/g,
41
+ type: this.type,
42
+ }),
43
+ ];
44
+ },
45
+ });
@@ -0,0 +1,45 @@
1
+ import { Mark, markInputRule, markPasteRule } from "@tiptap/core";
2
+
3
+ export const Superscript = Mark.create({
4
+ name: "superscript",
5
+
6
+ excludes: "subscript",
7
+
8
+ parseHTML() {
9
+ return [{ tag: "sup" }, { style: "vertical-align: super" }];
10
+ },
11
+
12
+ renderHTML() {
13
+ return ["sup", 0];
14
+ },
15
+
16
+ addCommands() {
17
+ return {
18
+ toggleSuperscript:
19
+ () =>
20
+ ({ chain }) =>
21
+ chain()
22
+ .unsetMark("subscript")
23
+ .toggleMark(this.name)
24
+ .run(),
25
+ };
26
+ },
27
+
28
+ addInputRules() {
29
+ return [
30
+ markInputRule({
31
+ find: /\^([^^]+)\^/,
32
+ type: this.type,
33
+ }),
34
+ ];
35
+ },
36
+
37
+ addPasteRules() {
38
+ return [
39
+ markPasteRule({
40
+ find: /\^([^^]+)\^/g,
41
+ type: this.type,
42
+ }),
43
+ ];
44
+ },
45
+ });
package/dist/index.js CHANGED
@@ -17226,7 +17226,6 @@ function EditorContent({ apiKey }) {
17226
17226
  }
17227
17227
 
17228
17228
  // src/index.ts
17229
- var import_tetrons = require("./tetrons-UCHWNATC.css");
17230
17229
  var API_VALID = false;
17231
17230
  var API_VERSION = "";
17232
17231
  async function initializeTetrons(apiKey) {
package/dist/index.mjs CHANGED
@@ -17232,7 +17232,6 @@ function EditorContent({ apiKey }) {
17232
17232
  }
17233
17233
 
17234
17234
  // src/index.ts
17235
- import "./tetrons-UCHWNATC.css";
17236
17235
  var API_VALID = false;
17237
17236
  var API_VERSION = "";
17238
17237
  async function initializeTetrons(apiKey) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tetrons",
3
- "version": "2.3.21",
3
+ "version": "2.3.23",
4
4
  "description": "A Next.js project written in TypeScript",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -63,13 +63,13 @@
63
63
  "author": "Your Name",
64
64
  "license": "MIT",
65
65
  "exports": {
66
- ".": {
67
- "import": "./dist/index.js",
68
- "require": "./dist/index.js",
69
- "types": "./dist/index.d.ts"
70
- },
71
- "./style.css": "./dist/styles/tetrons.css"
66
+ ".": {
67
+ "import": "./dist/index.js",
68
+ "require": "./dist/index.js",
69
+ "types": "./dist/index.d.ts"
72
70
  },
71
+ "./style.css": "./dist/styles/tetrons.css"
72
+ },
73
73
  "files": [
74
74
  "dist",
75
75
  "dist/styles/tetrons.css",