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.
- package/CHANGELOG.md +87 -0
- package/README.md +299 -142
- package/dist/admin/AuditPage-C2u6z4aN.js +381 -0
- package/dist/admin/AuditPage-guB0SiGS.mjs +381 -0
- package/dist/admin/{ConfigurationPage-C-UktL1x.js → ConfigurationPage-D6uya-J1.js} +228 -13
- package/dist/admin/{ConfigurationPage-BxLHIQdo.mjs → ConfigurationPage-DiEpF1Rr.mjs} +222 -7
- package/dist/admin/ConfirmAction-CUhpngYU.js +71 -0
- package/dist/admin/ConfirmAction-CZjpduc3.mjs +72 -0
- package/dist/admin/{CustomBlocksPage-D8aMbVXc.mjs → CustomBlocksPage-Byt10-6c.mjs} +6 -4
- package/dist/admin/{CustomBlocksPage-CxcTfdOT.js → CustomBlocksPage-DP3h_wNd.js} +21 -19
- package/dist/admin/MentionsWidget-C2OCAmqq.js +227 -0
- package/dist/admin/MentionsWidget-sMkM9mHX.mjs +225 -0
- package/dist/admin/{TemplatesPage-Hn6gyu2l.js → TemplatesPage-DrSJdteI.js} +313 -17
- package/dist/admin/{TemplatesPage-jhYi6Zdf.mjs → TemplatesPage-Yp4OqFE2.mjs} +305 -9
- package/dist/admin/{ConfirmAction-DuQwvRYi.mjs → api-2ZRpHM3d.mjs} +19 -70
- package/dist/admin/{ConfirmAction-zLuIFj8t.js → api-bix9RLLI.js} +19 -70
- package/dist/admin/auditText-DIIYVR6k.mjs +110 -0
- package/dist/admin/auditText-DUhWu2Nx.js +109 -0
- package/dist/admin/comments-C7P41lan.js +86 -0
- package/dist/admin/comments-hfIbLQNO.mjs +87 -0
- package/dist/admin/{de-BMY2LBaa.mjs → de-BNPIGqhs.mjs} +41 -2
- package/dist/admin/{de-2Ie5jy7j.js → de-BhhGss1l.js} +41 -2
- package/dist/admin/{de-DOiGaTNX.mjs → de-CKz6CG3V.mjs} +191 -5
- package/dist/admin/{de-C3AsGauQ.js → de-CbBDnXeT.js} +140 -1
- package/dist/admin/{de-BUS1hUw0.mjs → de-DiCZrmH8.mjs} +140 -1
- package/dist/admin/{de-B1X46JJZ.js → de-zcV8D7nt.js} +191 -5
- package/dist/admin/{en-Ah-Cw0Wd.js → en-B9ApE1y1.js} +41 -2
- package/dist/admin/{en-CDg_18Bt.js → en-BMWhILnj.js} +191 -5
- package/dist/admin/{en-BkEjpC3i.js → en-CpehF0Kv.js} +140 -1
- package/dist/admin/{en-GCzgS9Aw.mjs → en-DCPMqFIa.mjs} +140 -1
- package/dist/admin/{en-CU6UzV4g.mjs → en-cYzqbASF.mjs} +191 -5
- package/dist/admin/{en-CvFiqti2.mjs → en-gFLeK9Ng.mjs} +41 -2
- package/dist/admin/{es-DbKHZz5l.mjs → es-BmwBgEgz.mjs} +41 -2
- package/dist/admin/{es-Cr8JH85N.js → es-C0W31rl8.js} +41 -2
- package/dist/admin/{es-BCpJmUEM.js → es-CQPh8PXw.js} +191 -5
- package/dist/admin/{es-C4pEnDRv.js → es-CawpzwyC.js} +140 -1
- package/dist/admin/{es-DHBBZKl2.mjs → es-Chs37IBR.mjs} +140 -1
- package/dist/admin/{es-BmfffNM2.mjs → es-DCamt1ek.mjs} +191 -5
- package/dist/admin/{fr-DQJ_7aq5.mjs → fr-CMWBNE5D.mjs} +41 -2
- package/dist/admin/{fr-C2aLSwEu.js → fr-COOsqexl.js} +140 -1
- package/dist/admin/{fr-Dvq4xk2e.mjs → fr-Dp5-XP29.mjs} +140 -1
- package/dist/admin/{fr-ZcN0yM_2.js → fr-DpC44Ol8.js} +191 -5
- package/dist/admin/{fr-OJ4VW1kh.js → fr-iGeIfEcU.js} +41 -2
- package/dist/admin/{fr-DZd2XJP6.mjs → fr-oW0t8bT5.mjs} +191 -5
- package/dist/admin/{index-Cm-fFUhE.js → index-64wc26Bl.js} +13851 -6746
- package/dist/admin/{index-XgfwqLfV.mjs → index-BVjf1gVC.mjs} +13788 -6682
- package/dist/admin/{index-BHBRr562.js → index-D6Z7i8ba.js} +1003 -53
- package/dist/admin/{index-CQk1XeNb.mjs → index-D_Fv8Non.mjs} +1032 -82
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.mjs +3 -2
- package/dist/admin/math-CIQ4Z_mY.mjs +47 -0
- package/dist/admin/math-vsK_06ZR.js +49 -0
- package/dist/admin/{pt-D0I0_JYs.js → pt-BHmXk2d9.js} +41 -2
- package/dist/admin/{pt-CImqDnLB.js → pt-Bo0Pm_Pt.js} +191 -5
- package/dist/admin/{pt-CilDggGF.mjs → pt-DALDvfBn.mjs} +140 -1
- package/dist/admin/{pt-BSLzA17U.mjs → pt-DFNgZ5_k.mjs} +41 -2
- package/dist/admin/{pt-DX0OAIoL.js → pt-DXy7G1x7.js} +140 -1
- package/dist/admin/{pt-C3UdeIpd.mjs → pt-uGpfRQLC.mjs} +191 -5
- package/dist/admin/{useT-D3sM9Zf7.js → useT-BXJLIPN4.js} +1 -1
- package/dist/admin/{useT-CmaeZbCr.mjs → useT-CLPhBmBC.mjs} +1 -1
- package/dist/blocks/index.d.mts +2 -0
- package/dist/blocks/index.d.ts +2 -0
- package/dist/blocks/index.js +13 -2
- package/dist/blocks/index.mjs +13 -2
- package/dist/math/index.d.mts +27 -0
- package/dist/math/index.d.ts +27 -0
- package/dist/math/index.js +164 -0
- package/dist/math/index.mjs +134 -0
- package/dist/react/index.js +673 -91
- package/dist/react/index.mjs +673 -91
- package/dist/render/index.d.mts +26 -0
- package/dist/render/index.d.ts +26 -0
- package/dist/render/index.js +779 -106
- package/dist/render/index.mjs +779 -106
- package/dist/server/index.js +10419 -4103
- package/dist/server/index.mjs +10419 -4103
- package/dist/vue/index.js +673 -91
- package/dist/vue/index.mjs +673 -91
- package/package.json +8 -2
- package/schema/magic-editor-x.schema.json +127 -2
- package/types/blocks.d.ts +2 -0
- package/types/index.d.ts +42 -0
- package/types/math.d.ts +27 -0
- package/types/render.d.ts +26 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "magic-editor-x",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.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",
|
|
@@ -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
|
},
|
|
@@ -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)."
|
|
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"],
|
|
@@ -1484,6 +1587,28 @@
|
|
|
1484
1587
|
"required": ["title", "minLevel", "maxLevel", "style", "_mex"],
|
|
1485
1588
|
"additionalProperties": false
|
|
1486
1589
|
},
|
|
1590
|
+
"data_math": {
|
|
1591
|
+
"type": "object",
|
|
1592
|
+
"description": "Math block (2.4).",
|
|
1593
|
+
"properties": {
|
|
1594
|
+
"tex": {
|
|
1595
|
+
"type": "string",
|
|
1596
|
+
"maxLength": 10000,
|
|
1597
|
+
"description": "TeX source of the formula (only the source is stored). Renderers output MathML with `options.math`, else the source between \\[ \\] delimiters."
|
|
1598
|
+
},
|
|
1599
|
+
"display": {
|
|
1600
|
+
"type": "boolean",
|
|
1601
|
+
"description": "Display style (default true); false renders the formula in text style."
|
|
1602
|
+
},
|
|
1603
|
+
"_mex": {
|
|
1604
|
+
"type": "integer",
|
|
1605
|
+
"minimum": 1,
|
|
1606
|
+
"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."
|
|
1607
|
+
}
|
|
1608
|
+
},
|
|
1609
|
+
"required": ["tex", "display", "_mex"],
|
|
1610
|
+
"additionalProperties": false
|
|
1611
|
+
},
|
|
1487
1612
|
"data_synced": {
|
|
1488
1613
|
"type": "object",
|
|
1489
1614
|
"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;
|
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;
|
|
@@ -265,6 +285,22 @@ export interface SyncedData {
|
|
|
265
285
|
_mex: number;
|
|
266
286
|
}
|
|
267
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Math block (2.4): only the TeX source is stored. Renderers output MathML with
|
|
290
|
+
* the `math` render option (for example `renderMath` from `magic-editor-x/math`),
|
|
291
|
+
* else the source between `\\[ \\]` delimiters. Inline math is stored in inline
|
|
292
|
+
* HTML as `<span data-mex-math="true">TeX</span>`; footnotes as
|
|
293
|
+
* `<sup data-mex-footnote="id" data-mex-note="note HTML">n</sup>`.
|
|
294
|
+
*/
|
|
295
|
+
export interface MathData {
|
|
296
|
+
/** TeX source (at most 10000 characters). */
|
|
297
|
+
tex: string;
|
|
298
|
+
/** Display style (default true); false renders the formula in text style. */
|
|
299
|
+
display: boolean;
|
|
300
|
+
/** Built-in block marker (2.4 writes 1); a custom block named `math` from before 2.4 has none. */
|
|
301
|
+
_mex: number;
|
|
302
|
+
}
|
|
303
|
+
|
|
268
304
|
/** Data per built-in block type. */
|
|
269
305
|
export interface BlockDataMap {
|
|
270
306
|
paragraph: ParagraphData;
|
|
@@ -292,6 +328,7 @@ export interface BlockDataMap {
|
|
|
292
328
|
delimiter: DelimiterData;
|
|
293
329
|
toc: TocData;
|
|
294
330
|
synced: SyncedData;
|
|
331
|
+
math: MathData;
|
|
295
332
|
}
|
|
296
333
|
|
|
297
334
|
export type BuiltInBlockType = keyof BlockDataMap;
|
|
@@ -316,6 +353,11 @@ export interface MagicEditorXData {
|
|
|
316
353
|
time: number;
|
|
317
354
|
blocks: MagicEditorXBlock[];
|
|
318
355
|
version: string;
|
|
356
|
+
/**
|
|
357
|
+
* Since 2.4: stable identity of a value inside a repeatable component or dynamic zone
|
|
358
|
+
* (16-32 URL-safe characters, set by the server on save). Renderers ignore it.
|
|
359
|
+
*/
|
|
360
|
+
fieldKey?: string;
|
|
319
361
|
}
|
|
320
362
|
|
|
321
363
|
export type MagicEditorXValue = MagicEditorXData | null;
|
package/types/math.d.ts
ADDED
|
@@ -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,34 @@ 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 };
|
|
169
189
|
}
|
|
170
190
|
|
|
191
|
+
/** Renders TeX: MathML markup or render nodes; null/undefined for the fallback. */
|
|
192
|
+
export type MathRenderer = (
|
|
193
|
+
tex: string,
|
|
194
|
+
options: { display: boolean }
|
|
195
|
+
) => string | RenderNode | ReadonlyArray<RenderNode> | null | undefined;
|
|
196
|
+
|
|
171
197
|
/** A synced block source: an Editor.js document or its block array. */
|
|
172
198
|
export type SyncedSource = { blocks: ReadonlyArray<unknown> } | ReadonlyArray<unknown>;
|
|
173
199
|
/** Sources of synced blocks by reference (the source's documentId). */
|