@gooddata/sdk-ui-metric-component 11.67.0-alpha.1 → 11.67.0-alpha.3
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/NOTICE +943 -2401
- package/esm/MaqlEditor/codemirror/CodeEditor.d.ts +52 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.js +170 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.styles.d.ts +95 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.styles.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/CodeEditor.styles.js +536 -0
- package/esm/MaqlEditor/codemirror/ContextMenu.d.ts +52 -0
- package/esm/MaqlEditor/codemirror/ContextMenu.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/ContextMenu.js +204 -0
- package/esm/MaqlEditor/codemirror/baseExtensions.d.ts +22 -0
- package/esm/MaqlEditor/codemirror/baseExtensions.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/baseExtensions.js +95 -0
- package/esm/MaqlEditor/codemirror/commands.d.ts +21 -0
- package/esm/MaqlEditor/codemirror/commands.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/commands.js +98 -0
- package/esm/MaqlEditor/codemirror/hooks/useAutofocus.d.ts +7 -0
- package/esm/MaqlEditor/codemirror/hooks/useAutofocus.d.ts.map +1 -0
- package/esm/MaqlEditor/{monaco → codemirror}/hooks/useAutofocus.js +4 -0
- package/esm/MaqlEditor/codemirror/lsp.d.ts +28 -0
- package/esm/MaqlEditor/codemirror/lsp.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/lsp.js +70 -0
- package/esm/MaqlEditor/codemirror/markdown.d.ts +11 -0
- package/esm/MaqlEditor/codemirror/markdown.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/markdown.js +28 -0
- package/esm/MaqlEditor/codemirror/types.d.ts +8 -0
- package/esm/MaqlEditor/codemirror/types.d.ts.map +1 -0
- package/esm/MaqlEditor/codemirror/types.js +2 -0
- package/esm/MaqlEditor/hooks/useCodeTheme.d.ts +15 -2
- package/esm/MaqlEditor/hooks/useCodeTheme.d.ts.map +1 -1
- package/esm/MaqlEditor/hooks/useCodeTheme.js +36 -43
- package/esm/MaqlEditor/hooks/useCopyToClipboard.d.ts +7 -2
- package/esm/MaqlEditor/hooks/useCopyToClipboard.d.ts.map +1 -1
- package/esm/MaqlEditor/hooks/useCopyToClipboard.js +53 -10
- package/esm/MaqlEditor/maql/MaqlEditor.d.ts +25 -9
- package/esm/MaqlEditor/maql/MaqlEditor.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/MaqlEditor.js +179 -30
- package/esm/MaqlEditor/maql/MaqlEditor.styles.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/MaqlEditor.styles.js +13 -17
- package/esm/MaqlEditor/maql/MaqlEditor.tooltip.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/MaqlEditor.tooltip.js +15 -20
- package/esm/MaqlEditor/maql/extensions/completion.d.ts +101 -0
- package/esm/MaqlEditor/maql/extensions/completion.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/completion.js +420 -0
- package/esm/MaqlEditor/maql/extensions/decorations.d.ts +19 -0
- package/esm/MaqlEditor/maql/extensions/decorations.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/decorations.js +137 -0
- package/esm/MaqlEditor/maql/extensions/formatting.d.ts +22 -0
- package/esm/MaqlEditor/maql/extensions/formatting.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/formatting.js +78 -0
- package/esm/MaqlEditor/maql/extensions/hover.d.ts +22 -0
- package/esm/MaqlEditor/maql/extensions/hover.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/hover.js +98 -0
- package/esm/MaqlEditor/maql/extensions/semanticTokens.d.ts +15 -0
- package/esm/MaqlEditor/maql/extensions/semanticTokens.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/semanticTokens.js +79 -0
- package/esm/MaqlEditor/maql/extensions/validation.d.ts +41 -0
- package/esm/MaqlEditor/maql/extensions/validation.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/extensions/validation.js +202 -0
- package/esm/MaqlEditor/maql/hooks/hover/doHover.d.ts +19 -4
- package/esm/MaqlEditor/maql/hooks/hover/doHover.d.ts.map +1 -1
- package/esm/MaqlEditor/maql/hooks/hover/doHover.js +71 -61
- package/esm/MaqlEditor/maql/maqlLanguage.d.ts +16 -0
- package/esm/MaqlEditor/maql/maqlLanguage.d.ts.map +1 -0
- package/esm/MaqlEditor/maql/maqlLanguage.js +72 -0
- package/esm/MaqlEditor/mock/editor-shim.d.ts +7 -0
- package/esm/MaqlEditor/mock/editor-shim.d.ts.map +1 -0
- package/esm/MaqlEditor/mock/{monaco-shim.js → editor-shim.js} +27 -1
- package/esm/MaqlEditor/sql/SqlEditor.d.ts +15 -7
- package/esm/MaqlEditor/sql/SqlEditor.d.ts.map +1 -1
- package/esm/MaqlEditor/sql/SqlEditor.js +55 -30
- package/esm/MaqlEditor/sql/formatter.d.ts +6 -5
- package/esm/MaqlEditor/sql/formatter.d.ts.map +1 -1
- package/esm/MaqlEditor/sql/formatter.js +14 -14
- package/esm/MaqlEditor/sql/sqlLanguage.d.ts +3 -0
- package/esm/MaqlEditor/sql/sqlLanguage.d.ts.map +1 -0
- package/esm/MaqlEditor/sql/sqlLanguage.js +19 -0
- package/esm/MaqlEditor/statusBar/SuggestionStatusBar.d.ts +5 -2
- package/esm/MaqlEditor/statusBar/SuggestionStatusBar.d.ts.map +1 -1
- package/esm/MaqlEditor/statusBar/SuggestionStatusBar.js +20 -8
- package/esm/MetricComponent/Form/MaqlEditorField/MaqlEditorEditor.d.ts.map +1 -1
- package/esm/MetricComponent/Form/MaqlEditorField/MaqlEditorEditor.js +28 -27
- package/esm/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.d.ts +0 -1
- package/esm/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.d.ts.map +1 -1
- package/esm/MetricComponent/Form/MaqlEditorField/suggestionDetailsFunctions.js +4 -29
- package/esm/MetricComponent/Form/MaqlResult/MaqlSql.d.ts.map +1 -1
- package/esm/MetricComponent/Form/MaqlResult/MaqlSql.js +4 -2
- package/esm/MetricComponent/Form/maqlFieldFunctions.d.ts +2 -5
- package/esm/MetricComponent/Form/maqlFieldFunctions.d.ts.map +1 -1
- package/esm/MetricComponent/Form/maqlFieldFunctions.js +1 -4
- package/esm/index.d.ts +3 -3
- package/esm/index.d.ts.map +1 -1
- package/esm/index.js +1 -1
- package/esm/sdk-ui-metric-component.d.ts +50 -39
- package/esm/shared/permissions.d.ts.map +1 -1
- package/esm/shared/permissions.js +1 -0
- package/esm/translations/en-US.json +36 -0
- package/package.json +33 -30
- package/esm/MaqlEditor/hooks/useAutoformat.d.ts +0 -3
- package/esm/MaqlEditor/hooks/useAutoformat.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useAutoformat.js +0 -15
- package/esm/MaqlEditor/hooks/useCleanCallback.d.ts +0 -4
- package/esm/MaqlEditor/hooks/useCleanCallback.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useCleanCallback.js +0 -12
- package/esm/MaqlEditor/hooks/useMountCallback.d.ts +0 -13
- package/esm/MaqlEditor/hooks/useMountCallback.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useMountCallback.js +0 -26
- package/esm/MaqlEditor/hooks/useUpdateCallback.d.ts +0 -19
- package/esm/MaqlEditor/hooks/useUpdateCallback.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useUpdateCallback.js +0 -63
- package/esm/MaqlEditor/hooks/useValueCallbacks.d.ts +0 -6
- package/esm/MaqlEditor/hooks/useValueCallbacks.d.ts.map +0 -1
- package/esm/MaqlEditor/hooks/useValueCallbacks.js +0 -14
- package/esm/MaqlEditor/maql/formatter.d.ts +0 -6
- package/esm/MaqlEditor/maql/formatter.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/formatter.js +0 -14
- package/esm/MaqlEditor/maql/hooks/hover/useHoverEvent.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/hover/useHoverEvent.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/hover/useHoverEvent.js +0 -32
- package/esm/MaqlEditor/maql/hooks/useAutocomplete.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useAutocomplete.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useAutocomplete.js +0 -60
- package/esm/MaqlEditor/maql/hooks/useDecoration.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useDecoration.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useDecoration.js +0 -73
- package/esm/MaqlEditor/maql/hooks/useDocumentFormatting.d.ts +0 -3
- package/esm/MaqlEditor/maql/hooks/useDocumentFormatting.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useDocumentFormatting.js +0 -29
- package/esm/MaqlEditor/maql/hooks/useHover.d.ts +0 -6
- package/esm/MaqlEditor/maql/hooks/useHover.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useHover.js +0 -77
- package/esm/MaqlEditor/maql/hooks/useLanguageConfiguration.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useLanguageConfiguration.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useLanguageConfiguration.js +0 -21
- package/esm/MaqlEditor/maql/hooks/useMonaco.d.ts +0 -21
- package/esm/MaqlEditor/maql/hooks/useMonaco.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useMonaco.js +0 -75
- package/esm/MaqlEditor/maql/hooks/useSemanticHighlight.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useSemanticHighlight.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useSemanticHighlight.js +0 -33
- package/esm/MaqlEditor/maql/hooks/useSyntaxHighlight.d.ts +0 -2
- package/esm/MaqlEditor/maql/hooks/useSyntaxHighlight.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useSyntaxHighlight.js +0 -28
- package/esm/MaqlEditor/maql/hooks/useValidation.d.ts +0 -4
- package/esm/MaqlEditor/maql/hooks/useValidation.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/hooks/useValidation.js +0 -56
- package/esm/MaqlEditor/maql/monacoConverter.d.ts +0 -80
- package/esm/MaqlEditor/maql/monacoConverter.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/monacoConverter.js +0 -528
- package/esm/MaqlEditor/maql/utils.d.ts +0 -4
- package/esm/MaqlEditor/maql/utils.d.ts.map +0 -1
- package/esm/MaqlEditor/maql/utils.js +0 -6
- package/esm/MaqlEditor/mock/monaco-shim.d.ts +0 -5
- package/esm/MaqlEditor/mock/monaco-shim.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/MonacoEditor.d.ts +0 -64
- package/esm/MaqlEditor/monaco/MonacoEditor.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/MonacoEditor.js +0 -71
- package/esm/MaqlEditor/monaco/MonacoEditor.styles.d.ts +0 -53
- package/esm/MaqlEditor/monaco/MonacoEditor.styles.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/MonacoEditor.styles.js +0 -427
- package/esm/MaqlEditor/monaco/hooks/useAutofocus.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useAutofocus.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useDefaultValue.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useDefaultValue.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useDefaultValue.js +0 -14
- package/esm/MaqlEditor/monaco/hooks/useEditorInit.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useEditorInit.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useEditorInit.js +0 -84
- package/esm/MaqlEditor/monaco/hooks/useEditorOptions.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useEditorOptions.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useEditorOptions.js +0 -51
- package/esm/MaqlEditor/monaco/hooks/useMonaco.d.ts +0 -3
- package/esm/MaqlEditor/monaco/hooks/useMonaco.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/hooks/useMonaco.js +0 -24
- package/esm/MaqlEditor/monaco/monacoContributions.d.ts +0 -74
- package/esm/MaqlEditor/monaco/monacoContributions.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/monacoContributions.js +0 -88
- package/esm/MaqlEditor/monaco/monacoWorkers.d.ts +0 -53
- package/esm/MaqlEditor/monaco/monacoWorkers.d.ts.map +0 -1
- package/esm/MaqlEditor/monaco/monacoWorkers.js +0 -176
- package/esm/MaqlEditor/sql/hooks/useDocumentFormatting.d.ts +0 -2
- package/esm/MaqlEditor/sql/hooks/useDocumentFormatting.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/hooks/useDocumentFormatting.js +0 -26
- package/esm/MaqlEditor/sql/hooks/useLanguageConfiguration.d.ts +0 -4
- package/esm/MaqlEditor/sql/hooks/useLanguageConfiguration.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/hooks/useLanguageConfiguration.js +0 -29
- package/esm/MaqlEditor/sql/hooks/useMonaco.d.ts +0 -14
- package/esm/MaqlEditor/sql/hooks/useMonaco.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/hooks/useMonaco.js +0 -26
- package/esm/MaqlEditor/sql/hooks/useSyntaxHighlight.d.ts +0 -2
- package/esm/MaqlEditor/sql/hooks/useSyntaxHighlight.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/hooks/useSyntaxHighlight.js +0 -796
- package/esm/MaqlEditor/sql/utils.d.ts +0 -4
- package/esm/MaqlEditor/sql/utils.d.ts.map +0 -1
- package/esm/MaqlEditor/sql/utils.js +0 -6
- package/worker/monaco-editor-worker.js +0 -33
- package/worker/monaco-editor-worker.source.js +0 -1
|
@@ -1,48 +1,41 @@
|
|
|
1
1
|
// (C) 2021-2026 GoodData Corporation
|
|
2
2
|
import { useMemo } from "react";
|
|
3
|
-
import { DecoratorAttribute, DecoratorComputedAttribute, DecoratorDataset, DecoratorDateAttribute, DecoratorDateLabel, DecoratorFact, DecoratorLabel, DecoratorMetric, DecoratorParameter, } from "../
|
|
3
|
+
import { DecoratorAttribute, DecoratorComputedAttribute, DecoratorDataset, DecoratorDateAttribute, DecoratorDateLabel, DecoratorFact, DecoratorLabel, DecoratorMetric, DecoratorParameter, } from "../codemirror/CodeEditor.styles.js";
|
|
4
|
+
function decorator(color) {
|
|
5
|
+
return {
|
|
6
|
+
color: `rgba(${color},1)`,
|
|
7
|
+
background: `rgba(${color},0.07)`,
|
|
8
|
+
};
|
|
9
|
+
}
|
|
4
10
|
export function useCodeTheme() {
|
|
5
|
-
return useMemo(() =>
|
|
6
|
-
"
|
|
7
|
-
{
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
],
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
[`editor.variable.${DecoratorAttribute}.color`]: "rgba(219,121,0,1)",
|
|
34
|
-
[`editor.variable.${DecoratorAttribute}.background`]: "rgba(219,121,0,0.07)",
|
|
35
|
-
[`editor.variable.${DecoratorLabel}.color`]: "rgba(219,121,0,1)",
|
|
36
|
-
[`editor.variable.${DecoratorLabel}.background`]: "rgba(219,121,0,0.07)",
|
|
37
|
-
[`editor.variable.${DecoratorComputedAttribute}.color`]: "rgba(219,121,0,1)",
|
|
38
|
-
[`editor.variable.${DecoratorComputedAttribute}.background`]: "rgba(219,121,0,0.07)",
|
|
39
|
-
[`editor.variable.${DecoratorDateAttribute}.color`]: "rgba(0,155,201,1)",
|
|
40
|
-
[`editor.variable.${DecoratorDateAttribute}.background`]: "rgba(0,155,201,0.07)",
|
|
41
|
-
[`editor.variable.${DecoratorDateLabel}.color`]: "rgba(0,155,201,1)",
|
|
42
|
-
[`editor.variable.${DecoratorDateLabel}.background`]: "rgba(0,155,201,0.07)",
|
|
43
|
-
[`editor.variable.${DecoratorParameter}.color`]: "rgba(148,161,173,1)",
|
|
44
|
-
[`editor.variable.${DecoratorParameter}.background`]: "rgba(148,161,173,0.07)",
|
|
45
|
-
},
|
|
11
|
+
return useMemo(() => ({
|
|
12
|
+
background: "#FCFCFD",
|
|
13
|
+
tokens: {
|
|
14
|
+
keyword: "#7364CF",
|
|
15
|
+
function: "#7364CF",
|
|
16
|
+
type: "#7364CF",
|
|
17
|
+
operator: "#464E56",
|
|
18
|
+
variable: "#464E56",
|
|
19
|
+
attribute: "#DB7900",
|
|
20
|
+
label: "#DB7900",
|
|
21
|
+
fact: "#00A67D",
|
|
22
|
+
metric: "#00A67D",
|
|
23
|
+
dataset: "#952F8E",
|
|
24
|
+
string: "#D95791",
|
|
25
|
+
number: "#D95791",
|
|
26
|
+
comment: "#94A1AD",
|
|
27
|
+
bracket: "#0431FA",
|
|
28
|
+
},
|
|
29
|
+
decorators: {
|
|
30
|
+
[DecoratorFact]: decorator("0,166,125"),
|
|
31
|
+
[DecoratorMetric]: decorator("0,166,125"),
|
|
32
|
+
[DecoratorDataset]: decorator("149,47,142"),
|
|
33
|
+
[DecoratorAttribute]: decorator("219,121,0"),
|
|
34
|
+
[DecoratorLabel]: decorator("219,121,0"),
|
|
35
|
+
[DecoratorComputedAttribute]: decorator("219,121,0"),
|
|
36
|
+
[DecoratorDateAttribute]: decorator("0,155,201"),
|
|
37
|
+
[DecoratorDateLabel]: decorator("0,155,201"),
|
|
38
|
+
[DecoratorParameter]: decorator("148,161,173"),
|
|
46
39
|
},
|
|
47
|
-
|
|
40
|
+
}), []);
|
|
48
41
|
}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
|
|
1
|
+
import { type EditorView } from "@codemirror/view";
|
|
2
|
+
/**
|
|
3
|
+
* Copies the whole content of the editor, and selects it so the user sees what was copied.
|
|
4
|
+
*
|
|
5
|
+
* @returns whether the text reached the clipboard
|
|
6
|
+
*/
|
|
7
|
+
export declare function useCopyToClipboard(): (editor: EditorView | null | undefined) => Promise<boolean>;
|
|
3
8
|
//# sourceMappingURL=useCopyToClipboard.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCopyToClipboard.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/hooks/useCopyToClipboard.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"useCopyToClipboard.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/hooks/useCopyToClipboard.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,kBAAkB,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI,GAAG,SAAS,KAAK,OAAO,CAAC,OAAO,CAAC,CAiBhG"}
|
|
@@ -1,16 +1,59 @@
|
|
|
1
1
|
// (C) 2021-2026 GoodData Corporation
|
|
2
2
|
import { useCallback } from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Copies the whole content of the editor, and selects it so the user sees what was copied.
|
|
5
|
+
*
|
|
6
|
+
* @returns whether the text reached the clipboard
|
|
7
|
+
*/
|
|
3
8
|
export function useCopyToClipboard() {
|
|
4
|
-
return useCallback((editor) => {
|
|
5
|
-
if (editor) {
|
|
6
|
-
|
|
7
|
-
if (range) {
|
|
8
|
-
editor.setSelection(range);
|
|
9
|
-
editor.focus();
|
|
10
|
-
editor.trigger("editor", "editor.action.clipboardCopyAction", {});
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
9
|
+
return useCallback(async (editor) => {
|
|
10
|
+
if (!editor) {
|
|
11
|
+
return false;
|
|
13
12
|
}
|
|
14
|
-
|
|
13
|
+
const doc = editor.state.doc;
|
|
14
|
+
const copied = await copyText(doc.toString());
|
|
15
|
+
// The selection shows what was copied, so it is pointless once the content differs.
|
|
16
|
+
if (editor.state.doc === doc) {
|
|
17
|
+
editor.dispatch({ selection: { anchor: 0, head: doc.length } });
|
|
18
|
+
editor.focus();
|
|
19
|
+
}
|
|
20
|
+
return copied;
|
|
15
21
|
}, []);
|
|
16
22
|
}
|
|
23
|
+
async function copyText(text) {
|
|
24
|
+
if (navigator.clipboard?.writeText) {
|
|
25
|
+
try {
|
|
26
|
+
await navigator.clipboard.writeText(text);
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
// Rejected without the permission or focus; the legacy command may still work.
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
return copyWithCommand(text);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The legacy copy takes the selection of the document, which a read-only editor does not have: its
|
|
37
|
+
* content is not editable, so it cannot be focused and CodeMirror does not put its selection in the
|
|
38
|
+
* DOM. The text is copied from a temporary text area instead.
|
|
39
|
+
*/
|
|
40
|
+
function copyWithCommand(text) {
|
|
41
|
+
const textarea = document.createElement("textarea");
|
|
42
|
+
textarea.value = text;
|
|
43
|
+
textarea.setAttribute("readonly", "");
|
|
44
|
+
textarea.setAttribute("aria-hidden", "true");
|
|
45
|
+
textarea.style.position = "fixed";
|
|
46
|
+
textarea.style.top = "0";
|
|
47
|
+
textarea.style.left = "-10000px";
|
|
48
|
+
document.body.appendChild(textarea);
|
|
49
|
+
textarea.select();
|
|
50
|
+
try {
|
|
51
|
+
return document.execCommand("copy");
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return false;
|
|
55
|
+
}
|
|
56
|
+
finally {
|
|
57
|
+
textarea.remove();
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { type Ref } from "react";
|
|
2
|
+
import { type KeyBinding } from "@codemirror/view";
|
|
2
3
|
import { type IMetadataObject } from "@gooddata/sdk-model";
|
|
3
|
-
import { type
|
|
4
|
-
import { type
|
|
4
|
+
import { type IMaqlEditorIcons } from "../codemirror/CodeEditor.styles.js";
|
|
5
|
+
import { type MaqlEditorView } from "../codemirror/types.js";
|
|
5
6
|
import { type MaqlEditorDefaultTheme } from "../theme/default.js";
|
|
6
7
|
/**
|
|
7
8
|
* @internal
|
|
@@ -17,19 +18,34 @@ export interface IMaqlEditorApi {
|
|
|
17
18
|
export interface IMaqlEditorProps {
|
|
18
19
|
cssTheme?: MaqlEditorDefaultTheme;
|
|
19
20
|
autofocus?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Show the first error when the editor gets the focus, until the code changes or becomes valid.
|
|
23
|
+
*/
|
|
20
24
|
autohint?: boolean;
|
|
21
25
|
decorators?: boolean;
|
|
22
26
|
defaultValue?: string;
|
|
23
27
|
readonly?: boolean;
|
|
24
28
|
inline?: boolean;
|
|
25
29
|
icons?: IMaqlEditorIcons;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The accessible name of the editor.
|
|
32
|
+
*/
|
|
33
|
+
ariaLabel?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Extra key bindings of the host. They win over the editor's own.
|
|
36
|
+
*/
|
|
37
|
+
keyBindings?: readonly KeyBinding[];
|
|
38
|
+
onFocus?: (editor: MaqlEditorView) => void;
|
|
39
|
+
onBlur?: (editor: MaqlEditorView) => void;
|
|
40
|
+
onEditorMount?: (editor: MaqlEditorView) => void;
|
|
41
|
+
onEditorUpdate?: (editor: MaqlEditorView) => void;
|
|
42
|
+
onChange?: (editor: MaqlEditorView, value: string) => void;
|
|
43
|
+
onValid?: (editor: MaqlEditorView, valid: boolean) => void;
|
|
44
|
+
onMetricOpen?: (editor: MaqlEditorView, object: IMetadataObject) => void;
|
|
45
|
+
/**
|
|
46
|
+
* Called when the user shows or hides the documentation of the suggestions.
|
|
47
|
+
*/
|
|
48
|
+
onToggleSuggestionDetails?: (editor: MaqlEditorView, visible: boolean) => void;
|
|
33
49
|
ref?: Ref<IMaqlEditorApi | null>;
|
|
34
50
|
}
|
|
35
51
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaqlEditor.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/maql/MaqlEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"MaqlEditor.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/maql/MaqlEditor.tsx"],"names":[],"mappings":"AAEA,OAAO,EACH,KAAK,GAAG,EASX,MAAM,OAAO,CAAC;AAGf,OAAO,EAAc,KAAK,UAAU,EAAU,MAAM,kBAAkB,CAAC;AAKvE,OAAO,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAI3D,OAAO,EAAE,KAAK,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAI7D,OAAO,EAAE,KAAK,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAsBlE;;GAEG;AACH,MAAM,WAAW,cAAc;IAC3B,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,QAAQ,EAAE,MAAM,MAAM,CAAC;IACvB,QAAQ,EAAE,MAAM,OAAO,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC7B,QAAQ,CAAC,EAAE,sBAAsB,CAAC;IAClC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,gBAAgB,CAAC;IACzB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;OAEG;IACH,WAAW,CAAC,EAAE,SAAS,UAAU,EAAE,CAAC;IACpC,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAC3C,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAC1C,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IACjD,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,KAAK,IAAI,CAAC;IAClD,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC3D,OAAO,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IAC3D,YAAY,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,eAAe,KAAK,IAAI,CAAC;IACzE;;OAEG;IACH,yBAAyB,CAAC,EAAE,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,OAAO,KAAK,IAAI,CAAC;IAC/E,GAAG,CAAC,EAAE,GAAG,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;CACpC;AAED;;GAEG;AACH,eAAO,MAAM,UAAU,0HA8NrB,CAAC"}
|
|
@@ -1,45 +1,194 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
// (C) 2021-2026 GoodData Corporation
|
|
3
|
-
import { forwardRef, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useInsertionEffect, useMemo, useRef, useState, } from "react";
|
|
4
|
+
import { EditorState, Prec } from "@codemirror/state";
|
|
5
|
+
import { EditorView, keymap } from "@codemirror/view";
|
|
4
6
|
import classNames from "classnames";
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
+
import { FormattedMessage, useIntl } from "react-intl";
|
|
8
|
+
import { useBackendStrict, useWorkspaceStrict } from "@gooddata/sdk-ui";
|
|
9
|
+
import { CodeEditor } from "../codemirror/CodeEditor.js";
|
|
10
|
+
import { platformShortcut, useCommonMenuItems } from "../codemirror/ContextMenu.js";
|
|
7
11
|
import { useCodeTheme } from "../hooks/useCodeTheme.js";
|
|
8
|
-
import {
|
|
9
|
-
//more info in README.md
|
|
10
|
-
import { StatusBar } from "../statusBar/SuggestionStatusBar.js";
|
|
12
|
+
import { StatusBar, suggestionElementObserver } from "../statusBar/SuggestionStatusBar.js";
|
|
11
13
|
import { ThemeProvider } from "../theme/theme.js";
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
14
|
+
import { maqlCompletion } from "./extensions/completion.js";
|
|
15
|
+
import { decorationsPlugin, maqlDecorations } from "./extensions/decorations.js";
|
|
16
|
+
import { formatMaqlDocument, formatMaqlSelection, maqlFormattingKeymap } from "./extensions/formatting.js";
|
|
17
|
+
import { maqlHover } from "./extensions/hover.js";
|
|
18
|
+
import { semanticTokens } from "./extensions/semanticTokens.js";
|
|
19
|
+
import { initialValidity, isValid, maqlDiagnosticWidget, maqlLinter, showNextDiagnostic, validityListener, } from "./extensions/validation.js";
|
|
20
|
+
import { useLanguageService } from "./hooks/useLanguageService.js";
|
|
21
|
+
import { useLanguageServiceInitializer } from "./hooks/useLanguageServiceInitializer.js";
|
|
15
22
|
import { MaqlEditorClass, MaqlEditorTestClass, MaqlStyles } from "./MaqlEditor.styles.js";
|
|
23
|
+
import { destroyMaqlTooltip } from "./MaqlEditor.tooltip.js";
|
|
24
|
+
import { maqlLanguageSupport } from "./maqlLanguage.js";
|
|
16
25
|
/**
|
|
17
26
|
* @internal
|
|
18
27
|
*/
|
|
19
|
-
export const MaqlEditor = forwardRef(function MaqlEditor({ readonly = false, inline = false, autofocus = false, decorators = true, autohint = false, defaultValue = "", cssTheme, icons, onFocus, onBlur, onEditorMount, onEditorUpdate, onMetricOpen, onValid, onChange, }, ref) {
|
|
20
|
-
const [
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
28
|
+
export const MaqlEditor = forwardRef(function MaqlEditor({ readonly = false, inline = false, autofocus = false, decorators = true, autohint = false, defaultValue = "", cssTheme, icons, ariaLabel, keyBindings, onFocus, onBlur, onEditorMount, onEditorUpdate, onMetricOpen, onToggleSuggestionDetails, onValid, onChange, }, ref) {
|
|
29
|
+
const [suggestionList, setSuggestionList] = useState(null);
|
|
30
|
+
const [suggestionElement, setSuggestionElement] = useState(null);
|
|
31
|
+
const codeTheme = useCodeTheme();
|
|
32
|
+
const editor = useRef(null);
|
|
33
|
+
const languageService = useLanguageService();
|
|
34
|
+
const initializeData = useLanguageServiceInitializer(languageService);
|
|
35
|
+
const hints = useAutohint(autohint);
|
|
36
|
+
const handlers = useLatest({
|
|
27
37
|
onFocus,
|
|
28
38
|
onBlur,
|
|
29
|
-
onEditorMount,
|
|
30
|
-
onEditorUpdate,
|
|
31
|
-
onValid,
|
|
32
39
|
onChange,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
const
|
|
38
|
-
const
|
|
40
|
+
onValid,
|
|
41
|
+
onMetricOpen,
|
|
42
|
+
onToggleSuggestionDetails,
|
|
43
|
+
});
|
|
44
|
+
const backend = useBackendStrict();
|
|
45
|
+
const workspaceId = useWorkspaceStrict();
|
|
46
|
+
const intl = useIntl();
|
|
47
|
+
const hoverSettings = useLatest({ backend, workspaceId, intl });
|
|
48
|
+
const tooltip = useRef(null);
|
|
49
|
+
const reportValidity = useCallback((view, valid) => {
|
|
50
|
+
if (valid) {
|
|
51
|
+
hints.set(false);
|
|
52
|
+
}
|
|
53
|
+
handlers.current.onValid?.(view, valid);
|
|
54
|
+
}, [handlers, hints]);
|
|
55
|
+
const serviceExtensions = useMemo(() => {
|
|
56
|
+
if (!languageService || !initializeData) {
|
|
57
|
+
return [];
|
|
58
|
+
}
|
|
59
|
+
const { capabilities } = initializeData;
|
|
60
|
+
const legend = capabilities.semanticTokensProvider?.legend;
|
|
61
|
+
return [
|
|
62
|
+
legend ? semanticTokens(languageService, legend) : [],
|
|
63
|
+
maqlCompletion({
|
|
64
|
+
languageService,
|
|
65
|
+
triggerCharacters: capabilities.completionProvider?.triggerCharacters ?? [],
|
|
66
|
+
onList: setSuggestionList,
|
|
67
|
+
onDocsToggle: (view, visible) => handlers.current.onToggleSuggestionDetails?.(view, visible),
|
|
68
|
+
}),
|
|
69
|
+
capabilities.hoverProvider
|
|
70
|
+
? maqlHover({
|
|
71
|
+
languageService,
|
|
72
|
+
tooltip,
|
|
73
|
+
getSettings: () => hoverSettings.current,
|
|
74
|
+
onOpen: (view, object) => handlers.current.onMetricOpen?.(view, object),
|
|
75
|
+
})
|
|
76
|
+
: [],
|
|
77
|
+
maqlLinter(languageService),
|
|
78
|
+
initialValidity(languageService, reportValidity),
|
|
79
|
+
maqlFormattingKeymap(languageService),
|
|
80
|
+
];
|
|
81
|
+
}, [languageService, initializeData, hoverSettings, handlers, reportValidity]);
|
|
82
|
+
const decorationsExtension = useMemo(() => (languageService ? decorationsPlugin(languageService, decorators) : []), [languageService, decorators]);
|
|
83
|
+
const editorExtensions = useMemo(() => [
|
|
84
|
+
maqlLanguageSupport(),
|
|
85
|
+
maqlDecorations(),
|
|
86
|
+
maqlDiagnosticWidget(),
|
|
87
|
+
suggestionElementObserver(setSuggestionElement),
|
|
88
|
+
validityListener(reportValidity),
|
|
89
|
+
EditorView.updateListener.of((update) => {
|
|
90
|
+
if (update.docChanged) {
|
|
91
|
+
hints.set(false);
|
|
92
|
+
handlers.current.onChange?.(update.view, update.state.doc.toString());
|
|
93
|
+
}
|
|
94
|
+
}),
|
|
95
|
+
EditorView.domEventHandlers({
|
|
96
|
+
focus: (_event, view) => {
|
|
97
|
+
if (hints.get()) {
|
|
98
|
+
showNextDiagnostic(view);
|
|
99
|
+
}
|
|
100
|
+
handlers.current.onFocus?.(view);
|
|
101
|
+
return false;
|
|
102
|
+
},
|
|
103
|
+
blur: (_event, view) => {
|
|
104
|
+
handlers.current.onBlur?.(view);
|
|
105
|
+
return false;
|
|
106
|
+
},
|
|
107
|
+
}),
|
|
108
|
+
], [handlers, hints, reportValidity]);
|
|
109
|
+
const keyBindingsExtension = useMemo(() => (keyBindings?.length ? Prec.highest(keymap.of([...keyBindings])) : []), [keyBindings]);
|
|
110
|
+
// The labels the editor renders itself, in the locale of the application.
|
|
111
|
+
const phrasesExtension = useMemo(() => EditorState.phrases.of({
|
|
112
|
+
Documentation: intl.formatMessage({
|
|
113
|
+
id: "metricComponent.editMetric.suggestion.documentation",
|
|
114
|
+
}),
|
|
115
|
+
Close: intl.formatMessage({ id: "metricComponent.editMetric.suggestion.closeDocumentation" }),
|
|
116
|
+
}), [intl]);
|
|
117
|
+
const commonMenuItems = useCommonMenuItems();
|
|
118
|
+
const contextMenu = useMemo(() => {
|
|
119
|
+
const formatting = languageService
|
|
120
|
+
? [
|
|
121
|
+
{
|
|
122
|
+
id: "format-document",
|
|
123
|
+
group: "edit",
|
|
124
|
+
label: intl.formatMessage({
|
|
125
|
+
id: "metricComponent.editMetric.contextMenu.formatDocument",
|
|
126
|
+
}),
|
|
127
|
+
shortcut: platformShortcut("⇧⌥F", "Shift+Alt+F"),
|
|
128
|
+
run: (view) => formatMaqlDocument(view, languageService),
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
id: "format-selection",
|
|
132
|
+
group: "edit",
|
|
133
|
+
label: intl.formatMessage({
|
|
134
|
+
id: "metricComponent.editMetric.contextMenu.formatSelection",
|
|
135
|
+
}),
|
|
136
|
+
shortcut: platformShortcut("⌘K ⌘F", "Ctrl+K Ctrl+F"),
|
|
137
|
+
run: (view) => formatMaqlSelection(view, languageService),
|
|
138
|
+
},
|
|
139
|
+
]
|
|
140
|
+
: [];
|
|
141
|
+
return [commonMenuItems.changeAllOccurrences, ...formatting, ...commonMenuItems.clipboard];
|
|
142
|
+
}, [intl, languageService, commonMenuItems]);
|
|
143
|
+
const extensions = useMemo(() => [
|
|
144
|
+
keyBindingsExtension,
|
|
145
|
+
phrasesExtension,
|
|
146
|
+
editorExtensions,
|
|
147
|
+
serviceExtensions,
|
|
148
|
+
decorationsExtension,
|
|
149
|
+
], [keyBindingsExtension, phrasesExtension, editorExtensions, serviceExtensions, decorationsExtension]);
|
|
150
|
+
const onMount = useCallback((view) => {
|
|
151
|
+
editor.current = view;
|
|
152
|
+
onEditorMount?.(view);
|
|
153
|
+
}, [onEditorMount]);
|
|
39
154
|
useImperativeHandle(ref, () => ({
|
|
40
|
-
autoformat: () =>
|
|
41
|
-
|
|
42
|
-
|
|
155
|
+
autoformat: () => {
|
|
156
|
+
const view = editor.current;
|
|
157
|
+
if (view && languageService) {
|
|
158
|
+
void formatMaqlDocument(view, languageService).then(() => view.focus());
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
getValid: () => (editor.current ? isValid(editor.current.state) : false),
|
|
162
|
+
getValue: () => editor.current?.state.doc.toString() ?? "",
|
|
43
163
|
}));
|
|
44
|
-
|
|
164
|
+
useEffect(() => () => destroyMaqlTooltip(tooltip), []);
|
|
165
|
+
return (_jsxs(ThemeProvider, { theme: cssTheme, children: [_jsx(MaqlStyles, {}), _jsx(CodeEditor, { inline: inline, readonly: readonly, autofocus: autofocus, className: classNames(MaqlEditorClass, MaqlEditorTestClass), defaultValue: defaultValue, codeTheme: codeTheme, icons: icons, ariaLabel: ariaLabel, extensions: extensions, contextMenu: contextMenu, onEditorMount: onMount, onEditorUpdate: onEditorUpdate, ref: editor }), _jsx(StatusBar, { where: suggestionElement, children: suggestionList?.isIncomplete && (_jsx(FormattedMessage, { id: "metricEditor.status.lotsOfItemsInSuggestionResults" })) })] }));
|
|
45
166
|
});
|
|
167
|
+
/**
|
|
168
|
+
* The latest value of changing props, readable from the editor extensions without rebuilding them.
|
|
169
|
+
*/
|
|
170
|
+
function useLatest(value) {
|
|
171
|
+
const ref = useRef(value);
|
|
172
|
+
// Written on commit, not during render: React may throw a render away, and the editor's
|
|
173
|
+
// listeners must not see the values of a render that never committed.
|
|
174
|
+
useInsertionEffect(() => {
|
|
175
|
+
ref.current = value;
|
|
176
|
+
});
|
|
177
|
+
return ref;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* The autohint prop as a flag the editor extensions read and clear: a change of the prop sets
|
|
181
|
+
* it, a change of the code or a valid validation clears it.
|
|
182
|
+
*/
|
|
183
|
+
function useAutohint(autohint) {
|
|
184
|
+
const value = useRef(autohint);
|
|
185
|
+
useInsertionEffect(() => {
|
|
186
|
+
value.current = autohint;
|
|
187
|
+
}, [autohint]);
|
|
188
|
+
return useMemo(() => ({
|
|
189
|
+
get: () => value.current,
|
|
190
|
+
set: (next) => {
|
|
191
|
+
value.current = next;
|
|
192
|
+
},
|
|
193
|
+
}), []);
|
|
194
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaqlEditor.styles.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/maql/MaqlEditor.styles.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MaqlEditor.styles.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/maql/MaqlEditor.styles.tsx"],"names":[],"mappings":"AAYA,wBAAgB,UAAU,4CAIzB;AA+GD,eAAO,MAAM,eAAe,gBAAgB,CAAC;AAC7C,eAAO,MAAM,mBAAmB,kBAAkB,CAAC;AACnD,eAAO,MAAM,WAAW,wBAAwB,CAAC;AACjD,eAAO,MAAM,sBAAsB,uCAAuC,CAAC;AAC3E,eAAO,MAAM,UAAU,mBAAmB,CAAC;AAE3C,wBAAgB,iBAAiB,4CAIhC"}
|
|
@@ -2,6 +2,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
// (C) 2021-2026 GoodData Corporation
|
|
3
3
|
import { useMemo } from "react";
|
|
4
4
|
import { GlobalStyles } from "tss-react";
|
|
5
|
+
import { DOCS_CLASS } from "../codemirror/CodeEditor.styles.js";
|
|
5
6
|
import { ExpandedClass } from "../components/ExpandableTooltip.js";
|
|
6
7
|
import { makeStyles } from "../theme/styles.js";
|
|
7
8
|
const useStyles = makeStyles()(() => ({}));
|
|
@@ -56,10 +57,7 @@ function useMaqlStyles() {
|
|
|
56
57
|
fontSize: `${theme.doc.code.fontSize}px`,
|
|
57
58
|
lineHeight: `${theme.doc.code.lineHeight}px`,
|
|
58
59
|
color: theme.doc.code.color,
|
|
59
|
-
"
|
|
60
|
-
paddingBottom: "5px",
|
|
61
|
-
color: theme.doc.code.color,
|
|
62
|
-
},
|
|
60
|
+
whiteSpace: "pre-wrap",
|
|
63
61
|
};
|
|
64
62
|
const img = {
|
|
65
63
|
maxWidth: "100%",
|
|
@@ -76,20 +74,18 @@ function useMaqlStyles() {
|
|
|
76
74
|
return selectors.join(", ");
|
|
77
75
|
}
|
|
78
76
|
return {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
padding: "0 !important",
|
|
84
|
-
},
|
|
85
|
-
h1: h1,
|
|
86
|
-
h2: h2,
|
|
87
|
-
h3: h3,
|
|
88
|
-
"p, ul": p,
|
|
89
|
-
".code": code,
|
|
90
|
-
img: img,
|
|
91
|
-
[h1pSelector("h1")]: h1p,
|
|
77
|
+
[`.cm-completionInfo .${DOCS_CLASS}`]: {
|
|
78
|
+
fontFamily: theme.doc.font,
|
|
79
|
+
"& > :first-child": {
|
|
80
|
+
marginTop: 0,
|
|
92
81
|
},
|
|
82
|
+
h1: h1,
|
|
83
|
+
h2: h2,
|
|
84
|
+
h3: h3,
|
|
85
|
+
"p, ul": p,
|
|
86
|
+
"pre, code": code,
|
|
87
|
+
img: img,
|
|
88
|
+
[h1pSelector("h1")]: h1p,
|
|
93
89
|
},
|
|
94
90
|
};
|
|
95
91
|
}, [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MaqlEditor.tooltip.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/maql/MaqlEditor.tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAwC,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"MaqlEditor.tooltip.d.ts","sourceRoot":"","sources":["../../../src/MaqlEditor/maql/MaqlEditor.tooltip.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,gBAAgB,EAAwC,MAAM,OAAO,CAAC;AAIpF,OAAO,EAAkC,KAAK,SAAS,EAAW,MAAM,YAAY,CAAC;AAErF,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAIxE,OAAO,EAAE,KAAK,QAAQ,EAAiC,MAAM,oCAAoC,CAAC;AA8IlG,MAAM,WAAW,uBAAuB;IACpC,OAAO,EAAE,aAAa,CAAC;IACvB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;CACnB;AAkBD,MAAM,WAAW,8BAA8B;IAC3C,OAAO,EAAE,aAAa,CAAC;CAC1B;AAmGD,MAAM,MAAM,mBAAmB,GAAG;IAC9B,OAAO,EAAE,aAAa,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,WAAW,CAAC,CAAC;IAC7B;;;OAGG;IACH,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,CAAC,EAAE,KAAK,CACjB;QACI,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;KAClB,GACD,SAAS,CACd,CAAC;CACL,CAAC;AACF,wBAAgB,iBAAiB,CAC7B,GAAG,EAAE,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAC,EACtC,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,EAAE,EAAE,mBAAmB,EACzG,MAAM,CAAC,EAAE,MAAM,IAAI,EACnB,SAAS,CAAC,EAAE,MAAM,IAAI,GACvB,IAAI,CA0BN;AAED,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,gBAAgB,CAAC,QAAQ,GAAG,IAAI,CAAC,GAAG,IAAI,CAE/E"}
|
|
@@ -2,17 +2,17 @@ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-run
|
|
|
2
2
|
// (C) 2021-2026 GoodData Corporation
|
|
3
3
|
import { useEffect, useMemo, useRef, useState } from "react";
|
|
4
4
|
import classNames from "classnames";
|
|
5
|
-
import { FormattedMessage, IntlProvider } from "react-intl";
|
|
5
|
+
import { FormattedMessage, IntlProvider, useIntl } from "react-intl";
|
|
6
6
|
import { BackendProvider, WorkspaceProvider } from "@gooddata/sdk-ui";
|
|
7
|
+
import { CodeEditor, MainClassContent } from "../codemirror/CodeEditor.js";
|
|
7
8
|
import { destroyTooltip, renderTooltip } from "../components/ExpandableTooltip.js";
|
|
8
9
|
import { useExpandableTooltip } from "../components/hooks/useExpandableTooltip.js";
|
|
9
10
|
import { useCodeTheme } from "../hooks/useCodeTheme.js";
|
|
10
|
-
import { MainClassContent, MonacoEditor, } from "../monaco/MonacoEditor.js";
|
|
11
11
|
import { makeStyles } from "../theme/styles.js";
|
|
12
|
-
import {
|
|
13
|
-
import { useDecoration } from "./hooks/useDecoration.js";
|
|
12
|
+
import { decorationsPlugin, maqlDecorations } from "./extensions/decorations.js";
|
|
14
13
|
import { useLanguageService } from "./hooks/useLanguageService.js";
|
|
15
14
|
import { MaqlTooltip, MaqlTooltipEditorClass, TooltipMaqlStyles } from "./MaqlEditor.styles.js";
|
|
15
|
+
import { maqlLanguageSupport } from "./maqlLanguage.js";
|
|
16
16
|
const BiggerClass = "bigger";
|
|
17
17
|
const SmallerClass = "smaller";
|
|
18
18
|
const ExpandedClass = "expanded";
|
|
@@ -110,12 +110,10 @@ const useStyles = makeStyles()((theme) => {
|
|
|
110
110
|
maxWidth: "100%",
|
|
111
111
|
minHeight: `0 !important`,
|
|
112
112
|
maxHeight: `${normalSize}px !important`,
|
|
113
|
-
"
|
|
113
|
+
overflow: "auto",
|
|
114
|
+
".cm-content": {
|
|
114
115
|
paddingLeft: `${padding}px !important`,
|
|
115
116
|
},
|
|
116
|
-
textarea: {
|
|
117
|
-
marginLeft: `${padding + 1}px !important`,
|
|
118
|
-
},
|
|
119
117
|
},
|
|
120
118
|
[`&.${SmallerClass}`]: {
|
|
121
119
|
[`.${MainClassContent}`]: {
|
|
@@ -135,11 +133,15 @@ function MaqlEditorTooltip({ content, intl, backend, workspaceId }) {
|
|
|
135
133
|
}
|
|
136
134
|
function MaqlEditorTooltipContent({ content }) {
|
|
137
135
|
const { classes, cx } = useStyles();
|
|
136
|
+
const intl = useIntl();
|
|
138
137
|
const { title, description, maql } = content;
|
|
139
|
-
const
|
|
140
|
-
const
|
|
141
|
-
const
|
|
142
|
-
|
|
138
|
+
const languageService = useLanguageService();
|
|
139
|
+
const codeTheme = useCodeTheme();
|
|
140
|
+
const extensions = useMemo(() => [
|
|
141
|
+
maqlLanguageSupport(),
|
|
142
|
+
maqlDecorations(),
|
|
143
|
+
languageService ? decorationsPlugin(languageService, true) : [],
|
|
144
|
+
], [languageService]);
|
|
143
145
|
const { expanded, setHasScrollbar } = useExpandableTooltip();
|
|
144
146
|
const [descriptionOpened, setDescriptionOpened] = useState(false);
|
|
145
147
|
const [readMore, setReadMore] = useState(false);
|
|
@@ -155,7 +157,7 @@ function MaqlEditorTooltipContent({ content }) {
|
|
|
155
157
|
if (descElement) {
|
|
156
158
|
descElement.scrollTop = 0;
|
|
157
159
|
}
|
|
158
|
-
}, children: _jsx(FormattedMessage, { id: "metricComponent.editMetric.hover.less" }) }) }))] })), expanded && _jsx("div", { className: cx(classes.description, ExpandedClass), children: description }), _jsx("div", { className: classes.hr }), _jsx("div", { className: cx(classes.maql, descriptionOpened && SmallerClass, expanded && ExpandedClass), children: _jsx(
|
|
160
|
+
}, children: _jsx(FormattedMessage, { id: "metricComponent.editMetric.hover.less" }) }) }))] })), expanded && _jsx("div", { className: cx(classes.description, ExpandedClass), children: description }), _jsx("div", { className: classes.hr }), _jsx("div", { className: cx(classes.maql, descriptionOpened && SmallerClass, expanded && ExpandedClass), children: _jsx(CodeEditor, { className: MaqlTooltipEditorClass, inline: true, lineNumbers: false, readonly: true, autofocus: false, defaultValue: maql, codeTheme: codeTheme, ariaLabel: intl.formatMessage({ id: "metricComponent.editMetric.hover.definition" }, { title }), extensions: extensions }) })] }) }));
|
|
159
161
|
}
|
|
160
162
|
export function renderMaqlTooltip(ref, { content, backend, workspaceId, intl, elements, anchor, readOnly, cachedPositions }, onOpen, onDestroy) {
|
|
161
163
|
if (!content) {
|
|
@@ -178,10 +180,3 @@ export function renderMaqlTooltip(ref, { content, backend, workspaceId, intl, el
|
|
|
178
180
|
export function destroyMaqlTooltip(ref) {
|
|
179
181
|
destroyTooltip(ref);
|
|
180
182
|
}
|
|
181
|
-
function useEditorOptions() {
|
|
182
|
-
return useMemo(() => ({
|
|
183
|
-
lineNumbers: "off",
|
|
184
|
-
lineNumbersMinChars: 0,
|
|
185
|
-
folding: false,
|
|
186
|
-
}), []);
|
|
187
|
-
}
|