tetrons 2.1.7 → 2.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/api/export/route.d.ts +1 -0
- package/dist/app/api/export/route.js +4 -0
- package/dist/app/api/save/route.d.ts +6 -0
- package/dist/app/api/save/route.js +15 -0
- package/dist/app/layout.d.ts +6 -0
- package/dist/app/layout.jsx +30 -0
- package/dist/app/page.d.ts +1 -0
- package/dist/app/page.jsx +8 -0
- package/dist/components/UI/Button.d.ts +0 -0
- package/dist/components/UI/Button.jsx +1 -0
- package/dist/components/UI/Dropdown.d.ts +0 -0
- package/dist/components/UI/Dropdown.jsx +1 -0
- package/dist/components/tetrons/EditorContent.d.ts +2 -0
- package/dist/components/tetrons/EditorContent.jsx +160 -0
- package/dist/components/tetrons/ResizableImage.d.ts +1 -0
- package/dist/components/tetrons/ResizableImage.js +40 -0
- package/dist/components/tetrons/ResizableImageComponent.d.ts +11 -0
- package/dist/components/tetrons/ResizableImageComponent.jsx +37 -0
- package/dist/components/tetrons/ResizableVideo.d.ts +12 -0
- package/dist/components/tetrons/ResizableVideo.js +61 -0
- package/dist/components/tetrons/ResizableVideoComponent.d.ts +4 -0
- package/dist/components/tetrons/ResizableVideoComponent.jsx +32 -0
- package/dist/components/tetrons/helpers.d.ts +0 -0
- package/dist/components/tetrons/helpers.js +1 -0
- package/dist/components/tetrons/toolbar/ActionGroup.d.ts +7 -0
- package/dist/components/tetrons/toolbar/ActionGroup.jsx +165 -0
- package/dist/components/tetrons/toolbar/ClipboardGroup.d.ts +5 -0
- package/dist/components/tetrons/toolbar/ClipboardGroup.jsx +36 -0
- package/dist/components/tetrons/toolbar/FileGroup.d.ts +7 -0
- package/dist/components/tetrons/toolbar/FileGroup.jsx +40 -0
- package/dist/components/tetrons/toolbar/FontStyleGroup.d.ts +7 -0
- package/dist/components/tetrons/toolbar/FontStyleGroup.jsx +104 -0
- package/dist/components/tetrons/toolbar/InsertGroup.d.ts +5 -0
- package/dist/components/tetrons/toolbar/InsertGroup.jsx +162 -0
- package/dist/components/tetrons/toolbar/ListAlignGroup.d.ts +5 -0
- package/dist/components/tetrons/toolbar/ListAlignGroup.jsx +16 -0
- package/dist/components/tetrons/toolbar/MiscGroup.d.ts +7 -0
- package/dist/components/tetrons/toolbar/MiscGroup.jsx +31 -0
- package/dist/components/tetrons/toolbar/TableContextMenu.d.ts +7 -0
- package/dist/components/tetrons/toolbar/TableContextMenu.jsx +52 -0
- package/dist/components/tetrons/toolbar/TetronsToolbar.d.ts +5 -0
- package/dist/components/tetrons/toolbar/TetronsToolbar.jsx +46 -0
- package/dist/components/tetrons/toolbar/ToolbarButton.d.ts +12 -0
- package/dist/components/tetrons/toolbar/ToolbarButton.jsx +8 -0
- package/dist/components/tetrons/toolbar/extensions/Comment.d.ts +17 -0
- package/dist/components/tetrons/toolbar/extensions/Comment.js +45 -0
- package/dist/components/tetrons/toolbar/extensions/Embed.d.ts +2 -0
- package/dist/components/tetrons/toolbar/extensions/Embed.js +90 -0
- package/dist/components/tetrons/toolbar/extensions/FontFamily.d.ts +9 -0
- package/dist/components/tetrons/toolbar/extensions/FontFamily.js +28 -0
- package/dist/components/tetrons/toolbar/extensions/FontSize.d.ts +9 -0
- package/dist/components/tetrons/toolbar/extensions/FontSize.js +28 -0
- package/dist/components/tetrons/toolbar/extensions/ResizableTable.d.ts +1 -0
- package/dist/components/tetrons/toolbar/extensions/ResizableTable.js +11 -0
- package/dist/components/tetrons/toolbar/marks/Subscript.d.ts +2 -0
- package/dist/components/tetrons/toolbar/marks/Subscript.js +35 -0
- package/dist/components/tetrons/toolbar/marks/Superscript.d.ts +2 -0
- package/dist/components/tetrons/toolbar/marks/Superscript.js +35 -0
- package/dist/index.d.ts +3 -5
- package/dist/index.js +3 -17204
- package/dist/lib/export.d.ts +0 -0
- package/dist/lib/export.js +1 -0
- package/dist/lib/tiptap-extensions.d.ts +0 -0
- package/dist/lib/tiptap-extensions.js +1 -0
- package/dist/utils/loadEmojiPicker.d.ts +1 -0
- package/dist/utils/loadEmojiPicker.js +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,90 @@
|
|
|
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
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Mark, mergeAttributes } from '@tiptap/core';
|
|
2
|
+
export const FontFamily = Mark.create({
|
|
3
|
+
name: 'fontFamily',
|
|
4
|
+
addAttributes() {
|
|
5
|
+
return {
|
|
6
|
+
font: {
|
|
7
|
+
default: null,
|
|
8
|
+
parseHTML: element => element.style.fontFamily.replace(/['"]/g, ''),
|
|
9
|
+
renderHTML: attributes => {
|
|
10
|
+
if (!attributes.font)
|
|
11
|
+
return {};
|
|
12
|
+
return { style: `font-family: ${attributes.font}` };
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
parseHTML() {
|
|
18
|
+
return [{ style: 'font-family' }];
|
|
19
|
+
},
|
|
20
|
+
renderHTML({ HTMLAttributes }) {
|
|
21
|
+
return ['span', mergeAttributes(HTMLAttributes), 0];
|
|
22
|
+
},
|
|
23
|
+
addCommands() {
|
|
24
|
+
return {
|
|
25
|
+
setFontFamily: font => ({ commands }) => commands.setMark(this.name, { font }),
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { Mark, mergeAttributes } from "@tiptap/core";
|
|
2
|
+
export const FontSize = Mark.create({
|
|
3
|
+
name: "fontSize",
|
|
4
|
+
addAttributes() {
|
|
5
|
+
return {
|
|
6
|
+
size: {
|
|
7
|
+
default: null,
|
|
8
|
+
parseHTML: (element) => element.style.fontSize,
|
|
9
|
+
renderHTML: (attributes) => {
|
|
10
|
+
if (!attributes.size)
|
|
11
|
+
return {};
|
|
12
|
+
return { style: `font-size: ${attributes.size}` };
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
};
|
|
16
|
+
},
|
|
17
|
+
parseHTML() {
|
|
18
|
+
return [{ style: "font-size" }];
|
|
19
|
+
},
|
|
20
|
+
renderHTML({ HTMLAttributes }) {
|
|
21
|
+
return ["span", mergeAttributes(HTMLAttributes), 0];
|
|
22
|
+
},
|
|
23
|
+
addCommands() {
|
|
24
|
+
return {
|
|
25
|
+
setFontSize: (size) => ({ commands }) => commands.setMark(this.name, { size }),
|
|
26
|
+
};
|
|
27
|
+
},
|
|
28
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ResizableTable: import("@tiptap/core").Node<import("@tiptap/extension-table").TableOptions, any>;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Table } from "@tiptap/extension-table";
|
|
2
|
+
import { columnResizing, tableEditing } from "prosemirror-tables";
|
|
3
|
+
export const ResizableTable = Table.extend({
|
|
4
|
+
addOptions() {
|
|
5
|
+
var _a;
|
|
6
|
+
return Object.assign(Object.assign({}, (_a = this.parent) === null || _a === void 0 ? void 0 : _a.call(this)), { resizable: true });
|
|
7
|
+
},
|
|
8
|
+
addProseMirrorPlugins() {
|
|
9
|
+
return [columnResizing({ handleWidth: 5 }), tableEditing()];
|
|
10
|
+
},
|
|
11
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Mark, markInputRule, markPasteRule } from "@tiptap/core";
|
|
2
|
+
export const Subscript = Mark.create({
|
|
3
|
+
name: "subscript",
|
|
4
|
+
excludes: "superscript",
|
|
5
|
+
parseHTML() {
|
|
6
|
+
return [{ tag: "sub" }, { style: "vertical-align: sub" }];
|
|
7
|
+
},
|
|
8
|
+
renderHTML() {
|
|
9
|
+
return ["sub", 0];
|
|
10
|
+
},
|
|
11
|
+
addCommands() {
|
|
12
|
+
return {
|
|
13
|
+
toggleSubscript: () => ({ chain }) => chain()
|
|
14
|
+
.unsetMark("superscript")
|
|
15
|
+
.toggleMark(this.name)
|
|
16
|
+
.run(),
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
addInputRules() {
|
|
20
|
+
return [
|
|
21
|
+
markInputRule({
|
|
22
|
+
find: /~([^~]+)~/,
|
|
23
|
+
type: this.type,
|
|
24
|
+
}),
|
|
25
|
+
];
|
|
26
|
+
},
|
|
27
|
+
addPasteRules() {
|
|
28
|
+
return [
|
|
29
|
+
markPasteRule({
|
|
30
|
+
find: /~([^~]+)~/g,
|
|
31
|
+
type: this.type,
|
|
32
|
+
}),
|
|
33
|
+
];
|
|
34
|
+
},
|
|
35
|
+
});
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { Mark, markInputRule, markPasteRule } from "@tiptap/core";
|
|
2
|
+
export const Superscript = Mark.create({
|
|
3
|
+
name: "superscript",
|
|
4
|
+
excludes: "subscript",
|
|
5
|
+
parseHTML() {
|
|
6
|
+
return [{ tag: "sup" }, { style: "vertical-align: super" }];
|
|
7
|
+
},
|
|
8
|
+
renderHTML() {
|
|
9
|
+
return ["sup", 0];
|
|
10
|
+
},
|
|
11
|
+
addCommands() {
|
|
12
|
+
return {
|
|
13
|
+
toggleSuperscript: () => ({ chain }) => chain()
|
|
14
|
+
.unsetMark("subscript")
|
|
15
|
+
.toggleMark(this.name)
|
|
16
|
+
.run(),
|
|
17
|
+
};
|
|
18
|
+
},
|
|
19
|
+
addInputRules() {
|
|
20
|
+
return [
|
|
21
|
+
markInputRule({
|
|
22
|
+
find: /\^([^^]+)\^/,
|
|
23
|
+
type: this.type,
|
|
24
|
+
}),
|
|
25
|
+
];
|
|
26
|
+
},
|
|
27
|
+
addPasteRules() {
|
|
28
|
+
return [
|
|
29
|
+
markPasteRule({
|
|
30
|
+
find: /\^([^^]+)\^/g,
|
|
31
|
+
type: this.type,
|
|
32
|
+
}),
|
|
33
|
+
];
|
|
34
|
+
},
|
|
35
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { EditorContent, EditorContent as default };
|
|
1
|
+
export { default as EditorContent } from "./components/tetrons/EditorContent";
|
|
2
|
+
import EditorContent from "./components/tetrons/EditorContent";
|
|
3
|
+
export default EditorContent;
|