@scalio-cloud/ui 0.72.0 → 0.74.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/README.md +17 -0
- package/nav.css +6 -2
- package/package.json +1 -1
- package/react/ai.js +27 -7
- package/react/auth.js +5 -3
- package/react/index.js +10 -3
- package/react/labels.js +4 -0
- package/react/markdown.js +23 -7
- package/shell.css +9 -0
package/README.md
CHANGED
|
@@ -149,6 +149,10 @@ Texts are built in for `lang` `de` and `en` and can be overridden with `labels`.
|
|
|
149
149
|
`TEST_IDS`. The components are plain CommonJS with `React.createElement`, so CRA, Vite and Jest need no extra config.
|
|
150
150
|
Icons are inline (Lucide, ISC, see `licenses/`).
|
|
151
151
|
|
|
152
|
+
**Beta (ADR 0117 in scalio-docs):** apps sold as public beta (version 0.x) set `beta: true` in the brand object, in
|
|
153
|
+
the header (`AppHeader`) and on every sign-in page (`AuthLayout`). Both then show «Beta» next to the product name
|
|
154
|
+
(`BetaBadge`, hint on hover). Keep one brand object per app, so no page is missed, and remove the flag with 1.0.
|
|
155
|
+
|
|
152
156
|
## Sidebar, switcher and page blocks (React)
|
|
153
157
|
|
|
154
158
|
Every app has the same frame (UISPEC "Navigation"): switcher, header with the context select on the left, then
|
|
@@ -670,6 +674,16 @@ shows `AiCredits` (bar, warning from 80 %, note at 100 %). `AiHelp` is «Frag Sc
|
|
|
670
674
|
whose `onAsk` returns `{text, sources: [{title, source, url}]}`; `AiPanel` shows such sources too. Test IDs
|
|
671
675
|
`ai-scalio`, `ai-credits`, `ai-credits-text`, `ai-credits-note`, `ai-help`, `ai-help-sources-<n>`.
|
|
672
676
|
|
|
677
|
+
Since 0.73.0 (BL-332, scalio-infra #757) `AiSuggestion` (the `text`) and `AiPanel`/`AiHelp` (the answers) show
|
|
678
|
+
AI text as safe Markdown, no longer as raw text with `##`, `**` and backticks: headings, bold, italic, lists, inline
|
|
679
|
+
code and code blocks, paragraphs, tables and callouts. The text is parsed into React elements (the `Markdown` block
|
|
680
|
+
with `links="https"` and `anchors={false}`), never HTML: `<script>`, `<img onerror>` and other HTML stay visible as
|
|
681
|
+
text; links work only with `https://` (no `javascript:`, `data:`, `http:`, `mailto:` or relative addresses); images
|
|
682
|
+
stay text; headings get no id. Questions and error messages stay plain text. `format="text"` on `AiSuggestion` or
|
|
683
|
+
`AiPanel` keeps the old display (text as it is, line breaks kept). `AiText` shows any AI text the same way:
|
|
684
|
+
`<AiText text={answer} lang={lang} testId="explain-text" />` (`format`, `className`). Source links (`sources[].url`)
|
|
685
|
+
work only with https or a path of the app (`/help/...`), else only the title is shown.
|
|
686
|
+
|
|
673
687
|
## Benachrichtigungen: E-Mail-Versand und E-Mail-Vorlagen (React)
|
|
674
688
|
|
|
675
689
|
Since 0.29.0 (ADR 0069 W5) every app sends mail the same way. The server side is scalio-platform 0.8.0 `mail`
|
|
@@ -749,6 +763,9 @@ markdownOutline(page.body) // [{ level, text, id }] for a table of contents; h
|
|
|
749
763
|
`labels` overrides the callout titles (`{ note, tip, important, warning, caution }`). Also exported:
|
|
750
764
|
`parseMarkdownBlocks`, `parseMarkdownInline`, `markdownHeadingId`, `safeHref`. Test IDs: `callout-<kind>`.
|
|
751
765
|
|
|
766
|
+
From 0.73.0: `links="https"` makes only https addresses links (images stay text) and `anchors={false}` leaves the
|
|
767
|
+
headings without an id; `AiText` uses both for AI text. Also exported: `safeHttpsHref`.
|
|
768
|
+
|
|
752
769
|
From 0.70.0: `pageLinks` reads `[[Title]]`, `[[KEY:Title]]` and `[[Title|text]]` as page links (shown as text with a
|
|
753
770
|
dotted line, `.scalio-md-pagelink`, unless the app renders them). `render={{ image, link, pagelink }}` puts the app's
|
|
754
771
|
own elements in: `image(node, key)`, `link(node, key, children)`, `pagelink(node, key)`; a function that returns
|
package/nav.css
CHANGED
|
@@ -910,7 +910,11 @@ ul.scalio-notice { flex-direction: column; gap: 0.25rem; padding-left: 2rem; lis
|
|
|
910
910
|
.dark .scalio-ai-badge, .dark .scalio-ai-btn .scalio-icon { color: #8ba6f7; }
|
|
911
911
|
.scalio-ai-suggestion { display: flex; flex-direction: column; gap: 0.5rem; padding: 0.875rem 1rem; border: 1px solid hsl(var(--primary) / 0.3); border-left-width: 3px; border-radius: var(--radius, 4px); background: hsl(var(--card)); }
|
|
912
912
|
.scalio-ai-suggestion-head { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; }
|
|
913
|
-
.scalio-ai-suggestion-text {
|
|
913
|
+
.scalio-ai-suggestion-text { font-size: 0.875rem; }
|
|
914
|
+
.scalio-ai-text.is-plain { white-space: pre-wrap; }
|
|
915
|
+
.scalio-ai-text.scalio-md > * + * { margin-top: 0.5rem; }
|
|
916
|
+
.scalio-ai-text .scalio-md-h1, .scalio-ai-text .scalio-md-h2 { font-size: 1rem; line-height: 1.5rem; padding-top: 0.25rem; }
|
|
917
|
+
.scalio-ai-text .scalio-md-h3, .scalio-ai-text .scalio-md-h4 { font-size: 0.875rem; padding-top: 0; }
|
|
914
918
|
.scalio-ai-suggestion-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
|
|
915
919
|
.scalio-ai-feature { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.5rem 0; }
|
|
916
920
|
.scalio-ai-feature + .scalio-ai-feature { border-top: 1px solid hsl(var(--border)); }
|
|
@@ -932,7 +936,7 @@ ul.scalio-notice { flex-direction: column; gap: 0.25rem; padding-left: 2rem; lis
|
|
|
932
936
|
.scalio-ai-turn { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.875rem; }
|
|
933
937
|
.scalio-ai-turn.is-user { align-self: flex-end; max-width: 85%; padding: 0.5rem 0.75rem; border-radius: var(--radius, 4px); background: hsl(var(--muted)); }
|
|
934
938
|
.scalio-ai-turn.is-error .scalio-ai-turn-text { color: hsl(var(--destructive)); }
|
|
935
|
-
.scalio-ai-turn-text { white-space: pre-wrap; }
|
|
939
|
+
.scalio-ai-turn-text:not(.scalio-md) { white-space: pre-wrap; }
|
|
936
940
|
.scalio-ai-panel-form { display: flex; gap: 0.5rem; align-items: flex-end; }
|
|
937
941
|
.scalio-ai-panel-form textarea { flex: 1; resize: vertical; }
|
|
938
942
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scalio-cloud/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.74.0",
|
|
4
4
|
"description": "Scalio Control Room design tokens, Tailwind preset, self-hosted fonts, the shared app header, sign-in layout, sidebar and page blocks",
|
|
5
5
|
"license": "SEE LICENSE IN README.md",
|
|
6
6
|
"private": false,
|
package/react/ai.js
CHANGED
|
@@ -6,11 +6,13 @@
|
|
|
6
6
|
// - AiBadge: marks text the AI wrote
|
|
7
7
|
// - AiSuggestion: a proposal with reason and source; «Übernehmen», «Bearbeiten», «Verwerfen» (never runs by itself)
|
|
8
8
|
// - AiPanel: side panel «Assistent» with the context of the open page
|
|
9
|
+
// - AiText: a text of the AI as safe Markdown (React elements, never HTML; links only https); format="text" as is
|
|
9
10
|
const React = require("react");
|
|
10
11
|
const h = React.createElement;
|
|
11
12
|
const Icons = require("./icons");
|
|
12
13
|
const { SettingsSection, SettingsField: Field, SettingsRow } = require("./settings");
|
|
13
14
|
const { askConfirm } = require("./dialog");
|
|
15
|
+
const { Markdown, safeHref } = require("./markdown");
|
|
14
16
|
|
|
15
17
|
const PROVIDERS = ["scalio", "openai", "anthropic", "gemini", "ollama"];
|
|
16
18
|
const KEY_PROVIDERS = ["openai", "anthropic", "gemini"];
|
|
@@ -381,7 +383,23 @@ function AiBadge(props) {
|
|
|
381
383
|
h(Icons.Sparkles, { className: "scalio-icon" }), L.badge);
|
|
382
384
|
}
|
|
383
385
|
|
|
384
|
-
//
|
|
386
|
+
// Text the AI wrote: Markdown with headings, bold, italic, lists, code and https links (BL-332, scalio-infra #757);
|
|
387
|
+
// no HTML from the text, no other links, no images, headings without an id. format="text": the text as it is.
|
|
388
|
+
function AiText(props) {
|
|
389
|
+
const cls = props.className ? ` ${props.className}` : "";
|
|
390
|
+
if (props.format === "text") return h("div", { className: `scalio-ai-text is-plain${cls}`, "data-testid": props.testId }, String(props.text ?? ""));
|
|
391
|
+
return h(Markdown, { text: String(props.text ?? ""), lang: props.lang, links: "https", anchors: false,
|
|
392
|
+
className: `scalio-ai-text${cls}`, testId: props.testId });
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
// A source link of an answer: https or a path of the app, else only its title.
|
|
396
|
+
function sourceHref(url) {
|
|
397
|
+
const href = safeHref(url);
|
|
398
|
+
return href && (/^https:\/\//i.test(href) || href.startsWith("/")) ? href : null;
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
// Props: suggestion ({title, text, reason, risk, source}), onAccept, onEdit, onReject (each optional), busy, lang, labels, testId,
|
|
402
|
+
// format ("markdown", default, or "text").
|
|
385
403
|
// The app runs its normal action in onAccept, with the person's rights and an audit entry (ADR 0111 K3).
|
|
386
404
|
function AiSuggestion(props) {
|
|
387
405
|
const L = labels(props.lang, props.labels);
|
|
@@ -394,7 +412,7 @@ function AiSuggestion(props) {
|
|
|
394
412
|
h("div", { className: "scalio-ai-suggestion-head" }, h(AiBadge, { lang: props.lang, labels: props.labels, testId: `${tid}-badge` }),
|
|
395
413
|
s.title ? h("strong", null, s.title) : null,
|
|
396
414
|
risk ? h("span", { className: `scalio-badge ${risk === "high" ? "is-error" : risk === "medium" ? "is-warn" : "is-ok"}`, "data-testid": `${tid}-risk` }, L.risk[risk]) : null),
|
|
397
|
-
s.text ? h(
|
|
415
|
+
s.text ? h(AiText, { text: s.text, format: props.format, lang: props.lang, className: "scalio-ai-suggestion-text", testId: `${tid}-text` }) : null,
|
|
398
416
|
s.reason ? h("div", { className: "scalio-settings-help" }, `${L.reason}: ${s.reason}`) : null,
|
|
399
417
|
s.source ? h("div", { className: "scalio-settings-help", "data-testid": `${tid}-source` }, `${L.source}: ${s.source}`) : null,
|
|
400
418
|
h("div", { className: "scalio-ai-suggestion-actions" },
|
|
@@ -402,7 +420,7 @@ function AiSuggestion(props) {
|
|
|
402
420
|
}
|
|
403
421
|
|
|
404
422
|
// Props: open, onClose, context (name of the open page or object), onAsk(question, history) -> Promise<string>,
|
|
405
|
-
// lang, labels, testId. History is kept while the panel lives; nothing is stored.
|
|
423
|
+
// lang, labels, testId, format ("markdown", default, or "text" for the answers). History is kept while the panel lives; nothing is stored.
|
|
406
424
|
function AiPanel(props) {
|
|
407
425
|
const L = labels(props.lang, props.labels);
|
|
408
426
|
const [turns, setTurns] = React.useState([]);
|
|
@@ -442,11 +460,13 @@ function AiPanel(props) {
|
|
|
442
460
|
h("div", { className: "scalio-ai-panel-turns", "aria-live": "polite", "data-testid": `${tid}-turns` },
|
|
443
461
|
turns.length ? turns.map((t, i) => h("div", { key: i, className: `scalio-ai-turn is-${t.role}${t.error ? " is-error" : ""}` },
|
|
444
462
|
t.role === "assistant" && !t.error ? h(AiBadge, { lang: props.lang, labels: props.labels, testId: `${tid}-badge-${i}` }) : null,
|
|
445
|
-
|
|
463
|
+
t.role === "assistant" && !t.error
|
|
464
|
+
? h(AiText, { text: t.content, format: props.format, lang: props.lang, className: "scalio-ai-turn-text" })
|
|
465
|
+
: h("div", { className: "scalio-ai-turn-text" }, t.content),
|
|
446
466
|
t.sources && t.sources.length ? h("div", { className: "scalio-ai-sources", "data-testid": `${tid}-sources-${i}` },
|
|
447
467
|
h("span", null, `${L.helpSources}: `),
|
|
448
|
-
t.sources.map((src, j) => h("span", { key: j, className: "scalio-ai-source" }, src.url
|
|
449
|
-
? h("a", { href: src.url, target: "_blank", rel: "noreferrer" }, src.title || src.source) : (src.title || src.source)))) : null))
|
|
468
|
+
t.sources.map((src, j) => h("span", { key: j, className: "scalio-ai-source" }, sourceHref(src.url)
|
|
469
|
+
? h("a", { href: sourceHref(src.url), target: "_blank", rel: "noopener noreferrer" }, src.title || src.source) : (src.title || src.source)))) : null))
|
|
450
470
|
: h("p", { className: "scalio-settings-help" }, props.emptyText || L.panelEmpty),
|
|
451
471
|
busy ? h("div", { className: "scalio-ai-turn is-assistant", "data-testid": `${tid}-busy` }, h("span", { className: "scalio-spinner", "aria-hidden": "true" }), L.working) : null),
|
|
452
472
|
h("form", { className: "scalio-ai-panel-form", onSubmit: ask },
|
|
@@ -462,4 +482,4 @@ function AiHelp(props) {
|
|
|
462
482
|
return h(AiPanel, Object.assign({ testId: "ai-help", title: L.helpTitle, emptyText: L.helpEmpty }, props));
|
|
463
483
|
}
|
|
464
484
|
|
|
465
|
-
module.exports = { AiSettingsPanel, AiHelp, AiCredits, AiButton, AiBadge, AiSuggestion, AiPanel, aiApi, aiForm, aiPatch, AI_LABELS: LABELS, AI_LEVELS: LEVELS };
|
|
485
|
+
module.exports = { AiSettingsPanel, AiHelp, AiCredits, AiButton, AiBadge, AiSuggestion, AiPanel, AiText, aiApi, aiForm, aiPatch, AI_LABELS: LABELS, AI_LEVELS: LEVELS };
|
package/react/auth.js
CHANGED
|
@@ -91,13 +91,13 @@ function DemoAccounts({ accounts, onPick, lang, labels, className, testId }) {
|
|
|
91
91
|
);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
// brand: { mark: "N", name: "Scalio Nexus", claim, eyebrow, features: [..], color }
|
|
94
|
+
// brand: { mark: "N", name: "Scalio Nexus", claim, eyebrow, features: [..], color, beta }
|
|
95
95
|
// version: shown small bottom left; left out = read from /version.json, false = hidden.
|
|
96
96
|
function AuthLayout(props) {
|
|
97
97
|
const brand = props.brand || {};
|
|
98
98
|
const L = labelsFor(props.lang, props.labels);
|
|
99
99
|
const words = String(brand.name || "").split(/\s+/).filter(Boolean);
|
|
100
|
-
const { LanguageToggle, ThemeToggle } = require("./index");
|
|
100
|
+
const { LanguageToggle, ThemeToggle, BetaBadge } = require("./index");
|
|
101
101
|
return h(
|
|
102
102
|
"div",
|
|
103
103
|
{ className: cx("scalio-auth", props.className), "data-testid": props.testId || "auth-layout" },
|
|
@@ -111,6 +111,7 @@ function AuthLayout(props) {
|
|
|
111
111
|
{ className: "scalio-auth-hero" },
|
|
112
112
|
h(BrandMark, { brand, className: "scalio-auth-mark-lg" }),
|
|
113
113
|
h("h1", { className: "scalio-auth-title" }, words.map((w, i) => h(React.Fragment, { key: i }, i ? h("br") : null, w))),
|
|
114
|
+
brand.beta ? h(BetaBadge, { lang: props.lang, labels: props.labels, className: "scalio-beta-lg", testId: "auth-beta-badge" }) : null,
|
|
114
115
|
brand.claim ? h("p", { className: "scalio-auth-claim" }, brand.claim) : null
|
|
115
116
|
),
|
|
116
117
|
brand.features && brand.features.length
|
|
@@ -140,7 +141,8 @@ function AuthLayout(props) {
|
|
|
140
141
|
"div",
|
|
141
142
|
{ className: "scalio-auth-mobile-brand" },
|
|
142
143
|
h(BrandMark, { brand }),
|
|
143
|
-
h("span", { className: "scalio-auth-mobile-name" }, brand.name)
|
|
144
|
+
h("span", { className: "scalio-auth-mobile-name" }, brand.name),
|
|
145
|
+
brand.beta ? h(BetaBadge, { lang: props.lang, labels: props.labels, testId: "auth-beta-badge-mobile" }) : null
|
|
144
146
|
),
|
|
145
147
|
props.children
|
|
146
148
|
)
|
package/react/index.js
CHANGED
|
@@ -274,7 +274,13 @@ function DocsButton({ href, lang, labels, testId }) {
|
|
|
274
274
|
);
|
|
275
275
|
}
|
|
276
276
|
|
|
277
|
-
|
|
277
|
+
// «Beta» next to the product name (ADR 0117): apps on 0.x set brand.beta, AppHeader and AuthLayout show it.
|
|
278
|
+
function BetaBadge({ lang, labels, testId, className }) {
|
|
279
|
+
const L = labelsFor(lang, labels);
|
|
280
|
+
return h("span", { className: cx("scalio-beta", className), title: L.betaHint, "data-testid": testId || "scalio-beta-badge" }, L.beta);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
function Brand({ brand, lang, labels }) {
|
|
278
284
|
if (!brand) return null;
|
|
279
285
|
if (React.isValidElement(brand)) return brand;
|
|
280
286
|
const inner = [
|
|
@@ -282,7 +288,7 @@ function Brand({ brand }) {
|
|
|
282
288
|
h(
|
|
283
289
|
"span",
|
|
284
290
|
{ key: "t", className: "scalio-brand-text" },
|
|
285
|
-
h("span", { className: "scalio-brand-line" }, h("span", { className: "scalio-brand-name" }, brand.name), brand.badges || null),
|
|
291
|
+
h("span", { className: "scalio-brand-line" }, h("span", { className: "scalio-brand-name" }, brand.name), brand.beta ? h(BetaBadge, { lang, labels }) : null, brand.badges || null),
|
|
286
292
|
brand.sub ? h("span", { className: "scalio-brand-sub" }, brand.sub) : null
|
|
287
293
|
),
|
|
288
294
|
];
|
|
@@ -311,7 +317,7 @@ function AppHeader(props) {
|
|
|
311
317
|
h(Icons.Menu, { className: "scalio-icon" })
|
|
312
318
|
)
|
|
313
319
|
: null,
|
|
314
|
-
h(Brand, { brand: props.brand }),
|
|
320
|
+
h(Brand, { brand: props.brand, lang: props.lang, labels: props.labels }),
|
|
315
321
|
props.left ? h("div", { className: "scalio-header-left" }, props.left) : null,
|
|
316
322
|
h("div", { className: "scalio-header-spacer" }),
|
|
317
323
|
props.actions ? h("div", { className: "scalio-header-actions" }, props.actions) : null,
|
|
@@ -364,6 +370,7 @@ const VersionTag = Nav.VersionTag;
|
|
|
364
370
|
|
|
365
371
|
module.exports = {
|
|
366
372
|
AppHeader,
|
|
373
|
+
BetaBadge,
|
|
367
374
|
UserMenu,
|
|
368
375
|
LanguageToggle,
|
|
369
376
|
ThemeToggle,
|
package/react/labels.js
CHANGED
|
@@ -129,6 +129,8 @@ const LABELS = {
|
|
|
129
129
|
comingSoon: "Bald verfügbar",
|
|
130
130
|
notSetUp: "Für diese Installation nicht eingerichtet",
|
|
131
131
|
stageHint: "Umgebung dieser Installation",
|
|
132
|
+
beta: "Beta",
|
|
133
|
+
betaHint: "Öffentliche Beta: Funktionen und Oberfläche können sich bis Version 1.0 noch ändern.",
|
|
132
134
|
// Support request
|
|
133
135
|
supportTitle: "Support-Anfrage",
|
|
134
136
|
subject: "Betreff",
|
|
@@ -700,6 +702,8 @@ const LABELS = {
|
|
|
700
702
|
comingSoon: "Coming soon",
|
|
701
703
|
notSetUp: "Not set up for this installation",
|
|
702
704
|
stageHint: "Environment of this installation",
|
|
705
|
+
beta: "Beta",
|
|
706
|
+
betaHint: "Public beta: features and screens may still change until version 1.0.",
|
|
703
707
|
supportTitle: "Support request",
|
|
704
708
|
subject: "Subject",
|
|
705
709
|
description: "Description",
|
package/react/markdown.js
CHANGED
|
@@ -19,6 +19,12 @@ function safeHref(href) {
|
|
|
19
19
|
return h || null;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
+
// AI texts (links="https"): only https addresses become links.
|
|
23
|
+
function safeHttpsHref(href) {
|
|
24
|
+
const h = String(href || "").trim();
|
|
25
|
+
return /^https:\/\/[^\s/]/i.test(h) ? h : null;
|
|
26
|
+
}
|
|
27
|
+
|
|
22
28
|
function splitRow(line) {
|
|
23
29
|
let s = line.trim();
|
|
24
30
|
if (s.startsWith("|")) s = s.slice(1);
|
|
@@ -143,8 +149,11 @@ const INLINE = new RegExp(INLINE_SRC, "g");
|
|
|
143
149
|
const INLINE_PAGES = new RegExp(INLINE_SRC + "|\\[\\[([^[\\]\\n]+)\\]\\]", "g");
|
|
144
150
|
|
|
145
151
|
// opts.pageLinks: [[...]] becomes {type: "pagelink", space, title, label} (else it stays text).
|
|
152
|
+
// opts.httpsOnly (AI texts): links only with https, images stay text.
|
|
146
153
|
function parseInline(src, opts) {
|
|
147
154
|
const pages = !!(opts && opts.pageLinks);
|
|
155
|
+
const httpsOnly = !!(opts && opts.httpsOnly);
|
|
156
|
+
const linkHref = httpsOnly ? safeHttpsHref : safeHref;
|
|
148
157
|
const out = [];
|
|
149
158
|
const text = String(src || "");
|
|
150
159
|
let last = 0;
|
|
@@ -152,14 +161,15 @@ function parseInline(src, opts) {
|
|
|
152
161
|
if (m.index > last) out.push({ type: "text", text: text.slice(last, m.index) });
|
|
153
162
|
if (m[1]) out.push({ type: "code", text: m[2].trim() ? m[2].replace(/^ (.*) $/, "$1") : m[2] });
|
|
154
163
|
else if (m[4] !== undefined) {
|
|
155
|
-
const href = safeHref(m[4]);
|
|
164
|
+
const href = httpsOnly ? null : safeHref(m[4]);
|
|
156
165
|
out.push(href ? { type: "image", alt: m[3], href } : { type: "text", text: m[0] });
|
|
157
166
|
} else if (m[6] !== undefined) {
|
|
158
|
-
const href =
|
|
167
|
+
const href = linkHref(m[6]);
|
|
159
168
|
out.push(href ? { type: "link", href, children: parseInline(m[5], opts) } : { type: "text", text: m[5] });
|
|
160
169
|
} else if (m[7] !== undefined || m[8] !== undefined) out.push({ type: "bold", children: parseInline(m[7] ?? m[8], opts) });
|
|
161
170
|
else if (m[9] !== undefined) out.push({ type: "strike", children: parseInline(m[9], opts) });
|
|
162
171
|
else if (m[10] !== undefined || m[11] !== undefined) out.push({ type: "italic", children: parseInline(m[10] ?? m[11], opts) });
|
|
172
|
+
else if (m[12] && httpsOnly && !safeHttpsHref(m[12])) out.push({ type: "text", text: m[12] });
|
|
163
173
|
else if (m[12]) out.push({ type: "link", href: m[12], children: [{ type: "text", text: m[12] }] });
|
|
164
174
|
else if (m[13] !== undefined) {
|
|
165
175
|
const link = parsePageLink(m[13]);
|
|
@@ -204,7 +214,7 @@ function pageLinks(src) {
|
|
|
204
214
|
|
|
205
215
|
// The app's own elements (props.render): image(node, key), link(node, key, children), pagelink(node, key). A function
|
|
206
216
|
// that returns undefined leaves the building block's own element.
|
|
207
|
-
const Ctx = React.createContext({ render: {}, opts: null });
|
|
217
|
+
const Ctx = React.createContext({ render: {}, opts: null, anchors: true });
|
|
208
218
|
|
|
209
219
|
function own(ctx, kind, args) {
|
|
210
220
|
const fn = ctx.render && ctx.render[kind];
|
|
@@ -266,8 +276,9 @@ const CALLOUT_ICON = { note: "Info", tip: "Info", important: "Info", warning: "A
|
|
|
266
276
|
|
|
267
277
|
function Blocks(props) {
|
|
268
278
|
const L = props.labels;
|
|
279
|
+
const anchors = React.useContext(Ctx).anchors;
|
|
269
280
|
return h(React.Fragment, null, props.blocks.map((b, i) => {
|
|
270
|
-
if (b.type === "heading") return h("h" + b.level, { key: i, id: headingId(b.text), className: "scalio-md-h" + b.level }, inline(b.text));
|
|
281
|
+
if (b.type === "heading") return h("h" + b.level, { key: i, id: anchors ? headingId(b.text) : undefined, className: "scalio-md-h" + b.level }, inline(b.text));
|
|
271
282
|
if (b.type === "code") return h("pre", { key: i, "data-lang": b.lang || undefined, className: "scalio-md-pre" }, b.text);
|
|
272
283
|
if (b.type === "rule") return h("hr", { key: i, className: "scalio-md-rule" });
|
|
273
284
|
if (b.type === "list") return h(List, { key: i, list: b });
|
|
@@ -290,11 +301,15 @@ function Blocks(props) {
|
|
|
290
301
|
|
|
291
302
|
// <Markdown text="..." lang="de" /> shows the text; labels.markdown overrides the callout titles. pageLinks reads
|
|
292
303
|
// [[...]] as page links; render = {image, link, pagelink} puts the app's own elements in (Folio: images of the space,
|
|
293
|
-
// router links, resolved page links).
|
|
304
|
+
// router links, resolved page links). links="https" (AI texts): only https links, images stay text; anchors={false}:
|
|
305
|
+
// headings without an id (several answers on one page).
|
|
294
306
|
function Markdown(props) {
|
|
295
307
|
const L = Object.assign({}, labelsFor(props.lang).markdown, props.labels);
|
|
296
|
-
const
|
|
297
|
-
|
|
308
|
+
const httpsOnly = props.links === "https";
|
|
309
|
+
const ctx = React.useMemo(() => {
|
|
310
|
+
const opts = props.pageLinks || httpsOnly ? { pageLinks: !!props.pageLinks, httpsOnly } : null;
|
|
311
|
+
return { render: props.render || {}, opts, anchors: props.anchors !== false };
|
|
312
|
+
}, [props.render, props.pageLinks, httpsOnly, props.anchors]);
|
|
298
313
|
return h(Ctx.Provider, { value: ctx },
|
|
299
314
|
h("div", { className: "scalio-md" + (props.className ? " " + props.className : ""), "data-testid": props.testId },
|
|
300
315
|
h(Blocks, { blocks: parseBlocks(props.text), labels: L })));
|
|
@@ -310,4 +325,5 @@ module.exports = {
|
|
|
310
325
|
markdownPageLinkKey: pageLinkKey,
|
|
311
326
|
parseMarkdownPageLink: parsePageLink,
|
|
312
327
|
safeHref,
|
|
328
|
+
safeHttpsHref,
|
|
313
329
|
};
|
package/shell.css
CHANGED
|
@@ -31,6 +31,15 @@
|
|
|
31
31
|
@media (min-width: 1024px) { .scalio-brand-text { display: flex; } }
|
|
32
32
|
/* Product name and its edition badges on one line (ADR 0042 A1). */
|
|
33
33
|
.scalio-brand-line { display: flex; align-items: center; gap: 0.375rem; }
|
|
34
|
+
/* «Beta» next to the product name (ADR 0117); the large one sits under the title on the sign-in page. */
|
|
35
|
+
.scalio-beta {
|
|
36
|
+
display: inline-flex; align-items: center; padding: 0 0.3125rem; border-radius: 2px;
|
|
37
|
+
font-family: 'JetBrains Mono', monospace; font-size: 9px; font-weight: 700; line-height: 1rem;
|
|
38
|
+
text-transform: uppercase; letter-spacing: 0.1em;
|
|
39
|
+
background: rgb(139 92 246 / 0.12); color: #7c3aed; box-shadow: inset 0 0 0 1px rgb(139 92 246 / 0.45);
|
|
40
|
+
}
|
|
41
|
+
.dark .scalio-beta, .scalio-auth-brand .scalio-beta { color: #c4b5fd; }
|
|
42
|
+
.scalio-beta-lg { margin-top: 1rem; font-size: 0.75rem; line-height: 1.5rem; padding: 0 0.625rem; }
|
|
34
43
|
.scalio-edition-badges { display: inline-flex; align-items: center; gap: 0.25rem; }
|
|
35
44
|
.scalio-edition-badge { font-size: 9px; padding: 0.0625rem 0.3125rem; }
|
|
36
45
|
.scalio-api-status { gap: 0.25rem; }
|