@mintplayer/ng-bootstrap 22.14.0 → 22.15.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.
|
@@ -1,41 +1,113 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { input, output, ChangeDetectionStrategy, CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
|
|
2
|
+
import { input, output, viewChild, inject, ElementRef, ChangeDetectionStrategy, CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
|
|
3
3
|
import '@mintplayer/web-components/code-snippet';
|
|
4
4
|
|
|
5
|
+
/** Host attributes that describe the CONTROL and must reach it, not sit on a
|
|
6
|
+
* wrapper the accessibility tree does not care about. */
|
|
7
|
+
const FORWARDED_ATTRIBUTES = ['role', 'tabindex', 'id'];
|
|
5
8
|
/**
|
|
6
|
-
* Angular wrapper around `<mp-code-snippet>`. The WC owns
|
|
7
|
-
*
|
|
8
|
-
* component
|
|
9
|
-
* underlying WC's properties and events.
|
|
9
|
+
* Angular wrapper around `<mp-code-snippet>`. The WC owns highlighting,
|
|
10
|
+
* copy-to-clipboard, line rendering and the roving-focus keyboard layer; this
|
|
11
|
+
* component translates Angular input/output ergonomics onto it.
|
|
10
12
|
*
|
|
11
|
-
* Breaking changes
|
|
12
|
-
* - `
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
13
|
+
* Breaking changes:
|
|
14
|
+
* - `codeToCopy` is now `code`, matching the property it forwards to.
|
|
15
|
+
* - The code block follows `data-bs-theme` instead of being permanently dark.
|
|
16
|
+
* Pass `theme="dark"` to keep the old appearance.
|
|
17
|
+
* - `offcanvasVisible` (model) and `copiedTemplate` (viewChild) are long gone;
|
|
18
|
+
* the WC manages its own toast.
|
|
19
|
+
*
|
|
20
|
+
* CSS overrides go through parts: `::part(copy-button)`, `::part(pre)`,
|
|
21
|
+
* `::part(code)`, `::part(line)`, `::part(line-number)`, `::part(toast)`, and
|
|
22
|
+
* `::part(annotation-<kind>)` for whatever kinds you feed `annotations`.
|
|
19
23
|
*/
|
|
20
24
|
class BsCodeSnippetComponent {
|
|
21
25
|
constructor() {
|
|
22
|
-
this.
|
|
23
|
-
...(ngDevMode ? [{ debugName: "
|
|
26
|
+
this.code = input('', /* @ts-ignore */
|
|
27
|
+
...(ngDevMode ? [{ debugName: "code" }] : /* istanbul ignore next */ []));
|
|
24
28
|
this.language = input('', /* @ts-ignore */
|
|
25
29
|
...(ngDevMode ? [{ debugName: "language" }] : /* istanbul ignore next */ []));
|
|
30
|
+
this.lineNumbers = input(false, /* @ts-ignore */
|
|
31
|
+
...(ngDevMode ? [{ debugName: "lineNumbers" }] : /* istanbul ignore next */ []));
|
|
32
|
+
this.startLine = input(1, /* @ts-ignore */
|
|
33
|
+
...(ngDevMode ? [{ debugName: "startLine" }] : /* istanbul ignore next */ []));
|
|
34
|
+
this.wrap = input(false, /* @ts-ignore */
|
|
35
|
+
...(ngDevMode ? [{ debugName: "wrap" }] : /* istanbul ignore next */ []));
|
|
36
|
+
this.theme = input('auto', /* @ts-ignore */
|
|
37
|
+
...(ngDevMode ? [{ debugName: "theme" }] : /* istanbul ignore next */ []));
|
|
38
|
+
/** Sparse per-line markers; see `CodeLineAnnotation`. */
|
|
39
|
+
this.annotations = input([], /* @ts-ignore */
|
|
40
|
+
...(ngDevMode ? [{ debugName: "annotations" }] : /* istanbul ignore next */ []));
|
|
41
|
+
this.activeLine = input(null, /* @ts-ignore */
|
|
42
|
+
...(ngDevMode ? [{ debugName: "activeLine" }] : /* istanbul ignore next */ []));
|
|
43
|
+
/** Turns each line number into a real link, so middle-click still works. */
|
|
44
|
+
this.lineHref = input(null, /* @ts-ignore */
|
|
45
|
+
...(ngDevMode ? [{ debugName: "lineHref" }] : /* istanbul ignore next */ []));
|
|
46
|
+
this.label = input('', /* @ts-ignore */
|
|
47
|
+
...(ngDevMode ? [{ debugName: "label" }] : /* istanbul ignore next */ []));
|
|
48
|
+
this.copyLabel = input('', /* @ts-ignore */
|
|
49
|
+
...(ngDevMode ? [{ debugName: "copyLabel" }] : /* istanbul ignore next */ []));
|
|
50
|
+
this.lineLabel = input('', /* @ts-ignore */
|
|
51
|
+
...(ngDevMode ? [{ debugName: "lineLabel" }] : /* istanbul ignore next */ []));
|
|
26
52
|
this.detectedLanguage = output();
|
|
53
|
+
/**
|
|
54
|
+
* Emits the DOM event, not just the line number, so a consumer can call
|
|
55
|
+
* `preventDefault()` on it and navigate itself. Emitting the bare number
|
|
56
|
+
* dropped the only channel the element offers for that, and the anchor's
|
|
57
|
+
* default navigation always won.
|
|
58
|
+
*
|
|
59
|
+
* Angular's `output()` emits synchronously inside the DOM listener, so a
|
|
60
|
+
* `preventDefault()` in the handler lands before `dispatchEvent` returns.
|
|
61
|
+
* Same shape as `BsComboboxDirective`'s `activate`/`cancel`.
|
|
62
|
+
*/
|
|
63
|
+
this.lineActivate = output();
|
|
64
|
+
this.element = viewChild.required('element', /* @ts-ignore */
|
|
65
|
+
...(ngDevMode ? [{ debugName: "element" }] : /* istanbul ignore next */ []));
|
|
66
|
+
this.host = inject(ElementRef);
|
|
67
|
+
}
|
|
68
|
+
ngAfterViewInit() {
|
|
69
|
+
this.forwardHostAttributes();
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Scroll a line into view. Delegated to the element rather than reimplemented
|
|
73
|
+
* so that re-requesting the line the user is already on still scrolls — a
|
|
74
|
+
* plain `activeLine` binding would no-op.
|
|
75
|
+
*/
|
|
76
|
+
scrollToLine(line) {
|
|
77
|
+
this.element().nativeElement.scrollToLine(line);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* A consumer writing `aria-label` or `role` on `<bs-code-snippet>` means it
|
|
81
|
+
* for the code block. Left on the Angular host it reaches nothing: the host
|
|
82
|
+
* is a roleless div as far as AT is concerned. So the attributes are moved
|
|
83
|
+
* onto the `mp-*` element and removed from the host, where a duplicate would
|
|
84
|
+
* otherwise produce two named nodes.
|
|
85
|
+
*/
|
|
86
|
+
forwardHostAttributes() {
|
|
87
|
+
const host = this.host.nativeElement;
|
|
88
|
+
const target = this.element().nativeElement;
|
|
89
|
+
const names = [...host.getAttributeNames()].filter((name) => name.startsWith('aria-') || FORWARDED_ATTRIBUTES.includes(name));
|
|
90
|
+
for (const name of names) {
|
|
91
|
+
const value = host.getAttribute(name);
|
|
92
|
+
if (value === null)
|
|
93
|
+
continue;
|
|
94
|
+
target.setAttribute(name, value);
|
|
95
|
+
host.removeAttribute(name);
|
|
96
|
+
}
|
|
27
97
|
}
|
|
28
98
|
onLanguageDetected(event) {
|
|
29
|
-
|
|
30
|
-
|
|
99
|
+
this.detectedLanguage.emit(event.detail.language);
|
|
100
|
+
}
|
|
101
|
+
onLineActivate(event) {
|
|
102
|
+
this.lineActivate.emit(event);
|
|
31
103
|
}
|
|
32
104
|
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: BsCodeSnippetComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
33
|
-
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.
|
|
105
|
+
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.2.0", version: "22.0.8", type: BsCodeSnippetComponent, isStandalone: true, selector: "bs-code-snippet", inputs: { code: { classPropertyName: "code", publicName: "code", isSignal: true, isRequired: false, transformFunction: null }, language: { classPropertyName: "language", publicName: "language", isSignal: true, isRequired: false, transformFunction: null }, lineNumbers: { classPropertyName: "lineNumbers", publicName: "lineNumbers", isSignal: true, isRequired: false, transformFunction: null }, startLine: { classPropertyName: "startLine", publicName: "startLine", isSignal: true, isRequired: false, transformFunction: null }, wrap: { classPropertyName: "wrap", publicName: "wrap", isSignal: true, isRequired: false, transformFunction: null }, theme: { classPropertyName: "theme", publicName: "theme", isSignal: true, isRequired: false, transformFunction: null }, annotations: { classPropertyName: "annotations", publicName: "annotations", isSignal: true, isRequired: false, transformFunction: null }, activeLine: { classPropertyName: "activeLine", publicName: "activeLine", isSignal: true, isRequired: false, transformFunction: null }, lineHref: { classPropertyName: "lineHref", publicName: "lineHref", isSignal: true, isRequired: false, transformFunction: null }, label: { classPropertyName: "label", publicName: "label", isSignal: true, isRequired: false, transformFunction: null }, copyLabel: { classPropertyName: "copyLabel", publicName: "copyLabel", isSignal: true, isRequired: false, transformFunction: null }, lineLabel: { classPropertyName: "lineLabel", publicName: "lineLabel", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { detectedLanguage: "detectedLanguage", lineActivate: "lineActivate" }, viewQueries: [{ propertyName: "element", first: true, predicate: ["element"], descendants: true, isSignal: true }], ngImport: i0, template: "<!--\n Strings and booleans go in as ATTRIBUTES, not properties, so that an unset\n input removes the attribute (`null`) and the element keeps its own default.\n A property binding would write `''` over defaults like\n \"Copy ${language} code to clipboard\" and blank them.\n\n `code`, `annotations` and `lineHref` stay property bindings: multi-line text,\n an object and a function have no sensible attribute form.\n-->\n<mp-code-snippet\n #element\n [code]=\"code()\"\n [attr.language]=\"language() || null\"\n [attr.line-numbers]=\"lineNumbers() ? '' : null\"\n [attr.start-line]=\"startLine()\"\n [attr.wrap]=\"wrap() ? '' : null\"\n [attr.theme]=\"theme()\"\n [attr.active-line]=\"activeLine()\"\n [attr.label]=\"label() || null\"\n [attr.copy-label]=\"copyLabel() || null\"\n [attr.line-label]=\"lineLabel() || null\"\n [annotations]=\"annotations()\"\n [lineHref]=\"lineHref()\"\n (language-detected)=\"onLanguageDetected($event)\"\n (line-activate)=\"onLineActivate($event)\"\n></mp-code-snippet>\n", styles: [":host{display:flex;flex-direction:column}mp-code-snippet{flex:1 1 auto;min-height:0}\n"], changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
34
106
|
}
|
|
35
107
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.0.8", ngImport: i0, type: BsCodeSnippetComponent, decorators: [{
|
|
36
108
|
type: Component,
|
|
37
|
-
args: [{ selector: 'bs-code-snippet', schemas: [CUSTOM_ELEMENTS_SCHEMA], changeDetection: ChangeDetectionStrategy.OnPush,
|
|
38
|
-
}], propDecorators: {
|
|
109
|
+
args: [{ selector: 'bs-code-snippet', schemas: [CUSTOM_ELEMENTS_SCHEMA], changeDetection: ChangeDetectionStrategy.OnPush, template: "<!--\n Strings and booleans go in as ATTRIBUTES, not properties, so that an unset\n input removes the attribute (`null`) and the element keeps its own default.\n A property binding would write `''` over defaults like\n \"Copy ${language} code to clipboard\" and blank them.\n\n `code`, `annotations` and `lineHref` stay property bindings: multi-line text,\n an object and a function have no sensible attribute form.\n-->\n<mp-code-snippet\n #element\n [code]=\"code()\"\n [attr.language]=\"language() || null\"\n [attr.line-numbers]=\"lineNumbers() ? '' : null\"\n [attr.start-line]=\"startLine()\"\n [attr.wrap]=\"wrap() ? '' : null\"\n [attr.theme]=\"theme()\"\n [attr.active-line]=\"activeLine()\"\n [attr.label]=\"label() || null\"\n [attr.copy-label]=\"copyLabel() || null\"\n [attr.line-label]=\"lineLabel() || null\"\n [annotations]=\"annotations()\"\n [lineHref]=\"lineHref()\"\n (language-detected)=\"onLanguageDetected($event)\"\n (line-activate)=\"onLineActivate($event)\"\n></mp-code-snippet>\n", styles: [":host{display:flex;flex-direction:column}mp-code-snippet{flex:1 1 auto;min-height:0}\n"] }]
|
|
110
|
+
}], propDecorators: { code: [{ type: i0.Input, args: [{ isSignal: true, alias: "code", required: false }] }], language: [{ type: i0.Input, args: [{ isSignal: true, alias: "language", required: false }] }], lineNumbers: [{ type: i0.Input, args: [{ isSignal: true, alias: "lineNumbers", required: false }] }], startLine: [{ type: i0.Input, args: [{ isSignal: true, alias: "startLine", required: false }] }], wrap: [{ type: i0.Input, args: [{ isSignal: true, alias: "wrap", required: false }] }], theme: [{ type: i0.Input, args: [{ isSignal: true, alias: "theme", required: false }] }], annotations: [{ type: i0.Input, args: [{ isSignal: true, alias: "annotations", required: false }] }], activeLine: [{ type: i0.Input, args: [{ isSignal: true, alias: "activeLine", required: false }] }], lineHref: [{ type: i0.Input, args: [{ isSignal: true, alias: "lineHref", required: false }] }], label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], copyLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "copyLabel", required: false }] }], lineLabel: [{ type: i0.Input, args: [{ isSignal: true, alias: "lineLabel", required: false }] }], detectedLanguage: [{ type: i0.Output, args: ["detectedLanguage"] }], lineActivate: [{ type: i0.Output, args: ["lineActivate"] }], element: [{ type: i0.ViewChild, args: ['element', { isSignal: true }] }] } });
|
|
39
111
|
|
|
40
112
|
/**
|
|
41
113
|
* Generated bundle index. Do not edit.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mintplayer-ng-bootstrap-code-snippet.mjs","sources":["../../../../libs/mintplayer-ng-bootstrap/code-snippet/src/code-snippet.component.ts","../../../../libs/mintplayer-ng-bootstrap/code-snippet/src/code-snippet.component.html","../../../../libs/mintplayer-ng-bootstrap/code-snippet/mintplayer-ng-bootstrap-code-snippet.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"mintplayer-ng-bootstrap-code-snippet.mjs","sources":["../../../../libs/mintplayer-ng-bootstrap/code-snippet/src/code-snippet.component.ts","../../../../libs/mintplayer-ng-bootstrap/code-snippet/src/code-snippet.component.html","../../../../libs/mintplayer-ng-bootstrap/code-snippet/mintplayer-ng-bootstrap-code-snippet.ts"],"sourcesContent":["import {\n AfterViewInit,\n ChangeDetectionStrategy,\n Component,\n CUSTOM_ELEMENTS_SCHEMA,\n ElementRef,\n inject,\n input,\n output,\n viewChild,\n} from '@angular/core';\nimport '@mintplayer/web-components/code-snippet';\nimport type { CodeLineAnnotation, MpCodeSnippet } from '@mintplayer/web-components/code-snippet';\n\n/** Host attributes that describe the CONTROL and must reach it, not sit on a\n * wrapper the accessibility tree does not care about. */\nconst FORWARDED_ATTRIBUTES = ['role', 'tabindex', 'id'];\n\n/**\n * Angular wrapper around `<mp-code-snippet>`. The WC owns highlighting,\n * copy-to-clipboard, line rendering and the roving-focus keyboard layer; this\n * component translates Angular input/output ergonomics onto it.\n *\n * Breaking changes:\n * - `codeToCopy` is now `code`, matching the property it forwards to.\n * - The code block follows `data-bs-theme` instead of being permanently dark.\n * Pass `theme=\"dark\"` to keep the old appearance.\n * - `offcanvasVisible` (model) and `copiedTemplate` (viewChild) are long gone;\n * the WC manages its own toast.\n *\n * CSS overrides go through parts: `::part(copy-button)`, `::part(pre)`,\n * `::part(code)`, `::part(line)`, `::part(line-number)`, `::part(toast)`, and\n * `::part(annotation-<kind>)` for whatever kinds you feed `annotations`.\n */\n@Component({\n selector: 'bs-code-snippet',\n templateUrl: './code-snippet.component.html',\n schemas: [CUSTOM_ELEMENTS_SCHEMA],\n changeDetection: ChangeDetectionStrategy.OnPush,\n /**\n * A flex column that the `<mp-code-snippet>` fills, so a `height` or\n * `max-height` set on `<bs-code-snippet>` reaches the element that actually\n * scrolls. As a plain block the constraint stopped at this host and the\n * element kept its content height, overflowing it.\n *\n * React and Vue need no equivalent: both put the consumer's class straight\n * onto the custom element.\n */\n styles: `\n :host { display: flex; flex-direction: column; }\n mp-code-snippet { flex: 1 1 auto; min-height: 0; }\n `,\n})\nexport class BsCodeSnippetComponent implements AfterViewInit {\n readonly code = input<string>('');\n readonly language = input<string>('');\n\n readonly lineNumbers = input<boolean>(false);\n readonly startLine = input<number>(1);\n readonly wrap = input<boolean>(false);\n readonly theme = input<'auto' | 'light' | 'dark'>('auto');\n\n /** Sparse per-line markers; see `CodeLineAnnotation`. */\n readonly annotations = input<CodeLineAnnotation[]>([]);\n readonly activeLine = input<number | null>(null);\n /** Turns each line number into a real link, so middle-click still works. */\n readonly lineHref = input<((line: number) => string) | null>(null);\n\n readonly label = input<string>('');\n readonly copyLabel = input<string>('');\n readonly lineLabel = input<string>('');\n\n readonly detectedLanguage = output<string>();\n\n /**\n * Emits the DOM event, not just the line number, so a consumer can call\n * `preventDefault()` on it and navigate itself. Emitting the bare number\n * dropped the only channel the element offers for that, and the anchor's\n * default navigation always won.\n *\n * Angular's `output()` emits synchronously inside the DOM listener, so a\n * `preventDefault()` in the handler lands before `dispatchEvent` returns.\n * Same shape as `BsComboboxDirective`'s `activate`/`cancel`.\n */\n readonly lineActivate = output<CustomEvent<{ line: number }>>();\n\n private readonly element = viewChild.required<ElementRef<MpCodeSnippet>>('element');\n private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);\n\n ngAfterViewInit(): void {\n this.forwardHostAttributes();\n }\n\n /**\n * Scroll a line into view. Delegated to the element rather than reimplemented\n * so that re-requesting the line the user is already on still scrolls — a\n * plain `activeLine` binding would no-op.\n */\n scrollToLine(line: number): void {\n this.element().nativeElement.scrollToLine(line);\n }\n\n /**\n * A consumer writing `aria-label` or `role` on `<bs-code-snippet>` means it\n * for the code block. Left on the Angular host it reaches nothing: the host\n * is a roleless div as far as AT is concerned. So the attributes are moved\n * onto the `mp-*` element and removed from the host, where a duplicate would\n * otherwise produce two named nodes.\n */\n private forwardHostAttributes(): void {\n const host = this.host.nativeElement;\n const target = this.element().nativeElement as unknown as HTMLElement;\n\n const names = [...host.getAttributeNames()].filter(\n (name) => name.startsWith('aria-') || FORWARDED_ATTRIBUTES.includes(name),\n );\n\n for (const name of names) {\n const value = host.getAttribute(name);\n if (value === null) continue;\n target.setAttribute(name, value);\n host.removeAttribute(name);\n }\n }\n\n protected onLanguageDetected(event: Event): void {\n this.detectedLanguage.emit((event as CustomEvent<{ language: string }>).detail.language);\n }\n\n protected onLineActivate(event: Event): void {\n this.lineActivate.emit(event as CustomEvent<{ line: number }>);\n }\n}\n","<!--\n Strings and booleans go in as ATTRIBUTES, not properties, so that an unset\n input removes the attribute (`null`) and the element keeps its own default.\n A property binding would write `''` over defaults like\n \"Copy ${language} code to clipboard\" and blank them.\n\n `code`, `annotations` and `lineHref` stay property bindings: multi-line text,\n an object and a function have no sensible attribute form.\n-->\n<mp-code-snippet\n #element\n [code]=\"code()\"\n [attr.language]=\"language() || null\"\n [attr.line-numbers]=\"lineNumbers() ? '' : null\"\n [attr.start-line]=\"startLine()\"\n [attr.wrap]=\"wrap() ? '' : null\"\n [attr.theme]=\"theme()\"\n [attr.active-line]=\"activeLine()\"\n [attr.label]=\"label() || null\"\n [attr.copy-label]=\"copyLabel() || null\"\n [attr.line-label]=\"lineLabel() || null\"\n [annotations]=\"annotations()\"\n [lineHref]=\"lineHref()\"\n (language-detected)=\"onLanguageDetected($event)\"\n (line-activate)=\"onLineActivate($event)\"\n></mp-code-snippet>\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,27 +1,73 @@
|
|
|
1
1
|
import * as _angular_core from '@angular/core';
|
|
2
|
+
import { AfterViewInit } from '@angular/core';
|
|
3
|
+
import { CodeLineAnnotation } from '@mintplayer/web-components/code-snippet';
|
|
2
4
|
|
|
3
5
|
/**
|
|
4
|
-
* Angular wrapper around `<mp-code-snippet>`. The WC owns
|
|
5
|
-
*
|
|
6
|
-
* component
|
|
7
|
-
* underlying WC's properties and events.
|
|
6
|
+
* Angular wrapper around `<mp-code-snippet>`. The WC owns highlighting,
|
|
7
|
+
* copy-to-clipboard, line rendering and the roving-focus keyboard layer; this
|
|
8
|
+
* component translates Angular input/output ergonomics onto it.
|
|
8
9
|
*
|
|
9
|
-
* Breaking changes
|
|
10
|
-
* - `
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
10
|
+
* Breaking changes:
|
|
11
|
+
* - `codeToCopy` is now `code`, matching the property it forwards to.
|
|
12
|
+
* - The code block follows `data-bs-theme` instead of being permanently dark.
|
|
13
|
+
* Pass `theme="dark"` to keep the old appearance.
|
|
14
|
+
* - `offcanvasVisible` (model) and `copiedTemplate` (viewChild) are long gone;
|
|
15
|
+
* the WC manages its own toast.
|
|
16
|
+
*
|
|
17
|
+
* CSS overrides go through parts: `::part(copy-button)`, `::part(pre)`,
|
|
18
|
+
* `::part(code)`, `::part(line)`, `::part(line-number)`, `::part(toast)`, and
|
|
19
|
+
* `::part(annotation-<kind>)` for whatever kinds you feed `annotations`.
|
|
17
20
|
*/
|
|
18
|
-
declare class BsCodeSnippetComponent {
|
|
19
|
-
readonly
|
|
21
|
+
declare class BsCodeSnippetComponent implements AfterViewInit {
|
|
22
|
+
readonly code: _angular_core.InputSignal<string>;
|
|
20
23
|
readonly language: _angular_core.InputSignal<string>;
|
|
24
|
+
readonly lineNumbers: _angular_core.InputSignal<boolean>;
|
|
25
|
+
readonly startLine: _angular_core.InputSignal<number>;
|
|
26
|
+
readonly wrap: _angular_core.InputSignal<boolean>;
|
|
27
|
+
readonly theme: _angular_core.InputSignal<"auto" | "light" | "dark">;
|
|
28
|
+
/** Sparse per-line markers; see `CodeLineAnnotation`. */
|
|
29
|
+
readonly annotations: _angular_core.InputSignal<CodeLineAnnotation[]>;
|
|
30
|
+
readonly activeLine: _angular_core.InputSignal<number | null>;
|
|
31
|
+
/** Turns each line number into a real link, so middle-click still works. */
|
|
32
|
+
readonly lineHref: _angular_core.InputSignal<((line: number) => string) | null>;
|
|
33
|
+
readonly label: _angular_core.InputSignal<string>;
|
|
34
|
+
readonly copyLabel: _angular_core.InputSignal<string>;
|
|
35
|
+
readonly lineLabel: _angular_core.InputSignal<string>;
|
|
21
36
|
readonly detectedLanguage: _angular_core.OutputEmitterRef<string>;
|
|
37
|
+
/**
|
|
38
|
+
* Emits the DOM event, not just the line number, so a consumer can call
|
|
39
|
+
* `preventDefault()` on it and navigate itself. Emitting the bare number
|
|
40
|
+
* dropped the only channel the element offers for that, and the anchor's
|
|
41
|
+
* default navigation always won.
|
|
42
|
+
*
|
|
43
|
+
* Angular's `output()` emits synchronously inside the DOM listener, so a
|
|
44
|
+
* `preventDefault()` in the handler lands before `dispatchEvent` returns.
|
|
45
|
+
* Same shape as `BsComboboxDirective`'s `activate`/`cancel`.
|
|
46
|
+
*/
|
|
47
|
+
readonly lineActivate: _angular_core.OutputEmitterRef<CustomEvent<{
|
|
48
|
+
line: number;
|
|
49
|
+
}>>;
|
|
50
|
+
private readonly element;
|
|
51
|
+
private readonly host;
|
|
52
|
+
ngAfterViewInit(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Scroll a line into view. Delegated to the element rather than reimplemented
|
|
55
|
+
* so that re-requesting the line the user is already on still scrolls — a
|
|
56
|
+
* plain `activeLine` binding would no-op.
|
|
57
|
+
*/
|
|
58
|
+
scrollToLine(line: number): void;
|
|
59
|
+
/**
|
|
60
|
+
* A consumer writing `aria-label` or `role` on `<bs-code-snippet>` means it
|
|
61
|
+
* for the code block. Left on the Angular host it reaches nothing: the host
|
|
62
|
+
* is a roleless div as far as AT is concerned. So the attributes are moved
|
|
63
|
+
* onto the `mp-*` element and removed from the host, where a duplicate would
|
|
64
|
+
* otherwise produce two named nodes.
|
|
65
|
+
*/
|
|
66
|
+
private forwardHostAttributes;
|
|
22
67
|
protected onLanguageDetected(event: Event): void;
|
|
68
|
+
protected onLineActivate(event: Event): void;
|
|
23
69
|
static ɵfac: _angular_core.ɵɵFactoryDeclaration<BsCodeSnippetComponent, never>;
|
|
24
|
-
static ɵcmp: _angular_core.ɵɵComponentDeclaration<BsCodeSnippetComponent, "bs-code-snippet", never, { "
|
|
70
|
+
static ɵcmp: _angular_core.ɵɵComponentDeclaration<BsCodeSnippetComponent, "bs-code-snippet", never, { "code": { "alias": "code"; "required": false; "isSignal": true; }; "language": { "alias": "language"; "required": false; "isSignal": true; }; "lineNumbers": { "alias": "lineNumbers"; "required": false; "isSignal": true; }; "startLine": { "alias": "startLine"; "required": false; "isSignal": true; }; "wrap": { "alias": "wrap"; "required": false; "isSignal": true; }; "theme": { "alias": "theme"; "required": false; "isSignal": true; }; "annotations": { "alias": "annotations"; "required": false; "isSignal": true; }; "activeLine": { "alias": "activeLine"; "required": false; "isSignal": true; }; "lineHref": { "alias": "lineHref"; "required": false; "isSignal": true; }; "label": { "alias": "label"; "required": false; "isSignal": true; }; "copyLabel": { "alias": "copyLabel"; "required": false; "isSignal": true; }; "lineLabel": { "alias": "lineLabel"; "required": false; "isSignal": true; }; }, { "detectedLanguage": "detectedLanguage"; "lineActivate": "lineActivate"; }, never, never, true, never>;
|
|
25
71
|
}
|
|
26
72
|
|
|
27
73
|
export { BsCodeSnippetComponent };
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
Theme: a11y-dark
|
|
3
|
-
Author: @ericwbailey
|
|
4
|
-
Maintainer: @ericwbailey
|
|
5
|
-
|
|
6
|
-
Based on the Tomorrow Night Eighties theme:
|
|
7
|
-
https://github.com/isagalaev/highlight.js/blob/master/src/styles/tomorrow-night-eighties.css
|
|
8
|
-
Chosen because it meets WCAG AA contrast against the #2b2b2b background.
|
|
9
|
-
*/
|
|
10
|
-
|
|
11
|
-
pre code.hljs {
|
|
12
|
-
display: block;
|
|
13
|
-
overflow-x: auto;
|
|
14
|
-
padding: 1em;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
code.hljs {
|
|
18
|
-
padding: 3px 5px;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.hljs {
|
|
22
|
-
background: #2b2b2b;
|
|
23
|
-
color: #f8f8f2;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
.hljs ::selection, .hljs::selection {
|
|
27
|
-
background-color: #4d4d4d;
|
|
28
|
-
color: #f8f8f2;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
.hljs-comment,
|
|
32
|
-
.hljs-quote {
|
|
33
|
-
color: #d4d0ab;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.hljs-variable,
|
|
37
|
-
.hljs-template-variable,
|
|
38
|
-
.hljs-tag,
|
|
39
|
-
.hljs-name,
|
|
40
|
-
.hljs-selector-id,
|
|
41
|
-
.hljs-selector-class,
|
|
42
|
-
.hljs-regexp,
|
|
43
|
-
.hljs-deletion {
|
|
44
|
-
color: #ffa07a;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
.hljs-number,
|
|
48
|
-
.hljs-built_in,
|
|
49
|
-
.hljs-literal,
|
|
50
|
-
.hljs-type,
|
|
51
|
-
.hljs-params,
|
|
52
|
-
.hljs-meta,
|
|
53
|
-
.hljs-link {
|
|
54
|
-
color: #f5ab35;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.hljs-attribute {
|
|
58
|
-
color: #ffd700;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.hljs-string,
|
|
62
|
-
.hljs-symbol,
|
|
63
|
-
.hljs-bullet,
|
|
64
|
-
.hljs-addition {
|
|
65
|
-
color: #abe338;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
.hljs-title,
|
|
69
|
-
.hljs-section {
|
|
70
|
-
color: #00e0e0;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
.hljs-keyword,
|
|
74
|
-
.hljs-selector-tag {
|
|
75
|
-
color: #dcc6e0;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
.hljs-emphasis {
|
|
79
|
-
font-style: italic;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
.hljs-strong {
|
|
83
|
-
font-weight: bold;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
@media screen and (-ms-high-contrast: active) {
|
|
87
|
-
.hljs-addition,
|
|
88
|
-
.hljs-attribute,
|
|
89
|
-
.hljs-built_in,
|
|
90
|
-
.hljs-bullet,
|
|
91
|
-
.hljs-comment,
|
|
92
|
-
.hljs-link,
|
|
93
|
-
.hljs-literal,
|
|
94
|
-
.hljs-meta,
|
|
95
|
-
.hljs-number,
|
|
96
|
-
.hljs-params,
|
|
97
|
-
.hljs-string,
|
|
98
|
-
.hljs-symbol,
|
|
99
|
-
.hljs-type,
|
|
100
|
-
.hljs-quote {
|
|
101
|
-
color: highlight;
|
|
102
|
-
}
|
|
103
|
-
.hljs-keyword,
|
|
104
|
-
.hljs-selector-tag {
|
|
105
|
-
font-weight: bold;
|
|
106
|
-
}
|
|
107
|
-
}
|