magic-editor-x 2.3.0 → 2.4.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 (84) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/README.md +299 -142
  3. package/dist/admin/AuditPage-C2u6z4aN.js +381 -0
  4. package/dist/admin/AuditPage-guB0SiGS.mjs +381 -0
  5. package/dist/admin/{ConfigurationPage-C-UktL1x.js → ConfigurationPage-D6uya-J1.js} +228 -13
  6. package/dist/admin/{ConfigurationPage-BxLHIQdo.mjs → ConfigurationPage-DiEpF1Rr.mjs} +222 -7
  7. package/dist/admin/ConfirmAction-CUhpngYU.js +71 -0
  8. package/dist/admin/ConfirmAction-CZjpduc3.mjs +72 -0
  9. package/dist/admin/{CustomBlocksPage-D8aMbVXc.mjs → CustomBlocksPage-Byt10-6c.mjs} +6 -4
  10. package/dist/admin/{CustomBlocksPage-CxcTfdOT.js → CustomBlocksPage-DP3h_wNd.js} +21 -19
  11. package/dist/admin/MentionsWidget-C2OCAmqq.js +227 -0
  12. package/dist/admin/MentionsWidget-sMkM9mHX.mjs +225 -0
  13. package/dist/admin/{TemplatesPage-Hn6gyu2l.js → TemplatesPage-DrSJdteI.js} +313 -17
  14. package/dist/admin/{TemplatesPage-jhYi6Zdf.mjs → TemplatesPage-Yp4OqFE2.mjs} +305 -9
  15. package/dist/admin/{ConfirmAction-DuQwvRYi.mjs → api-2ZRpHM3d.mjs} +19 -70
  16. package/dist/admin/{ConfirmAction-zLuIFj8t.js → api-bix9RLLI.js} +19 -70
  17. package/dist/admin/auditText-DIIYVR6k.mjs +110 -0
  18. package/dist/admin/auditText-DUhWu2Nx.js +109 -0
  19. package/dist/admin/comments-C7P41lan.js +86 -0
  20. package/dist/admin/comments-hfIbLQNO.mjs +87 -0
  21. package/dist/admin/{de-BMY2LBaa.mjs → de-BNPIGqhs.mjs} +41 -2
  22. package/dist/admin/{de-2Ie5jy7j.js → de-BhhGss1l.js} +41 -2
  23. package/dist/admin/{de-DOiGaTNX.mjs → de-CKz6CG3V.mjs} +191 -5
  24. package/dist/admin/{de-C3AsGauQ.js → de-CbBDnXeT.js} +140 -1
  25. package/dist/admin/{de-BUS1hUw0.mjs → de-DiCZrmH8.mjs} +140 -1
  26. package/dist/admin/{de-B1X46JJZ.js → de-zcV8D7nt.js} +191 -5
  27. package/dist/admin/{en-Ah-Cw0Wd.js → en-B9ApE1y1.js} +41 -2
  28. package/dist/admin/{en-CDg_18Bt.js → en-BMWhILnj.js} +191 -5
  29. package/dist/admin/{en-BkEjpC3i.js → en-CpehF0Kv.js} +140 -1
  30. package/dist/admin/{en-GCzgS9Aw.mjs → en-DCPMqFIa.mjs} +140 -1
  31. package/dist/admin/{en-CU6UzV4g.mjs → en-cYzqbASF.mjs} +191 -5
  32. package/dist/admin/{en-CvFiqti2.mjs → en-gFLeK9Ng.mjs} +41 -2
  33. package/dist/admin/{es-DbKHZz5l.mjs → es-BmwBgEgz.mjs} +41 -2
  34. package/dist/admin/{es-Cr8JH85N.js → es-C0W31rl8.js} +41 -2
  35. package/dist/admin/{es-BCpJmUEM.js → es-CQPh8PXw.js} +191 -5
  36. package/dist/admin/{es-C4pEnDRv.js → es-CawpzwyC.js} +140 -1
  37. package/dist/admin/{es-DHBBZKl2.mjs → es-Chs37IBR.mjs} +140 -1
  38. package/dist/admin/{es-BmfffNM2.mjs → es-DCamt1ek.mjs} +191 -5
  39. package/dist/admin/{fr-DQJ_7aq5.mjs → fr-CMWBNE5D.mjs} +41 -2
  40. package/dist/admin/{fr-C2aLSwEu.js → fr-COOsqexl.js} +140 -1
  41. package/dist/admin/{fr-Dvq4xk2e.mjs → fr-Dp5-XP29.mjs} +140 -1
  42. package/dist/admin/{fr-ZcN0yM_2.js → fr-DpC44Ol8.js} +191 -5
  43. package/dist/admin/{fr-OJ4VW1kh.js → fr-iGeIfEcU.js} +41 -2
  44. package/dist/admin/{fr-DZd2XJP6.mjs → fr-oW0t8bT5.mjs} +191 -5
  45. package/dist/admin/{index-Cm-fFUhE.js → index-64wc26Bl.js} +13851 -6746
  46. package/dist/admin/{index-XgfwqLfV.mjs → index-BVjf1gVC.mjs} +13788 -6682
  47. package/dist/admin/{index-BHBRr562.js → index-D6Z7i8ba.js} +1003 -53
  48. package/dist/admin/{index-CQk1XeNb.mjs → index-D_Fv8Non.mjs} +1032 -82
  49. package/dist/admin/index.js +2 -1
  50. package/dist/admin/index.mjs +3 -2
  51. package/dist/admin/math-CIQ4Z_mY.mjs +47 -0
  52. package/dist/admin/math-vsK_06ZR.js +49 -0
  53. package/dist/admin/{pt-D0I0_JYs.js → pt-BHmXk2d9.js} +41 -2
  54. package/dist/admin/{pt-CImqDnLB.js → pt-Bo0Pm_Pt.js} +191 -5
  55. package/dist/admin/{pt-CilDggGF.mjs → pt-DALDvfBn.mjs} +140 -1
  56. package/dist/admin/{pt-BSLzA17U.mjs → pt-DFNgZ5_k.mjs} +41 -2
  57. package/dist/admin/{pt-DX0OAIoL.js → pt-DXy7G1x7.js} +140 -1
  58. package/dist/admin/{pt-C3UdeIpd.mjs → pt-uGpfRQLC.mjs} +191 -5
  59. package/dist/admin/{useT-D3sM9Zf7.js → useT-BXJLIPN4.js} +1 -1
  60. package/dist/admin/{useT-CmaeZbCr.mjs → useT-CLPhBmBC.mjs} +1 -1
  61. package/dist/blocks/index.d.mts +2 -0
  62. package/dist/blocks/index.d.ts +2 -0
  63. package/dist/blocks/index.js +13 -2
  64. package/dist/blocks/index.mjs +13 -2
  65. package/dist/math/index.d.mts +27 -0
  66. package/dist/math/index.d.ts +27 -0
  67. package/dist/math/index.js +164 -0
  68. package/dist/math/index.mjs +134 -0
  69. package/dist/react/index.js +673 -91
  70. package/dist/react/index.mjs +673 -91
  71. package/dist/render/index.d.mts +26 -0
  72. package/dist/render/index.d.ts +26 -0
  73. package/dist/render/index.js +779 -106
  74. package/dist/render/index.mjs +779 -106
  75. package/dist/server/index.js +10419 -4103
  76. package/dist/server/index.mjs +10419 -4103
  77. package/dist/vue/index.js +673 -91
  78. package/dist/vue/index.mjs +673 -91
  79. package/package.json +8 -2
  80. package/schema/magic-editor-x.schema.json +127 -2
  81. package/types/blocks.d.ts +2 -0
  82. package/types/index.d.ts +42 -0
  83. package/types/math.d.ts +27 -0
  84. package/types/render.d.ts +26 -0
@@ -0,0 +1,110 @@
1
+ const EVENT_LABELS = {
2
+ "entry.create": { key: "settings.audit.event.entryCreate", text: "Entry created" },
3
+ "entry.update": { key: "settings.audit.event.entryUpdate", text: "Entry saved" },
4
+ "entry.publish": { key: "settings.audit.event.entryPublish", text: "Published" },
5
+ "entry.unpublish": { key: "settings.audit.event.entryUnpublish", text: "Unpublished" },
6
+ "entry.discard": { key: "settings.audit.event.entryDiscard", text: "Draft discarded" },
7
+ "entry.delete": { key: "settings.audit.event.entryDelete", text: "Entry deleted" },
8
+ "version.create": { key: "settings.audit.event.versionCreate", text: "Version saved" },
9
+ "version.restore": { key: "settings.audit.event.versionRestore", text: "Version restored" },
10
+ "version.rename": { key: "settings.audit.event.versionRename", text: "Version renamed" },
11
+ "ai.action": { key: "settings.audit.event.aiAction", text: "AI assistant used" },
12
+ "comment.create": { key: "settings.audit.event.commentCreate", text: "Comment added" },
13
+ "comment.reply": { key: "settings.audit.event.commentReply", text: "Reply added" },
14
+ "comment.resolve": { key: "settings.audit.event.commentResolve", text: "Thread resolved" },
15
+ "comment.reopen": { key: "settings.audit.event.commentReopen", text: "Thread reopened" },
16
+ "comment.delete": { key: "settings.audit.event.commentDelete", text: "Comment deleted" },
17
+ "comment.moderate": { key: "settings.audit.event.commentModerate", text: "Comment removed by a moderator" },
18
+ "template.create": { key: "settings.audit.event.templateCreate", text: "Template created" },
19
+ "template.update": { key: "settings.audit.event.templateUpdate", text: "Template changed" },
20
+ "template.delete": { key: "settings.audit.event.templateDelete", text: "Template deleted" },
21
+ "synced.create": { key: "settings.audit.event.syncedCreate", text: "Synced block created" },
22
+ "synced.update": { key: "settings.audit.event.syncedUpdate", text: "Synced block changed" },
23
+ "synced.delete": { key: "settings.audit.event.syncedDelete", text: "Synced block deleted" },
24
+ "synced.restore": { key: "settings.audit.event.syncedRestore", text: "Synced block version restored" },
25
+ "settings.update": { key: "settings.audit.event.settingsUpdate", text: "Settings changed" },
26
+ "linkcheck.run": { key: "settings.audit.event.linkcheckRun", text: "Link check run" },
27
+ "ai.localize": { key: "settings.audit.event.aiLocalize", text: "Strapi AI translation checked" },
28
+ // 2.4 block suggestions
29
+ "suggestion.create": { key: "settings.audit.event.suggestionCreate", text: "Changes suggested" },
30
+ "suggestion.accept": { key: "settings.audit.event.suggestionAccept", text: "Suggestion accepted" },
31
+ "suggestion.reject": { key: "settings.audit.event.suggestionReject", text: "Suggestion rejected" },
32
+ "suggestion.withdraw": { key: "settings.audit.event.suggestionWithdraw", text: "Suggestion withdrawn" }
33
+ };
34
+ const eventLabel = (t, event) => {
35
+ const entry = EVENT_LABELS[event];
36
+ return entry ? t(entry.key, entry.text) : event;
37
+ };
38
+ const actorLabel = (t, actor) => {
39
+ if (!actor) return t("settings.audit.actor.system", "System");
40
+ if (actor.kind === "deleted") return t("settings.audit.actor.deleted", "Deleted user");
41
+ if (actor.kind === "api") return t("settings.audit.actor.api", "Content API");
42
+ if (actor.kind === "system") return t("settings.audit.actor.system", "System");
43
+ const name = actor.name || t("settings.audit.actor.unnamed", "Admin without a name");
44
+ return actor.own ? t("settings.audit.actor.you", "{name} (you)", { name }) : name;
45
+ };
46
+ const changeSummary = (t, item) => {
47
+ const counts = item.counts || {};
48
+ const meta = item.meta || {};
49
+ const parts = [];
50
+ if (item.event && item.event.startsWith("entry.")) {
51
+ if (counts.added)
52
+ parts.push(t("settings.audit.counts.added", "{count, number} added", { count: counts.added }));
53
+ if (counts.changed)
54
+ parts.push(t("settings.audit.counts.changed", "{count, number} changed", { count: counts.changed }));
55
+ if (counts.removed)
56
+ parts.push(t("settings.audit.counts.removed", "{count, number} removed", { count: counts.removed }));
57
+ if (counts.moved)
58
+ parts.push(t("settings.audit.counts.moved", "{count, number} moved", { count: counts.moved }));
59
+ }
60
+ if (item.event && item.event.startsWith("version.") && counts.version)
61
+ parts.push(t("settings.audit.counts.version", "Version {version}", { version: counts.version }));
62
+ if (item.event === "ai.action" && typeof meta.action === "string") {
63
+ parts.push(t("settings.audit.meta.action", "Action: {action}", { action: meta.action }));
64
+ if (counts.segments)
65
+ parts.push(
66
+ t("settings.audit.counts.segments", "{count, plural, one {# text} other {# texts}}", {
67
+ count: counts.segments
68
+ })
69
+ );
70
+ }
71
+ if (item.event === "settings.update" && Array.isArray(meta.keys) && meta.keys.length)
72
+ parts.push(t("settings.audit.meta.keys", "Sections: {keys}", { keys: meta.keys.join(", ") }));
73
+ if (item.event === "linkcheck.run")
74
+ parts.push(
75
+ t(
76
+ "settings.audit.counts.linkcheck",
77
+ "{checked, number} links checked, {problems, number} with problems",
78
+ { checked: counts.checked || 0, problems: counts.problems || 0 }
79
+ )
80
+ );
81
+ if (item.event === "ai.localize")
82
+ parts.push(
83
+ t(
84
+ "settings.audit.counts.aiLocalize",
85
+ "{translated, number} of {segments, number} texts translated, {kept, number} kept from the source locale",
86
+ { translated: counts.translated || 0, segments: counts.segments || 0, kept: counts.kept || 0 }
87
+ )
88
+ );
89
+ if ((item.event || "").match(/^(template|synced)\./) && Number.isInteger(counts.blocks))
90
+ parts.push(
91
+ t("settings.audit.counts.blocks", "{count, plural, one {# block} other {# blocks}}", {
92
+ count: counts.blocks
93
+ })
94
+ );
95
+ if (item.event === "suggestion.create" && Number.isInteger(counts.suggestions))
96
+ parts.push(
97
+ t("settings.audit.counts.blocks", "{count, plural, one {# block} other {# blocks}}", {
98
+ count: counts.suggestions
99
+ })
100
+ );
101
+ if (item.event === "suggestion.accept" && counts.outdated)
102
+ parts.push(t("settings.audit.counts.outdated", "Replaced a newer version of the block"));
103
+ return parts.join(" · ");
104
+ };
105
+ export {
106
+ EVENT_LABELS as E,
107
+ actorLabel as a,
108
+ changeSummary as c,
109
+ eventLabel as e
110
+ };
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ const EVENT_LABELS = {
3
+ "entry.create": { key: "settings.audit.event.entryCreate", text: "Entry created" },
4
+ "entry.update": { key: "settings.audit.event.entryUpdate", text: "Entry saved" },
5
+ "entry.publish": { key: "settings.audit.event.entryPublish", text: "Published" },
6
+ "entry.unpublish": { key: "settings.audit.event.entryUnpublish", text: "Unpublished" },
7
+ "entry.discard": { key: "settings.audit.event.entryDiscard", text: "Draft discarded" },
8
+ "entry.delete": { key: "settings.audit.event.entryDelete", text: "Entry deleted" },
9
+ "version.create": { key: "settings.audit.event.versionCreate", text: "Version saved" },
10
+ "version.restore": { key: "settings.audit.event.versionRestore", text: "Version restored" },
11
+ "version.rename": { key: "settings.audit.event.versionRename", text: "Version renamed" },
12
+ "ai.action": { key: "settings.audit.event.aiAction", text: "AI assistant used" },
13
+ "comment.create": { key: "settings.audit.event.commentCreate", text: "Comment added" },
14
+ "comment.reply": { key: "settings.audit.event.commentReply", text: "Reply added" },
15
+ "comment.resolve": { key: "settings.audit.event.commentResolve", text: "Thread resolved" },
16
+ "comment.reopen": { key: "settings.audit.event.commentReopen", text: "Thread reopened" },
17
+ "comment.delete": { key: "settings.audit.event.commentDelete", text: "Comment deleted" },
18
+ "comment.moderate": { key: "settings.audit.event.commentModerate", text: "Comment removed by a moderator" },
19
+ "template.create": { key: "settings.audit.event.templateCreate", text: "Template created" },
20
+ "template.update": { key: "settings.audit.event.templateUpdate", text: "Template changed" },
21
+ "template.delete": { key: "settings.audit.event.templateDelete", text: "Template deleted" },
22
+ "synced.create": { key: "settings.audit.event.syncedCreate", text: "Synced block created" },
23
+ "synced.update": { key: "settings.audit.event.syncedUpdate", text: "Synced block changed" },
24
+ "synced.delete": { key: "settings.audit.event.syncedDelete", text: "Synced block deleted" },
25
+ "synced.restore": { key: "settings.audit.event.syncedRestore", text: "Synced block version restored" },
26
+ "settings.update": { key: "settings.audit.event.settingsUpdate", text: "Settings changed" },
27
+ "linkcheck.run": { key: "settings.audit.event.linkcheckRun", text: "Link check run" },
28
+ "ai.localize": { key: "settings.audit.event.aiLocalize", text: "Strapi AI translation checked" },
29
+ // 2.4 block suggestions
30
+ "suggestion.create": { key: "settings.audit.event.suggestionCreate", text: "Changes suggested" },
31
+ "suggestion.accept": { key: "settings.audit.event.suggestionAccept", text: "Suggestion accepted" },
32
+ "suggestion.reject": { key: "settings.audit.event.suggestionReject", text: "Suggestion rejected" },
33
+ "suggestion.withdraw": { key: "settings.audit.event.suggestionWithdraw", text: "Suggestion withdrawn" }
34
+ };
35
+ const eventLabel = (t, event) => {
36
+ const entry = EVENT_LABELS[event];
37
+ return entry ? t(entry.key, entry.text) : event;
38
+ };
39
+ const actorLabel = (t, actor) => {
40
+ if (!actor) return t("settings.audit.actor.system", "System");
41
+ if (actor.kind === "deleted") return t("settings.audit.actor.deleted", "Deleted user");
42
+ if (actor.kind === "api") return t("settings.audit.actor.api", "Content API");
43
+ if (actor.kind === "system") return t("settings.audit.actor.system", "System");
44
+ const name = actor.name || t("settings.audit.actor.unnamed", "Admin without a name");
45
+ return actor.own ? t("settings.audit.actor.you", "{name} (you)", { name }) : name;
46
+ };
47
+ const changeSummary = (t, item) => {
48
+ const counts = item.counts || {};
49
+ const meta = item.meta || {};
50
+ const parts = [];
51
+ if (item.event && item.event.startsWith("entry.")) {
52
+ if (counts.added)
53
+ parts.push(t("settings.audit.counts.added", "{count, number} added", { count: counts.added }));
54
+ if (counts.changed)
55
+ parts.push(t("settings.audit.counts.changed", "{count, number} changed", { count: counts.changed }));
56
+ if (counts.removed)
57
+ parts.push(t("settings.audit.counts.removed", "{count, number} removed", { count: counts.removed }));
58
+ if (counts.moved)
59
+ parts.push(t("settings.audit.counts.moved", "{count, number} moved", { count: counts.moved }));
60
+ }
61
+ if (item.event && item.event.startsWith("version.") && counts.version)
62
+ parts.push(t("settings.audit.counts.version", "Version {version}", { version: counts.version }));
63
+ if (item.event === "ai.action" && typeof meta.action === "string") {
64
+ parts.push(t("settings.audit.meta.action", "Action: {action}", { action: meta.action }));
65
+ if (counts.segments)
66
+ parts.push(
67
+ t("settings.audit.counts.segments", "{count, plural, one {# text} other {# texts}}", {
68
+ count: counts.segments
69
+ })
70
+ );
71
+ }
72
+ if (item.event === "settings.update" && Array.isArray(meta.keys) && meta.keys.length)
73
+ parts.push(t("settings.audit.meta.keys", "Sections: {keys}", { keys: meta.keys.join(", ") }));
74
+ if (item.event === "linkcheck.run")
75
+ parts.push(
76
+ t(
77
+ "settings.audit.counts.linkcheck",
78
+ "{checked, number} links checked, {problems, number} with problems",
79
+ { checked: counts.checked || 0, problems: counts.problems || 0 }
80
+ )
81
+ );
82
+ if (item.event === "ai.localize")
83
+ parts.push(
84
+ t(
85
+ "settings.audit.counts.aiLocalize",
86
+ "{translated, number} of {segments, number} texts translated, {kept, number} kept from the source locale",
87
+ { translated: counts.translated || 0, segments: counts.segments || 0, kept: counts.kept || 0 }
88
+ )
89
+ );
90
+ if ((item.event || "").match(/^(template|synced)\./) && Number.isInteger(counts.blocks))
91
+ parts.push(
92
+ t("settings.audit.counts.blocks", "{count, plural, one {# block} other {# blocks}}", {
93
+ count: counts.blocks
94
+ })
95
+ );
96
+ if (item.event === "suggestion.create" && Number.isInteger(counts.suggestions))
97
+ parts.push(
98
+ t("settings.audit.counts.blocks", "{count, plural, one {# block} other {# blocks}}", {
99
+ count: counts.suggestions
100
+ })
101
+ );
102
+ if (item.event === "suggestion.accept" && counts.outdated)
103
+ parts.push(t("settings.audit.counts.outdated", "Replaced a newer version of the block"));
104
+ return parts.join(" · ");
105
+ };
106
+ exports.EVENT_LABELS = EVENT_LABELS;
107
+ exports.actorLabel = actorLabel;
108
+ exports.changeSummary = changeSummary;
109
+ exports.eventLabel = eventLabel;
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ const MAX_COMMENT_LENGTH = 4e3;
3
+ const MAX_EXCERPT_LENGTH = 200;
4
+ const CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g;
5
+ const BIDI = /[\u061c\u200b-\u200f\u202a-\u202e\u2060\u2066-\u2069\ufeff]/g;
6
+ const normalizeExcerpt = (value) => {
7
+ if (typeof value !== "string") return null;
8
+ const text = value.slice(0, MAX_EXCERPT_LENGTH * 4).replace(CONTROL, " ").replace(BIDI, "").replace(/\s+/g, " ").trim();
9
+ if (!text) return null;
10
+ return text.length > MAX_EXCERPT_LENGTH ? `${text.slice(0, MAX_EXCERPT_LENGTH - 1).trimEnd()}…` : text;
11
+ };
12
+ const blockExcerpt = (block) => {
13
+ if (!block || typeof block !== "object" || !block.data || typeof block.data !== "object") return null;
14
+ const parts = [];
15
+ const visit = (value, depth) => {
16
+ if (parts.join(" ").length > MAX_EXCERPT_LENGTH * 2 || depth > 6) return;
17
+ if (typeof value === "string") parts.push(value.slice(0, MAX_EXCERPT_LENGTH * 4));
18
+ else if (Array.isArray(value)) value.forEach((item) => visit(item, depth + 1));
19
+ else if (value && typeof value === "object") {
20
+ for (const [key, item] of Object.entries(value)) {
21
+ if (["url", "href", "link", "src", "file", "id", "documentId", "mime", "style", "level"].includes(key))
22
+ continue;
23
+ visit(item, depth + 1);
24
+ }
25
+ }
26
+ };
27
+ visit(block.data, 0);
28
+ const text = parts.join(" ").replace(/<[^>]{0,500}>/g, " ").replace(/&nbsp;/g, " ").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&amp;/g, "&");
29
+ return normalizeExcerpt(text);
30
+ };
31
+ const openThreadsByBlock = (threads) => {
32
+ const counts = /* @__PURE__ */ new Map();
33
+ for (const thread of Array.isArray(threads) ? threads : []) {
34
+ if (!thread || thread.status !== "open" || typeof thread.blockId !== "string") continue;
35
+ counts.set(thread.blockId, (counts.get(thread.blockId) || 0) + 1);
36
+ }
37
+ return counts;
38
+ };
39
+ const countThreads = (threads) => {
40
+ const counts = { open: 0, resolved: 0, comments: 0 };
41
+ for (const thread of Array.isArray(threads) ? threads : []) {
42
+ if (!thread) continue;
43
+ if (thread.status === "resolved") counts.resolved += 1;
44
+ else counts.open += 1;
45
+ counts.comments += Array.isArray(thread.comments) ? thread.comments.length : 0;
46
+ }
47
+ return counts;
48
+ };
49
+ const arrangeThreads = (threads, blockIds) => {
50
+ const index = new Map((blockIds || []).map((id, position) => [id, position]));
51
+ return (Array.isArray(threads) ? threads : []).map((thread) => {
52
+ const position = index.has(thread.blockId) ? index.get(thread.blockId) : null;
53
+ return { ...thread, detached: Boolean(blockIds) && position === null, position };
54
+ }).sort((a, b) => {
55
+ if (a.status === "resolved" !== (b.status === "resolved")) return a.status === "resolved" ? 1 : -1;
56
+ if (a.detached !== b.detached) return a.detached ? 1 : -1;
57
+ if (a.position !== null && b.position !== null && a.position !== b.position)
58
+ return a.position - b.position;
59
+ return String(b.updatedAt || "").localeCompare(String(a.updatedAt || ""));
60
+ });
61
+ };
62
+ const UNITS = [
63
+ ["year", 365 * 24 * 3600],
64
+ ["month", 30 * 24 * 3600],
65
+ ["week", 7 * 24 * 3600],
66
+ ["day", 24 * 3600],
67
+ ["hour", 3600],
68
+ ["minute", 60]
69
+ ];
70
+ const relativeTimeParts = (when, now = Date.now()) => {
71
+ const time = new Date(when).getTime();
72
+ if (!Number.isFinite(time)) return { value: 0, unit: "second" };
73
+ const seconds = Math.round((time - now) / 1e3);
74
+ const abs = Math.abs(seconds);
75
+ for (const [unit, size] of UNITS) {
76
+ if (abs >= size) return { value: Math.trunc(seconds / size), unit };
77
+ }
78
+ return { value: 0, unit: "second" };
79
+ };
80
+ exports.MAX_COMMENT_LENGTH = MAX_COMMENT_LENGTH;
81
+ exports.arrangeThreads = arrangeThreads;
82
+ exports.blockExcerpt = blockExcerpt;
83
+ exports.countThreads = countThreads;
84
+ exports.normalizeExcerpt = normalizeExcerpt;
85
+ exports.openThreadsByBlock = openThreadsByBlock;
86
+ exports.relativeTimeParts = relativeTimeParts;
@@ -0,0 +1,87 @@
1
+ const MAX_COMMENT_LENGTH = 4e3;
2
+ const MAX_EXCERPT_LENGTH = 200;
3
+ const CONTROL = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f-\u009f]/g;
4
+ const BIDI = /[\u061c\u200b-\u200f\u202a-\u202e\u2060\u2066-\u2069\ufeff]/g;
5
+ const normalizeExcerpt = (value) => {
6
+ if (typeof value !== "string") return null;
7
+ const text = value.slice(0, MAX_EXCERPT_LENGTH * 4).replace(CONTROL, " ").replace(BIDI, "").replace(/\s+/g, " ").trim();
8
+ if (!text) return null;
9
+ return text.length > MAX_EXCERPT_LENGTH ? `${text.slice(0, MAX_EXCERPT_LENGTH - 1).trimEnd()}…` : text;
10
+ };
11
+ const blockExcerpt = (block) => {
12
+ if (!block || typeof block !== "object" || !block.data || typeof block.data !== "object") return null;
13
+ const parts = [];
14
+ const visit = (value, depth) => {
15
+ if (parts.join(" ").length > MAX_EXCERPT_LENGTH * 2 || depth > 6) return;
16
+ if (typeof value === "string") parts.push(value.slice(0, MAX_EXCERPT_LENGTH * 4));
17
+ else if (Array.isArray(value)) value.forEach((item) => visit(item, depth + 1));
18
+ else if (value && typeof value === "object") {
19
+ for (const [key, item] of Object.entries(value)) {
20
+ if (["url", "href", "link", "src", "file", "id", "documentId", "mime", "style", "level"].includes(key))
21
+ continue;
22
+ visit(item, depth + 1);
23
+ }
24
+ }
25
+ };
26
+ visit(block.data, 0);
27
+ const text = parts.join(" ").replace(/<[^>]{0,500}>/g, " ").replace(/&nbsp;/g, " ").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").replace(/&amp;/g, "&");
28
+ return normalizeExcerpt(text);
29
+ };
30
+ const openThreadsByBlock = (threads) => {
31
+ const counts = /* @__PURE__ */ new Map();
32
+ for (const thread of Array.isArray(threads) ? threads : []) {
33
+ if (!thread || thread.status !== "open" || typeof thread.blockId !== "string") continue;
34
+ counts.set(thread.blockId, (counts.get(thread.blockId) || 0) + 1);
35
+ }
36
+ return counts;
37
+ };
38
+ const countThreads = (threads) => {
39
+ const counts = { open: 0, resolved: 0, comments: 0 };
40
+ for (const thread of Array.isArray(threads) ? threads : []) {
41
+ if (!thread) continue;
42
+ if (thread.status === "resolved") counts.resolved += 1;
43
+ else counts.open += 1;
44
+ counts.comments += Array.isArray(thread.comments) ? thread.comments.length : 0;
45
+ }
46
+ return counts;
47
+ };
48
+ const arrangeThreads = (threads, blockIds) => {
49
+ const index = new Map((blockIds || []).map((id, position) => [id, position]));
50
+ return (Array.isArray(threads) ? threads : []).map((thread) => {
51
+ const position = index.has(thread.blockId) ? index.get(thread.blockId) : null;
52
+ return { ...thread, detached: Boolean(blockIds) && position === null, position };
53
+ }).sort((a, b) => {
54
+ if (a.status === "resolved" !== (b.status === "resolved")) return a.status === "resolved" ? 1 : -1;
55
+ if (a.detached !== b.detached) return a.detached ? 1 : -1;
56
+ if (a.position !== null && b.position !== null && a.position !== b.position)
57
+ return a.position - b.position;
58
+ return String(b.updatedAt || "").localeCompare(String(a.updatedAt || ""));
59
+ });
60
+ };
61
+ const UNITS = [
62
+ ["year", 365 * 24 * 3600],
63
+ ["month", 30 * 24 * 3600],
64
+ ["week", 7 * 24 * 3600],
65
+ ["day", 24 * 3600],
66
+ ["hour", 3600],
67
+ ["minute", 60]
68
+ ];
69
+ const relativeTimeParts = (when, now = Date.now()) => {
70
+ const time = new Date(when).getTime();
71
+ if (!Number.isFinite(time)) return { value: 0, unit: "second" };
72
+ const seconds = Math.round((time - now) / 1e3);
73
+ const abs = Math.abs(seconds);
74
+ for (const [unit, size] of UNITS) {
75
+ if (abs >= size) return { value: Math.trunc(seconds / size), unit };
76
+ }
77
+ return { value: 0, unit: "second" };
78
+ };
79
+ export {
80
+ MAX_COMMENT_LENGTH as M,
81
+ arrangeThreads as a,
82
+ blockExcerpt as b,
83
+ countThreads as c,
84
+ normalizeExcerpt as n,
85
+ openThreadsByBlock as o,
86
+ relativeTimeParts as r
87
+ };
@@ -32,6 +32,22 @@ const de = {
32
32
  "tools.code.language": "Sprache",
33
33
  "tools.code.lineNumbers": "Zeilennummern",
34
34
  "tools.code.placeholder": "Code eingeben",
35
+ "tools.math.label": "TeX",
36
+ "tools.math.placeholder": "Geben Sie TeX ein, zum Beispiel x^2 + y^2",
37
+ "tools.math.style": "Darstellung",
38
+ "tools.math.styleDisplay": "Abgesetzt (eigene Zeile, zentriert)",
39
+ "tools.math.styleText": "Textgröße",
40
+ "tools.math.preview": "Vorschau der Formel",
41
+ "tools.math.empty": "Hier erscheint die Formel.",
42
+ "tools.math.invalid": "Dieses TeX funktioniert nicht: {message}",
43
+ "tools.math.unavailable": "Die Vorschau konnte nicht geladen werden.",
44
+ "tools.inlineMath.title": "Formel im Text",
45
+ "tools.inlineMath.preview": "Vorschau der Formel",
46
+ "tools.inlineMath.empty": "Geben Sie TeX ein, zum Beispiel x^2",
47
+ "tools.footnote.title": "Fußnote",
48
+ "tools.names.math": "Formel",
49
+ "tools.names.inlineMath": "Formel im Text",
50
+ "tools.names.footnote": "Fußnote",
35
51
  "tools.common.cancel": "Abbrechen",
36
52
  "tools.common.caption": "Bildunterschrift",
37
53
  "tools.common.noUpload": "Sie haben keine Berechtigung, Dateien hochzuladen",
@@ -78,6 +94,13 @@ const de = {
78
94
  "tools.hyperlink.newTab": "In neuem Tab öffnen",
79
95
  "tools.hyperlink.placeholder": "Link einfügen und Eingabetaste drücken",
80
96
  "tools.mention.title": "Eintrag erwähnen",
97
+ "tools.mention.trigger.results": "Einträge zum Erwähnen",
98
+ "tools.mention.trigger.type": "Inhaltstyp",
99
+ "tools.mention.trigger.hint": "Pfeiltasten wählen, Enter fügt ein, Escape schließt. Tab wechselt den Inhaltstyp.",
100
+ "tools.mention.trigger.hintSingle": "Pfeiltasten wählen, Enter fügt ein, Escape schließt.",
101
+ "tools.mention.trigger.count": "{count, plural, =0 {Keine passenden Einträge} one {# Eintrag} other {# Einträge}}",
102
+ "tools.code.filename": "Dateiname",
103
+ "tools.code.filenamePlaceholder": "Dateiname (optional)",
81
104
  "tools.names.mention": "Erwähnung",
82
105
  "tools.names.toc": "Inhaltsverzeichnis",
83
106
  "tools.toc.empty": "Noch keine Überschriften zwischen Ebene {min} und {max}. Fügen Sie Überschriften hinzu, sie erscheinen dann hier.",
@@ -149,8 +172,23 @@ const de = {
149
172
  "tools.table.deleteRow": "Zeile löschen",
150
173
  "tools.table.rowAbove": "Zeile oberhalb einfügen",
151
174
  "tools.table.rowBelow": "Zeile unterhalb einfügen",
152
- "tools.table.withHeadings": "Mit Überschriften",
153
- "tools.table.withoutHeadings": "Ohne Überschriften",
175
+ "tools.table.alignCenter": "Spalte zentrieren",
176
+ "tools.table.alignLeft": "Spalte linksbündig ausrichten",
177
+ "tools.table.alignRight": "Spalte rechtsbündig ausrichten",
178
+ "tools.table.caption": "Beschriftung (optional)",
179
+ "tools.table.captionLabel": "Tabellenbeschriftung",
180
+ "tools.table.cell": "Zeile {row}, Spalte {column}",
181
+ "tools.table.headerColumn": "Kopfspalte",
182
+ "tools.table.headerRow": "Kopfzeile",
183
+ "tools.table.merge": "Ausgewählte Zellen verbinden",
184
+ "tools.table.mergeDown": "Mit der Zelle darunter verbinden",
185
+ "tools.table.mergeRight": "Mit der Zelle rechts verbinden",
186
+ "tools.table.merged": "Zellen verbunden",
187
+ "tools.table.selection": "{count, plural, one {# Zelle ausgewählt} other {# Zellen ausgewählt}}",
188
+ "tools.table.split": "Zelle teilen",
189
+ "tools.table.splitDone": "Zelle geteilt",
190
+ "tools.table.stretch": "Volle Breite",
191
+ "tools.table.toolbar": "Tabellenwerkzeuge",
154
192
  "tools.textVariant.callOut": "Hervorhebung",
155
193
  "tools.textVariant.citation": "Zitat",
156
194
  "tools.textVariant.details": "Details",
@@ -250,6 +288,7 @@ const de = {
250
288
  "tools.focal.none": "Kein Fokuspunkt gesetzt (Frontends verwenden die Mitte).",
251
289
  "tools.focal.toggleSet": "Fokuspunkt {x} %, {y} %",
252
290
  "tools.focal.toggle": "Fokuspunkt festlegen",
291
+ "tools.names.comment": "Kommentieren",
253
292
  "tools.names.gallery": "Galerie",
254
293
  "tools.names.video": "Video",
255
294
  "tools.names.audio": "Audio",
@@ -34,6 +34,22 @@ const de = {
34
34
  "tools.code.language": "Sprache",
35
35
  "tools.code.lineNumbers": "Zeilennummern",
36
36
  "tools.code.placeholder": "Code eingeben",
37
+ "tools.math.label": "TeX",
38
+ "tools.math.placeholder": "Geben Sie TeX ein, zum Beispiel x^2 + y^2",
39
+ "tools.math.style": "Darstellung",
40
+ "tools.math.styleDisplay": "Abgesetzt (eigene Zeile, zentriert)",
41
+ "tools.math.styleText": "Textgröße",
42
+ "tools.math.preview": "Vorschau der Formel",
43
+ "tools.math.empty": "Hier erscheint die Formel.",
44
+ "tools.math.invalid": "Dieses TeX funktioniert nicht: {message}",
45
+ "tools.math.unavailable": "Die Vorschau konnte nicht geladen werden.",
46
+ "tools.inlineMath.title": "Formel im Text",
47
+ "tools.inlineMath.preview": "Vorschau der Formel",
48
+ "tools.inlineMath.empty": "Geben Sie TeX ein, zum Beispiel x^2",
49
+ "tools.footnote.title": "Fußnote",
50
+ "tools.names.math": "Formel",
51
+ "tools.names.inlineMath": "Formel im Text",
52
+ "tools.names.footnote": "Fußnote",
37
53
  "tools.common.cancel": "Abbrechen",
38
54
  "tools.common.caption": "Bildunterschrift",
39
55
  "tools.common.noUpload": "Sie haben keine Berechtigung, Dateien hochzuladen",
@@ -80,6 +96,13 @@ const de = {
80
96
  "tools.hyperlink.newTab": "In neuem Tab öffnen",
81
97
  "tools.hyperlink.placeholder": "Link einfügen und Eingabetaste drücken",
82
98
  "tools.mention.title": "Eintrag erwähnen",
99
+ "tools.mention.trigger.results": "Einträge zum Erwähnen",
100
+ "tools.mention.trigger.type": "Inhaltstyp",
101
+ "tools.mention.trigger.hint": "Pfeiltasten wählen, Enter fügt ein, Escape schließt. Tab wechselt den Inhaltstyp.",
102
+ "tools.mention.trigger.hintSingle": "Pfeiltasten wählen, Enter fügt ein, Escape schließt.",
103
+ "tools.mention.trigger.count": "{count, plural, =0 {Keine passenden Einträge} one {# Eintrag} other {# Einträge}}",
104
+ "tools.code.filename": "Dateiname",
105
+ "tools.code.filenamePlaceholder": "Dateiname (optional)",
83
106
  "tools.names.mention": "Erwähnung",
84
107
  "tools.names.toc": "Inhaltsverzeichnis",
85
108
  "tools.toc.empty": "Noch keine Überschriften zwischen Ebene {min} und {max}. Fügen Sie Überschriften hinzu, sie erscheinen dann hier.",
@@ -151,8 +174,23 @@ const de = {
151
174
  "tools.table.deleteRow": "Zeile löschen",
152
175
  "tools.table.rowAbove": "Zeile oberhalb einfügen",
153
176
  "tools.table.rowBelow": "Zeile unterhalb einfügen",
154
- "tools.table.withHeadings": "Mit Überschriften",
155
- "tools.table.withoutHeadings": "Ohne Überschriften",
177
+ "tools.table.alignCenter": "Spalte zentrieren",
178
+ "tools.table.alignLeft": "Spalte linksbündig ausrichten",
179
+ "tools.table.alignRight": "Spalte rechtsbündig ausrichten",
180
+ "tools.table.caption": "Beschriftung (optional)",
181
+ "tools.table.captionLabel": "Tabellenbeschriftung",
182
+ "tools.table.cell": "Zeile {row}, Spalte {column}",
183
+ "tools.table.headerColumn": "Kopfspalte",
184
+ "tools.table.headerRow": "Kopfzeile",
185
+ "tools.table.merge": "Ausgewählte Zellen verbinden",
186
+ "tools.table.mergeDown": "Mit der Zelle darunter verbinden",
187
+ "tools.table.mergeRight": "Mit der Zelle rechts verbinden",
188
+ "tools.table.merged": "Zellen verbunden",
189
+ "tools.table.selection": "{count, plural, one {# Zelle ausgewählt} other {# Zellen ausgewählt}}",
190
+ "tools.table.split": "Zelle teilen",
191
+ "tools.table.splitDone": "Zelle geteilt",
192
+ "tools.table.stretch": "Volle Breite",
193
+ "tools.table.toolbar": "Tabellenwerkzeuge",
156
194
  "tools.textVariant.callOut": "Hervorhebung",
157
195
  "tools.textVariant.citation": "Zitat",
158
196
  "tools.textVariant.details": "Details",
@@ -252,6 +290,7 @@ const de = {
252
290
  "tools.focal.none": "Kein Fokuspunkt gesetzt (Frontends verwenden die Mitte).",
253
291
  "tools.focal.toggleSet": "Fokuspunkt {x} %, {y} %",
254
292
  "tools.focal.toggle": "Fokuspunkt festlegen",
293
+ "tools.names.comment": "Kommentieren",
255
294
  "tools.names.gallery": "Galerie",
256
295
  "tools.names.video": "Video",
257
296
  "tools.names.audio": "Audio",