Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SOF-7293: [MD] Implement support for highlighting atoms in source/3D views #68

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions dist/mui/components/accordion/Accordion.d.ts
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how the compiled files appeared to mismatch the TS version before. Not it is in sync.

Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
export interface AccordionProps {
hideExpandIcon: boolean;
children: React.ReactNode;
hideExpandIcon?: boolean;
children?: React.ReactNode;
isExpanded: boolean;
header: React.ReactNode;
alternativeComponent: React.ReactNode;
header?: React.ReactNode;
renderSummary?: React.ReactNode;
}
export default function Accordion({ hideExpandIcon, children, isExpanded, header, alternativeComponent, ...restProps }: AccordionProps): React.JSX.Element;
export default function Accordion({ hideExpandIcon, children, isExpanded, header, renderSummary, ...restProps }: AccordionProps): React.JSX.Element;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you commit the src? dist is updated automatically. Looks like the only changes there are to CodeMirror.tsx

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. If we want to remove the .d.ts and .java from PRs, we have to remove those in repo and add them to .gitignore.
@timurbazhirov , lmn if want me to do so

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We decided to commit dist to simplify installing packages from github commits. Just don't modify it directly.

6 changes: 2 additions & 4 deletions dist/mui/components/accordion/Accordion.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const AccordionSummary = withStyles({
},
expanded: {},
})(MuiAccordionSummary);
export default function Accordion({ hideExpandIcon, children, isExpanded, header, alternativeComponent, ...restProps }) {
export default function Accordion({ hideExpandIcon, children, isExpanded, header, renderSummary, ...restProps }) {
const [isExpanded_, setIsExpanded] = useState(isExpanded);
useEffect(() => {
setIsExpanded(isExpanded);
Expand All @@ -51,9 +51,7 @@ export default function Accordion({ hideExpandIcon, children, isExpanded, header
}
};
return (React.createElement(StyledAccordion, { defaultExpanded: isExpanded, expanded: isExpanded_, ...restProps },
React.createElement(AccordionSummary, { onClick: handleToggleExpanded, "aria-controls": "panel2a-content", expandIcon: !hideExpandIcon && React.createElement(IconByName, { name: "actions.expand" }) },
React.createElement(Typography, { variant: "overline" }, header),
alternativeComponent),
React.createElement(AccordionSummary, { onClick: handleToggleExpanded, "aria-controls": "panel2a-content", expandIcon: !hideExpandIcon && React.createElement(IconByName, { name: "actions.expand" }) }, renderSummary || React.createElement(Typography, { variant: "overline" }, header)),
React.createElement(Divider, null),
React.createElement(AccordionDetails, null, children)));
}
3 changes: 2 additions & 1 deletion dist/other/codemirror/CodeMirror.d.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { CompletionContext, CompletionResult } from "@codemirror/autocomplete";
import { Extension } from "@codemirror/state";
import { ConsistencyCheck } from "@mat3ra/esse/lib/js/types";
import { BasicSetupOptions } from "@uiw/react-codemirror";
import { BasicSetupOptions, Statistics } from "@uiw/react-codemirror";
import React from "react";
export interface CodeMirrorProps {
updateContent?: (content: string) => void;
onSelection?: (content: Statistics) => void;
content?: string;
options: boolean | BasicSetupOptions;
language: string;
Expand Down
4 changes: 2 additions & 2 deletions dist/other/codemirror/CodeMirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@ class CodeMirror extends React.Component {
return extensions;
}
render() {
const { options = {}, theme, readOnly } = this.props;
const { options = {}, theme, readOnly, onSelection } = this.props;
const { content } = this.state;
const extensions = this.createExtensions();
return (React.createElement(CodeMirrorBase, { value: content, onChange: (value) => {
this.handleContentChange(value);
}, onFocus: () => this.setState({ isEditing: true }), onBlur: () => this.setState({ isEditing: false }), basicSetup: options, theme: theme || "light", extensions: extensions, readOnly: readOnly }));
}, onFocus: () => this.setState({ isEditing: true }), onBlur: () => this.setState({ isEditing: false }), onStatistics: (data) => onSelection && onSelection(data), basicSetup: options, theme: theme || "light", extensions: extensions, readOnly: readOnly }));
}
}
export default CodeMirror;
6 changes: 4 additions & 2 deletions src/other/codemirror/CodeMirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { shell } from "@codemirror/legacy-modes/mode/shell";
import { linter, lintGutter } from "@codemirror/lint";
import { Extension } from "@codemirror/state";
import { ConsistencyCheck } from "@mat3ra/esse/lib/js/types";
import CodeMirrorBase, { BasicSetupOptions } from "@uiw/react-codemirror";
import CodeMirrorBase, { BasicSetupOptions, Statistics } from "@uiw/react-codemirror";
import React from "react";

import { linterGenerator } from "./utils/linterGenerator";
Expand All @@ -25,6 +25,7 @@ const LANGUAGE_EXTENSIONS_MAP: Record<string, Extension[]> = {

export interface CodeMirrorProps {
updateContent?: (content: string) => void;
onSelection?: (content: Statistics) => void;
content?: string;
options: boolean | BasicSetupOptions;
language: string;
Expand Down Expand Up @@ -103,7 +104,7 @@ class CodeMirror extends React.Component<CodeMirrorProps, CodeMirrorState> {
}

render() {
const { options = {}, theme, readOnly } = this.props;
const { options = {}, theme, readOnly, onSelection } = this.props;
const { content } = this.state;
const extensions = this.createExtensions();

Expand All @@ -115,6 +116,7 @@ class CodeMirror extends React.Component<CodeMirrorProps, CodeMirrorState> {
}}
onFocus={() => this.setState({ isEditing: true })}
onBlur={() => this.setState({ isEditing: false })}
onStatistics={(data) => onSelection && onSelection(data)}
basicSetup={options}
theme={theme || "light"}
extensions={extensions}
Expand Down
Loading