athena-ui-js 2.4.0 → 2.4.1
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 +24 -2
- package/docs/styling.md +123 -123
- package/package.json +4 -1
- package/src/athena-ui.js +1 -1
- package/src/libs/config/config.js +1 -1
- package/src/libs/hephaestus/codeGenerator/codeEditor.js +1037 -0
- package/src/libs/hephaestus/codeGenerator/codeGenerator.js +286 -0
- package/src/libs/hephaestus/widgetGrid/widgetGrid.js +870 -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/codeGenerator/codeEditor.d.ts +60 -60
- package/types/libs/hephaestus/codeGenerator/codeGenerator.d.ts +99 -99
package/types/athena-ui.d.ts
CHANGED
|
@@ -1,103 +1,103 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Loads the theme, waits for the page and generates the layout.
|
|
3
|
-
*
|
|
4
|
-
* @param {object} [options]
|
|
5
|
-
* @param {{id?: number, href?: string}} [options.theme] registered theme id or custom stylesheet
|
|
6
|
-
* @param {object} [options.config] settings overriding the defaults (and the global appConfig)
|
|
7
|
-
* @param {Function} [options.nav] navigation callback (falls back to the global nav)
|
|
8
|
-
* @param {Function} [options.login] login callback (falls back to the global login)
|
|
9
|
-
* @param {Function} [options.register] registration callback (falls back to the global register)
|
|
10
|
-
* @param {Function} [options.lostPassword] lost password callback (falls back to the global lostPassword)
|
|
11
|
-
* @param {Function} [options.changePassword] change password callback (falls back to the global changePassword)
|
|
12
|
-
* @param {object} [options.menuItems] { headerMenu, footerMenu } (falls back to the global menuItems)
|
|
13
|
-
* @returns {Promise<object>} the effective configuration
|
|
14
|
-
*/
|
|
15
|
-
export function init(options?: {
|
|
16
|
-
theme?: {
|
|
17
|
-
id?: number;
|
|
18
|
-
href?: string;
|
|
19
|
-
};
|
|
20
|
-
config?: object;
|
|
21
|
-
nav?: Function;
|
|
22
|
-
login?: Function;
|
|
23
|
-
register?: Function;
|
|
24
|
-
lostPassword?: Function;
|
|
25
|
-
changePassword?: Function;
|
|
26
|
-
menuItems?: object;
|
|
27
|
-
}): Promise<object>;
|
|
28
|
-
/**
|
|
29
|
-
* Starts Athena UI inside an element of your page instead of the body, so it can be one part of a larger page (or of several apps).
|
|
30
|
-
* It does what init() does (settings, language, theme, hooks), and the layout (container, header, wrapper, footer) is generated into
|
|
31
|
-
* `root`. The parts follow the settings: `config: { generateHeader: false, generateFooter: false }` leaves only the wrapper, which is where
|
|
32
|
-
* the components go by default (the element with the id "wrapper"). One app per page: the parts have fixed ids.
|
|
33
|
-
*
|
|
34
|
-
* @param {object} options the options of init(), and
|
|
35
|
-
* @param {string|Element} options.root the element to build into (an element, an id or a selector)
|
|
36
|
-
* @returns {Promise<{element: HTMLElement, container: HTMLElement, header: HTMLElement|null, wrapper: HTMLElement|null, footer: HTMLElement|null,
|
|
37
|
-
* config: object, update: Function, destroy: Function}>}
|
|
38
|
-
*/
|
|
39
|
-
export function createApp(options?: {
|
|
40
|
-
root: string | Element;
|
|
41
|
-
}): Promise<{
|
|
42
|
-
element: HTMLElement;
|
|
43
|
-
container: HTMLElement;
|
|
44
|
-
header: HTMLElement | null;
|
|
45
|
-
wrapper: HTMLElement | null;
|
|
46
|
-
footer: HTMLElement | null;
|
|
47
|
-
config: object;
|
|
48
|
-
update: Function;
|
|
49
|
-
destroy: Function;
|
|
50
|
-
}>;
|
|
51
|
-
/**
|
|
52
|
-
* Switches the theme at runtime: { id } of a registered theme or { href } of a stylesheet.
|
|
53
|
-
* @returns {Promise<object>} the applied theme
|
|
54
|
-
*/
|
|
55
|
-
export function setTheme(selected: any): Promise<object>;
|
|
56
|
-
export { default as Cookies } from "./libs/core/cookies.js";
|
|
57
|
-
export * from "./libs/core/elementGenerator.js";
|
|
58
|
-
export * from "./libs/core/controls.js";
|
|
59
|
-
export * from "./libs/core/hungarianControls.js";
|
|
60
|
-
export * from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
|
|
61
|
-
export * from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
|
|
62
|
-
export * from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
|
|
63
|
-
export * from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
|
|
64
|
-
export * from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
|
|
65
|
-
export * from "./libs/hephaestus/MenuGenerator/menuGenerator.js";
|
|
66
|
-
export * from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
|
|
67
|
-
export * from "./libs/hephaestus/formGenerator/registrationFormGenerator.js";
|
|
68
|
-
export * from "./libs/hephaestus/formGenerator/lostPasswordFormGenerator.js";
|
|
69
|
-
export * from "./libs/hephaestus/chartGenerator/chartGenerator.js";
|
|
70
|
-
export * from "./libs/hephaestus/tableGenerator/tableGenerator.js";
|
|
71
|
-
export * from "./libs/hephaestus/formGenerator/changePasswordFormGenerator.js";
|
|
72
|
-
export * from "./libs/hephaestus/formGenerator/formBuilder.js";
|
|
73
|
-
export * from "./libs/hephaestus/formGenerator/authForms.js";
|
|
74
|
-
export * from "./libs/hephaestus/feedbackGenerator/feedbackGenerator.js";
|
|
75
|
-
export * from "./libs/hephaestus/dialogGenerator/dialogGenerator.js";
|
|
76
|
-
export * from "./libs/hephaestus/navigationGenerator/navigationGenerator.js";
|
|
77
|
-
export * from "./libs/hephaestus/componentGenerator/componentGenerator.js";
|
|
78
|
-
export * from "./libs/hephaestus/inputGenerator/inputGenerator.js";
|
|
79
|
-
export * from "./libs/hephaestus/inputGenerator/dropZoneGenerator.js";
|
|
80
|
-
export * from "./libs/hephaestus/inputGenerator/richTextGenerator.js";
|
|
81
|
-
export * from "./libs/core/sanitize.js";
|
|
82
|
-
export * from "./libs/hephaestus/router/router.js";
|
|
83
|
-
export * from "./libs/hephaestus/auth/session.js";
|
|
84
|
-
export * from "./libs/hephaestus/auth/authState.js";
|
|
85
|
-
export * from "./libs/core/i18n.js";
|
|
86
|
-
export * from "./libs/core/validation.js";
|
|
87
|
-
export * from "./libs/core/csv.js";
|
|
88
|
-
export * from "./libs/core/dateRange.js";
|
|
89
|
-
export * from "./libs/core/format.js";
|
|
90
|
-
export * from "./libs/core/motion.js";
|
|
91
|
-
export * from "./libs/hephaestus/widgetGrid/widgetGrid.js";
|
|
92
|
-
export * from "./libs/core/gridLayout.js";
|
|
93
|
-
export * from "./libs/hephaestus/codeGenerator/codeGenerator.js";
|
|
94
|
-
export * from "./libs/hephaestus/codeGenerator/codeEditor.js";
|
|
95
|
-
export * from "./libs/core/codeLanguages.js";
|
|
96
|
-
export * from "./libs/core/codeDiff.js";
|
|
97
|
-
export * from "./libs/hephaestus/modalGenerator/modalGenerator.js";
|
|
98
|
-
export * from "./libs/core/theme.js";
|
|
99
|
-
export * from "./libs/hephaestus/componentGenerator/themePicker.js";
|
|
100
|
-
import config from "./libs/config/config.js";
|
|
101
|
-
import { loadScript } from "./libs/hephaestus/hephaestus.js";
|
|
102
|
-
export { config, loadScript };
|
|
103
|
-
export { el, setContent, resolveElement, asHandle, createSafeBuilder } from "./libs/core/dom.js";
|
|
1
|
+
/**
|
|
2
|
+
* Loads the theme, waits for the page and generates the layout.
|
|
3
|
+
*
|
|
4
|
+
* @param {object} [options]
|
|
5
|
+
* @param {{id?: number, href?: string}} [options.theme] registered theme id or custom stylesheet
|
|
6
|
+
* @param {object} [options.config] settings overriding the defaults (and the global appConfig)
|
|
7
|
+
* @param {Function} [options.nav] navigation callback (falls back to the global nav)
|
|
8
|
+
* @param {Function} [options.login] login callback (falls back to the global login)
|
|
9
|
+
* @param {Function} [options.register] registration callback (falls back to the global register)
|
|
10
|
+
* @param {Function} [options.lostPassword] lost password callback (falls back to the global lostPassword)
|
|
11
|
+
* @param {Function} [options.changePassword] change password callback (falls back to the global changePassword)
|
|
12
|
+
* @param {object} [options.menuItems] { headerMenu, footerMenu } (falls back to the global menuItems)
|
|
13
|
+
* @returns {Promise<object>} the effective configuration
|
|
14
|
+
*/
|
|
15
|
+
export function init(options?: {
|
|
16
|
+
theme?: {
|
|
17
|
+
id?: number;
|
|
18
|
+
href?: string;
|
|
19
|
+
};
|
|
20
|
+
config?: object;
|
|
21
|
+
nav?: Function;
|
|
22
|
+
login?: Function;
|
|
23
|
+
register?: Function;
|
|
24
|
+
lostPassword?: Function;
|
|
25
|
+
changePassword?: Function;
|
|
26
|
+
menuItems?: object;
|
|
27
|
+
}): Promise<object>;
|
|
28
|
+
/**
|
|
29
|
+
* Starts Athena UI inside an element of your page instead of the body, so it can be one part of a larger page (or of several apps).
|
|
30
|
+
* It does what init() does (settings, language, theme, hooks), and the layout (container, header, wrapper, footer) is generated into
|
|
31
|
+
* `root`. The parts follow the settings: `config: { generateHeader: false, generateFooter: false }` leaves only the wrapper, which is where
|
|
32
|
+
* the components go by default (the element with the id "wrapper"). One app per page: the parts have fixed ids.
|
|
33
|
+
*
|
|
34
|
+
* @param {object} options the options of init(), and
|
|
35
|
+
* @param {string|Element} options.root the element to build into (an element, an id or a selector)
|
|
36
|
+
* @returns {Promise<{element: HTMLElement, container: HTMLElement, header: HTMLElement|null, wrapper: HTMLElement|null, footer: HTMLElement|null,
|
|
37
|
+
* config: object, update: Function, destroy: Function}>}
|
|
38
|
+
*/
|
|
39
|
+
export function createApp(options?: {
|
|
40
|
+
root: string | Element;
|
|
41
|
+
}): Promise<{
|
|
42
|
+
element: HTMLElement;
|
|
43
|
+
container: HTMLElement;
|
|
44
|
+
header: HTMLElement | null;
|
|
45
|
+
wrapper: HTMLElement | null;
|
|
46
|
+
footer: HTMLElement | null;
|
|
47
|
+
config: object;
|
|
48
|
+
update: Function;
|
|
49
|
+
destroy: Function;
|
|
50
|
+
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Switches the theme at runtime: { id } of a registered theme or { href } of a stylesheet.
|
|
53
|
+
* @returns {Promise<object>} the applied theme
|
|
54
|
+
*/
|
|
55
|
+
export function setTheme(selected: any): Promise<object>;
|
|
56
|
+
export { default as Cookies } from "./libs/core/cookies.js";
|
|
57
|
+
export * from "./libs/core/elementGenerator.js";
|
|
58
|
+
export * from "./libs/core/controls.js";
|
|
59
|
+
export * from "./libs/core/hungarianControls.js";
|
|
60
|
+
export * from "./libs/hephaestus/LayoutGenerator/basicLayoutGenerator.js";
|
|
61
|
+
export * from "./libs/hephaestus/LayoutGenerator/headerContentGenerator.js";
|
|
62
|
+
export * from "./libs/hephaestus/LayoutGenerator/wrapperContentGenerator.js";
|
|
63
|
+
export * from "./libs/hephaestus/LayoutGenerator/footerContentGenerator.js";
|
|
64
|
+
export * from "./libs/hephaestus/MenuGenerator/basicMenuGenerator.js";
|
|
65
|
+
export * from "./libs/hephaestus/MenuGenerator/menuGenerator.js";
|
|
66
|
+
export * from "./libs/hephaestus/formGenerator/loginFormGenerator.js";
|
|
67
|
+
export * from "./libs/hephaestus/formGenerator/registrationFormGenerator.js";
|
|
68
|
+
export * from "./libs/hephaestus/formGenerator/lostPasswordFormGenerator.js";
|
|
69
|
+
export * from "./libs/hephaestus/chartGenerator/chartGenerator.js";
|
|
70
|
+
export * from "./libs/hephaestus/tableGenerator/tableGenerator.js";
|
|
71
|
+
export * from "./libs/hephaestus/formGenerator/changePasswordFormGenerator.js";
|
|
72
|
+
export * from "./libs/hephaestus/formGenerator/formBuilder.js";
|
|
73
|
+
export * from "./libs/hephaestus/formGenerator/authForms.js";
|
|
74
|
+
export * from "./libs/hephaestus/feedbackGenerator/feedbackGenerator.js";
|
|
75
|
+
export * from "./libs/hephaestus/dialogGenerator/dialogGenerator.js";
|
|
76
|
+
export * from "./libs/hephaestus/navigationGenerator/navigationGenerator.js";
|
|
77
|
+
export * from "./libs/hephaestus/componentGenerator/componentGenerator.js";
|
|
78
|
+
export * from "./libs/hephaestus/inputGenerator/inputGenerator.js";
|
|
79
|
+
export * from "./libs/hephaestus/inputGenerator/dropZoneGenerator.js";
|
|
80
|
+
export * from "./libs/hephaestus/inputGenerator/richTextGenerator.js";
|
|
81
|
+
export * from "./libs/core/sanitize.js";
|
|
82
|
+
export * from "./libs/hephaestus/router/router.js";
|
|
83
|
+
export * from "./libs/hephaestus/auth/session.js";
|
|
84
|
+
export * from "./libs/hephaestus/auth/authState.js";
|
|
85
|
+
export * from "./libs/core/i18n.js";
|
|
86
|
+
export * from "./libs/core/validation.js";
|
|
87
|
+
export * from "./libs/core/csv.js";
|
|
88
|
+
export * from "./libs/core/dateRange.js";
|
|
89
|
+
export * from "./libs/core/format.js";
|
|
90
|
+
export * from "./libs/core/motion.js";
|
|
91
|
+
export * from "./libs/hephaestus/widgetGrid/widgetGrid.js";
|
|
92
|
+
export * from "./libs/core/gridLayout.js";
|
|
93
|
+
export * from "./libs/hephaestus/codeGenerator/codeGenerator.js";
|
|
94
|
+
export * from "./libs/hephaestus/codeGenerator/codeEditor.js";
|
|
95
|
+
export * from "./libs/core/codeLanguages.js";
|
|
96
|
+
export * from "./libs/core/codeDiff.js";
|
|
97
|
+
export * from "./libs/hephaestus/modalGenerator/modalGenerator.js";
|
|
98
|
+
export * from "./libs/core/theme.js";
|
|
99
|
+
export * from "./libs/hephaestus/componentGenerator/themePicker.js";
|
|
100
|
+
import config from "./libs/config/config.js";
|
|
101
|
+
import { loadScript } from "./libs/hephaestus/hephaestus.js";
|
|
102
|
+
export { config, loadScript };
|
|
103
|
+
export { el, setContent, resolveElement, asHandle, createSafeBuilder } from "./libs/core/dom.js";
|
package/types/code.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./libs/hephaestus/codeGenerator/codeGenerator.js";
|
|
2
|
-
export * from "./libs/hephaestus/codeGenerator/codeEditor.js";
|
|
3
|
-
export * from "./libs/core/codeLanguages.js";
|
|
4
|
-
export * from "./libs/core/codeDiff.js";
|
|
1
|
+
export * from "./libs/hephaestus/codeGenerator/codeGenerator.js";
|
|
2
|
+
export * from "./libs/hephaestus/codeGenerator/codeEditor.js";
|
|
3
|
+
export * from "./libs/core/codeLanguages.js";
|
|
4
|
+
export * from "./libs/core/codeDiff.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function applyConfig(...sources: any[]): {
|
|
2
|
-
version: "2.4.
|
|
2
|
+
version: "2.4.1";
|
|
3
3
|
container_class: "container";
|
|
4
4
|
header_class: "header-container";
|
|
5
5
|
header_menu_class: "header-menu menu";
|
|
@@ -32,7 +32,7 @@ export function applyConfig(...sources: any[]): {
|
|
|
32
32
|
export function withBorder(className: any): any;
|
|
33
33
|
export const BORDERED_CLASS: "default-cointainer-bordered";
|
|
34
34
|
export const defaults: Readonly<{
|
|
35
|
-
version: "2.4.
|
|
35
|
+
version: "2.4.1";
|
|
36
36
|
container_class: "container";
|
|
37
37
|
header_class: "header-container";
|
|
38
38
|
header_menu_class: "header-menu menu";
|
|
@@ -64,7 +64,7 @@ export const defaults: Readonly<{
|
|
|
64
64
|
}>;
|
|
65
65
|
export default config;
|
|
66
66
|
declare namespace config {
|
|
67
|
-
let version: "2.4.
|
|
67
|
+
let version: "2.4.1";
|
|
68
68
|
let container_class: "container";
|
|
69
69
|
let header_class: "header-container";
|
|
70
70
|
let header_menu_class: "header-menu menu";
|
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The difference between two lists of lines, as operations in order. `a` and `b` are indexes into the two lists.
|
|
3
|
-
* When the two lists differ by more than `maxEdits` lines the result is coarse (everything removed, then everything added) instead of slow.
|
|
4
|
-
*
|
|
5
|
-
* @param {string[]} oldLines
|
|
6
|
-
* @param {string[]} newLines
|
|
7
|
-
* @param {{maxEdits?: number}} [options]
|
|
8
|
-
* @returns {DiffOp[]}
|
|
9
|
-
*/
|
|
10
|
-
export function diffLines(oldLines: string[], newLines: string[], { maxEdits }?: {
|
|
11
|
-
maxEdits?: number;
|
|
12
|
-
}): DiffOp[];
|
|
13
|
-
/**
|
|
14
|
-
* Groups the operations into hunks that show `context` unchanged lines around each change (Infinity: everything is one hunk).
|
|
15
|
-
* @returns {{ops: DiffOp[], skippedBefore: number}[]} `skippedBefore` is the number of unchanged lines left out before the hunk
|
|
16
|
-
*/
|
|
17
|
-
export function hunksOf(ops: any, context?: number): {
|
|
18
|
-
ops: DiffOp[];
|
|
19
|
-
skippedBefore: number;
|
|
20
|
-
}[];
|
|
21
|
-
export function splitLines(text: any): string[];
|
|
22
|
-
export type DiffOp = {
|
|
23
|
-
type: "equal";
|
|
24
|
-
a: number;
|
|
25
|
-
b: number;
|
|
26
|
-
} | {
|
|
27
|
-
type: "remove";
|
|
28
|
-
a: number;
|
|
29
|
-
} | {
|
|
30
|
-
type: "add";
|
|
31
|
-
b: number;
|
|
32
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* The difference between two lists of lines, as operations in order. `a` and `b` are indexes into the two lists.
|
|
3
|
+
* When the two lists differ by more than `maxEdits` lines the result is coarse (everything removed, then everything added) instead of slow.
|
|
4
|
+
*
|
|
5
|
+
* @param {string[]} oldLines
|
|
6
|
+
* @param {string[]} newLines
|
|
7
|
+
* @param {{maxEdits?: number}} [options]
|
|
8
|
+
* @returns {DiffOp[]}
|
|
9
|
+
*/
|
|
10
|
+
export function diffLines(oldLines: string[], newLines: string[], { maxEdits }?: {
|
|
11
|
+
maxEdits?: number;
|
|
12
|
+
}): DiffOp[];
|
|
13
|
+
/**
|
|
14
|
+
* Groups the operations into hunks that show `context` unchanged lines around each change (Infinity: everything is one hunk).
|
|
15
|
+
* @returns {{ops: DiffOp[], skippedBefore: number}[]} `skippedBefore` is the number of unchanged lines left out before the hunk
|
|
16
|
+
*/
|
|
17
|
+
export function hunksOf(ops: any, context?: number): {
|
|
18
|
+
ops: DiffOp[];
|
|
19
|
+
skippedBefore: number;
|
|
20
|
+
}[];
|
|
21
|
+
export function splitLines(text: any): string[];
|
|
22
|
+
export type DiffOp = {
|
|
23
|
+
type: "equal";
|
|
24
|
+
a: number;
|
|
25
|
+
b: number;
|
|
26
|
+
} | {
|
|
27
|
+
type: "remove";
|
|
28
|
+
a: number;
|
|
29
|
+
} | {
|
|
30
|
+
type: "add";
|
|
31
|
+
b: number;
|
|
32
|
+
};
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
/** Registers a language (and its aliases). */
|
|
2
|
-
export function registerLanguage(language: any): void;
|
|
3
|
-
/**
|
|
4
|
-
* Splits text into tokens: [{ type, text }]. `type` is null for plain text. Concatenating the texts gives the input back.
|
|
5
|
-
* An unknown language, or a text that is too long, gives one plain token.
|
|
6
|
-
*/
|
|
7
|
-
export function tokenize(text: any, language: any): any[];
|
|
8
|
-
export function getLanguage(name: any): any;
|
|
9
|
-
export function getLanguages(): any[];
|
|
10
|
-
/** The token types the default theme gives a colour to: the classes are `tok-<type>`. */
|
|
11
|
-
export const TOKEN_TYPES: string[];
|
|
12
|
-
/**
|
|
13
|
-
* A language: an ordered list of rules. The text is scanned once; at every position the first rule that matches wins.
|
|
14
|
-
*/
|
|
15
|
-
export type CodeLanguage = {
|
|
16
|
-
name: string;
|
|
17
|
-
/**
|
|
18
|
-
* shown in the label of a code block (default: the name)
|
|
19
|
-
*/
|
|
20
|
-
label?: string;
|
|
21
|
-
/**
|
|
22
|
-
* other names ("js" for "javascript")
|
|
23
|
-
*/
|
|
24
|
-
aliases?: string[];
|
|
25
|
-
/**
|
|
26
|
-
* `type` becomes the class `tok-<type>`;
|
|
27
|
-
* the pattern must use non-capturing groups only; `inner` splits a match into smaller tokens (a tag into name and attributes)
|
|
28
|
-
*/
|
|
29
|
-
rules: {
|
|
30
|
-
type: string;
|
|
31
|
-
pattern: RegExp;
|
|
32
|
-
inner?: (text: string) => {
|
|
33
|
-
type: string | null;
|
|
34
|
-
text: string;
|
|
35
|
-
}[];
|
|
36
|
-
}[];
|
|
37
|
-
/**
|
|
38
|
-
* the rules are case-insensitive (SQL)
|
|
39
|
-
*/
|
|
40
|
-
ignoreCase?: boolean;
|
|
41
|
-
/**
|
|
42
|
-
* ^ and $ match at every line (YAML, C# preprocessor lines)
|
|
43
|
-
*/
|
|
44
|
-
multiline?: boolean;
|
|
45
|
-
/**
|
|
46
|
-
* used by the editor to comment lines ("//")
|
|
47
|
-
*/
|
|
48
|
-
lineComment?: string;
|
|
49
|
-
blockComment?: [string, string];
|
|
50
|
-
/**
|
|
51
|
-
* characters the editor closes: ["()", "[]", "{}", "\"\"", "''"]
|
|
52
|
-
*/
|
|
53
|
-
pairs?: string[];
|
|
54
|
-
/**
|
|
55
|
-
* a line that matches this makes the next line one level deeper (/[{(\[:]\s*$/)
|
|
56
|
-
*/
|
|
57
|
-
indentAfter?: RegExp;
|
|
58
|
-
};
|
|
1
|
+
/** Registers a language (and its aliases). */
|
|
2
|
+
export function registerLanguage(language: any): void;
|
|
3
|
+
/**
|
|
4
|
+
* Splits text into tokens: [{ type, text }]. `type` is null for plain text. Concatenating the texts gives the input back.
|
|
5
|
+
* An unknown language, or a text that is too long, gives one plain token.
|
|
6
|
+
*/
|
|
7
|
+
export function tokenize(text: any, language: any): any[];
|
|
8
|
+
export function getLanguage(name: any): any;
|
|
9
|
+
export function getLanguages(): any[];
|
|
10
|
+
/** The token types the default theme gives a colour to: the classes are `tok-<type>`. */
|
|
11
|
+
export const TOKEN_TYPES: string[];
|
|
12
|
+
/**
|
|
13
|
+
* A language: an ordered list of rules. The text is scanned once; at every position the first rule that matches wins.
|
|
14
|
+
*/
|
|
15
|
+
export type CodeLanguage = {
|
|
16
|
+
name: string;
|
|
17
|
+
/**
|
|
18
|
+
* shown in the label of a code block (default: the name)
|
|
19
|
+
*/
|
|
20
|
+
label?: string;
|
|
21
|
+
/**
|
|
22
|
+
* other names ("js" for "javascript")
|
|
23
|
+
*/
|
|
24
|
+
aliases?: string[];
|
|
25
|
+
/**
|
|
26
|
+
* `type` becomes the class `tok-<type>`;
|
|
27
|
+
* the pattern must use non-capturing groups only; `inner` splits a match into smaller tokens (a tag into name and attributes)
|
|
28
|
+
*/
|
|
29
|
+
rules: {
|
|
30
|
+
type: string;
|
|
31
|
+
pattern: RegExp;
|
|
32
|
+
inner?: (text: string) => {
|
|
33
|
+
type: string | null;
|
|
34
|
+
text: string;
|
|
35
|
+
}[];
|
|
36
|
+
}[];
|
|
37
|
+
/**
|
|
38
|
+
* the rules are case-insensitive (SQL)
|
|
39
|
+
*/
|
|
40
|
+
ignoreCase?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* ^ and $ match at every line (YAML, C# preprocessor lines)
|
|
43
|
+
*/
|
|
44
|
+
multiline?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* used by the editor to comment lines ("//")
|
|
47
|
+
*/
|
|
48
|
+
lineComment?: string;
|
|
49
|
+
blockComment?: [string, string];
|
|
50
|
+
/**
|
|
51
|
+
* characters the editor closes: ["()", "[]", "{}", "\"\"", "''"]
|
|
52
|
+
*/
|
|
53
|
+
pairs?: string[];
|
|
54
|
+
/**
|
|
55
|
+
* a line that matches this makes the next line one level deeper (/[{(\[:]\s*$/)
|
|
56
|
+
*/
|
|
57
|
+
indentAfter?: RegExp;
|
|
58
|
+
};
|
|
@@ -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;
|