xmlui 0.9.36 → 0.9.37
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/dist/lib/{apiInterceptorWorker-CWN1iwsH.mjs → apiInterceptorWorker-5JLbCSKz.mjs} +1 -1
- package/dist/lib/{index-BmTqBdiA.mjs → index-qQpSddXH.mjs} +137 -83
- package/dist/lib/index.css +46 -47
- package/dist/lib/language-server-web-worker.mjs +1 -1
- package/dist/lib/language-server.mjs +1 -1
- package/dist/lib/{server-common-B7iKLsag.mjs → server-common-D9McswSL.mjs} +2587 -2492
- package/dist/lib/xmlui.mjs +1 -1
- package/dist/metadata/style.css +46 -47
- package/dist/metadata/xmlui-metadata.mjs +36 -30
- package/dist/metadata/xmlui-metadata.umd.js +36 -30
- package/dist/scripts/package.json +2 -2
- package/dist/scripts/src/components/Markdown/Markdown.js +10 -3
- package/dist/scripts/src/components/Markdown/MarkdownNative.js +109 -47
- package/dist/scripts/src/components/NavGroup/NavGroup.js +1 -1
- package/dist/scripts/src/components/Text/Text.js +1 -0
- package/dist/standalone/xmlui-standalone.umd.js +185 -132
- package/package.json +2 -2
|
@@ -45,22 +45,11 @@ function PreTagComponent({ id, children, codeHighlighter }) {
|
|
|
45
45
|
}
|
|
46
46
|
return ((0, jsx_runtime_1.jsx)(CodeBlockNative_1.CodeBlock, { meta: highlighterResult.meta, textToCopy: highlighterResult.codeStr, children: (0, jsx_runtime_1.jsx)(TextNative_1.Text, { uid: id, variant: "codefence", syntaxHighlightClasses: highlighterResult.classNames, dangerouslySetInnerHTML: { __html: highlighterResult.cleanedHtmlStr } }) }));
|
|
47
47
|
}
|
|
48
|
-
exports.Markdown = (0, react_1.memo)(function Markdown({ removeIndents = true, children, style, codeHighlighter, }) {
|
|
48
|
+
exports.Markdown = (0, react_1.memo)(function Markdown({ removeIndents = true, children, style, codeHighlighter, showHeadingAnchors = false, }) {
|
|
49
49
|
if (typeof children !== "string") {
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
52
|
children = removeIndents ? removeTextIndents(children) : children;
|
|
53
|
-
const renderHeading = (level, children) => {
|
|
54
|
-
if (typeof children === "string") {
|
|
55
|
-
const [headingLabel, anchorId] = getCustomAnchor(children);
|
|
56
|
-
if (anchorId) {
|
|
57
|
-
const currentPath = window.location.href.replace(/(?<!\/)#.*$/, "");
|
|
58
|
-
const href = `${currentPath}#${anchorId}`;
|
|
59
|
-
return ((0, jsx_runtime_1.jsxs)(HeadingNative_1.Heading, { level: level, id: anchorId, children: [headingLabel, (0, jsx_runtime_1.jsx)("a", { href: href, id: anchorId, "aria-label": "Permalink for this section", children: "#" })] }));
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return (0, jsx_runtime_1.jsx)(HeadingNative_1.Heading, { level: level, children: children });
|
|
63
|
-
};
|
|
64
53
|
return ((0, jsx_runtime_1.jsx)("div", { className: Markdown_module_scss_1.default.markdownContent, style: Object.assign({}, style), children: (0, jsx_runtime_1.jsx)(react_markdown_1.MarkdownHooks, { remarkPlugins: [remark_gfm_1.default, CodeBlockNative_1.markdownCodeBlockParser], rehypePlugins: [rehype_raw_1.default], components: {
|
|
65
54
|
details(_a) {
|
|
66
55
|
var { children, node } = _a, props = __rest(_a, ["children", "node"]);
|
|
@@ -82,22 +71,22 @@ exports.Markdown = (0, react_1.memo)(function Markdown({ removeIndents = true, c
|
|
|
82
71
|
}
|
|
83
72
|
},
|
|
84
73
|
h1({ children }) {
|
|
85
|
-
return
|
|
74
|
+
return ((0, jsx_runtime_1.jsx)(LinkAwareHeading, { level: "h1", showHeadingAnchors: showHeadingAnchors, children: children }));
|
|
86
75
|
},
|
|
87
76
|
h2({ children }) {
|
|
88
|
-
return
|
|
77
|
+
return ((0, jsx_runtime_1.jsx)(LinkAwareHeading, { level: "h2", showHeadingAnchors: showHeadingAnchors, children: children }));
|
|
89
78
|
},
|
|
90
79
|
h3({ children }) {
|
|
91
|
-
return
|
|
80
|
+
return ((0, jsx_runtime_1.jsx)(LinkAwareHeading, { level: "h3", showHeadingAnchors: showHeadingAnchors, children: children }));
|
|
92
81
|
},
|
|
93
82
|
h4({ children }) {
|
|
94
|
-
return
|
|
83
|
+
return ((0, jsx_runtime_1.jsx)(LinkAwareHeading, { level: "h4", showHeadingAnchors: showHeadingAnchors, children: children }));
|
|
95
84
|
},
|
|
96
85
|
h5({ children }) {
|
|
97
|
-
return
|
|
86
|
+
return ((0, jsx_runtime_1.jsx)(LinkAwareHeading, { level: "h5", showHeadingAnchors: showHeadingAnchors, children: children }));
|
|
98
87
|
},
|
|
99
88
|
h6({ children }) {
|
|
100
|
-
return
|
|
89
|
+
return ((0, jsx_runtime_1.jsx)(LinkAwareHeading, { level: "h6", showHeadingAnchors: showHeadingAnchors, children: children }));
|
|
101
90
|
},
|
|
102
91
|
p({ id, children }) {
|
|
103
92
|
return ((0, jsx_runtime_1.jsx)(TextNative_1.Text, { uid: id, variant: "markdown", children: children }));
|
|
@@ -177,35 +166,6 @@ exports.Markdown = (0, react_1.memo)(function Markdown({ removeIndents = true, c
|
|
|
177
166
|
},
|
|
178
167
|
}, children: children }) }));
|
|
179
168
|
});
|
|
180
|
-
function removeTextIndents(input) {
|
|
181
|
-
if (!input) {
|
|
182
|
-
return "";
|
|
183
|
-
}
|
|
184
|
-
const lines = input.split("\n");
|
|
185
|
-
// Find the shortest starting whitespace length
|
|
186
|
-
const minIndent = lines.reduce((min, line) => {
|
|
187
|
-
const match = line.match(/^\s*/);
|
|
188
|
-
const indentLength = match ? match[0].length : 0;
|
|
189
|
-
return line.trim() ? Math.min(min, indentLength) : min;
|
|
190
|
-
}, Infinity);
|
|
191
|
-
// Remove the shortest starting whitespace length from each line
|
|
192
|
-
const trimmedLines = lines.map((line) => line.startsWith(" ".repeat(minIndent)) ? line.slice(minIndent) : line);
|
|
193
|
-
return trimmedLines.join("\n");
|
|
194
|
-
}
|
|
195
|
-
function getCustomAnchor(value) {
|
|
196
|
-
if (!value) {
|
|
197
|
-
return ["", ""];
|
|
198
|
-
}
|
|
199
|
-
// --- Match the pattern: "Heading text [#anchor]"
|
|
200
|
-
const match = value.match(/^(.*?)\s*\[#([^\]]+)\]$/);
|
|
201
|
-
if (match) {
|
|
202
|
-
const headingLabel = match[1].trim(); // Extract the heading text
|
|
203
|
-
const anchorId = match[2].trim(); // Extract the anchor ID
|
|
204
|
-
return [headingLabel, anchorId];
|
|
205
|
-
}
|
|
206
|
-
// If no match, return the full value as the heading label and an empty anchor ID
|
|
207
|
-
return [value.trim(), ""];
|
|
208
|
-
}
|
|
209
169
|
const HorizontalRule = () => {
|
|
210
170
|
return (0, jsx_runtime_1.jsx)("hr", { className: Markdown_module_scss_1.default.horizontalRule });
|
|
211
171
|
};
|
|
@@ -282,3 +242,105 @@ const OrderedList = ({ children, style }) => {
|
|
|
282
242
|
const ListItem = ({ children, style }) => {
|
|
283
243
|
return ((0, jsx_runtime_1.jsx)("li", { className: Markdown_module_scss_1.default.listItem, style: style, children: children }));
|
|
284
244
|
};
|
|
245
|
+
function LinkAwareHeading({ children, level, showHeadingAnchors }) {
|
|
246
|
+
let headingLabel = "";
|
|
247
|
+
let anchorId = "";
|
|
248
|
+
if (!children)
|
|
249
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
250
|
+
if (typeof children === "string") {
|
|
251
|
+
[headingLabel, anchorId] = getCustomAnchor(children);
|
|
252
|
+
// At this point, the anchorId might still be empty
|
|
253
|
+
}
|
|
254
|
+
else if (Array.isArray(children)) {
|
|
255
|
+
if (children.length === 0)
|
|
256
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
257
|
+
if (children.length === 1) {
|
|
258
|
+
headingLabel = children[0];
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
headingLabel = children.slice(0, -1);
|
|
262
|
+
const last = children[children.length - 1];
|
|
263
|
+
// Check for explicit anchor at the end
|
|
264
|
+
if (typeof last === "string") {
|
|
265
|
+
const match = last.trim().match(/^\[#([^\]]+)\]$/);
|
|
266
|
+
if (match && match.length > 0) {
|
|
267
|
+
anchorId = match[1];
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
// Provided children are not a string or array but still valid React elements
|
|
274
|
+
// if it contains text, use it as the heading label
|
|
275
|
+
const headingContent = extractTextNodes(children);
|
|
276
|
+
if (!headingContent)
|
|
277
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
278
|
+
headingLabel = children;
|
|
279
|
+
}
|
|
280
|
+
// Generate implicit anchor if not provided
|
|
281
|
+
if (!anchorId) {
|
|
282
|
+
anchorId = headingToAnchorLink(extractTextNodes(headingLabel));
|
|
283
|
+
}
|
|
284
|
+
const currentPath = window.location.href.replace(/(?<!\/)#.*$/, "");
|
|
285
|
+
const href = `${currentPath}#${anchorId}`;
|
|
286
|
+
return ((0, jsx_runtime_1.jsxs)(HeadingNative_1.Heading, { level: level, id: anchorId, children: [headingLabel, showHeadingAnchors && anchorId && (
|
|
287
|
+
// NOTE: Anchor is hidden from screen readers
|
|
288
|
+
// TODO: make sure this is a good idea
|
|
289
|
+
(0, jsx_runtime_1.jsx)("a", { href: href, id: anchorId, "aria-hidden": "true", children: "#" }))] }));
|
|
290
|
+
}
|
|
291
|
+
// --- Helper functions
|
|
292
|
+
function removeTextIndents(input) {
|
|
293
|
+
if (!input) {
|
|
294
|
+
return "";
|
|
295
|
+
}
|
|
296
|
+
const lines = input.split("\n");
|
|
297
|
+
// Find the shortest starting whitespace length
|
|
298
|
+
const minIndent = lines.reduce((min, line) => {
|
|
299
|
+
const match = line.match(/^\s*/);
|
|
300
|
+
const indentLength = match ? match[0].length : 0;
|
|
301
|
+
return line.trim() ? Math.min(min, indentLength) : min;
|
|
302
|
+
}, Infinity);
|
|
303
|
+
// Remove the shortest starting whitespace length from each line
|
|
304
|
+
const trimmedLines = lines.map((line) => line.startsWith(" ".repeat(minIndent)) ? line.slice(minIndent) : line);
|
|
305
|
+
return trimmedLines.join("\n");
|
|
306
|
+
}
|
|
307
|
+
function getCustomAnchor(value) {
|
|
308
|
+
if (!value) {
|
|
309
|
+
return ["", ""];
|
|
310
|
+
}
|
|
311
|
+
// --- Match the pattern: "Heading text [#anchor]"
|
|
312
|
+
const match = value.match(/^(.*?)\s*\[#([^\]]+)\]$/);
|
|
313
|
+
if (match) {
|
|
314
|
+
const headingLabel = match[1].trim(); // Extract the heading text
|
|
315
|
+
const anchorId = match[2].trim(); // Extract the anchor ID
|
|
316
|
+
return [headingLabel, anchorId];
|
|
317
|
+
}
|
|
318
|
+
// If no match, return the full value as the heading label and an empty anchor ID
|
|
319
|
+
return [value.trim(), ""];
|
|
320
|
+
}
|
|
321
|
+
function headingToAnchorLink(rawStr) {
|
|
322
|
+
return (rawStr
|
|
323
|
+
.trim()
|
|
324
|
+
.toLocaleLowerCase()
|
|
325
|
+
// replace all non-alphanumeric characters with hyphens
|
|
326
|
+
.replaceAll(/[^A-Za-z0-9-]/g, "-")
|
|
327
|
+
// remove multiple hyphens
|
|
328
|
+
.replaceAll(/--+/g, "-")
|
|
329
|
+
// remove leading and trailing hyphens
|
|
330
|
+
.replace(/^-|-$/, "")
|
|
331
|
+
// remove backticks
|
|
332
|
+
.replace(/`/g, "")
|
|
333
|
+
// remove parentheses
|
|
334
|
+
.replace(/"|'/g, ""));
|
|
335
|
+
}
|
|
336
|
+
function extractTextNodes(node) {
|
|
337
|
+
if (typeof node === "string" || typeof node === "number")
|
|
338
|
+
return node.toString();
|
|
339
|
+
if (react_2.default.isValidElement(node) && node.props && node.props.children) {
|
|
340
|
+
if (Array.isArray(node.props.children)) {
|
|
341
|
+
return node.props.children.map(extractTextNodes).join("");
|
|
342
|
+
}
|
|
343
|
+
return extractTextNodes(node.props.children);
|
|
344
|
+
}
|
|
345
|
+
return "";
|
|
346
|
+
}
|
|
@@ -63,5 +63,5 @@ exports.NavGroupMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
63
63
|
});
|
|
64
64
|
exports.navGroupComponentRenderer = (0, renderers_1.createComponentRenderer)(COMP, exports.NavGroupMd, ({ node, extractValue, renderChild }) => {
|
|
65
65
|
var _a;
|
|
66
|
-
return ((0, jsx_runtime_1.jsx)(NavGroupNative_1.NavGroup, { label: extractValue.asDisplayText(node.props.label), disabled: !extractValue.asOptionalBoolean((_a = node.props.enabled) !== null && _a !== void 0 ? _a : true), to: extractValue.asOptionalString(node.props.to), icon: (0, jsx_runtime_1.jsx)(IconNative_1.Icon, { name: extractValue.asString(node.props.icon), className: NavLink_module_scss_1.default.icon }), node: node, initiallyExpanded: extractValue.
|
|
66
|
+
return ((0, jsx_runtime_1.jsx)(NavGroupNative_1.NavGroup, { label: extractValue.asDisplayText(node.props.label), disabled: !extractValue.asOptionalBoolean((_a = node.props.enabled) !== null && _a !== void 0 ? _a : true), to: extractValue.asOptionalString(node.props.to), icon: (0, jsx_runtime_1.jsx)(IconNative_1.Icon, { name: extractValue.asString(node.props.icon), className: NavLink_module_scss_1.default.icon }), node: node, initiallyExpanded: extractValue.asOptionalBoolean(node.props.initiallyExpanded), renderChild: renderChild, iconHorizontalExpanded: extractValue.asOptionalString(node.props.iconHorizontalExpanded), iconVerticalExpanded: extractValue.asOptionalString(node.props.iconVerticalExpanded), iconHorizontalCollapsed: extractValue.asOptionalString(node.props.iconHorizontalCollapsed), iconVerticalCollapsed: extractValue.asOptionalString(node.props.iconVerticalCollapsed) }));
|
|
67
67
|
});
|
|
@@ -63,6 +63,7 @@ exports.TextMd = (0, ComponentDefs_1.createMetadata)({
|
|
|
63
63
|
[`textColor-${COMP}`]: "$textColor-primary",
|
|
64
64
|
[`fontFamily-${COMP}`]: "$fontFamily",
|
|
65
65
|
[`fontWeight-${COMP}`]: "$fontWeight-normal",
|
|
66
|
+
[`fontSize-${COMP}-codefence`]: "$fontSize-small",
|
|
66
67
|
[`fontFamily-${COMP}-code`]: "$fontFamily-monospace",
|
|
67
68
|
[`fontSize-${COMP}-code`]: "$fontSize-small",
|
|
68
69
|
[`borderWidth-${COMP}-code`]: "1px",
|