@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.
Files changed (107) hide show
  1. package/dist/components/ai/ai-icon.js +2 -25
  2. package/dist/components/ai/ai-prompt-suggestion.js +3 -26
  3. package/dist/components/brand/tick-icon.js +2 -25
  4. package/dist/components/chat/chat-input.js +8 -31
  5. package/dist/components/chat/chat-typing-indicator.js +2 -2
  6. package/dist/components/chat/chat-view.d.ts +1 -5
  7. package/dist/components/chat/chat-view.js +8 -36
  8. package/dist/components/loading/ai-spinner.js +2 -13
  9. package/dist/components/loading/tick-loader.js +39 -104
  10. package/dist/components/print/answer-box.js +2 -25
  11. package/dist/components/question-types/fetch-component.js +65 -106
  12. package/dist/components/question-types/format-question-type.d.ts +41 -41
  13. package/dist/components/question-types/format-question-type.js +36 -37
  14. package/dist/components/rich-text/minimal-rich-text-field.d.ts +2 -2
  15. package/dist/components/rich-text/minimal-rich-text-field.js +47 -85
  16. package/dist/components/rich-text/rich-text-display.js +15 -33
  17. package/dist/components/rich-text/rich-text-field.js +2 -25
  18. package/dist/components/rich-text/rich-text-toolbar.d.ts +3 -2
  19. package/dist/components/rich-text/rich-text-toolbar.js +5 -6
  20. package/dist/components/rich-text/tiptap/collaboration-caret.js +24 -34
  21. package/dist/components/rich-text/tiptap/comments/comment-bubble.d.ts +1 -1
  22. package/dist/components/rich-text/tiptap/comments/comment-bubble.js +36 -41
  23. package/dist/components/rich-text/tiptap/content-reference.js +6 -7
  24. package/dist/components/rich-text/tiptap/crop-page-clipping-modal.d.ts +3 -3
  25. package/dist/components/rich-text/tiptap/crop-page-clipping-modal.js +20 -25
  26. package/dist/components/rich-text/tiptap/extensions.d.ts +2 -2
  27. package/dist/components/rich-text/tiptap/extensions.js +6 -16
  28. package/dist/components/rich-text/tiptap/file-attachment.js +9 -11
  29. package/dist/components/rich-text/tiptap/file-handler.d.ts +2 -2
  30. package/dist/components/rich-text/tiptap/file-handler.js +110 -185
  31. package/dist/components/rich-text/tiptap/image.js +18 -23
  32. package/dist/components/rich-text/tiptap/mathematics-component.js +25 -30
  33. package/dist/components/rich-text/tiptap/mathematics.js +56 -82
  34. package/dist/components/rich-text/tiptap/page-clipping.js +3 -4
  35. package/dist/components/rich-text/tiptap/png-scanner.js +63 -108
  36. package/dist/components/rich-text/tiptap/rich-text-formatting-menu.d.ts +1 -1
  37. package/dist/components/rich-text/tiptap/rich-text-formatting-menu.js +31 -47
  38. package/dist/components/ui/alert.d.ts +3 -3
  39. package/dist/components/ui/alert.js +7 -32
  40. package/dist/components/ui/avatar.d.ts +2 -1
  41. package/dist/components/ui/avatar.js +33 -26
  42. package/dist/components/ui/badge.d.ts +3 -3
  43. package/dist/components/ui/badge.js +4 -27
  44. package/dist/components/ui/button.d.ts +4 -4
  45. package/dist/components/ui/button.js +4 -27
  46. package/dist/components/ui/card.js +6 -46
  47. package/dist/components/ui/checkbox.js +1 -26
  48. package/dist/components/ui/color-picker.js +11 -22
  49. package/dist/components/ui/command-palette.d.ts +3 -3
  50. package/dist/components/ui/command-palette.js +54 -73
  51. package/dist/components/ui/command.js +18 -49
  52. package/dist/components/ui/comments.js +37 -107
  53. package/dist/components/ui/context-menu.js +30 -67
  54. package/dist/components/ui/dialog.js +15 -61
  55. package/dist/components/ui/dropdown.js +17 -64
  56. package/dist/components/ui/floating-menu.js +2 -25
  57. package/dist/components/ui/floating-resizable.d.ts +5 -0
  58. package/dist/components/ui/floating-resizable.js +24 -0
  59. package/dist/components/ui/help-icon.js +1 -2
  60. package/dist/components/ui/icon-picker.js +50 -130
  61. package/dist/components/ui/index.d.ts +1 -0
  62. package/dist/components/ui/index.js +1 -0
  63. package/dist/components/ui/input.js +2 -25
  64. package/dist/components/ui/label.d.ts +1 -1
  65. package/dist/components/ui/label.js +2 -27
  66. package/dist/components/ui/popover.d.ts +2 -2
  67. package/dist/components/ui/popover.js +4 -32
  68. package/dist/components/ui/progress-bar.js +2 -3
  69. package/dist/components/ui/radio-group.js +4 -28
  70. package/dist/components/ui/resizable.d.ts +6 -9
  71. package/dist/components/ui/resizable.js +13 -60
  72. package/dist/components/ui/select.js +12 -55
  73. package/dist/components/ui/separator.js +1 -26
  74. package/dist/components/ui/sheet.d.ts +3 -3
  75. package/dist/components/ui/sheet.js +11 -51
  76. package/dist/components/ui/skeleton.js +2 -25
  77. package/dist/components/ui/slider.js +7 -32
  78. package/dist/components/ui/sortable.d.ts +1 -1
  79. package/dist/components/ui/sortable.js +131 -155
  80. package/dist/components/ui/switch.d.ts +3 -3
  81. package/dist/components/ui/switch.js +3 -28
  82. package/dist/components/ui/table.js +8 -54
  83. package/dist/components/ui/tabs.js +8 -34
  84. package/dist/components/ui/text-selection-menu.d.ts +1 -1
  85. package/dist/components/ui/text-selection-menu.js +19 -25
  86. package/dist/components/ui/textarea.js +7 -30
  87. package/dist/components/ui/tooltip.js +4 -29
  88. package/dist/components/web-components/content-reference.js +81 -106
  89. package/dist/components/web-components/file-attachment.js +9 -30
  90. package/dist/components/web-components/index.js +1 -1
  91. package/dist/components/web-components/inline-comment-reply.js +3 -24
  92. package/dist/components/web-components/inline-comment.js +3 -24
  93. package/dist/components/web-components/inline-math.js +14 -36
  94. package/dist/components/web-components/page-clipping.js +13 -34
  95. package/dist/lib/compose-refs.js +10 -18
  96. package/dist/lib/use-spin-loop.js +19 -69
  97. package/dist/src/global.css +2 -2
  98. package/dist/utils.js +1 -5
  99. package/package.json +5 -4
  100. package/dist/components/rich-text/tiptap/comments/comment-reply.d.ts +0 -21
  101. package/dist/components/rich-text/tiptap/comments/comment-reply.js +0 -230
  102. package/dist/components/rich-text/tiptap/comments/comment.d.ts +0 -22
  103. package/dist/components/rich-text/tiptap/comments/comment.js +0 -198
  104. package/dist/components/rich-text/tiptap/comments/helpers.d.ts +0 -19
  105. package/dist/components/rich-text/tiptap/comments/helpers.js +0 -95
  106. package/dist/components/rich-text/tiptap/comments/types.d.ts +0 -29
  107. 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 var Mathematics = Node.create({
12
+ export const Mathematics = Node.create({
24
13
  name: "inlineMath",
25
14
  group: "inline",
26
15
  inline: true,
27
16
  atom: true,
28
- addAttributes: function () {
17
+ addAttributes() {
29
18
  return {
30
19
  latex: {
31
20
  default: "",
32
- parseHTML: function (element) { return element.textContent; },
33
- renderHTML: function () {
21
+ parseHTML: (element) => element.textContent,
22
+ renderHTML: () => {
34
23
  return {};
35
24
  },
36
25
  },
37
26
  };
38
27
  },
39
- addCommands: function () {
40
- var _this = this;
28
+ addCommands() {
41
29
  return {
42
- deleteInlineMath: function (options) {
43
- return function (_a) {
44
- var _b;
45
- var editor = _a.editor, tr = _a.tr;
46
- var pos = (_b = options === null || options === void 0 ? void 0 : options.pos) !== null && _b !== void 0 ? _b : editor.state.selection.$from.pos;
47
- var node = editor.state.doc.nodeAt(pos);
48
- if (!node || node.type.name !== _this.name) {
49
- return false;
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: function (options) {
56
- return function (_a) {
57
- var _b, _c, _d;
58
- var editor = _a.editor, tr = _a.tr;
59
- // Insert latex if specified
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: function (options) {
79
- return function (_a) {
80
- var editor = _a.editor, tr = _a.tr;
81
- var latex = options === null || options === void 0 ? void 0 : options.latex;
82
- var pos = options === null || options === void 0 ? void 0 : options.pos;
83
- if (pos === undefined) {
84
- pos = editor.state.selection.$from.pos;
85
- }
86
- var node = editor.state.doc.nodeAt(pos);
87
- if (!node || node.type.name !== _this.name) {
88
- return false;
89
- }
90
- if ((latex === null || latex === void 0 ? void 0 : latex.trim()) === "") {
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: function () {
78
+ parseHTML() {
102
79
  return [
103
80
  {
104
81
  tag: "inline-math",
105
82
  },
106
83
  ];
107
84
  },
108
- renderHTML: function (_a) {
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: function () {
113
- var _this = this;
88
+ addInputRules() {
114
89
  return [
115
90
  new InputRule({
116
91
  find: /(^|[^$])(\$\$([^$\n]+?)\$\$)(?!\$)/,
117
- handler: function (_a) {
118
- var state = _a.state, range = _a.range, match = _a.match;
119
- var latex = match[3];
120
- var tr = state.tr;
121
- var start = range.from;
122
- var end = range.to;
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: function () {
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: function () {
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: function () {
17
+ parseHTML() {
18
18
  return [
19
19
  {
20
20
  tag: "page-clipping",
21
21
  },
22
22
  ];
23
23
  },
24
- renderHTML: function (_a) {
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
- var PNGScanner = /** @class */ (function () {
41
- function PNGScanner(buffer) {
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
- PNGScanner.prototype.advance = function (bytes) {
14
+ advance(bytes) {
49
15
  this.pos += bytes;
50
- };
16
+ }
51
17
  /**
52
18
  * Read an integer of specified byte length
53
19
  */
54
- PNGScanner.prototype.readInt = function (bytes) {
55
- var value;
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
- PNGScanner.prototype.readChar = function () {
41
+ readChar() {
76
42
  return this.readInt(1);
77
- };
43
+ }
78
44
  /**
79
45
  * Read a 2-byte short integer
80
46
  */
81
- PNGScanner.prototype.readShort = function () {
47
+ readShort() {
82
48
  return this.readInt(2);
83
- };
49
+ }
84
50
  /**
85
51
  * Read a 4-byte long integer
86
52
  */
87
- PNGScanner.prototype.readLong = function () {
53
+ readLong() {
88
54
  return this.readInt(4);
89
- };
55
+ }
90
56
  /**
91
57
  * Read a string of specified length
92
58
  */
93
- PNGScanner.prototype.readString = function (length) {
94
- var chars = [];
95
- for (var i = 0; i < length; i++) {
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
- PNGScanner.prototype.scan = function (callback) {
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
- var chunkLength = this.readLong();
113
- var chunkType = this.readString(4);
114
- var nextChunkPos = this.pos + chunkLength + 4;
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
- return PNGScanner;
123
- }());
87
+ }
88
+ }
124
89
  /**
125
90
  * Parse PNG metadata from a buffer
126
91
  */
127
- var parsePNGMetadata = function (buffer) {
128
- var scanner = new PNGScanner(buffer);
129
- var metadata = {
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
- var metersToInches = void 0;
142
- var xPixelsPerUnit = this.readLong();
143
- var yPixelsPerUnit = this.readLong();
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
- var extractPNGMetadata = function (file) { return __awaiter(void 0, void 0, void 0, function () {
165
- var buffer, error_1;
166
- return __generator(this, function (_a) {
167
- switch (_a.label) {
168
- case 0:
169
- _a.trys.push([0, 2, , 3]);
170
- return [4 /*yield*/, new Promise(function (resolve, reject) {
171
- var reader = new FileReader();
172
- reader.onload = function () { return resolve(reader.result); };
173
- reader.onerror = function () { return reject(reader.error); };
174
- reader.readAsArrayBuffer(file);
175
- })];
176
- case 1:
177
- buffer = _a.sent();
178
- return [2 /*return*/, buffer ? parsePNGMetadata(buffer) : null];
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 var getImageSize = function (file) { return __awaiter(void 0, void 0, void 0, function () {
191
- var metadata, actualWidth;
192
- return __generator(this, function (_a) {
193
- switch (_a.label) {
194
- case 0: return [4 /*yield*/, extractPNGMetadata(file)];
195
- case 1:
196
- metadata = _a.sent();
197
- if (!metadata) {
198
- return [2 /*return*/, { width: 0 }];
199
- }
200
- // For high DPI images (e.g., 144 PPI which is common for 2x retina displays)
201
- if (metadata.ppi === 144) {
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 var RichTextFormattingMenu = function (_a) {
11
- var allowComments = _a.allowComments, editor = _a.editor;
12
- var _b = useState(null), pageClipping = _b[0], setPageClipping = _b[1];
13
- var t = useTranslation().t;
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
- var mark_1 = editor.chain().focus().extendMarkRange("link");
17
- mark_1.unsetLink().run();
15
+ const mark = editor.chain().focus().extendMarkRange("link");
16
+ mark.unsetLink().run();
18
17
  return;
19
18
  }
20
- var previousUrl = editor.getAttributes("link").href;
21
- var url = window.prompt("Where do you want to link to? Enter a link that starts with 'https://'.", previousUrl);
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
- var mark_2 = editor.chain().focus().extendMarkRange("link");
29
- mark_2.unsetLink().run();
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
- var mark = editor.chain().focus().extendMarkRange("link");
35
+ const mark = editor.chain().focus().extendMarkRange("link");
37
36
  mark.setLink({ href: url }).run();
38
37
  }, [editor]);
39
- var state = useEditorState({
40
- editor: editor,
41
- selector: function (ctx) { return ({
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
- var actions = useMemo(function () {
58
- var items = [];
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: function () { return editor.chain().focus().toggleComment().run(); },
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: function () { return setPageClipping(editor.getAttributes("page-clipping")); },
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
- active: state.isImage || state.isFileAttachment,
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: function () {
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: function () {
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: function () {
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: function () {
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: function () {
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: function () {
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: function () {
136
- return editor.chain().focus()
137
- .insertInlineMath({ latex: "" })
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: function () { return setPageClipping(null); }, onUpdate: function (newParameters) {
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(function (item, index) { return (_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)); }) }) })] }));
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;