Skip to content

Commit

Permalink
🚧 WIP sdl editor experiment
Browse files Browse the repository at this point in the history
  • Loading branch information
aexol committed Sep 29, 2023
1 parent a0c56f7 commit 65c7c5c
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 15 deletions.
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/editor-worker/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-editor-worker",
"version": "6.9.7",
"version": "6.9.8",
"private": false,
"license": "MIT",
"description": "Visual node editor for GraphQL",
Expand Down
4 changes: 2 additions & 2 deletions packages/editor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "graphql-editor",
"version": "6.9.7",
"version": "6.9.8",
"private": false,
"license": "MIT",
"description": "Visual node editor for GraphQL",
Expand Down Expand Up @@ -45,7 +45,7 @@
"file-saver": "^2.0.5",
"framer-motion": "^10.12.16",
"fuzzyjs": "^5.0.1",
"graphql-editor-worker": "^6.9.7",
"graphql-editor-worker": "^6.9.8",
"graphql-js-tree": "^1.0.5",
"graphql-language-service": "3.1.4",
"html-to-image": "^1.10.8",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ export class EnrichedLanguageService extends LanguageService {
const markerData = ([] as monaco.editor.IMarkerData[]).concat(
...nestedArrays
);

monacoInstance.editor.setModelMarkers(model, "graphql", markerData);
}

Expand Down
47 changes: 47 additions & 0 deletions packages/editor/src/editor/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
ThemeProvider,
RelationsProvider,
RelationNodesProvider,
useErrorsState,
} from "@/state/containers";
import { ThemeProvider as ScThemeProvider } from "@emotion/react";
import { LayoutStateProvider } from "@/state/containers/layout";
Expand All @@ -15,6 +16,8 @@ import { MainTheme } from "@/gshared/theme/MainTheme";
import { RouterProvider, EditorRoutes } from "@/state/containers/router";
import { EmbeddedEditor, EmbeddedEditorProps } from "@/editor/EmbeddedEditor";
import { themeColors, ToastsProvider } from "@aexol-studio/styling-system";
import { CodePane, CodePaneApi, CodePaneProps } from "@/editor/code";
import { ErrorsList } from "@/shared/errors/ErrorsList";

export { ExternalEditorAPI };

Expand Down Expand Up @@ -112,4 +115,48 @@ export const GraphQLGqlEditor = ({ ...props }: GqlEditorProps) => {
</ThemeProvider>
);
};

const SdlEditor = React.forwardRef<CodePaneApi, CodePaneProps>((props, ref) => {
const { errorsItems } = useErrorsState();
return (
<>
<CodePane {...props} ref={ref} />
{!!errorsItems?.length && <ErrorsList>{errorsItems}</ErrorsList>}
</>
);
});

export const GraphQLSdlCodeDisplay = React.forwardRef<
CodePaneApi,
Pick<EditorProps, "path" | "schema" | "theme">
>(({ ...props }, ref) => {
const baseITheme = themeColors("graphqleditor", "dark");
const combinedTheme = {
...MainTheme,
...baseITheme,
};
const theme = props.theme || combinedTheme;
return (
<ThemeProvider initialState={theme}>
<ErrorsStateProvider>
<TreesStateProvider>
<ScThemeProvider theme={theme}>
<ToastsProvider>
<SdlEditor
schema={props.schema}
onChange={() => {
//noop readonly
}}
size={500}
readonly
fullScreen
ref={ref}
/>
</ToastsProvider>
</ScThemeProvider>
</TreesStateProvider>
</ErrorsStateProvider>
</ThemeProvider>
);
});
export { EditorRoutes };
1 change: 1 addition & 0 deletions packages/sandbox/apps/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ export * from "./mergedLibraries";
export * from "./VeryLongSchema";
export * from "./livesocket";
export * from "./exoticDirectives";
export * from "./justcode";
27 changes: 27 additions & 0 deletions packages/sandbox/apps/justcode.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { useRef } from "react";
import * as schemas from "../schema";
import { ExternalEditorAPI, GraphQLSdlCodeDisplay } from "graphql-editor";

export const justcode = () => {
const ref = useRef<ExternalEditorAPI>(null);
return (
<div
style={{
flex: 1,
width: "100%",
height: "100%",
alignSelf: "stretch",
display: "flex",
position: "relative",
}}
>
<GraphQLSdlCodeDisplay
path="googlediff"
ref={ref}
schema={{ code: schemas.exoticDirectives, source: "outside" }}
/>
</div>
);
};

justcode.description = "Google Directions GraphQL Schema, SDL Editor only";
4 changes: 2 additions & 2 deletions packages/sandbox/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sandbox",
"version": "6.9.7",
"version": "6.9.8",
"private": false,
"license": "MIT",
"description": "Visual node editor for GraphQL",
Expand Down Expand Up @@ -48,7 +48,7 @@
"@aexol-studio/styling-system": "^0.0.8",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"graphql-editor": "^6.9.7",
"graphql-editor": "^6.9.8",
"graphql-js-tree": "^0.1.6",
"socket.io-client": "^4.7.2"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/socket-live-test/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "socket-live-test",
"version": "1.0.5",
"version": "1.0.6",
"description": "testing editor live",
"main": "index.js",
"type": "module",
Expand Down
2 changes: 1 addition & 1 deletion packages/svg-ts-sync/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "svg-ts-sync",
"version": "0.8.7",
"version": "0.8.8",
"private": false,
"license": "MIT",
"description": "Sync folders with svg's to react typescript components",
Expand Down

0 comments on commit 65c7c5c

Please sign in to comment.