The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Remove and unify monaco editor define theming
Joshen Lim6124425e17f4
diff --git a/studio/components/grid/SupabaseGrid.tsx b/studio/components/grid/SupabaseGrid.tsxindex 94e65bfa996..373ee642756 100644--- a/studio/components/grid/SupabaseGrid.tsx+++ b/studio/components/grid/SupabaseGrid.tsx@@ -1,52 +1,31 @@-import { useEffect, useState, useRef, forwardRef, useImperativeHandle } from 'react'-import { createPortal } from 'react-dom'+import { DataGridHandle } from '@supabase/react-data-grid'+import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react'import { DndProvider } from 'react-dnd'import { HTML5Backend } from 'react-dnd-html5-backend'-import { useMonaco } from '@monaco-editor/react'-import { DataGridHandle } from '@supabase/react-data-grid'+import { createPortal } from 'react-dom'-import { useUrlState } from 'hooks'-import { Dictionary, SupabaseGridProps, SupabaseGridRef } from './types'+import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'import { useTableRowsQuery } from 'data/table-rows/table-rows-query'-import { StoreProvider, useDispatch, useTrackedState } from './store'-import { Shortcuts } from './components/common'-import { Grid } from './components/grid'-import Header from './components/header'-import Footer from './components/footer'-import { RowContextMenu } from './components/menu'+import { useUrlState } from 'hooks'import {cleanupProps,- initTable,- saveStorageDebounced,formatFilterURLParams,formatSortURLParams,+ initTable,+ saveStorageDebounced,} from './SupabaseGrid.utils'-import { useProjectContext } from 'components/layouts/ProjectLayout/ProjectContext'+import { Shortcuts } from './components/common'+import Footer from './components/footer'+import { Grid } from './components/grid'+import Header from './components/header'+import { RowContextMenu } from './components/menu'+import { StoreProvider, useDispatch, useTrackedState } from './store'+import { Dictionary, SupabaseGridProps, SupabaseGridRef } from './types'/** Supabase Grid: React component to render database table */export const SupabaseGrid = forwardRef<SupabaseGridRef, SupabaseGridProps>((props, ref) => {- const monaco = useMonaco()const _props = cleanupProps(props)- const { theme } = _props-- useEffect(() => {- if (monaco) {- const darkTheme = theme && theme === 'dark' ? true : false- monaco.editor.defineTheme('supabase', {- base: darkTheme ? 'vs-dark' : 'vs',- inherit: true, // can also be false to completely replace the builtin rules- rules: [- { token: 'string.sql', foreground: '24b47e' },- { token: 'comment', foreground: '666666' },- { token: 'predefined.sql', foreground: '999999' },- ],- colors: {- 'editor.background': darkTheme ? '#222222' : '#fbfcfd',- },- })- }- }, [monaco, theme])return (<StoreProvider>diff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsxindex c98ba5e41fa..df5362b0cb7 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/ColumnEditor/ColumnEditor.tsx@@ -243,18 +243,20 @@ const ColumnEditor = ({<FormSectionLabelclassName="lg:!col-span-4"description={- <Link href="https://supabase.com/docs/guides/database/tables#data-types" passHref>- <Button- asChild- type="default"- size="tiny"- icon={<IconExternalLink size={14} strokeWidth={2} />}- >- <a target="_blank" rel="noreferrer">- About data types- </a>- </Button>- </Link>+ <div>+ <Link href="https://supabase.com/docs/guides/database/tables#data-types" passHref>+ <Button+ asChild+ type="default"+ size="tiny"+ icon={<IconExternalLink size={14} strokeWidth={2} />}+ >+ <a target="_blank" rel="noreferrer">+ About data types+ </a>+ </Button>+ </Link>+ </div>}>Data Typediff --git a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsxindex 2c76081f737..0dfdda0a335 100644--- a/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx+++ b/studio/components/interfaces/TableGridEditor/SidePanelEditor/RowEditor/JsonEditor/JsonCodeEditor.tsx@@ -1,7 +1,8 @@-import Editor, { useMonaco } from '@monaco-editor/react'-import { useTheme } from 'common'+import Editor from '@monaco-editor/react'import { noop } from 'lodash'-import { useEffect, useRef } from 'react'+import { useRef } from 'react'++// [Joshen] Should just use CodeEditor instead of declaring Editor here so that all the mount logic is consistentinterface JsonEditorProps {queryId?: string@@ -16,31 +17,7 @@ const JsonEditor = ({readOnly = false,onInputChange = noop,}: JsonEditorProps) => {- const monaco = useMonaco()const editorRef = useRef()- const { isDarkMode } = useTheme()-- useEffect(() => {- if (monaco) {- // Supabase theming (Can't seem to get it to work for now)- monaco.editor.defineTheme('supabase', {- base: 'vs-dark', // can also be vs-dark or hc-black- inherit: true, // can also be false to completely replace the builtin rules- rules: [- // @ts-ignore- { background: isDarkMode ? '1f1f1f' : '30313f' },- { token: 'string.sql', foreground: '24b47e' },- { token: 'comment', foreground: '666666' },- { token: 'predefined.sql', foreground: 'D4D4D4' },- ],- colors: {- 'editor.background': isDarkMode ? '#1f1f1f' : '#30313f',- // 'editorGutter.background': '#30313f',- // 'editorLineNumber.foreground': '#555671',- },- })- }- }, [isDarkMode, monaco])const onMount = (editor: any, monaco: any) => {editorRef.current = editor@@ -60,7 +37,7 @@ const JsonEditor = ({return (<EditorclassName="monaco-editor"- theme="vs-dark"+ theme="supabase"defaultLanguage="json"defaultValue={defaultValue}path={queryId}diff --git a/studio/components/ui/SqlEditor.tsx b/studio/components/ui/SqlEditor.tsxindex 8ea75fa6932..d8443cbb599 100644--- a/studio/components/ui/SqlEditor.tsx+++ b/studio/components/ui/SqlEditor.tsx@@ -4,6 +4,8 @@ import { useEffect, useRef } from 'react'import { useStore } from 'hooks'+// [Joshen] We should deprecate this and use CodeEditor instead+interface SqlEditorProps {contextmenu?: booleandefaultValue?: string@@ -27,19 +29,6 @@ const SqlEditor = ({useEffect(() => {if (monaco) {- // Supabase theming (Can't seem to get it to work for now)- monaco.editor.defineTheme('supabase', {- base: 'vs-dark',- inherit: true,- colors: {},- rules: [- { token: '', background: '4a5568' },- { token: 'string.sql', foreground: '24b47e' },- { token: 'comment', foreground: '666666' },- { token: 'predefined.sql', foreground: 'D4D4D4' },- ],- })-// Enable pgsql formatconst formatprovider = monaco.languages.registerDocumentFormattingEditProvider('pgsql', {async provideDocumentFormattingEdits(model: any) {