@examplary/ui 1.56.0 → 1.60.0
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/components/ai/ai-icon.js +2 -25
- package/dist/components/ai/ai-prompt-suggestion.js +3 -26
- package/dist/components/brand/tick-icon.js +2 -25
- package/dist/components/chat/chat-input.js +8 -31
- package/dist/components/chat/chat-typing-indicator.js +2 -2
- package/dist/components/chat/chat-view.d.ts +1 -5
- package/dist/components/chat/chat-view.js +8 -36
- package/dist/components/loading/ai-spinner.js +2 -13
- package/dist/components/loading/tick-loader.js +39 -104
- package/dist/components/print/answer-box.js +2 -25
- package/dist/components/question-types/fetch-component.js +65 -106
- package/dist/components/question-types/format-question-type.d.ts +41 -41
- package/dist/components/question-types/format-question-type.js +36 -37
- package/dist/components/rich-text/minimal-rich-text-field.d.ts +2 -2
- package/dist/components/rich-text/minimal-rich-text-field.js +47 -85
- package/dist/components/rich-text/rich-text-display.js +15 -33
- package/dist/components/rich-text/rich-text-field.js +2 -25
- package/dist/components/rich-text/rich-text-toolbar.d.ts +3 -2
- package/dist/components/rich-text/rich-text-toolbar.js +5 -6
- package/dist/components/rich-text/tiptap/collaboration-caret.js +24 -34
- package/dist/components/rich-text/tiptap/comments/comment-bubble.d.ts +1 -1
- package/dist/components/rich-text/tiptap/comments/comment-bubble.js +36 -41
- package/dist/components/rich-text/tiptap/content-reference.js +6 -7
- package/dist/components/rich-text/tiptap/crop-page-clipping-modal.d.ts +3 -3
- package/dist/components/rich-text/tiptap/crop-page-clipping-modal.js +20 -25
- package/dist/components/rich-text/tiptap/extensions.d.ts +2 -2
- package/dist/components/rich-text/tiptap/extensions.js +6 -16
- package/dist/components/rich-text/tiptap/file-attachment.js +9 -11
- package/dist/components/rich-text/tiptap/file-handler.d.ts +2 -2
- package/dist/components/rich-text/tiptap/file-handler.js +110 -185
- package/dist/components/rich-text/tiptap/image.js +18 -23
- package/dist/components/rich-text/tiptap/mathematics-component.js +25 -30
- package/dist/components/rich-text/tiptap/mathematics.js +56 -82
- package/dist/components/rich-text/tiptap/page-clipping.js +3 -4
- package/dist/components/rich-text/tiptap/png-scanner.js +63 -108
- package/dist/components/rich-text/tiptap/rich-text-formatting-menu.d.ts +1 -1
- package/dist/components/rich-text/tiptap/rich-text-formatting-menu.js +31 -47
- package/dist/components/ui/alert.d.ts +3 -3
- package/dist/components/ui/alert.js +7 -32
- package/dist/components/ui/avatar.d.ts +2 -1
- package/dist/components/ui/avatar.js +33 -26
- package/dist/components/ui/badge.d.ts +3 -3
- package/dist/components/ui/badge.js +4 -27
- package/dist/components/ui/button.d.ts +4 -4
- package/dist/components/ui/button.js +4 -27
- package/dist/components/ui/card.js +6 -46
- package/dist/components/ui/checkbox.js +1 -26
- package/dist/components/ui/color-picker.js +11 -22
- package/dist/components/ui/command-palette.d.ts +3 -3
- package/dist/components/ui/command-palette.js +54 -73
- package/dist/components/ui/command.js +18 -49
- package/dist/components/ui/comments.js +37 -107
- package/dist/components/ui/context-menu.js +30 -67
- package/dist/components/ui/dialog.js +15 -61
- package/dist/components/ui/dropdown.js +17 -64
- package/dist/components/ui/floating-menu.js +2 -25
- package/dist/components/ui/floating-resizable.d.ts +5 -0
- package/dist/components/ui/floating-resizable.js +24 -0
- package/dist/components/ui/help-icon.js +1 -2
- package/dist/components/ui/icon-picker.js +50 -130
- package/dist/components/ui/index.d.ts +1 -0
- package/dist/components/ui/index.js +1 -0
- package/dist/components/ui/input.js +2 -25
- package/dist/components/ui/label.d.ts +1 -1
- package/dist/components/ui/label.js +2 -27
- package/dist/components/ui/popover.d.ts +2 -2
- package/dist/components/ui/popover.js +4 -32
- package/dist/components/ui/progress-bar.js +2 -3
- package/dist/components/ui/radio-group.js +4 -28
- package/dist/components/ui/resizable.d.ts +6 -9
- package/dist/components/ui/resizable.js +13 -60
- package/dist/components/ui/select.js +12 -55
- package/dist/components/ui/separator.js +1 -26
- package/dist/components/ui/sheet.d.ts +3 -3
- package/dist/components/ui/sheet.js +11 -51
- package/dist/components/ui/skeleton.js +2 -25
- package/dist/components/ui/slider.js +7 -32
- package/dist/components/ui/sortable.d.ts +1 -1
- package/dist/components/ui/sortable.js +131 -155
- package/dist/components/ui/switch.d.ts +3 -3
- package/dist/components/ui/switch.js +3 -28
- package/dist/components/ui/table.js +8 -54
- package/dist/components/ui/tabs.js +8 -34
- package/dist/components/ui/text-selection-menu.d.ts +1 -1
- package/dist/components/ui/text-selection-menu.js +19 -25
- package/dist/components/ui/textarea.js +7 -30
- package/dist/components/ui/tooltip.js +4 -29
- package/dist/components/web-components/content-reference.js +81 -106
- package/dist/components/web-components/file-attachment.js +9 -30
- package/dist/components/web-components/index.js +1 -1
- package/dist/components/web-components/inline-comment-reply.js +3 -24
- package/dist/components/web-components/inline-comment.js +3 -24
- package/dist/components/web-components/inline-math.js +14 -36
- package/dist/components/web-components/page-clipping.js +13 -34
- package/dist/lib/compose-refs.js +10 -18
- package/dist/lib/use-spin-loop.js +19 -69
- package/dist/src/global.css +2 -2
- package/dist/utils.js +1 -5
- package/package.json +5 -4
- package/dist/components/rich-text/tiptap/comments/comment-reply.d.ts +0 -21
- package/dist/components/rich-text/tiptap/comments/comment-reply.js +0 -230
- package/dist/components/rich-text/tiptap/comments/comment.d.ts +0 -22
- package/dist/components/rich-text/tiptap/comments/comment.js +0 -198
- package/dist/components/rich-text/tiptap/comments/helpers.d.ts +0 -19
- package/dist/components/rich-text/tiptap/comments/helpers.js +0 -95
- package/dist/components/rich-text/tiptap/comments/types.d.ts +0 -29
- package/dist/components/rich-text/tiptap/comments/types.js +0 -1
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
var __assign = (this && this.__assign) || function () {
|
|
2
|
-
__assign = Object.assign || function(t) {
|
|
3
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
-
s = arguments[i];
|
|
5
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
-
t[p] = s[p];
|
|
7
|
-
}
|
|
8
|
-
return t;
|
|
9
|
-
};
|
|
10
|
-
return __assign.apply(this, arguments);
|
|
11
|
-
};
|
|
12
1
|
import { InputRule, Node } from "@tiptap/core";
|
|
13
2
|
import { ReactNodeViewRenderer } from "@tiptap/react";
|
|
14
3
|
import { MathematicsEditComponent } from "./mathematics-component.js";
|
|
@@ -20,112 +9,97 @@ import { MathematicsEditComponent } from "./mathematics-component.js";
|
|
|
20
9
|
* Original:
|
|
21
10
|
* https://github.com/ueberdosis/tiptap/blob/develop/packages/extension-mathematics/src/extensions/InlineMath.ts
|
|
22
11
|
*/
|
|
23
|
-
export
|
|
12
|
+
export const Mathematics = Node.create({
|
|
24
13
|
name: "inlineMath",
|
|
25
14
|
group: "inline",
|
|
26
15
|
inline: true,
|
|
27
16
|
atom: true,
|
|
28
|
-
addAttributes
|
|
17
|
+
addAttributes() {
|
|
29
18
|
return {
|
|
30
19
|
latex: {
|
|
31
20
|
default: "",
|
|
32
|
-
parseHTML:
|
|
33
|
-
renderHTML:
|
|
21
|
+
parseHTML: (element) => element.textContent,
|
|
22
|
+
renderHTML: () => {
|
|
34
23
|
return {};
|
|
35
24
|
},
|
|
36
25
|
},
|
|
37
26
|
};
|
|
38
27
|
},
|
|
39
|
-
addCommands
|
|
40
|
-
var _this = this;
|
|
28
|
+
addCommands() {
|
|
41
29
|
return {
|
|
42
|
-
deleteInlineMath:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
tr.delete(pos, pos + node.nodeSize);
|
|
52
|
-
return true;
|
|
53
|
-
};
|
|
30
|
+
deleteInlineMath: (options) => ({ editor, tr }) => {
|
|
31
|
+
const pos = options?.pos ?? editor.state.selection.$from.pos;
|
|
32
|
+
const node = editor.state.doc.nodeAt(pos);
|
|
33
|
+
if (!node || node.type.name !== this.name) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
tr.delete(pos, pos + node.nodeSize);
|
|
37
|
+
return true;
|
|
54
38
|
},
|
|
55
|
-
insertInlineMath:
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (options === null || options === void 0 ? void 0 : options.latex) {
|
|
61
|
-
var from_1 = (_b = options === null || options === void 0 ? void 0 : options.pos) !== null && _b !== void 0 ? _b : editor.state.selection.from;
|
|
62
|
-
tr.replaceWith(from_1, from_1, _this.type.create({ latex: options.latex }));
|
|
63
|
-
return true;
|
|
64
|
-
}
|
|
65
|
-
// If there is a selection that isn't empty, replace it with the inline math
|
|
66
|
-
var _e = editor.state.selection, from = _e.from, to = _e.to;
|
|
67
|
-
if (from !== to) {
|
|
68
|
-
var selectedText = editor.state.doc.textBetween(from, to);
|
|
69
|
-
tr.replaceWith(from, to, _this.type.create({ latex: selectedText.trim() || "2x + 2" }));
|
|
70
|
-
return true;
|
|
71
|
-
}
|
|
72
|
-
// Otherwise, insert at the current position
|
|
73
|
-
var pos = (_c = options === null || options === void 0 ? void 0 : options.pos) !== null && _c !== void 0 ? _c : editor.state.selection.to;
|
|
74
|
-
tr.replaceWith(pos, pos, _this.type.create({ latex: ((_d = options.latex) === null || _d === void 0 ? void 0 : _d.trim()) || "2x + 2" }));
|
|
39
|
+
insertInlineMath: (options) => ({ editor, tr }) => {
|
|
40
|
+
// Insert latex if specified
|
|
41
|
+
if (options?.latex) {
|
|
42
|
+
const from = options?.pos ?? editor.state.selection.from;
|
|
43
|
+
tr.replaceWith(from, from, this.type.create({ latex: options.latex }));
|
|
75
44
|
return true;
|
|
76
|
-
}
|
|
45
|
+
}
|
|
46
|
+
// If there is a selection that isn't empty, replace it with the inline math
|
|
47
|
+
const { from, to } = editor.state.selection;
|
|
48
|
+
if (from !== to) {
|
|
49
|
+
const selectedText = editor.state.doc.textBetween(from, to);
|
|
50
|
+
tr.replaceWith(from, to, this.type.create({ latex: selectedText.trim() || "2x + 2" }));
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
// Otherwise, insert at the current position
|
|
54
|
+
const pos = options?.pos ?? editor.state.selection.to;
|
|
55
|
+
tr.replaceWith(pos, pos, this.type.create({ latex: options.latex?.trim() || "2x + 2" }));
|
|
56
|
+
return true;
|
|
77
57
|
},
|
|
78
|
-
updateInlineMath:
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
// Delete node if new latex is empty
|
|
92
|
-
tr.delete(pos, pos + node.nodeSize);
|
|
93
|
-
return true;
|
|
94
|
-
}
|
|
95
|
-
tr.setNodeMarkup(pos, _this.type, __assign(__assign({}, node.attrs), { latex: latex }));
|
|
58
|
+
updateInlineMath: (options) => ({ editor, tr }) => {
|
|
59
|
+
const latex = options?.latex;
|
|
60
|
+
let pos = options?.pos;
|
|
61
|
+
if (pos === undefined) {
|
|
62
|
+
pos = editor.state.selection.$from.pos;
|
|
63
|
+
}
|
|
64
|
+
const node = editor.state.doc.nodeAt(pos);
|
|
65
|
+
if (!node || node.type.name !== this.name) {
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
68
|
+
if (latex?.trim() === "") {
|
|
69
|
+
// Delete node if new latex is empty
|
|
70
|
+
tr.delete(pos, pos + node.nodeSize);
|
|
96
71
|
return true;
|
|
97
|
-
}
|
|
72
|
+
}
|
|
73
|
+
tr.setNodeMarkup(pos, this.type, { ...node.attrs, latex });
|
|
74
|
+
return true;
|
|
98
75
|
},
|
|
99
76
|
};
|
|
100
77
|
},
|
|
101
|
-
parseHTML
|
|
78
|
+
parseHTML() {
|
|
102
79
|
return [
|
|
103
80
|
{
|
|
104
81
|
tag: "inline-math",
|
|
105
82
|
},
|
|
106
83
|
];
|
|
107
84
|
},
|
|
108
|
-
renderHTML
|
|
109
|
-
var node = _a.node, HTMLAttributes = _a.HTMLAttributes;
|
|
85
|
+
renderHTML({ node, HTMLAttributes }) {
|
|
110
86
|
return ["inline-math", HTMLAttributes, node.attrs.latex || ""];
|
|
111
87
|
},
|
|
112
|
-
addInputRules
|
|
113
|
-
var _this = this;
|
|
88
|
+
addInputRules() {
|
|
114
89
|
return [
|
|
115
90
|
new InputRule({
|
|
116
91
|
find: /(^|[^$])(\$\$([^$\n]+?)\$\$)(?!\$)/,
|
|
117
|
-
handler:
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
tr.replaceWith(start, end, _this.type.create({ latex: latex }));
|
|
92
|
+
handler: ({ state, range, match }) => {
|
|
93
|
+
const latex = match[3];
|
|
94
|
+
const { tr } = state;
|
|
95
|
+
const start = range.from;
|
|
96
|
+
const end = range.to;
|
|
97
|
+
tr.replaceWith(start, end, this.type.create({ latex }));
|
|
124
98
|
},
|
|
125
99
|
}),
|
|
126
100
|
];
|
|
127
101
|
},
|
|
128
|
-
addNodeView
|
|
102
|
+
addNodeView() {
|
|
129
103
|
return ReactNodeViewRenderer(MathematicsEditComponent);
|
|
130
104
|
},
|
|
131
105
|
});
|
|
@@ -4,7 +4,7 @@ export default Node.create({
|
|
|
4
4
|
group: "block",
|
|
5
5
|
content: "inline*",
|
|
6
6
|
atom: true,
|
|
7
|
-
addAttributes
|
|
7
|
+
addAttributes() {
|
|
8
8
|
return {
|
|
9
9
|
url: {},
|
|
10
10
|
page: {},
|
|
@@ -14,15 +14,14 @@ export default Node.create({
|
|
|
14
14
|
height: {},
|
|
15
15
|
};
|
|
16
16
|
},
|
|
17
|
-
parseHTML
|
|
17
|
+
parseHTML() {
|
|
18
18
|
return [
|
|
19
19
|
{
|
|
20
20
|
tag: "page-clipping",
|
|
21
21
|
},
|
|
22
22
|
];
|
|
23
23
|
},
|
|
24
|
-
renderHTML
|
|
25
|
-
var HTMLAttributes = _a.HTMLAttributes;
|
|
24
|
+
renderHTML({ HTMLAttributes }) {
|
|
26
25
|
return ["page-clipping", mergeAttributes(HTMLAttributes)];
|
|
27
26
|
},
|
|
28
27
|
});
|
|
@@ -1,58 +1,24 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
12
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
1
|
/**
|
|
38
2
|
* Class to scan PNG files and extract metadata
|
|
39
3
|
*/
|
|
40
|
-
|
|
41
|
-
|
|
4
|
+
class PNGScanner {
|
|
5
|
+
dataview;
|
|
6
|
+
pos;
|
|
7
|
+
constructor(buffer) {
|
|
42
8
|
this.dataview = new DataView(buffer);
|
|
43
9
|
this.pos = 0;
|
|
44
10
|
}
|
|
45
11
|
/**
|
|
46
12
|
* Advance the position pointer
|
|
47
13
|
*/
|
|
48
|
-
|
|
14
|
+
advance(bytes) {
|
|
49
15
|
this.pos += bytes;
|
|
50
|
-
}
|
|
16
|
+
}
|
|
51
17
|
/**
|
|
52
18
|
* Read an integer of specified byte length
|
|
53
19
|
*/
|
|
54
|
-
|
|
55
|
-
|
|
20
|
+
readInt(bytes) {
|
|
21
|
+
let value;
|
|
56
22
|
switch (bytes) {
|
|
57
23
|
case 1:
|
|
58
24
|
value = this.dataview.getUint8(this.pos);
|
|
@@ -68,39 +34,39 @@ var PNGScanner = /** @class */ (function () {
|
|
|
68
34
|
}
|
|
69
35
|
this.advance(bytes);
|
|
70
36
|
return value;
|
|
71
|
-
}
|
|
37
|
+
}
|
|
72
38
|
/**
|
|
73
39
|
* Read a single byte as a character
|
|
74
40
|
*/
|
|
75
|
-
|
|
41
|
+
readChar() {
|
|
76
42
|
return this.readInt(1);
|
|
77
|
-
}
|
|
43
|
+
}
|
|
78
44
|
/**
|
|
79
45
|
* Read a 2-byte short integer
|
|
80
46
|
*/
|
|
81
|
-
|
|
47
|
+
readShort() {
|
|
82
48
|
return this.readInt(2);
|
|
83
|
-
}
|
|
49
|
+
}
|
|
84
50
|
/**
|
|
85
51
|
* Read a 4-byte long integer
|
|
86
52
|
*/
|
|
87
|
-
|
|
53
|
+
readLong() {
|
|
88
54
|
return this.readInt(4);
|
|
89
|
-
}
|
|
55
|
+
}
|
|
90
56
|
/**
|
|
91
57
|
* Read a string of specified length
|
|
92
58
|
*/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
for (
|
|
59
|
+
readString(length) {
|
|
60
|
+
const chars = [];
|
|
61
|
+
for (let i = 0; i < length; i++) {
|
|
96
62
|
chars.push(String.fromCharCode(this.readChar()));
|
|
97
63
|
}
|
|
98
64
|
return chars.join("");
|
|
99
|
-
}
|
|
65
|
+
}
|
|
100
66
|
/**
|
|
101
67
|
* Scan through PNG chunks and call the provided callback for each chunk
|
|
102
68
|
*/
|
|
103
|
-
|
|
69
|
+
scan(callback) {
|
|
104
70
|
// Check PNG signature
|
|
105
71
|
if (0x89504e47 !== this.readLong()) {
|
|
106
72
|
throw Error("invalid PNG");
|
|
@@ -109,24 +75,23 @@ var PNGScanner = /** @class */ (function () {
|
|
|
109
75
|
this.advance(4);
|
|
110
76
|
// Process chunks
|
|
111
77
|
while (true) {
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
78
|
+
const chunkLength = this.readLong();
|
|
79
|
+
const chunkType = this.readString(4);
|
|
80
|
+
const nextChunkPos = this.pos + chunkLength + 4;
|
|
115
81
|
if (callback.call(this, chunkType, chunkLength) === false ||
|
|
116
82
|
chunkType === "IEND") {
|
|
117
83
|
break;
|
|
118
84
|
}
|
|
119
85
|
this.pos = nextChunkPos;
|
|
120
86
|
}
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
}());
|
|
87
|
+
}
|
|
88
|
+
}
|
|
124
89
|
/**
|
|
125
90
|
* Parse PNG metadata from a buffer
|
|
126
91
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
92
|
+
const parsePNGMetadata = (buffer) => {
|
|
93
|
+
const scanner = new PNGScanner(buffer);
|
|
94
|
+
const metadata = {
|
|
130
95
|
width: 0,
|
|
131
96
|
height: 0,
|
|
132
97
|
ppi: 1,
|
|
@@ -134,14 +99,19 @@ var parsePNGMetadata = function (buffer) {
|
|
|
134
99
|
scanner.scan(function (chunkType) {
|
|
135
100
|
switch (chunkType) {
|
|
136
101
|
case "IHDR":
|
|
102
|
+
// @ts-expect-error this
|
|
137
103
|
metadata.width = this.readLong();
|
|
104
|
+
// @ts-expect-error this
|
|
138
105
|
metadata.height = this.readLong();
|
|
139
106
|
break;
|
|
140
107
|
case "pHYs": {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
108
|
+
let metersToInches;
|
|
109
|
+
// @ts-expect-error this
|
|
110
|
+
const xPixelsPerUnit = this.readLong();
|
|
111
|
+
// @ts-expect-error this
|
|
112
|
+
const yPixelsPerUnit = this.readLong();
|
|
144
113
|
// Check if units are meters (1)
|
|
114
|
+
// @ts-expect-error this
|
|
145
115
|
if (this.readChar() === 1) {
|
|
146
116
|
metersToInches = 0.0254; // Conversion factor from meters to inches
|
|
147
117
|
}
|
|
@@ -161,48 +131,33 @@ var parsePNGMetadata = function (buffer) {
|
|
|
161
131
|
/**
|
|
162
132
|
* Read a file as ArrayBuffer and extract PNG metadata
|
|
163
133
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
case 2:
|
|
180
|
-
error_1 = _a.sent();
|
|
181
|
-
console.error("Error reading PNG file:", error_1);
|
|
182
|
-
return [2 /*return*/, null];
|
|
183
|
-
case 3: return [2 /*return*/];
|
|
184
|
-
}
|
|
185
|
-
});
|
|
186
|
-
}); };
|
|
134
|
+
const extractPNGMetadata = async (file) => {
|
|
135
|
+
try {
|
|
136
|
+
const buffer = await new Promise((resolve, reject) => {
|
|
137
|
+
const reader = new FileReader();
|
|
138
|
+
reader.onload = () => resolve(reader.result);
|
|
139
|
+
reader.onerror = () => reject(reader.error);
|
|
140
|
+
reader.readAsArrayBuffer(file);
|
|
141
|
+
});
|
|
142
|
+
return buffer ? parsePNGMetadata(buffer) : null;
|
|
143
|
+
}
|
|
144
|
+
catch (error) {
|
|
145
|
+
console.error("Error reading PNG file:", error);
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
};
|
|
187
149
|
/**
|
|
188
150
|
* Get the actual width of an image, accounting for high DPI images
|
|
189
151
|
*/
|
|
190
|
-
export
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
actualWidth = Math.round(metadata.width / 2);
|
|
203
|
-
return [2 /*return*/, { width: actualWidth }];
|
|
204
|
-
}
|
|
205
|
-
return [2 /*return*/, { width: metadata.width }];
|
|
206
|
-
}
|
|
207
|
-
});
|
|
208
|
-
}); };
|
|
152
|
+
export const getImageSize = async (file) => {
|
|
153
|
+
const metadata = await extractPNGMetadata(file);
|
|
154
|
+
if (!metadata) {
|
|
155
|
+
return { width: 0 };
|
|
156
|
+
}
|
|
157
|
+
// For high DPI images (e.g., 144 PPI which is common for 2x retina displays)
|
|
158
|
+
if (metadata.ppi === 144) {
|
|
159
|
+
const actualWidth = Math.round(metadata.width / 2);
|
|
160
|
+
return { width: actualWidth };
|
|
161
|
+
}
|
|
162
|
+
return { width: metadata.width };
|
|
163
|
+
};
|
|
@@ -3,5 +3,5 @@ type RichTextFormattingMenuProps = {
|
|
|
3
3
|
editor: Editor;
|
|
4
4
|
allowComments?: boolean;
|
|
5
5
|
};
|
|
6
|
-
export declare const RichTextFormattingMenu: ({ allowComments, editor, }: RichTextFormattingMenuProps) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
export declare const RichTextFormattingMenu: ({ allowComments, editor, }: RichTextFormattingMenuProps) => import("react/jsx-runtime").JSX.Element | null;
|
|
7
7
|
export {};
|
|
@@ -7,38 +7,37 @@ import { BoldIcon, CropIcon, HighlighterIcon, ItalicIcon, LinkIcon, ListIcon, Me
|
|
|
7
7
|
import { CropPageClippingModal } from "./crop-page-clipping-modal";
|
|
8
8
|
import { cn } from "../../../utils";
|
|
9
9
|
import { FloatingMenu } from "../../ui/floating-menu";
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
var setLink = useCallback(function () {
|
|
10
|
+
export const RichTextFormattingMenu = ({ allowComments, editor, }) => {
|
|
11
|
+
const [pageClipping, setPageClipping] = useState(null);
|
|
12
|
+
const { t } = useTranslation();
|
|
13
|
+
const setLink = useCallback(() => {
|
|
15
14
|
if (editor.isActive("link")) {
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
const mark = editor.chain().focus().extendMarkRange("link");
|
|
16
|
+
mark.unsetLink().run();
|
|
18
17
|
return;
|
|
19
18
|
}
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const previousUrl = editor.getAttributes("link").href;
|
|
20
|
+
let url = window.prompt("Where do you want to link to? Enter a link that starts with 'https://'.", previousUrl);
|
|
22
21
|
// cancelled
|
|
23
22
|
if (url === null) {
|
|
24
23
|
return;
|
|
25
24
|
}
|
|
26
25
|
// empty
|
|
27
26
|
if (url === "") {
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const mark = editor.chain().focus().extendMarkRange("link");
|
|
28
|
+
mark.unsetLink().run();
|
|
30
29
|
return;
|
|
31
30
|
}
|
|
32
31
|
if (url.indexOf("http") !== 0) {
|
|
33
32
|
url = "http://" + url;
|
|
34
33
|
}
|
|
35
34
|
// update link
|
|
36
|
-
|
|
35
|
+
const mark = editor.chain().focus().extendMarkRange("link");
|
|
37
36
|
mark.setLink({ href: url }).run();
|
|
38
37
|
}, [editor]);
|
|
39
|
-
|
|
40
|
-
editor
|
|
41
|
-
selector:
|
|
38
|
+
const state = useEditorState({
|
|
39
|
+
editor,
|
|
40
|
+
selector: (ctx) => ({
|
|
42
41
|
isBold: ctx.editor.isActive("bold"),
|
|
43
42
|
isItalic: ctx.editor.isActive("italic"),
|
|
44
43
|
isStrikethrough: ctx.editor.isActive("strike"),
|
|
@@ -52,16 +51,16 @@ export var RichTextFormattingMenu = function (_a) {
|
|
|
52
51
|
isFileAttachment: ctx.editor.isActive("file-attachment"),
|
|
53
52
|
isImage: ctx.editor.isActive("image"),
|
|
54
53
|
isComment: allowComments ? ctx.editor.isActive("comment") : false,
|
|
55
|
-
})
|
|
54
|
+
}),
|
|
56
55
|
});
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
const actions = useMemo(() => {
|
|
57
|
+
const items = [];
|
|
59
58
|
if (allowComments) {
|
|
60
59
|
items.push({
|
|
61
60
|
icon: MessageCircleIcon,
|
|
62
61
|
label: t("formatting.comment"),
|
|
63
62
|
active: state.isComment,
|
|
64
|
-
action:
|
|
63
|
+
action: () => editor.chain().focus().toggleComment().run(),
|
|
65
64
|
});
|
|
66
65
|
}
|
|
67
66
|
if (state.isPageClipping) {
|
|
@@ -69,15 +68,14 @@ export var RichTextFormattingMenu = function (_a) {
|
|
|
69
68
|
icon: CropIcon,
|
|
70
69
|
label: t("formatting.crop.edit"),
|
|
71
70
|
active: state.isPageClipping,
|
|
72
|
-
action:
|
|
71
|
+
action: () => setPageClipping(editor.getAttributes("page-clipping")),
|
|
73
72
|
});
|
|
74
73
|
}
|
|
75
74
|
else if (state.isImage || state.isFileAttachment) {
|
|
76
75
|
items.push({
|
|
77
76
|
icon: TrashIcon,
|
|
78
77
|
label: t("formatting.delete"),
|
|
79
|
-
|
|
80
|
-
action: function () { return editor.commands.deleteSelection(); },
|
|
78
|
+
action: () => editor.commands.deleteSelection(),
|
|
81
79
|
});
|
|
82
80
|
}
|
|
83
81
|
else {
|
|
@@ -85,23 +83,17 @@ export var RichTextFormattingMenu = function (_a) {
|
|
|
85
83
|
icon: BoldIcon,
|
|
86
84
|
label: t("formatting.bold"),
|
|
87
85
|
active: state.isBold,
|
|
88
|
-
action:
|
|
89
|
-
return editor.chain().focus().toggleBold().run();
|
|
90
|
-
},
|
|
86
|
+
action: () => editor.chain().focus().toggleBold().run(),
|
|
91
87
|
}, {
|
|
92
88
|
icon: ItalicIcon,
|
|
93
89
|
label: t("formatting.italic"),
|
|
94
90
|
active: state.isItalic,
|
|
95
|
-
action:
|
|
96
|
-
return editor.chain().focus().toggleItalic().run();
|
|
97
|
-
},
|
|
91
|
+
action: () => editor.chain().focus().toggleItalic().run(),
|
|
98
92
|
}, {
|
|
99
93
|
icon: HighlighterIcon,
|
|
100
94
|
label: t("formatting.highlight"),
|
|
101
95
|
active: state.isHighlight,
|
|
102
|
-
action:
|
|
103
|
-
return editor.chain().focus().toggleHighlight().run();
|
|
104
|
-
},
|
|
96
|
+
action: () => editor.chain().focus().toggleHighlight().run(),
|
|
105
97
|
}, {
|
|
106
98
|
icon: LinkIcon,
|
|
107
99
|
label: t("formatting.link"),
|
|
@@ -111,32 +103,24 @@ export var RichTextFormattingMenu = function (_a) {
|
|
|
111
103
|
icon: ListIcon,
|
|
112
104
|
label: t("formatting.bulletList"),
|
|
113
105
|
active: state.isBulletList,
|
|
114
|
-
action:
|
|
115
|
-
return editor.chain().focus().toggleBulletList().run();
|
|
116
|
-
},
|
|
106
|
+
action: () => editor.chain().focus().toggleBulletList().run(),
|
|
117
107
|
}, {
|
|
118
108
|
icon: ListIcon,
|
|
119
109
|
label: t("formatting.orderedList"),
|
|
120
110
|
active: state.isOrderedList,
|
|
121
|
-
action:
|
|
122
|
-
return editor.chain().focus().toggleOrderedList().run();
|
|
123
|
-
},
|
|
111
|
+
action: () => editor.chain().focus().toggleOrderedList().run(),
|
|
124
112
|
}, {
|
|
125
113
|
icon: TextQuoteIcon,
|
|
126
114
|
label: t("formatting.blockquote"),
|
|
127
115
|
active: state.isBlockquote,
|
|
128
|
-
action:
|
|
129
|
-
return editor.chain().focus().toggleBlockquote().run();
|
|
130
|
-
},
|
|
116
|
+
action: () => editor.chain().focus().toggleBlockquote().run(),
|
|
131
117
|
}, {
|
|
132
118
|
icon: SquareFunctionIcon,
|
|
133
119
|
label: t("formatting.inlineMath"),
|
|
134
120
|
active: state.isInlineMath,
|
|
135
|
-
action:
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
.run();
|
|
139
|
-
},
|
|
121
|
+
action: () => editor.chain().focus()
|
|
122
|
+
.insertInlineMath({ latex: "" })
|
|
123
|
+
.run(),
|
|
140
124
|
});
|
|
141
125
|
}
|
|
142
126
|
return items;
|
|
@@ -144,12 +128,12 @@ export var RichTextFormattingMenu = function (_a) {
|
|
|
144
128
|
if (!editor) {
|
|
145
129
|
return null;
|
|
146
130
|
}
|
|
147
|
-
return (_jsxs(_Fragment, { children: [state.isPageClipping && (_jsx(CropPageClippingModal, { pageClipping: pageClipping, onClose:
|
|
131
|
+
return (_jsxs(_Fragment, { children: [state.isPageClipping && (_jsx(CropPageClippingModal, { pageClipping: pageClipping, onClose: () => setPageClipping(null), onUpdate: (newParameters) => {
|
|
148
132
|
setPageClipping(null);
|
|
149
133
|
editor
|
|
150
134
|
.chain()
|
|
151
135
|
.focus()
|
|
152
136
|
.updateAttributes("page-clipping", newParameters)
|
|
153
137
|
.run();
|
|
154
|
-
} })), _jsx(BubbleMenu, { editor: editor, children: _jsx(FloatingMenu, { className: "ml-2 flex items-center gap-0.5", children: actions.map(
|
|
138
|
+
} })), _jsx(BubbleMenu, { editor: editor, children: _jsx(FloatingMenu, { className: "ml-2 flex items-center gap-0.5", children: actions.map((item, index) => (_jsx("button", { onClick: item.action, type: "button", title: item.label, "aria-label": item.label, className: cn("p-1 cursor-pointer flex items-center gap-1 hover:bg-zinc-100 rounded-md", item.active ? "bg-zinc-200" : ""), children: _jsx(item.icon, { className: "size-3.5 m-0.5" }) }, index))) }) })] }));
|
|
155
139
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { type VariantProps } from "class-variance-authority";
|
|
3
|
-
declare const alertVariants: (props?: {
|
|
4
|
-
variant?: "default" | "secondary" | "destructive" | "warning" | "info";
|
|
5
|
-
} & import("class-variance-authority/types").ClassProp) => string;
|
|
3
|
+
declare const alertVariants: (props?: ({
|
|
4
|
+
variant?: "default" | "secondary" | "destructive" | "warning" | "info" | null | undefined;
|
|
5
|
+
} & import("class-variance-authority/types").ClassProp) | undefined) => string;
|
|
6
6
|
declare function Alert({ className, variant, ...props }: React.ComponentProps<"div"> & VariantProps<typeof alertVariants>): import("react/jsx-runtime").JSX.Element;
|
|
7
7
|
declare function AlertTitle({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|
|
8
8
|
declare function AlertDescription({ className, ...props }: React.ComponentProps<"div">): import("react/jsx-runtime").JSX.Element;
|