athena-ui-js 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/README.md +32 -2
- package/docs/styling.md +1 -1
- package/package.json +4 -1
- package/src/athena-ui.js +1 -1
- package/src/libs/config/config.js +1 -1
- package/src/libs/core/i18n.js +2 -0
- package/src/libs/hephaestus/chartGenerator/chartGenerator.js +70 -28
- package/src/libs/hephaestus/codeGenerator/codeEditor.js +1037 -0
- package/src/libs/hephaestus/codeGenerator/codeGenerator.js +286 -0
- package/src/libs/hephaestus/dialogGenerator/dialogGenerator.js +5 -2
- package/src/libs/hephaestus/formGenerator/formBuilder.js +86 -5
- package/src/libs/hephaestus/tableGenerator/tableGenerator.js +5 -1
- package/src/libs/hephaestus/widgetGrid/widgetGrid.js +870 -0
- package/src/res/themes/default/style.css +4 -0
- package/types/athena-ui.d.ts +103 -103
- package/types/code.d.ts +4 -4
- package/types/libs/config/config.d.ts +3 -3
- package/types/libs/core/codeDiff.d.ts +32 -32
- package/types/libs/core/codeLanguages.d.ts +58 -58
- package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +117 -95
- package/types/libs/hephaestus/codeGenerator/codeEditor.d.ts +60 -60
- package/types/libs/hephaestus/codeGenerator/codeGenerator.d.ts +99 -99
- package/types/libs/hephaestus/dialogGenerator/dialogGenerator.d.ts +122 -120
- package/types/libs/hephaestus/formGenerator/authForms.d.ts +130 -122
- package/types/libs/hephaestus/formGenerator/formBuilder.d.ts +128 -113
- package/types/libs/hephaestus/tableGenerator/tableGenerator.d.ts +129 -123
|
@@ -1,95 +1,117 @@
|
|
|
1
|
-
/** Tick positions (ms) at round times between `from` and `to`, about `count` of them. */
|
|
2
|
-
export function timeTicks(from: any, to: any, count?: number): {
|
|
3
|
-
ticks: number[];
|
|
4
|
-
step: number;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Keeps about `buckets` x positions of a long series: of every bucket the lowest and the highest value stay (in their order),
|
|
8
|
-
* so peaks are not lost. Returns the kept indices.
|
|
9
|
-
*/
|
|
10
|
-
export function decimate(indices: any, values: any, buckets: any): any;
|
|
11
|
-
/**
|
|
12
|
-
* Draws a chart as inline SVG and appends it to its parent.
|
|
13
|
-
*
|
|
14
|
-
* @param {object} options
|
|
15
|
-
* @param {"bar"|"line"|"area"|"sparkline"|"pie"|"donut"} [options.type="bar"]
|
|
16
|
-
* @param {string|Element} [options.parent] element, id or selector, defaults to "wrapper"
|
|
17
|
-
* @param {string} [options.id] id of the svg element
|
|
18
|
-
* @param {string} [options.title] drawn above the chart, and its accessible name
|
|
19
|
-
* @param {string[]} [options.labels] category labels
|
|
20
|
-
* @param {(number|Date|string)[]} [options.times] line and area charts: the time of every value (Date, ms or a date string).
|
|
21
|
-
* The x axis becomes a time axis with ticks at round times, and the points sit at their real distance.
|
|
22
|
-
* @param {{name?: string, data: number[], color?: string}[]} options.series pie / donut / sparkline use the first series only.
|
|
23
|
-
* Colours come from the theme (--series-1 ... --series-8); `color` is an override for one series.
|
|
24
|
-
* @param {number} [options.width=600] (a sparkline: 120)
|
|
25
|
-
* @param {number} [options.height=360] (a sparkline: 32)
|
|
26
|
-
* @param {boolean} [options.legend] default: shown for several series, and for pie / donut. Clicking an entry hides / shows its series.
|
|
27
|
-
* @param {boolean} [options.table=false] adds a "Show as table" section with the values below the chart
|
|
28
|
-
* @param {boolean} [options.zero=true] line charts: false lets the value axis start near the smallest value
|
|
29
|
-
* @param {boolean} [options.zoom=false] line and area charts: drag over the plot to zoom into that range, double click (or the
|
|
30
|
-
* reset button, or 0 / Esc) to zoom out; with the keyboard on the plot: + and - zoom, the arrow keys pan
|
|
31
|
-
* @param {{from: number, to: number}|null} [options.zoomRange] the range in view, in the units of the x axis: milliseconds with
|
|
32
|
-
* `times`, otherwise the index of the point (-0.5 is the left edge of the first point)
|
|
33
|
-
* @param {(range: ({from: number, to: number}|null)) => void} [options.onZoom] called when a person zooms or resets
|
|
34
|
-
* @param {number} [options.maxPoints] `push` keeps at most this many points per series (the oldest are dropped)
|
|
35
|
-
* @param {number[]} [options.hiddenSeries] the series (or slices) that are hidden at the start; a person hides and shows them with the legend, and a redraw keeps that
|
|
36
|
-
* @param {boolean} [options.animate=true] the first drawing animates: bars grow, a line is drawn, slices pop in (not when it is redrawn, and not under reduced motion)
|
|
37
|
-
* @param {boolean} [options.interactive=true] line and area charts: false leaves out the pointer layer (tooltip that follows the pointer, zoom)
|
|
38
|
-
* @
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
1
|
+
/** Tick positions (ms) at round times between `from` and `to`, about `count` of them. */
|
|
2
|
+
export function timeTicks(from: any, to: any, count?: number): {
|
|
3
|
+
ticks: number[];
|
|
4
|
+
step: number;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Keeps about `buckets` x positions of a long series: of every bucket the lowest and the highest value stay (in their order),
|
|
8
|
+
* so peaks are not lost. Returns the kept indices.
|
|
9
|
+
*/
|
|
10
|
+
export function decimate(indices: any, values: any, buckets: any): any;
|
|
11
|
+
/**
|
|
12
|
+
* Draws a chart as inline SVG and appends it to its parent.
|
|
13
|
+
*
|
|
14
|
+
* @param {object} options
|
|
15
|
+
* @param {"bar"|"line"|"area"|"sparkline"|"pie"|"donut"} [options.type="bar"]
|
|
16
|
+
* @param {string|Element} [options.parent] element, id or selector, defaults to "wrapper"
|
|
17
|
+
* @param {string} [options.id] id of the svg element
|
|
18
|
+
* @param {string} [options.title] drawn above the chart, and its accessible name
|
|
19
|
+
* @param {string[]} [options.labels] category labels
|
|
20
|
+
* @param {(number|Date|string)[]} [options.times] line and area charts: the time of every value (Date, ms or a date string).
|
|
21
|
+
* The x axis becomes a time axis with ticks at round times, and the points sit at their real distance.
|
|
22
|
+
* @param {{name?: string, data: number[], color?: string}[]} options.series pie / donut / sparkline use the first series only.
|
|
23
|
+
* Colours come from the theme (--series-1 ... --series-8); `color` is an override for one series.
|
|
24
|
+
* @param {number} [options.width=600] (a sparkline: 120)
|
|
25
|
+
* @param {number} [options.height=360] (a sparkline: 32)
|
|
26
|
+
* @param {boolean} [options.legend] default: shown for several series, and for pie / donut. Clicking an entry hides / shows its series.
|
|
27
|
+
* @param {boolean} [options.table=false] adds a "Show as table" section with the values below the chart
|
|
28
|
+
* @param {boolean} [options.zero=true] line charts: false lets the value axis start near the smallest value
|
|
29
|
+
* @param {boolean} [options.zoom=false] line and area charts: drag over the plot to zoom into that range, double click (or the
|
|
30
|
+
* reset button, or 0 / Esc) to zoom out; with the keyboard on the plot: + and - zoom, the arrow keys pan
|
|
31
|
+
* @param {{from: number, to: number}|null} [options.zoomRange] the range in view, in the units of the x axis: milliseconds with
|
|
32
|
+
* `times`, otherwise the index of the point (-0.5 is the left edge of the first point)
|
|
33
|
+
* @param {(range: ({from: number, to: number}|null)) => void} [options.onZoom] called when a person zooms or resets
|
|
34
|
+
* @param {number} [options.maxPoints] `push` keeps at most this many points per series (the oldest are dropped)
|
|
35
|
+
* @param {number[]} [options.hiddenSeries] the series (or slices) that are hidden at the start; a person hides and shows them with the legend, and a redraw keeps that
|
|
36
|
+
* @param {boolean} [options.animate=true] the first drawing animates: bars grow, a line is drawn, slices pop in (not when it is redrawn, and not under reduced motion)
|
|
37
|
+
* @param {boolean} [options.interactive=true] line and area charts: false leaves out the pointer layer (tooltip that follows the pointer, zoom)
|
|
38
|
+
* @param {boolean} [options.gaps=false] line and area charts: a missing value (null, NaN, undefined) breaks the line, and a point on its own is a dot;
|
|
39
|
+
* without it the line goes on from the value before to the one after
|
|
40
|
+
* @param {{from: (number|Date|string), to: (number|Date|string)}} [options.timeRange] line and area charts with `times`: the range of the time axis, when it is not the one
|
|
41
|
+
* the data covers (the last hour, of which only the last quarter has been measured)
|
|
42
|
+
* @param {(value: number) => string} [options.format] how a value is written: on the axis, in the tooltips and in the table of values (default: whole numbers, otherwise two decimals)
|
|
43
|
+
* @param {(value: number) => string} [options.tickFormat] how the numbers of the value axis are written, when they should not be written like the values (a chart of whole numbers has ticks of 0.2)
|
|
44
|
+
* @param {{top?: number, right?: number, bottom?: number, left?: number}} [options.margin] room around the plot in px (default 40, 20, 50, 55): a chart without a title and a legend does not need the top
|
|
45
|
+
* @param {boolean} [options.responsive=false] the chart is as wide as its parent and follows it when it changes (`height` stays); `width` is only the first guess
|
|
46
|
+
* @returns {(SVGElement & {element: SVGElement, update: (options?: object) => SVGElement, destroy: () => void,
|
|
47
|
+
* zoom: (from: number, to: number) => void, resetZoom: () => void, getZoom: () => ({from: number, to: number}|null),
|
|
48
|
+
* push: (point: {x?: (number|Date|string), label?: string, values: (number|number[])}, config?: {maxPoints?: number}) => void,
|
|
49
|
+
* dataTable: (HTMLElement|null)})|null}
|
|
50
|
+
* the SVG element, which also carries the handle ({ element, update(options), destroy() }) of the other
|
|
51
|
+
* components; null when the options are invalid. `parent` is an element, an id or a selector.
|
|
52
|
+
* `push` adds a point to every series (a number for the first series, or one value per series; `x` is the time with
|
|
53
|
+
* `times`, `label` the category) and draws the chart again at most once per frame, however often it is called.
|
|
54
|
+
*/
|
|
55
|
+
export function generateChart(options?: {
|
|
56
|
+
type?: "bar" | "line" | "area" | "sparkline" | "pie" | "donut";
|
|
57
|
+
parent?: string | Element;
|
|
58
|
+
id?: string;
|
|
59
|
+
title?: string;
|
|
60
|
+
labels?: string[];
|
|
61
|
+
times?: (number | Date | string)[];
|
|
62
|
+
series: {
|
|
63
|
+
name?: string;
|
|
64
|
+
data: number[];
|
|
65
|
+
color?: string;
|
|
66
|
+
}[];
|
|
67
|
+
width?: number;
|
|
68
|
+
height?: number;
|
|
69
|
+
legend?: boolean;
|
|
70
|
+
table?: boolean;
|
|
71
|
+
zero?: boolean;
|
|
72
|
+
zoom?: boolean;
|
|
73
|
+
zoomRange?: {
|
|
74
|
+
from: number;
|
|
75
|
+
to: number;
|
|
76
|
+
} | null;
|
|
77
|
+
onZoom?: (range: ({
|
|
78
|
+
from: number;
|
|
79
|
+
to: number;
|
|
80
|
+
} | null)) => void;
|
|
81
|
+
maxPoints?: number;
|
|
82
|
+
hiddenSeries?: number[];
|
|
83
|
+
animate?: boolean;
|
|
84
|
+
interactive?: boolean;
|
|
85
|
+
gaps?: boolean;
|
|
86
|
+
timeRange?: {
|
|
87
|
+
from: (number | Date | string);
|
|
88
|
+
to: (number | Date | string);
|
|
89
|
+
};
|
|
90
|
+
format?: (value: number) => string;
|
|
91
|
+
tickFormat?: (value: number) => string;
|
|
92
|
+
margin?: {
|
|
93
|
+
top?: number;
|
|
94
|
+
right?: number;
|
|
95
|
+
bottom?: number;
|
|
96
|
+
left?: number;
|
|
97
|
+
};
|
|
98
|
+
responsive?: boolean;
|
|
99
|
+
}): (SVGElement & {
|
|
100
|
+
element: SVGElement;
|
|
101
|
+
update: (options?: object) => SVGElement;
|
|
102
|
+
destroy: () => void;
|
|
103
|
+
zoom: (from: number, to: number) => void;
|
|
104
|
+
resetZoom: () => void;
|
|
105
|
+
getZoom: () => ({
|
|
106
|
+
from: number;
|
|
107
|
+
to: number;
|
|
108
|
+
} | null);
|
|
109
|
+
push: (point: {
|
|
110
|
+
x?: (number | Date | string);
|
|
111
|
+
label?: string;
|
|
112
|
+
values: (number | number[]);
|
|
113
|
+
}, config?: {
|
|
114
|
+
maxPoints?: number;
|
|
115
|
+
}) => void;
|
|
116
|
+
dataTable: (HTMLElement | null);
|
|
117
|
+
}) | null;
|
|
@@ -1,60 +1,60 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* A code editor.
|
|
3
|
-
*
|
|
4
|
-
* @param {object} options
|
|
5
|
-
* @param {string|HTMLElement} options.element the container
|
|
6
|
-
* @param {string} [options.value]
|
|
7
|
-
* @param {string|object} [options.language] "js", "json", ... or a language object (see registerLanguage)
|
|
8
|
-
* @param {boolean} [options.readOnly=false]
|
|
9
|
-
* @param {boolean} [options.lineNumbers=true]
|
|
10
|
-
* @param {boolean} [options.wrap=false] soft wrap
|
|
11
|
-
* @param {number} [options.tabSize=4]
|
|
12
|
-
* @param {boolean} [options.insertSpaces=true] Tab inserts spaces (false: a tab character)
|
|
13
|
-
* @param {boolean} [options.statusBar=true] line and column, and the message of a marker
|
|
14
|
-
* @param {string} [options.label] accessible name of the editor
|
|
15
|
-
* @param {number} [options.maxHighlightLength=300000] longer texts are shown without highlighting (and without line numbers) to stay fast
|
|
16
|
-
* @param {{line: number, message: string, level?: "error"|"warning"|"info"}[]} [options.markers] lint markers (lines count from 1)
|
|
17
|
-
* @param {{from: number, to: number}[]} [options.readOnlyRanges] lines (1-based, inclusive) that cannot be changed
|
|
18
|
-
* @param {(context: {value: string, position: number, line: number, lineText: string, prefix: string, explicit: boolean, language: string}) => (Array<{label: string, insert?: string, detail?: string}>|Promise<Array>)} [options.provideCompletions]
|
|
19
|
-
* @param {boolean} [options.autoComplete=true] with provideCompletions: suggest while typing (otherwise only with Ctrl+Space)
|
|
20
|
-
* @param {(value: string, reason: string) => void} [options.onChange] after every change made by typing, undo, redo, replace ... (not after setValue)
|
|
21
|
-
* @returns the handle: { element, textarea, getValue, setValue, focus, getSelection, setSelection, insertText, setLanguage, setReadOnly, setWrap, setMarkers,
|
|
22
|
-
* setReadOnlyRanges, undo, redo, canUndo, canRedo, openFind, closeFind, toggleComment, destroy }
|
|
23
|
-
*/
|
|
24
|
-
export function createCodeEditor(options?: {
|
|
25
|
-
element: string | HTMLElement;
|
|
26
|
-
value?: string;
|
|
27
|
-
language?: string | object;
|
|
28
|
-
readOnly?: boolean;
|
|
29
|
-
lineNumbers?: boolean;
|
|
30
|
-
wrap?: boolean;
|
|
31
|
-
tabSize?: number;
|
|
32
|
-
insertSpaces?: boolean;
|
|
33
|
-
statusBar?: boolean;
|
|
34
|
-
label?: string;
|
|
35
|
-
maxHighlightLength?: number;
|
|
36
|
-
markers?: {
|
|
37
|
-
line: number;
|
|
38
|
-
message: string;
|
|
39
|
-
level?: "error" | "warning" | "info";
|
|
40
|
-
}[];
|
|
41
|
-
readOnlyRanges?: {
|
|
42
|
-
from: number;
|
|
43
|
-
to: number;
|
|
44
|
-
}[];
|
|
45
|
-
provideCompletions?: (context: {
|
|
46
|
-
value: string;
|
|
47
|
-
position: number;
|
|
48
|
-
line: number;
|
|
49
|
-
lineText: string;
|
|
50
|
-
prefix: string;
|
|
51
|
-
explicit: boolean;
|
|
52
|
-
language: string;
|
|
53
|
-
}) => (Array<{
|
|
54
|
-
label: string;
|
|
55
|
-
insert?: string;
|
|
56
|
-
detail?: string;
|
|
57
|
-
}> | Promise<any[]>);
|
|
58
|
-
autoComplete?: boolean;
|
|
59
|
-
onChange?: (value: string, reason: string) => void;
|
|
60
|
-
}): any;
|
|
1
|
+
/**
|
|
2
|
+
* A code editor.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {string|HTMLElement} options.element the container
|
|
6
|
+
* @param {string} [options.value]
|
|
7
|
+
* @param {string|object} [options.language] "js", "json", ... or a language object (see registerLanguage)
|
|
8
|
+
* @param {boolean} [options.readOnly=false]
|
|
9
|
+
* @param {boolean} [options.lineNumbers=true]
|
|
10
|
+
* @param {boolean} [options.wrap=false] soft wrap
|
|
11
|
+
* @param {number} [options.tabSize=4]
|
|
12
|
+
* @param {boolean} [options.insertSpaces=true] Tab inserts spaces (false: a tab character)
|
|
13
|
+
* @param {boolean} [options.statusBar=true] line and column, and the message of a marker
|
|
14
|
+
* @param {string} [options.label] accessible name of the editor
|
|
15
|
+
* @param {number} [options.maxHighlightLength=300000] longer texts are shown without highlighting (and without line numbers) to stay fast
|
|
16
|
+
* @param {{line: number, message: string, level?: "error"|"warning"|"info"}[]} [options.markers] lint markers (lines count from 1)
|
|
17
|
+
* @param {{from: number, to: number}[]} [options.readOnlyRanges] lines (1-based, inclusive) that cannot be changed
|
|
18
|
+
* @param {(context: {value: string, position: number, line: number, lineText: string, prefix: string, explicit: boolean, language: string}) => (Array<{label: string, insert?: string, detail?: string}>|Promise<Array>)} [options.provideCompletions]
|
|
19
|
+
* @param {boolean} [options.autoComplete=true] with provideCompletions: suggest while typing (otherwise only with Ctrl+Space)
|
|
20
|
+
* @param {(value: string, reason: string) => void} [options.onChange] after every change made by typing, undo, redo, replace ... (not after setValue)
|
|
21
|
+
* @returns the handle: { element, textarea, getValue, setValue, focus, getSelection, setSelection, insertText, setLanguage, setReadOnly, setWrap, setMarkers,
|
|
22
|
+
* setReadOnlyRanges, undo, redo, canUndo, canRedo, openFind, closeFind, toggleComment, destroy }
|
|
23
|
+
*/
|
|
24
|
+
export function createCodeEditor(options?: {
|
|
25
|
+
element: string | HTMLElement;
|
|
26
|
+
value?: string;
|
|
27
|
+
language?: string | object;
|
|
28
|
+
readOnly?: boolean;
|
|
29
|
+
lineNumbers?: boolean;
|
|
30
|
+
wrap?: boolean;
|
|
31
|
+
tabSize?: number;
|
|
32
|
+
insertSpaces?: boolean;
|
|
33
|
+
statusBar?: boolean;
|
|
34
|
+
label?: string;
|
|
35
|
+
maxHighlightLength?: number;
|
|
36
|
+
markers?: {
|
|
37
|
+
line: number;
|
|
38
|
+
message: string;
|
|
39
|
+
level?: "error" | "warning" | "info";
|
|
40
|
+
}[];
|
|
41
|
+
readOnlyRanges?: {
|
|
42
|
+
from: number;
|
|
43
|
+
to: number;
|
|
44
|
+
}[];
|
|
45
|
+
provideCompletions?: (context: {
|
|
46
|
+
value: string;
|
|
47
|
+
position: number;
|
|
48
|
+
line: number;
|
|
49
|
+
lineText: string;
|
|
50
|
+
prefix: string;
|
|
51
|
+
explicit: boolean;
|
|
52
|
+
language: string;
|
|
53
|
+
}) => (Array<{
|
|
54
|
+
label: string;
|
|
55
|
+
insert?: string;
|
|
56
|
+
detail?: string;
|
|
57
|
+
}> | Promise<any[]>);
|
|
58
|
+
autoComplete?: boolean;
|
|
59
|
+
onChange?: (value: string, reason: string) => void;
|
|
60
|
+
}): any;
|
|
@@ -1,99 +1,99 @@
|
|
|
1
|
-
/** Splits tokens at the line breaks: an array (one entry per line) of arrays of { type, text }. */
|
|
2
|
-
export function tokensToLines(tokens: any): any[][];
|
|
3
|
-
/** The nodes of one line: text nodes and <span class="tok-..."> (a span has one class and one text node). */
|
|
4
|
-
export function lineNodes(tokens: any): any;
|
|
5
|
-
/**
|
|
6
|
-
* Writes the highlighted lines of a text into a <code> element (replacing what is there). The editor uses it too.
|
|
7
|
-
*
|
|
8
|
-
* @param {HTMLElement} code
|
|
9
|
-
* @param {string} text
|
|
10
|
-
* @param {string|object} [language] a name or alias ("js"), or a language object; unknown: plain text
|
|
11
|
-
* @param {object} [options]
|
|
12
|
-
* @param {Array<number|string>} [options.highlightLines] line numbers (1-based) or ranges ("5-8") that get a background
|
|
13
|
-
* @returns {number} the number of lines
|
|
14
|
-
*/
|
|
15
|
-
export function renderCode(code: HTMLElement, text: string, language?: string | object, { highlightLines }?: {
|
|
16
|
-
highlightLines?: Array<number | string>;
|
|
17
|
-
}): number;
|
|
18
|
-
/**
|
|
19
|
-
* Highlights read-only code: a `<pre class="athena-code"><code>` element.
|
|
20
|
-
*
|
|
21
|
-
* @param {string} text
|
|
22
|
-
* @param {string|object} [language] "js", "ts", "json", "html", "css", "sql", "sh", "yaml", "c#", "python" or a language you registered
|
|
23
|
-
* @param {object} [options]
|
|
24
|
-
* @param {boolean} [options.lineNumbers=false]
|
|
25
|
-
* @param {Array<number|string>} [options.highlightLines]
|
|
26
|
-
* @param {boolean} [options.wrap=false] long lines wrap instead of scrolling
|
|
27
|
-
* @param {string} [options.label] accessible name of the code
|
|
28
|
-
* @returns {HTMLPreElement}
|
|
29
|
-
*/
|
|
30
|
-
export function highlightCode(text: string, language?: string | object, { lineNumbers, highlightLines, wrap, label }?: {
|
|
31
|
-
lineNumbers?: boolean;
|
|
32
|
-
highlightLines?: Array<number | string>;
|
|
33
|
-
wrap?: boolean;
|
|
34
|
-
label?: string;
|
|
35
|
-
}): HTMLPreElement;
|
|
36
|
-
/**
|
|
37
|
-
* A code block: a label with the language, a copy button and the highlighted code.
|
|
38
|
-
*
|
|
39
|
-
* @param {object} options
|
|
40
|
-
* @param {string|HTMLElement} [options.parent]
|
|
41
|
-
* @param {string} options.code
|
|
42
|
-
* @param {string|object} [options.language]
|
|
43
|
-
* @param {string} [options.title] shown in the header instead of the language
|
|
44
|
-
* @param {boolean} [options.lineNumbers=false]
|
|
45
|
-
* @param {Array<number|string>} [options.highlightLines]
|
|
46
|
-
* @param {boolean} [options.copy=true] the copy button
|
|
47
|
-
* @param {boolean} [options.wrap=false]
|
|
48
|
-
* @param {string} [options.id]
|
|
49
|
-
* @returns {{element: HTMLElement, getCode: () => string, setCode: (code: string, language?: string|object) => void, copy: () => Promise<boolean>, destroy: Function}}
|
|
50
|
-
*/
|
|
51
|
-
export function generateCodeBlock({ parent, code, language, title, lineNumbers, highlightLines, copy, wrap, id }?: {
|
|
52
|
-
parent?: string | HTMLElement;
|
|
53
|
-
code: string;
|
|
54
|
-
language?: string | object;
|
|
55
|
-
title?: string;
|
|
56
|
-
lineNumbers?: boolean;
|
|
57
|
-
highlightLines?: Array<number | string>;
|
|
58
|
-
copy?: boolean;
|
|
59
|
-
wrap?: boolean;
|
|
60
|
-
id?: string;
|
|
61
|
-
}): {
|
|
62
|
-
element: HTMLElement;
|
|
63
|
-
getCode: () => string;
|
|
64
|
-
setCode: (code: string, language?: string | object) => void;
|
|
65
|
-
copy: () => Promise<boolean>;
|
|
66
|
-
destroy: Function;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* A view of the difference between two texts, with highlighted code on both sides.
|
|
70
|
-
*
|
|
71
|
-
* @param {object} options
|
|
72
|
-
* @param {string|HTMLElement} [options.parent]
|
|
73
|
-
* @param {string} [options.original]
|
|
74
|
-
* @param {string} [options.modified]
|
|
75
|
-
* @param {string|object} [options.language]
|
|
76
|
-
* @param {"unified"|"split"} [options.mode="unified"]
|
|
77
|
-
* @param {number} [options.context=3] unchanged lines kept around a change (Infinity: all of them); a button shows the rest
|
|
78
|
-
* @param {string} [options.originalLabel]
|
|
79
|
-
* @param {string} [options.modifiedLabel]
|
|
80
|
-
* @returns {{element: HTMLElement, setTexts: (original: string, modified: string) => void, setMode: (mode: string) => void, getStats: () => {added: number, removed: number}}}
|
|
81
|
-
*/
|
|
82
|
-
export function createDiffView({ parent, original, modified, language, mode, context, originalLabel, modifiedLabel }?: {
|
|
83
|
-
parent?: string | HTMLElement;
|
|
84
|
-
original?: string;
|
|
85
|
-
modified?: string;
|
|
86
|
-
language?: string | object;
|
|
87
|
-
mode?: "unified" | "split";
|
|
88
|
-
context?: number;
|
|
89
|
-
originalLabel?: string;
|
|
90
|
-
modifiedLabel?: string;
|
|
91
|
-
}): {
|
|
92
|
-
element: HTMLElement;
|
|
93
|
-
setTexts: (original: string, modified: string) => void;
|
|
94
|
-
setMode: (mode: string) => void;
|
|
95
|
-
getStats: () => {
|
|
96
|
-
added: number;
|
|
97
|
-
removed: number;
|
|
98
|
-
};
|
|
99
|
-
};
|
|
1
|
+
/** Splits tokens at the line breaks: an array (one entry per line) of arrays of { type, text }. */
|
|
2
|
+
export function tokensToLines(tokens: any): any[][];
|
|
3
|
+
/** The nodes of one line: text nodes and <span class="tok-..."> (a span has one class and one text node). */
|
|
4
|
+
export function lineNodes(tokens: any): any;
|
|
5
|
+
/**
|
|
6
|
+
* Writes the highlighted lines of a text into a <code> element (replacing what is there). The editor uses it too.
|
|
7
|
+
*
|
|
8
|
+
* @param {HTMLElement} code
|
|
9
|
+
* @param {string} text
|
|
10
|
+
* @param {string|object} [language] a name or alias ("js"), or a language object; unknown: plain text
|
|
11
|
+
* @param {object} [options]
|
|
12
|
+
* @param {Array<number|string>} [options.highlightLines] line numbers (1-based) or ranges ("5-8") that get a background
|
|
13
|
+
* @returns {number} the number of lines
|
|
14
|
+
*/
|
|
15
|
+
export function renderCode(code: HTMLElement, text: string, language?: string | object, { highlightLines }?: {
|
|
16
|
+
highlightLines?: Array<number | string>;
|
|
17
|
+
}): number;
|
|
18
|
+
/**
|
|
19
|
+
* Highlights read-only code: a `<pre class="athena-code"><code>` element.
|
|
20
|
+
*
|
|
21
|
+
* @param {string} text
|
|
22
|
+
* @param {string|object} [language] "js", "ts", "json", "html", "css", "sql", "sh", "yaml", "c#", "python" or a language you registered
|
|
23
|
+
* @param {object} [options]
|
|
24
|
+
* @param {boolean} [options.lineNumbers=false]
|
|
25
|
+
* @param {Array<number|string>} [options.highlightLines]
|
|
26
|
+
* @param {boolean} [options.wrap=false] long lines wrap instead of scrolling
|
|
27
|
+
* @param {string} [options.label] accessible name of the code
|
|
28
|
+
* @returns {HTMLPreElement}
|
|
29
|
+
*/
|
|
30
|
+
export function highlightCode(text: string, language?: string | object, { lineNumbers, highlightLines, wrap, label }?: {
|
|
31
|
+
lineNumbers?: boolean;
|
|
32
|
+
highlightLines?: Array<number | string>;
|
|
33
|
+
wrap?: boolean;
|
|
34
|
+
label?: string;
|
|
35
|
+
}): HTMLPreElement;
|
|
36
|
+
/**
|
|
37
|
+
* A code block: a label with the language, a copy button and the highlighted code.
|
|
38
|
+
*
|
|
39
|
+
* @param {object} options
|
|
40
|
+
* @param {string|HTMLElement} [options.parent]
|
|
41
|
+
* @param {string} options.code
|
|
42
|
+
* @param {string|object} [options.language]
|
|
43
|
+
* @param {string} [options.title] shown in the header instead of the language
|
|
44
|
+
* @param {boolean} [options.lineNumbers=false]
|
|
45
|
+
* @param {Array<number|string>} [options.highlightLines]
|
|
46
|
+
* @param {boolean} [options.copy=true] the copy button
|
|
47
|
+
* @param {boolean} [options.wrap=false]
|
|
48
|
+
* @param {string} [options.id]
|
|
49
|
+
* @returns {{element: HTMLElement, getCode: () => string, setCode: (code: string, language?: string|object) => void, copy: () => Promise<boolean>, destroy: Function}}
|
|
50
|
+
*/
|
|
51
|
+
export function generateCodeBlock({ parent, code, language, title, lineNumbers, highlightLines, copy, wrap, id }?: {
|
|
52
|
+
parent?: string | HTMLElement;
|
|
53
|
+
code: string;
|
|
54
|
+
language?: string | object;
|
|
55
|
+
title?: string;
|
|
56
|
+
lineNumbers?: boolean;
|
|
57
|
+
highlightLines?: Array<number | string>;
|
|
58
|
+
copy?: boolean;
|
|
59
|
+
wrap?: boolean;
|
|
60
|
+
id?: string;
|
|
61
|
+
}): {
|
|
62
|
+
element: HTMLElement;
|
|
63
|
+
getCode: () => string;
|
|
64
|
+
setCode: (code: string, language?: string | object) => void;
|
|
65
|
+
copy: () => Promise<boolean>;
|
|
66
|
+
destroy: Function;
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* A view of the difference between two texts, with highlighted code on both sides.
|
|
70
|
+
*
|
|
71
|
+
* @param {object} options
|
|
72
|
+
* @param {string|HTMLElement} [options.parent]
|
|
73
|
+
* @param {string} [options.original]
|
|
74
|
+
* @param {string} [options.modified]
|
|
75
|
+
* @param {string|object} [options.language]
|
|
76
|
+
* @param {"unified"|"split"} [options.mode="unified"]
|
|
77
|
+
* @param {number} [options.context=3] unchanged lines kept around a change (Infinity: all of them); a button shows the rest
|
|
78
|
+
* @param {string} [options.originalLabel]
|
|
79
|
+
* @param {string} [options.modifiedLabel]
|
|
80
|
+
* @returns {{element: HTMLElement, setTexts: (original: string, modified: string) => void, setMode: (mode: string) => void, getStats: () => {added: number, removed: number}}}
|
|
81
|
+
*/
|
|
82
|
+
export function createDiffView({ parent, original, modified, language, mode, context, originalLabel, modifiedLabel }?: {
|
|
83
|
+
parent?: string | HTMLElement;
|
|
84
|
+
original?: string;
|
|
85
|
+
modified?: string;
|
|
86
|
+
language?: string | object;
|
|
87
|
+
mode?: "unified" | "split";
|
|
88
|
+
context?: number;
|
|
89
|
+
originalLabel?: string;
|
|
90
|
+
modifiedLabel?: string;
|
|
91
|
+
}): {
|
|
92
|
+
element: HTMLElement;
|
|
93
|
+
setTexts: (original: string, modified: string) => void;
|
|
94
|
+
setMode: (mode: string) => void;
|
|
95
|
+
getStats: () => {
|
|
96
|
+
added: number;
|
|
97
|
+
removed: number;
|
|
98
|
+
};
|
|
99
|
+
};
|