magic-editor-x 2.3.1 → 2.5.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 (106) hide show
  1. package/CHANGELOG.md +125 -0
  2. package/README.md +428 -148
  3. package/bin/magic-editor-x.mjs +55 -8
  4. package/dist/admin/AuditPage-Be78C7EC.mjs +382 -0
  5. package/dist/admin/AuditPage-iQzpjH8H.js +382 -0
  6. package/dist/admin/{ConfigurationPage-CYGDLjM7.mjs → ConfigurationPage-C9CPBfWy.mjs} +405 -10
  7. package/dist/admin/{ConfigurationPage-CFP3lp9p.js → ConfigurationPage-DefuBeYO.js} +415 -20
  8. package/dist/admin/ConfirmAction-CUhpngYU.js +71 -0
  9. package/dist/admin/ConfirmAction-CZjpduc3.mjs +72 -0
  10. package/dist/admin/Content-BttG50Mc.mjs +360 -0
  11. package/dist/admin/Content-V5MRBsI3.js +362 -0
  12. package/dist/admin/{CustomBlocksPage-B5Q33N-s.mjs → CustomBlocksPage-DB5nnCsn.mjs} +8 -5
  13. package/dist/admin/{CustomBlocksPage-DzPOSpfn.js → CustomBlocksPage-Dg2rM3F4.js} +26 -23
  14. package/dist/admin/EntryWidgets-B8YA0Zxy.mjs +199 -0
  15. package/dist/admin/EntryWidgets-BcXAAx3F.js +201 -0
  16. package/dist/admin/MentionsWidget-CJPZDk9Z.mjs +225 -0
  17. package/dist/admin/MentionsWidget-DUz6YVIG.js +227 -0
  18. package/dist/admin/{useT-Cmg1jwwG.mjs → SectionCard-8ZNHkvn9.mjs} +2 -12
  19. package/dist/admin/{useT-DNphiBQR.js → SectionCard-Bs-xiiH1.js} +0 -10
  20. package/dist/admin/{TemplatesPage-4A8JNO_Z.mjs → TemplatesPage-VsZ_Mc0R.mjs} +307 -10
  21. package/dist/admin/{TemplatesPage-BVkgafCK.js → TemplatesPage-dx4_yd_t.js} +321 -24
  22. package/dist/admin/{ConfirmAction-zLuIFj8t.js → api-4AYzwS4-.js} +28 -71
  23. package/dist/admin/{ConfirmAction-DuQwvRYi.mjs → api-CcTYyckq.mjs} +28 -71
  24. package/dist/admin/auditText-DIIYVR6k.mjs +110 -0
  25. package/dist/admin/auditText-DUhWu2Nx.js +109 -0
  26. package/dist/admin/comments-C7P41lan.js +86 -0
  27. package/dist/admin/comments-hfIbLQNO.mjs +87 -0
  28. package/dist/admin/{de-B1X46JJZ.js → de-B6rdcOqQ.js} +293 -5
  29. package/dist/admin/{de-1cFMs-4c.mjs → de-BWfR2jTg.mjs} +8 -1
  30. package/dist/admin/{de-BUS1hUw0.mjs → de-Bip0sBRT.mjs} +158 -1
  31. package/dist/admin/{de-Dn8athM8.js → de-BrPR4sUB.js} +8 -1
  32. package/dist/admin/{de-DOiGaTNX.mjs → de-CQA8hOpl.mjs} +293 -5
  33. package/dist/admin/{de-C3AsGauQ.js → de-CnnxKXj7.js} +158 -1
  34. package/dist/admin/{de-2Ie5jy7j.js → de-Dss5POqk.js} +53 -3
  35. package/dist/admin/{de-BMY2LBaa.mjs → de-zgHCYTLH.mjs} +53 -3
  36. package/dist/admin/{en-CIZ5Ggod.js → en--JjAHbpP.js} +8 -1
  37. package/dist/admin/{en-CU6UzV4g.mjs → en-BCKaVgBM.mjs} +293 -5
  38. package/dist/admin/{en-Ah-Cw0Wd.js → en-CJ17Sp_e.js} +53 -3
  39. package/dist/admin/{en-CDg_18Bt.js → en-CbGkcq0Q.js} +293 -5
  40. package/dist/admin/{en-GCzgS9Aw.mjs → en-Cd6Jk-J0.mjs} +158 -1
  41. package/dist/admin/{en-BkEjpC3i.js → en-D69Fe9ZO.js} +158 -1
  42. package/dist/admin/{en-Dc9y-6n9.mjs → en-Dr58wBAo.mjs} +8 -1
  43. package/dist/admin/{en-CvFiqti2.mjs → en-Uhm7OouM.mjs} +53 -3
  44. package/dist/admin/entry-panel-events-0msyPrAD.js +18 -0
  45. package/dist/admin/entry-panel-events-XRuUoLZ9.mjs +19 -0
  46. package/dist/admin/{es-D2Kw6E4N.mjs → es-B2Hkkbw9.mjs} +8 -1
  47. package/dist/admin/{es-DbKHZz5l.mjs → es-BMkmfH88.mjs} +53 -3
  48. package/dist/admin/{es-DHBBZKl2.mjs → es-Bz8d72Fa.mjs} +158 -1
  49. package/dist/admin/{es-BCpJmUEM.js → es-C8UotT8O.js} +293 -5
  50. package/dist/admin/{es-C4pEnDRv.js → es-CcEDZpVQ.js} +158 -1
  51. package/dist/admin/{es-Cr8JH85N.js → es-DJm3HFJt.js} +53 -3
  52. package/dist/admin/{es-C4IRHV5d.js → es-YvaTAtqY.js} +8 -1
  53. package/dist/admin/{es-BmfffNM2.mjs → es-pvPfNAld.mjs} +293 -5
  54. package/dist/admin/{fr-BOvvfEH7.mjs → fr-BvPjRiwr.mjs} +8 -1
  55. package/dist/admin/{fr-Dvq4xk2e.mjs → fr-CKHZ0xxU.mjs} +158 -1
  56. package/dist/admin/{fr-OJ4VW1kh.js → fr-CRM9VuAq.js} +53 -3
  57. package/dist/admin/{fr-DQJ_7aq5.mjs → fr-CrIHmKYX.mjs} +53 -3
  58. package/dist/admin/{fr-C2aLSwEu.js → fr-Cx29jQ_g.js} +158 -1
  59. package/dist/admin/{fr-DZd2XJP6.mjs → fr-D4tL6Ag2.mjs} +293 -5
  60. package/dist/admin/{fr-Zkb8vfjN.js → fr-Di-U-rAH.js} +8 -1
  61. package/dist/admin/{fr-ZcN0yM_2.js → fr-DrUYv2jh.js} +293 -5
  62. package/dist/admin/{index-k8_a5o1A.mjs → index-C4ksUkEm.mjs} +20059 -10130
  63. package/dist/admin/{index-DQVE0ymw.js → index-C5D3VqLq.js} +21272 -11344
  64. package/dist/admin/index-CMYCZWOh.mjs +3752 -0
  65. package/dist/admin/index-DRyctF9s.js +3753 -0
  66. package/dist/admin/index.js +2 -1
  67. package/dist/admin/index.mjs +3 -2
  68. package/dist/admin/math-D6jmskGS.js +49 -0
  69. package/dist/admin/math-DntdSWKX.mjs +47 -0
  70. package/dist/admin/{pt-CilDggGF.mjs → pt-B8x7v-Xw.mjs} +158 -1
  71. package/dist/admin/{pt-DX0OAIoL.js → pt-BYn2xx78.js} +158 -1
  72. package/dist/admin/{pt-CImqDnLB.js → pt-CojQcz-p.js} +293 -5
  73. package/dist/admin/{pt-C3UdeIpd.mjs → pt-CuoIihKx.mjs} +293 -5
  74. package/dist/admin/{pt-1IUyx6ae.js → pt-CzrN_3ui.js} +8 -1
  75. package/dist/admin/{pt-BSLzA17U.mjs → pt-DDlPJYtB.mjs} +53 -3
  76. package/dist/admin/{pt-D0I0_JYs.js → pt-DPVAycXJ.js} +53 -3
  77. package/dist/admin/{pt-etwsg3G4.mjs → pt-DdGagO99.mjs} +8 -1
  78. package/dist/admin/useT-Bpw__IXT.js +12 -0
  79. package/dist/admin/useT-Cb-R3kyA.mjs +13 -0
  80. package/dist/blocks/index.d.mts +126 -0
  81. package/dist/blocks/index.d.ts +126 -0
  82. package/dist/blocks/index.js +184 -4
  83. package/dist/blocks/index.mjs +184 -4
  84. package/dist/math/index.d.mts +27 -0
  85. package/dist/math/index.d.ts +27 -0
  86. package/dist/math/index.js +168 -0
  87. package/dist/math/index.mjs +138 -0
  88. package/dist/react/index.js +1650 -759
  89. package/dist/react/index.mjs +1650 -759
  90. package/dist/render/index.d.mts +48 -0
  91. package/dist/render/index.d.ts +48 -0
  92. package/dist/render/index.js +1755 -773
  93. package/dist/render/index.mjs +1755 -773
  94. package/dist/server/index.js +29475 -18462
  95. package/dist/server/index.mjs +29475 -18462
  96. package/dist/server/mcp-worker.js +11319 -0
  97. package/dist/vue/index.js +1650 -759
  98. package/dist/vue/index.mjs +1650 -759
  99. package/package.json +14 -8
  100. package/schema/magic-editor-x.schema.json +135 -2
  101. package/types/blocks.d.ts +126 -0
  102. package/types/index.d.ts +52 -1
  103. package/types/math.d.ts +27 -0
  104. package/types/render.d.ts +48 -0
  105. package/dist/admin/index-DR8sHkTk.js +0 -1940
  106. package/dist/admin/index-My6FjjHB.mjs +0 -1939
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-editor-x",
3
- "version": "2.3.1",
3
+ "version": "2.5.0",
4
4
  "description": "Free, open-source block editor for Strapi 5: Editor.js custom field with Media Library uploads, custom blocks, version history, live collaboration across several servers and an optional AI assistant with your own provider.",
5
5
  "keywords": [
6
6
  "strapi",
@@ -61,6 +61,12 @@
61
61
  "require": "./dist/vue/index.js",
62
62
  "default": "./dist/vue/index.js"
63
63
  },
64
+ "./math": {
65
+ "source": "./shared/math/index.mjs",
66
+ "import": "./dist/math/index.mjs",
67
+ "require": "./dist/math/index.js",
68
+ "default": "./dist/math/index.js"
69
+ },
64
70
  "./blocks": {
65
71
  "source": "./shared/blocks/index.mjs",
66
72
  "import": "./dist/blocks/index.mjs",
@@ -111,7 +117,7 @@
111
117
  "@editorjs/attaches": "^1.3.2",
112
118
  "@editorjs/code": "^2.9.4",
113
119
  "@editorjs/editorjs": "^2.31.7",
114
- "@editorjs/embed": "^2.8.0",
120
+ "@editorjs/embed": "~2.7.7",
115
121
  "@editorjs/header": "^2.8.9",
116
122
  "@editorjs/image": "^2.10.3",
117
123
  "@editorjs/inline-code": "^1.5.2",
@@ -119,7 +125,6 @@
119
125
  "@editorjs/paragraph": "^2.11.7",
120
126
  "@editorjs/quote": "^2.7.6",
121
127
  "@editorjs/raw": "^2.5.1",
122
- "@editorjs/table": "^2.4.6",
123
128
  "@editorjs/warning": "^1.4.1",
124
129
  "dompurify": "^3.4.17",
125
130
  "editorjs-indent-tune": "^1.4.4",
@@ -131,6 +136,7 @@
131
136
  "sanitize-html": "^2.18.1",
132
137
  "socket.io": "^4.8.4",
133
138
  "socket.io-client": "^4.8.4",
139
+ "temml": "^0.14.0",
134
140
  "yjs": "^13.6.33",
135
141
  "zod": "^4.6.7"
136
142
  },
@@ -142,11 +148,11 @@
142
148
  "@semantic-release/github": "^12.0.10",
143
149
  "@semantic-release/npm": "^13.2.0",
144
150
  "@semantic-release/release-notes-generator": "^14.1.1",
145
- "@strapi/design-system": "2.2.4",
146
- "@strapi/icons": "2.2.4",
151
+ "@strapi/design-system": "^2.3.1",
152
+ "@strapi/icons": "^2.3.1",
147
153
  "@strapi/sdk-plugin": "^6.1.1",
148
- "@strapi/strapi": "^5.61.1",
149
- "@strapi/utils": "^5.61.1",
154
+ "@strapi/strapi": "^5.62.0",
155
+ "@strapi/utils": "^5.62.0",
150
156
  "better-sqlite3": "^13.0.3",
151
157
  "esbuild": "^0.28.2",
152
158
  "eslint": "^10.14.0",
@@ -190,7 +196,7 @@
190
196
  }
191
197
  },
192
198
  "engines": {
193
- "node": ">=22.0.0 <=26.x.x"
199
+ "node": ">=22.12.0 <=26.x.x"
194
200
  },
195
201
  "strapi": {
196
202
  "kind": "plugin",
@@ -19,6 +19,11 @@
19
19
  "version": {
20
20
  "type": "string",
21
21
  "maxLength": 32
22
+ },
23
+ "fieldKey": {
24
+ "type": "string",
25
+ "pattern": "^[A-Za-z0-9_-]{16,32}$",
26
+ "description": "Since 2.4: stable identity of a value inside a repeatable component or dynamic zone (random, URL-safe). Set by the server on save; renderers ignore it. Absent on top-level fields."
22
27
  }
23
28
  },
24
29
  "required": ["time", "blocks", "version"],
@@ -26,7 +31,7 @@
26
31
  "$defs": {
27
32
  "inlineHtml": {
28
33
  "type": "string",
29
- "description": "Inline HTML limited to b, strong, i, em, u, s, mark, code, a, br, span, sub, sup with the attributes of the sanitising policy. Internal links carry data-mex-uid, data-mex-document-id and data-mex-locale; mentions (inline entry references) also data-mex-mention=\"true\"."
34
+ "description": "Inline HTML limited to b, strong, i, em, u, s, mark, code, a, br, span, sub, sup with the attributes of the sanitising policy. Internal links carry data-mex-uid, data-mex-document-id and data-mex-locale; mentions (inline entry references) also data-mex-mention=\"true\". Inline math (2.4): <span data-mex-math=\"true\">TeX source</span> (text only). Footnote markers (2.4): <sup data-mex-footnote=\"id\" data-mex-note=\"inline HTML of the note\">n</sup> (the note follows the same rules without footnotes and entry references; the marker text is a placeholder). Since 2.5: text colour <span data-mex-color=\"token\"> and highlight <mark data-mex-highlight=\"token\"> (token /^[a-z][a-z0-9-]{0,31}$/ from the configured palette, never a style), inline annotations <span data-mex-annotation=\"name\" data-mex-a-<key>=\"value\"> (name /^[a-z][a-z0-9-]{1,39}$/, at most 8 values of at most 1000 characters; the attribute schema of a registered annotation is annotationJsonSchema(definition) from magic-editor-x/blocks), and plain <sup>/<sub>."
30
35
  },
31
36
  "url": {
32
37
  "type": "string",
@@ -807,6 +812,48 @@
807
812
  }
808
813
  }
809
814
  },
815
+ {
816
+ "if": {
817
+ "properties": {
818
+ "type": {
819
+ "const": "math"
820
+ },
821
+ "data": {
822
+ "type": "object",
823
+ "anyOf": [
824
+ {
825
+ "required": ["_mex"],
826
+ "properties": {
827
+ "_mex": {
828
+ "type": "integer",
829
+ "minimum": 1,
830
+ "description": "Built-in block marker (2.3: 1). Tells the built-in block apart from a custom block created before 2.3 under the same name."
831
+ }
832
+ }
833
+ },
834
+ {
835
+ "properties": {
836
+ "tex": {
837
+ "type": "string"
838
+ },
839
+ "display": {}
840
+ },
841
+ "additionalProperties": false,
842
+ "required": ["tex"]
843
+ }
844
+ ]
845
+ }
846
+ },
847
+ "required": ["type", "data"]
848
+ },
849
+ "then": {
850
+ "properties": {
851
+ "data": {
852
+ "$ref": "#/$defs/data_math"
853
+ }
854
+ }
855
+ }
856
+ },
810
857
  {
811
858
  "if": {
812
859
  "properties": {
@@ -1026,6 +1073,12 @@
1026
1073
  },
1027
1074
  "showlinenumbers": {
1028
1075
  "type": "boolean"
1076
+ },
1077
+ "filename": {
1078
+ "type": "string",
1079
+ "maxLength": 200,
1080
+ "minLength": 1,
1081
+ "description": "Optional file name label shown above the code (plain text, no control characters; 2.4). Omitted when empty."
1029
1082
  }
1030
1083
  },
1031
1084
  "required": ["code", "language"],
@@ -1047,7 +1100,8 @@
1047
1100
  "type": "object",
1048
1101
  "properties": {
1049
1102
  "withHeadings": {
1050
- "type": "boolean"
1103
+ "type": "boolean",
1104
+ "description": "The first row is a header row."
1051
1105
  },
1052
1106
  "stretched": {
1053
1107
  "type": "boolean"
@@ -1061,7 +1115,56 @@
1061
1115
  "items": {
1062
1116
  "$ref": "#/$defs/inlineHtml"
1063
1117
  }
1118
+ },
1119
+ "description": "Rows of cells. With `merges` the grid is rectangular and the cells a merge covers are empty strings."
1120
+ },
1121
+ "headerColumn": {
1122
+ "type": "boolean",
1123
+ "description": "2.4: the first column is a header column (only written when true)."
1124
+ },
1125
+ "align": {
1126
+ "type": "array",
1127
+ "maxItems": 100,
1128
+ "items": {
1129
+ "enum": ["left", "center", "right", null]
1130
+ },
1131
+ "description": "2.4: alignment per column (null = not set); trailing nulls are removed."
1132
+ },
1133
+ "merges": {
1134
+ "type": "array",
1135
+ "maxItems": 1000,
1136
+ "description": "2.4: merged cells, sorted by row and column. Inside the grid, never overlapping, at least two cells, never from the header row into the body.",
1137
+ "items": {
1138
+ "type": "object",
1139
+ "properties": {
1140
+ "row": {
1141
+ "type": "integer",
1142
+ "minimum": 0,
1143
+ "maximum": 499
1144
+ },
1145
+ "col": {
1146
+ "type": "integer",
1147
+ "minimum": 0,
1148
+ "maximum": 99
1149
+ },
1150
+ "rowspan": {
1151
+ "type": "integer",
1152
+ "minimum": 1,
1153
+ "maximum": 500
1154
+ },
1155
+ "colspan": {
1156
+ "type": "integer",
1157
+ "minimum": 1,
1158
+ "maximum": 100
1159
+ }
1160
+ },
1161
+ "required": ["row", "col", "rowspan", "colspan"],
1162
+ "additionalProperties": false
1064
1163
  }
1164
+ },
1165
+ "caption": {
1166
+ "$ref": "#/$defs/inlineHtml",
1167
+ "description": "2.4: table caption (inline HTML, only written when not empty)."
1065
1168
  }
1066
1169
  },
1067
1170
  "required": ["withHeadings", "stretched", "content"],
@@ -1346,6 +1449,14 @@
1346
1449
  "url": {
1347
1450
  "$ref": "#/$defs/url"
1348
1451
  },
1452
+ "id": {
1453
+ "type": ["integer", "string"],
1454
+ "description": "Media Library file id (2.5)."
1455
+ },
1456
+ "documentId": {
1457
+ "type": "string",
1458
+ "maxLength": 64
1459
+ },
1349
1460
  "name": {
1350
1461
  "type": "string",
1351
1462
  "maxLength": 255
@@ -1484,6 +1595,28 @@
1484
1595
  "required": ["title", "minLevel", "maxLevel", "style", "_mex"],
1485
1596
  "additionalProperties": false
1486
1597
  },
1598
+ "data_math": {
1599
+ "type": "object",
1600
+ "description": "Math block (2.4).",
1601
+ "properties": {
1602
+ "tex": {
1603
+ "type": "string",
1604
+ "maxLength": 10000,
1605
+ "description": "TeX source of the formula (only the source is stored). Renderers output MathML with `options.math`, else the source between \\[ \\] delimiters."
1606
+ },
1607
+ "display": {
1608
+ "type": "boolean",
1609
+ "description": "Display style (default true); false renders the formula in text style."
1610
+ },
1611
+ "_mex": {
1612
+ "type": "integer",
1613
+ "minimum": 1,
1614
+ "description": "Built-in block marker (2.3: 1). Tells the built-in block apart from a custom block created before 2.3 under the same name."
1615
+ }
1616
+ },
1617
+ "required": ["tex", "display", "_mex"],
1618
+ "additionalProperties": false
1619
+ },
1487
1620
  "data_synced": {
1488
1621
  "type": "object",
1489
1622
  "description": "Synced block: a reference to shared content that is edited in one place.",
package/types/blocks.d.ts CHANGED
@@ -153,6 +153,8 @@ export class BlockDefinitionError extends Error {
153
153
  export const BLOCK_FIELD_TYPES: readonly BlockFieldType[];
154
154
  export const BLOCK_PRESETS: readonly ['article', 'basic', 'minimal'];
155
155
  export const RESERVED_BLOCK_NAMES: readonly string[];
156
+ /** Built-in names that code blocks may still use (2.4: `math`, a built-in added after the SDK shipped). */
157
+ export const SDK_COMPATIBLE_NAMES: readonly string[];
156
158
  export const BLOCK_LIMITS: Readonly<{
157
159
  maxFields: number;
158
160
  maxDepth: number;
@@ -165,3 +167,127 @@ export const BLOCK_LIMITS: Readonly<{
165
167
  maxValues: number;
166
168
  maxUrl: number;
167
169
  }>;
170
+
171
+ /* ------------------------------------------------------------------ 2.5 */
172
+
173
+ /** Attribute types of an inline annotation. */
174
+ export type InlineAnnotationFieldType = 'text' | 'enum' | 'url';
175
+
176
+ export interface InlineAnnotationAttributeInput {
177
+ type: InlineAnnotationFieldType;
178
+ label?: string;
179
+ /** Without a required value the annotation is unwrapped on save (its text stays). */
180
+ required?: boolean;
181
+ /** `text`: 1-1000 characters (default 200). */
182
+ max?: number;
183
+ /** `enum`: 1-50 distinct strings. */
184
+ values?: readonly string[];
185
+ /** `url`: subset of http, https, mailto, tel (default http + https). */
186
+ schemes?: ReadonlyArray<'http' | 'https' | 'mailto' | 'tel'>;
187
+ /** `url`: allow site-relative URLs (default true). */
188
+ relative?: boolean;
189
+ }
190
+
191
+ /** What `render` and `resolve` see of one annotation (clean values). */
192
+ export interface InlineAnnotationUse {
193
+ name: string;
194
+ attrs: Record<string, string>;
195
+ text: string;
196
+ /** Value from `resolve` (server output) or the `resolveAnnotation` render option. */
197
+ resolved?: string | Record<string, unknown>;
198
+ }
199
+
200
+ /** The one element that wraps the annotated text (validated: allowed tags and attributes only). */
201
+ export interface InlineAnnotationWrapper {
202
+ tag:
203
+ | 'abbr'
204
+ | 'dfn'
205
+ | 'span'
206
+ | 'a'
207
+ | 'mark'
208
+ | 'cite'
209
+ | 'q'
210
+ | 'small'
211
+ | 'em'
212
+ | 'strong'
213
+ | 'b'
214
+ | 'i'
215
+ | 'u'
216
+ | 's'
217
+ | 'time'
218
+ | 'data'
219
+ | 'bdi'
220
+ | 'kbd'
221
+ | 'var'
222
+ | 'ins'
223
+ | 'del';
224
+ /** `title`, `class`, `lang`, `dir`, `href` (only on `a`), `datetime`, `value`, `cite`, `aria-label`, `data-*` (not `data-mex-*`). */
225
+ attrs?: Record<string, string | number | null | undefined | false>;
226
+ }
227
+
228
+ /** Context of a server-side `resolve` call (Content API `?mex=`, GraphQL `…Rendered`). */
229
+ export interface InlineAnnotationResolveContext {
230
+ status: 'draft' | 'published';
231
+ /**
232
+ * Permission-aware lookup: only `api::` types the caller may `find`, the
233
+ * query sanitised with the caller's auth, the request's publication status,
234
+ * at most 100 rows, every row sanitised for output.
235
+ */
236
+ find(
237
+ uid: string,
238
+ query?: { filters?: Record<string, unknown>; fields?: string[]; locale?: string | null; limit?: number }
239
+ ): Promise<Array<Record<string, unknown>>>;
240
+ }
241
+
242
+ export interface InlineAnnotationDefinitionInput {
243
+ /** `/^[a-z][a-z0-9-]{1,39}$/`; `abbreviation` is built in. */
244
+ name: string;
245
+ label?: string;
246
+ description?: string;
247
+ /** 0-8 attributes, keys `/^[a-z][a-z0-9]{0,23}$/`, stored as `data-mex-a-<key>`. */
248
+ attributes: Record<string, InlineAnnotationAttributeInput>;
249
+ /** Presets that offer the annotation without the field option `inlineAnnotations`. */
250
+ presets?: ReadonlyArray<'full' | 'article' | 'basic' | 'minimal'>;
251
+ /** Keyboard shortcut of the editor tool: one of `ANNOTATION_SHORTCUTS` (Ctrl on Windows/Linux). */
252
+ shortcut?: 'CMD+SHIFT+0' | 'CMD+SHIFT+1' | 'CMD+SHIFT+8';
253
+ /**
254
+ * Server only: one call per response with every distinct use (at most 200);
255
+ * return the values in the same order (string up to 2000 characters or a plain object).
256
+ */
257
+ resolve?: (
258
+ items: ReadonlyArray<{ attrs: Record<string, string>; locale: string | null }>,
259
+ context: InlineAnnotationResolveContext
260
+ ) => Promise<ReadonlyArray<unknown>> | ReadonlyArray<unknown>;
261
+ /** Wrapper of the annotated text; `false` renders the text only; null/undefined/throw = default span. */
262
+ render?: (annotation: InlineAnnotationUse) => InlineAnnotationWrapper | false | null | undefined;
263
+ }
264
+
265
+ export type InlineAnnotationDefinition = Readonly<
266
+ Required<Pick<InlineAnnotationDefinitionInput, 'name' | 'label'>> &
267
+ Omit<InlineAnnotationDefinitionInput, 'name' | 'label' | 'attributes' | 'presets'> & {
268
+ attributes: Readonly<Record<string, Readonly<InlineAnnotationAttributeInput & { required: boolean }>>>;
269
+ presets: readonly string[];
270
+ }
271
+ >;
272
+
273
+ export function defineInlineAnnotation(
274
+ definition: InlineAnnotationDefinitionInput
275
+ ): InlineAnnotationDefinition;
276
+ export function annotationJsonSchema(definition: InlineAnnotationDefinition): Record<string, unknown>;
277
+ /** The built-in abbreviation (`title`, required): renders `<abbr title>`. */
278
+ export const abbreviationAnnotation: InlineAnnotationDefinition;
279
+ export const ANNOTATION_ATTRIBUTE: 'data-mex-annotation';
280
+ export const ANNOTATION_VALUE_PREFIX: 'data-mex-a-';
281
+ export const ANNOTATION_FIELD_TYPES: readonly InlineAnnotationFieldType[];
282
+ export const ANNOTATION_PRESETS: readonly ['full', 'article', 'basic', 'minimal'];
283
+ export const ANNOTATION_SHORTCUTS: readonly ['CMD+SHIFT+0', 'CMD+SHIFT+1', 'CMD+SHIFT+8'];
284
+ export const ANNOTATION_RENDER_TAGS: readonly InlineAnnotationWrapper['tag'][];
285
+ export const ANNOTATION_LIMITS: Readonly<{
286
+ attributes: number;
287
+ text: number;
288
+ textDefault: number;
289
+ values: number;
290
+ registered: number;
291
+ label: number;
292
+ resolveItems: number;
293
+ }>;
package/types/index.d.ts CHANGED
@@ -69,15 +69,35 @@ export interface CodeFlaskData {
69
69
  code: string;
70
70
  language: string;
71
71
  showlinenumbers?: boolean;
72
+ /** File name label shown above the code (plain text, max 200 characters; 2.4). */
73
+ filename?: string;
72
74
  }
73
75
  export interface RawData {
74
76
  /** Raw HTML, sanitised or emptied according to the server's `rawHtml` option. */
75
77
  html: string;
76
78
  }
79
+ /** A merged table cell (2.4): anchor (top left) cell and size. */
80
+ export interface TableMerge {
81
+ row: number;
82
+ col: number;
83
+ rowspan: number;
84
+ colspan: number;
85
+ }
86
+ export type TableAlign = 'left' | 'center' | 'right';
77
87
  export interface TableData {
88
+ /** The first row is a header row. */
78
89
  withHeadings: boolean;
79
90
  stretched: boolean;
91
+ /** Rows of cells. With `merges` the grid is rectangular and covered cells are ''. */
80
92
  content: InlineHtml[][];
93
+ /** 2.4: the first column is a header column (only stored when true). */
94
+ headerColumn?: boolean;
95
+ /** 2.4: alignment per column (null = not set). */
96
+ align?: Array<TableAlign | null>;
97
+ /** 2.4: merged cells (inside the grid, never overlapping, never from the header row into the body). */
98
+ merges?: TableMerge[];
99
+ /** 2.4: caption (only stored when not empty). */
100
+ caption?: InlineHtml;
81
101
  }
82
102
  export interface MediaFormat {
83
103
  url: Url;
@@ -210,7 +230,16 @@ export interface LinkToolData {
210
230
  meta: { title: string; description: string; site_name?: string; image?: { url: Url } };
211
231
  }
212
232
  export interface AttachesData {
213
- file: { url: Url; name?: string; extension?: string; size?: number; title?: string };
233
+ file: {
234
+ url: Url;
235
+ /** Media Library file id (2.5). */
236
+ id?: number | string;
237
+ documentId?: string;
238
+ name?: string;
239
+ extension?: string;
240
+ size?: number;
241
+ title?: string;
242
+ };
214
243
  title: string;
215
244
  }
216
245
  export interface EmbedData {
@@ -265,6 +294,22 @@ export interface SyncedData {
265
294
  _mex: number;
266
295
  }
267
296
 
297
+ /**
298
+ * Math block (2.4): only the TeX source is stored. Renderers output MathML with
299
+ * the `math` render option (for example `renderMath` from `magic-editor-x/math`),
300
+ * else the source between `\\[ \\]` delimiters. Inline math is stored in inline
301
+ * HTML as `<span data-mex-math="true">TeX</span>`; footnotes as
302
+ * `<sup data-mex-footnote="id" data-mex-note="note HTML">n</sup>`.
303
+ */
304
+ export interface MathData {
305
+ /** TeX source (at most 10000 characters). */
306
+ tex: string;
307
+ /** Display style (default true); false renders the formula in text style. */
308
+ display: boolean;
309
+ /** Built-in block marker (2.4 writes 1); a custom block named `math` from before 2.4 has none. */
310
+ _mex: number;
311
+ }
312
+
268
313
  /** Data per built-in block type. */
269
314
  export interface BlockDataMap {
270
315
  paragraph: ParagraphData;
@@ -292,6 +337,7 @@ export interface BlockDataMap {
292
337
  delimiter: DelimiterData;
293
338
  toc: TocData;
294
339
  synced: SyncedData;
340
+ math: MathData;
295
341
  }
296
342
 
297
343
  export type BuiltInBlockType = keyof BlockDataMap;
@@ -316,6 +362,11 @@ export interface MagicEditorXData {
316
362
  time: number;
317
363
  blocks: MagicEditorXBlock[];
318
364
  version: string;
365
+ /**
366
+ * Since 2.4: stable identity of a value inside a repeatable component or dynamic zone
367
+ * (16-32 URL-safe characters, set by the server on save). Renderers ignore it.
368
+ */
369
+ fieldKey?: string;
319
370
  }
320
371
 
321
372
  export type MagicEditorXValue = MagicEditorXData | null;
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Math helper (`magic-editor-x/math`, 2.4): TeX to MathML with Temml, for the
3
+ * `math` render option.
4
+ */
5
+
6
+ /** Temml settings used by the helper. */
7
+ export const MATH_SETTINGS: Readonly<{
8
+ trust: false;
9
+ throwOnError: true;
10
+ strict: false;
11
+ annotate: true;
12
+ xml: false;
13
+ wrap: 'none';
14
+ maxSize: readonly [number, number];
15
+ maxExpand: number;
16
+ }>;
17
+
18
+ /** MathML (`<math>…</math>`) or null when the TeX is empty, too long or does not parse. Never throws. */
19
+ export function renderMath(tex: unknown, options?: { display?: boolean }): string | null;
20
+
21
+ /** Whether the TeX parses; `message` explains the error (plain text, may quote the TeX). */
22
+ export function checkMath(
23
+ tex: unknown,
24
+ options?: { display?: boolean }
25
+ ): { ok: true } | { ok: false; message: string };
26
+
27
+ export default renderMath;
package/types/render.d.ts CHANGED
@@ -166,8 +166,56 @@ export interface RenderOptions {
166
166
  * come expanded.
167
167
  */
168
168
  synced?: SyncedSources;
169
+ /**
170
+ * Math (2.4): renders TeX of math blocks and inline math. Return MathML
171
+ * (string) or render nodes; the result is parsed through a strict MathML
172
+ * allow-list (MathML Core elements, no href, style, id or event
173
+ * attributes). `renderMath` from `magic-editor-x/math` (Temml) fits.
174
+ * Without it, or when it returns nothing usable, the TeX source is written
175
+ * between `\\( \\)` / `\\[ \\]` in `<span|div class="mex-math" data-mex-math>`
176
+ * for client-side auto-render. Text output is the TeX source; Markdown
177
+ * `$…$` / `$$…$$`.
178
+ */
179
+ math?: MathRenderer;
180
+ /**
181
+ * Footnotes (2.4): numbered references `<sup class="mex-footnote-ref"><a href="#<prefix>fn-<id>">n</a></sup>`
182
+ * and a list `<section class="mex-footnotes">` after the content. `label`
183
+ * names the list (default 'Footnotes'), `backLabel` the back links
184
+ * (`{n}` = number, default 'Back to reference {n}'), `prefix` starts every id
185
+ * (default 'mex-'; use one per field when several fields render on a page).
186
+ * Text output: `[n]` and a list; Markdown: GFM `[^n]` footnotes.
187
+ */
188
+ footnotes?: { label?: string; backLabel?: string; prefix?: string };
189
+ /**
190
+ * Inline annotations (2.5, `defineInlineAnnotation` from `magic-editor-x/blocks`):
191
+ * `<span data-mex-annotation="name">` is rendered with the definition's
192
+ * `render` (one validated wrapper element around the text). These
193
+ * definitions replace the bundle's registry for that call; the built-in
194
+ * `abbreviation` (`<abbr title>`) is always known. Unknown annotations get
195
+ * `<span class="mex-annotation mex-annotation-<name>" data-mex-annotation …>`.
196
+ * Pass a stable array. Text and Markdown output keep the text only.
197
+ */
198
+ annotations?: ReadonlyArray<import('./blocks.js').InlineAnnotationDefinition>;
199
+ /**
200
+ * Value of an annotation for its `render` (`resolved`), e.g. a glossary
201
+ * definition looked up by the caller. A string (max 2000 characters) or a
202
+ * plain object; anything else, or a throw, is ignored. Content API output
203
+ * (`?mex=`) and GraphQL `…Rendered` pass the results of the definitions'
204
+ * server-side `resolve`.
205
+ */
206
+ resolveAnnotation?: (annotation: {
207
+ name: string;
208
+ attrs: Record<string, string>;
209
+ text: string;
210
+ }) => string | Record<string, unknown> | null | undefined;
169
211
  }
170
212
 
213
+ /** Renders TeX: MathML markup or render nodes; null/undefined for the fallback. */
214
+ export type MathRenderer = (
215
+ tex: string,
216
+ options: { display: boolean }
217
+ ) => string | RenderNode | ReadonlyArray<RenderNode> | null | undefined;
218
+
171
219
  /** A synced block source: an Editor.js document or its block array. */
172
220
  export type SyncedSource = { blocks: ReadonlyArray<unknown> } | ReadonlyArray<unknown>;
173
221
  /** Sources of synced blocks by reference (the source's documentId). */