magic-editor-x 2.4.0 → 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.
- package/CHANGELOG.md +51 -0
- package/README.md +129 -6
- package/bin/magic-editor-x.mjs +55 -8
- package/dist/admin/{AuditPage-guB0SiGS.mjs → AuditPage-Be78C7EC.mjs} +4 -3
- package/dist/admin/{AuditPage-C2u6z4aN.js → AuditPage-iQzpjH8H.js} +7 -6
- package/dist/admin/{ConfigurationPage-DiEpF1Rr.mjs → ConfigurationPage-C9CPBfWy.mjs} +186 -6
- package/dist/admin/{ConfigurationPage-D6uya-J1.js → ConfigurationPage-DefuBeYO.js} +191 -11
- package/dist/admin/Content-BttG50Mc.mjs +360 -0
- package/dist/admin/Content-V5MRBsI3.js +362 -0
- package/dist/admin/{CustomBlocksPage-Byt10-6c.mjs → CustomBlocksPage-DB5nnCsn.mjs} +5 -4
- package/dist/admin/{CustomBlocksPage-DP3h_wNd.js → CustomBlocksPage-Dg2rM3F4.js} +8 -7
- package/dist/admin/EntryWidgets-B8YA0Zxy.mjs +199 -0
- package/dist/admin/EntryWidgets-BcXAAx3F.js +201 -0
- package/dist/admin/{MentionsWidget-sMkM9mHX.mjs → MentionsWidget-CJPZDk9Z.mjs} +2 -2
- package/dist/admin/{MentionsWidget-C2OCAmqq.js → MentionsWidget-DUz6YVIG.js} +2 -2
- package/dist/admin/{useT-CLPhBmBC.mjs → SectionCard-8ZNHkvn9.mjs} +2 -12
- package/dist/admin/{useT-BXJLIPN4.js → SectionCard-Bs-xiiH1.js} +0 -10
- package/dist/admin/{TemplatesPage-Yp4OqFE2.mjs → TemplatesPage-VsZ_Mc0R.mjs} +6 -5
- package/dist/admin/{TemplatesPage-DrSJdteI.js → TemplatesPage-dx4_yd_t.js} +13 -12
- package/dist/admin/{api-bix9RLLI.js → api-4AYzwS4-.js} +9 -1
- package/dist/admin/{api-2ZRpHM3d.mjs → api-CcTYyckq.mjs} +9 -1
- package/dist/admin/{de-zcV8D7nt.js → de-B6rdcOqQ.js} +103 -1
- package/dist/admin/{de-1cFMs-4c.mjs → de-BWfR2jTg.mjs} +8 -1
- package/dist/admin/{de-DiCZrmH8.mjs → de-Bip0sBRT.mjs} +19 -1
- package/dist/admin/{de-Dn8athM8.js → de-BrPR4sUB.js} +8 -1
- package/dist/admin/{de-CKz6CG3V.mjs → de-CQA8hOpl.mjs} +103 -1
- package/dist/admin/{de-CbBDnXeT.js → de-CnnxKXj7.js} +19 -1
- package/dist/admin/{de-BhhGss1l.js → de-Dss5POqk.js} +12 -1
- package/dist/admin/{de-BNPIGqhs.mjs → de-zgHCYTLH.mjs} +12 -1
- package/dist/admin/{en-CIZ5Ggod.js → en--JjAHbpP.js} +8 -1
- package/dist/admin/{en-cYzqbASF.mjs → en-BCKaVgBM.mjs} +103 -1
- package/dist/admin/{en-B9ApE1y1.js → en-CJ17Sp_e.js} +12 -1
- package/dist/admin/{en-BMWhILnj.js → en-CbGkcq0Q.js} +103 -1
- package/dist/admin/{en-DCPMqFIa.mjs → en-Cd6Jk-J0.mjs} +19 -1
- package/dist/admin/{en-CpehF0Kv.js → en-D69Fe9ZO.js} +19 -1
- package/dist/admin/{en-Dc9y-6n9.mjs → en-Dr58wBAo.mjs} +8 -1
- package/dist/admin/{en-gFLeK9Ng.mjs → en-Uhm7OouM.mjs} +12 -1
- package/dist/admin/entry-panel-events-0msyPrAD.js +18 -0
- package/dist/admin/entry-panel-events-XRuUoLZ9.mjs +19 -0
- package/dist/admin/{es-D2Kw6E4N.mjs → es-B2Hkkbw9.mjs} +8 -1
- package/dist/admin/{es-BmwBgEgz.mjs → es-BMkmfH88.mjs} +12 -1
- package/dist/admin/{es-Chs37IBR.mjs → es-Bz8d72Fa.mjs} +19 -1
- package/dist/admin/{es-CQPh8PXw.js → es-C8UotT8O.js} +103 -1
- package/dist/admin/{es-CawpzwyC.js → es-CcEDZpVQ.js} +19 -1
- package/dist/admin/{es-C0W31rl8.js → es-DJm3HFJt.js} +12 -1
- package/dist/admin/{es-C4IRHV5d.js → es-YvaTAtqY.js} +8 -1
- package/dist/admin/{es-DCamt1ek.mjs → es-pvPfNAld.mjs} +103 -1
- package/dist/admin/{fr-BOvvfEH7.mjs → fr-BvPjRiwr.mjs} +8 -1
- package/dist/admin/{fr-Dp5-XP29.mjs → fr-CKHZ0xxU.mjs} +19 -1
- package/dist/admin/{fr-iGeIfEcU.js → fr-CRM9VuAq.js} +12 -1
- package/dist/admin/{fr-CMWBNE5D.mjs → fr-CrIHmKYX.mjs} +12 -1
- package/dist/admin/{fr-COOsqexl.js → fr-Cx29jQ_g.js} +19 -1
- package/dist/admin/{fr-oW0t8bT5.mjs → fr-D4tL6Ag2.mjs} +103 -1
- package/dist/admin/{fr-Zkb8vfjN.js → fr-Di-U-rAH.js} +8 -1
- package/dist/admin/{fr-DpC44Ol8.js → fr-DrUYv2jh.js} +103 -1
- package/dist/admin/{index-BVjf1gVC.mjs → index-C4ksUkEm.mjs} +9183 -6353
- package/dist/admin/{index-64wc26Bl.js → index-C5D3VqLq.js} +9170 -6340
- package/dist/admin/{index-D_Fv8Non.mjs → index-CMYCZWOh.mjs} +1053 -190
- package/dist/admin/{index-D6Z7i8ba.js → index-DRyctF9s.js} +961 -98
- package/dist/admin/index.js +1 -1
- package/dist/admin/index.mjs +2 -2
- package/dist/admin/{math-vsK_06ZR.js → math-D6jmskGS.js} +1 -1
- package/dist/admin/{math-CIQ4Z_mY.mjs → math-DntdSWKX.mjs} +1 -1
- package/dist/admin/{pt-DALDvfBn.mjs → pt-B8x7v-Xw.mjs} +19 -1
- package/dist/admin/{pt-DXy7G1x7.js → pt-BYn2xx78.js} +19 -1
- package/dist/admin/{pt-Bo0Pm_Pt.js → pt-CojQcz-p.js} +103 -1
- package/dist/admin/{pt-uGpfRQLC.mjs → pt-CuoIihKx.mjs} +103 -1
- package/dist/admin/{pt-1IUyx6ae.js → pt-CzrN_3ui.js} +8 -1
- package/dist/admin/{pt-DFNgZ5_k.mjs → pt-DDlPJYtB.mjs} +12 -1
- package/dist/admin/{pt-BHmXk2d9.js → pt-DPVAycXJ.js} +12 -1
- package/dist/admin/{pt-etwsg3G4.mjs → pt-DdGagO99.mjs} +8 -1
- package/dist/admin/useT-Bpw__IXT.js +12 -0
- package/dist/admin/useT-Cb-R3kyA.mjs +13 -0
- package/dist/blocks/index.d.mts +124 -0
- package/dist/blocks/index.d.ts +124 -0
- package/dist/blocks/index.js +172 -3
- package/dist/blocks/index.mjs +172 -3
- package/dist/math/index.js +6 -2
- package/dist/math/index.mjs +6 -2
- package/dist/react/index.js +1376 -1067
- package/dist/react/index.mjs +1376 -1067
- package/dist/render/index.d.mts +22 -0
- package/dist/render/index.d.ts +22 -0
- package/dist/render/index.js +1376 -1067
- package/dist/render/index.mjs +1376 -1067
- package/dist/server/index.js +28894 -24197
- package/dist/server/index.mjs +28893 -24196
- package/dist/server/mcp-worker.js +11319 -0
- package/dist/vue/index.js +1376 -1067
- package/dist/vue/index.mjs +1376 -1067
- package/package.json +7 -7
- package/schema/magic-editor-x.schema.json +9 -1
- package/types/blocks.d.ts +124 -0
- package/types/index.d.ts +10 -1
- package/types/render.d.ts +22 -0
|
@@ -1,32 +1,105 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
const icons = require("@strapi/icons");
|
|
3
3
|
const jsxRuntime = require("react/jsx-runtime");
|
|
4
|
-
const createDOMPurify = require("dompurify");
|
|
5
4
|
const ReactNamespace = require("react");
|
|
5
|
+
const reactIntl = require("react-intl");
|
|
6
|
+
const designSystem = require("@strapi/design-system");
|
|
7
|
+
const admin = require("@strapi/strapi/admin");
|
|
8
|
+
const createDOMPurify = require("dompurify");
|
|
6
9
|
const client = require("react-dom/client");
|
|
7
10
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
8
11
|
const createDOMPurify__default = /* @__PURE__ */ _interopDefault(createDOMPurify);
|
|
9
|
-
const PLUGIN_ID = "magic-editor-x";
|
|
10
|
-
const PluginIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.Feather, { "aria-hidden": true });
|
|
11
12
|
const action = (uid) => [{ action: `plugin::magic-editor-x.${uid}`, subject: null }];
|
|
12
13
|
const PERMISSIONS = {
|
|
14
|
+
access: action("access"),
|
|
13
15
|
customBlocksManage: action("custom-blocks.manage"),
|
|
14
16
|
settingsRead: action("settings.read"),
|
|
15
17
|
settingsUpdate: action("settings.update"),
|
|
16
18
|
templatesManage: action("templates.manage"),
|
|
17
19
|
auditRead: action("audit.read")
|
|
18
20
|
};
|
|
21
|
+
const PLUGIN_ID = "magic-editor-x";
|
|
19
22
|
const getTranslation = (id) => `${PLUGIN_ID}.${id}`;
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
+
const CUSTOM_FIELD_UID = "plugin::magic-editor-x.richtext";
|
|
24
|
+
const HEARTBEAT_MS = 15e3;
|
|
25
|
+
const MAX_BACKOFF_MS = 12e4;
|
|
26
|
+
const IDLE_AFTER_MS = 6e4;
|
|
27
|
+
const MAX_DEPTH$1 = 8;
|
|
28
|
+
const hasEditorFields = (schema, components = {}, depth = 0) => {
|
|
29
|
+
if (!schema || !schema.attributes || depth > MAX_DEPTH$1) return false;
|
|
30
|
+
return Object.values(schema.attributes).some((attribute) => {
|
|
31
|
+
if (!attribute || typeof attribute !== "object") return false;
|
|
32
|
+
if (attribute.customField === CUSTOM_FIELD_UID) return true;
|
|
33
|
+
if (attribute.type === "component")
|
|
34
|
+
return hasEditorFields(components[attribute.component], components, depth + 1);
|
|
35
|
+
if (attribute.type === "dynamiczone" && Array.isArray(attribute.components))
|
|
36
|
+
return attribute.components.some((uid) => hasEditorFields(components[uid], components, depth + 1));
|
|
37
|
+
return false;
|
|
38
|
+
});
|
|
39
|
+
};
|
|
40
|
+
const nextDelay = (failures, status = null) => {
|
|
41
|
+
if (!failures) return HEARTBEAT_MS;
|
|
42
|
+
const delay = Math.min(MAX_BACKOFF_MS, HEARTBEAT_MS * 2 ** Math.min(failures, 4));
|
|
43
|
+
return status === 429 ? Math.max(6e4, delay) : delay;
|
|
44
|
+
};
|
|
45
|
+
const createTabId = (source = globalThis.crypto) => {
|
|
46
|
+
const bytes = source.getRandomValues(new Uint8Array(16));
|
|
47
|
+
let binary = "";
|
|
48
|
+
for (const byte of bytes) binary += String.fromCharCode(byte);
|
|
49
|
+
return btoa(binary).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
50
|
+
};
|
|
51
|
+
const entryPath = (target, extra = {}) => {
|
|
52
|
+
const value = target || {};
|
|
53
|
+
const uid = encodeURIComponent(String(value.uid || ""));
|
|
54
|
+
const path = value.kind === "singleType" ? `/content-manager/single-types/${uid}` : `/content-manager/collection-types/${uid}/${encodeURIComponent(String(value.documentId || ""))}`;
|
|
55
|
+
const params = new URLSearchParams();
|
|
56
|
+
if (value.locale) params.set("plugins[i18n][locale]", value.locale);
|
|
57
|
+
for (const [key, item] of Object.entries(extra)) params.set(key, item);
|
|
58
|
+
const query = params.toString();
|
|
59
|
+
return query ? `${path}?${query}` : path;
|
|
60
|
+
};
|
|
61
|
+
const fieldsWith = (fields, count) => Array.isArray(fields) ? fields.filter((field2) => count(field2) > 0) : [];
|
|
62
|
+
const fieldProblems = (field2) => (field2 && field2.issues ? field2.issues.errors + field2.issues.warnings : 0) + (field2 && field2.brokenLinks && field2.brokenLinks.draft ? field2.brokenLinks.draft : 0);
|
|
63
|
+
const Content = ReactNamespace.lazy(() => Promise.resolve().then(() => require("./Content-V5MRBsI3.js")));
|
|
64
|
+
const EntryPanel = ({ model, documentId, document: document2 }) => {
|
|
65
|
+
const { formatMessage } = reactIntl.useIntl();
|
|
66
|
+
const context = admin.unstable_useContentManagerContext();
|
|
67
|
+
const [{ query }] = admin.useQueryParams();
|
|
68
|
+
const { isLoading, allowedActions } = admin.useRBAC(PERMISSIONS.access);
|
|
69
|
+
const locale = query && query.plugins && query.plugins.i18n && typeof query.plugins.i18n.locale === "string" ? query.plugins.i18n.locale : null;
|
|
70
|
+
const editorType = hasEditorFields(context && context.contentType, context && context.components || {});
|
|
71
|
+
if (!documentId || !model || !editorType || isLoading || !allowedActions.canAccess) return null;
|
|
72
|
+
const loading = formatMessage({ id: getTranslation("entryPanel.loading"), defaultMessage: "Loading" });
|
|
73
|
+
return {
|
|
74
|
+
title: formatMessage({ id: getTranslation("entryPanel.title"), defaultMessage: "Magic Editor X" }),
|
|
75
|
+
content: /* @__PURE__ */ jsxRuntime.jsx(
|
|
76
|
+
ReactNamespace.Suspense,
|
|
77
|
+
{
|
|
78
|
+
fallback: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: loading }),
|
|
79
|
+
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
80
|
+
Content,
|
|
81
|
+
{
|
|
82
|
+
uid: model,
|
|
83
|
+
documentId,
|
|
84
|
+
locale,
|
|
85
|
+
version: String(document2 && document2.updatedAt || "")
|
|
86
|
+
}
|
|
87
|
+
)
|
|
88
|
+
}
|
|
89
|
+
)
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
const PluginIcon = () => /* @__PURE__ */ jsxRuntime.jsx(icons.Feather, { "aria-hidden": true });
|
|
93
|
+
const registry$1 = /* @__PURE__ */ new Map();
|
|
94
|
+
const activeBlock = (type) => typeof type === "string" && registry$1.has(type) ? registry$1.get(type) : null;
|
|
95
|
+
const activeBlocks = () => [...registry$1.values()];
|
|
23
96
|
const activeBlockIgnoringCase = (name) => {
|
|
24
97
|
const lower = String(name).toLowerCase();
|
|
25
|
-
for (const definition of registry.values()) if (definition.name.toLowerCase() === lower) return definition;
|
|
98
|
+
for (const definition of registry$1.values()) if (definition.name.toLowerCase() === lower) return definition;
|
|
26
99
|
return null;
|
|
27
100
|
};
|
|
28
101
|
const setActiveBlock = (compiled2) => {
|
|
29
|
-
registry.set(compiled2.name, compiled2);
|
|
102
|
+
registry$1.set(compiled2.name, compiled2);
|
|
30
103
|
};
|
|
31
104
|
const isPlainObject$1 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
32
105
|
const BUILT_IN_MARKER = "_mex";
|
|
@@ -80,6 +153,10 @@ const createFieldKey = (fill) => {
|
|
|
80
153
|
};
|
|
81
154
|
const isPositionalFieldPath = (path) => typeof path === "string" && path.split(".").some((part) => /^\d+$/.test(part));
|
|
82
155
|
const basePathOf = (path) => String(path).split(".").filter((part) => !/^\d+$/.test(part)).join(".");
|
|
156
|
+
const fieldIdentity = (path, fieldKey, positional = isPositionalFieldPath(path)) => {
|
|
157
|
+
if (!positional) return String(path);
|
|
158
|
+
return isValidFieldKey(fieldKey) ? `${basePathOf(path)}#${fieldKey}` : null;
|
|
159
|
+
};
|
|
83
160
|
const EDITOR_DATA_LIMITS = Object.freeze({
|
|
84
161
|
maxBlocks: 5e3,
|
|
85
162
|
maxBytes: 5 * 1024 * 1024,
|
|
@@ -272,7 +349,7 @@ const computeStats = (data) => {
|
|
|
272
349
|
};
|
|
273
350
|
const TABLE_LIMITS = Object.freeze({ rows: 500, cols: 100, merges: 1e3, caption: 4e3 });
|
|
274
351
|
const TABLE_ALIGNS = Object.freeze(["left", "center", "right"]);
|
|
275
|
-
const isObject$
|
|
352
|
+
const isObject$3 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
276
353
|
const tableWidth = (content) => Array.isArray(content) ? content.reduce((width, row) => Math.max(width, Array.isArray(row) ? row.length : 0), 0) : 0;
|
|
277
354
|
const cleanTableAlign = (value, cols) => {
|
|
278
355
|
if (!Array.isArray(value) || cols <= 0) return null;
|
|
@@ -285,7 +362,7 @@ const normalizeMerges = (merges, rows, cols, options = {}) => {
|
|
|
285
362
|
if (!Array.isArray(merges) || rows <= 0 || cols <= 0) return [];
|
|
286
363
|
const out = [];
|
|
287
364
|
for (const merge of merges.slice(0, TABLE_LIMITS.merges)) {
|
|
288
|
-
if (!isObject$
|
|
365
|
+
if (!isObject$3(merge)) continue;
|
|
289
366
|
const { row, col, rowspan, colspan } = merge;
|
|
290
367
|
if (![row, col, rowspan, colspan].every(Number.isInteger)) continue;
|
|
291
368
|
if (row < 0 || col < 0 || rowspan < 1 || colspan < 1 || rowspan * colspan < 2) continue;
|
|
@@ -358,7 +435,7 @@ const cleanTableExtras = (out, d, inline) => {
|
|
|
358
435
|
return out;
|
|
359
436
|
};
|
|
360
437
|
const toTableModel = (data, defaults = {}) => {
|
|
361
|
-
const d = isObject$
|
|
438
|
+
const d = isObject$3(data) ? data : {};
|
|
362
439
|
let content = Array.isArray(d.content) ? d.content.slice(0, TABLE_LIMITS.rows).map(
|
|
363
440
|
(row) => Array.isArray(row) ? row.slice(0, TABLE_LIMITS.cols).map((cell) => typeof cell === "string" ? cell : "") : []
|
|
364
441
|
) : [];
|
|
@@ -640,11 +717,15 @@ const FOOTNOTE_ID = /^[A-Za-z0-9_-]{1,64}$/;
|
|
|
640
717
|
const MAX_MATH_TEX = 1e4;
|
|
641
718
|
const MAX_INLINE_TEX = 2e3;
|
|
642
719
|
const MAX_FOOTNOTE_NOTE = 4e3;
|
|
720
|
+
const INLINE_FORMAT_ATTRIBUTES = Object.freeze({
|
|
721
|
+
span: ["data-mex-color", "data-mex-annotation", "data-mex-a-*"],
|
|
722
|
+
mark: ["data-mex-highlight"]
|
|
723
|
+
});
|
|
643
724
|
const INLINE_ATTRIBUTES = Object.freeze({
|
|
644
725
|
a: ["href", "target", "rel", "title", ...INTERNAL_LINK_ATTRIBUTES],
|
|
645
|
-
span: ["class", "data-tooltip", MATH_ATTRIBUTE],
|
|
726
|
+
span: ["class", "data-tooltip", MATH_ATTRIBUTE, ...INLINE_FORMAT_ATTRIBUTES.span],
|
|
646
727
|
sup: [...FOOTNOTE_ATTRIBUTES],
|
|
647
|
-
mark: ["class"],
|
|
728
|
+
mark: ["class", ...INLINE_FORMAT_ATTRIBUTES.mark],
|
|
648
729
|
u: ["class"],
|
|
649
730
|
s: ["class"],
|
|
650
731
|
code: ["class"]
|
|
@@ -961,6 +1042,9 @@ const BLOCK_POLICIES = {
|
|
|
961
1042
|
if (typeof file.extension === "string") cleanFile.extension = plain(file.extension, 16);
|
|
962
1043
|
if (Number.isFinite(file.size)) cleanFile.size = file.size;
|
|
963
1044
|
if (typeof file.title === "string") cleanFile.title = plain(file.title, 255);
|
|
1045
|
+
if (file.id !== void 0 && (Number.isInteger(file.id) || typeof file.id === "string"))
|
|
1046
|
+
cleanFile.id = file.id;
|
|
1047
|
+
if (typeof file.documentId === "string") cleanFile.documentId = plain(file.documentId, 64);
|
|
964
1048
|
return { file: cleanFile, title: plain(d.title, 255) };
|
|
965
1049
|
},
|
|
966
1050
|
embed: (d, inline) => ({
|
|
@@ -1165,27 +1249,27 @@ class BlockDefinitionError extends Error {
|
|
|
1165
1249
|
this.code = code;
|
|
1166
1250
|
}
|
|
1167
1251
|
}
|
|
1168
|
-
const isObject$
|
|
1169
|
-
const fail = (where, message) => {
|
|
1252
|
+
const isObject$2 = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
1253
|
+
const fail$1 = (where, message) => {
|
|
1170
1254
|
throw new BlockDefinitionError(`Magic Editor X block ${where}: ${message}`);
|
|
1171
1255
|
};
|
|
1172
1256
|
const boundedInt = (value, min, max, fallback, where, key) => {
|
|
1173
1257
|
if (value === void 0) return fallback;
|
|
1174
1258
|
if (!Number.isInteger(value) || value < min || value > max)
|
|
1175
|
-
fail(where, `"${key}" must be an integer from ${min} to ${max}`);
|
|
1259
|
+
fail$1(where, `"${key}" must be an integer from ${min} to ${max}`);
|
|
1176
1260
|
return value;
|
|
1177
1261
|
};
|
|
1178
1262
|
const normalizeField = (input2, where, depth) => {
|
|
1179
|
-
if (!isObject$
|
|
1263
|
+
if (!isObject$2(input2)) fail$1(where, 'a field must be an object with a "type"');
|
|
1180
1264
|
const type = input2.type;
|
|
1181
|
-
if (!BLOCK_FIELD_TYPES.includes(type)) fail(where, `unknown field type ${JSON.stringify(type)}`);
|
|
1265
|
+
if (!BLOCK_FIELD_TYPES.includes(type)) fail$1(where, `unknown field type ${JSON.stringify(type)}`);
|
|
1182
1266
|
for (const key of Object.keys(input2))
|
|
1183
1267
|
if (key !== "type" && key !== "label" && !FIELD_KEYS[type].includes(key))
|
|
1184
|
-
fail(where, `unknown option "${key}" for a ${type} field`);
|
|
1268
|
+
fail$1(where, `unknown option "${key}" for a ${type} field`);
|
|
1185
1269
|
const out = { type };
|
|
1186
1270
|
if (input2.label !== void 0) {
|
|
1187
1271
|
if (typeof input2.label !== "string" || input2.label.length > 100)
|
|
1188
|
-
fail(where, '"label" must be a string of at most 100 characters');
|
|
1272
|
+
fail$1(where, '"label" must be a string of at most 100 characters');
|
|
1189
1273
|
out.label = input2.label;
|
|
1190
1274
|
}
|
|
1191
1275
|
switch (type) {
|
|
@@ -1200,11 +1284,11 @@ const normalizeField = (input2, where, depth) => {
|
|
|
1200
1284
|
"max"
|
|
1201
1285
|
);
|
|
1202
1286
|
if (input2.default !== void 0 && typeof input2.default !== "string")
|
|
1203
|
-
fail(where, '"default" must be a string');
|
|
1287
|
+
fail$1(where, '"default" must be a string');
|
|
1204
1288
|
out.default = (input2.default || "").slice(0, out.max);
|
|
1205
1289
|
if (type === "text") {
|
|
1206
1290
|
if (input2.multiline !== void 0 && typeof input2.multiline !== "boolean")
|
|
1207
|
-
fail(where, '"multiline" must be a boolean');
|
|
1291
|
+
fail$1(where, '"multiline" must be a boolean');
|
|
1208
1292
|
out.multiline = input2.multiline === true;
|
|
1209
1293
|
}
|
|
1210
1294
|
break;
|
|
@@ -1212,9 +1296,9 @@ const normalizeField = (input2, where, depth) => {
|
|
|
1212
1296
|
case "url": {
|
|
1213
1297
|
const schemes = input2.schemes === void 0 ? ["http", "https"] : input2.schemes;
|
|
1214
1298
|
if (!Array.isArray(schemes) || !schemes.length || schemes.some((scheme) => !LINK_SCHEMES.includes(scheme)))
|
|
1215
|
-
fail(where, `"schemes" must be a non-empty list of ${LINK_SCHEMES.join(", ")}`);
|
|
1299
|
+
fail$1(where, `"schemes" must be a non-empty list of ${LINK_SCHEMES.join(", ")}`);
|
|
1216
1300
|
if (input2.relative !== void 0 && typeof input2.relative !== "boolean")
|
|
1217
|
-
fail(where, '"relative" must be a boolean');
|
|
1301
|
+
fail$1(where, '"relative" must be a boolean');
|
|
1218
1302
|
out.schemes = Object.freeze([...new Set(schemes)]);
|
|
1219
1303
|
out.relative = input2.relative !== false;
|
|
1220
1304
|
break;
|
|
@@ -1222,59 +1306,59 @@ const normalizeField = (input2, where, depth) => {
|
|
|
1222
1306
|
case "enum": {
|
|
1223
1307
|
const values = input2.values;
|
|
1224
1308
|
if (!Array.isArray(values) || values.length < 1 || values.length > BLOCK_LIMITS.maxEnumValues || values.some((value) => typeof value !== "string" || value.length < 1 || value.length > 100) || new Set(values).size !== values.length)
|
|
1225
|
-
fail(
|
|
1309
|
+
fail$1(
|
|
1226
1310
|
where,
|
|
1227
1311
|
`"values" must be 1 to ${BLOCK_LIMITS.maxEnumValues} distinct strings (1-100 characters)`
|
|
1228
1312
|
);
|
|
1229
1313
|
out.values = Object.freeze([...values]);
|
|
1230
1314
|
if (input2.default !== void 0 && !values.includes(input2.default))
|
|
1231
|
-
fail(where, '"default" must be one of "values"');
|
|
1315
|
+
fail$1(where, '"default" must be one of "values"');
|
|
1232
1316
|
out.default = input2.default === void 0 ? values[0] : input2.default;
|
|
1233
1317
|
break;
|
|
1234
1318
|
}
|
|
1235
1319
|
case "number": {
|
|
1236
1320
|
for (const key of ["min", "max", "default"])
|
|
1237
1321
|
if (input2[key] !== void 0 && (typeof input2[key] !== "number" || !Number.isFinite(input2[key])))
|
|
1238
|
-
fail(where, `"${key}" must be a finite number`);
|
|
1322
|
+
fail$1(where, `"${key}" must be a finite number`);
|
|
1239
1323
|
if (input2.integer !== void 0 && typeof input2.integer !== "boolean")
|
|
1240
|
-
fail(where, '"integer" must be a boolean');
|
|
1324
|
+
fail$1(where, '"integer" must be a boolean');
|
|
1241
1325
|
out.integer = input2.integer === true;
|
|
1242
1326
|
out.min = input2.min === void 0 ? -Number.MAX_SAFE_INTEGER : input2.min;
|
|
1243
1327
|
out.max = input2.max === void 0 ? Number.MAX_SAFE_INTEGER : input2.max;
|
|
1244
|
-
if (out.min > out.max) fail(where, '"min" must not be greater than "max"');
|
|
1328
|
+
if (out.min > out.max) fail$1(where, '"min" must not be greater than "max"');
|
|
1245
1329
|
if (input2.default !== void 0) {
|
|
1246
1330
|
if (input2.default < out.min || input2.default > out.max || out.integer && !Number.isInteger(input2.default))
|
|
1247
|
-
fail(where, '"default" must be a valid value of the field');
|
|
1331
|
+
fail$1(where, '"default" must be a valid value of the field');
|
|
1248
1332
|
out.default = input2.default;
|
|
1249
1333
|
}
|
|
1250
1334
|
break;
|
|
1251
1335
|
}
|
|
1252
1336
|
case "boolean":
|
|
1253
1337
|
if (input2.default !== void 0 && typeof input2.default !== "boolean")
|
|
1254
|
-
fail(where, '"default" must be a boolean');
|
|
1338
|
+
fail$1(where, '"default" must be a boolean');
|
|
1255
1339
|
out.default = input2.default === true;
|
|
1256
1340
|
break;
|
|
1257
1341
|
case "array":
|
|
1258
|
-
if (depth >= BLOCK_LIMITS.maxDepth) fail(where, `fields nest at most ${BLOCK_LIMITS.maxDepth} levels`);
|
|
1342
|
+
if (depth >= BLOCK_LIMITS.maxDepth) fail$1(where, `fields nest at most ${BLOCK_LIMITS.maxDepth} levels`);
|
|
1259
1343
|
out.max = boundedInt(input2.max, 1, BLOCK_LIMITS.maxItems, BLOCK_LIMITS.defaultItems, where, "max");
|
|
1260
1344
|
out.items = normalizeField(input2.items, `${where}[]`, depth + 1);
|
|
1261
1345
|
break;
|
|
1262
1346
|
case "object":
|
|
1263
|
-
if (depth >= BLOCK_LIMITS.maxDepth) fail(where, `fields nest at most ${BLOCK_LIMITS.maxDepth} levels`);
|
|
1347
|
+
if (depth >= BLOCK_LIMITS.maxDepth) fail$1(where, `fields nest at most ${BLOCK_LIMITS.maxDepth} levels`);
|
|
1264
1348
|
out.fields = normalizeFields(input2.fields, where, depth + 1);
|
|
1265
1349
|
break;
|
|
1266
1350
|
}
|
|
1267
1351
|
return Object.freeze(out);
|
|
1268
1352
|
};
|
|
1269
1353
|
const normalizeFields = (input2, where, depth) => {
|
|
1270
|
-
if (!isObject$
|
|
1354
|
+
if (!isObject$2(input2)) fail$1(where, '"fields" must be an object of field descriptors');
|
|
1271
1355
|
const keys = Object.keys(input2);
|
|
1272
1356
|
if (keys.length < 1 || keys.length > BLOCK_LIMITS.maxFields)
|
|
1273
|
-
fail(where, `an object needs 1 to ${BLOCK_LIMITS.maxFields} fields`);
|
|
1357
|
+
fail$1(where, `an object needs 1 to ${BLOCK_LIMITS.maxFields} fields`);
|
|
1274
1358
|
const out = /* @__PURE__ */ Object.create(null);
|
|
1275
1359
|
for (const key of keys) {
|
|
1276
1360
|
if (!KEY_PATTERN.test(key) || FORBIDDEN_KEYS.has(key))
|
|
1277
|
-
fail(where, `field name ${JSON.stringify(key)} must match ${KEY_PATTERN}`);
|
|
1361
|
+
fail$1(where, `field name ${JSON.stringify(key)} must match ${KEY_PATTERN}`);
|
|
1278
1362
|
out[key] = normalizeField(input2[key], `${where}.${key}`, depth);
|
|
1279
1363
|
}
|
|
1280
1364
|
return Object.freeze(out);
|
|
@@ -1286,11 +1370,11 @@ const blockNameProblem = (name) => {
|
|
|
1286
1370
|
return null;
|
|
1287
1371
|
};
|
|
1288
1372
|
const defineBlock = (definition) => {
|
|
1289
|
-
if (!isObject$
|
|
1373
|
+
if (!isObject$2(definition))
|
|
1290
1374
|
throw new BlockDefinitionError("Magic Editor X block: the definition must be an object");
|
|
1291
1375
|
const label = typeof definition.name === "string" ? `"${definition.name.slice(0, 50)}"` : "(no name)";
|
|
1292
1376
|
for (const key of Object.keys(definition))
|
|
1293
|
-
if (!DEFINITION_KEYS.has(key)) fail(label, `unknown key "${key}"`);
|
|
1377
|
+
if (!DEFINITION_KEYS.has(key)) fail$1(label, `unknown key "${key}"`);
|
|
1294
1378
|
const problem = blockNameProblem(definition.name);
|
|
1295
1379
|
if (problem)
|
|
1296
1380
|
throw new BlockDefinitionError(
|
|
@@ -1307,18 +1391,18 @@ const defineBlock = (definition) => {
|
|
|
1307
1391
|
]) {
|
|
1308
1392
|
if (definition[key] === void 0) continue;
|
|
1309
1393
|
if (typeof definition[key] !== "string" || definition[key].length > max)
|
|
1310
|
-
fail(label, `"${key}" must be a string of at most ${max} characters`);
|
|
1394
|
+
fail$1(label, `"${key}" must be a string of at most ${max} characters`);
|
|
1311
1395
|
out[key] = definition[key];
|
|
1312
1396
|
}
|
|
1313
1397
|
out.schema = normalizeFields(definition.schema, `${label} schema`, 0);
|
|
1314
1398
|
for (const key of ["sanitize", "text", "markdown", "render"]) {
|
|
1315
1399
|
if (definition[key] === void 0) continue;
|
|
1316
|
-
if (typeof definition[key] !== "function") fail(label, `"${key}" must be a function`);
|
|
1400
|
+
if (typeof definition[key] !== "function") fail$1(label, `"${key}" must be a function`);
|
|
1317
1401
|
out[key] = definition[key];
|
|
1318
1402
|
}
|
|
1319
1403
|
const presets = definition.presets === void 0 ? [] : definition.presets;
|
|
1320
1404
|
if (!Array.isArray(presets) || presets.some((preset) => !BLOCK_PRESETS.includes(preset)))
|
|
1321
|
-
fail(label, `"presets" must list some of ${BLOCK_PRESETS.join(", ")}`);
|
|
1405
|
+
fail$1(label, `"presets" must list some of ${BLOCK_PRESETS.join(", ")}`);
|
|
1322
1406
|
out.presets = Object.freeze([...new Set(presets)]);
|
|
1323
1407
|
return Object.freeze(out);
|
|
1324
1408
|
};
|
|
@@ -1352,7 +1436,7 @@ const cleanValue = (field2, value, inline, budget) => {
|
|
|
1352
1436
|
return out;
|
|
1353
1437
|
}
|
|
1354
1438
|
case "object":
|
|
1355
|
-
return cleanObject(field2.fields, isObject$
|
|
1439
|
+
return cleanObject(field2.fields, isObject$2(value) ? value : {}, inline, budget);
|
|
1356
1440
|
default:
|
|
1357
1441
|
return void 0;
|
|
1358
1442
|
}
|
|
@@ -1371,7 +1455,7 @@ const matchesType = (field2, item) => {
|
|
|
1371
1455
|
case "array":
|
|
1372
1456
|
return Array.isArray(item);
|
|
1373
1457
|
default:
|
|
1374
|
-
return isObject$
|
|
1458
|
+
return isObject$2(item);
|
|
1375
1459
|
}
|
|
1376
1460
|
};
|
|
1377
1461
|
const cleanObject = (fields, value, inline, budget) => {
|
|
@@ -1390,13 +1474,13 @@ const eachLeaf = (fields, data, visit) => {
|
|
|
1390
1474
|
if (!Array.isArray(value)) return;
|
|
1391
1475
|
value.slice(0, field2.max).forEach((item, index2) => walk(field2.items, item, [...path, index2], depth + 1));
|
|
1392
1476
|
} else if (field2.type === "object") {
|
|
1393
|
-
if (!isObject$
|
|
1477
|
+
if (!isObject$2(value)) return;
|
|
1394
1478
|
for (const key of Object.keys(field2.fields))
|
|
1395
1479
|
if (Object.prototype.hasOwnProperty.call(value, key))
|
|
1396
1480
|
walk(field2.fields[key], value[key], [...path, key], depth + 1);
|
|
1397
1481
|
} else visit(field2, value, path);
|
|
1398
1482
|
};
|
|
1399
|
-
if (!isObject$
|
|
1483
|
+
if (!isObject$2(data)) return;
|
|
1400
1484
|
for (const key of Object.keys(fields))
|
|
1401
1485
|
if (Object.prototype.hasOwnProperty.call(data, key)) walk(fields[key], data[key], [key], 0);
|
|
1402
1486
|
};
|
|
@@ -1422,7 +1506,7 @@ const compileBlock = (definition) => {
|
|
|
1422
1506
|
return compiled.get(definition);
|
|
1423
1507
|
const def = defineBlock(definition && typeof definition === "object" ? { ...definition } : definition);
|
|
1424
1508
|
const schema = def.schema;
|
|
1425
|
-
const run = (data, inline) => cleanObject(schema, isObject$
|
|
1509
|
+
const run = (data, inline) => cleanObject(schema, isObject$2(data) ? data : {}, inline, { left: BLOCK_LIMITS.maxValues });
|
|
1426
1510
|
const result = Object.freeze({
|
|
1427
1511
|
...def,
|
|
1428
1512
|
/**
|
|
@@ -1443,7 +1527,7 @@ const compileBlock = (definition) => {
|
|
|
1443
1527
|
} catch {
|
|
1444
1528
|
return first;
|
|
1445
1529
|
}
|
|
1446
|
-
return isObject$
|
|
1530
|
+
return isObject$2(next) ? run(next, inline) : first;
|
|
1447
1531
|
},
|
|
1448
1532
|
/**
|
|
1449
1533
|
* Text fields of the data in schema order: `{ path, kind, value }`
|
|
@@ -1491,7 +1575,7 @@ const compileBlock = (definition) => {
|
|
|
1491
1575
|
};
|
|
1492
1576
|
const copyData = (value) => {
|
|
1493
1577
|
if (Array.isArray(value)) return value.map(copyData);
|
|
1494
|
-
if (isObject$
|
|
1578
|
+
if (isObject$2(value)) {
|
|
1495
1579
|
const out = {};
|
|
1496
1580
|
for (const [key, child] of Object.entries(value)) out[key] = copyData(child);
|
|
1497
1581
|
return out;
|
|
@@ -1529,10 +1613,10 @@ const LINK_SANITIZE = Object.freeze({
|
|
|
1529
1613
|
rel: true,
|
|
1530
1614
|
...Object.fromEntries(INTERNAL_LINK_ATTRIBUTES.map((name) => [name, true]))
|
|
1531
1615
|
});
|
|
1532
|
-
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1616
|
+
const isObject$1 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
1533
1617
|
const localized = (value, locale) => {
|
|
1534
1618
|
if (typeof value === "string") return value;
|
|
1535
|
-
if (!isObject(value)) return "";
|
|
1619
|
+
if (!isObject$1(value)) return "";
|
|
1536
1620
|
const lang = String(locale || "en");
|
|
1537
1621
|
const pick = value[lang] ?? value[lang.split("-")[0]] ?? value.en ?? Object.values(value)[0];
|
|
1538
1622
|
return typeof pick === "string" ? pick : "";
|
|
@@ -1563,7 +1647,7 @@ const sanitizeRulesFor = (fields) => {
|
|
|
1563
1647
|
for (const [key, field2] of Object.entries(fields)) out[key] = rule(field2);
|
|
1564
1648
|
return out;
|
|
1565
1649
|
};
|
|
1566
|
-
const mergeCodeBlocks = (server,
|
|
1650
|
+
const mergeCodeBlocks = (server, admin2, locale) => {
|
|
1567
1651
|
const rows = /* @__PURE__ */ new Map();
|
|
1568
1652
|
for (const block of Array.isArray(server) ? server : []) {
|
|
1569
1653
|
rows.set(block.name, {
|
|
@@ -1576,7 +1660,7 @@ const mergeCodeBlocks = (server, admin, locale) => {
|
|
|
1576
1660
|
inAdmin: false
|
|
1577
1661
|
});
|
|
1578
1662
|
}
|
|
1579
|
-
for (const entry of
|
|
1663
|
+
for (const entry of admin2) {
|
|
1580
1664
|
const { definition } = entry;
|
|
1581
1665
|
const current = rows.get(definition.name);
|
|
1582
1666
|
const title = localized(entry.title, locale) || definition.title || definition.name;
|
|
@@ -1674,6 +1758,290 @@ const nodesTextContent = (nodes) => {
|
|
|
1674
1758
|
}
|
|
1675
1759
|
return out;
|
|
1676
1760
|
};
|
|
1761
|
+
const TOKEN_PATTERN = /^[a-z][a-z0-9-]{0,31}$/;
|
|
1762
|
+
const COLOR_ATTRIBUTE = "data-mex-color";
|
|
1763
|
+
const HIGHLIGHT_ATTRIBUTE = "data-mex-highlight";
|
|
1764
|
+
const PALETTE_LIMITS = Object.freeze({ tokens: 24, label: 60, locales: 20 });
|
|
1765
|
+
const HEX = /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/;
|
|
1766
|
+
const LOCALE = /^[A-Za-z]{2,8}(?:-[A-Za-z0-9]{1,8}){0,3}$/;
|
|
1767
|
+
const DEFAULT_SURFACE = Object.freeze({
|
|
1768
|
+
background: Object.freeze({ light: "#ffffff", dark: "#121212" }),
|
|
1769
|
+
text: Object.freeze({ light: "#1f1f1f", dark: "#f2f2f2" })
|
|
1770
|
+
});
|
|
1771
|
+
const isHexColor = (value) => typeof value === "string" && HEX.test(value);
|
|
1772
|
+
const longHex = (value) => {
|
|
1773
|
+
const hex = value.slice(1).toLowerCase();
|
|
1774
|
+
return `#${hex.length === 3 ? [...hex].map((c) => c + c).join("") : hex}`;
|
|
1775
|
+
};
|
|
1776
|
+
const isToken = (value) => typeof value === "string" && TOKEN_PATTERN.test(value);
|
|
1777
|
+
const cleanLabel = (value) => {
|
|
1778
|
+
if (typeof value === "string") return value.trim().slice(0, PALETTE_LIMITS.label) || null;
|
|
1779
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return null;
|
|
1780
|
+
const out = {};
|
|
1781
|
+
for (const [locale, text] of Object.entries(value).slice(0, PALETTE_LIMITS.locales))
|
|
1782
|
+
if (LOCALE.test(locale) && typeof text === "string" && text.trim())
|
|
1783
|
+
out[locale] = text.trim().slice(0, PALETTE_LIMITS.label);
|
|
1784
|
+
return Object.keys(out).length ? out : null;
|
|
1785
|
+
};
|
|
1786
|
+
const cleanTokens = (list) => {
|
|
1787
|
+
const out = [];
|
|
1788
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1789
|
+
for (const item of Array.isArray(list) ? list : []) {
|
|
1790
|
+
if (out.length >= PALETTE_LIMITS.tokens) break;
|
|
1791
|
+
if (!item || typeof item !== "object" || !isToken(item.name) || seen.has(item.name)) continue;
|
|
1792
|
+
if (!isHexColor(item.light)) continue;
|
|
1793
|
+
seen.add(item.name);
|
|
1794
|
+
out.push({
|
|
1795
|
+
name: item.name,
|
|
1796
|
+
label: cleanLabel(item.label),
|
|
1797
|
+
light: longHex(item.light),
|
|
1798
|
+
dark: longHex(isHexColor(item.dark) ? item.dark : item.light)
|
|
1799
|
+
});
|
|
1800
|
+
}
|
|
1801
|
+
return out;
|
|
1802
|
+
};
|
|
1803
|
+
const cleanPair = (value, fallback) => {
|
|
1804
|
+
const source = value && typeof value === "object" ? value : {};
|
|
1805
|
+
return {
|
|
1806
|
+
light: isHexColor(source.light) ? longHex(source.light) : fallback.light,
|
|
1807
|
+
dark: isHexColor(source.dark) ? longHex(source.dark) : fallback.dark
|
|
1808
|
+
};
|
|
1809
|
+
};
|
|
1810
|
+
const normalizePalette = (input2) => {
|
|
1811
|
+
const source = input2 && typeof input2 === "object" ? input2 : {};
|
|
1812
|
+
return {
|
|
1813
|
+
background: cleanPair(source.background, DEFAULT_SURFACE.background),
|
|
1814
|
+
text: cleanPair(source.text, DEFAULT_SURFACE.text),
|
|
1815
|
+
colors: cleanTokens(source.colors),
|
|
1816
|
+
highlights: cleanTokens(source.highlights)
|
|
1817
|
+
};
|
|
1818
|
+
};
|
|
1819
|
+
const hasPalette = (palette) => Boolean(
|
|
1820
|
+
palette && (palette.colors && palette.colors.length || palette.highlights && palette.highlights.length)
|
|
1821
|
+
);
|
|
1822
|
+
const tokenLabel = (token, locale) => {
|
|
1823
|
+
const { label } = token;
|
|
1824
|
+
if (typeof label === "string") return label;
|
|
1825
|
+
if (label && typeof label === "object") {
|
|
1826
|
+
const language = typeof locale === "string" ? locale.split("-")[0] : "";
|
|
1827
|
+
return label[locale] || label[language] || label.en || Object.values(label)[0] || token.name;
|
|
1828
|
+
}
|
|
1829
|
+
return token.name;
|
|
1830
|
+
};
|
|
1831
|
+
const colorClass = (token) => `mex-color-${token}`;
|
|
1832
|
+
const highlightClass = (token) => `mex-highlight-${token}`;
|
|
1833
|
+
const paletteCss = (palette, options = {}) => {
|
|
1834
|
+
const selector = typeof options.selector === "function" ? options.selector : (kind, token) => `.${kind === "color" ? colorClass(token) : highlightClass(token)}`;
|
|
1835
|
+
const mode = options.dark || "media";
|
|
1836
|
+
const rules = (variant) => [
|
|
1837
|
+
...palette.colors.map((token) => `${selector("color", token.name)} { color: ${token[variant]}; }`),
|
|
1838
|
+
...palette.highlights.map(
|
|
1839
|
+
(token) => `${selector("highlight", token.name)} { background-color: ${token[variant]}; color: inherit; }`
|
|
1840
|
+
)
|
|
1841
|
+
];
|
|
1842
|
+
if (mode === "only") return rules("dark").join("\n");
|
|
1843
|
+
const light = rules("light").join("\n");
|
|
1844
|
+
if (mode === "none" || !light) return light;
|
|
1845
|
+
return `${light}
|
|
1846
|
+
@media (prefers-color-scheme: dark) {
|
|
1847
|
+
${rules("dark").map((rule) => ` ${rule}`).join("\n")}
|
|
1848
|
+
}`;
|
|
1849
|
+
};
|
|
1850
|
+
const ANNOTATION_ATTRIBUTE = "data-mex-annotation";
|
|
1851
|
+
const ANNOTATION_VALUE_PREFIX = "data-mex-a-";
|
|
1852
|
+
const ANNOTATION_NAME = /^[a-z][a-z0-9-]{1,39}$/;
|
|
1853
|
+
const ANNOTATION_KEY = /^[a-z][a-z0-9]{0,23}$/;
|
|
1854
|
+
const ANNOTATION_FIELD_TYPES = Object.freeze(["text", "enum", "url"]);
|
|
1855
|
+
const ANNOTATION_LIMITS = Object.freeze({
|
|
1856
|
+
attributes: 8,
|
|
1857
|
+
text: 1e3,
|
|
1858
|
+
textDefault: 200,
|
|
1859
|
+
values: 50,
|
|
1860
|
+
registered: 50,
|
|
1861
|
+
label: 100,
|
|
1862
|
+
resolveItems: 200
|
|
1863
|
+
});
|
|
1864
|
+
const ANNOTATION_PRESETS = Object.freeze(["full", "article", "basic", "minimal"]);
|
|
1865
|
+
const ANNOTATION_RENDER_TAGS = Object.freeze([
|
|
1866
|
+
"abbr",
|
|
1867
|
+
"dfn",
|
|
1868
|
+
"span",
|
|
1869
|
+
"a",
|
|
1870
|
+
"mark",
|
|
1871
|
+
"cite",
|
|
1872
|
+
"q",
|
|
1873
|
+
"small",
|
|
1874
|
+
"em",
|
|
1875
|
+
"strong",
|
|
1876
|
+
"b",
|
|
1877
|
+
"i",
|
|
1878
|
+
"u",
|
|
1879
|
+
"s",
|
|
1880
|
+
"time",
|
|
1881
|
+
"data",
|
|
1882
|
+
"bdi",
|
|
1883
|
+
"kbd",
|
|
1884
|
+
"var",
|
|
1885
|
+
"ins",
|
|
1886
|
+
"del"
|
|
1887
|
+
]);
|
|
1888
|
+
const ANNOTATION_SHORTCUTS = Object.freeze(["CMD+SHIFT+0", "CMD+SHIFT+1", "CMD+SHIFT+8"]);
|
|
1889
|
+
const ABBREVIATION = "abbreviation";
|
|
1890
|
+
const isObject = (value) => value !== null && typeof value === "object" && !Array.isArray(value) && (Object.getPrototypeOf(value) === Object.prototype || Object.getPrototypeOf(value) === null);
|
|
1891
|
+
const fail = (name, message, code = "INVALID_DEFINITION") => {
|
|
1892
|
+
throw new BlockDefinitionError(`Magic Editor X inline annotation ${name}: ${message}`, code);
|
|
1893
|
+
};
|
|
1894
|
+
const defined = /* @__PURE__ */ new WeakSet();
|
|
1895
|
+
const cleanText = (value, max) => typeof value === "string" ? value.trim().slice(0, max).trim() : "";
|
|
1896
|
+
const normalizeAttribute = (where, input2) => {
|
|
1897
|
+
if (!isObject(input2)) fail(where, 'an attribute must be an object with a "type"');
|
|
1898
|
+
const { type } = input2;
|
|
1899
|
+
if (!ANNOTATION_FIELD_TYPES.includes(type)) fail(where, `unknown attribute type ${JSON.stringify(type)}`);
|
|
1900
|
+
const allowed = { text: ["max"], enum: ["values"], url: ["schemes", "relative"] }[type];
|
|
1901
|
+
for (const key of Object.keys(input2))
|
|
1902
|
+
if (!["type", "label", "required", ...allowed].includes(key))
|
|
1903
|
+
fail(where, `unknown option "${key}" for a ${type} attribute`);
|
|
1904
|
+
const out = { type, required: input2.required === true };
|
|
1905
|
+
if (input2.label !== void 0) {
|
|
1906
|
+
if (typeof input2.label !== "string" || input2.label.length > ANNOTATION_LIMITS.label)
|
|
1907
|
+
fail(where, `"label" must be a string of at most ${ANNOTATION_LIMITS.label} characters`);
|
|
1908
|
+
out.label = input2.label;
|
|
1909
|
+
}
|
|
1910
|
+
if (input2.required !== void 0 && typeof input2.required !== "boolean")
|
|
1911
|
+
fail(where, '"required" must be a boolean');
|
|
1912
|
+
if (type === "text") {
|
|
1913
|
+
const max = input2.max === void 0 ? ANNOTATION_LIMITS.textDefault : input2.max;
|
|
1914
|
+
if (!Number.isInteger(max) || max < 1 || max > ANNOTATION_LIMITS.text)
|
|
1915
|
+
fail(where, `"max" must be an integer from 1 to ${ANNOTATION_LIMITS.text}`);
|
|
1916
|
+
out.max = max;
|
|
1917
|
+
} else if (type === "enum") {
|
|
1918
|
+
const { values } = input2;
|
|
1919
|
+
if (!Array.isArray(values) || !values.length || values.length > ANNOTATION_LIMITS.values || !values.every((value) => typeof value === "string" && value.length >= 1 && value.length <= 100) || new Set(values).size !== values.length)
|
|
1920
|
+
fail(where, `"values" must be 1 to ${ANNOTATION_LIMITS.values} distinct strings`);
|
|
1921
|
+
out.values = Object.freeze([...values]);
|
|
1922
|
+
} else {
|
|
1923
|
+
const schemes = input2.schemes === void 0 ? ["http", "https"] : input2.schemes;
|
|
1924
|
+
if (!Array.isArray(schemes) || !schemes.length || !schemes.every((scheme) => LINK_SCHEMES.includes(scheme)))
|
|
1925
|
+
fail(where, `"schemes" must be a non-empty subset of ${LINK_SCHEMES.join(", ")}`);
|
|
1926
|
+
if (input2.relative !== void 0 && typeof input2.relative !== "boolean")
|
|
1927
|
+
fail(where, '"relative" must be a boolean');
|
|
1928
|
+
out.schemes = Object.freeze([...new Set(schemes)]);
|
|
1929
|
+
out.relative = input2.relative !== false;
|
|
1930
|
+
}
|
|
1931
|
+
return Object.freeze(out);
|
|
1932
|
+
};
|
|
1933
|
+
const defineInlineAnnotation = (definition) => {
|
|
1934
|
+
if (!isObject(definition)) fail("(unnamed)", "the definition must be an object");
|
|
1935
|
+
const { name } = definition;
|
|
1936
|
+
if (typeof name !== "string" || !ANNOTATION_NAME.test(name))
|
|
1937
|
+
fail(JSON.stringify(name), "the name must match /^[a-z][a-z0-9-]{1,39}$/");
|
|
1938
|
+
for (const key of Object.keys(definition))
|
|
1939
|
+
if (!["name", "label", "description", "attributes", "presets", "resolve", "render", "shortcut"].includes(
|
|
1940
|
+
key
|
|
1941
|
+
))
|
|
1942
|
+
fail(name, `unknown key "${key}"`);
|
|
1943
|
+
for (const key of ["label", "description"])
|
|
1944
|
+
if (definition[key] !== void 0 && (typeof definition[key] !== "string" || definition[key].length > (key === "label" ? 100 : 500)))
|
|
1945
|
+
fail(name, `"${key}" must be a short string`);
|
|
1946
|
+
if (!isObject(definition.attributes)) fail(name, '"attributes" must be an object');
|
|
1947
|
+
const keys = Object.keys(definition.attributes);
|
|
1948
|
+
if (keys.length > ANNOTATION_LIMITS.attributes)
|
|
1949
|
+
fail(name, `at most ${ANNOTATION_LIMITS.attributes} attributes`);
|
|
1950
|
+
const attributes = {};
|
|
1951
|
+
for (const key of keys) {
|
|
1952
|
+
if (!ANNOTATION_KEY.test(key)) fail(name, `attribute key "${key}" must match /^[a-z][a-z0-9]{0,23}$/`);
|
|
1953
|
+
attributes[key] = normalizeAttribute(`${name}.${key}`, definition.attributes[key]);
|
|
1954
|
+
}
|
|
1955
|
+
const presets = definition.presets === void 0 ? [] : definition.presets;
|
|
1956
|
+
if (!Array.isArray(presets) || !presets.every((preset) => ANNOTATION_PRESETS.includes(preset)))
|
|
1957
|
+
fail(name, `"presets" must list only ${ANNOTATION_PRESETS.join(", ")}`);
|
|
1958
|
+
if (definition.shortcut !== void 0 && !ANNOTATION_SHORTCUTS.includes(definition.shortcut))
|
|
1959
|
+
fail(name, `"shortcut" must be one of ${ANNOTATION_SHORTCUTS.join(", ")}`);
|
|
1960
|
+
for (const key of ["resolve", "render"])
|
|
1961
|
+
if (definition[key] !== void 0 && typeof definition[key] !== "function")
|
|
1962
|
+
fail(name, `"${key}" must be a function`);
|
|
1963
|
+
const out = Object.freeze({
|
|
1964
|
+
name,
|
|
1965
|
+
label: definition.label || name,
|
|
1966
|
+
...definition.description ? { description: definition.description } : {},
|
|
1967
|
+
attributes: Object.freeze(attributes),
|
|
1968
|
+
presets: Object.freeze([...new Set(presets)]),
|
|
1969
|
+
...definition.shortcut ? { shortcut: definition.shortcut } : {},
|
|
1970
|
+
...definition.resolve ? { resolve: definition.resolve } : {},
|
|
1971
|
+
...definition.render ? { render: definition.render } : {}
|
|
1972
|
+
});
|
|
1973
|
+
defined.add(out);
|
|
1974
|
+
return out;
|
|
1975
|
+
};
|
|
1976
|
+
const cleanAnnotationAttributes = (definition, raw) => {
|
|
1977
|
+
const source = raw && typeof raw === "object" ? raw : {};
|
|
1978
|
+
const out = {};
|
|
1979
|
+
for (const [key, field2] of Object.entries(definition.attributes)) {
|
|
1980
|
+
const value = Object.prototype.hasOwnProperty.call(source, key) ? source[key] : void 0;
|
|
1981
|
+
let clean;
|
|
1982
|
+
if (field2.type === "text") clean = cleanText(value, field2.max);
|
|
1983
|
+
else if (field2.type === "enum")
|
|
1984
|
+
clean = typeof value === "string" && field2.values.includes(value) ? value : "";
|
|
1985
|
+
else clean = sanitizeUrl(value, { schemes: field2.schemes, allowRelative: field2.relative });
|
|
1986
|
+
if (clean) out[key] = clean;
|
|
1987
|
+
else if (field2.required) return null;
|
|
1988
|
+
}
|
|
1989
|
+
return out;
|
|
1990
|
+
};
|
|
1991
|
+
const abbreviationAnnotation = defineInlineAnnotation({
|
|
1992
|
+
name: ABBREVIATION,
|
|
1993
|
+
label: "Abbreviation",
|
|
1994
|
+
description: "Short form with its full form (shown as a tooltip and read by screen readers).",
|
|
1995
|
+
attributes: { title: { type: "text", max: 200, required: true, label: "Full form" } },
|
|
1996
|
+
render: (annotation) => ({ tag: "abbr", attrs: { title: annotation.attrs.title } })
|
|
1997
|
+
});
|
|
1998
|
+
const registry = /* @__PURE__ */ new Map();
|
|
1999
|
+
const activeAnnotation = (name) => {
|
|
2000
|
+
if (name === ABBREVIATION) return abbreviationAnnotation;
|
|
2001
|
+
return typeof name === "string" && registry.has(name) ? registry.get(name) : null;
|
|
2002
|
+
};
|
|
2003
|
+
const activeAnnotations = () => [abbreviationAnnotation, ...registry.values()];
|
|
2004
|
+
const annotationsFromSummaries = (summaries) => {
|
|
2005
|
+
const out = [];
|
|
2006
|
+
for (const summary of Array.isArray(summaries) ? summaries.slice(0, ANNOTATION_LIMITS.registered) : []) {
|
|
2007
|
+
if (!isObject(summary) || summary.name === ABBREVIATION) continue;
|
|
2008
|
+
try {
|
|
2009
|
+
out.push(
|
|
2010
|
+
defineInlineAnnotation({
|
|
2011
|
+
name: summary.name,
|
|
2012
|
+
label: typeof summary.label === "string" ? summary.label.slice(0, 100) : void 0,
|
|
2013
|
+
attributes: summary.attributes,
|
|
2014
|
+
presets: Array.isArray(summary.presets) ? summary.presets : [],
|
|
2015
|
+
...typeof summary.shortcut === "string" ? { shortcut: summary.shortcut } : {}
|
|
2016
|
+
})
|
|
2017
|
+
);
|
|
2018
|
+
} catch {
|
|
2019
|
+
}
|
|
2020
|
+
}
|
|
2021
|
+
return out;
|
|
2022
|
+
};
|
|
2023
|
+
const CLASS_TOKEN = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/;
|
|
2024
|
+
const RENDER_ATTRIBUTES = /* @__PURE__ */ new Set(["title", "class", "lang", "dir", "href", "datetime", "value", "cite"]);
|
|
2025
|
+
const cleanAnnotationWrapper = (out) => {
|
|
2026
|
+
if (!isObject(out) || !ANNOTATION_RENDER_TAGS.includes(out.tag)) return null;
|
|
2027
|
+
const attrs = {};
|
|
2028
|
+
for (const [name, raw] of Object.entries(isObject(out.attrs) ? out.attrs : {})) {
|
|
2029
|
+
if (raw === void 0 || raw === null || raw === false) continue;
|
|
2030
|
+
if (!["string", "number"].includes(typeof raw)) continue;
|
|
2031
|
+
const allowed = RENDER_ATTRIBUTES.has(name) || name === "aria-label" || name.startsWith("data-") && !name.startsWith("data-mex-");
|
|
2032
|
+
if (!allowed || !isSafeAttributeName(name)) continue;
|
|
2033
|
+
const text = String(raw).slice(0, 2e3);
|
|
2034
|
+
if (name === "href" || name === "cite") {
|
|
2035
|
+
if (out.tag !== "a" && name === "href") continue;
|
|
2036
|
+
const url = sanitizeUrl(text);
|
|
2037
|
+
if (url) attrs[name] = url;
|
|
2038
|
+
} else if (name === "class") {
|
|
2039
|
+
const classes = text.split(/\s+/).filter((token) => CLASS_TOKEN.test(token));
|
|
2040
|
+
if (classes.length) attrs.class = classes.join(" ");
|
|
2041
|
+
} else if (text) attrs[name] = text;
|
|
2042
|
+
}
|
|
2043
|
+
return { tag: out.tag, attrs };
|
|
2044
|
+
};
|
|
1677
2045
|
const DROP_WITH_CONTENT = /* @__PURE__ */ new Set([
|
|
1678
2046
|
"script",
|
|
1679
2047
|
"style",
|
|
@@ -1794,6 +2162,20 @@ const cleanAttributes = (tag, attribs, options = {}) => {
|
|
|
1794
2162
|
const MAX_MARKER_TEXT = 16;
|
|
1795
2163
|
const isMathNode = (node) => node.type === "element" && node.tag === "span" && node.attrs[MATH_ATTRIBUTE] === "true";
|
|
1796
2164
|
const isFootnoteNode = (node) => node.type === "element" && node.tag === "sup" && typeof node.attrs["data-mex-footnote"] === "string";
|
|
2165
|
+
const isColorNode = (node) => node.type === "element" && node.tag === "span" && typeof node.attrs[COLOR_ATTRIBUTE] === "string";
|
|
2166
|
+
const isHighlightNode = (node) => node.type === "element" && node.tag === "mark" && typeof node.attrs[HIGHLIGHT_ATTRIBUTE] === "string";
|
|
2167
|
+
const isAnnotationNode = (node) => node.type === "element" && node.tag === "span" && typeof node.attrs[ANNOTATION_ATTRIBUTE] === "string";
|
|
2168
|
+
const annotationOf = (node) => {
|
|
2169
|
+
const attrs = {};
|
|
2170
|
+
for (const [name, value] of Object.entries(node.attrs))
|
|
2171
|
+
if (name.startsWith(ANNOTATION_VALUE_PREFIX)) attrs[name.slice(ANNOTATION_VALUE_PREFIX.length)] = value;
|
|
2172
|
+
return { name: node.attrs[ANNOTATION_ATTRIBUTE], attrs };
|
|
2173
|
+
};
|
|
2174
|
+
const annotationAttributes = (name, values) => {
|
|
2175
|
+
const out = { [ANNOTATION_ATTRIBUTE]: name };
|
|
2176
|
+
for (const key of Object.keys(values).sort()) out[`${ANNOTATION_VALUE_PREFIX}${key}`] = values[key];
|
|
2177
|
+
return out;
|
|
2178
|
+
};
|
|
1797
2179
|
const finalizeSpecial = (nodes, depth = 0) => {
|
|
1798
2180
|
for (const node of nodes) {
|
|
1799
2181
|
if (node.type !== "element") continue;
|
|
@@ -1812,6 +2194,25 @@ const specialElement = (tag, attribs, options) => {
|
|
|
1812
2194
|
if (!/^(?:|true)$/.test(attribs[MATH_ATTRIBUTE])) return null;
|
|
1813
2195
|
return { attrs: { [MATH_ATTRIBUTE]: "true" } };
|
|
1814
2196
|
}
|
|
2197
|
+
if (tag === "span" && Object.prototype.hasOwnProperty.call(attribs, ANNOTATION_ATTRIBUTE)) {
|
|
2198
|
+
const name = attribs[ANNOTATION_ATTRIBUTE];
|
|
2199
|
+
if (!ANNOTATION_NAME.test(name)) return null;
|
|
2200
|
+
const values = {};
|
|
2201
|
+
for (const [attribute, value] of Object.entries(attribs)) {
|
|
2202
|
+
if (!attribute.startsWith(ANNOTATION_VALUE_PREFIX)) continue;
|
|
2203
|
+
const key = attribute.slice(ANNOTATION_VALUE_PREFIX.length);
|
|
2204
|
+
if (!ANNOTATION_KEY.test(key) || Object.keys(values).length >= ANNOTATION_LIMITS.attributes) continue;
|
|
2205
|
+
const text = String(value).slice(0, ANNOTATION_LIMITS.text);
|
|
2206
|
+
if (text) values[key] = text;
|
|
2207
|
+
}
|
|
2208
|
+
return { attrs: annotationAttributes(name, values) };
|
|
2209
|
+
}
|
|
2210
|
+
if (tag === "span" && Object.prototype.hasOwnProperty.call(attribs, COLOR_ATTRIBUTE)) {
|
|
2211
|
+
return TOKEN_PATTERN.test(attribs[COLOR_ATTRIBUTE]) ? { attrs: { [COLOR_ATTRIBUTE]: attribs[COLOR_ATTRIBUTE] } } : null;
|
|
2212
|
+
}
|
|
2213
|
+
if (tag === "mark" && Object.prototype.hasOwnProperty.call(attribs, HIGHLIGHT_ATTRIBUTE)) {
|
|
2214
|
+
return TOKEN_PATTERN.test(attribs[HIGHLIGHT_ATTRIBUTE]) ? { attrs: { [HIGHLIGHT_ATTRIBUTE]: attribs[HIGHLIGHT_ATTRIBUTE] } } : null;
|
|
2215
|
+
}
|
|
1815
2216
|
if (tag === "sup" && !options.inNote) {
|
|
1816
2217
|
const id = attribs["data-mex-footnote"];
|
|
1817
2218
|
if (typeof id !== "string" || !FOOTNOTE_ID.test(id)) return null;
|
|
@@ -1995,6 +2396,24 @@ const inlineNodesToRender = (nodes, options = {}) => {
|
|
|
1995
2396
|
out.push({ type: "element", tag: "sup", attrs: attrs2, children: inlineNodesToRender(node.children, options) });
|
|
1996
2397
|
continue;
|
|
1997
2398
|
}
|
|
2399
|
+
if (isColorNode(node) || isHighlightNode(node)) {
|
|
2400
|
+
const color = node.tag === "span";
|
|
2401
|
+
const name = color ? COLOR_ATTRIBUTE : HIGHLIGHT_ATTRIBUTE;
|
|
2402
|
+
const token = node.attrs[name];
|
|
2403
|
+
out.push({
|
|
2404
|
+
type: "element",
|
|
2405
|
+
tag: node.tag,
|
|
2406
|
+
attrs: options.storage ? { [name]: token } : { class: color ? colorClass(token) : highlightClass(token), [name]: token },
|
|
2407
|
+
children: inlineNodesToRender(node.children, options)
|
|
2408
|
+
});
|
|
2409
|
+
continue;
|
|
2410
|
+
}
|
|
2411
|
+
if (isAnnotationNode(node)) {
|
|
2412
|
+
const children = inlineNodesToRender(node.children, options);
|
|
2413
|
+
if (options.storage) out.push({ type: "element", tag: "span", attrs: { ...node.attrs }, children });
|
|
2414
|
+
else out.push(...renderAnnotation(node, children, options));
|
|
2415
|
+
continue;
|
|
2416
|
+
}
|
|
1998
2417
|
let attrs = node.attrs;
|
|
1999
2418
|
if (node.tag === "a") {
|
|
2000
2419
|
attrs = resolveLinkAttributes(attrs, options.links);
|
|
@@ -2025,6 +2444,68 @@ const inlineNodesToRender = (nodes, options = {}) => {
|
|
|
2025
2444
|
}
|
|
2026
2445
|
return out;
|
|
2027
2446
|
};
|
|
2447
|
+
const annotationLists = /* @__PURE__ */ new WeakMap();
|
|
2448
|
+
const annotationDefinition = (name, options) => {
|
|
2449
|
+
const list = options.annotations;
|
|
2450
|
+
if (Array.isArray(list)) {
|
|
2451
|
+
if (!annotationLists.has(list)) {
|
|
2452
|
+
const map = /* @__PURE__ */ new Map();
|
|
2453
|
+
for (const item of list.slice(0, ANNOTATION_LIMITS.registered))
|
|
2454
|
+
if (item && typeof item === "object" && typeof item.name === "string" && item.attributes)
|
|
2455
|
+
map.set(item.name, item);
|
|
2456
|
+
annotationLists.set(list, map);
|
|
2457
|
+
}
|
|
2458
|
+
const found = annotationLists.get(list).get(name);
|
|
2459
|
+
if (found) return found;
|
|
2460
|
+
}
|
|
2461
|
+
return activeAnnotation(name);
|
|
2462
|
+
};
|
|
2463
|
+
const resolvedValue = (options, annotation) => {
|
|
2464
|
+
if (typeof options.resolveAnnotation !== "function") return void 0;
|
|
2465
|
+
let value;
|
|
2466
|
+
try {
|
|
2467
|
+
value = options.resolveAnnotation(annotation);
|
|
2468
|
+
} catch {
|
|
2469
|
+
return void 0;
|
|
2470
|
+
}
|
|
2471
|
+
if (typeof value === "string") return value.slice(0, 2e3);
|
|
2472
|
+
if (value && typeof value === "object" && !Array.isArray(value)) return value;
|
|
2473
|
+
return void 0;
|
|
2474
|
+
};
|
|
2475
|
+
const renderAnnotation = (node, children, options) => {
|
|
2476
|
+
const { name, attrs } = annotationOf(node);
|
|
2477
|
+
const definition = annotationDefinition(name, options);
|
|
2478
|
+
const values = definition ? cleanAnnotationAttributes(definition, attrs) : attrs;
|
|
2479
|
+
if (!values) return children;
|
|
2480
|
+
if (definition && typeof definition.render === "function") {
|
|
2481
|
+
const text = nodesToText(node.children);
|
|
2482
|
+
let out;
|
|
2483
|
+
try {
|
|
2484
|
+
out = definition.render({
|
|
2485
|
+
name,
|
|
2486
|
+
attrs: { ...values },
|
|
2487
|
+
text,
|
|
2488
|
+
resolved: resolvedValue(options, { name, attrs: { ...values }, text })
|
|
2489
|
+
});
|
|
2490
|
+
} catch {
|
|
2491
|
+
out = void 0;
|
|
2492
|
+
}
|
|
2493
|
+
if (out === false) return children;
|
|
2494
|
+
const wrapper = cleanAnnotationWrapper(out);
|
|
2495
|
+
if (wrapper) return [{ type: "element", tag: wrapper.tag, attrs: wrapper.attrs, children }];
|
|
2496
|
+
}
|
|
2497
|
+
return [
|
|
2498
|
+
{
|
|
2499
|
+
type: "element",
|
|
2500
|
+
tag: "span",
|
|
2501
|
+
attrs: {
|
|
2502
|
+
class: `mex-annotation mex-annotation-${name}`,
|
|
2503
|
+
...annotationAttributes(name, definition ? values : {})
|
|
2504
|
+
},
|
|
2505
|
+
children
|
|
2506
|
+
}
|
|
2507
|
+
];
|
|
2508
|
+
};
|
|
2028
2509
|
const inlineToNodes = (html, options) => inlineNodesToRender(parseInline(html), options);
|
|
2029
2510
|
const nodesToHtml = (nodes, options = {}) => serializeNodes(inlineNodesToRender(nodes, options));
|
|
2030
2511
|
const nodesToText = (nodes, options = {}) => nodes.map((node) => {
|
|
@@ -2057,22 +2538,53 @@ const mapFootnoteNotes = (html, fn) => {
|
|
|
2057
2538
|
visit(nodes);
|
|
2058
2539
|
return changed ? nodesToHtml(nodes, { storage: true }) : html;
|
|
2059
2540
|
};
|
|
2541
|
+
const SPECIAL_MARKERS = [
|
|
2542
|
+
MATH_ATTRIBUTE,
|
|
2543
|
+
"data-mex-footnote",
|
|
2544
|
+
COLOR_ATTRIBUTE,
|
|
2545
|
+
HIGHLIGHT_ATTRIBUTE,
|
|
2546
|
+
ANNOTATION_ATTRIBUTE
|
|
2547
|
+
];
|
|
2548
|
+
const isSpecialNode = (node) => isMathNode(node) || isFootnoteNode(node) || isColorNode(node) || isHighlightNode(node) || isAnnotationNode(node);
|
|
2060
2549
|
const canonicalInlineExtras = (html, options = {}) => {
|
|
2061
2550
|
if (typeof html !== "string") return "";
|
|
2062
|
-
const
|
|
2063
|
-
const
|
|
2064
|
-
|
|
2551
|
+
const plain2 = Array.isArray(options.plainTags) ? options.plainTags : [];
|
|
2552
|
+
const special = SPECIAL_MARKERS.some((marker) => html.includes(marker));
|
|
2553
|
+
const restricted = plain2.some((tag) => html.includes(`<${tag}`));
|
|
2554
|
+
if (!special && !restricted) return html;
|
|
2555
|
+
const colors = Array.isArray(options.colors) ? new Set(options.colors) : null;
|
|
2556
|
+
const highlights = Array.isArray(options.highlights) ? new Set(options.highlights) : null;
|
|
2557
|
+
let annotations = null;
|
|
2558
|
+
if (options.annotations instanceof Map) annotations = options.annotations;
|
|
2559
|
+
else if (Array.isArray(options.annotations))
|
|
2560
|
+
annotations = new Map(options.annotations.filter(Boolean).map((item) => [item.name, item]));
|
|
2065
2561
|
const nodes = parseInline(html);
|
|
2066
|
-
|
|
2067
|
-
const
|
|
2068
|
-
|
|
2069
|
-
if (
|
|
2070
|
-
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
|
|
2074
|
-
|
|
2075
|
-
|
|
2562
|
+
const filter = (list, depth = 0) => {
|
|
2563
|
+
const out = [];
|
|
2564
|
+
for (const node of list) {
|
|
2565
|
+
if (node.type !== "element") {
|
|
2566
|
+
out.push(node);
|
|
2567
|
+
continue;
|
|
2568
|
+
}
|
|
2569
|
+
if (options.footnotes === false && isFootnoteNode(node)) continue;
|
|
2570
|
+
if (depth < MAX_DEPTH) node.children = filter(node.children, depth + 1);
|
|
2571
|
+
if (node.note) node.note = filter(node.note, depth + 1);
|
|
2572
|
+
let keep = true;
|
|
2573
|
+
if (isColorNode(node)) keep = !colors || colors.has(node.attrs[COLOR_ATTRIBUTE]);
|
|
2574
|
+
else if (isHighlightNode(node)) keep = !highlights || highlights.has(node.attrs[HIGHLIGHT_ATTRIBUTE]);
|
|
2575
|
+
else if (isAnnotationNode(node) && annotations) {
|
|
2576
|
+
const { name, attrs } = annotationOf(node);
|
|
2577
|
+
const definition = annotations.get(name);
|
|
2578
|
+
const values = definition ? cleanAnnotationAttributes(definition, attrs) : null;
|
|
2579
|
+
if (values) node.attrs = annotationAttributes(name, values);
|
|
2580
|
+
else keep = false;
|
|
2581
|
+
} else if (!isSpecialNode(node) && plain2.includes(node.tag)) keep = false;
|
|
2582
|
+
if (keep) out.push(node);
|
|
2583
|
+
else out.push(...node.children);
|
|
2584
|
+
}
|
|
2585
|
+
return out;
|
|
2586
|
+
};
|
|
2587
|
+
return nodesToHtml(filter(nodes), { storage: true });
|
|
2076
2588
|
};
|
|
2077
2589
|
const walkInlineElements = (nodes, fn, inNote = false, depth = 0) => {
|
|
2078
2590
|
if (depth > MAX_DEPTH) return;
|
|
@@ -2089,6 +2601,10 @@ const instance = () => {
|
|
|
2089
2601
|
purify = createDOMPurify__default.default(window);
|
|
2090
2602
|
purify.addHook("uponSanitizeAttribute", (node, data) => {
|
|
2091
2603
|
const tag = node.nodeName.toLowerCase();
|
|
2604
|
+
if (tag === "span" && ANNOTATION_VALUE_ATTRIBUTE.test(data.attrName) && typeof node.hasAttribute === "function" && node.hasAttribute(ANNOTATION_ATTRIBUTE)) {
|
|
2605
|
+
data.forceKeepAttr = true;
|
|
2606
|
+
return;
|
|
2607
|
+
}
|
|
2092
2608
|
if (data.attrName === "class") {
|
|
2093
2609
|
const allowed = INLINE_CLASSES[tag] || [];
|
|
2094
2610
|
const kept = String(data.attrValue).split(/\s+/).filter((name) => allowed.includes(name));
|
|
@@ -2118,7 +2634,10 @@ const instance = () => {
|
|
|
2118
2634
|
});
|
|
2119
2635
|
return purify;
|
|
2120
2636
|
};
|
|
2121
|
-
const ALLOWED_ATTR = Array.from(new Set(Object.values(INLINE_ATTRIBUTES).flat()))
|
|
2637
|
+
const ALLOWED_ATTR = Array.from(new Set(Object.values(INLINE_ATTRIBUTES).flat())).filter(
|
|
2638
|
+
(name) => !name.endsWith("*")
|
|
2639
|
+
);
|
|
2640
|
+
const ANNOTATION_VALUE_ATTRIBUTE = /^data-mex-a-[a-z][a-z0-9]{0,23}$/;
|
|
2122
2641
|
const sanitizeInline = (html) => canonicalInlineExtras(
|
|
2123
2642
|
instance().sanitize(String(html || ""), {
|
|
2124
2643
|
ALLOWED_TAGS: [...INLINE_TAGS],
|
|
@@ -2130,7 +2649,15 @@ const sanitizeInline = (html) => canonicalInlineExtras(
|
|
|
2130
2649
|
// validated by cleanInternalLinkAttributes in the hook above, and math and
|
|
2131
2650
|
// footnote attributes (2.4: a note is inline HTML, "See: …" looks like a
|
|
2132
2651
|
// scheme too) by `canonicalInlineExtras` below.
|
|
2133
|
-
ADD_URI_SAFE_ATTR: [
|
|
2652
|
+
ADD_URI_SAFE_ATTR: [
|
|
2653
|
+
...INTERNAL_LINK_ATTRIBUTES,
|
|
2654
|
+
MATH_ATTRIBUTE,
|
|
2655
|
+
...FOOTNOTE_ATTRIBUTES,
|
|
2656
|
+
// 2.5: tokens and the annotation name (validated by `canonicalInlineExtras`).
|
|
2657
|
+
COLOR_ATTRIBUTE,
|
|
2658
|
+
HIGHLIGHT_ATTRIBUTE,
|
|
2659
|
+
ANNOTATION_ATTRIBUTE
|
|
2660
|
+
]
|
|
2134
2661
|
})
|
|
2135
2662
|
);
|
|
2136
2663
|
const sanitizeTemplate = (html) => instance().sanitize(String(html || ""), {
|
|
@@ -2325,11 +2852,13 @@ const ICONS = {
|
|
|
2325
2852
|
lineNumbers: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 6h2M4 12h2M4 18h2M10 6h10M10 12h10M10 18h10" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>',
|
|
2326
2853
|
math: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18 5H6l6 7-6 7h12" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
2327
2854
|
inlineMath: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 18c3 0 3-12 6-12M5 11h5m4 1 6 6m0-6-6 6" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
2328
|
-
footnote: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 18h10M4 13h10M17 4l2-1v6m-2 0h4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>'
|
|
2855
|
+
footnote: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M4 18h10M4 13h10M17 4l2-1v6m-2 0h4" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>',
|
|
2856
|
+
// 2.5: "Copy block" in the block menu.
|
|
2857
|
+
copy: '<svg width="20" height="20" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg"><rect x="8" y="8" width="12" height="12" rx="2" stroke="currentColor" stroke-width="2"/><path d="M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2" stroke="currentColor" stroke-width="2" stroke-linecap="round"/></svg>'
|
|
2329
2858
|
};
|
|
2330
2859
|
const tools = /* @__PURE__ */ new Map();
|
|
2331
2860
|
const registerBlock = (options) => {
|
|
2332
|
-
if (!isObject(options))
|
|
2861
|
+
if (!isObject$1(options))
|
|
2333
2862
|
throw new BlockDefinitionError("Magic Editor X registerBlock: pass { definition, tool }");
|
|
2334
2863
|
const { definition, tool, title, icon, i18n, inlineToolbar, shortcut } = options;
|
|
2335
2864
|
if (typeof tool !== "function")
|
|
@@ -2347,7 +2876,7 @@ const registerBlock = (options) => {
|
|
|
2347
2876
|
tool,
|
|
2348
2877
|
title: title === void 0 ? compiled2.title || compiled2.name : title,
|
|
2349
2878
|
icon: typeof icon === "string" ? sanitizeSvg(icon) : "",
|
|
2350
|
-
i18n: isObject(i18n) ? i18n : {},
|
|
2879
|
+
i18n: isObject$1(i18n) ? i18n : {},
|
|
2351
2880
|
inlineToolbar: inlineToolbar === true,
|
|
2352
2881
|
shortcut
|
|
2353
2882
|
});
|
|
@@ -2358,7 +2887,7 @@ const buildCodeBlockTools = (ctx) => {
|
|
|
2358
2887
|
const out = {};
|
|
2359
2888
|
for (const entry of tools.values()) {
|
|
2360
2889
|
const { definition, tool: Tool } = entry;
|
|
2361
|
-
const messages = isObject(entry.i18n[ctx.locale]) ? entry.i18n[ctx.locale] : isObject(entry.i18n[String(ctx.locale || "").split("-")[0]]) ? entry.i18n[String(ctx.locale).split("-")[0]] : isObject(entry.i18n.en) ? entry.i18n.en : {};
|
|
2890
|
+
const messages = isObject$1(entry.i18n[ctx.locale]) ? entry.i18n[ctx.locale] : isObject$1(entry.i18n[String(ctx.locale || "").split("-")[0]]) ? entry.i18n[String(ctx.locale).split("-")[0]] : isObject$1(entry.i18n.en) ? entry.i18n.en : {};
|
|
2362
2891
|
const rules = sanitizeRulesFor(definition.schema);
|
|
2363
2892
|
const toolbox = {
|
|
2364
2893
|
title: localized(entry.title, ctx.locale) || definition.name,
|
|
@@ -2455,36 +2984,244 @@ const createReactTool = (Component, options = {}) => {
|
|
|
2455
2984
|
}
|
|
2456
2985
|
};
|
|
2457
2986
|
};
|
|
2987
|
+
const DRAFT_RECORD_VERSION = 1;
|
|
2988
|
+
const DEFAULT_DRAFT_TTL_HOURS = 72;
|
|
2989
|
+
const DRAFT_WRITE_DELAY_MS = 800;
|
|
2990
|
+
const MAX_DRAFT_CHARS = 6 * 1024 * 1024;
|
|
2991
|
+
const VOLUNTARY_LOGOUT_WINDOW_MS = 60 * 1e3;
|
|
2992
|
+
const MAX_PART = 512;
|
|
2993
|
+
const draftIdentity = (target) => {
|
|
2994
|
+
if (!target || target.owner === void 0 || target.owner === null || target.owner === "") return null;
|
|
2995
|
+
const { uid, field: field2 } = target;
|
|
2996
|
+
if (typeof uid !== "string" || !uid || typeof field2 !== "string" || !field2) return null;
|
|
2997
|
+
const identity = isPositionalFieldPath(field2) && isValidFieldKey(target.fieldKey) ? `${basePathOf(field2)}#${target.fieldKey}` : field2;
|
|
2998
|
+
const parts = [
|
|
2999
|
+
String(target.owner),
|
|
3000
|
+
uid,
|
|
3001
|
+
typeof target.documentId === "string" && target.documentId ? target.documentId : "new",
|
|
3002
|
+
typeof target.locale === "string" && target.locale ? target.locale : "-",
|
|
3003
|
+
identity
|
|
3004
|
+
];
|
|
3005
|
+
if (parts.some((part) => part.length > MAX_PART)) return null;
|
|
3006
|
+
return parts.join("|");
|
|
3007
|
+
};
|
|
3008
|
+
const hashText = (text) => {
|
|
3009
|
+
let h1 = 2166136261;
|
|
3010
|
+
let h2 = 16777619;
|
|
3011
|
+
const value = String(text);
|
|
3012
|
+
for (let i = 0; i < value.length; i += 1) {
|
|
3013
|
+
const code = value.charCodeAt(i);
|
|
3014
|
+
h1 = Math.imul(h1 ^ code, 16777619) >>> 0;
|
|
3015
|
+
h2 = Math.imul(h2 ^ code, 2246822519) >>> 0;
|
|
3016
|
+
}
|
|
3017
|
+
return `${h2.toString(16).padStart(8, "0")}${h1.toString(16).padStart(8, "0")}`;
|
|
3018
|
+
};
|
|
3019
|
+
const isValidDraftRecord = (record) => Boolean(
|
|
3020
|
+
record && typeof record === "object" && record.v === DRAFT_RECORD_VERSION && typeof record.id === "string" && typeof record.baseHash === "string" && Number.isFinite(record.savedAt) && Number.isFinite(record.expiresAt) && record.data && typeof record.data === "object" && Array.isArray(record.data.blocks)
|
|
3021
|
+
);
|
|
3022
|
+
const isExpired = (record, now) => !record || !(record.expiresAt > now);
|
|
3023
|
+
const ttlMsOf = (hours) => {
|
|
3024
|
+
const number = Number(hours);
|
|
3025
|
+
const safe = Number.isFinite(number) && number >= 1 && number <= 720 ? number : DEFAULT_DRAFT_TTL_HOURS;
|
|
3026
|
+
return Math.round(safe * 3600 * 1e3);
|
|
3027
|
+
};
|
|
3028
|
+
const buildDraftRecord = ({ id, data, baseKey, now, ttlMs }) => {
|
|
3029
|
+
if (!id || !data || !Array.isArray(data.blocks)) return null;
|
|
3030
|
+
const copy2 = { ...data };
|
|
3031
|
+
delete copy2.fieldKey;
|
|
3032
|
+
let json;
|
|
3033
|
+
try {
|
|
3034
|
+
json = JSON.stringify(copy2);
|
|
3035
|
+
} catch {
|
|
3036
|
+
return null;
|
|
3037
|
+
}
|
|
3038
|
+
if (json.length > MAX_DRAFT_CHARS) return null;
|
|
3039
|
+
return {
|
|
3040
|
+
v: DRAFT_RECORD_VERSION,
|
|
3041
|
+
id,
|
|
3042
|
+
baseHash: hashText(baseKey),
|
|
3043
|
+
savedAt: now,
|
|
3044
|
+
expiresAt: now + ttlMs,
|
|
3045
|
+
data: JSON.parse(json)
|
|
3046
|
+
};
|
|
3047
|
+
};
|
|
3048
|
+
const restoreDecision = ({ record, now, readOnly = false, recordKey, shownKey, savedKey }) => {
|
|
3049
|
+
if (!record) return { action: "none" };
|
|
3050
|
+
if (!isValidDraftRecord(record) || isExpired(record, now)) return { action: "delete" };
|
|
3051
|
+
if (readOnly) return { action: "none" };
|
|
3052
|
+
if (recordKey === shownKey || recordKey === savedKey) return { action: "delete" };
|
|
3053
|
+
return { action: "offer", conflict: record.baseHash !== hashText(savedKey) };
|
|
3054
|
+
};
|
|
3055
|
+
const bufferAction = ({ dirty, collaboration }) => {
|
|
3056
|
+
const synced = collaboration && collaboration.active && collaboration.status === "live" && !collaboration.pending;
|
|
3057
|
+
return dirty && !synced ? "write" : "delete";
|
|
3058
|
+
};
|
|
3059
|
+
const relativeTimeOf = (then, now) => {
|
|
3060
|
+
const seconds = Math.max(0, Math.round((now - then) / 1e3));
|
|
3061
|
+
if (seconds < 60) return { value: -seconds, unit: "second" };
|
|
3062
|
+
const minutes = Math.round(seconds / 60);
|
|
3063
|
+
if (minutes < 60) return { value: -minutes, unit: "minute" };
|
|
3064
|
+
const hours = Math.round(minutes / 60);
|
|
3065
|
+
if (hours < 24) return { value: -hours, unit: "hour" };
|
|
3066
|
+
return { value: -Math.round(hours / 24), unit: "day" };
|
|
3067
|
+
};
|
|
3068
|
+
const createLogoutMiddleware = ({ onLogout, now = () => Date.now() }) => {
|
|
3069
|
+
let voluntaryAt = -Infinity;
|
|
3070
|
+
return () => () => (next) => (action2) => {
|
|
3071
|
+
if (action2 && typeof action2 === "object") {
|
|
3072
|
+
if (isLogoutMutationStart(action2)) voluntaryAt = now();
|
|
3073
|
+
else if (action2.type === "admin/logout" && now() - voluntaryAt <= VOLUNTARY_LOGOUT_WINDOW_MS) {
|
|
3074
|
+
voluntaryAt = -Infinity;
|
|
3075
|
+
try {
|
|
3076
|
+
onLogout();
|
|
3077
|
+
} catch {
|
|
3078
|
+
}
|
|
3079
|
+
}
|
|
3080
|
+
}
|
|
3081
|
+
return next(action2);
|
|
3082
|
+
};
|
|
3083
|
+
};
|
|
3084
|
+
const isLogoutMutationStart = (action2) => Boolean(
|
|
3085
|
+
action2 && action2.type === "adminApi/executeMutation/pending" && action2.meta && action2.meta.arg && action2.meta.arg.endpointName === "logout"
|
|
3086
|
+
);
|
|
3087
|
+
const valueAtPath = (values, path) => {
|
|
3088
|
+
let current = values;
|
|
3089
|
+
for (const part of String(path || "").split(".").filter(Boolean).slice(0, 24)) {
|
|
3090
|
+
if (!current || typeof current !== "object") return void 0;
|
|
3091
|
+
current = current[part];
|
|
3092
|
+
}
|
|
3093
|
+
return current;
|
|
3094
|
+
};
|
|
3095
|
+
const savedValueOf = (initialValues, path, fieldKey = null) => {
|
|
3096
|
+
if (isPositionalFieldPath(path) && isValidFieldKey(fieldKey)) {
|
|
3097
|
+
const parts = basePathOf(path).split(".").filter(Boolean);
|
|
3098
|
+
let found = null;
|
|
3099
|
+
const walk = (data, index2, depth) => {
|
|
3100
|
+
if (found || !data || typeof data !== "object" || depth > 16) return;
|
|
3101
|
+
if (Array.isArray(data)) {
|
|
3102
|
+
data.forEach((item) => walk(item, index2, depth + 1));
|
|
3103
|
+
return;
|
|
3104
|
+
}
|
|
3105
|
+
if (index2 === parts.length) {
|
|
3106
|
+
if (data.fieldKey === fieldKey) found = data;
|
|
3107
|
+
return;
|
|
3108
|
+
}
|
|
3109
|
+
walk(data[parts[index2]], index2 + 1, depth + 1);
|
|
3110
|
+
};
|
|
3111
|
+
walk(initialValues, 0, 0);
|
|
3112
|
+
if (found) return found;
|
|
3113
|
+
}
|
|
3114
|
+
const value = valueAtPath(initialValues, path);
|
|
3115
|
+
return value === void 0 ? null : value;
|
|
3116
|
+
};
|
|
3117
|
+
let loggedOut = false;
|
|
3118
|
+
const isLoggedOut = () => loggedOut;
|
|
3119
|
+
const trackSessionAction = (action2) => {
|
|
3120
|
+
if (!action2 || typeof action2 !== "object") return;
|
|
3121
|
+
if (action2.type === "admin/logout") loggedOut = true;
|
|
3122
|
+
else if (action2.type === "admin/login" || action2.type === "admin/setToken") loggedOut = false;
|
|
3123
|
+
};
|
|
3124
|
+
const createSessionMiddleware = () => () => (next) => (action2) => {
|
|
3125
|
+
trackSessionAction(action2);
|
|
3126
|
+
return next(action2);
|
|
3127
|
+
};
|
|
3128
|
+
const DB_NAME = "magic-editor-x";
|
|
3129
|
+
const STORE = "drafts";
|
|
3130
|
+
let dbPromise = null;
|
|
3131
|
+
const openDb = () => {
|
|
3132
|
+
if (dbPromise) return dbPromise;
|
|
3133
|
+
dbPromise = new Promise((resolve) => {
|
|
3134
|
+
let request;
|
|
3135
|
+
try {
|
|
3136
|
+
if (typeof indexedDB === "undefined") {
|
|
3137
|
+
resolve(null);
|
|
3138
|
+
return;
|
|
3139
|
+
}
|
|
3140
|
+
request = indexedDB.open(DB_NAME, 1);
|
|
3141
|
+
} catch {
|
|
3142
|
+
resolve(null);
|
|
3143
|
+
return;
|
|
3144
|
+
}
|
|
3145
|
+
request.onupgradeneeded = () => {
|
|
3146
|
+
const db = request.result;
|
|
3147
|
+
if (!db.objectStoreNames.contains(STORE)) db.createObjectStore(STORE, { keyPath: "id" });
|
|
3148
|
+
};
|
|
3149
|
+
request.onsuccess = () => {
|
|
3150
|
+
const db = request.result;
|
|
3151
|
+
db.onversionchange = () => {
|
|
3152
|
+
db.close();
|
|
3153
|
+
dbPromise = null;
|
|
3154
|
+
};
|
|
3155
|
+
resolve(db);
|
|
3156
|
+
};
|
|
3157
|
+
request.onerror = () => resolve(null);
|
|
3158
|
+
request.onblocked = () => resolve(null);
|
|
3159
|
+
});
|
|
3160
|
+
return dbPromise;
|
|
3161
|
+
};
|
|
3162
|
+
const withStore = async (mode, run) => {
|
|
3163
|
+
const db = await openDb();
|
|
3164
|
+
if (!db) return null;
|
|
3165
|
+
return new Promise((resolve) => {
|
|
3166
|
+
try {
|
|
3167
|
+
const transaction = db.transaction(STORE, mode);
|
|
3168
|
+
const request = run(transaction.objectStore(STORE));
|
|
3169
|
+
transaction.oncomplete = () => resolve(request ? request.result : true);
|
|
3170
|
+
transaction.onerror = () => resolve(null);
|
|
3171
|
+
transaction.onabort = () => resolve(null);
|
|
3172
|
+
} catch {
|
|
3173
|
+
resolve(null);
|
|
3174
|
+
}
|
|
3175
|
+
});
|
|
3176
|
+
};
|
|
3177
|
+
const getDraft = async (id) => id ? await withStore("readonly", (s) => s.get(id)) || null : null;
|
|
3178
|
+
const putDraft = async (record) => Boolean(record && record.id && await withStore("readwrite", (s) => s.put(record)) !== null);
|
|
3179
|
+
const deleteDraft = async (id) => Boolean(id && await withStore("readwrite", (s) => s.delete(id)) !== null);
|
|
3180
|
+
const clearDrafts = async () => await withStore("readwrite", (s) => s.clear()) !== null;
|
|
3181
|
+
let pruned = false;
|
|
3182
|
+
const pruneDrafts = async (now) => {
|
|
3183
|
+
if (pruned) return;
|
|
3184
|
+
pruned = true;
|
|
3185
|
+
await withStore("readwrite", (store) => {
|
|
3186
|
+
const cursorRequest = store.openCursor();
|
|
3187
|
+
cursorRequest.onsuccess = () => {
|
|
3188
|
+
const cursor = cursorRequest.result;
|
|
3189
|
+
if (!cursor) return;
|
|
3190
|
+
if (isExpired(cursor.value, now)) cursor.delete();
|
|
3191
|
+
cursor.continue();
|
|
3192
|
+
};
|
|
3193
|
+
});
|
|
3194
|
+
};
|
|
2458
3195
|
const LOADERS = {
|
|
2459
3196
|
en: () => [
|
|
2460
|
-
Promise.resolve().then(() => require("./en
|
|
2461
|
-
Promise.resolve().then(() => require("./en-
|
|
2462
|
-
Promise.resolve().then(() => require("./en-
|
|
2463
|
-
Promise.resolve().then(() => require("./en-
|
|
3197
|
+
Promise.resolve().then(() => require("./en--JjAHbpP.js")),
|
|
3198
|
+
Promise.resolve().then(() => require("./en-CbGkcq0Q.js")),
|
|
3199
|
+
Promise.resolve().then(() => require("./en-CJ17Sp_e.js")),
|
|
3200
|
+
Promise.resolve().then(() => require("./en-D69Fe9ZO.js"))
|
|
2464
3201
|
],
|
|
2465
3202
|
de: () => [
|
|
2466
|
-
Promise.resolve().then(() => require("./de-
|
|
2467
|
-
Promise.resolve().then(() => require("./de-
|
|
2468
|
-
Promise.resolve().then(() => require("./de-
|
|
2469
|
-
Promise.resolve().then(() => require("./de-
|
|
3203
|
+
Promise.resolve().then(() => require("./de-BrPR4sUB.js")),
|
|
3204
|
+
Promise.resolve().then(() => require("./de-B6rdcOqQ.js")),
|
|
3205
|
+
Promise.resolve().then(() => require("./de-Dss5POqk.js")),
|
|
3206
|
+
Promise.resolve().then(() => require("./de-CnnxKXj7.js"))
|
|
2470
3207
|
],
|
|
2471
3208
|
fr: () => [
|
|
2472
|
-
Promise.resolve().then(() => require("./fr-
|
|
2473
|
-
Promise.resolve().then(() => require("./fr-
|
|
2474
|
-
Promise.resolve().then(() => require("./fr-
|
|
2475
|
-
Promise.resolve().then(() => require("./fr-
|
|
3209
|
+
Promise.resolve().then(() => require("./fr-Di-U-rAH.js")),
|
|
3210
|
+
Promise.resolve().then(() => require("./fr-DrUYv2jh.js")),
|
|
3211
|
+
Promise.resolve().then(() => require("./fr-CRM9VuAq.js")),
|
|
3212
|
+
Promise.resolve().then(() => require("./fr-Cx29jQ_g.js"))
|
|
2476
3213
|
],
|
|
2477
3214
|
es: () => [
|
|
2478
|
-
Promise.resolve().then(() => require("./es-
|
|
2479
|
-
Promise.resolve().then(() => require("./es-
|
|
2480
|
-
Promise.resolve().then(() => require("./es-
|
|
2481
|
-
Promise.resolve().then(() => require("./es-
|
|
3215
|
+
Promise.resolve().then(() => require("./es-YvaTAtqY.js")),
|
|
3216
|
+
Promise.resolve().then(() => require("./es-C8UotT8O.js")),
|
|
3217
|
+
Promise.resolve().then(() => require("./es-DJm3HFJt.js")),
|
|
3218
|
+
Promise.resolve().then(() => require("./es-CcEDZpVQ.js"))
|
|
2482
3219
|
],
|
|
2483
3220
|
pt: () => [
|
|
2484
|
-
Promise.resolve().then(() => require("./pt-
|
|
2485
|
-
Promise.resolve().then(() => require("./pt-
|
|
2486
|
-
Promise.resolve().then(() => require("./pt-
|
|
2487
|
-
Promise.resolve().then(() => require("./pt-
|
|
3221
|
+
Promise.resolve().then(() => require("./pt-CzrN_3ui.js")),
|
|
3222
|
+
Promise.resolve().then(() => require("./pt-CojQcz-p.js")),
|
|
3223
|
+
Promise.resolve().then(() => require("./pt-DPVAycXJ.js")),
|
|
3224
|
+
Promise.resolve().then(() => require("./pt-BYn2xx78.js"))
|
|
2488
3225
|
]
|
|
2489
3226
|
};
|
|
2490
3227
|
const PRESET_OPTIONS = [
|
|
@@ -2522,7 +3259,7 @@ const index = {
|
|
|
2522
3259
|
icon: icons.Bell,
|
|
2523
3260
|
title: { id: getTranslation("widget.mentions.title"), defaultMessage: "Mentions and replies" },
|
|
2524
3261
|
component: async () => {
|
|
2525
|
-
const { MentionsWidget } = await Promise.resolve().then(() => require("./MentionsWidget-
|
|
3262
|
+
const { MentionsWidget } = await Promise.resolve().then(() => require("./MentionsWidget-DUz6YVIG.js"));
|
|
2526
3263
|
return MentionsWidget;
|
|
2527
3264
|
},
|
|
2528
3265
|
permissions: [
|
|
@@ -2531,6 +3268,35 @@ const index = {
|
|
|
2531
3268
|
]
|
|
2532
3269
|
});
|
|
2533
3270
|
}
|
|
3271
|
+
if (app.widgets && typeof app.widgets.register === "function") {
|
|
3272
|
+
app.widgets.register([
|
|
3273
|
+
{
|
|
3274
|
+
id: "open-threads",
|
|
3275
|
+
pluginId: PLUGIN_ID,
|
|
3276
|
+
icon: icons.Discuss,
|
|
3277
|
+
title: { id: getTranslation("widget.openThreads.title"), defaultMessage: "My open threads" },
|
|
3278
|
+
component: async () => {
|
|
3279
|
+
const { OpenThreadsWidget } = await Promise.resolve().then(() => require("./EntryWidgets-BcXAAx3F.js"));
|
|
3280
|
+
return OpenThreadsWidget;
|
|
3281
|
+
},
|
|
3282
|
+
permissions: [
|
|
3283
|
+
{ action: "plugin::magic-editor-x.access" },
|
|
3284
|
+
{ action: "plugin::magic-editor-x.comments.read" }
|
|
3285
|
+
]
|
|
3286
|
+
},
|
|
3287
|
+
{
|
|
3288
|
+
id: "broken-links",
|
|
3289
|
+
pluginId: PLUGIN_ID,
|
|
3290
|
+
icon: icons.Link,
|
|
3291
|
+
title: { id: getTranslation("widget.brokenLinks.title"), defaultMessage: "Broken links" },
|
|
3292
|
+
component: async () => {
|
|
3293
|
+
const { BrokenLinksWidget } = await Promise.resolve().then(() => require("./EntryWidgets-BcXAAx3F.js"));
|
|
3294
|
+
return BrokenLinksWidget;
|
|
3295
|
+
},
|
|
3296
|
+
permissions: [{ action: "plugin::magic-editor-x.access" }]
|
|
3297
|
+
}
|
|
3298
|
+
]);
|
|
3299
|
+
}
|
|
2534
3300
|
app.customFields.register({
|
|
2535
3301
|
name: "richtext",
|
|
2536
3302
|
pluginId: PLUGIN_ID,
|
|
@@ -2542,7 +3308,7 @@ const index = {
|
|
|
2542
3308
|
},
|
|
2543
3309
|
icon: PluginIcon,
|
|
2544
3310
|
components: {
|
|
2545
|
-
Input: () => Promise.resolve().then(() => require("./index-
|
|
3311
|
+
Input: () => Promise.resolve().then(() => require("./index-C5D3VqLq.js")).then((n) => n.index)
|
|
2546
3312
|
},
|
|
2547
3313
|
options: {
|
|
2548
3314
|
base: [
|
|
@@ -2664,6 +3430,51 @@ const index = {
|
|
|
2664
3430
|
}
|
|
2665
3431
|
]
|
|
2666
3432
|
},
|
|
3433
|
+
// 2.5: extra inline formatting, off unless turned on here.
|
|
3434
|
+
{
|
|
3435
|
+
sectionTitle: {
|
|
3436
|
+
id: getTranslation("field.options.formatting"),
|
|
3437
|
+
defaultMessage: "Extra formatting"
|
|
3438
|
+
},
|
|
3439
|
+
items: [
|
|
3440
|
+
{
|
|
3441
|
+
intlLabel: {
|
|
3442
|
+
id: getTranslation("field.options.inlineColors.label"),
|
|
3443
|
+
defaultMessage: "Text colour and highlight"
|
|
3444
|
+
},
|
|
3445
|
+
description: {
|
|
3446
|
+
id: getTranslation("field.options.inlineColors.description"),
|
|
3447
|
+
defaultMessage: "Editors pick from the colours your developer set in the plugin configuration (palette). Without a palette nothing is shown."
|
|
3448
|
+
},
|
|
3449
|
+
name: "options.inlineColors",
|
|
3450
|
+
type: "checkbox"
|
|
3451
|
+
},
|
|
3452
|
+
{
|
|
3453
|
+
intlLabel: {
|
|
3454
|
+
id: getTranslation("field.options.inlineScript.label"),
|
|
3455
|
+
defaultMessage: "Superscript and subscript"
|
|
3456
|
+
},
|
|
3457
|
+
description: {
|
|
3458
|
+
id: getTranslation("field.options.inlineScript.description"),
|
|
3459
|
+
defaultMessage: "For formulas and units such as m² or H₂O"
|
|
3460
|
+
},
|
|
3461
|
+
name: "options.inlineScript",
|
|
3462
|
+
type: "checkbox"
|
|
3463
|
+
},
|
|
3464
|
+
{
|
|
3465
|
+
intlLabel: {
|
|
3466
|
+
id: getTranslation("field.options.inlineAnnotations.label"),
|
|
3467
|
+
defaultMessage: "Annotations"
|
|
3468
|
+
},
|
|
3469
|
+
description: {
|
|
3470
|
+
id: getTranslation("field.options.inlineAnnotations.description"),
|
|
3471
|
+
defaultMessage: "Comma-separated annotation names, for example: abbreviation. Your developer can add more, such as glossary."
|
|
3472
|
+
},
|
|
3473
|
+
name: "options.inlineAnnotations",
|
|
3474
|
+
type: "text"
|
|
3475
|
+
}
|
|
3476
|
+
]
|
|
3477
|
+
},
|
|
2667
3478
|
{
|
|
2668
3479
|
sectionTitle: { id: getTranslation("field.options.features"), defaultMessage: "Features" },
|
|
2669
3480
|
items: [
|
|
@@ -2740,33 +3551,46 @@ const index = {
|
|
|
2740
3551
|
intlLabel: { id: getTranslation("settings.link.configuration"), defaultMessage: "Configuration" },
|
|
2741
3552
|
to: `${PLUGIN_ID}/configuration`,
|
|
2742
3553
|
permissions: PERMISSIONS.settingsRead,
|
|
2743
|
-
Component: () => Promise.resolve().then(() => require("./ConfigurationPage-
|
|
3554
|
+
Component: () => Promise.resolve().then(() => require("./ConfigurationPage-DefuBeYO.js"))
|
|
2744
3555
|
},
|
|
2745
3556
|
{
|
|
2746
3557
|
id: `${PLUGIN_ID}-custom-blocks`,
|
|
2747
3558
|
intlLabel: { id: getTranslation("settings.link.customBlocks"), defaultMessage: "Custom blocks" },
|
|
2748
3559
|
to: `${PLUGIN_ID}/custom-blocks`,
|
|
2749
3560
|
permissions: PERMISSIONS.customBlocksManage,
|
|
2750
|
-
Component: () => Promise.resolve().then(() => require("./CustomBlocksPage-
|
|
3561
|
+
Component: () => Promise.resolve().then(() => require("./CustomBlocksPage-Dg2rM3F4.js"))
|
|
2751
3562
|
},
|
|
2752
3563
|
{
|
|
2753
3564
|
id: `${PLUGIN_ID}-templates`,
|
|
2754
3565
|
intlLabel: { id: getTranslation("settings.link.templates"), defaultMessage: "Templates" },
|
|
2755
3566
|
to: `${PLUGIN_ID}/templates`,
|
|
2756
3567
|
permissions: PERMISSIONS.templatesManage,
|
|
2757
|
-
Component: () => Promise.resolve().then(() => require("./TemplatesPage-
|
|
3568
|
+
Component: () => Promise.resolve().then(() => require("./TemplatesPage-dx4_yd_t.js"))
|
|
2758
3569
|
},
|
|
2759
3570
|
{
|
|
2760
3571
|
id: `${PLUGIN_ID}-audit`,
|
|
2761
3572
|
intlLabel: { id: getTranslation("settings.link.audit"), defaultMessage: "Audit trail" },
|
|
2762
3573
|
to: `${PLUGIN_ID}/audit`,
|
|
2763
3574
|
permissions: PERMISSIONS.auditRead,
|
|
2764
|
-
Component: () => Promise.resolve().then(() => require("./AuditPage-
|
|
3575
|
+
Component: () => Promise.resolve().then(() => require("./AuditPage-iQzpjH8H.js"))
|
|
2765
3576
|
}
|
|
2766
3577
|
]
|
|
2767
3578
|
);
|
|
3579
|
+
if (typeof app.addMiddlewares === "function")
|
|
3580
|
+
app.addMiddlewares([
|
|
3581
|
+
createLogoutMiddleware({ onLogout: () => clearDrafts() }),
|
|
3582
|
+
createSessionMiddleware
|
|
3583
|
+
]);
|
|
2768
3584
|
},
|
|
2769
|
-
|
|
3585
|
+
/**
|
|
3586
|
+
* 2.5: the one Magic Editor X side panel of the Content Manager edit view (presence, comments,
|
|
3587
|
+
* quality). Other features add a section to `components/EntryPanel/sections.jsx`, never a panel.
|
|
3588
|
+
* @param {object} app - Strapi admin app.
|
|
3589
|
+
*/
|
|
3590
|
+
bootstrap(app) {
|
|
3591
|
+
const contentManager = app.getPlugin && app.getPlugin("content-manager");
|
|
3592
|
+
const apis = contentManager && contentManager.apis;
|
|
3593
|
+
if (apis && typeof apis.addEditViewSidePanel === "function") apis.addEditViewSidePanel([EntryPanel]);
|
|
2770
3594
|
},
|
|
2771
3595
|
/**
|
|
2772
3596
|
* @param {{ locales: string[] }} options - Admin locales.
|
|
@@ -2784,13 +3608,21 @@ const index = {
|
|
|
2784
3608
|
);
|
|
2785
3609
|
}
|
|
2786
3610
|
};
|
|
3611
|
+
exports.ANNOTATION_ATTRIBUTE = ANNOTATION_ATTRIBUTE;
|
|
3612
|
+
exports.ANNOTATION_KEY = ANNOTATION_KEY;
|
|
3613
|
+
exports.ANNOTATION_NAME = ANNOTATION_NAME;
|
|
3614
|
+
exports.ANNOTATION_VALUE_PREFIX = ANNOTATION_VALUE_PREFIX;
|
|
2787
3615
|
exports.BLOCK_POLICIES = BLOCK_POLICIES;
|
|
2788
3616
|
exports.BUILT_IN_MARKER = BUILT_IN_MARKER;
|
|
2789
3617
|
exports.BUILT_IN_MARKER_VERSION = BUILT_IN_MARKER_VERSION;
|
|
3618
|
+
exports.COLOR_ATTRIBUTE = COLOR_ATTRIBUTE;
|
|
3619
|
+
exports.DRAFT_WRITE_DELAY_MS = DRAFT_WRITE_DELAY_MS;
|
|
2790
3620
|
exports.EDITOR_DATA_LIMITS = EDITOR_DATA_LIMITS;
|
|
2791
3621
|
exports.FOOTNOTE_ATTRIBUTES = FOOTNOTE_ATTRIBUTES;
|
|
2792
3622
|
exports.FOOTNOTE_ID = FOOTNOTE_ID;
|
|
3623
|
+
exports.HIGHLIGHT_ATTRIBUTE = HIGHLIGHT_ATTRIBUTE;
|
|
2793
3624
|
exports.ICONS = ICONS;
|
|
3625
|
+
exports.IDLE_AFTER_MS = IDLE_AFTER_MS;
|
|
2794
3626
|
exports.INTERNAL_LINK_ATTRIBUTES = INTERNAL_LINK_ATTRIBUTES;
|
|
2795
3627
|
exports.LINK_SCHEMES = LINK_SCHEMES;
|
|
2796
3628
|
exports.MARKED_BLOCKS = MARKED_BLOCKS;
|
|
@@ -2808,36 +3640,53 @@ exports.TABLE_LIMITS = TABLE_LIMITS;
|
|
|
2808
3640
|
exports.TAG_NAME = TAG_NAME;
|
|
2809
3641
|
exports.TRACK_KINDS = TRACK_KINDS;
|
|
2810
3642
|
exports.VOID_TAGS = VOID_TAGS;
|
|
3643
|
+
exports.abbreviationAnnotation = abbreviationAnnotation;
|
|
3644
|
+
exports.activeAnnotations = activeAnnotations;
|
|
2811
3645
|
exports.activeBlocks = activeBlocks;
|
|
3646
|
+
exports.annotationsFromSummaries = annotationsFromSummaries;
|
|
2812
3647
|
exports.basePathOf = basePathOf;
|
|
3648
|
+
exports.bufferAction = bufferAction;
|
|
2813
3649
|
exports.buildCodeBlockTools = buildCodeBlockTools;
|
|
3650
|
+
exports.buildDraftRecord = buildDraftRecord;
|
|
2814
3651
|
exports.button = button;
|
|
2815
3652
|
exports.byteLength = byteLength;
|
|
2816
3653
|
exports.canMergeRect = canMergeRect;
|
|
2817
3654
|
exports.canonicalInlineExtras = canonicalInlineExtras;
|
|
3655
|
+
exports.cleanAnnotationAttributes = cleanAnnotationAttributes;
|
|
2818
3656
|
exports.cleanCodeFilename = cleanCodeFilename;
|
|
2819
3657
|
exports.cleanFocalPoint = cleanFocalPoint;
|
|
2820
3658
|
exports.cleanMediaFile = cleanMediaFile;
|
|
2821
3659
|
exports.cleanTableAlign = cleanTableAlign;
|
|
2822
3660
|
exports.cloneJsonSafe = cloneJsonSafe;
|
|
2823
3661
|
exports.codeBlocks = codeBlocks;
|
|
3662
|
+
exports.colorClass = colorClass;
|
|
2824
3663
|
exports.compileBlockList = compileBlockList;
|
|
2825
3664
|
exports.computeStats = computeStats;
|
|
2826
3665
|
exports.createFieldKey = createFieldKey;
|
|
3666
|
+
exports.createTabId = createTabId;
|
|
2827
3667
|
exports.decodeEntities = decodeEntities;
|
|
2828
3668
|
exports.deleteColumn = deleteColumn;
|
|
3669
|
+
exports.deleteDraft = deleteDraft;
|
|
2829
3670
|
exports.deleteRow = deleteRow;
|
|
3671
|
+
exports.draftIdentity = draftIdentity;
|
|
2830
3672
|
exports.editable = editable;
|
|
2831
3673
|
exports.el = el;
|
|
2832
3674
|
exports.el$1 = el$1;
|
|
3675
|
+
exports.entryPath = entryPath;
|
|
2833
3676
|
exports.escapeHtml = escapeHtml$1;
|
|
2834
3677
|
exports.escapeHtml$1 = escapeHtml;
|
|
2835
3678
|
exports.expandRect = expandRect;
|
|
2836
3679
|
exports.field = field;
|
|
3680
|
+
exports.fieldIdentity = fieldIdentity;
|
|
3681
|
+
exports.fieldProblems = fieldProblems;
|
|
3682
|
+
exports.fieldsWith = fieldsWith;
|
|
2837
3683
|
exports.fromTableModel = fromTableModel;
|
|
3684
|
+
exports.getDraft = getDraft;
|
|
2838
3685
|
exports.getTranslation = getTranslation;
|
|
3686
|
+
exports.hasPalette = hasPalette;
|
|
2839
3687
|
exports.hashString = hashString;
|
|
2840
3688
|
exports.headerKind = headerKind;
|
|
3689
|
+
exports.highlightClass = highlightClass;
|
|
2841
3690
|
exports.index = index;
|
|
2842
3691
|
exports.inlineNodesToRender = inlineNodesToRender;
|
|
2843
3692
|
exports.inlineToHtml = inlineToHtml;
|
|
@@ -2848,7 +3697,11 @@ exports.insertColumn = insertColumn;
|
|
|
2848
3697
|
exports.insertRow = insertRow;
|
|
2849
3698
|
exports.isBlankInlineHtml = isBlankInlineHtml;
|
|
2850
3699
|
exports.isBuiltInBlock = isBuiltInBlock;
|
|
3700
|
+
exports.isColorNode = isColorNode;
|
|
2851
3701
|
exports.isFootnoteNode = isFootnoteNode;
|
|
3702
|
+
exports.isHexColor = isHexColor;
|
|
3703
|
+
exports.isHighlightNode = isHighlightNode;
|
|
3704
|
+
exports.isLoggedOut = isLoggedOut;
|
|
2852
3705
|
exports.isMathNode = isMathNode;
|
|
2853
3706
|
exports.isPlainObject = isPlainObject;
|
|
2854
3707
|
exports.isPositionalFieldPath = isPositionalFieldPath;
|
|
@@ -2859,24 +3712,32 @@ exports.mergeCodeBlocks = mergeCodeBlocks;
|
|
|
2859
3712
|
exports.mergeMap = mergeMap;
|
|
2860
3713
|
exports.mergeRect = mergeRect;
|
|
2861
3714
|
exports.neighbourRect = neighbourRect;
|
|
3715
|
+
exports.nextDelay = nextDelay;
|
|
2862
3716
|
exports.nodesTextContent = nodesTextContent;
|
|
2863
3717
|
exports.nodesToHtml = nodesToHtml;
|
|
2864
3718
|
exports.nodesToText = nodesToText;
|
|
2865
3719
|
exports.normalizeEditorDataSafe = normalizeEditorDataSafe;
|
|
2866
3720
|
exports.normalizeMerges = normalizeMerges;
|
|
3721
|
+
exports.normalizePalette = normalizePalette;
|
|
3722
|
+
exports.paletteCss = paletteCss;
|
|
2867
3723
|
exports.parseInline = parseInline;
|
|
2868
3724
|
exports.parseTabularText = parseTabularText;
|
|
2869
3725
|
exports.pasteGrid = pasteGrid;
|
|
2870
3726
|
exports.prepareEditorValue = prepareEditorValue;
|
|
2871
3727
|
exports.prepareRemoteData = prepareRemoteData;
|
|
3728
|
+
exports.pruneDrafts = pruneDrafts;
|
|
3729
|
+
exports.putDraft = putDraft;
|
|
2872
3730
|
exports.registeredBlockOf = registeredBlockOf;
|
|
3731
|
+
exports.relativeTimeOf = relativeTimeOf;
|
|
2873
3732
|
exports.resolveLinkAttributes = resolveLinkAttributes;
|
|
3733
|
+
exports.restoreDecision = restoreDecision;
|
|
2874
3734
|
exports.safeStyle = safeStyle;
|
|
2875
3735
|
exports.sanitizeInline = sanitizeInline;
|
|
2876
3736
|
exports.sanitizeSvg = sanitizeSvg;
|
|
2877
3737
|
exports.sanitizeTemplate = sanitizeTemplate;
|
|
2878
3738
|
exports.sanitizeTunes = sanitizeTunes;
|
|
2879
3739
|
exports.sanitizeUrl = sanitizeUrl;
|
|
3740
|
+
exports.savedValueOf = savedValueOf;
|
|
2880
3741
|
exports.select = select;
|
|
2881
3742
|
exports.serializeNodes = serializeNodes;
|
|
2882
3743
|
exports.setColumnAlign = setColumnAlign;
|
|
@@ -2887,4 +3748,6 @@ exports.tableLayout = tableLayout;
|
|
|
2887
3748
|
exports.textNode = textNode;
|
|
2888
3749
|
exports.toNodes = toNodes;
|
|
2889
3750
|
exports.toTableModel = toTableModel;
|
|
3751
|
+
exports.tokenLabel = tokenLabel;
|
|
3752
|
+
exports.ttlMsOf = ttlMsOf;
|
|
2890
3753
|
exports.walkInlineElements = walkInlineElements;
|