magic-editor-x 1.5.1 → 2.0.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 (97) hide show
  1. package/CHANGELOG.md +268 -0
  2. package/LICENSE +1 -7
  3. package/README.md +317 -1078
  4. package/dist/admin/ConfigurationPage-B1uCIE3J.js +767 -0
  5. package/dist/admin/ConfigurationPage-DvAifELO.mjs +767 -0
  6. package/dist/admin/CustomBlocksPage-6-OQwpXQ.mjs +1741 -0
  7. package/dist/admin/CustomBlocksPage-6eWCOreU.js +1743 -0
  8. package/dist/admin/EditorField-DocyD2Q3.js +5506 -0
  9. package/dist/admin/EditorField-ThSoOCPm.mjs +5471 -0
  10. package/dist/admin/api-B-RsxJCs.js +34 -0
  11. package/dist/admin/api-C4XsDZxd.mjs +35 -0
  12. package/dist/admin/de-B8XFFhHh.js +95 -0
  13. package/dist/admin/de-BMxADn2Z.mjs +231 -0
  14. package/dist/admin/de-DBR893G4.js +13 -0
  15. package/dist/admin/de-DcDPRzV4.js +155 -0
  16. package/dist/admin/de-Dx7vUW0Z.js +231 -0
  17. package/dist/admin/de-RAxzvrwm.mjs +95 -0
  18. package/dist/admin/de-fBFh09Wl.mjs +13 -0
  19. package/dist/admin/de-n5V6c5RT.mjs +155 -0
  20. package/dist/admin/en-BQ5Pxe2o.mjs +231 -0
  21. package/dist/admin/en-BqNm3nMQ.mjs +155 -0
  22. package/dist/admin/en-BzfyifEU.mjs +95 -0
  23. package/dist/admin/en-D-DGftl0.js +155 -0
  24. package/dist/admin/en-D9Nfccux.mjs +13 -0
  25. package/dist/admin/en-DcWUTE2J.js +95 -0
  26. package/dist/admin/en-gueRT44P.js +13 -0
  27. package/dist/admin/en-sNn4z9lA.js +231 -0
  28. package/dist/admin/es-B0Zy8DVg.mjs +13 -0
  29. package/dist/admin/es-B6NYq0VH.mjs +231 -0
  30. package/dist/admin/es-BOtVc9qv.js +95 -0
  31. package/dist/admin/es-C2OJVYkV.mjs +95 -0
  32. package/dist/admin/es-DRGs7meF.js +13 -0
  33. package/dist/admin/es-DVsXnS0N.js +231 -0
  34. package/dist/admin/es-Di0pyQCh.js +155 -0
  35. package/dist/admin/es-SzeTV4q8.mjs +155 -0
  36. package/dist/admin/fr-B8rdLAIL.js +13 -0
  37. package/dist/admin/fr-Bpo5Uq1f.mjs +95 -0
  38. package/dist/admin/fr-D6F--jIB.js +155 -0
  39. package/dist/admin/fr-DfxKaOc_.js +95 -0
  40. package/dist/admin/fr-DhgPYHIH.mjs +155 -0
  41. package/dist/admin/fr-DmG3_Cn-.mjs +231 -0
  42. package/dist/admin/fr-Fwxcj4SM.js +231 -0
  43. package/dist/admin/fr-oiUb2bb_.mjs +13 -0
  44. package/dist/admin/index-CwfaB5-e.js +155 -0
  45. package/dist/admin/index-D1Q5Rlt6.mjs +156 -0
  46. package/dist/admin/index.js +3 -2
  47. package/dist/admin/index.mjs +1 -1
  48. package/dist/admin/pt-B3Jce6uT.mjs +13 -0
  49. package/dist/admin/pt-BPo0ex21.js +155 -0
  50. package/dist/admin/pt-BbdwHlWF.mjs +231 -0
  51. package/dist/admin/pt-BiWuSBcH.js +13 -0
  52. package/dist/admin/pt-BvSl1btT.mjs +155 -0
  53. package/dist/admin/pt-C6nr71Yw.js +231 -0
  54. package/dist/admin/pt-DqCXuI4S.mjs +95 -0
  55. package/dist/admin/pt-LCvjwk0y.js +95 -0
  56. package/dist/admin/sanitize-9UVcXFfc.js +552 -0
  57. package/dist/admin/sanitize-D4kfZ_ly.mjs +551 -0
  58. package/dist/admin/useT-B5M49wGH.js +130 -0
  59. package/dist/admin/useT-CjX6fL2m.mjs +131 -0
  60. package/dist/server/index.js +4531 -39542
  61. package/dist/server/index.mjs +4534 -39527
  62. package/package.json +111 -74
  63. package/strapi-admin.js +3 -0
  64. package/strapi-server.js +3 -0
  65. package/COPYRIGHT_NOTICE.txt +0 -20
  66. package/dist/_chunks/App-DImBvISP.js +0 -2146
  67. package/dist/_chunks/App-iNfbV7cz.mjs +0 -2143
  68. package/dist/_chunks/CustomBlocksPage-COPOZ2-_.mjs +0 -1517
  69. package/dist/_chunks/CustomBlocksPage-Cj-0TTUs.js +0 -1519
  70. package/dist/_chunks/LicensePage-CmvILX9m.js +0 -393
  71. package/dist/_chunks/LicensePage-gLRoo8WJ.mjs +0 -391
  72. package/dist/_chunks/LiveCollaborationPanel-BFybu8h0.js +0 -222
  73. package/dist/_chunks/LiveCollaborationPanel-CVgl4IyR.mjs +0 -220
  74. package/dist/_chunks/Settings-ButYcfrm.mjs +0 -438
  75. package/dist/_chunks/Settings-BzGqgrxD.js +0 -440
  76. package/dist/_chunks/de-C_0Mj-Zo.mjs +0 -296
  77. package/dist/_chunks/de-DVNVpAt9.js +0 -296
  78. package/dist/_chunks/en-B7AAf1ie.mjs +0 -296
  79. package/dist/_chunks/en-C2hv5GsA.js +0 -296
  80. package/dist/_chunks/es-BzJqcIST.js +0 -274
  81. package/dist/_chunks/es-zdP8sd-f.mjs +0 -274
  82. package/dist/_chunks/fr-CtAgOgH1.mjs +0 -274
  83. package/dist/_chunks/fr-D3GwqAAJ.js +0 -274
  84. package/dist/_chunks/getTranslation-BADoesEn.js +0 -57807
  85. package/dist/_chunks/getTranslation-D3h3Z3gU.mjs +0 -57791
  86. package/dist/_chunks/index-BXBnwuRw.js +0 -2158
  87. package/dist/_chunks/index-BvEdg518.mjs +0 -2159
  88. package/dist/_chunks/index-DDFAuQNT.js +0 -6955
  89. package/dist/_chunks/index-DEi6nwfM.mjs +0 -6933
  90. package/dist/_chunks/pt-BmUw6YMP.mjs +0 -274
  91. package/dist/_chunks/pt-CFo0nTbj.js +0 -274
  92. package/dist/_chunks/tools-BXzd0lx5.mjs +0 -2265
  93. package/dist/_chunks/tools-Q0uwDS9E.js +0 -2296
  94. package/dist/style.css +0 -1103
  95. package/pics/collab-magiceditorX.png +0 -0
  96. package/pics/editorX.png +0 -0
  97. package/pics/liveCollabwidget1.png +0 -0
@@ -1,391 +0,0 @@
1
- import { jsx, jsxs } from "react/jsx-runtime";
2
- import { useState, useEffect } from "react";
3
- import { useFetchClient, useNotification } from "@strapi/strapi/admin";
4
- import { u as useIntl, T, V as Vd, I, P as Ps, R, g as getTranslation, z as zn } from "./getTranslation-D3h3Z3gU.mjs";
5
- import styled from "styled-components";
6
- import { t as t5, C as C5, S as Sn, a as C3, l as ln } from "./index-BvEdg518.mjs";
7
- const Container = styled(R)`
8
- padding: 32px;
9
- max-width: 1400px;
10
- margin: 0 auto;
11
- `;
12
- const Header = styled(R)`
13
- text-align: center;
14
- margin-bottom: 48px;
15
- display: flex;
16
- flex-direction: column;
17
- align-items: center;
18
- gap: 8px;
19
- `;
20
- const Title = styled(I)`
21
- font-size: 2.5rem;
22
- font-weight: 700;
23
- margin-bottom: 8px;
24
- background: linear-gradient(135deg, #7C3AED, #6d28d9);
25
- -webkit-background-clip: text;
26
- -webkit-text-fill-color: transparent;
27
- display: block;
28
- `;
29
- const Subtitle = styled(I)`
30
- font-size: 1.125rem;
31
- color: ${(props) => props.theme.colors.neutral600};
32
- line-height: 1.6;
33
- display: block;
34
- `;
35
- const TierGrid = styled(T)`
36
- gap: 32px;
37
- margin: 0 auto 48px;
38
- max-width: 1080px;
39
- justify-content: center;
40
- flex-wrap: wrap;
41
- align-items: stretch;
42
- `;
43
- const TierWrapper = styled(R)`
44
- flex: 1;
45
- min-width: 280px;
46
- max-width: 340px;
47
- display: flex;
48
- `;
49
- const TierCard = styled(R)`
50
- background: ${(props) => props.theme.colors.neutral0};
51
- border-radius: 16px;
52
- padding: 32px;
53
- border: 2px solid ${(props) => props.$featured ? "#7C3AED" : props.theme.colors.neutral200};
54
- position: relative;
55
- transition: all 0.3s ease;
56
- box-shadow: ${(props) => props.$featured ? "0 20px 25px -5px rgba(124, 58, 237, 0.25), 0 8px 10px -6px rgba(124, 58, 237, 0.2)" : "0 10px 15px -3px rgba(15, 23, 42, 0.08), 0 4px 6px -4px rgba(15, 23, 42, 0.05)"};
57
- display: flex;
58
- flex-direction: column;
59
- width: 100%;
60
-
61
- &:hover {
62
- transform: translateY(-4px);
63
- box-shadow: 0 20px 25px -5px rgba(15, 23, 42, 0.15), 0 8px 10px -6px rgba(15, 23, 42, 0.1);
64
- }
65
- `;
66
- const PopularBadge = styled(Ps)`
67
- position: absolute;
68
- top: -12px;
69
- right: 24px;
70
- background: linear-gradient(135deg, #7C3AED, #6d28d9);
71
- color: white;
72
- padding: 4px 16px;
73
- font-size: 12px;
74
- font-weight: 600;
75
- `;
76
- const TierIcon = styled(R)`
77
- width: 48px;
78
- height: 48px;
79
- border-radius: 12px;
80
- display: flex;
81
- align-items: center;
82
- justify-content: center;
83
- margin-bottom: 16px;
84
- background: ${(props) => props.$color};
85
-
86
- svg {
87
- width: 28px;
88
- height: 28px;
89
- color: white;
90
- }
91
- `;
92
- const TierName = styled(I)`
93
- font-size: 1.5rem;
94
- font-weight: 700;
95
- margin-bottom: 8px;
96
- `;
97
- const TierPrice = styled(I)`
98
- font-size: 2rem;
99
- font-weight: 800;
100
- margin-bottom: 4px;
101
- `;
102
- const TierDescription = styled(I)`
103
- color: ${(props) => props.theme.colors.neutral600};
104
- margin-bottom: 24px;
105
- `;
106
- const FeatureList = styled(R)`
107
- margin-bottom: 24px;
108
- flex: 1;
109
- `;
110
- const Feature = styled(T)`
111
- gap: 12px;
112
- margin-bottom: 12px;
113
- align-items: flex-start;
114
- `;
115
- const FeatureIcon = styled(R)`
116
- width: 20px;
117
- height: 20px;
118
- border-radius: 50%;
119
- display: flex;
120
- align-items: center;
121
- justify-content: center;
122
- flex-shrink: 0;
123
- margin-top: 2px;
124
-
125
- ${(props) => props.$included ? `
126
- background: #DCFCE7;
127
- svg { color: #16A34A; }
128
- ` : `
129
- background: #FEE2E2;
130
- svg { color: #DC2626; }
131
- `}
132
- `;
133
- const UpgradeButton = styled(zn)`
134
- width: 100%;
135
- height: 48px;
136
- font-weight: 600;
137
- font-size: 15px;
138
- background: ${(props) => props.$gradient};
139
- border: none;
140
- color: white;
141
-
142
- &:hover {
143
- transform: translateY(-2px);
144
- box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
145
- }
146
- `;
147
- const CurrentPlanBadge = styled(Ps)`
148
- width: 100%;
149
- height: 48px;
150
- display: flex;
151
- align-items: center;
152
- justify-content: center;
153
- background: ${(props) => props.theme.colors.neutral100};
154
- color: ${(props) => props.theme.colors.neutral600};
155
- font-weight: 600;
156
- font-size: 15px;
157
- `;
158
- const UsageBox = styled(R)`
159
- background: ${(props) => props.theme.colors.neutral100};
160
- border: 1px solid ${(props) => props.theme.colors.neutral200};
161
- border-radius: 12px;
162
- padding: 20px;
163
- margin-bottom: 32px;
164
- `;
165
- const UsageBar = styled.div`
166
- height: 8px;
167
- background: ${(props) => props.theme.colors.neutral200};
168
- border-radius: 4px;
169
- overflow: hidden;
170
- margin-top: 8px;
171
- `;
172
- const UsageProgress = styled.div`
173
- height: 100%;
174
- background: ${(props) => props.$percentage > 80 ? "#ef4444" : props.$percentage > 50 ? "#f59e0b" : "#10b981"};
175
- width: ${(props) => Math.min(props.$percentage, 100)}%;
176
- transition: width 0.3s ease;
177
- `;
178
- const LicensePage = () => {
179
- const { formatMessage } = useIntl();
180
- const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
181
- const { get } = useFetchClient();
182
- const { toggleNotification } = useNotification();
183
- const [currentTier, setCurrentTier] = useState("free");
184
- const [limits, setLimits] = useState(null);
185
- const [loading, setLoading] = useState(true);
186
- useEffect(() => {
187
- fetchLicenseInfo();
188
- }, []);
189
- const fetchLicenseInfo = async () => {
190
- try {
191
- const response = await get("/magic-editor-x/license/limits");
192
- const licenseData = response.data || {};
193
- setCurrentTier(licenseData.tier || "free");
194
- setLimits(licenseData.limits);
195
- setLoading(false);
196
- } catch (error) {
197
- console.error("Failed to fetch license info:", error);
198
- setLoading(false);
199
- }
200
- };
201
- const getTierRank = (tierId) => {
202
- const ranks = {
203
- "free": 0,
204
- "premium": 1,
205
- "advanced": 2,
206
- "enterprise": 3
207
- };
208
- return ranks[tierId] || 0;
209
- };
210
- const getButtonText = (tierId) => {
211
- const currentRank = getTierRank(currentTier);
212
- const targetRank = getTierRank(tierId);
213
- if (currentRank === targetRank) {
214
- return t("upgradePage.currentPlan", "Current Plan");
215
- } else if (targetRank > currentRank) {
216
- return t("upgradePage.upgradeNow", "Upgrade Now");
217
- } else {
218
- return t("upgradePage.downgrade", "Downgrade");
219
- }
220
- };
221
- const tiers = [
222
- {
223
- id: "free",
224
- name: "FREE",
225
- price: "$0",
226
- period: "forever",
227
- description: "Perfect for small projects and testing",
228
- icon: /* @__PURE__ */ jsx(Sn, {}),
229
- color: "linear-gradient(135deg, #6B7280, #4B5563)",
230
- features: [
231
- { name: "Full Editor Access", included: true },
232
- { name: "All Editor Tools", included: true },
233
- { name: "2 Collaborators", included: true },
234
- { name: "3 Custom Blocks (Simple)", included: true },
235
- { name: "Real-time Sync", included: true },
236
- { name: "Embedded Entry Blocks", included: false },
237
- { name: "Block Export/Import", included: false },
238
- { name: "AI Style + Rewrite", included: false },
239
- { name: "Version History", included: false },
240
- { name: "Priority Support", included: false }
241
- ],
242
- limits: {
243
- collaborators: "2",
244
- customBlocks: "3 Simple"
245
- }
246
- },
247
- {
248
- id: "premium",
249
- name: "PREMIUM",
250
- price: "$9.90",
251
- period: "/month",
252
- description: "Enhanced collaboration for teams",
253
- icon: /* @__PURE__ */ jsx(C3, {}),
254
- color: "linear-gradient(135deg, #8B5CF6, #7C3AED)",
255
- featured: true,
256
- features: [
257
- { name: "Full Editor Access", included: true },
258
- { name: "All Editor Tools", included: true },
259
- { name: "10 Collaborators", included: true },
260
- { name: "10 Custom Blocks", included: true },
261
- { name: "Embedded Entry Blocks", included: true },
262
- { name: "Real-time Sync", included: true },
263
- { name: "AI Grammar + Style (10/day)", included: true },
264
- { name: "Block Export/Import", included: false },
265
- { name: "Version History", included: true },
266
- { name: "Priority Support", included: true }
267
- ],
268
- limits: {
269
- collaborators: "10",
270
- customBlocks: "10 Total"
271
- }
272
- },
273
- {
274
- id: "advanced",
275
- name: "ADVANCED",
276
- price: "$24.90",
277
- period: "/month",
278
- description: "Unlimited collaboration for enterprises",
279
- icon: /* @__PURE__ */ jsx(ln, {}),
280
- color: "linear-gradient(135deg, #7C3AED, #6d28d9)",
281
- features: [
282
- { name: "Full Editor Access", included: true },
283
- { name: "All Editor Tools", included: true },
284
- { name: "Unlimited Collaborators", included: true },
285
- { name: "Unlimited Custom Blocks", included: true },
286
- { name: "Embedded Entry Blocks", included: true },
287
- { name: "Block Export/Import + API", included: true },
288
- { name: "Real-time Sync", included: true },
289
- { name: "AI All Types (Unlimited)", included: true },
290
- { name: "Version History", included: true },
291
- { name: "Priority Support", included: true }
292
- ],
293
- limits: {
294
- collaborators: "Unlimited",
295
- customBlocks: "Unlimited"
296
- }
297
- }
298
- ];
299
- const handleUpgrade = (tierId) => {
300
- window.open("https://store.magicdx.dev/", "_blank");
301
- };
302
- if (loading) {
303
- return /* @__PURE__ */ jsx(Container, { children: /* @__PURE__ */ jsx(T, { justifyContent: "center", alignItems: "center", style: { minHeight: "400px" }, children: /* @__PURE__ */ jsx(Vd, { children: t("license.loading", "Loading license information...") }) }) });
304
- }
305
- const collaboratorUsage = limits?.collaborators ? {
306
- current: limits.collaborators.current || 0,
307
- max: limits.collaborators.max,
308
- unlimited: limits.collaborators.unlimited,
309
- percentage: limits.collaborators.unlimited ? 0 : limits.collaborators.current / limits.collaborators.max * 100
310
- } : { current: 0, max: 2, unlimited: false, percentage: 0 };
311
- return /* @__PURE__ */ jsxs(Container, { children: [
312
- /* @__PURE__ */ jsxs(Header, { children: [
313
- /* @__PURE__ */ jsx(Title, { variant: "alpha", children: t("upgradePage.title", "Magic Editor X") }),
314
- /* @__PURE__ */ jsx(Subtitle, { variant: "omega", children: t("upgradePage.subtitle", "Choose your plan for collaborative editing") })
315
- ] }),
316
- /* @__PURE__ */ jsxs(UsageBox, { children: [
317
- /* @__PURE__ */ jsxs(T, { justifyContent: "space-between", alignItems: "center", children: [
318
- /* @__PURE__ */ jsx(I, { variant: "beta", fontWeight: "bold", children: t("upgradePage.currentUsage", "Current Usage") }),
319
- /* @__PURE__ */ jsx(Ps, { style: { background: currentTier === "free" ? "#6B7280" : "#7C3AED", color: "white" }, children: currentTier.toUpperCase() })
320
- ] }),
321
- /* @__PURE__ */ jsxs(R, { marginTop: 4, children: [
322
- /* @__PURE__ */ jsxs(T, { justifyContent: "space-between", children: [
323
- /* @__PURE__ */ jsx(I, { variant: "omega", children: t("upgradePage.collaborators", "Collaborators") }),
324
- /* @__PURE__ */ jsxs(I, { variant: "omega", fontWeight: "bold", children: [
325
- collaboratorUsage.current,
326
- " / ",
327
- collaboratorUsage.unlimited ? t("license.unlimited", "Unlimited") : collaboratorUsage.max
328
- ] })
329
- ] }),
330
- !collaboratorUsage.unlimited && /* @__PURE__ */ jsx(UsageBar, { children: /* @__PURE__ */ jsx(UsageProgress, { $percentage: collaboratorUsage.percentage }) })
331
- ] })
332
- ] }),
333
- /* @__PURE__ */ jsx(TierGrid, { children: tiers.map((tier) => /* @__PURE__ */ jsx(TierWrapper, { children: /* @__PURE__ */ jsxs(TierCard, { $featured: tier.featured, children: [
334
- tier.featured && /* @__PURE__ */ jsx(PopularBadge, { children: t("upgradePage.mostPopular", "MOST POPULAR") }),
335
- /* @__PURE__ */ jsx(TierIcon, { $color: tier.color, children: tier.icon }),
336
- /* @__PURE__ */ jsx(TierName, { variant: "beta", children: tier.name }),
337
- /* @__PURE__ */ jsxs(T, { alignItems: "baseline", gap: 1, children: [
338
- /* @__PURE__ */ jsx(TierPrice, { variant: "alpha", children: tier.price }),
339
- /* @__PURE__ */ jsx(I, { variant: "omega", style: { color: "#6B7280" }, children: tier.period })
340
- ] }),
341
- /* @__PURE__ */ jsx(TierDescription, { variant: "omega", children: tier.description }),
342
- /* @__PURE__ */ jsxs(
343
- R,
344
- {
345
- background: "neutral100",
346
- hasRadius: true,
347
- padding: 3,
348
- marginBottom: 5,
349
- children: [
350
- /* @__PURE__ */ jsxs(I, { variant: "pi", style: { fontSize: "13px", display: "block", marginBottom: "4px" }, children: [
351
- /* @__PURE__ */ jsx("strong", { children: "Collaborators:" }),
352
- " ",
353
- tier.limits.collaborators
354
- ] }),
355
- /* @__PURE__ */ jsxs(I, { variant: "pi", style: { fontSize: "13px", display: "block" }, children: [
356
- /* @__PURE__ */ jsx("strong", { children: "Custom Blocks:" }),
357
- " ",
358
- tier.limits.customBlocks
359
- ] })
360
- ]
361
- }
362
- ),
363
- /* @__PURE__ */ jsx(FeatureList, { children: tier.features.map((feature, index) => /* @__PURE__ */ jsxs(Feature, { children: [
364
- /* @__PURE__ */ jsx(FeatureIcon, { $included: feature.included, children: feature.included ? /* @__PURE__ */ jsx(t5, { style: { width: 14, height: 14 } }) : /* @__PURE__ */ jsx(C5, { style: { width: 14, height: 14 } }) }),
365
- /* @__PURE__ */ jsx(
366
- I,
367
- {
368
- variant: "omega",
369
- textColor: feature.included ? "neutral800" : "neutral500",
370
- style: {
371
- fontSize: "14px",
372
- textDecoration: feature.included ? "none" : "line-through"
373
- },
374
- children: feature.name
375
- }
376
- )
377
- ] }, index)) }),
378
- currentTier === tier.id ? /* @__PURE__ */ jsx(CurrentPlanBadge, { children: t("upgradePage.currentPlan", "Current Plan") }) : /* @__PURE__ */ jsx(
379
- UpgradeButton,
380
- {
381
- $gradient: tier.color,
382
- onClick: () => handleUpgrade(tier.id),
383
- children: getButtonText(tier.id)
384
- }
385
- )
386
- ] }) }, tier.id)) })
387
- ] });
388
- };
389
- export {
390
- LicensePage as default
391
- };
@@ -1,222 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const jsxRuntime = require("react/jsx-runtime");
4
- const m = require("react");
5
- const getTranslation = require("./getTranslation-BADoesEn.js");
6
- const styled = require("styled-components");
7
- const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
8
- const styled__default = /* @__PURE__ */ _interopDefault(styled);
9
- const pulse = styled.keyframes`
10
- 0%, 100% {
11
- box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
12
- transform: scale(1);
13
- }
14
- 50% {
15
- box-shadow: 0 0 0 6px rgba(34, 197, 94, 0.1);
16
- transform: scale(1.1);
17
- }
18
- `;
19
- const StatusCard = styled__default.default.div`
20
- background: ${(props) => props.theme.colors.neutral0};
21
- border: 1px solid ${({ $status, theme }) => $status === "connected" ? "rgba(34, 197, 94, 0.3)" : $status === "denied" ? "rgba(239, 68, 68, 0.3)" : theme.colors.neutral200};
22
- border-radius: 10px;
23
- padding: 14px 16px;
24
- display: flex;
25
- align-items: center;
26
- gap: 12px;
27
- `;
28
- const StatusDot = styled__default.default.div`
29
- width: 12px;
30
- height: 12px;
31
- border-radius: 50%;
32
- flex-shrink: 0;
33
- background: ${({ $status }) => $status === "connected" ? "#22c55e" : $status === "connecting" || $status === "requesting" ? "#f59e0b" : $status === "denied" ? "#ef4444" : "#94a3b8"};
34
-
35
- ${({ $status }) => $status === "connected" && styled.css`
36
- animation: ${pulse} 2s ease-in-out infinite;
37
- `}
38
- `;
39
- const StatusText = styled__default.default.div`
40
- display: flex;
41
- flex-direction: column;
42
- gap: 2px;
43
- `;
44
- const StatusLabel = styled__default.default.span`
45
- font-size: 14px;
46
- font-weight: 600;
47
- color: ${({ $status, theme }) => $status === "connected" ? theme.colors.success600 : $status === "connecting" || $status === "requesting" ? theme.colors.warning600 : $status === "denied" ? theme.colors.danger600 : theme.colors.neutral600};
48
- `;
49
- const StatusSubtext = styled__default.default.span`
50
- font-size: 12px;
51
- color: ${(props) => props.theme.colors.neutral500};
52
- `;
53
- const SectionTitle = styled__default.default.div`
54
- font-size: 11px;
55
- font-weight: 600;
56
- color: ${(props) => props.theme.colors.neutral600};
57
- text-transform: uppercase;
58
- letter-spacing: 0.5px;
59
- margin-bottom: 10px;
60
- `;
61
- const PeerItem = styled__default.default.div`
62
- display: flex;
63
- align-items: center;
64
- gap: 12px;
65
- padding: 12px 14px;
66
- background: ${(props) => props.theme.colors.neutral0};
67
- border-radius: 10px;
68
- border: 1px solid ${(props) => props.theme.colors.neutral150};
69
- transition: all 0.2s ease;
70
-
71
- &:hover {
72
- border-color: ${(props) => props.theme.colors.primary200};
73
- box-shadow: 0 2px 8px rgba(124, 58, 237, 0.08);
74
- transform: translateY(-1px);
75
- }
76
- `;
77
- const PEER_COLORS = [
78
- "linear-gradient(135deg, #7C3AED 0%, #a855f7 100%)",
79
- "linear-gradient(135deg, #3b82f6 0%, #60a5fa 100%)",
80
- "linear-gradient(135deg, #10b981 0%, #34d399 100%)",
81
- "linear-gradient(135deg, #f59e0b 0%, #fbbf24 100%)",
82
- "linear-gradient(135deg, #ef4444 0%, #f87171 100%)",
83
- "linear-gradient(135deg, #ec4899 0%, #f472b6 100%)"
84
- ];
85
- const PeerAvatar = styled__default.default.div`
86
- width: 36px;
87
- height: 36px;
88
- border-radius: 50%;
89
- background: ${({ $color }) => $color || PEER_COLORS[0]};
90
- color: white;
91
- font-size: 12px;
92
- font-weight: 700;
93
- display: flex;
94
- align-items: center;
95
- justify-content: center;
96
- flex-shrink: 0;
97
- box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
98
- `;
99
- const PeerInfo = styled__default.default.div`
100
- flex: 1;
101
- min-width: 0;
102
- display: flex;
103
- flex-direction: column;
104
- gap: 2px;
105
- `;
106
- const PeerName = styled__default.default.span`
107
- font-size: 13px;
108
- font-weight: 600;
109
- color: ${(props) => props.theme.colors.neutral800};
110
- white-space: nowrap;
111
- overflow: hidden;
112
- text-overflow: ellipsis;
113
- `;
114
- const PeerEmail = styled__default.default.span`
115
- font-size: 11px;
116
- color: ${(props) => props.theme.colors.neutral500};
117
- white-space: nowrap;
118
- overflow: hidden;
119
- text-overflow: ellipsis;
120
- `;
121
- const OnlineBadge = styled__default.default.span`
122
- font-size: 10px;
123
- font-weight: 600;
124
- color: #166534;
125
- background: #dcfce7;
126
- padding: 4px 8px;
127
- border-radius: 12px;
128
- flex-shrink: 0;
129
- `;
130
- const EmptyState = styled__default.default.div`
131
- text-align: center;
132
- padding: 16px;
133
- background: ${(props) => props.theme.colors.neutral100};
134
- border-radius: 10px;
135
- border: 1px dashed ${(props) => props.theme.colors.neutral300};
136
- `;
137
- const EmptyText = styled__default.default.span`
138
- font-size: 13px;
139
- color: ${(props) => props.theme.colors.neutral500};
140
- `;
141
- const getPeerInitials = (user = {}) => {
142
- const first = (user.firstname?.[0] || user.email?.[0] || "?").toUpperCase();
143
- const last = (user.lastname?.[0] || "").toUpperCase();
144
- return `${first}${last}`.trim();
145
- };
146
- const getPeerName = (user = {}, t) => {
147
- if (user.firstname) {
148
- return `${user.firstname} ${user.lastname || ""}`.trim();
149
- }
150
- return user.email || t("collab.unknown", "Unknown");
151
- };
152
- const LiveCollaborationPanel = ({ documentId, model, document }) => {
153
- const { formatMessage } = getTranslation.useIntl();
154
- const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation.getTranslation(id), defaultMessage }, values);
155
- const [collabState, setCollabState] = m.useState({
156
- status: "disabled",
157
- peers: [],
158
- error: null
159
- });
160
- m.useEffect(() => {
161
- const handleCollabUpdate = (event) => {
162
- if (event.detail) {
163
- setCollabState(event.detail);
164
- }
165
- };
166
- window.addEventListener("magic-editor-collab-update", handleCollabUpdate);
167
- if (window.__MAGIC_EDITOR_COLLAB_STATE__) {
168
- setCollabState(window.__MAGIC_EDITOR_COLLAB_STATE__);
169
- }
170
- return () => {
171
- window.removeEventListener("magic-editor-collab-update", handleCollabUpdate);
172
- };
173
- }, []);
174
- const { status, peers, error } = collabState;
175
- const statusLabel = m.useMemo(() => {
176
- switch (status) {
177
- case "connected":
178
- return t("collab.live", "Live");
179
- case "connecting":
180
- return t("collab.connecting", "Connecting...");
181
- case "requesting":
182
- return t("collab.checkingPermission", "Checking permission");
183
- case "denied":
184
- return t("collab.noPermission", "No permission");
185
- case "disconnected":
186
- return t("collab.disconnected", "Disconnected");
187
- case "disabled":
188
- return t("collab.disabled", "Disabled");
189
- default:
190
- return t("collab.ready", "Ready");
191
- }
192
- }, [status, t]);
193
- if (status === "disabled" || status === "idle") {
194
- return null;
195
- }
196
- const isConnected = status === "connected";
197
- return {
198
- title: t("collab.title", "Live Collaboration"),
199
- content: /* @__PURE__ */ jsxRuntime.jsxs(getTranslation.T, { direction: "column", gap: 4, alignItems: "stretch", style: { width: "100%" }, children: [
200
- /* @__PURE__ */ jsxRuntime.jsxs(StatusCard, { $status: status, children: [
201
- /* @__PURE__ */ jsxRuntime.jsx(StatusDot, { $status: status }),
202
- /* @__PURE__ */ jsxRuntime.jsxs(StatusText, { children: [
203
- /* @__PURE__ */ jsxRuntime.jsx(StatusLabel, { $status: status, children: statusLabel }),
204
- /* @__PURE__ */ jsxRuntime.jsx(StatusSubtext, { children: isConnected ? t("collab.realtimeActive", "Realtime sync active") : error || t("collab.connectionEstablishing", "Connection is being established...") })
205
- ] })
206
- ] }),
207
- isConnected && peers.length > 0 && /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
208
- /* @__PURE__ */ jsxRuntime.jsx(SectionTitle, { children: t("collab.activePeers", "Active Collaborators ({count})", { count: peers.length }) }),
209
- /* @__PURE__ */ jsxRuntime.jsx(getTranslation.T, { direction: "column", gap: 2, alignItems: "stretch", children: peers.map((peer, idx) => /* @__PURE__ */ jsxRuntime.jsxs(PeerItem, { children: [
210
- /* @__PURE__ */ jsxRuntime.jsx(PeerAvatar, { $color: PEER_COLORS[idx % PEER_COLORS.length], children: getPeerInitials(peer) }),
211
- /* @__PURE__ */ jsxRuntime.jsxs(PeerInfo, { children: [
212
- /* @__PURE__ */ jsxRuntime.jsx(PeerName, { children: getPeerName(peer, t) }),
213
- peer.email && peer.firstname && /* @__PURE__ */ jsxRuntime.jsx(PeerEmail, { children: peer.email })
214
- ] }),
215
- /* @__PURE__ */ jsxRuntime.jsx(OnlineBadge, { children: t("collab.online", "Online") })
216
- ] }, peer.id)) })
217
- ] }),
218
- isConnected && peers.length === 0 && /* @__PURE__ */ jsxRuntime.jsx(EmptyState, { children: /* @__PURE__ */ jsxRuntime.jsx(EmptyText, { children: t("collab.workingAlone", "You are working alone") }) })
219
- ] })
220
- };
221
- };
222
- exports.default = LiveCollaborationPanel;