@eccenca/gui-elements 24.0.1 → 24.1.0-rc.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/CHANGELOG.md +15 -6
- 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/ExtendedCodeEditor.js +3 -3
- package/dist/cjs/components/AutoSuggestion/ExtendedCodeEditor.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/index.js +1 -0
- package/dist/cjs/components/index.js.map +1 -1
- package/dist/cjs/extensions/codemirror/CodeMirror.js +58 -6
- 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 +9 -18
- 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/types.js +3 -0
- package/dist/cjs/extensions/codemirror/types.js.map +1 -0
- 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/ExtendedCodeEditor.js +14 -3
- package/dist/esm/components/AutoSuggestion/ExtendedCodeEditor.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/index.js +1 -0
- package/dist/esm/components/index.js.map +1 -1
- package/dist/esm/extensions/codemirror/CodeMirror.js +58 -7
- 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 +6 -15
- 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/types.js +2 -0
- package/dist/esm/extensions/codemirror/types.js.map +1 -0
- 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/ContentGroup/ContentGroup.d.ts +78 -0
- package/dist/types/components/index.d.ts +1 -0
- package/dist/types/extensions/codemirror/CodeMirror.d.ts +23 -5
- package/dist/types/extensions/codemirror/debouncedLinter.d.ts +4 -0
- package/dist/types/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.d.ts +3 -5
- 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/types.d.ts +5 -0
- package/package.json +7 -5
- package/src/cmem/react-flow/StickyNoteModal/StickyNoteModal.tsx +16 -2
- package/src/components/AutoSuggestion/ExtendedCodeEditor.tsx +29 -6
- 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/TextField/stories/TextField.stories.tsx +2 -1
- package/src/components/index.scss +1 -0
- package/src/components/index.ts +1 -0
- package/src/extensions/codemirror/CodeMirror.stories.tsx +30 -0
- package/src/extensions/codemirror/CodeMirror.tsx +86 -9
- package/src/extensions/codemirror/_codemirror.scss +96 -0
- package/src/extensions/codemirror/debouncedLinter.ts +26 -0
- package/src/extensions/codemirror/hooks/useCodemirrorModeExtension.hooks.ts +6 -16
- package/src/extensions/codemirror/linters/jsLinter.ts +38 -0
- package/src/extensions/codemirror/linters/turtleLinter.ts +102 -0
- package/src/extensions/codemirror/types.ts +7 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { SimpleDialogProps } from "./../../../index";
|
|
2
|
+
import { CodeEditorProps, SimpleDialogProps } from "./../../../index";
|
|
3
3
|
export type StickyNoteModalTranslationKeys = "modalTitle" | "noteLabel" | "colorLabel" | "saveButton" | "cancelButton";
|
|
4
4
|
export type StickyNoteMetadataType = {
|
|
5
5
|
note: string;
|
|
@@ -27,5 +27,9 @@ export interface StickyNoteModalProps {
|
|
|
27
27
|
* Forward other properties to the `SimpleModal` element that is used for this dialog.
|
|
28
28
|
*/
|
|
29
29
|
simpleDialogProps?: Omit<SimpleDialogProps, "size" | "title" | "hasBorder" | "isOpen" | "onClose" | "actions">;
|
|
30
|
+
/**
|
|
31
|
+
* Code editor props
|
|
32
|
+
*/
|
|
33
|
+
codeEditorProps?: Omit<CodeEditorProps, "defaultValue" | "onChange" | "preventLinuNumbers" | "id" | "name">;
|
|
30
34
|
}
|
|
31
35
|
export declare const StickyNoteModal: React.FC<StickyNoteModalProps>;
|
|
@@ -1,28 +1,33 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { EditorView, Rect } from "@codemirror/view";
|
|
3
|
+
import { CodeEditorProps } from "../../extensions/codemirror/CodeMirror";
|
|
3
4
|
import { SupportedCodeEditorModes } from "../../extensions/codemirror/hooks/useCodemirrorModeExtension.hooks";
|
|
4
5
|
export interface IRange {
|
|
5
6
|
from: number;
|
|
6
7
|
to: number;
|
|
7
8
|
}
|
|
8
9
|
export interface ExtendedCodeEditorProps {
|
|
9
|
-
setCM: (editor: EditorView | undefined) =>
|
|
10
|
-
onChange: (value: string) =>
|
|
11
|
-
onCursorChange: (pos: number, coords: Rect, scrollinfo: HTMLElement, cm: EditorView) =>
|
|
10
|
+
setCM: (editor: EditorView | undefined) => void;
|
|
11
|
+
onChange: (value: string) => void;
|
|
12
|
+
onCursorChange: (pos: number, coords: Rect, scrollinfo: HTMLElement, cm: EditorView) => void;
|
|
12
13
|
mode?: SupportedCodeEditorModes;
|
|
13
14
|
initialValue: string;
|
|
14
|
-
onFocusChange: (focused: boolean) =>
|
|
15
|
+
onFocusChange: (focused: boolean) => void;
|
|
15
16
|
onKeyDown: (event: KeyboardEvent) => boolean;
|
|
16
17
|
onMouseDown?: (view: EditorView) => void;
|
|
17
|
-
onSelection: (ranges: IRange[]) =>
|
|
18
|
+
onSelection: (ranges: IRange[]) => void;
|
|
18
19
|
enableTab?: boolean;
|
|
19
20
|
/** Placeholder to be shown when no text has been entered, yet. */
|
|
20
21
|
placeholder?: string;
|
|
21
22
|
showScrollBar?: boolean;
|
|
22
23
|
/** allow multiline entries when new line characters are entered */
|
|
23
24
|
multiline?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Code editor props
|
|
27
|
+
*/
|
|
28
|
+
codeEditorProps?: Omit<CodeEditorProps, "defaultValue" | "setEditorView" | "onChange" | "onCursorChange" | "onFocusChange" | "onKeyDown" | "onSelection" | "onMouseDown" | "shouldHaveMinimalSetup" | "preventLineNumbers" | "mode" | "name" | "enableTab" | "additionalExtensions" | "outerDivAttributes">;
|
|
24
29
|
}
|
|
25
30
|
export type IEditorProps = ExtendedCodeEditorProps;
|
|
26
31
|
/** Supports single-line and multiline editing. */
|
|
27
|
-
export declare const ExtendedCodeEditor: ({ multiline, initialValue, onKeyDown, enableTab, mode, setCM, onFocusChange, onMouseDown, onChange, placeholder, onCursorChange, onSelection, }: ExtendedCodeEditorProps) => React.JSX.Element;
|
|
32
|
+
export declare const ExtendedCodeEditor: ({ multiline, initialValue, onKeyDown, enableTab, mode, setCM, onFocusChange, onMouseDown, onChange, placeholder, onCursorChange, onSelection, codeEditorProps, }: ExtendedCodeEditorProps) => React.JSX.Element;
|
|
28
33
|
export default ExtendedCodeEditor;
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { TestableComponent } from "../../components/interfaces";
|
|
3
|
+
import { StickyTargetProps } from "../index";
|
|
4
|
+
export interface ContentGroupProps extends Omit<React.HTMLAttributes<HTMLElement>, "title">, TestableComponent {
|
|
5
|
+
/**
|
|
6
|
+
* Title of the content group.
|
|
7
|
+
*/
|
|
8
|
+
title?: string;
|
|
9
|
+
/**
|
|
10
|
+
* Level of the content group.
|
|
11
|
+
*/
|
|
12
|
+
level?: number;
|
|
13
|
+
/**
|
|
14
|
+
* Context information to display in the header.
|
|
15
|
+
*/
|
|
16
|
+
contextInfo?: React.ReactElement | React.ReactElement[];
|
|
17
|
+
/**
|
|
18
|
+
* Annotation to display in the content.
|
|
19
|
+
*/
|
|
20
|
+
annotation?: React.ReactElement | React.ReactElement[];
|
|
21
|
+
/**
|
|
22
|
+
* Action options to display in the header.
|
|
23
|
+
*/
|
|
24
|
+
actionOptions?: React.ReactElement | React.ReactElement[];
|
|
25
|
+
/**
|
|
26
|
+
* Flag to collapse the content group.
|
|
27
|
+
*/
|
|
28
|
+
isCollapsed?: boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Text to display when the callapse button is hovered.
|
|
31
|
+
* If not set then it uses "Show more" or "Show less".
|
|
32
|
+
*/
|
|
33
|
+
textToggleCollapse?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Event handler to toggle the collapse state.
|
|
36
|
+
*/
|
|
37
|
+
handlerToggleCollapse?: () => void;
|
|
38
|
+
/**
|
|
39
|
+
* Use a border on the left side to visually connect the whole content content group.
|
|
40
|
+
*/
|
|
41
|
+
borderMainConnection?: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Use a border on the left side to visually emphase the content group.
|
|
44
|
+
* If it is set to an array of color codes then the border is multi colored.
|
|
45
|
+
*/
|
|
46
|
+
borderSubConnection?: boolean | string[];
|
|
47
|
+
/**
|
|
48
|
+
* Whitespace size between header and the content.
|
|
49
|
+
*/
|
|
50
|
+
whitespaceSize?: "tiny" | "small" | "medium" | "large" | "xlarge";
|
|
51
|
+
/**
|
|
52
|
+
* Title minimum headline level.
|
|
53
|
+
*/
|
|
54
|
+
minimumHeadlineLevel?: 1 | 2 | 3 | 4 | 5 | 6;
|
|
55
|
+
/**
|
|
56
|
+
* Props to pass to `StickyTarget`.
|
|
57
|
+
*/
|
|
58
|
+
stickyHeaderProps?: Omit<StickyTargetProps, "children">;
|
|
59
|
+
/**
|
|
60
|
+
* Description of the content group.
|
|
61
|
+
* Added as tooltip to an info icon placed in the content group header.
|
|
62
|
+
*/
|
|
63
|
+
description?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Flag to hide the group divider.
|
|
66
|
+
*/
|
|
67
|
+
hideGroupDivider?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* Additional props to pass to the content container.
|
|
70
|
+
*/
|
|
71
|
+
contentProps?: Omit<React.HTMLAttributes<HTMLDivElement>, "children">;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Manage display of a grouped content section.
|
|
75
|
+
* Add info, actions and context annotations by using its properties.
|
|
76
|
+
* Can be nested into each other.
|
|
77
|
+
*/
|
|
78
|
+
export declare const ContentGroup: ({ children, className, title, contextInfo, annotation, actionOptions, isCollapsed, textToggleCollapse, handlerToggleCollapse, borderMainConnection, borderSubConnection, level, minimumHeadlineLevel, whitespaceSize, style, stickyHeaderProps, description, hideGroupDivider, contentProps, ...otherContentWrapperProps }: ContentGroupProps) => React.JSX.Element;
|
|
@@ -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,27 @@ 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;
|
|
104
122
|
}
|
|
105
123
|
/**
|
|
106
124
|
* Includes a code editor, currently we use CodeMirror library as base.
|
|
107
125
|
*/
|
|
108
126
|
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;
|
|
127
|
+
({ 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, ...otherCodeEditorProps }: CodeEditorProps): React.JSX.Element;
|
|
110
128
|
supportedModes: ("markdown" | "python" | "sparql" | "turtle" | "xml" | "yaml" | "jinja2" | "json" | "ntriples" | "mathematica" | "sql" | "javascript")[];
|
|
111
129
|
};
|
|
@@ -1,23 +1,21 @@
|
|
|
1
|
-
import { javascript } from "@codemirror/lang-javascript";
|
|
2
1
|
import { json } from "@codemirror/lang-json";
|
|
3
2
|
import { markdown } from "@codemirror/lang-markdown";
|
|
4
|
-
import { sql } from "@codemirror/lang-sql";
|
|
5
3
|
import { xml } from "@codemirror/lang-xml";
|
|
6
|
-
import { yaml } from "@codemirror/lang-yaml";
|
|
7
4
|
import { StreamParser } from "@codemirror/language";
|
|
5
|
+
import { sql } from "@codemirror/legacy-modes/mode/sql";
|
|
8
6
|
declare const supportedModes: {
|
|
9
7
|
readonly markdown: typeof markdown;
|
|
10
8
|
readonly python: StreamParser<unknown>;
|
|
11
9
|
readonly sparql: StreamParser<unknown>;
|
|
12
10
|
readonly turtle: StreamParser<unknown>;
|
|
13
11
|
readonly xml: typeof xml;
|
|
14
|
-
readonly yaml:
|
|
12
|
+
readonly yaml: StreamParser<unknown>;
|
|
15
13
|
readonly jinja2: StreamParser<unknown>;
|
|
16
14
|
readonly json: typeof json;
|
|
17
15
|
readonly ntriples: StreamParser<unknown>;
|
|
18
16
|
readonly mathematica: StreamParser<unknown>;
|
|
19
17
|
readonly sql: typeof sql;
|
|
20
|
-
readonly javascript:
|
|
18
|
+
readonly javascript: StreamParser<unknown>;
|
|
21
19
|
};
|
|
22
20
|
export declare const supportedCodeEditorModes: Array<keyof typeof supportedModes>;
|
|
23
21
|
export type SupportedCodeEditorModes = (typeof supportedCodeEditorModes)[number];
|
|
@@ -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;
|
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.1",
|
|
4
|
+
"version": "24.1.0-rc.1",
|
|
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",
|
|
@@ -72,19 +72,19 @@
|
|
|
72
72
|
"@blueprintjs/core": "^5.16.2",
|
|
73
73
|
"@blueprintjs/select": "^5.3.7",
|
|
74
74
|
"@carbon/icons": "^11.53.0",
|
|
75
|
-
"@carbon/react": "1.72.0",
|
|
76
|
-
"@codemirror/lang-javascript": "^6.2.2",
|
|
75
|
+
"@carbon/react": "^1.72.0",
|
|
77
76
|
"@codemirror/lang-json": "^6.0.1",
|
|
78
77
|
"@codemirror/lang-markdown": "^6.3.1",
|
|
79
|
-
"@codemirror/lang-sql": "^6.8.0",
|
|
80
78
|
"@codemirror/lang-xml": "^6.1.0",
|
|
81
|
-
"@codemirror/lang-yaml": "^6.1.2",
|
|
82
79
|
"@codemirror/legacy-modes": "^6.4.2",
|
|
83
80
|
"@mavrin/remark-typograf": "^2.2.0",
|
|
81
|
+
"classnames": "^2.5.1",
|
|
84
82
|
"codemirror": "^6.0.1",
|
|
85
83
|
"color": "^4.2.3",
|
|
86
84
|
"compute-scroll-into-view": "^3.1.0",
|
|
85
|
+
"jshint": "^2.13.6",
|
|
87
86
|
"lodash": "^4.17.21",
|
|
87
|
+
"n3": "^1.23.1",
|
|
88
88
|
"re-resizable": "^6.10.1",
|
|
89
89
|
"react": "^16.13.1",
|
|
90
90
|
"react-dom": "^16.13.1",
|
|
@@ -129,7 +129,9 @@
|
|
|
129
129
|
"@types/codemirror": "^5.60.15",
|
|
130
130
|
"@types/color": "^3.0.6",
|
|
131
131
|
"@types/jest": "^29.5.14",
|
|
132
|
+
"@types/jshint": "^2.12.4",
|
|
132
133
|
"@types/lodash": "^4.17.13",
|
|
134
|
+
"@types/n3": "^1.21.1",
|
|
133
135
|
"@types/react-syntax-highlighter": "^15.5.13",
|
|
134
136
|
"@typescript-eslint/eslint-plugin": "^8.18.1",
|
|
135
137
|
"@typescript-eslint/parser": "^8.18.1",
|
|
@@ -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
|
|
@@ -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
|
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { LoremIpsum } from "react-lorem-ipsum";
|
|
3
|
+
import { Meta, StoryFn } from "@storybook/react";
|
|
4
|
+
|
|
5
|
+
import { Badge, ContentGroup, HtmlContentBlock, IconButton, Tag } from "../../../index";
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
title: "Components/ContentGroup",
|
|
9
|
+
component: ContentGroup,
|
|
10
|
+
argTypes: {
|
|
11
|
+
handlerToggleCollapse: {
|
|
12
|
+
action: "toggle collapse",
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
} as Meta<typeof ContentGroup>;
|
|
16
|
+
|
|
17
|
+
const TemplateFull: StoryFn<typeof ContentGroup> = (args) => <ContentGroup {...args} />;
|
|
18
|
+
|
|
19
|
+
export const BasicExample = TemplateFull.bind({});
|
|
20
|
+
BasicExample.args = {
|
|
21
|
+
title: "Content group title",
|
|
22
|
+
contextInfo: <Badge children={100} maxLength={3} intent={"warning"} title="Found warnings context." />,
|
|
23
|
+
annotation: (
|
|
24
|
+
<Tag backgroundColor={"purple"} round>
|
|
25
|
+
Context tag
|
|
26
|
+
</Tag>
|
|
27
|
+
),
|
|
28
|
+
actionOptions: (
|
|
29
|
+
<>
|
|
30
|
+
<IconButton name="item-remove" text="Example remove tooltip" disruptive />
|
|
31
|
+
</>
|
|
32
|
+
),
|
|
33
|
+
isCollapsed: false,
|
|
34
|
+
handlerToggleCollapse: () => {},
|
|
35
|
+
borderMainConnection: true,
|
|
36
|
+
borderSubConnection: ["red", "blue"],
|
|
37
|
+
level: 1,
|
|
38
|
+
minimumHeadlineLevel: 5,
|
|
39
|
+
whitespaceSize: "small",
|
|
40
|
+
description: "More context description by tooltip.",
|
|
41
|
+
hideGroupDivider: false,
|
|
42
|
+
children: (
|
|
43
|
+
<HtmlContentBlock>
|
|
44
|
+
<LoremIpsum p={3} avgSentencesPerParagraph={4} random={false} />
|
|
45
|
+
</HtmlContentBlock>
|
|
46
|
+
),
|
|
47
|
+
};
|