@eccenca/gui-elements 24.0.1 → 24.1.0-featureimprovepublishingprocesscmem6356.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/CHANGELOG.md +82 -0
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js +7 -2
- package/dist/cjs/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/cjs/cmem/react-flow/StickyNoteModal/StickyNoteModal.js +3 -3
- package/dist/cjs/cmem/react-flow/StickyNoteModal/StickyNoteModal.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js +13 -3
- package/dist/cjs/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.js +3 -3
- package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.js.map +1 -1
- package/dist/cjs/components/AutocompleteField/AutoCompleteField.js +4 -2
- package/dist/cjs/components/AutocompleteField/AutoCompleteField.js.map +1 -1
- package/dist/cjs/components/Card/CardActions.js +2 -1
- package/dist/cjs/components/Card/CardActions.js.map +1 -1
- package/dist/cjs/components/Card/CardContent.js +4 -6
- package/dist/cjs/components/Card/CardContent.js.map +1 -1
- package/dist/cjs/components/ContentGroup/ContentGroup.js +95 -0
- package/dist/cjs/components/ContentGroup/ContentGroup.js.map +1 -0
- package/dist/cjs/components/Dialog/SimpleDialog.js +3 -3
- package/dist/cjs/components/Dialog/SimpleDialog.js.map +1 -1
- package/dist/cjs/components/Icon/canonicalIconNames.js +12 -0
- package/dist/cjs/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/cjs/components/Label/Label.js +8 -3
- package/dist/cjs/components/Label/Label.js.map +1 -1
- package/dist/cjs/components/Menu/MenuItem.js +3 -2
- package/dist/cjs/components/Menu/MenuItem.js.map +1 -1
- package/dist/cjs/components/OverviewItem/OverviewItem.js +5 -2
- package/dist/cjs/components/OverviewItem/OverviewItem.js.map +1 -1
- package/dist/cjs/components/OverviewItem/OverviewItemList.js +2 -2
- package/dist/cjs/components/OverviewItem/OverviewItemList.js.map +1 -1
- package/dist/cjs/components/Switch/Switch.js +6 -4
- package/dist/cjs/components/Switch/Switch.js.map +1 -1
- package/dist/cjs/components/Tag/TagList.js +1 -1
- package/dist/cjs/components/Tag/TagList.js.map +1 -1
- package/dist/cjs/components/TextField/SearchField.js +19 -2
- package/dist/cjs/components/TextField/SearchField.js.map +1 -1
- package/dist/cjs/components/Typography/OverflowText.js +1 -1
- package/dist/cjs/components/Typography/OverflowText.js.map +1 -1
- package/dist/cjs/components/index.js +1 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/extensions/codemirror/CodeMirror.js +93 -11
- package/dist/cjs/extensions/codemirror/CodeMirror.js.map +1 -1
- package/dist/cjs/extensions/codemirror/debouncedLinter.js +18 -0
- package/dist/cjs/extensions/codemirror/debouncedLinter.js.map +1 -0
- package/dist/cjs/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js +1 -1
- package/dist/cjs/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js.map +1 -1
- package/dist/cjs/extensions/codemirror/linters/jsLinter.js +36 -0
- package/dist/cjs/extensions/codemirror/linters/jsLinter.js.map +1 -0
- package/dist/cjs/extensions/codemirror/linters/turtleLinter.js +81 -0
- package/dist/cjs/extensions/codemirror/linters/turtleLinter.js.map +1 -0
- package/dist/cjs/extensions/codemirror/tests/codemirrorTestHelper.js +4 -1
- package/dist/cjs/extensions/codemirror/tests/codemirrorTestHelper.js.map +1 -1
- package/dist/cjs/extensions/codemirror/toolbars/commands/markdown.command.js +278 -0
- package/dist/cjs/extensions/codemirror/toolbars/commands/markdown.command.js.map +1 -0
- package/dist/cjs/extensions/codemirror/toolbars/markdown.toolbar.js +47 -0
- package/dist/cjs/extensions/codemirror/toolbars/markdown.toolbar.js.map +1 -0
- package/dist/cjs/extensions/codemirror/types.js +3 -0
- package/dist/cjs/extensions/codemirror/types.js.map +1 -0
- package/dist/cjs/extensions/react-flow/nodes/NodeContent.js +140 -41
- package/dist/cjs/extensions/react-flow/nodes/NodeContent.js.map +1 -1
- package/dist/cjs/extensions/react-flow/nodes/nodeUtils.js +5 -6
- package/dist/cjs/extensions/react-flow/nodes/nodeUtils.js.map +1 -1
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js +7 -2
- package/dist/esm/cmem/ActivityControl/ActivityControlWidget.js.map +1 -1
- package/dist/esm/cmem/react-flow/StickyNoteModal/StickyNoteModal.js +4 -4
- package/dist/esm/cmem/react-flow/StickyNoteModal/StickyNoteModal.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js +13 -3
- package/dist/esm/components/AutoSuggestion/AutoSuggestion.js.map +1 -1
- package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.js +14 -3
- package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.js.map +1 -1
- package/dist/esm/components/AutocompleteField/AutoCompleteField.js +4 -3
- package/dist/esm/components/AutocompleteField/AutoCompleteField.js.map +1 -1
- package/dist/esm/components/Card/CardActions.js +2 -1
- package/dist/esm/components/Card/CardActions.js.map +1 -1
- package/dist/esm/components/Card/CardContent.js +4 -5
- package/dist/esm/components/Card/CardContent.js.map +1 -1
- package/dist/esm/components/ContentGroup/ContentGroup.js +100 -0
- package/dist/esm/components/ContentGroup/ContentGroup.js.map +1 -0
- package/dist/esm/components/Dialog/SimpleDialog.js +4 -4
- package/dist/esm/components/Dialog/SimpleDialog.js.map +1 -1
- package/dist/esm/components/Icon/canonicalIconNames.js +12 -0
- package/dist/esm/components/Icon/canonicalIconNames.js.map +1 -1
- package/dist/esm/components/Label/Label.js +8 -3
- package/dist/esm/components/Label/Label.js.map +1 -1
- package/dist/esm/components/Menu/MenuItem.js +3 -2
- package/dist/esm/components/Menu/MenuItem.js.map +1 -1
- package/dist/esm/components/OverviewItem/OverviewItem.js +5 -2
- package/dist/esm/components/OverviewItem/OverviewItem.js.map +1 -1
- package/dist/esm/components/OverviewItem/OverviewItemList.js +2 -2
- package/dist/esm/components/OverviewItem/OverviewItemList.js.map +1 -1
- package/dist/esm/components/Switch/Switch.js +7 -5
- package/dist/esm/components/Switch/Switch.js.map +1 -1
- package/dist/esm/components/Tag/TagList.js +1 -1
- package/dist/esm/components/Tag/TagList.js.map +1 -1
- package/dist/esm/components/TextField/SearchField.js +35 -2
- package/dist/esm/components/TextField/SearchField.js.map +1 -1
- package/dist/esm/components/Typography/OverflowText.js +1 -1
- package/dist/esm/components/Typography/OverflowText.js.map +1 -1
- package/dist/esm/components/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/extensions/codemirror/CodeMirror.js +94 -13
- package/dist/esm/extensions/codemirror/CodeMirror.js.map +1 -1
- package/dist/esm/extensions/codemirror/debouncedLinter.js +15 -0
- package/dist/esm/extensions/codemirror/debouncedLinter.js.map +1 -0
- package/dist/esm/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js +1 -1
- package/dist/esm/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.js.map +1 -1
- package/dist/esm/extensions/codemirror/linters/jsLinter.js +32 -0
- package/dist/esm/extensions/codemirror/linters/jsLinter.js.map +1 -0
- package/dist/esm/extensions/codemirror/linters/turtleLinter.js +77 -0
- package/dist/esm/extensions/codemirror/linters/turtleLinter.js.map +1 -0
- package/dist/esm/extensions/codemirror/tests/codemirrorTestHelper.js +4 -0
- package/dist/esm/extensions/codemirror/tests/codemirrorTestHelper.js.map +1 -1
- package/dist/esm/extensions/codemirror/toolbars/commands/markdown.command.js +283 -0
- package/dist/esm/extensions/codemirror/toolbars/commands/markdown.command.js.map +1 -0
- package/dist/esm/extensions/codemirror/toolbars/markdown.toolbar.js +41 -0
- package/dist/esm/extensions/codemirror/toolbars/markdown.toolbar.js.map +1 -0
- package/dist/esm/extensions/codemirror/types.js +2 -0
- package/dist/esm/extensions/codemirror/types.js.map +1 -0
- package/dist/esm/extensions/react-flow/nodes/NodeContent.js +149 -48
- package/dist/esm/extensions/react-flow/nodes/NodeContent.js.map +1 -1
- package/dist/esm/extensions/react-flow/nodes/nodeUtils.js +5 -6
- package/dist/esm/extensions/react-flow/nodes/nodeUtils.js.map +1 -1
- package/dist/types/cmem/ActivityControl/ActivityControlWidget.d.ts +1 -1
- package/dist/types/cmem/react-flow/StickyNoteModal/StickyNoteModal.d.ts +5 -1
- package/dist/types/components/AutoSuggestion/ExtendedCodeEditor.d.ts +11 -6
- package/dist/types/components/Card/CardActions.d.ts +5 -1
- package/dist/types/components/Card/CardContent.d.ts +1 -2
- package/dist/types/components/ContentGroup/ContentGroup.d.ts +78 -0
- package/dist/types/components/Dialog/SimpleDialog.d.ts +4 -1
- package/dist/types/components/Icon/canonicalIconNames.d.ts +12 -0
- package/dist/types/components/Label/Label.d.ts +7 -1
- package/dist/types/components/Menu/MenuItem.d.ts +8 -1
- package/dist/types/components/OverviewItem/OverviewItem.d.ts +13 -1
- package/dist/types/components/OverviewItem/OverviewItemList.d.ts +3 -2
- package/dist/types/components/ProgressBar/ProgressBar.d.ts +2 -2
- package/dist/types/components/Structure/TitleSubsection.d.ts +7 -0
- package/dist/types/components/Switch/Switch.d.ts +3 -3
- package/dist/types/components/Tabs/Tab.d.ts +14 -0
- package/dist/types/components/TextField/SearchField.d.ts +1 -1
- package/dist/types/components/Typography/OverflowText.d.ts +23 -2
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/extensions/codemirror/CodeMirror.d.ts +32 -5
- package/dist/types/extensions/codemirror/debouncedLinter.d.ts +4 -0
- package/dist/types/extensions/codemirror/linters/jsLinter.d.ts +5 -0
- package/dist/types/extensions/codemirror/linters/turtleLinter.d.ts +5 -0
- package/dist/types/extensions/codemirror/tests/codemirrorTestHelper.d.ts +1 -0
- package/dist/types/extensions/codemirror/toolbars/commands/markdown.command.d.ts +55 -0
- package/dist/types/extensions/codemirror/toolbars/markdown.toolbar.d.ts +12 -0
- package/dist/types/extensions/codemirror/types.d.ts +5 -0
- package/dist/types/extensions/react-flow/nodes/NodeContent.d.ts +18 -4
- package/dist/types/extensions/react-flow/nodes/nodeUtils.d.ts +7 -6
- package/package.json +50 -47
- package/src/cmem/ActivityControl/ActivityControlWidget.tsx +5 -2
- package/src/cmem/react-flow/StickyNoteModal/StickyNoteModal.tsx +16 -2
- package/src/cmem/react-flow/configuration/_colors-graph.scss +4 -1
- package/src/cmem/react-flow/configuration/_colors-workflow.scss +3 -0
- package/src/components/AutoSuggestion/AutoSuggestion.tsx +14 -3
- package/src/components/AutoSuggestion/ExtendedCodeEditor.tsx +29 -6
- package/src/components/AutocompleteField/AutoCompleteField.tsx +5 -3
- package/src/components/Card/CardActions.tsx +6 -0
- package/src/components/Card/CardContent.tsx +8 -4
- package/src/components/Card/card.scss +15 -0
- package/src/components/CodeAutocompleteField/CodeAutocompleteField.stories.tsx +3 -2
- package/src/components/ContentGroup/ContentGroup.stories.tsx +47 -0
- package/src/components/ContentGroup/ContentGroup.tsx +256 -0
- package/src/components/ContentGroup/_contentgroup.scss +56 -0
- package/src/components/ContextOverlay/ContextOverlay.stories.tsx +15 -4
- package/src/components/Depiction/depiction.scss +7 -0
- package/src/components/Dialog/SimpleDialog.tsx +9 -2
- package/src/components/Dialog/stories/AlertDialog.stories.tsx +5 -1
- package/src/components/Dialog/stories/Modal.stories.tsx +4 -2
- package/src/components/Dialog/stories/SimpleDialog.stories.tsx +5 -2
- package/src/components/Icon/canonicalIconNames.tsx +12 -0
- package/src/components/Label/Label.stories.tsx +2 -1
- package/src/components/Label/Label.tsx +17 -1
- package/src/components/Label/label.scss +5 -1
- package/src/components/Menu/MenuItem.tsx +27 -1
- package/src/components/Menu/menu.scss +1 -0
- package/src/components/OverviewItem/OverviewItem.tsx +24 -1
- package/src/components/OverviewItem/OverviewItemList.tsx +3 -2
- package/src/components/OverviewItem/overviewitem.scss +4 -1
- package/src/components/OverviewItem/stories/OverviewItem.stories.tsx +6 -12
- package/src/components/Select/Select.stories.tsx +4 -1
- package/src/components/Switch/Switch.tsx +27 -8
- package/src/components/Tag/TagList.tsx +2 -2
- package/src/components/TextField/SearchField.tsx +37 -9
- package/src/components/TextField/stories/SearchField.stories.tsx +15 -1
- package/src/components/TextField/stories/TextField.stories.tsx +2 -1
- package/src/components/TextField/textfield.scss +17 -3
- package/src/components/Typography/OverflowText.tsx +24 -3
- package/src/components/Typography/stories/OverflowText.stories.tsx +33 -0
- package/src/components/index.scss +1 -0
- package/src/components/index.ts +1 -0
- package/src/extensions/codemirror/CodeMirror.stories.tsx +19 -1
- package/src/extensions/codemirror/CodeMirror.tsx +154 -16
- package/src/extensions/codemirror/_codemirror.scss +130 -1
- package/src/extensions/codemirror/debouncedLinter.ts +26 -0
- package/src/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.ts +1 -1
- package/src/extensions/codemirror/linters/jsLinter.ts +38 -0
- package/src/extensions/codemirror/linters/turtleLinter.ts +102 -0
- package/src/extensions/codemirror/tests/codemirrorTestHelper.ts +4 -0
- package/src/extensions/codemirror/toolbars/commands/markdown.command.ts +340 -0
- package/src/extensions/codemirror/toolbars/markdown.toolbar.tsx +117 -0
- package/src/extensions/codemirror/types.ts +7 -0
- package/src/extensions/react-flow/_config.scss +1 -0
- package/src/extensions/react-flow/nodes/NodeContent.tsx +170 -52
- package/src/extensions/react-flow/nodes/_nodes.scss +71 -35
- package/src/extensions/react-flow/nodes/nodeUtils.tsx +16 -14
- package/src/extensions/react-flow/nodes/stories/NodeContent.stories.tsx +51 -12
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Extension } from "@codemirror/state";
|
|
3
3
|
import { EditorView, Rect } from "@codemirror/view";
|
|
4
|
+
import { IntentTypes } from "../../common/Intent";
|
|
5
|
+
import { TestableComponent } from "../../components/interfaces";
|
|
4
6
|
import { SupportedCodeEditorModes } from "./hooks/useCodemirrorModeExtension.hooks";
|
|
5
|
-
export interface CodeEditorProps {
|
|
6
|
-
setEditorView?: (editor: EditorView | undefined) =>
|
|
7
|
+
export interface CodeEditorProps extends TestableComponent {
|
|
8
|
+
setEditorView?: (editor: EditorView | undefined) => void;
|
|
7
9
|
/**
|
|
8
10
|
* `name` attribute of connected textarea element.
|
|
9
11
|
*/
|
|
@@ -25,7 +27,7 @@ export interface CodeEditorProps {
|
|
|
25
27
|
/**
|
|
26
28
|
* Called when the focus status changes
|
|
27
29
|
*/
|
|
28
|
-
onFocusChange?: (focused: boolean) =>
|
|
30
|
+
onFocusChange?: (focused: boolean) => void;
|
|
29
31
|
/**
|
|
30
32
|
* Called when the user presses a key
|
|
31
33
|
*/
|
|
@@ -40,7 +42,7 @@ export interface CodeEditorProps {
|
|
|
40
42
|
onSelection?: (ranges: {
|
|
41
43
|
from: number;
|
|
42
44
|
to: number;
|
|
43
|
-
}[]) =>
|
|
45
|
+
}[]) => void;
|
|
44
46
|
/**
|
|
45
47
|
* Called when the cursor position changes
|
|
46
48
|
*/
|
|
@@ -101,11 +103,36 @@ export interface CodeEditorProps {
|
|
|
101
103
|
* If the <Tab> key is enabled as normal input, i.e. it won't have the behavior of changing to the next input element, expected in a web app.
|
|
102
104
|
*/
|
|
103
105
|
enableTab?: boolean;
|
|
106
|
+
/**
|
|
107
|
+
* Enables linting feature in the editor ("turtle" and "javascript" modes can use linting currently).
|
|
108
|
+
*/
|
|
109
|
+
useLinting?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Autofocus the editor when it is rendered
|
|
112
|
+
*/
|
|
113
|
+
autoFocus?: boolean;
|
|
114
|
+
/**
|
|
115
|
+
* Intent state of the code editor.
|
|
116
|
+
*/
|
|
117
|
+
intent?: IntentTypes | "edited" | "removed";
|
|
118
|
+
/**
|
|
119
|
+
* Disables the editor.
|
|
120
|
+
*/
|
|
121
|
+
disabled?: boolean;
|
|
122
|
+
/**
|
|
123
|
+
* Add toolbar for mode.
|
|
124
|
+
* Currently only `markdown` is supported.
|
|
125
|
+
*/
|
|
126
|
+
useToolbar?: boolean;
|
|
127
|
+
/**
|
|
128
|
+
* Get the translation for a specific key
|
|
129
|
+
*/
|
|
130
|
+
translate?: (key: string) => string | false;
|
|
104
131
|
}
|
|
105
132
|
/**
|
|
106
133
|
* Includes a code editor, currently we use CodeMirror library as base.
|
|
107
134
|
*/
|
|
108
135
|
export declare const CodeEditor: {
|
|
109
|
-
({ onChange, onSelection, onMouseDown, onFocusChange, onKeyDown, onCursorChange, name, id, mode, preventLineNumbers, defaultValue, readOnly, shouldHaveMinimalSetup, wrapLines, onScroll, setEditorView, supportCodeFolding, shouldHighlightActiveLine, outerDivAttributes, tabIntentSize, tabIntentStyle, placeholder, additionalExtensions, tabForceSpaceForModes, enableTab, height, }: CodeEditorProps): React.JSX.Element;
|
|
136
|
+
({ onChange, onSelection, onMouseDown, onFocusChange, onKeyDown, onCursorChange, name, id, mode, preventLineNumbers, defaultValue, readOnly, shouldHaveMinimalSetup, wrapLines, onScroll, setEditorView, supportCodeFolding, shouldHighlightActiveLine, outerDivAttributes, tabIntentSize, tabIntentStyle, placeholder, additionalExtensions, tabForceSpaceForModes, enableTab, height, useLinting, "data-test-id": dataTestId, autoFocus, disabled, intent, useToolbar, translate, ...otherCodeEditorProps }: CodeEditorProps): React.JSX.Element;
|
|
110
137
|
supportedModes: ("markdown" | "python" | "sparql" | "turtle" | "xml" | "yaml" | "jinja2" | "json" | "ntriples" | "mathematica" | "sql" | "javascript")[];
|
|
111
138
|
};
|
|
@@ -18,3 +18,4 @@ export declare const adaptedLineNumbers: (props?: any) => any;
|
|
|
18
18
|
export declare const adaptedHighlightActiveLine: () => any;
|
|
19
19
|
export declare const adaptedFoldGutter: (props?: any) => any;
|
|
20
20
|
export declare const adaptedCodeFolding: (props?: any) => any;
|
|
21
|
+
export declare const adaptedLintGutter: (props?: any) => any;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { EditorView } from "codemirror";
|
|
2
|
+
import { ValidIconName } from "../../../../components/Icon/canonicalIconNames";
|
|
3
|
+
declare enum Commands {
|
|
4
|
+
header1 = "Heading 1",
|
|
5
|
+
header2 = "Heading 2",
|
|
6
|
+
header3 = "Heading 3",
|
|
7
|
+
header4 = "Heading 4",
|
|
8
|
+
header5 = "Heading 5",
|
|
9
|
+
header6 = "Heading 6",
|
|
10
|
+
codeBlock = "Code block",
|
|
11
|
+
quote = "Block quote",
|
|
12
|
+
bold = "Bold",
|
|
13
|
+
italic = "Italic",
|
|
14
|
+
strike = "StrikeThrough",
|
|
15
|
+
inlineCode = "Inline code",
|
|
16
|
+
unorderedList = "Unordered list",
|
|
17
|
+
orderedList = "Ordered list",
|
|
18
|
+
todoList = "Todo list",
|
|
19
|
+
link = "Link",
|
|
20
|
+
image = "Image"
|
|
21
|
+
}
|
|
22
|
+
export default class MarkdownCommand {
|
|
23
|
+
private view;
|
|
24
|
+
static commands: {
|
|
25
|
+
readonly paragraphs: readonly [Commands.header1, Commands.header2, Commands.header3, Commands.header4, Commands.header5, Commands.header6, Commands.quote, Commands.codeBlock];
|
|
26
|
+
readonly basic: {
|
|
27
|
+
title: Commands;
|
|
28
|
+
icon: ValidIconName;
|
|
29
|
+
}[];
|
|
30
|
+
readonly lists: {
|
|
31
|
+
title: Commands;
|
|
32
|
+
icon: ValidIconName;
|
|
33
|
+
moniker: string;
|
|
34
|
+
}[];
|
|
35
|
+
readonly attachments: {
|
|
36
|
+
title: Commands;
|
|
37
|
+
icon: ValidIconName;
|
|
38
|
+
}[];
|
|
39
|
+
};
|
|
40
|
+
constructor(view: EditorView);
|
|
41
|
+
/**
|
|
42
|
+
* Supported list types are ol, ul, todo.
|
|
43
|
+
* utility helps to determine which at the start of the line
|
|
44
|
+
*/
|
|
45
|
+
private getListTypeOfLine;
|
|
46
|
+
private createListDelimiter;
|
|
47
|
+
private createList;
|
|
48
|
+
private enforceCursorFocus;
|
|
49
|
+
private createHeading;
|
|
50
|
+
private applyFormatting;
|
|
51
|
+
private applyAttachment;
|
|
52
|
+
private applyQuoteFormatting;
|
|
53
|
+
executeCommand: (command: Commands) => true | void;
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { EditorView } from "codemirror";
|
|
3
|
+
interface MarkdownToolbarProps {
|
|
4
|
+
view?: EditorView;
|
|
5
|
+
togglePreviewStatus: () => void;
|
|
6
|
+
showPreview: boolean;
|
|
7
|
+
translate: (key: string) => string | false;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
readonly?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const MarkdownToolbar: React.FC<MarkdownToolbarProps>;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Diagnostic } from "@codemirror/lint";
|
|
2
|
+
import { Extension } from "@codemirror/state";
|
|
3
|
+
import { EditorView } from "@codemirror/view";
|
|
4
|
+
export type Linter = (view: EditorView) => ReadonlyArray<Diagnostic> | Promise<ReadonlyArray<Diagnostic>>;
|
|
5
|
+
export type ExtensionCreator<T = unknown> = (options?: T) => Extension;
|
|
@@ -11,9 +11,19 @@ import { NodeHighlightColor } from "./sharedTypes";
|
|
|
11
11
|
type NodeContentHandleLegacyProps = HandleProps;
|
|
12
12
|
type NodeContentHandleNextProps = HandleNextProps;
|
|
13
13
|
export type NodeContentHandleProps = NodeContentHandleLegacyProps | NodeContentHandleNextProps;
|
|
14
|
-
type NodeDimensions = {
|
|
15
|
-
width
|
|
16
|
-
height
|
|
14
|
+
export type NodeDimensions = {
|
|
15
|
+
width?: number;
|
|
16
|
+
height?: number;
|
|
17
|
+
};
|
|
18
|
+
type ResizeDirections = {
|
|
19
|
+
right: true;
|
|
20
|
+
bottom?: false;
|
|
21
|
+
} | {
|
|
22
|
+
right?: false;
|
|
23
|
+
bottom: true;
|
|
24
|
+
} | {
|
|
25
|
+
right: true;
|
|
26
|
+
bottom: true;
|
|
17
27
|
};
|
|
18
28
|
type IntroductionTime = {
|
|
19
29
|
/**
|
|
@@ -185,12 +195,16 @@ export interface NodeContentProps<NODE_DATA, NODE_CONTENT_PROPS = any> extends N
|
|
|
185
195
|
* width and height dimensions of the node (Optional)
|
|
186
196
|
*/
|
|
187
197
|
nodeDimensions?: NodeDimensions;
|
|
198
|
+
/** if node is resizable, this allows direction of specificity */
|
|
199
|
+
resizeDirections?: ResizeDirections;
|
|
200
|
+
/** determines how much width a node can be resized to */
|
|
201
|
+
resizeMaxDimensions?: Partial<NodeDimensions>;
|
|
188
202
|
}
|
|
189
203
|
/**
|
|
190
204
|
* The `NodeContent` element manages the main view of how a node is displaying which content.
|
|
191
205
|
* This element cannot be used directly, all properties must be routed through the `data` property of an `elements` property item inside the `ReactFlow` container.
|
|
192
206
|
*/
|
|
193
|
-
export declare function NodeContent<CONTENT_PROPS = any>({ flowVersion, iconName, depiction, leftElement, typeLabel, label, labelSubline, enlargeHeader, fullWidth, showExecutionButtons, executionButtons, menuButtons, content, contentExtension, footerContent, size, minimalShape, intent, border, highlightColor, adaptHeightForHandleMinCount, adaptSizeIncrement, getMinimalTooltipData, style, showUnconnectableHandles, animated, introductionTime, onNodeResize, nodeDimensions, targetPosition, sourcePosition, isConnectable, selected, letPassWheelEvents, businessData, ...otherDomProps }: NodeContentProps<any>): React.JSX.Element;
|
|
207
|
+
export declare function NodeContent<CONTENT_PROPS = any>({ flowVersion, iconName, depiction, leftElement, typeLabel, label, labelSubline, enlargeHeader, fullWidth, showExecutionButtons, executionButtons, menuButtons, content, contentExtension, footerContent, size, minimalShape, intent, border, highlightColor, adaptHeightForHandleMinCount, adaptSizeIncrement, getMinimalTooltipData, style, showUnconnectableHandles, animated, introductionTime, onNodeResize, nodeDimensions, resizeDirections, resizeMaxDimensions, targetPosition, sourcePosition, isConnectable, selected, letPassWheelEvents, businessData, ...otherDomProps }: NodeContentProps<any>): React.JSX.Element;
|
|
194
208
|
export declare const nodeContentUtils: {
|
|
195
209
|
evaluateHighlightColors: (baseCustomProperty: string, highlightColor?: NodeHighlightColor | NodeHighlightColor[]) => {
|
|
196
210
|
highlightClassNameSuffix: string[];
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { CSSProperties } from "react";
|
|
2
|
-
import { Node } from "react-flow-renderer";
|
|
3
|
-
|
|
2
|
+
import { Node, XYPosition } from "react-flow-renderer";
|
|
3
|
+
import { NodeDimensions } from "./NodeContent";
|
|
4
|
+
/** A sticky note for display in the UI as returned from the backend. */
|
|
5
|
+
export interface StickyNote {
|
|
4
6
|
id: string;
|
|
5
7
|
content: string;
|
|
6
8
|
color: string;
|
|
7
|
-
position:
|
|
8
|
-
|
|
9
|
-
};
|
|
9
|
+
position: XYPosition & NodeDimensions;
|
|
10
|
+
}
|
|
10
11
|
export declare const nodeDefaultUtils: {
|
|
11
12
|
generateStyleWithColor: (color: string) => CSSProperties;
|
|
12
|
-
transformNodeToStickyNode: (node: Node<any>) =>
|
|
13
|
+
transformNodeToStickyNode: (node: Node<any>) => StickyNote;
|
|
13
14
|
};
|
|
14
15
|
export default nodeDefaultUtils;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eccenca/gui-elements",
|
|
3
3
|
"description": "GUI elements based on other libraries, usable in React application, written in Typescript.",
|
|
4
|
-
"version": "24.0.
|
|
4
|
+
"version": "24.1.0-featureimprovepublishingprocesscmem6356.0",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://github.com/eccenca/gui-elements",
|
|
7
7
|
"bugs": "https://github.com/eccenca/gui-elements/issues",
|
|
@@ -68,24 +68,27 @@
|
|
|
68
68
|
"autolint:all": "yarn autolint:scripts && yarn autolint:styles && yarn autolint:prettier"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@blueprintjs/colors": "^5.1.
|
|
72
|
-
"@blueprintjs/core": "^5.
|
|
73
|
-
"@blueprintjs/select": "^5.3.
|
|
74
|
-
"@carbon/icons": "^11.
|
|
75
|
-
"@carbon/react": "1.
|
|
76
|
-
"@codemirror/lang-javascript": "^6.2.
|
|
71
|
+
"@blueprintjs/colors": "^5.1.8",
|
|
72
|
+
"@blueprintjs/core": "^5.18.0",
|
|
73
|
+
"@blueprintjs/select": "^5.3.19",
|
|
74
|
+
"@carbon/icons": "^11.58.0",
|
|
75
|
+
"@carbon/react": "^1.80.1",
|
|
76
|
+
"@codemirror/lang-javascript": "^6.2.3",
|
|
77
77
|
"@codemirror/lang-json": "^6.0.1",
|
|
78
|
-
"@codemirror/lang-markdown": "^6.3.
|
|
78
|
+
"@codemirror/lang-markdown": "^6.3.2",
|
|
79
79
|
"@codemirror/lang-sql": "^6.8.0",
|
|
80
80
|
"@codemirror/lang-xml": "^6.1.0",
|
|
81
81
|
"@codemirror/lang-yaml": "^6.1.2",
|
|
82
|
-
"@codemirror/legacy-modes": "^6.
|
|
82
|
+
"@codemirror/legacy-modes": "^6.5.0",
|
|
83
83
|
"@mavrin/remark-typograf": "^2.2.0",
|
|
84
|
+
"classnames": "^2.5.1",
|
|
84
85
|
"codemirror": "^6.0.1",
|
|
85
86
|
"color": "^4.2.3",
|
|
86
|
-
"compute-scroll-into-view": "^3.1.
|
|
87
|
+
"compute-scroll-into-view": "^3.1.1",
|
|
88
|
+
"jshint": "^2.13.6",
|
|
87
89
|
"lodash": "^4.17.21",
|
|
88
|
-
"
|
|
90
|
+
"n3": "^1.25.1",
|
|
91
|
+
"re-resizable": "^6.10.3",
|
|
89
92
|
"react": "^16.13.1",
|
|
90
93
|
"react-dom": "^16.13.1",
|
|
91
94
|
"react-flow-renderer": "9.7.4",
|
|
@@ -100,51 +103,53 @@
|
|
|
100
103
|
"reset-css": "^5.0.2",
|
|
101
104
|
"unified": "^11.0.5",
|
|
102
105
|
"wicg-inert": "^3.1.3",
|
|
103
|
-
"xml-formatter": "^3.6.
|
|
106
|
+
"xml-formatter": "^3.6.5"
|
|
104
107
|
},
|
|
105
108
|
"devDependencies": {
|
|
106
|
-
"@babel/core": "^7.26.
|
|
107
|
-
"@babel/plugin-
|
|
108
|
-
"@babel/plugin-
|
|
109
|
-
"@babel/plugin-
|
|
110
|
-
"@babel/preset-env": "^7.26.
|
|
109
|
+
"@babel/core": "^7.26.10",
|
|
110
|
+
"@babel/plugin-transform-class-properties": "^7.25.9",
|
|
111
|
+
"@babel/plugin-transform-private-methods": "^7.25.9",
|
|
112
|
+
"@babel/plugin-transform-private-property-in-object": "^7.25.9",
|
|
113
|
+
"@babel/preset-env": "^7.26.9",
|
|
111
114
|
"@babel/preset-flow": "^7.25.9",
|
|
112
115
|
"@babel/preset-react": "^7.26.3",
|
|
113
|
-
"@babel/preset-typescript": "^7.
|
|
114
|
-
"@eslint/compat": "^1.2.
|
|
115
|
-
"@eslint/eslintrc": "^3.
|
|
116
|
-
"@eslint/js": "^9.
|
|
117
|
-
"@storybook/addon-actions": "^8.
|
|
118
|
-
"@storybook/addon-essentials": "^8.
|
|
119
|
-
"@storybook/addon-jest": "^8.
|
|
120
|
-
"@storybook/addon-links": "^8.
|
|
121
|
-
"@storybook/addon-webpack5-compiler-babel": "^3.0.
|
|
122
|
-
"@storybook/cli": "^8.
|
|
116
|
+
"@babel/preset-typescript": "^7.27.0",
|
|
117
|
+
"@eslint/compat": "^1.2.8",
|
|
118
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
119
|
+
"@eslint/js": "^9.24.0",
|
|
120
|
+
"@storybook/addon-actions": "^8.6.12",
|
|
121
|
+
"@storybook/addon-essentials": "^8.6.12",
|
|
122
|
+
"@storybook/addon-jest": "^8.6.12",
|
|
123
|
+
"@storybook/addon-links": "^8.6.12",
|
|
124
|
+
"@storybook/addon-webpack5-compiler-babel": "^3.0.6",
|
|
125
|
+
"@storybook/cli": "^8.6.12",
|
|
123
126
|
"@storybook/preset-scss": "^1.0.3",
|
|
124
|
-
"@storybook/react": "^8.
|
|
125
|
-
"@storybook/react-webpack5": "^8.
|
|
126
|
-
"@storybook/test": "^8.
|
|
127
|
+
"@storybook/react": "^8.6.12",
|
|
128
|
+
"@storybook/react-webpack5": "^8.6.12",
|
|
129
|
+
"@storybook/test": "^8.6.12",
|
|
127
130
|
"@testing-library/jest-dom": "^6.6.3",
|
|
128
|
-
"@testing-library/react": "^12.1.
|
|
131
|
+
"@testing-library/react": "^12.1.5",
|
|
129
132
|
"@types/codemirror": "^5.60.15",
|
|
130
133
|
"@types/color": "^3.0.6",
|
|
131
134
|
"@types/jest": "^29.5.14",
|
|
132
|
-
"@types/
|
|
135
|
+
"@types/jshint": "^2.12.4",
|
|
136
|
+
"@types/lodash": "^4.17.16",
|
|
137
|
+
"@types/n3": "^1.24.2",
|
|
133
138
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
134
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
135
|
-
"@typescript-eslint/parser": "^8.
|
|
139
|
+
"@typescript-eslint/eslint-plugin": "^8.30.1",
|
|
140
|
+
"@typescript-eslint/parser": "^8.30.1",
|
|
136
141
|
"babel-jest": "^29.7.0",
|
|
137
|
-
"chromatic": "^11.
|
|
138
|
-
"eslint": "^9.
|
|
139
|
-
"eslint-plugin-react": "^7.37.
|
|
140
|
-
"eslint-plugin-react-hooks": "^5.
|
|
142
|
+
"chromatic": "^11.28.0",
|
|
143
|
+
"eslint": "^9.24.0",
|
|
144
|
+
"eslint-plugin-react": "^7.37.5",
|
|
145
|
+
"eslint-plugin-react-hooks": "^5.2.0",
|
|
141
146
|
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
142
147
|
"husky": "4",
|
|
143
148
|
"identity-obj-proxy": "^3.0.0",
|
|
144
149
|
"jest": "^29.7.0",
|
|
145
150
|
"jest-environment-jsdom": "^29.7.0",
|
|
146
151
|
"jest-pnp-resolver": "^1.2.3",
|
|
147
|
-
"lint-staged": "^15.
|
|
152
|
+
"lint-staged": "^15.5.1",
|
|
148
153
|
"node-sass-package-importer": "^5.3.3",
|
|
149
154
|
"path": "^0.12.7",
|
|
150
155
|
"prettier": "^2.8.8",
|
|
@@ -154,10 +159,10 @@
|
|
|
154
159
|
"rimraf": "^5.0.10",
|
|
155
160
|
"sass": "1.62.1",
|
|
156
161
|
"sass-loader": "10.3.1",
|
|
157
|
-
"storybook": "^8.
|
|
158
|
-
"stylelint": "^
|
|
159
|
-
"stylelint-config-recess-order": "^
|
|
160
|
-
"stylelint-config-standard-scss": "^
|
|
162
|
+
"storybook": "^8.6.12",
|
|
163
|
+
"stylelint": "^16.18.0",
|
|
164
|
+
"stylelint-config-recess-order": "^6.0.0",
|
|
165
|
+
"stylelint-config-standard-scss": "^14.0.0",
|
|
161
166
|
"ts-node": "^10.9.2",
|
|
162
167
|
"tsc-esm-fix": "^3.1.2",
|
|
163
168
|
"typescript": "5.5.3",
|
|
@@ -170,10 +175,8 @@
|
|
|
170
175
|
"react-dom": ">=16"
|
|
171
176
|
},
|
|
172
177
|
"resolutions": {
|
|
173
|
-
"**/@types/react": "^17.0.
|
|
174
|
-
"node-sass-package-importer/**/postcss": "^8.4.49"
|
|
175
|
-
"**/cross-spawn": "^7.0.5 ",
|
|
176
|
-
"**/micromatch": "^4.0.8"
|
|
178
|
+
"**/@types/react": "^17.0.85",
|
|
179
|
+
"node-sass-package-importer/**/postcss": "^8.4.49"
|
|
177
180
|
},
|
|
178
181
|
"husky": {
|
|
179
182
|
"hooks": {
|
|
@@ -92,7 +92,7 @@ interface IActivityContextMenu extends TestableComponent {
|
|
|
92
92
|
|
|
93
93
|
export interface ActivityControlWidgetAction extends TestableComponent {
|
|
94
94
|
// The action that should be triggered
|
|
95
|
-
action: () =>
|
|
95
|
+
action: () => void;
|
|
96
96
|
// The tooltip that should be shown over the action icon
|
|
97
97
|
tooltip?: string;
|
|
98
98
|
// The icon of the action button
|
|
@@ -147,6 +147,7 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
|
|
|
147
147
|
{props.label && (
|
|
148
148
|
<OverviewItemLine small={small}>
|
|
149
149
|
{React.cloneElement(labelWrapper, {}, props.label)}
|
|
150
|
+
{timerExecutionMsg && (props.statusMessage || tags) && <> ({timerExecutionMsg})</>}
|
|
150
151
|
</OverviewItemLine>
|
|
151
152
|
)}
|
|
152
153
|
{(props.statusMessage || tags) && (
|
|
@@ -170,7 +171,9 @@ export function ActivityControlWidget(props: ActivityControlWidgetProps) {
|
|
|
170
171
|
)}
|
|
171
172
|
</OverviewItemLine>
|
|
172
173
|
)}
|
|
173
|
-
{timerExecutionMsg &&
|
|
174
|
+
{timerExecutionMsg && !(props.statusMessage || tags) && (
|
|
175
|
+
<OverviewItemLine small>{timerExecutionMsg}</OverviewItemLine>
|
|
176
|
+
)}
|
|
174
177
|
</OverviewItemDescription>
|
|
175
178
|
<OverviewItemActions>
|
|
176
179
|
{activityActions &&
|
|
@@ -4,7 +4,16 @@ import getColorConfiguration from "../../../common/utils/getColorConfiguration";
|
|
|
4
4
|
import { CodeEditor } from "../../../extensions";
|
|
5
5
|
import { ReactFlowHotkeyContext } from "../extensions/ReactFlowHotkeyContext";
|
|
6
6
|
|
|
7
|
-
import {
|
|
7
|
+
import {
|
|
8
|
+
Button,
|
|
9
|
+
CodeEditorProps,
|
|
10
|
+
FieldItem,
|
|
11
|
+
Icon,
|
|
12
|
+
SimpleDialog,
|
|
13
|
+
SimpleDialogProps,
|
|
14
|
+
Tag,
|
|
15
|
+
TagList,
|
|
16
|
+
} from "./../../../index";
|
|
8
17
|
|
|
9
18
|
export type StickyNoteModalTranslationKeys = "modalTitle" | "noteLabel" | "colorLabel" | "saveButton" | "cancelButton";
|
|
10
19
|
|
|
@@ -32,10 +41,14 @@ export interface StickyNoteModalProps {
|
|
|
32
41
|
* Forward other properties to the `SimpleModal` element that is used for this dialog.
|
|
33
42
|
*/
|
|
34
43
|
simpleDialogProps?: Omit<SimpleDialogProps, "size" | "title" | "hasBorder" | "isOpen" | "onClose" | "actions">;
|
|
44
|
+
/**
|
|
45
|
+
* Code editor props
|
|
46
|
+
*/
|
|
47
|
+
codeEditorProps?: Omit<CodeEditorProps, "defaultValue" | "onChange" | "preventLinuNumbers" | "id" | "name">;
|
|
35
48
|
}
|
|
36
49
|
|
|
37
50
|
export const StickyNoteModal: React.FC<StickyNoteModalProps> = React.memo(
|
|
38
|
-
({ metaData, onClose, onSubmit, translate, simpleDialogProps }) => {
|
|
51
|
+
({ metaData, onClose, onSubmit, translate, simpleDialogProps, codeEditorProps }) => {
|
|
39
52
|
const refNote = React.useRef<string>(metaData?.note ?? "");
|
|
40
53
|
const [color, setSelectedColor] = React.useState<string>(metaData?.color ?? "");
|
|
41
54
|
const noteColors: [string, string][] = Object.entries(getColorConfiguration("stickynotes")).map(
|
|
@@ -123,6 +136,7 @@ export const StickyNoteModal: React.FC<StickyNoteModalProps> = React.memo(
|
|
|
123
136
|
refNote.current = value;
|
|
124
137
|
}}
|
|
125
138
|
defaultValue={refNote.current}
|
|
139
|
+
{...codeEditorProps}
|
|
126
140
|
/>
|
|
127
141
|
</FieldItem>
|
|
128
142
|
<FieldItem
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
$reactflow-color-graph-node: #745a85 !default;
|
|
2
2
|
$reactflow-color-class-node: #3a7896 !default;
|
|
3
3
|
$reactflow-color-instance-node: #0097a7 !default;
|
|
4
|
-
$reactflow-color-property-node: #
|
|
4
|
+
$reactflow-color-property-node: #40a691 !default;
|
|
5
5
|
$reactflow-color-implicit-edge: #ae3c74 !default;
|
|
6
6
|
$reactflow-color-import-edge: $reactflow-color-graph-node !default;
|
|
7
7
|
$reactflow-color-subclass-edge: $reactflow-color-class-node !default;
|
|
@@ -13,6 +13,8 @@ $reactflow-color-rdftype-edge: $reactflow-color-instance-node !default;
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
.#{eccgui}-configuration--colors__react-flow-graph {
|
|
16
|
+
/* stylelint-disable custom-property-pattern */
|
|
17
|
+
// TODO: we should correct custom property names later but atm this would lead to broken consumer apps
|
|
16
18
|
--graphNode: #{$reactflow-color-graph-node};
|
|
17
19
|
--classNode: #{$reactflow-color-class-node};
|
|
18
20
|
--instanceNode: #{$reactflow-color-instance-node};
|
|
@@ -31,4 +33,5 @@ $reactflow-color-rdftype-edge: $reactflow-color-instance-node !default;
|
|
|
31
33
|
--subclassEdgeBright: #{bright($reactflow-color-subclass-edge)};
|
|
32
34
|
--subpropertyEdgeBright: #{bright($reactflow-color-subproperty-edge)};
|
|
33
35
|
--rdftypeEdgeBright: #{bright($reactflow-color-rdftype-edge)};
|
|
36
|
+
/* stylelint-enable custom-property-pattern */
|
|
34
37
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
$reactflow-color-project-node: #A5356E !default; // Cannot be part of a workflow but we have no other place atm to configure it
|
|
1
2
|
$reactflow-color-dataset-node: #3a7896 !default;
|
|
2
3
|
$reactflow-color-linking-node: #0097a7 !default;
|
|
3
4
|
$reactflow-color-transform-node: #40a691 !default;
|
|
@@ -10,12 +11,14 @@ $reactflow-color-replaceable-input: #faa854 !default;
|
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
.#{eccgui}-configuration--colors__react-flow-workflow {
|
|
14
|
+
--projectNode: #{$reactflow-color-project-node};
|
|
13
15
|
--datasetNode: #{$reactflow-color-dataset-node};
|
|
14
16
|
--linkingNode: #{$reactflow-color-linking-node};
|
|
15
17
|
--transformNode: #{$reactflow-color-transform-node};
|
|
16
18
|
--taskNode: #{$reactflow-color-task-node};
|
|
17
19
|
--workflowNode: #{$reactflow-color-workflow-node};
|
|
18
20
|
--replaceableInput: #{$reactflow-color-replaceable-input};
|
|
21
|
+
--projectNodeBright: #{bright($reactflow-color-project-node)};
|
|
19
22
|
--datasetNodeBright: #{bright($reactflow-color-dataset-node)};
|
|
20
23
|
--linkingNodeBright: #{bright($reactflow-color-linking-node)};
|
|
21
24
|
--transformNodeBright: #{bright($reactflow-color-transform-node)};
|
|
@@ -219,6 +219,8 @@ const AutoSuggestion = ({
|
|
|
219
219
|
CodeAutocompleteFieldSuggestionWithReplacementInfo | undefined
|
|
220
220
|
>(undefined);
|
|
221
221
|
const [cm, setCM] = React.useState<EditorView>();
|
|
222
|
+
const currentCm = React.useRef<EditorView>()
|
|
223
|
+
currentCm.current = cm
|
|
222
224
|
const isFocused = React.useRef(false);
|
|
223
225
|
const autoSuggestionDivRef = React.useRef<HTMLDivElement>(null);
|
|
224
226
|
/** Mutable editor state, since this needs to be current in scope of the SingleLineEditorComponent. */
|
|
@@ -235,12 +237,21 @@ const AutoSuggestion = ({
|
|
|
235
237
|
const pathIsValid = validationResponse?.valid ?? true;
|
|
236
238
|
|
|
237
239
|
React.useEffect(() => {
|
|
238
|
-
if (reInitOnInitialValueChange && initialValue != null &&
|
|
240
|
+
if (reInitOnInitialValueChange && initialValue != null && currentCm.current) {
|
|
239
241
|
dispatch({
|
|
240
|
-
changes: { from: 0, to:
|
|
242
|
+
changes: { from: 0, to: currentCm.current.state?.doc.length, insert: initialValue },
|
|
241
243
|
});
|
|
244
|
+
// Validate initial value change
|
|
245
|
+
checkValuePathValidity(initialValue)
|
|
242
246
|
}
|
|
243
|
-
}, [initialValue,
|
|
247
|
+
}, [initialValue, reInitOnInitialValueChange]);
|
|
248
|
+
|
|
249
|
+
React.useEffect(() => {
|
|
250
|
+
if(currentCm.current) {
|
|
251
|
+
// Validate initial value
|
|
252
|
+
checkValuePathValidity(initialValue)
|
|
253
|
+
}
|
|
254
|
+
}, [currentCm.current!!])
|
|
244
255
|
|
|
245
256
|
const setCurrentIndex = (newIndex: number) => {
|
|
246
257
|
editorState.index = newIndex;
|
|
@@ -4,7 +4,7 @@ import { EditorState } from "@codemirror/state";
|
|
|
4
4
|
import { EditorView, lineNumbers, Rect } from "@codemirror/view";
|
|
5
5
|
|
|
6
6
|
import { CLASSPREFIX as eccgui } from "../../configuration/constants";
|
|
7
|
-
import { CodeEditor } from "../../extensions/codemirror/CodeMirror";
|
|
7
|
+
import { CodeEditor, CodeEditorProps } from "../../extensions/codemirror/CodeMirror";
|
|
8
8
|
//hooks
|
|
9
9
|
import { SupportedCodeEditorModes } from "../../extensions/codemirror/hooks/useCodemirrorModeExtension.hooks";
|
|
10
10
|
|
|
@@ -15,23 +15,23 @@ export interface IRange {
|
|
|
15
15
|
|
|
16
16
|
export interface ExtendedCodeEditorProps {
|
|
17
17
|
// Is called with the editor instance that allows access via the CodeMirror API
|
|
18
|
-
setCM: (editor: EditorView | undefined) =>
|
|
18
|
+
setCM: (editor: EditorView | undefined) => void;
|
|
19
19
|
// Called whenever the editor content changes
|
|
20
|
-
onChange: (value: string) =>
|
|
20
|
+
onChange: (value: string) => void;
|
|
21
21
|
// Called when the cursor position changes
|
|
22
|
-
onCursorChange: (pos: number, coords: Rect, scrollinfo: HTMLElement, cm: EditorView) =>
|
|
22
|
+
onCursorChange: (pos: number, coords: Rect, scrollinfo: HTMLElement, cm: EditorView) => void;
|
|
23
23
|
// The editor theme, e.g. "sparql"
|
|
24
24
|
mode?: SupportedCodeEditorModes;
|
|
25
25
|
// The initial value of the editor
|
|
26
26
|
initialValue: string;
|
|
27
27
|
// Called when the focus status changes
|
|
28
|
-
onFocusChange: (focused: boolean) =>
|
|
28
|
+
onFocusChange: (focused: boolean) => void;
|
|
29
29
|
// Called when the user presses a key
|
|
30
30
|
onKeyDown: (event: KeyboardEvent) => boolean;
|
|
31
31
|
// function invoked when any click occurs
|
|
32
32
|
onMouseDown?: (view: EditorView) => void;
|
|
33
33
|
// Called when the user selects text
|
|
34
|
-
onSelection: (ranges: IRange[]) =>
|
|
34
|
+
onSelection: (ranges: IRange[]) => void;
|
|
35
35
|
// If the <Tab> key is enabled as normal input, i.e. it won't have the behavior of changing to the next input element, expected in a web app.
|
|
36
36
|
enableTab?: boolean;
|
|
37
37
|
/** Placeholder to be shown when no text has been entered, yet. */
|
|
@@ -40,6 +40,27 @@ export interface ExtendedCodeEditorProps {
|
|
|
40
40
|
showScrollBar?: boolean;
|
|
41
41
|
/** allow multiline entries when new line characters are entered */
|
|
42
42
|
multiline?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Code editor props
|
|
45
|
+
*/
|
|
46
|
+
codeEditorProps?: Omit<
|
|
47
|
+
CodeEditorProps,
|
|
48
|
+
| "defaultValue"
|
|
49
|
+
| "setEditorView"
|
|
50
|
+
| "onChange"
|
|
51
|
+
| "onCursorChange"
|
|
52
|
+
| "onFocusChange"
|
|
53
|
+
| "onKeyDown"
|
|
54
|
+
| "onSelection"
|
|
55
|
+
| "onMouseDown"
|
|
56
|
+
| "shouldHaveMinimalSetup"
|
|
57
|
+
| "preventLineNumbers"
|
|
58
|
+
| "mode"
|
|
59
|
+
| "name"
|
|
60
|
+
| "enableTab"
|
|
61
|
+
| "additionalExtensions"
|
|
62
|
+
| "outerDivAttributes"
|
|
63
|
+
>;
|
|
43
64
|
}
|
|
44
65
|
|
|
45
66
|
export type IEditorProps = ExtendedCodeEditorProps;
|
|
@@ -58,6 +79,7 @@ export const ExtendedCodeEditor = ({
|
|
|
58
79
|
placeholder,
|
|
59
80
|
onCursorChange,
|
|
60
81
|
onSelection,
|
|
82
|
+
codeEditorProps,
|
|
61
83
|
}: ExtendedCodeEditorProps) => {
|
|
62
84
|
const initialContent = React.useRef(multiline ? initialValue : initialValue.replace(/[\r\n]/g, " "));
|
|
63
85
|
const multilineExtensions = multiline
|
|
@@ -88,6 +110,7 @@ export const ExtendedCodeEditor = ({
|
|
|
88
110
|
multiline ? "codeeditor" : `singlelinecodeeditor ${BlueprintClassNames.INPUT}`
|
|
89
111
|
}`,
|
|
90
112
|
}}
|
|
113
|
+
{...codeEditorProps}
|
|
91
114
|
/>
|
|
92
115
|
);
|
|
93
116
|
};
|
|
@@ -301,13 +301,15 @@ function AutoCompleteField<T, UPDATE_VALUE>(props: AutoCompleteFieldProps<T, UPD
|
|
|
301
301
|
let enableHighlighting = true;
|
|
302
302
|
if (onlySelectItemReturned) {
|
|
303
303
|
// If the auto-completion only returns no suggestion or the selected item itself, query with empty string.
|
|
304
|
-
const emptyStringResults = await onSearch("");
|
|
304
|
+
const emptyStringResults: T[] = await onSearch("");
|
|
305
305
|
// Disable highlighting, since we used empty string search
|
|
306
306
|
enableHighlighting = false;
|
|
307
307
|
// Put selected item at the top if it is not in the result list
|
|
308
308
|
if (!!selectedItem && itemIndexOf(emptyStringResults, selectedItem) > -1) {
|
|
309
|
-
|
|
310
|
-
|
|
309
|
+
// Do not mutate original array
|
|
310
|
+
const withoutSelected = [...emptyStringResults]
|
|
311
|
+
withoutSelected.splice(itemIndexOf(emptyStringResults, selectedItem), 1);
|
|
312
|
+
result = [selectedItem, ...withoutSelected];
|
|
311
313
|
} else {
|
|
312
314
|
result = emptyStringResults;
|
|
313
315
|
}
|