@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,45 +1,9 @@
1
1
  "use client";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- 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);
13
- return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (g && (g = 0, op[0] && (_ = 0)), _) try {
18
- 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;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
2
  import * as _React from "react";
39
3
  import * as _ReactDom from "react-dom";
40
4
  import * as _jsxRuntime from "react/jsx-runtime";
41
5
  import * as ExamplaryUI from "../../index";
42
- var componentCache = new Map();
6
+ const componentCache = new Map();
43
7
  /**
44
8
  * Little helper to evaluate the JS code in the context of the module.
45
9
  *
@@ -52,84 +16,79 @@ var componentCache = new Map();
52
16
  * However, if the code being evaluated here were to be modified by an attacker
53
17
  * after review, but before being loaded by users, then this could be a security risk.
54
18
  */
55
- var evalInScope = function (js, contextAsScope) {
56
- return new Function("\n with (this) { \n ".concat(js, "\n \n if (module.exports.default) {\n module.exports.default._context = this;\n }\n }\n ")).call(contextAsScope);
19
+ const evalInScope = (js, contextAsScope) => {
20
+ return new Function(`
21
+ with (this) {
22
+ ${js}
23
+
24
+ if (module.exports.default) {
25
+ module.exports.default._context = this;
26
+ }
27
+ }
28
+ `).call(contextAsScope);
57
29
  };
58
- export var loadComponentStyles = function (url) {
59
- if (document.querySelector("link[href=\"".concat(url, "\"]"))) {
30
+ export const loadComponentStyles = (url) => {
31
+ if (document.querySelector(`link[href="${url}"]`)) {
60
32
  return; // Styles already loaded
61
33
  }
62
- var link = document.createElement("link");
34
+ const link = document.createElement("link");
63
35
  link.rel = "stylesheet";
64
36
  link.href = url;
65
37
  link.dataset.source = "component-loader";
66
38
  document.head.appendChild(link);
67
39
  };
68
- export var evalComponent = function (js) { return __awaiter(void 0, void 0, void 0, function () {
69
- var _componentResult;
70
- return __generator(this, function (_a) {
71
- (function () {
72
- var _a;
73
- try {
74
- var module_1 = { exports: { default: null } };
75
- var require_1 = function (name) {
76
- if (name === "react")
77
- // @ts-expect-error default
78
- return _React.default || _React;
79
- if (name === "react-dom")
80
- // @ts-expect-error default
81
- return _ReactDom.default || _ReactDom;
82
- if (name === "react/jsx-runtime")
83
- // @ts-expect-error default
84
- return _jsxRuntime.default || _jsxRuntime;
85
- if (name === "@examplary/ui")
86
- // @ts-expect-error default
87
- return ExamplaryUI.default || ExamplaryUI;
88
- throw new Error("Module not found: ".concat(name));
89
- };
90
- evalInScope(js, {
91
- module: module_1,
92
- exports: module_1.exports,
40
+ export const evalComponent = async (js) => {
41
+ let _componentResult;
42
+ (() => {
43
+ try {
44
+ const module = { exports: { default: null } };
45
+ const require = (name) => {
46
+ if (name === "react")
93
47
  // @ts-expect-error default
94
- React: _React.default || _React,
95
- require: require_1,
96
- __dirname: "/web/task",
97
- __filename: "dynamic-module.js",
98
- });
99
- _componentResult = (_a = module_1.exports) === null || _a === void 0 ? void 0 : _a.default;
100
- if (!_componentResult) {
101
- throw new Error("No default export found in the module");
102
- }
103
- }
104
- catch (e) {
105
- console.error(e);
106
- throw new Error("Failed to evaluate component: ".concat(e.message));
48
+ return _React.default || _React;
49
+ if (name === "react-dom")
50
+ // @ts-expect-error default
51
+ return _ReactDom.default || _ReactDom;
52
+ if (name === "react/jsx-runtime")
53
+ // @ts-expect-error default
54
+ return _jsxRuntime.default || _jsxRuntime;
55
+ if (name === "@examplary/ui")
56
+ // @ts-expect-error default
57
+ return ExamplaryUI.default || ExamplaryUI;
58
+ throw new Error(`Module not found: ${name}`);
59
+ };
60
+ evalInScope(js, {
61
+ module,
62
+ exports: module.exports,
63
+ // @ts-expect-error default
64
+ React: _React.default || _React,
65
+ require,
66
+ __dirname: "/web/task",
67
+ __filename: "dynamic-module.js",
68
+ });
69
+ _componentResult = module.exports?.default;
70
+ if (!_componentResult) {
71
+ throw new Error("No default export found in the module");
107
72
  }
108
- })();
109
- return [2 /*return*/, _componentResult];
110
- });
111
- }); };
112
- export var fetchComponent = function (url) { return __awaiter(void 0, void 0, void 0, function () {
113
- var js, res;
114
- return __generator(this, function (_a) {
115
- switch (_a.label) {
116
- case 0:
117
- if (componentCache.has(url)) {
118
- return [2 /*return*/, componentCache.get(url)];
119
- }
120
- return [4 /*yield*/, fetch(url).then(function (res) {
121
- if (!res.ok) {
122
- throw new Error("Failed to fetch component from ".concat(url, ": ").concat(res.status, " ").concat(res.statusText));
123
- }
124
- return res.text();
125
- })];
126
- case 1:
127
- js = _a.sent();
128
- return [4 /*yield*/, evalComponent(js)];
129
- case 2:
130
- res = _a.sent();
131
- componentCache.set(url, res);
132
- return [2 /*return*/, res];
133
73
  }
74
+ catch (e) {
75
+ console.error(e);
76
+ throw new Error(`Failed to evaluate component: ${e.message}`);
77
+ }
78
+ })();
79
+ return _componentResult;
80
+ };
81
+ export const fetchComponent = async (url) => {
82
+ if (componentCache.has(url)) {
83
+ return componentCache.get(url);
84
+ }
85
+ const js = await fetch(url).then((res) => {
86
+ if (!res.ok) {
87
+ throw new Error(`Failed to fetch component from ${url}: ${res.status} ${res.statusText}`);
88
+ }
89
+ return res.text();
134
90
  });
135
- }); };
91
+ const res = await evalComponent(js);
92
+ componentCache.set(url, res);
93
+ return res;
94
+ };
@@ -14,63 +14,63 @@ export declare const formatQuestionType: (type: QuestionType, i18n: any) => {
14
14
  options: {
15
15
  label: any;
16
16
  value: string;
17
- }[];
17
+ }[] | undefined;
18
18
  id: string;
19
19
  type: "string" | "number" | "boolean" | "tags" | "enum" | "custom" | "string-array" | "scoring-criteria" | "question-type";
20
- description?: string;
21
- index?: number;
22
- hidden?: boolean;
20
+ description?: string | undefined;
21
+ index?: number | undefined;
22
+ hidden?: boolean | undefined;
23
23
  default?: any;
24
- required?: boolean;
25
- step?: number;
26
- min?: number;
27
- max?: number;
28
- }[];
24
+ required?: boolean | undefined;
25
+ step?: number | undefined;
26
+ min?: number | undefined;
27
+ max?: number | undefined;
28
+ }[] | undefined;
29
29
  id: string;
30
- $schema?: string;
31
- icon?: string;
32
- shortcut?: string;
30
+ $schema?: string | undefined;
31
+ icon?: string | undefined;
32
+ shortcut?: string | undefined;
33
33
  generation?: {
34
34
  enabled: boolean;
35
- instructions?: string | string[];
36
- };
35
+ instructions?: string | string[] | undefined;
36
+ } | undefined;
37
37
  grading?: {
38
38
  enabled: boolean;
39
- instructions?: string | string[];
40
- };
39
+ instructions?: string | string[] | undefined;
40
+ } | undefined;
41
41
  scanning?: {
42
- instructions?: string | string[];
43
- };
44
- timeEstimateMinutes?: number;
45
- isAi?: boolean;
46
- backgroundColor?: string;
47
- enforcePosition?: "end" | "start";
48
- hideSettings?: boolean;
49
- isPreviewRefreshable?: boolean;
50
- hasSimpleScoring?: boolean;
42
+ instructions?: string | string[] | undefined;
43
+ } | undefined;
44
+ timeEstimateMinutes?: number | undefined;
45
+ isAi?: boolean | undefined;
46
+ backgroundColor?: string | undefined;
47
+ enforcePosition?: "end" | "start" | undefined;
48
+ hideSettings?: boolean | undefined;
49
+ isPreviewRefreshable?: boolean | undefined;
50
+ hasSimpleScoring?: boolean | undefined;
51
51
  components?: {
52
- assessment?: string;
53
- print?: string;
54
- "settings-area"?: string;
55
- results?: string;
56
- };
57
- public?: boolean;
58
- translations?: Record<string, string | Record<string, string>>;
52
+ assessment?: string | undefined;
53
+ print?: string | undefined;
54
+ "settings-area"?: string | undefined;
55
+ results?: string | undefined;
56
+ } | undefined;
57
+ public?: boolean | undefined;
58
+ translations?: Record<string, string | Record<string, string>> | undefined;
59
59
  capabilities?: {
60
60
  [x: string]: unknown;
61
- "answer-scanning"?: boolean;
62
- };
61
+ "answer-scanning"?: boolean | undefined;
62
+ } | undefined;
63
63
  export?: {
64
64
  qti3?: {
65
65
  interaction: {
66
66
  type: "AssociateInteraction" | "ChoiceInteraction" | "DrawingInteraction" | "EndAttemptInteraction" | "ExtendedTextInteraction" | "GapMatchInteraction" | "GraphicAssociateInteraction" | "GraphicGapMatchInteraction" | "GraphicOrderInteraction" | "HotspotInteraction" | "HottextInteraction" | "InlineChoiceInteraction" | "MatchInteraction" | "MediaInteraction" | "OrderInteraction" | "PortableCustomInteraction" | "PositionObjectInteraction" | "SelectPointInteraction" | "SliderInteraction" | "TextEntryInteraction" | "UploadInteraction";
67
- options?: Record<string, string | number | boolean | any[] | Record<string, never>>;
67
+ options?: Record<string, string | number | boolean | any[] | Record<string, never>> | undefined;
68
68
  };
69
- };
70
- };
71
- metadata?: Record<string, string | number | boolean>;
72
- stylesheet?: string;
73
- index?: number;
74
- isDefault?: boolean;
69
+ } | undefined;
70
+ } | undefined;
71
+ metadata?: Record<string, string | number | boolean | null> | undefined;
72
+ stylesheet?: string | undefined;
73
+ index?: number | undefined;
74
+ isDefault?: boolean | undefined;
75
75
  };
76
76
  export type FormattedQuestionType = ReturnType<typeof formatQuestionType>;
@@ -1,22 +1,10 @@
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
- export var formatQuestionType = function (type, i18n) {
13
- var _a, _b;
14
- var locale = i18n.language;
15
- var translationNs = "question_type_".concat(type.id);
16
- var scopedT = i18n.getFixedT(locale, translationNs);
1
+ export const formatQuestionType = (type, i18n) => {
2
+ const locale = i18n.language;
3
+ const translationNs = `question_type_${type.id}`;
4
+ const scopedT = i18n.getFixedT(locale, translationNs);
17
5
  // Load the translations for the question type
18
- var resources = {};
19
- var extractTranslations = function (key, obj) {
6
+ const resources = {};
7
+ const extractTranslations = (key, obj) => {
20
8
  if (!obj)
21
9
  return;
22
10
  if (typeof obj === "string") {
@@ -25,8 +13,7 @@ export var formatQuestionType = function (type, i18n) {
25
13
  resources[locale][key] = obj;
26
14
  }
27
15
  else if (typeof obj === "object") {
28
- Object.entries(obj).forEach(function (_a) {
29
- var lang = _a[0], value = _a[1];
16
+ Object.entries(obj).forEach(([lang, value]) => {
30
17
  if (!resources[lang])
31
18
  resources[lang] = {};
32
19
  resources[lang][key] = value;
@@ -39,25 +26,37 @@ export var formatQuestionType = function (type, i18n) {
39
26
  extractTranslations("titlePlaceholder", type.titlePlaceholder);
40
27
  extractTranslations("descriptionPlaceholder", type.descriptionPlaceholder);
41
28
  extractTranslations("untitledPlaceholder", type.untitledPlaceholder);
42
- (_a = type.settings) === null || _a === void 0 ? void 0 : _a.forEach(function (setting) {
43
- var _a;
44
- extractTranslations("settings.".concat(setting.id, ".name"), setting.name);
45
- extractTranslations("settings.".concat(setting.id, ".helpText"), setting.helpText);
46
- extractTranslations("settings.".concat(setting.id, ".placeholder"), setting.placeholder);
47
- (_a = setting.options) === null || _a === void 0 ? void 0 : _a.forEach(function (option) {
48
- extractTranslations("settings.".concat(setting.id, ".options.").concat(option.value), option.label);
29
+ type.settings?.forEach((setting) => {
30
+ extractTranslations(`settings.${setting.id}.name`, setting.name);
31
+ extractTranslations(`settings.${setting.id}.helpText`, setting.helpText);
32
+ extractTranslations(`settings.${setting.id}.placeholder`, setting.placeholder);
33
+ setting.options?.forEach((option) => {
34
+ extractTranslations(`settings.${setting.id}.options.${option.value}`, option.label);
49
35
  });
50
36
  });
51
- Object.entries((type === null || type === void 0 ? void 0 : type.translations) || {}).forEach(function (_a) {
52
- var key = _a[0], value = _a[1];
53
- return extractTranslations(key, value);
54
- });
55
- for (var lang in resources) {
37
+ Object.entries(type?.translations || {}).forEach(([key, value]) => extractTranslations(key, value));
38
+ for (const lang in resources) {
56
39
  i18n.addResources(lang, translationNs, resources[lang]);
57
40
  }
58
- return __assign(__assign({}, type), { translationNs: translationNs, name: type.name && scopedT("name"), description: type.description && scopedT("description"), enforceTitle: type.enforceTitle && scopedT("enforceTitle"), titlePlaceholder: type.titlePlaceholder && scopedT("titlePlaceholder"), descriptionPlaceholder: type.descriptionPlaceholder && scopedT("descriptionPlaceholder"), untitledPlaceholder: type.untitledPlaceholder && scopedT("untitledPlaceholder"), settings: (_b = type.settings) === null || _b === void 0 ? void 0 : _b.map(function (setting) {
59
- var _a;
60
- return (__assign(__assign({}, setting), { name: setting.name && scopedT("settings.".concat(setting.id, ".name")), helpText: setting.helpText && scopedT("settings.".concat(setting.id, ".helpText")), placeholder: setting.placeholder && scopedT("settings.".concat(setting.id, ".placeholder")), options: (_a = setting.options) === null || _a === void 0 ? void 0 : _a.map(function (option) { return (__assign(__assign({}, option), { label: option.label &&
61
- scopedT("settings.".concat(setting.id, ".options.").concat(option.value)) })); }) }));
62
- }) });
41
+ return {
42
+ ...type,
43
+ translationNs,
44
+ name: type.name && scopedT("name"),
45
+ description: type.description && scopedT("description"),
46
+ enforceTitle: type.enforceTitle && scopedT("enforceTitle"),
47
+ titlePlaceholder: type.titlePlaceholder && scopedT("titlePlaceholder"),
48
+ descriptionPlaceholder: type.descriptionPlaceholder && scopedT("descriptionPlaceholder"),
49
+ untitledPlaceholder: type.untitledPlaceholder && scopedT("untitledPlaceholder"),
50
+ settings: type.settings?.map((setting) => ({
51
+ ...setting,
52
+ name: setting.name && scopedT(`settings.${setting.id}.name`),
53
+ helpText: setting.helpText && scopedT(`settings.${setting.id}.helpText`),
54
+ placeholder: setting.placeholder && scopedT(`settings.${setting.id}.placeholder`),
55
+ options: setting.options?.map((option) => ({
56
+ ...option,
57
+ label: option.label &&
58
+ scopedT(`settings.${setting.id}.options.${option.value}`),
59
+ })),
60
+ })),
61
+ };
63
62
  };
@@ -1,7 +1,7 @@
1
1
  import { Editor, EditorContentProps } from "@tiptap/react";
2
+ import { CommentAuthor } from "tiptap-inline-comments";
2
3
  import { XmlFragment } from "yjs";
3
- import { CommentAuthor } from "./tiptap/comments/types";
4
- export declare const getEditorById: (id: string) => Editor;
4
+ export declare const getEditorById: (id: string) => Editor | undefined;
5
5
  export type MinimalRichTextFieldProps = {
6
6
  className?: string;
7
7
  value?: string;
@@ -1,35 +1,4 @@
1
1
  "use client";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __rest = (this && this.__rest) || function (s, e) {
14
- var t = {};
15
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
- t[p] = s[p];
17
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
- t[p[i]] = s[p[i]];
21
- }
22
- return t;
23
- };
24
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
25
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
26
- if (ar || !(i in from)) {
27
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
28
- ar[i] = from[i];
29
- }
30
- }
31
- return to.concat(ar || Array.prototype.slice.call(from));
32
- };
33
2
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
34
3
  import { useEffect, useMemo, useState } from "react";
35
4
  import Collaboration from "@tiptap/extension-collaboration";
@@ -37,42 +6,40 @@ import Document from "@tiptap/extension-document";
37
6
  import Placeholder from "@tiptap/extension-placeholder";
38
7
  import { UndoRedo } from "@tiptap/extensions";
39
8
  import { EditorContent, useEditor, } from "@tiptap/react";
9
+ import { InlineComments } from "tiptap-inline-comments";
40
10
  import { CollaborationCaret } from "./tiptap/collaboration-caret";
41
11
  import { cn } from "../../utils";
42
12
  import { registerWebComponents } from "../web-components";
43
- import { Comment } from "./tiptap/comments/comment";
44
13
  import { CommentBubble } from "./tiptap/comments/comment-bubble";
45
- import { CommentReply } from "./tiptap/comments/comment-reply";
46
14
  import { defaultRichTextExtensions } from "./tiptap/extensions";
47
15
  import { fileHandler } from "./tiptap/file-handler";
48
16
  import Image from "./tiptap/image";
49
17
  import { RichTextFormattingMenu } from "./tiptap/rich-text-formatting-menu";
50
18
  registerWebComponents();
51
- var textEditors = new Map();
52
- export var getEditorById = function (id) {
19
+ const textEditors = new Map();
20
+ export const getEditorById = (id) => {
53
21
  return textEditors.get(id);
54
22
  };
55
- var CustomCollaboration = Collaboration.extend({
56
- addCommands: function () {
23
+ const CustomCollaboration = Collaboration.extend({
24
+ addCommands() {
57
25
  return {
58
- undo: function () { return function () {
26
+ undo: () => () => {
59
27
  return false;
60
- }; },
61
- redo: function () { return function () {
28
+ },
29
+ redo: () => () => {
62
30
  return false;
63
- }; },
31
+ },
64
32
  };
65
33
  },
66
- addKeyboardShortcuts: function () {
34
+ addKeyboardShortcuts() {
67
35
  return {};
68
36
  },
69
37
  });
70
- var isEmpty = function (value) {
71
- var _a;
38
+ const isEmpty = (value) => {
72
39
  if (!value) {
73
40
  return true;
74
41
  }
75
- if (!((_a = value.trim) === null || _a === void 0 ? void 0 : _a.call(value))) {
42
+ if (!value.trim?.()) {
76
43
  return true;
77
44
  }
78
45
  if (value.trim() === "<p></p>" || value.trim() === "<p><br></p>") {
@@ -83,63 +50,58 @@ var isEmpty = function (value) {
83
50
  }
84
51
  return false;
85
52
  };
86
- export var MinimalRichTextField = function (_a) {
87
- var _b = _a.className, className = _b === void 0 ? "" : _b, _c = _a.value, value = _c === void 0 ? "" : _c, defaultValue = _a.defaultValue, _d = _a.placeholder, placeholder = _d === void 0 ? "" : _d, onChange = _a.onChange, onBlur = _a.onBlur, slotBefore = _a.slotBefore, style = _a.style, _e = _a.singleLine, singleLine = _e === void 0 ? false : _e, _f = _a.autoFocus, autoFocus = _f === void 0 ? false : _f, _g = _a.showFormattingMenu, showFormattingMenu = _g === void 0 ? false : _g, commentAuthor = _a.commentAuthor, _h = _a.uploadFile, uploadFile = _h === void 0 ? undefined : _h, fragment = _a.fragment, awareness = _a.awareness, id = _a.id, props = __rest(_a, ["className", "value", "defaultValue", "placeholder", "onChange", "onBlur", "slotBefore", "style", "singleLine", "autoFocus", "showFormattingMenu", "commentAuthor", "uploadFile", "fragment", "awareness", "id"]);
88
- var _j = useState(value), content = _j[0], setContent = _j[1];
89
- var extensions = useMemo(function () {
90
- return __spreadArray(__spreadArray([], defaultRichTextExtensions, true), [
91
- singleLine
92
- ? Document.extend({
93
- content: "block",
94
- })
95
- : Document,
96
- Image,
97
- !fragment && UndoRedo,
98
- fragment &&
99
- CustomCollaboration.configure({
100
- fragment: fragment,
101
- }),
102
- awareness && CollaborationCaret.configure({ awareness: awareness }),
103
- placeholder && Placeholder.configure({ placeholder: placeholder }),
104
- uploadFile && fileHandler(uploadFile),
105
- commentAuthor && Comment.configure({ createdBy: commentAuthor }),
106
- commentAuthor && CommentReply.configure({ createdBy: commentAuthor }),
107
- ], false).filter(Boolean);
108
- }, [singleLine, placeholder, uploadFile, fragment, awareness, commentAuthor]);
109
- var editor = useEditor({
110
- onUpdate: function (_a) {
111
- var editor = _a.editor;
53
+ export const MinimalRichTextField = ({ className = "", value = "", defaultValue, placeholder = "", onChange, onBlur, slotBefore, style, singleLine = false, autoFocus = false, showFormattingMenu = false, commentAuthor, uploadFile = undefined, fragment, awareness, id, ...props }) => {
54
+ const [content, setContent] = useState(value);
55
+ const extensions = useMemo(() => [
56
+ ...defaultRichTextExtensions,
57
+ singleLine
58
+ ? Document.extend({
59
+ content: "block",
60
+ })
61
+ : Document,
62
+ Image,
63
+ !fragment && UndoRedo,
64
+ fragment &&
65
+ CustomCollaboration.configure({
66
+ fragment,
67
+ }),
68
+ awareness && CollaborationCaret.configure({ awareness }),
69
+ placeholder && Placeholder.configure({ placeholder }),
70
+ uploadFile && fileHandler(uploadFile),
71
+ commentAuthor && InlineComments.configure({ createdBy: commentAuthor }),
72
+ ].filter(Boolean), [singleLine, placeholder, uploadFile, fragment, awareness, commentAuthor]);
73
+ const editor = useEditor({
74
+ onUpdate: ({ editor }) => {
112
75
  if (onChange || !fragment) {
113
- var html = editor.getHTML();
76
+ let html = editor.getHTML();
114
77
  html = isEmpty(html) ? "" : html;
115
78
  setContent(html);
116
- onChange === null || onChange === void 0 ? void 0 : onChange(html);
79
+ onChange?.(html);
117
80
  }
118
81
  },
119
- onBlur: function (_a) {
120
- var editor = _a.editor;
82
+ onBlur: ({ editor }) => {
121
83
  if (onBlur) {
122
- var html = editor.getHTML();
84
+ let html = editor.getHTML();
123
85
  html = isEmpty(html) ? "" : html;
124
86
  onBlur(html);
125
87
  }
126
88
  },
127
89
  autofocus: autoFocus,
128
90
  content: fragment ? undefined : content,
129
- extensions: extensions,
91
+ extensions,
130
92
  editorProps: {
131
93
  attributes: {
132
- class: cn("max-w-none", className),
94
+ class: cn(`max-w-none`, className),
133
95
  style: style,
134
96
  },
135
97
  },
136
98
  });
137
- useEffect(function () {
99
+ useEffect(() => {
138
100
  if (fragment)
139
101
  return;
140
102
  if (value !== content && defaultValue === undefined) {
141
103
  setContent(value);
142
- editor === null || editor === void 0 ? void 0 : editor.commands.setContent(value, {
104
+ editor?.commands.setContent(value, {
143
105
  emitUpdate: false,
144
106
  parseOptions: {
145
107
  preserveWhitespace: "full",
@@ -147,12 +109,12 @@ export var MinimalRichTextField = function (_a) {
147
109
  });
148
110
  }
149
111
  }, [value, content, editor, fragment]);
150
- useEffect(function () {
112
+ useEffect(() => {
151
113
  if (fragment)
152
114
  return;
153
115
  if (defaultValue !== undefined) {
154
116
  setContent(defaultValue);
155
- editor === null || editor === void 0 ? void 0 : editor.commands.setContent(defaultValue, {
117
+ editor?.commands.setContent(defaultValue, {
156
118
  emitUpdate: false,
157
119
  parseOptions: {
158
120
  preserveWhitespace: "full",
@@ -160,15 +122,15 @@ export var MinimalRichTextField = function (_a) {
160
122
  });
161
123
  }
162
124
  }, [defaultValue, fragment]);
163
- useEffect(function () {
125
+ useEffect(() => {
164
126
  if (!editor || !id)
165
127
  return;
166
128
  textEditors.set(id, editor);
167
- return function () {
129
+ return () => {
168
130
  if (textEditors.get(id) === editor) {
169
131
  textEditors.delete(id);
170
132
  }
171
133
  };
172
134
  }, [editor, id]);
173
- return (_jsxs(_Fragment, { children: [slotBefore ? slotBefore(editor) : null, showFormattingMenu && (_jsx(RichTextFormattingMenu, { allowComments: !!commentAuthor, editor: editor })), !!commentAuthor && (_jsx(CommentBubble, { editor: editor, commentAuthor: commentAuthor })), _jsx(EditorContent, __assign({ editor: editor }, props))] }));
135
+ return (_jsxs(_Fragment, { children: [slotBefore ? slotBefore(editor) : null, showFormattingMenu && (_jsx(RichTextFormattingMenu, { allowComments: !!commentAuthor, editor: editor })), !!commentAuthor && (_jsx(CommentBubble, { editor: editor, commentAuthor: commentAuthor })), _jsx(EditorContent, { editor: editor, ...props })] }));
174
136
  };