@sqlrooms/monaco-editor 0.29.0-rc.1 → 0.29.0-rc.2
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/README.md +10 -10
- package/dist/components/MarkdownMonacoEditor.d.ts +9 -0
- package/dist/components/MarkdownMonacoEditor.d.ts.map +1 -0
- package/dist/components/MarkdownMonacoEditor.js +13 -0
- package/dist/components/MarkdownMonacoEditor.js.map +1 -0
- package/dist/components/MonacoEditor.d.ts +5 -4
- package/dist/components/MonacoEditor.d.ts.map +1 -1
- package/dist/components/MonacoEditor.js +18 -33
- package/dist/components/MonacoEditor.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/color-utils.d.ts +8 -20
- package/dist/utils/color-utils.d.ts.map +1 -1
- package/dist/utils/color-utils.js +102 -141
- package/dist/utils/color-utils.js.map +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -105,16 +105,16 @@ configureMonacoLoader({paths: {vs: 'https://unpkg.com/monaco-editor/min/vs'}});
|
|
|
105
105
|
|
|
106
106
|
### MonacoEditor Props
|
|
107
107
|
|
|
108
|
-
| Prop | Type
|
|
109
|
-
| --------- |
|
|
110
|
-
| className | string
|
|
111
|
-
| language | string
|
|
112
|
-
| theme | '
|
|
113
|
-
| value | string
|
|
114
|
-
| readOnly | boolean
|
|
115
|
-
| options | object
|
|
116
|
-
| onMount | function
|
|
117
|
-
| onChange | function
|
|
108
|
+
| Prop | Type | Default | Description |
|
|
109
|
+
| --------- | ----------------------------- | ------------ | ---------------------------------------- |
|
|
110
|
+
| className | string | '' | CSS class name for the editor container |
|
|
111
|
+
| language | string | 'javascript' | The language of the editor |
|
|
112
|
+
| theme | 'dark' \| 'light' \| 'system' | 'dark' | The theme of the editor |
|
|
113
|
+
| value | string | '' | The value of the editor |
|
|
114
|
+
| readOnly | boolean | false | Whether the editor is read-only |
|
|
115
|
+
| options | object | {} | Additional options for the editor |
|
|
116
|
+
| onMount | function | - | Callback when the editor is mounted |
|
|
117
|
+
| onChange | function | - | Callback when the editor content changes |
|
|
118
118
|
|
|
119
119
|
### JsonMonacoEditor Props
|
|
120
120
|
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { MonacoEditorProps } from './MonacoEditor';
|
|
3
|
+
export type MarkdownMonacoEditorProps = Omit<MonacoEditorProps, 'language'>;
|
|
4
|
+
/**
|
|
5
|
+
* A Monaco editor configured for editing Markdown files with
|
|
6
|
+
* readable dark/light theme colors for headings, links, lists, and code.
|
|
7
|
+
*/
|
|
8
|
+
export declare const MarkdownMonacoEditor: React.FC<MarkdownMonacoEditorProps>;
|
|
9
|
+
//# sourceMappingURL=MarkdownMonacoEditor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownMonacoEditor.d.ts","sourceRoot":"","sources":["../../src/components/MarkdownMonacoEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAe,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAE/D,MAAM,MAAM,yBAAyB,GAAG,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,CAAC;AAE5E;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,KAAK,CAAC,EAAE,CAAC,yBAAyB,CAcpE,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { MonacoEditor } from './MonacoEditor';
|
|
3
|
+
/**
|
|
4
|
+
* A Monaco editor configured for editing Markdown files with
|
|
5
|
+
* readable dark/light theme colors for headings, links, lists, and code.
|
|
6
|
+
*/
|
|
7
|
+
export const MarkdownMonacoEditor = ({ options: userOptions, ...props }) => {
|
|
8
|
+
return (_jsx(MonacoEditor, { language: "markdown", options: {
|
|
9
|
+
wordWrap: 'on',
|
|
10
|
+
...userOptions,
|
|
11
|
+
}, ...props }));
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=MarkdownMonacoEditor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MarkdownMonacoEditor.js","sourceRoot":"","sources":["../../src/components/MarkdownMonacoEditor.tsx"],"names":[],"mappings":";AACA,OAAO,EAAC,YAAY,EAAoB,MAAM,gBAAgB,CAAC;AAI/D;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAwC,CAAC,EACxE,OAAO,EAAE,WAAW,EACpB,GAAG,KAAK,EACT,EAAE,EAAE;IACH,OAAO,CACL,KAAC,YAAY,IACX,QAAQ,EAAC,UAAU,EACnB,OAAO,EAAE;YACP,QAAQ,EAAE,IAAI;YACd,GAAG,WAAW;SACf,KACG,KAAK,GACT,CACH,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import React from 'react';\nimport {MonacoEditor, MonacoEditorProps} from './MonacoEditor';\n\nexport type MarkdownMonacoEditorProps = Omit<MonacoEditorProps, 'language'>;\n\n/**\n * A Monaco editor configured for editing Markdown files with\n * readable dark/light theme colors for headings, links, lists, and code.\n */\nexport const MarkdownMonacoEditor: React.FC<MarkdownMonacoEditorProps> = ({\n options: userOptions,\n ...props\n}) => {\n return (\n <MonacoEditor\n language=\"markdown\"\n options={{\n wordWrap: 'on',\n ...userOptions,\n }}\n {...props}\n />\n );\n};\n"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EditorProps, OnChange, OnMount } from '@monaco-editor/react';
|
|
2
|
-
import type
|
|
2
|
+
import type { Theme } from '@sqlrooms/ui';
|
|
3
3
|
import React from 'react';
|
|
4
|
+
import type * as Monaco from 'monaco-editor';
|
|
4
5
|
export interface MonacoEditorProps extends Omit<EditorProps, 'onMount'> {
|
|
5
6
|
/**
|
|
6
7
|
* Callback when the editor is mounted
|
|
@@ -21,11 +22,11 @@ export interface MonacoEditorProps extends Omit<EditorProps, 'onMount'> {
|
|
|
21
22
|
*/
|
|
22
23
|
language?: string;
|
|
23
24
|
/**
|
|
24
|
-
* The theme of the editor
|
|
25
|
+
* The theme of the editor ('dark' | 'light' | 'system')
|
|
25
26
|
* Can be explicitly set or will automatically use the app theme if not provided
|
|
26
|
-
* @default '
|
|
27
|
+
* @default 'dark'
|
|
27
28
|
*/
|
|
28
|
-
theme?:
|
|
29
|
+
theme?: Theme;
|
|
29
30
|
/**
|
|
30
31
|
* The value of the editor
|
|
31
32
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonacoEditor.d.ts","sourceRoot":"","sources":["../../src/components/MonacoEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAE5E,OAAO,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"MonacoEditor.d.ts","sourceRoot":"","sources":["../../src/components/MonacoEditor.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAS,WAAW,EAAE,QAAQ,EAAE,OAAO,EAAC,MAAM,sBAAsB,CAAC;AAE5E,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,KAAmC,MAAM,OAAO,CAAC;AAMxD,OAAO,KAAK,KAAK,MAAM,MAAM,eAAe,CAAC;AAmC7C,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,WAAW,EAAE,SAAS,CAAC;IACrE;;OAEG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB;;OAEG;IACH,QAAQ,CAAC,EAAE,QAAQ,CAAC;IACpB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,oCAAoC,CAAC;CAC9D;AA4ED;;GAEG;AACH,eAAO,MAAM,YAAY,EAAE,KAAK,CAAC,EAAE,CAAC,iBAAiB,CA8FpD,CAAC"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { Editor } from '@monaco-editor/react';
|
|
3
|
-
import { Spinner, cn, useTheme } from '@sqlrooms/ui';
|
|
4
|
-
import { useEffect, useMemo, useRef
|
|
5
|
-
import {
|
|
3
|
+
import { Spinner, cn, getResolvedTheme, useTheme } from '@sqlrooms/ui';
|
|
4
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
5
|
+
import { getJsonEditorTheme, getMarkdownEditorTheme, getMenuColors, } from '../utils/color-utils';
|
|
6
|
+
import { getCssColor, getMonospaceFont } from '@sqlrooms/utils';
|
|
6
7
|
// Rendering issue fix for white rectangle appearing above text in Monaco.
|
|
7
8
|
// Monaco creates a hidden textarea for IME input. If Monaco CSS loads late,
|
|
8
9
|
// this textarea can briefly render as a normal white block and shift content.
|
|
@@ -35,15 +36,8 @@ function suppressMonacoTextareaFlash() {
|
|
|
35
36
|
`;
|
|
36
37
|
document.head.appendChild(style);
|
|
37
38
|
}
|
|
38
|
-
// Module-level singleton to track theme state
|
|
39
|
-
let lastDefinedForDarkMode = null;
|
|
40
39
|
function defineMonacoThemes(monaco, isDark, currentTheme) {
|
|
41
40
|
suppressMonacoTextareaFlash();
|
|
42
|
-
// Only redefine if the theme mode has changed or themes haven't been defined yet
|
|
43
|
-
if (lastDefinedForDarkMode === isDark)
|
|
44
|
-
return;
|
|
45
|
-
lastDefinedForDarkMode = isDark;
|
|
46
|
-
// Define both light and dark themes with current CSS variable values
|
|
47
41
|
// Light theme
|
|
48
42
|
monaco.editor.defineTheme('sqlrooms-light', {
|
|
49
43
|
base: 'vs',
|
|
@@ -60,6 +54,7 @@ function defineMonacoThemes(monaco, isDark, currentTheme) {
|
|
|
60
54
|
},
|
|
61
55
|
});
|
|
62
56
|
monaco.editor.defineTheme('sqlrooms-json-light', getJsonEditorTheme(false));
|
|
57
|
+
monaco.editor.defineTheme('sqlrooms-markdown-light', getMarkdownEditorTheme(false));
|
|
63
58
|
// Dark theme
|
|
64
59
|
monaco.editor.defineTheme('sqlrooms-dark', {
|
|
65
60
|
base: 'vs-dark',
|
|
@@ -76,6 +71,7 @@ function defineMonacoThemes(monaco, isDark, currentTheme) {
|
|
|
76
71
|
},
|
|
77
72
|
});
|
|
78
73
|
monaco.editor.defineTheme('sqlrooms-json-dark', getJsonEditorTheme(true));
|
|
74
|
+
monaco.editor.defineTheme('sqlrooms-markdown-dark', getMarkdownEditorTheme(true));
|
|
79
75
|
// Apply the correct theme variant (respects JSON-specific themes)
|
|
80
76
|
monaco.editor.setTheme(currentTheme);
|
|
81
77
|
}
|
|
@@ -85,6 +81,8 @@ const DEFAULT_MONACO_OPTIONS = {
|
|
|
85
81
|
automaticLayout: true,
|
|
86
82
|
fontLigatures: true,
|
|
87
83
|
fixedOverflowWidgets: true,
|
|
84
|
+
fontSize: 14,
|
|
85
|
+
lineHeight: 21,
|
|
88
86
|
// Prevent an initial top "reserved" area that can appear briefly while Monaco
|
|
89
87
|
// computes sticky scroll layout (shows up as a blank/white rectangle above text).
|
|
90
88
|
stickyScroll: { enabled: false },
|
|
@@ -92,33 +90,20 @@ const DEFAULT_MONACO_OPTIONS = {
|
|
|
92
90
|
/**
|
|
93
91
|
* A wrapper around the Monaco Editor component
|
|
94
92
|
*/
|
|
95
|
-
export const MonacoEditor = ({ className, language = 'javascript',
|
|
96
|
-
const { theme
|
|
97
|
-
|
|
98
|
-
const systemPrefersDark = useSyncExternalStore((onStoreChange) => {
|
|
99
|
-
if (appTheme !== 'system' || typeof window === 'undefined') {
|
|
100
|
-
return () => { };
|
|
101
|
-
}
|
|
102
|
-
const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');
|
|
103
|
-
mediaQuery.addEventListener('change', onStoreChange);
|
|
104
|
-
return () => mediaQuery.removeEventListener('change', onStoreChange);
|
|
105
|
-
}, () => {
|
|
106
|
-
if (appTheme !== 'system' || typeof window === 'undefined')
|
|
107
|
-
return false;
|
|
108
|
-
return window.matchMedia('(prefers-color-scheme: dark)').matches;
|
|
109
|
-
}, () => false);
|
|
110
|
-
const isDark = explicitTheme === 'vs-dark'
|
|
111
|
-
? true
|
|
112
|
-
: explicitTheme === 'light'
|
|
113
|
-
? false
|
|
114
|
-
: appTheme === 'dark' || (appTheme === 'system' && systemPrefersDark);
|
|
93
|
+
export const MonacoEditor = ({ className, language = 'javascript', value = '', readOnly = false, onMount, onChange, options = {}, beforeMount, ...props }) => {
|
|
94
|
+
const { theme } = useTheme();
|
|
95
|
+
const isDark = getResolvedTheme(theme) === 'dark';
|
|
115
96
|
const monacoTheme = language === 'json'
|
|
116
97
|
? isDark
|
|
117
98
|
? 'sqlrooms-json-dark'
|
|
118
99
|
: 'sqlrooms-json-light'
|
|
119
|
-
:
|
|
120
|
-
?
|
|
121
|
-
|
|
100
|
+
: language === 'markdown'
|
|
101
|
+
? isDark
|
|
102
|
+
? 'sqlrooms-markdown-dark'
|
|
103
|
+
: 'sqlrooms-markdown-light'
|
|
104
|
+
: isDark
|
|
105
|
+
? 'sqlrooms-dark'
|
|
106
|
+
: 'sqlrooms-light';
|
|
122
107
|
const editorRef = useRef(null);
|
|
123
108
|
const monacoRef = useRef(null);
|
|
124
109
|
const handleBeforeMount = (monaco) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MonacoEditor.js","sourceRoot":"","sources":["../../src/components/MonacoEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAiC,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAC,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAC,MAAM,c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B;IACxB,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,CAAC,OAAO,EAAE,CAAC;YACtB,SAAS,CAAC,OAAO,CAAC,aAAa,CAAC,EAAC,QAAQ,EAAC,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEf,qCAAqC;IACrC,MAAM,UAAU,GAAG,gBAAgB,EAAE,CAAC;IAEtC,MAAM,eAAe,GAAG,OAAO,CAC7B,GAAG,EAAE,CAAC,CAAC;QACL,GAAG,sBAAsB;QACzB,QAAQ;QACR,UAAU;QACV,GAAG,OAAO;KACX,CAAC,EACF,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,CAChC,CAAC;IAEF,OAAO,CACL,cAAK,SAAS,EAAE,EAAE,CAAC,kBAAkB,EAAE,SAAS,CAAC,YAC/C,KAAC,MAAM,IACL,MAAM,EAAC,MAAM,EACb,KAAK,EAAC,MAAM,EACZ,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,EAAE,oBAAoB,EAC7B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,KAAC,OAAO,KAAG,KAChB,KAAK,GACT,GACE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {Editor, EditorProps, OnChange, OnMount} from '@monaco-editor/react';\nimport {Spinner, cn, useTheme} from '@sqlrooms/ui';\nimport type * as Monaco from 'monaco-editor';\nimport React, {useEffect, useMemo, useRef, useSyncExternalStore} from 'react';\nimport {\n getCssColor,\n getJsonEditorTheme,\n getMenuColors,\n getMonospaceFont,\n} from '../utils/color-utils';\n\n// Rendering issue fix for white rectangle appearing above text in Monaco.\n// Monaco creates a hidden textarea for IME input. If Monaco CSS loads late,\n// this textarea can briefly render as a normal white block and shift content.\n// Force it to never participate in layout / painting.\nlet isImeTextareaStyleInjected = false;\nfunction suppressMonacoTextareaFlash() {\n if (isImeTextareaStyleInjected) return;\n if (typeof document === 'undefined') return;\n isImeTextareaStyleInjected = true;\n\n const style = document.createElement('style');\n style.setAttribute('data-sqlrooms-monaco-ime-style', 'true');\n style.textContent = `\n .monaco-editor textarea.ime-text-area {\n position: absolute !important;\n top: 0 !important;\n left: 0 !important;\n width: 1px !important;\n height: 1px !important;\n opacity: 0 !important;\n background: transparent !important;\n color: transparent !important;\n border: 0 !important;\n padding: 0 !important;\n margin: 0 !important;\n pointer-events: none !important;\n z-index: -1 !important;\n }\n `;\n document.head.appendChild(style);\n}\n\nexport interface MonacoEditorProps extends Omit<EditorProps, 'onMount'> {\n /**\n * Callback when the editor is mounted\n */\n onMount?: OnMount;\n /**\n * Callback when the editor content changes\n */\n onChange?: OnChange;\n /**\n * CSS class name for the editor container\n * @default ''\n */\n className?: string;\n /**\n * The language of the editor\n * @default 'javascript'\n */\n language?: string;\n /**\n * The theme of the editor\n * Can be explicitly set or will automatically use the app theme if not provided\n * @default 'vs-dark'\n */\n theme?: 'vs-dark' | 'light';\n /**\n * The value of the editor\n */\n value?: string;\n /**\n * Whether the editor is read-only\n * @default false\n */\n readOnly?: boolean;\n /**\n * Additional options for the editor\n */\n options?: Monaco.editor.IStandaloneEditorConstructionOptions;\n}\n\n// Module-level singleton to track theme state\nlet lastDefinedForDarkMode: boolean | null = null;\n\nfunction defineMonacoThemes(\n monaco: typeof Monaco,\n isDark: boolean,\n currentTheme: string,\n) {\n suppressMonacoTextareaFlash();\n\n // Only redefine if the theme mode has changed or themes haven't been defined yet\n if (lastDefinedForDarkMode === isDark) return;\n lastDefinedForDarkMode = isDark;\n\n // Define both light and dark themes with current CSS variable values\n // Light theme\n monaco.editor.defineTheme('sqlrooms-light', {\n base: 'vs',\n inherit: true,\n rules: [],\n colors: {\n 'editor.background': getCssColor('--background', '#ffffff'),\n 'editor.foreground': getCssColor('--foreground', '#000000'),\n 'editor.lineHighlightBackground': getCssColor('--muted', '#f5f5f5'),\n 'editorCursor.foreground': getCssColor('--primary', '#000000'),\n 'editor.selectionBackground': getCssColor('--accent', '#e3e3e3'),\n 'editorLineNumber.foreground': getCssColor(\n '--muted-foreground',\n '#888888',\n ),\n ...getMenuColors(false),\n },\n });\n\n monaco.editor.defineTheme('sqlrooms-json-light', getJsonEditorTheme(false));\n\n // Dark theme\n monaco.editor.defineTheme('sqlrooms-dark', {\n base: 'vs-dark',\n inherit: true,\n rules: [],\n colors: {\n 'editor.background': getCssColor('--background', '#1e1e1e'),\n 'editor.foreground': getCssColor('--foreground', '#d4d4d4'),\n 'editor.lineHighlightBackground': getCssColor('--muted', '#2a2a2a'),\n 'editorCursor.foreground': getCssColor('--primary', '#ffffff'),\n 'editor.selectionBackground': getCssColor('--accent', '#264f78'),\n 'editorLineNumber.foreground': getCssColor(\n '--muted-foreground',\n '#858585',\n ),\n ...getMenuColors(true),\n },\n });\n\n monaco.editor.defineTheme('sqlrooms-json-dark', getJsonEditorTheme(true));\n\n // Apply the correct theme variant (respects JSON-specific themes)\n monaco.editor.setTheme(currentTheme);\n}\n\nconst DEFAULT_MONACO_OPTIONS: Monaco.editor.IStandaloneEditorConstructionOptions =\n {\n minimap: {enabled: false},\n scrollBeyondLastLine: false,\n automaticLayout: true,\n fontLigatures: true,\n fixedOverflowWidgets: true,\n // Prevent an initial top \"reserved\" area that can appear briefly while Monaco\n // computes sticky scroll layout (shows up as a blank/white rectangle above text).\n stickyScroll: {enabled: false} as any,\n };\n/**\n * A wrapper around the Monaco Editor component\n */\nexport const MonacoEditor: React.FC<MonacoEditorProps> = ({\n className,\n language = 'javascript',\n theme: explicitTheme,\n value = '',\n readOnly = false,\n onMount,\n onChange,\n options = {},\n beforeMount,\n ...props\n}) => {\n const {theme: appTheme} = useTheme();\n\n // Track system dark preference without setState-in-effect\n const systemPrefersDark = useSyncExternalStore(\n (onStoreChange) => {\n if (appTheme !== 'system' || typeof window === 'undefined') {\n return () => {};\n }\n const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n mediaQuery.addEventListener('change', onStoreChange);\n return () => mediaQuery.removeEventListener('change', onStoreChange);\n },\n () => {\n if (appTheme !== 'system' || typeof window === 'undefined') return false;\n return window.matchMedia('(prefers-color-scheme: dark)').matches;\n },\n () => false,\n );\n\n const isDark =\n explicitTheme === 'vs-dark'\n ? true\n : explicitTheme === 'light'\n ? false\n : appTheme === 'dark' || (appTheme === 'system' && systemPrefersDark);\n\n const monacoTheme =\n language === 'json'\n ? isDark\n ? 'sqlrooms-json-dark'\n : 'sqlrooms-json-light'\n : isDark\n ? 'sqlrooms-dark'\n : 'sqlrooms-light';\n\n const editorRef = useRef<any>(null);\n const monacoRef = useRef<typeof Monaco | null>(null);\n\n const handleBeforeMount: NonNullable<EditorProps['beforeMount']> = (\n monaco,\n ) => {\n monacoRef.current = monaco;\n defineMonacoThemes(monaco, isDark, monacoTheme);\n beforeMount?.(monaco);\n };\n\n const handleEditorDidMount: OnMount = (editor, monaco) => {\n editorRef.current = editor;\n monacoRef.current = monaco;\n\n // Safety: in case beforeMount didn't run for any reason.\n defineMonacoThemes(monaco, isDark, monacoTheme);\n\n if (onMount) {\n onMount(editor, monaco);\n }\n };\n\n // Redefine themes globally (once) when theme mode changes, then apply correct variant\n useEffect(() => {\n if (monacoRef.current) {\n defineMonacoThemes(monacoRef.current, isDark, monacoTheme);\n }\n }, [isDark, monacoTheme, language]);\n\n // Apply readOnly option\n useEffect(() => {\n if (editorRef.current) {\n editorRef.current.updateOptions({readOnly});\n }\n }, [readOnly]);\n\n // Get monospace font for code editor\n const fontFamily = getMonospaceFont();\n\n const combinedOptions = useMemo(\n () => ({\n ...DEFAULT_MONACO_OPTIONS,\n readOnly,\n fontFamily,\n ...options,\n }),\n [options, fontFamily, readOnly],\n );\n\n return (\n <div className={cn('h-[300px] w-full', className)}>\n <Editor\n height=\"100%\"\n width=\"100%\"\n language={language}\n theme={monacoTheme}\n value={value}\n options={combinedOptions}\n beforeMount={handleBeforeMount}\n onMount={handleEditorDidMount}\n onChange={onChange}\n loading={<Spinner />}\n {...props}\n />\n </div>\n );\n};\n"]}
|
|
1
|
+
{"version":3,"file":"MonacoEditor.js","sourceRoot":"","sources":["../../src/components/MonacoEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAC,MAAM,EAAiC,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAC,OAAO,EAAE,EAAE,EAAE,gBAAgB,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AAErE,OAAc,EAAC,SAAS,EAAE,OAAO,EAAE,MAAM,EAAC,MAAM,OAAO,CAAC;AACxD,OAAO,EACL,kBAAkB,EAClB,sBAAsB,EACtB,aAAa,GACd,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,iBAAiB,CAAC;AAE9D,0EAA0E;AAC1E,4EAA4E;AAC5E,8EAA8E;AAC9E,sDAAsD;AACtD,IAAI,0BAA0B,GAAG,KAAK,CAAC;AACvC,SAAS,2BAA2B;IAClC,IAAI,0BAA0B;QAAE,OAAO;IACvC,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO;IAC5C,0BAA0B,GAAG,IAAI,CAAC;IAElC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,KAAK,CAAC,YAAY,CAAC,gCAAgC,EAAE,MAAM,CAAC,CAAC;IAC7D,KAAK,CAAC,WAAW,GAAG;;;;;;;;;;;;;;;;GAgBnB,CAAC;IACF,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AACnC,CAAC;AA0CD,SAAS,kBAAkB,CACzB,MAAqB,EACrB,MAAe,EACf,YAAoB;IAEpB,2BAA2B,EAAE,CAAC;IAE9B,cAAc;IACd,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,gBAAgB,EAAE;QAC1C,IAAI,EAAE,IAAI;QACV,OAAO,EAAE,IAAI;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AC,CAAC;QACL,GAAG,sBAAsB;QACzB,QAAQ;QACR,UAAU;QACV,GAAG,OAAO;KACX,CAAC,EACF,CAAC,OAAO,EAAE,UAAU,EAAE,QAAQ,CAAC,CAChC,CAAC;IAEF,OAAO,CACL,cAAK,SAAS,EAAE,EAAE,CAAC,kBAAkB,EAAE,SAAS,CAAC,YAC/C,KAAC,MAAM,IACL,MAAM,EAAC,MAAM,EACb,KAAK,EAAC,MAAM,EACZ,QAAQ,EAAE,QAAQ,EAClB,KAAK,EAAE,WAAW,EAClB,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,eAAe,EACxB,WAAW,EAAE,iBAAiB,EAC9B,OAAO,EAAE,oBAAoB,EAC7B,QAAQ,EAAE,QAAQ,EAClB,OAAO,EAAE,KAAC,OAAO,KAAG,KAChB,KAAK,GACT,GACE,CACP,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import {Editor, EditorProps, OnChange, OnMount} from '@monaco-editor/react';\nimport {Spinner, cn, getResolvedTheme, useTheme} from '@sqlrooms/ui';\nimport type {Theme} from '@sqlrooms/ui';\nimport React, {useEffect, useMemo, useRef} from 'react';\nimport {\n getJsonEditorTheme,\n getMarkdownEditorTheme,\n getMenuColors,\n} from '../utils/color-utils';\nimport type * as Monaco from 'monaco-editor';\nimport {getCssColor, getMonospaceFont} from '@sqlrooms/utils';\n\n// Rendering issue fix for white rectangle appearing above text in Monaco.\n// Monaco creates a hidden textarea for IME input. If Monaco CSS loads late,\n// this textarea can briefly render as a normal white block and shift content.\n// Force it to never participate in layout / painting.\nlet isImeTextareaStyleInjected = false;\nfunction suppressMonacoTextareaFlash() {\n if (isImeTextareaStyleInjected) return;\n if (typeof document === 'undefined') return;\n isImeTextareaStyleInjected = true;\n\n const style = document.createElement('style');\n style.setAttribute('data-sqlrooms-monaco-ime-style', 'true');\n style.textContent = `\n .monaco-editor textarea.ime-text-area {\n position: absolute !important;\n top: 0 !important;\n left: 0 !important;\n width: 1px !important;\n height: 1px !important;\n opacity: 0 !important;\n background: transparent !important;\n color: transparent !important;\n border: 0 !important;\n padding: 0 !important;\n margin: 0 !important;\n pointer-events: none !important;\n z-index: -1 !important;\n }\n `;\n document.head.appendChild(style);\n}\n\nexport interface MonacoEditorProps extends Omit<EditorProps, 'onMount'> {\n /**\n * Callback when the editor is mounted\n */\n onMount?: OnMount;\n /**\n * Callback when the editor content changes\n */\n onChange?: OnChange;\n /**\n * CSS class name for the editor container\n * @default ''\n */\n className?: string;\n /**\n * The language of the editor\n * @default 'javascript'\n */\n language?: string;\n /**\n * The theme of the editor ('dark' | 'light' | 'system')\n * Can be explicitly set or will automatically use the app theme if not provided\n * @default 'dark'\n */\n theme?: Theme;\n /**\n * The value of the editor\n */\n value?: string;\n /**\n * Whether the editor is read-only\n * @default false\n */\n readOnly?: boolean;\n /**\n * Additional options for the editor\n */\n options?: Monaco.editor.IStandaloneEditorConstructionOptions;\n}\n\nfunction defineMonacoThemes(\n monaco: typeof Monaco,\n isDark: boolean,\n currentTheme: string,\n) {\n suppressMonacoTextareaFlash();\n\n // Light theme\n monaco.editor.defineTheme('sqlrooms-light', {\n base: 'vs',\n inherit: true,\n rules: [],\n colors: {\n 'editor.background': getCssColor('--background', '#ffffff'),\n 'editor.foreground': getCssColor('--foreground', '#000000'),\n 'editor.lineHighlightBackground': getCssColor('--muted', '#f5f5f5'),\n 'editorCursor.foreground': getCssColor('--primary', '#000000'),\n 'editor.selectionBackground': getCssColor('--accent', '#e3e3e3'),\n 'editorLineNumber.foreground': getCssColor(\n '--muted-foreground',\n '#888888',\n ),\n ...getMenuColors(false),\n },\n });\n\n monaco.editor.defineTheme('sqlrooms-json-light', getJsonEditorTheme(false));\n monaco.editor.defineTheme(\n 'sqlrooms-markdown-light',\n getMarkdownEditorTheme(false),\n );\n\n // Dark theme\n monaco.editor.defineTheme('sqlrooms-dark', {\n base: 'vs-dark',\n inherit: true,\n rules: [],\n colors: {\n 'editor.background': getCssColor('--background', '#1e1e1e'),\n 'editor.foreground': getCssColor('--foreground', '#d4d4d4'),\n 'editor.lineHighlightBackground': getCssColor('--muted', '#2a2a2a'),\n 'editorCursor.foreground': getCssColor('--primary', '#ffffff'),\n 'editor.selectionBackground': getCssColor('--accent', '#264f78'),\n 'editorLineNumber.foreground': getCssColor(\n '--muted-foreground',\n '#858585',\n ),\n ...getMenuColors(true),\n },\n });\n\n monaco.editor.defineTheme('sqlrooms-json-dark', getJsonEditorTheme(true));\n monaco.editor.defineTheme(\n 'sqlrooms-markdown-dark',\n getMarkdownEditorTheme(true),\n );\n\n // Apply the correct theme variant (respects JSON-specific themes)\n monaco.editor.setTheme(currentTheme);\n}\n\nconst DEFAULT_MONACO_OPTIONS: Monaco.editor.IStandaloneEditorConstructionOptions =\n {\n minimap: {enabled: false},\n scrollBeyondLastLine: false,\n automaticLayout: true,\n fontLigatures: true,\n fixedOverflowWidgets: true,\n fontSize: 14,\n lineHeight: 21,\n // Prevent an initial top \"reserved\" area that can appear briefly while Monaco\n // computes sticky scroll layout (shows up as a blank/white rectangle above text).\n stickyScroll: {enabled: false} as any,\n };\n/**\n * A wrapper around the Monaco Editor component\n */\nexport const MonacoEditor: React.FC<MonacoEditorProps> = ({\n className,\n language = 'javascript',\n value = '',\n readOnly = false,\n onMount,\n onChange,\n options = {},\n beforeMount,\n ...props\n}) => {\n const {theme} = useTheme();\n const isDark = getResolvedTheme(theme) === 'dark';\n\n const monacoTheme =\n language === 'json'\n ? isDark\n ? 'sqlrooms-json-dark'\n : 'sqlrooms-json-light'\n : language === 'markdown'\n ? isDark\n ? 'sqlrooms-markdown-dark'\n : 'sqlrooms-markdown-light'\n : isDark\n ? 'sqlrooms-dark'\n : 'sqlrooms-light';\n\n const editorRef = useRef<any>(null);\n const monacoRef = useRef<typeof Monaco | null>(null);\n\n const handleBeforeMount: NonNullable<EditorProps['beforeMount']> = (\n monaco,\n ) => {\n monacoRef.current = monaco;\n defineMonacoThemes(monaco, isDark, monacoTheme);\n beforeMount?.(monaco);\n };\n\n const handleEditorDidMount: OnMount = (editor, monaco) => {\n editorRef.current = editor;\n monacoRef.current = monaco;\n\n // Safety: in case beforeMount didn't run for any reason.\n defineMonacoThemes(monaco, isDark, monacoTheme);\n\n if (onMount) {\n onMount(editor, monaco);\n }\n };\n\n // Redefine themes globally (once) when theme mode changes, then apply correct variant\n useEffect(() => {\n if (monacoRef.current) {\n defineMonacoThemes(monacoRef.current, isDark, monacoTheme);\n }\n }, [isDark, monacoTheme, language]);\n\n // Apply readOnly option\n useEffect(() => {\n if (editorRef.current) {\n editorRef.current.updateOptions({readOnly});\n }\n }, [readOnly]);\n\n // Get monospace font for code editor\n const fontFamily = getMonospaceFont();\n\n const combinedOptions = useMemo(\n () => ({\n ...DEFAULT_MONACO_OPTIONS,\n readOnly,\n fontFamily,\n ...options,\n }),\n [options, fontFamily, readOnly],\n );\n\n return (\n <div className={cn('h-[300px] w-full', className)}>\n <Editor\n height=\"100%\"\n width=\"100%\"\n language={language}\n theme={monacoTheme}\n value={value}\n options={combinedOptions}\n beforeMount={handleBeforeMount}\n onMount={handleEditorDidMount}\n onChange={onChange}\n loading={<Spinner />}\n {...props}\n />\n </div>\n );\n};\n"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,5 +7,6 @@ export type { MonacoEditorProps } from './components/MonacoEditor';
|
|
|
7
7
|
export { configureMonacoLoader, isMonacoLoaderConfigured, ensureMonacoLoaderConfigured, type LoaderConfig, type MonacoLoaderOptions, type LoaderWorkers, } from './loader';
|
|
8
8
|
export { JsonMonacoEditor } from './components/JsonMonacoEditor';
|
|
9
9
|
export type { JsonMonacoEditorProps } from './components/JsonMonacoEditor';
|
|
10
|
-
export {
|
|
10
|
+
export { MarkdownMonacoEditor } from './components/MarkdownMonacoEditor';
|
|
11
|
+
export type { MarkdownMonacoEditorProps } from './components/MarkdownMonacoEditor';
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,YAAY,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,YAAY,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AACvD,YAAY,EAAC,iBAAiB,EAAC,MAAM,2BAA2B,CAAC;AAEjE,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,EAC5B,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,aAAa,GACnB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAC/D,YAAY,EAAC,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AAEzE,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAC;AACvE,YAAY,EAAC,yBAAyB,EAAC,MAAM,mCAAmC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,5 @@
|
|
|
5
5
|
export { MonacoEditor } from './components/MonacoEditor';
|
|
6
6
|
export { configureMonacoLoader, isMonacoLoaderConfigured, ensureMonacoLoaderConfigured, } from './loader';
|
|
7
7
|
export { JsonMonacoEditor } from './components/JsonMonacoEditor';
|
|
8
|
-
|
|
9
|
-
export { getCssColor, hslToHex, getMonospaceFont } from './utils/color-utils';
|
|
8
|
+
export { MarkdownMonacoEditor } from './components/MarkdownMonacoEditor';
|
|
10
9
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,GAI7B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAG/D,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAC,YAAY,EAAC,MAAM,2BAA2B,CAAC;AAGvD,OAAO,EACL,qBAAqB,EACrB,wBAAwB,EACxB,4BAA4B,GAI7B,MAAM,UAAU,CAAC;AAElB,OAAO,EAAC,gBAAgB,EAAC,MAAM,+BAA+B,CAAC;AAG/D,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAC","sourcesContent":["/**\n * {@include ../README.md}\n * @packageDocumentation\n */\n\nexport {MonacoEditor} from './components/MonacoEditor';\nexport type {MonacoEditorProps} from './components/MonacoEditor';\n\nexport {\n configureMonacoLoader,\n isMonacoLoaderConfigured,\n ensureMonacoLoaderConfigured,\n type LoaderConfig,\n type MonacoLoaderOptions,\n type LoaderWorkers,\n} from './loader';\n\nexport {JsonMonacoEditor} from './components/JsonMonacoEditor';\nexport type {JsonMonacoEditorProps} from './components/JsonMonacoEditor';\n\nexport {MarkdownMonacoEditor} from './components/MarkdownMonacoEditor';\nexport type {MarkdownMonacoEditorProps} from './components/MarkdownMonacoEditor';\n"]}
|
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Converts HSL color values to Hex color string
|
|
3
|
-
* @param h Hue (0-360)
|
|
4
|
-
* @param s Saturation (0-100)
|
|
5
|
-
* @param l Lightness (0-100)
|
|
6
|
-
* @returns Hex color string (#RRGGBB)
|
|
7
|
-
*/
|
|
8
|
-
export declare function hslToHex(h: number, s: number, l: number): string;
|
|
9
|
-
/**
|
|
10
|
-
* Safely gets a CSS variable and ensures it's in a format Monaco can use
|
|
11
|
-
* @param variableName CSS variable name (e.g. '--background')
|
|
12
|
-
* @param fallbackColor Fallback color if the variable isn't found
|
|
13
|
-
* @returns A color string in a format Monaco can use (typically hex)
|
|
14
|
-
*/
|
|
15
|
-
export declare function getCssColor(variableName: string, fallbackColor: string): string;
|
|
16
|
-
/**
|
|
17
|
-
* Gets a monospace font family from CSS variables or falls back to a system monospace font stack
|
|
18
|
-
* @returns Monospace font family string suitable for code editors
|
|
19
|
-
*/
|
|
20
|
-
export declare function getMonospaceFont(): string;
|
|
21
1
|
/**
|
|
22
2
|
* Gets Monaco editor menu theme colors based on Tailwind CSS variables
|
|
23
3
|
* @param isDarkTheme Whether the current theme is dark or light
|
|
24
4
|
* @returns Object with menu-related color settings for Monaco editor
|
|
25
5
|
*/
|
|
26
6
|
export declare function getMenuColors(isDarkTheme: boolean): Record<string, string>;
|
|
7
|
+
/**
|
|
8
|
+
* Generates a Monaco editor theme for Markdown editing with Tailwind colors.
|
|
9
|
+
* Provides syntax-aware highlighting for headings, code blocks, links,
|
|
10
|
+
* bold/italic, lists, block quotes, and inline HTML.
|
|
11
|
+
* @param isDarkTheme Whether the current theme is dark or light
|
|
12
|
+
* @returns A complete Monaco editor theme data object for Markdown editing
|
|
13
|
+
*/
|
|
14
|
+
export declare function getMarkdownEditorTheme(isDarkTheme: boolean): any;
|
|
27
15
|
/**
|
|
28
16
|
* Generates a Monaco editor theme specifically for JSON editing with Tailwind colors
|
|
29
17
|
* @param isDarkTheme Whether the current theme is dark or light
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-utils.d.ts","sourceRoot":"","sources":["../../src/utils/color-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"color-utils.d.ts","sourceRoot":"","sources":["../../src/utils/color-utils.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,WAAW,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA+J1E;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,WAAW,EAAE,OAAO,GAAG,GAAG,CAsGhE;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,OAAO,GAAG,GAAG,CAmI5D"}
|
|
@@ -1,111 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
* @param h Hue (0-360)
|
|
4
|
-
* @param s Saturation (0-100)
|
|
5
|
-
* @param l Lightness (0-100)
|
|
6
|
-
* @returns Hex color string (#RRGGBB)
|
|
7
|
-
*/
|
|
8
|
-
export function hslToHex(h, s, l) {
|
|
9
|
-
// Convert saturation and lightness to fractions
|
|
10
|
-
s /= 100;
|
|
11
|
-
l /= 100;
|
|
12
|
-
// Calculate chroma
|
|
13
|
-
const c = (1 - Math.abs(2 * l - 1)) * s;
|
|
14
|
-
const x = c * (1 - Math.abs(((h / 60) % 2) - 1));
|
|
15
|
-
const m = l - c / 2;
|
|
16
|
-
let r = 0, g = 0, b = 0;
|
|
17
|
-
if (0 <= h && h < 60) {
|
|
18
|
-
r = c;
|
|
19
|
-
g = x;
|
|
20
|
-
b = 0;
|
|
21
|
-
}
|
|
22
|
-
else if (60 <= h && h < 120) {
|
|
23
|
-
r = x;
|
|
24
|
-
g = c;
|
|
25
|
-
b = 0;
|
|
26
|
-
}
|
|
27
|
-
else if (120 <= h && h < 180) {
|
|
28
|
-
r = 0;
|
|
29
|
-
g = c;
|
|
30
|
-
b = x;
|
|
31
|
-
}
|
|
32
|
-
else if (180 <= h && h < 240) {
|
|
33
|
-
r = 0;
|
|
34
|
-
g = x;
|
|
35
|
-
b = c;
|
|
36
|
-
}
|
|
37
|
-
else if (240 <= h && h < 300) {
|
|
38
|
-
r = x;
|
|
39
|
-
g = 0;
|
|
40
|
-
b = c;
|
|
41
|
-
}
|
|
42
|
-
else if (300 <= h && h < 360) {
|
|
43
|
-
r = c;
|
|
44
|
-
g = 0;
|
|
45
|
-
b = x;
|
|
46
|
-
}
|
|
47
|
-
// Convert RGB to hex format
|
|
48
|
-
const toHex = (c) => {
|
|
49
|
-
const hex = Math.round((c + m) * 255).toString(16);
|
|
50
|
-
return hex.length === 1 ? '0' + hex : hex;
|
|
51
|
-
};
|
|
52
|
-
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
53
|
-
}
|
|
54
|
-
function normalizeCssColorValue(cssValue, fallbackColor) {
|
|
55
|
-
const trimmed = cssValue.trim();
|
|
56
|
-
if (!trimmed)
|
|
57
|
-
return fallbackColor;
|
|
58
|
-
// If already a hex color, return it
|
|
59
|
-
if (trimmed.startsWith('#'))
|
|
60
|
-
return trimmed;
|
|
61
|
-
// Check if value is in HSL format (e.g. "210 40% 98%" or "222.2 84% 4.9%")
|
|
62
|
-
const hslMatch = trimmed.match(/^(\d+(?:\.\d+)?)\s+(\d+(?:\.\d+)?)%\s+(\d+(?:\.\d+)?)%$/);
|
|
63
|
-
if (hslMatch && hslMatch[1] && hslMatch[2] && hslMatch[3]) {
|
|
64
|
-
const h = parseFloat(hslMatch[1]);
|
|
65
|
-
const s = parseFloat(hslMatch[2]);
|
|
66
|
-
const l = parseFloat(hslMatch[3]);
|
|
67
|
-
return hslToHex(h, s, l);
|
|
68
|
-
}
|
|
69
|
-
return fallbackColor;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Safely gets a CSS variable and ensures it's in a format Monaco can use
|
|
73
|
-
* @param variableName CSS variable name (e.g. '--background')
|
|
74
|
-
* @param fallbackColor Fallback color if the variable isn't found
|
|
75
|
-
* @returns A color string in a format Monaco can use (typically hex)
|
|
76
|
-
*/
|
|
77
|
-
export function getCssColor(variableName, fallbackColor) {
|
|
78
|
-
if (typeof document === 'undefined')
|
|
79
|
-
return fallbackColor;
|
|
80
|
-
try {
|
|
81
|
-
// Get CSS variable value from current DOM
|
|
82
|
-
const cssValue = getComputedStyle(document.documentElement)
|
|
83
|
-
.getPropertyValue(variableName)
|
|
84
|
-
.trim();
|
|
85
|
-
if (!cssValue)
|
|
86
|
-
return fallbackColor;
|
|
87
|
-
return normalizeCssColorValue(cssValue, fallbackColor);
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
console.error(`Error getting CSS variable ${variableName}:`, error);
|
|
91
|
-
return fallbackColor;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Gets a monospace font family from CSS variables or falls back to a system monospace font stack
|
|
96
|
-
* @returns Monospace font family string suitable for code editors
|
|
97
|
-
*/
|
|
98
|
-
export function getMonospaceFont() {
|
|
99
|
-
if (typeof document === 'undefined') {
|
|
100
|
-
return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace';
|
|
101
|
-
}
|
|
102
|
-
return (getComputedStyle(document.documentElement)
|
|
103
|
-
.getPropertyValue('--font-mono')
|
|
104
|
-
.trim() ||
|
|
105
|
-
'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
|
|
106
|
-
//'SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace'
|
|
107
|
-
);
|
|
108
|
-
}
|
|
1
|
+
// Re-export generic color utilities from shared utils package
|
|
2
|
+
import { getCssColor } from '@sqlrooms/utils';
|
|
109
3
|
/**
|
|
110
4
|
* Gets Monaco editor menu theme colors based on Tailwind CSS variables
|
|
111
5
|
* @param isDarkTheme Whether the current theme is dark or light
|
|
@@ -184,31 +78,94 @@ export function getMenuColors(isDarkTheme) {
|
|
|
184
78
|
}
|
|
185
79
|
return result;
|
|
186
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Generates a Monaco editor theme for Markdown editing with Tailwind colors.
|
|
83
|
+
* Provides syntax-aware highlighting for headings, code blocks, links,
|
|
84
|
+
* bold/italic, lists, block quotes, and inline HTML.
|
|
85
|
+
* @param isDarkTheme Whether the current theme is dark or light
|
|
86
|
+
* @returns A complete Monaco editor theme data object for Markdown editing
|
|
87
|
+
*/
|
|
88
|
+
export function getMarkdownEditorTheme(isDarkTheme) {
|
|
89
|
+
const background = getCssColor('--background', isDarkTheme ? '#0b1220' : '#ffffff');
|
|
90
|
+
const foreground = getCssColor('--foreground', isDarkTheme ? '#e0e6ed' : '#24292f');
|
|
91
|
+
const lineHighlight = getCssColor('--muted', isDarkTheme ? '#111a2b' : '#f5f5f5');
|
|
92
|
+
const cursor = getCssColor('--primary', isDarkTheme ? '#ffffff' : '#000000');
|
|
93
|
+
const selection = getCssColor('--accent', isDarkTheme ? '#23436b' : '#e3e3e3');
|
|
94
|
+
const lineNumbers = getCssColor('--muted-foreground', isDarkTheme ? '#8b97ab' : '#888888');
|
|
95
|
+
const heading = getCssColor('--editor-heading', isDarkTheme ? '#78AEFF' : '#0550AE');
|
|
96
|
+
const bold = isDarkTheme ? '#E0E6ED' : '#24292F';
|
|
97
|
+
const italic = isDarkTheme ? '#C987E8' : '#8250DF';
|
|
98
|
+
const link = getCssColor('--editor-link', isDarkTheme ? '#58A6FF' : '#0969DA');
|
|
99
|
+
const codeInline = isDarkTheme ? '#FFAD85' : '#DB745C';
|
|
100
|
+
const codeContent = isDarkTheme ? '#8BD5CA' : '#2B6F63';
|
|
101
|
+
const codeFence = isDarkTheme ? '#525C6A' : '#A0A8B4';
|
|
102
|
+
const listMarker = isDarkTheme ? '#F0883E' : '#CF5309';
|
|
103
|
+
const quote = isDarkTheme ? '#8b97ab' : '#6E7781';
|
|
104
|
+
const separator = isDarkTheme ? '#3D444D' : '#D0D7DE';
|
|
105
|
+
const htmlTag = isDarkTheme ? '#7CD992' : '#116329';
|
|
106
|
+
const fg = (hex) => hex.slice(1);
|
|
107
|
+
return {
|
|
108
|
+
base: isDarkTheme ? 'vs-dark' : 'vs',
|
|
109
|
+
inherit: true,
|
|
110
|
+
rules: [
|
|
111
|
+
// Headings (# to ######)
|
|
112
|
+
{ token: 'keyword.md', foreground: fg(heading), fontStyle: 'bold' },
|
|
113
|
+
{ token: 'keyword.table.header.md', foreground: fg(heading) },
|
|
114
|
+
// Bold **text**
|
|
115
|
+
{ token: 'strong.md', foreground: fg(bold), fontStyle: 'bold' },
|
|
116
|
+
// Italic *text*
|
|
117
|
+
{ token: 'emphasis.md', foreground: fg(italic), fontStyle: 'italic' },
|
|
118
|
+
// Strikethrough ~~text~~
|
|
119
|
+
{ token: 'strikethrough.md', fontStyle: 'strikethrough' },
|
|
120
|
+
// Links [text](url)
|
|
121
|
+
{ token: 'string.link.md', foreground: fg(link) },
|
|
122
|
+
{ token: 'type.header.md', foreground: fg(link), fontStyle: 'underline' },
|
|
123
|
+
// Inline code `code`
|
|
124
|
+
{ token: 'variable.md', foreground: fg(codeInline) },
|
|
125
|
+
// Fenced code block fence markers (``` lines)
|
|
126
|
+
{ token: 'variable.source.md', foreground: fg(codeFence) },
|
|
127
|
+
// Fenced code block content
|
|
128
|
+
{ token: 'string.md', foreground: fg(codeContent) },
|
|
129
|
+
// List markers (-, *, 1.)
|
|
130
|
+
{ token: 'keyword.list.md', foreground: fg(listMarker) },
|
|
131
|
+
// Block quotes >
|
|
132
|
+
{ token: 'comment.md', foreground: fg(quote), fontStyle: 'italic' },
|
|
133
|
+
{ token: 'quote.md', foreground: fg(quote), fontStyle: 'italic' },
|
|
134
|
+
// Horizontal rules --- / ***
|
|
135
|
+
{ token: 'keyword.hr.md', foreground: fg(separator) },
|
|
136
|
+
// HTML tags in markdown
|
|
137
|
+
{ token: 'tag.md', foreground: fg(htmlTag) },
|
|
138
|
+
{ token: 'tag', foreground: fg(htmlTag) },
|
|
139
|
+
{ token: 'attribute.name.md', foreground: fg(heading) },
|
|
140
|
+
{ token: 'attribute.value.md', foreground: fg(codeInline) },
|
|
141
|
+
// Fallback
|
|
142
|
+
{ token: '', foreground: fg(foreground) },
|
|
143
|
+
],
|
|
144
|
+
colors: {
|
|
145
|
+
'editor.background': background,
|
|
146
|
+
'editor.foreground': foreground,
|
|
147
|
+
'editor.lineHighlightBackground': lineHighlight,
|
|
148
|
+
'editorCursor.foreground': cursor,
|
|
149
|
+
'editor.selectionBackground': selection,
|
|
150
|
+
'editorLineNumber.foreground': lineNumbers,
|
|
151
|
+
...getMenuColors(isDarkTheme),
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
187
155
|
/**
|
|
188
156
|
* Generates a Monaco editor theme specifically for JSON editing with Tailwind colors
|
|
189
157
|
* @param isDarkTheme Whether the current theme is dark or light
|
|
190
158
|
* @returns A complete Monaco editor theme data object for JSON editing
|
|
191
159
|
*/
|
|
192
160
|
export function getJsonEditorTheme(isDarkTheme) {
|
|
193
|
-
//
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
};
|
|
202
|
-
// Dark theme colors
|
|
203
|
-
const darkThemeColors = {
|
|
204
|
-
property: '#78AEFF', // Pastel blue for property names
|
|
205
|
-
string: '#FFAD85', // Pastel coral/orange for string values
|
|
206
|
-
number: '#7CD992', // Pastel green for numbers
|
|
207
|
-
keyword: '#C987E8', // Pastel purple for keywords
|
|
208
|
-
punctuation: '#A9B1BA', // Light gray for punctuation
|
|
209
|
-
};
|
|
210
|
-
// Select the appropriate color set based on theme
|
|
211
|
-
const colors = isDarkTheme ? darkThemeColors : lightThemeColors;
|
|
161
|
+
// Get syntax colors from CSS variables with fallbacks
|
|
162
|
+
const property = getCssColor('--editor-property', isDarkTheme ? '#78AEFF' : '#4B6BDF');
|
|
163
|
+
const string = getCssColor('--editor-string', isDarkTheme ? '#FFAD85' : '#DB745C');
|
|
164
|
+
const number = getCssColor('--editor-number', isDarkTheme ? '#7CD992' : '#56A64B');
|
|
165
|
+
const keyword = getCssColor('--editor-keyword', isDarkTheme ? '#C987E8' : '#A450B5');
|
|
166
|
+
const punctuation = getCssColor('--editor-punctuation', isDarkTheme ? '#A9B1BA' : '#6E7781');
|
|
167
|
+
const comment = getCssColor('--editor-comment', isDarkTheme ? '#6A9955' : '#008000');
|
|
168
|
+
const invalid = getCssColor('--editor-invalid', isDarkTheme ? '#F44747' : '#CD3131');
|
|
212
169
|
// Theme background and UI colors - read from current DOM
|
|
213
170
|
const background = getCssColor('--background', isDarkTheme ? '#1E1E1E' : '#FFFFFF');
|
|
214
171
|
const foreground = getCssColor('--foreground', isDarkTheme ? '#D4D4D4' : '#000000');
|
|
@@ -224,20 +181,24 @@ export function getJsonEditorTheme(isDarkTheme) {
|
|
|
224
181
|
base: isDarkTheme ? 'vs-dark' : 'vs',
|
|
225
182
|
inherit: true,
|
|
226
183
|
rules: [
|
|
227
|
-
// Property keys
|
|
228
|
-
{ token: 'type', foreground:
|
|
229
|
-
{ token: 'string.key.json', foreground:
|
|
230
|
-
{ token: 'key', foreground:
|
|
231
|
-
// String values
|
|
232
|
-
{ token: 'string.value.json', foreground:
|
|
233
|
-
{ token: 'string', foreground:
|
|
234
|
-
// Numbers
|
|
235
|
-
{ token: 'number', foreground:
|
|
236
|
-
// Keywords (true, false, null)
|
|
237
|
-
{ token: 'keyword', foreground:
|
|
238
|
-
// Punctuation
|
|
239
|
-
{ token: 'delimiter', foreground:
|
|
240
|
-
{ token: 'bracket', foreground:
|
|
184
|
+
// Property keys
|
|
185
|
+
{ token: 'type', foreground: property.slice(1) },
|
|
186
|
+
{ token: 'string.key.json', foreground: property.slice(1) },
|
|
187
|
+
{ token: 'key', foreground: property.slice(1) },
|
|
188
|
+
// String values
|
|
189
|
+
{ token: 'string.value.json', foreground: string.slice(1) },
|
|
190
|
+
{ token: 'string', foreground: string.slice(1) },
|
|
191
|
+
// Numbers
|
|
192
|
+
{ token: 'number', foreground: number.slice(1) },
|
|
193
|
+
// Keywords (true, false, null)
|
|
194
|
+
{ token: 'keyword', foreground: keyword.slice(1) },
|
|
195
|
+
// Punctuation
|
|
196
|
+
{ token: 'delimiter', foreground: punctuation.slice(1) },
|
|
197
|
+
{ token: 'bracket', foreground: punctuation.slice(1) },
|
|
198
|
+
// Comments
|
|
199
|
+
{ token: 'comment', foreground: comment.slice(1) },
|
|
200
|
+
// Invalid syntax
|
|
201
|
+
{ token: 'invalid', foreground: invalid.slice(1) },
|
|
241
202
|
// Fallbacks
|
|
242
203
|
{ token: '', foreground: foreground.slice(1) },
|
|
243
204
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color-utils.js","sourceRoot":"","sources":["../../src/utils/color-utils.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,UAAU,QAAQ,CAAC,CAAS,EAAE,CAAS,EAAE,CAAS;IACtD,gDAAgD;IAChD,CAAC,IAAI,GAAG,CAAC;IACT,CAAC,IAAI,GAAG,CAAC;IAET,mBAAmB;IACnB,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;IACxC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IACjD,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACpB,IAAI,CAAC,GAAG,CAAC,EACP,CAAC,GAAG,CAAC,EACL,CAAC,GAAG,CAAC,CAAC;IAER,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC;QACrB,CAAC,GAAG,CAAC,CAAC;QACN,CAAC,GAAG,CAAC,CAAC;QACN,CAAC,GAAG,CAAC,CAAC;IACR,CAAC;SAAM,IAAI,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CAAC,CAAC,EAAC;SAC7C;QACD,MAAM,EAAE;YACN,gBAAgB;YAChB,mBAAmB,EAAE,UAAU;YAC/B,mBAAmB,EAAE,UAAU;YAC/B,4BAA4B,EAAE,SAAS;YACvC,gCAAgC,EAAE,aAAa;YAC/C,6BAA6B,EAAE,WAAW;YAC1C,yBAAyB,EAAE,MAAM;YAEjC,uBAAuB;YACvB,yBAAyB,EAAE,cAAc;YACzC,yBAAyB,EAAE,cAAc;YACzC,qBAAqB,EAAE,aAAa;YACpC,gCAAgC,EAAE,cAAc;YAChD,gCAAgC,EAAE,cAAc;YAChD,4BAA4B,EAAE,aAAa;YAE3C,cAAc;YACd,iBAAiB,EAAE,cAAc;YACjC,iBAAiB,EAAE,cAAc;YACjC,0BAA0B,EAAE,SAAS;YACrC,0BAA0B,EAAE,cAAc;YAC1C,0BAA0B,EAAE,aAAa;YAEzC,yBAAyB;YACzB,sBAAsB,EAAE,aAAa;YACrC,gCAAgC,EAAE,SAAS;YAC3C,uBAAuB,EAAE,cAAc;YACvC,uBAAuB,EAAE,cAAc;SACxC;KACF,CAAC;AACJ,CAAC","sourcesContent":["/**\n * Converts HSL color values to Hex color string\n * @param h Hue (0-360)\n * @param s Saturation (0-100)\n * @param l Lightness (0-100)\n * @returns Hex color string (#RRGGBB)\n */\nexport function hslToHex(h: number, s: number, l: number): string {\n // Convert saturation and lightness to fractions\n s /= 100;\n l /= 100;\n\n // Calculate chroma\n const c = (1 - Math.abs(2 * l - 1)) * s;\n const x = c * (1 - Math.abs(((h / 60) % 2) - 1));\n const m = l - c / 2;\n let r = 0,\n g = 0,\n b = 0;\n\n if (0 <= h && h < 60) {\n r = c;\n g = x;\n b = 0;\n } else if (60 <= h && h < 120) {\n r = x;\n g = c;\n b = 0;\n } else if (120 <= h && h < 180) {\n r = 0;\n g = c;\n b = x;\n } else if (180 <= h && h < 240) {\n r = 0;\n g = x;\n b = c;\n } else if (240 <= h && h < 300) {\n r = x;\n g = 0;\n b = c;\n } else if (300 <= h && h < 360) {\n r = c;\n g = 0;\n b = x;\n }\n\n // Convert RGB to hex format\n const toHex = (c: number) => {\n const hex = Math.round((c + m) * 255).toString(16);\n return hex.length === 1 ? '0' + hex : hex;\n };\n\n return `#${toHex(r)}${toHex(g)}${toHex(b)}`;\n}\n\nfunction normalizeCssColorValue(\n cssValue: string,\n fallbackColor: string,\n): string {\n const trimmed = cssValue.trim();\n if (!trimmed) return fallbackColor;\n\n // If already a hex color, return it\n if (trimmed.startsWith('#')) return trimmed;\n\n // Check if value is in HSL format (e.g. \"210 40% 98%\" or \"222.2 84% 4.9%\")\n const hslMatch = trimmed.match(\n /^(\\d+(?:\\.\\d+)?)\\s+(\\d+(?:\\.\\d+)?)%\\s+(\\d+(?:\\.\\d+)?)%$/,\n );\n if (hslMatch && hslMatch[1] && hslMatch[2] && hslMatch[3]) {\n const h = parseFloat(hslMatch[1]);\n const s = parseFloat(hslMatch[2]);\n const l = parseFloat(hslMatch[3]);\n return hslToHex(h, s, l);\n }\n\n return fallbackColor;\n}\n\n/**\n * Safely gets a CSS variable and ensures it's in a format Monaco can use\n * @param variableName CSS variable name (e.g. '--background')\n * @param fallbackColor Fallback color if the variable isn't found\n * @returns A color string in a format Monaco can use (typically hex)\n */\nexport function getCssColor(\n variableName: string,\n fallbackColor: string,\n): string {\n if (typeof document === 'undefined') return fallbackColor;\n try {\n // Get CSS variable value from current DOM\n const cssValue = getComputedStyle(document.documentElement)\n .getPropertyValue(variableName)\n .trim();\n\n if (!cssValue) return fallbackColor;\n return normalizeCssColorValue(cssValue, fallbackColor);\n } catch (error) {\n console.error(`Error getting CSS variable ${variableName}:`, error);\n return fallbackColor;\n }\n}\n\n/**\n * Gets a monospace font family from CSS variables or falls back to a system monospace font stack\n * @returns Monospace font family string suitable for code editors\n */\nexport function getMonospaceFont(): string {\n if (typeof document === 'undefined') {\n return 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace';\n }\n return (\n getComputedStyle(document.documentElement)\n .getPropertyValue('--font-mono')\n .trim() ||\n 'ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace'\n //'SFMono-Regular, Menlo, Monaco, Consolas, \"Liberation Mono\", \"Courier New\", monospace'\n );\n}\n\n/**\n * Gets Monaco editor menu theme colors based on Tailwind CSS variables\n * @param isDarkTheme Whether the current theme is dark or light\n * @returns Object with menu-related color settings for Monaco editor\n */\nexport function getMenuColors(isDarkTheme: boolean): Record<string, string> {\n const defaultDarkColors = {\n 'editorWidget.background': '#1f1f1f',\n 'editorWidget.foreground': '#cccccc',\n 'editorWidget.border': '#454545',\n 'editorSuggestWidget.background': '#252526',\n 'list.hoverBackground': '#2a2d2e',\n 'list.highlightForeground': '#0097fb',\n 'menu.background': '#252526',\n 'menu.foreground': '#cccccc',\n 'menu.selectionBackground': '#04395e',\n 'menu.selectionForeground': '#ffffff',\n 'quickInput.background': '#252526',\n 'quickInput.foreground': '#cccccc',\n 'dropdown.background': '#252526',\n 'dropdown.foreground': '#f0f0f0',\n };\n\n const defaultLightColors = {\n 'editorWidget.background': '#f3f3f3',\n 'editorWidget.foreground': '#616161',\n 'editorWidget.border': '#c8c8c8',\n 'editorSuggestWidget.background': '#f3f3f3',\n 'list.hoverBackground': '#e8e8e8',\n 'list.highlightForeground': '#0066bf',\n 'menu.background': '#f3f3f3',\n 'menu.foreground': '#616161',\n 'menu.selectionBackground': '#d6ebff',\n 'menu.selectionForeground': '#333333',\n 'quickInput.background': '#f3f3f3',\n 'quickInput.foreground': '#616161',\n 'dropdown.background': '#f3f3f3',\n 'dropdown.foreground': '#616161',\n };\n\n // Choose base defaults based on theme\n const defaults = isDarkTheme ? defaultDarkColors : defaultLightColors;\n const result: Record<string, string> = {};\n\n // Map Tailwind variables to Monaco color settings\n if (isDarkTheme) {\n // Dark theme mappings\n result['editorWidget.background'] = getCssColor(\n '--popover',\n defaults['editorWidget.background'],\n );\n result['editorWidget.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['editorWidget.foreground'],\n );\n result['editorWidget.border'] = getCssColor(\n '--border',\n defaults['editorWidget.border'],\n );\n result['editorSuggestWidget.background'] = getCssColor(\n '--popover',\n defaults['editorSuggestWidget.background'],\n );\n result['list.hoverBackground'] = getCssColor(\n '--accent',\n defaults['list.hoverBackground'],\n );\n result['list.highlightForeground'] = getCssColor(\n '--primary',\n defaults['list.highlightForeground'],\n );\n result['menu.background'] = getCssColor(\n '--popover',\n defaults['menu.background'],\n );\n result['menu.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['menu.foreground'],\n );\n result['menu.selectionBackground'] = getCssColor(\n '--accent',\n defaults['menu.selectionBackground'],\n );\n result['menu.selectionForeground'] = getCssColor(\n '--accent-foreground',\n defaults['menu.selectionForeground'],\n );\n result['quickInput.background'] = getCssColor(\n '--popover',\n defaults['quickInput.background'],\n );\n result['quickInput.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['quickInput.foreground'],\n );\n result['dropdown.background'] = getCssColor(\n '--popover',\n defaults['dropdown.background'],\n );\n result['dropdown.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['dropdown.foreground'],\n );\n } else {\n // Light theme mappings\n result['editorWidget.background'] = getCssColor(\n '--popover',\n defaults['editorWidget.background'],\n );\n result['editorWidget.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['editorWidget.foreground'],\n );\n result['editorWidget.border'] = getCssColor(\n '--border',\n defaults['editorWidget.border'],\n );\n result['editorSuggestWidget.background'] = getCssColor(\n '--popover',\n defaults['editorSuggestWidget.background'],\n );\n result['list.hoverBackground'] = getCssColor(\n '--accent',\n defaults['list.hoverBackground'],\n );\n result['list.highlightForeground'] = getCssColor(\n '--primary',\n defaults['list.highlightForeground'],\n );\n result['menu.background'] = getCssColor(\n '--popover',\n defaults['menu.background'],\n );\n result['menu.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['menu.foreground'],\n );\n result['menu.selectionBackground'] = getCssColor(\n '--accent',\n defaults['menu.selectionBackground'],\n );\n result['menu.selectionForeground'] = getCssColor(\n '--accent-foreground',\n defaults['menu.selectionForeground'],\n );\n result['quickInput.background'] = getCssColor(\n '--popover',\n defaults['quickInput.background'],\n );\n result['quickInput.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['quickInput.foreground'],\n );\n result['dropdown.background'] = getCssColor(\n '--popover',\n defaults['dropdown.background'],\n );\n result['dropdown.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['dropdown.foreground'],\n );\n }\n\n return result;\n}\n\n/**\n * Generates a Monaco editor theme specifically for JSON editing with Tailwind colors\n * @param isDarkTheme Whether the current theme is dark or light\n * @returns A complete Monaco editor theme data object for JSON editing\n */\nexport function getJsonEditorTheme(isDarkTheme: boolean): any {\n // Predefined pastel colors for syntax highlighting\n // Light theme colors\n const lightThemeColors = {\n property: '#4B6BDF', // Soft blue for property names\n string: '#DB745C', // Soft coral for string values\n number: '#56A64B', // Soft green for numbers\n keyword: '#A450B5', // Soft purple for keywords\n punctuation: '#6E7781', // Soft gray for punctuation\n };\n\n // Dark theme colors\n const darkThemeColors = {\n property: '#78AEFF', // Pastel blue for property names\n string: '#FFAD85', // Pastel coral/orange for string values\n number: '#7CD992', // Pastel green for numbers\n keyword: '#C987E8', // Pastel purple for keywords\n punctuation: '#A9B1BA', // Light gray for punctuation\n };\n\n // Select the appropriate color set based on theme\n const colors = isDarkTheme ? darkThemeColors : lightThemeColors;\n\n // Theme background and UI colors - read from current DOM\n const background = getCssColor(\n '--background',\n isDarkTheme ? '#1E1E1E' : '#FFFFFF',\n );\n const foreground = getCssColor(\n '--foreground',\n isDarkTheme ? '#D4D4D4' : '#000000',\n );\n const selection = getCssColor(\n '--accent',\n isDarkTheme ? '#264F78' : '#ADD6FF',\n );\n const lineHighlight = getCssColor(\n '--muted',\n isDarkTheme ? '#2A2A2A' : '#F5F5F5',\n );\n const lineNumbers = getCssColor(\n '--muted-foreground',\n isDarkTheme ? '#858585' : '#888888',\n );\n const cursor = getCssColor('--primary', isDarkTheme ? '#FFFFFF' : '#000000');\n\n // Menu colors\n const menuBackground = getCssColor(\n '--popover',\n isDarkTheme ? '#1C2233' : '#F3F3F3',\n );\n const menuForeground = getCssColor(\n '--popover-foreground',\n isDarkTheme ? '#FFFFFF' : '#616161',\n );\n const menuSeparator = getCssColor(\n '--border',\n isDarkTheme ? '#39435E' : '#C8C8C8',\n );\n\n return {\n base: isDarkTheme ? 'vs-dark' : 'vs',\n inherit: true,\n rules: [\n // Property keys - using pastel blue\n {token: 'type', foreground: colors.property.slice(1)},\n {token: 'string.key.json', foreground: colors.property.slice(1)},\n {token: 'key', foreground: colors.property.slice(1)},\n\n // String values - using pastel coral/orange\n {token: 'string.value.json', foreground: colors.string.slice(1)},\n {token: 'string', foreground: colors.string.slice(1)},\n\n // Numbers - using pastel green\n {token: 'number', foreground: colors.number.slice(1)},\n\n // Keywords (true, false, null) - using pastel purple\n {token: 'keyword', foreground: colors.keyword.slice(1)},\n\n // Punctuation - using light gray\n {token: 'delimiter', foreground: colors.punctuation.slice(1)},\n {token: 'bracket', foreground: colors.punctuation.slice(1)},\n\n // Fallbacks\n {token: '', foreground: foreground.slice(1)},\n ],\n colors: {\n // Editor colors\n 'editor.background': background,\n 'editor.foreground': foreground,\n 'editor.selectionBackground': selection,\n 'editor.lineHighlightBackground': lineHighlight,\n 'editorLineNumber.foreground': lineNumbers,\n 'editorCursor.foreground': cursor,\n\n // Widget and UI colors\n 'editorWidget.background': menuBackground,\n 'editorWidget.foreground': menuForeground,\n 'editorWidget.border': menuSeparator,\n 'editorSuggestWidget.background': menuBackground,\n 'editorSuggestWidget.foreground': menuForeground,\n 'editorSuggestWidget.border': menuSeparator,\n\n // Menu colors\n 'menu.background': menuBackground,\n 'menu.foreground': menuForeground,\n 'menu.selectionBackground': selection,\n 'menu.selectionForeground': menuForeground,\n 'menu.separatorBackground': menuSeparator,\n\n // Additional UI elements\n 'list.hoverBackground': lineHighlight,\n 'list.activeSelectionBackground': selection,\n 'quickInput.background': menuBackground,\n 'quickInput.foreground': menuForeground,\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"color-utils.js","sourceRoot":"","sources":["../../src/utils/color-utils.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,WAAoB;IAChD,MAAM,iBAAiB,GAAG;QACxB,yBAAyB,EAAE,SAAS;QACpC,yBAAyB,EAAE,SAAS;QACpC,qBAAqB,EAAE,SAAS;QAChC,gCAAgC,EAAE,SAAS;QAC3C,sBAAsB,EAAE,SAAS;QACjC,0BAA0B,EAAE,SAAS;QACrC,iBAAiB,EAAE,SAAS;QAC5B,iBAAiB,EAAE,SAAS;QAC5B,0BAA0B,EAAE,SAAS;QACrC,0BAA0B,EAAE,SAAS;QACrC,uBAAuB,EAAE,SAAS;QAClC,uBAAuB,EAAE,SAAS;QAClC,qBAAqB,EAAE,SAAS;QAChC,qBAAqB,EAAE,SAAS;KACjC,CAAC;IAEF,MAAM,kBAAkB,GAAG;QACzB,yBAAyB,EAAE,SAAS;QACpC,yBAAyB,EAAE,SAAS;QACpC,qBAAqB,EAAE,SAAS;QAChC,gCAAgC,EAAE,SAAS;QAC3C,sBAAsB,EAAE,SAAS;QACjC,0BAA0B,EAAE,SAAS;QACrC,iBAAiB,EAAE,SAAS;QAC5B,iBAAiB,EAAE,SAAS;QAC5B,0BAA0B,EAAE,SAAS;QACrC,0BAA0B,EAAE,SAAS;QACrC,uBAAuB,EAAE,SAAS;QAClC,uBAAuB,EAAE,SAAS;QAClC,qBAAqB,EAAE,SAAS;QAChC,qBAAqB,EAAE,SAAS;KACjC,CAAC;IAEF,sCAAsC;IACtC,MAAM,QAAQ,GAAG,WAAW,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,kBAAkB,CAAC;IACtE,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,kD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W,CAAC,KAAK,CAAC,CAAC,CAAC,EAAC;YACtD,EAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,EAAC;YAEpD,WAAW;YACX,EAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAC;YAEhD,iBAAiB;YACjB,EAAC,KAAK,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAC;YAEhD,YAAY;YACZ,EAAC,KAAK,EAAE,EAAE,EAAE,UAAU,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,EAAC;SAC7C;QACD,MAAM,EAAE;YACN,gBAAgB;YAChB,mBAAmB,EAAE,UAAU;YAC/B,mBAAmB,EAAE,UAAU;YAC/B,4BAA4B,EAAE,SAAS;YACvC,gCAAgC,EAAE,aAAa;YAC/C,6BAA6B,EAAE,WAAW;YAC1C,yBAAyB,EAAE,MAAM;YAEjC,uBAAuB;YACvB,yBAAyB,EAAE,cAAc;YACzC,yBAAyB,EAAE,cAAc;YACzC,qBAAqB,EAAE,aAAa;YACpC,gCAAgC,EAAE,cAAc;YAChD,gCAAgC,EAAE,cAAc;YAChD,4BAA4B,EAAE,aAAa;YAE3C,cAAc;YACd,iBAAiB,EAAE,cAAc;YACjC,iBAAiB,EAAE,cAAc;YACjC,0BAA0B,EAAE,SAAS;YACrC,0BAA0B,EAAE,cAAc;YAC1C,0BAA0B,EAAE,aAAa;YAEzC,yBAAyB;YACzB,sBAAsB,EAAE,aAAa;YACrC,gCAAgC,EAAE,SAAS;YAC3C,uBAAuB,EAAE,cAAc;YACvC,uBAAuB,EAAE,cAAc;SACxC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Re-export generic color utilities from shared utils package\nimport {getCssColor} from '@sqlrooms/utils';\n\n/**\n * Gets Monaco editor menu theme colors based on Tailwind CSS variables\n * @param isDarkTheme Whether the current theme is dark or light\n * @returns Object with menu-related color settings for Monaco editor\n */\nexport function getMenuColors(isDarkTheme: boolean): Record<string, string> {\n const defaultDarkColors = {\n 'editorWidget.background': '#1f1f1f',\n 'editorWidget.foreground': '#cccccc',\n 'editorWidget.border': '#454545',\n 'editorSuggestWidget.background': '#252526',\n 'list.hoverBackground': '#2a2d2e',\n 'list.highlightForeground': '#0097fb',\n 'menu.background': '#252526',\n 'menu.foreground': '#cccccc',\n 'menu.selectionBackground': '#04395e',\n 'menu.selectionForeground': '#ffffff',\n 'quickInput.background': '#252526',\n 'quickInput.foreground': '#cccccc',\n 'dropdown.background': '#252526',\n 'dropdown.foreground': '#f0f0f0',\n };\n\n const defaultLightColors = {\n 'editorWidget.background': '#f3f3f3',\n 'editorWidget.foreground': '#616161',\n 'editorWidget.border': '#c8c8c8',\n 'editorSuggestWidget.background': '#f3f3f3',\n 'list.hoverBackground': '#e8e8e8',\n 'list.highlightForeground': '#0066bf',\n 'menu.background': '#f3f3f3',\n 'menu.foreground': '#616161',\n 'menu.selectionBackground': '#d6ebff',\n 'menu.selectionForeground': '#333333',\n 'quickInput.background': '#f3f3f3',\n 'quickInput.foreground': '#616161',\n 'dropdown.background': '#f3f3f3',\n 'dropdown.foreground': '#616161',\n };\n\n // Choose base defaults based on theme\n const defaults = isDarkTheme ? defaultDarkColors : defaultLightColors;\n const result: Record<string, string> = {};\n\n // Map Tailwind variables to Monaco color settings\n if (isDarkTheme) {\n // Dark theme mappings\n result['editorWidget.background'] = getCssColor(\n '--popover',\n defaults['editorWidget.background'],\n );\n result['editorWidget.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['editorWidget.foreground'],\n );\n result['editorWidget.border'] = getCssColor(\n '--border',\n defaults['editorWidget.border'],\n );\n result['editorSuggestWidget.background'] = getCssColor(\n '--popover',\n defaults['editorSuggestWidget.background'],\n );\n result['list.hoverBackground'] = getCssColor(\n '--accent',\n defaults['list.hoverBackground'],\n );\n result['list.highlightForeground'] = getCssColor(\n '--primary',\n defaults['list.highlightForeground'],\n );\n result['menu.background'] = getCssColor(\n '--popover',\n defaults['menu.background'],\n );\n result['menu.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['menu.foreground'],\n );\n result['menu.selectionBackground'] = getCssColor(\n '--accent',\n defaults['menu.selectionBackground'],\n );\n result['menu.selectionForeground'] = getCssColor(\n '--accent-foreground',\n defaults['menu.selectionForeground'],\n );\n result['quickInput.background'] = getCssColor(\n '--popover',\n defaults['quickInput.background'],\n );\n result['quickInput.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['quickInput.foreground'],\n );\n result['dropdown.background'] = getCssColor(\n '--popover',\n defaults['dropdown.background'],\n );\n result['dropdown.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['dropdown.foreground'],\n );\n } else {\n // Light theme mappings\n result['editorWidget.background'] = getCssColor(\n '--popover',\n defaults['editorWidget.background'],\n );\n result['editorWidget.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['editorWidget.foreground'],\n );\n result['editorWidget.border'] = getCssColor(\n '--border',\n defaults['editorWidget.border'],\n );\n result['editorSuggestWidget.background'] = getCssColor(\n '--popover',\n defaults['editorSuggestWidget.background'],\n );\n result['list.hoverBackground'] = getCssColor(\n '--accent',\n defaults['list.hoverBackground'],\n );\n result['list.highlightForeground'] = getCssColor(\n '--primary',\n defaults['list.highlightForeground'],\n );\n result['menu.background'] = getCssColor(\n '--popover',\n defaults['menu.background'],\n );\n result['menu.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['menu.foreground'],\n );\n result['menu.selectionBackground'] = getCssColor(\n '--accent',\n defaults['menu.selectionBackground'],\n );\n result['menu.selectionForeground'] = getCssColor(\n '--accent-foreground',\n defaults['menu.selectionForeground'],\n );\n result['quickInput.background'] = getCssColor(\n '--popover',\n defaults['quickInput.background'],\n );\n result['quickInput.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['quickInput.foreground'],\n );\n result['dropdown.background'] = getCssColor(\n '--popover',\n defaults['dropdown.background'],\n );\n result['dropdown.foreground'] = getCssColor(\n '--popover-foreground',\n defaults['dropdown.foreground'],\n );\n }\n\n return result;\n}\n\n/**\n * Generates a Monaco editor theme for Markdown editing with Tailwind colors.\n * Provides syntax-aware highlighting for headings, code blocks, links,\n * bold/italic, lists, block quotes, and inline HTML.\n * @param isDarkTheme Whether the current theme is dark or light\n * @returns A complete Monaco editor theme data object for Markdown editing\n */\nexport function getMarkdownEditorTheme(isDarkTheme: boolean): any {\n const background = getCssColor(\n '--background',\n isDarkTheme ? '#0b1220' : '#ffffff',\n );\n const foreground = getCssColor(\n '--foreground',\n isDarkTheme ? '#e0e6ed' : '#24292f',\n );\n const lineHighlight = getCssColor(\n '--muted',\n isDarkTheme ? '#111a2b' : '#f5f5f5',\n );\n const cursor = getCssColor('--primary', isDarkTheme ? '#ffffff' : '#000000');\n const selection = getCssColor(\n '--accent',\n isDarkTheme ? '#23436b' : '#e3e3e3',\n );\n const lineNumbers = getCssColor(\n '--muted-foreground',\n isDarkTheme ? '#8b97ab' : '#888888',\n );\n\n const heading = getCssColor(\n '--editor-heading',\n isDarkTheme ? '#78AEFF' : '#0550AE',\n );\n const bold = isDarkTheme ? '#E0E6ED' : '#24292F';\n const italic = isDarkTheme ? '#C987E8' : '#8250DF';\n const link = getCssColor(\n '--editor-link',\n isDarkTheme ? '#58A6FF' : '#0969DA',\n );\n const codeInline = isDarkTheme ? '#FFAD85' : '#DB745C';\n const codeContent = isDarkTheme ? '#8BD5CA' : '#2B6F63';\n const codeFence = isDarkTheme ? '#525C6A' : '#A0A8B4';\n const listMarker = isDarkTheme ? '#F0883E' : '#CF5309';\n const quote = isDarkTheme ? '#8b97ab' : '#6E7781';\n const separator = isDarkTheme ? '#3D444D' : '#D0D7DE';\n const htmlTag = isDarkTheme ? '#7CD992' : '#116329';\n\n const fg = (hex: string) => hex.slice(1);\n\n return {\n base: isDarkTheme ? 'vs-dark' : 'vs',\n inherit: true,\n rules: [\n // Headings (# to ######)\n {token: 'keyword.md', foreground: fg(heading), fontStyle: 'bold'},\n {token: 'keyword.table.header.md', foreground: fg(heading)},\n\n // Bold **text**\n {token: 'strong.md', foreground: fg(bold), fontStyle: 'bold'},\n\n // Italic *text*\n {token: 'emphasis.md', foreground: fg(italic), fontStyle: 'italic'},\n\n // Strikethrough ~~text~~\n {token: 'strikethrough.md', fontStyle: 'strikethrough'},\n\n // Links [text](url)\n {token: 'string.link.md', foreground: fg(link)},\n {token: 'type.header.md', foreground: fg(link), fontStyle: 'underline'},\n\n // Inline code `code`\n {token: 'variable.md', foreground: fg(codeInline)},\n\n // Fenced code block fence markers (``` lines)\n {token: 'variable.source.md', foreground: fg(codeFence)},\n\n // Fenced code block content\n {token: 'string.md', foreground: fg(codeContent)},\n\n // List markers (-, *, 1.)\n {token: 'keyword.list.md', foreground: fg(listMarker)},\n\n // Block quotes >\n {token: 'comment.md', foreground: fg(quote), fontStyle: 'italic'},\n {token: 'quote.md', foreground: fg(quote), fontStyle: 'italic'},\n\n // Horizontal rules --- / ***\n {token: 'keyword.hr.md', foreground: fg(separator)},\n\n // HTML tags in markdown\n {token: 'tag.md', foreground: fg(htmlTag)},\n {token: 'tag', foreground: fg(htmlTag)},\n {token: 'attribute.name.md', foreground: fg(heading)},\n {token: 'attribute.value.md', foreground: fg(codeInline)},\n\n // Fallback\n {token: '', foreground: fg(foreground)},\n ],\n colors: {\n 'editor.background': background,\n 'editor.foreground': foreground,\n 'editor.lineHighlightBackground': lineHighlight,\n 'editorCursor.foreground': cursor,\n 'editor.selectionBackground': selection,\n 'editorLineNumber.foreground': lineNumbers,\n ...getMenuColors(isDarkTheme),\n },\n };\n}\n\n/**\n * Generates a Monaco editor theme specifically for JSON editing with Tailwind colors\n * @param isDarkTheme Whether the current theme is dark or light\n * @returns A complete Monaco editor theme data object for JSON editing\n */\nexport function getJsonEditorTheme(isDarkTheme: boolean): any {\n // Get syntax colors from CSS variables with fallbacks\n const property = getCssColor(\n '--editor-property',\n isDarkTheme ? '#78AEFF' : '#4B6BDF',\n );\n const string = getCssColor(\n '--editor-string',\n isDarkTheme ? '#FFAD85' : '#DB745C',\n );\n const number = getCssColor(\n '--editor-number',\n isDarkTheme ? '#7CD992' : '#56A64B',\n );\n const keyword = getCssColor(\n '--editor-keyword',\n isDarkTheme ? '#C987E8' : '#A450B5',\n );\n const punctuation = getCssColor(\n '--editor-punctuation',\n isDarkTheme ? '#A9B1BA' : '#6E7781',\n );\n const comment = getCssColor(\n '--editor-comment',\n isDarkTheme ? '#6A9955' : '#008000',\n );\n const invalid = getCssColor(\n '--editor-invalid',\n isDarkTheme ? '#F44747' : '#CD3131',\n );\n\n // Theme background and UI colors - read from current DOM\n const background = getCssColor(\n '--background',\n isDarkTheme ? '#1E1E1E' : '#FFFFFF',\n );\n const foreground = getCssColor(\n '--foreground',\n isDarkTheme ? '#D4D4D4' : '#000000',\n );\n const selection = getCssColor(\n '--accent',\n isDarkTheme ? '#264F78' : '#ADD6FF',\n );\n const lineHighlight = getCssColor(\n '--muted',\n isDarkTheme ? '#2A2A2A' : '#F5F5F5',\n );\n const lineNumbers = getCssColor(\n '--muted-foreground',\n isDarkTheme ? '#858585' : '#888888',\n );\n const cursor = getCssColor('--primary', isDarkTheme ? '#FFFFFF' : '#000000');\n\n // Menu colors\n const menuBackground = getCssColor(\n '--popover',\n isDarkTheme ? '#1C2233' : '#F3F3F3',\n );\n const menuForeground = getCssColor(\n '--popover-foreground',\n isDarkTheme ? '#FFFFFF' : '#616161',\n );\n const menuSeparator = getCssColor(\n '--border',\n isDarkTheme ? '#39435E' : '#C8C8C8',\n );\n\n return {\n base: isDarkTheme ? 'vs-dark' : 'vs',\n inherit: true,\n rules: [\n // Property keys\n {token: 'type', foreground: property.slice(1)},\n {token: 'string.key.json', foreground: property.slice(1)},\n {token: 'key', foreground: property.slice(1)},\n\n // String values\n {token: 'string.value.json', foreground: string.slice(1)},\n {token: 'string', foreground: string.slice(1)},\n\n // Numbers\n {token: 'number', foreground: number.slice(1)},\n\n // Keywords (true, false, null)\n {token: 'keyword', foreground: keyword.slice(1)},\n\n // Punctuation\n {token: 'delimiter', foreground: punctuation.slice(1)},\n {token: 'bracket', foreground: punctuation.slice(1)},\n\n // Comments\n {token: 'comment', foreground: comment.slice(1)},\n\n // Invalid syntax\n {token: 'invalid', foreground: invalid.slice(1)},\n\n // Fallbacks\n {token: '', foreground: foreground.slice(1)},\n ],\n colors: {\n // Editor colors\n 'editor.background': background,\n 'editor.foreground': foreground,\n 'editor.selectionBackground': selection,\n 'editor.lineHighlightBackground': lineHighlight,\n 'editorLineNumber.foreground': lineNumbers,\n 'editorCursor.foreground': cursor,\n\n // Widget and UI colors\n 'editorWidget.background': menuBackground,\n 'editorWidget.foreground': menuForeground,\n 'editorWidget.border': menuSeparator,\n 'editorSuggestWidget.background': menuBackground,\n 'editorSuggestWidget.foreground': menuForeground,\n 'editorSuggestWidget.border': menuSeparator,\n\n // Menu colors\n 'menu.background': menuBackground,\n 'menu.foreground': menuForeground,\n 'menu.selectionBackground': selection,\n 'menu.selectionForeground': menuForeground,\n 'menu.separatorBackground': menuSeparator,\n\n // Additional UI elements\n 'list.hoverBackground': lineHighlight,\n 'list.activeSelectionBackground': selection,\n 'quickInput.background': menuBackground,\n 'quickInput.foreground': menuForeground,\n },\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sqlrooms/monaco-editor",
|
|
3
|
-
"version": "0.29.0-rc.
|
|
3
|
+
"version": "0.29.0-rc.2",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"types": "dist/index.d.ts",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"repository": {
|
|
12
12
|
"type": "git",
|
|
13
|
-
"url": "https://github.com/sqlrooms/sqlrooms.git"
|
|
13
|
+
"url": "git+https://github.com/sqlrooms/sqlrooms.git"
|
|
14
14
|
},
|
|
15
15
|
"files": [
|
|
16
16
|
"dist"
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@monaco-editor/react": "^4.7.0",
|
|
23
|
-
"@sqlrooms/ui": "0.29.0-rc.
|
|
24
|
-
"
|
|
23
|
+
"@sqlrooms/ui": "0.29.0-rc.2",
|
|
24
|
+
"@sqlrooms/utils": "0.29.0-rc.2",
|
|
25
|
+
"monaco-editor": "^0.55.0"
|
|
25
26
|
},
|
|
26
27
|
"peerDependencies": {
|
|
27
28
|
"react": ">=18",
|
|
@@ -34,5 +35,5 @@
|
|
|
34
35
|
"typecheck": "tsc --noEmit",
|
|
35
36
|
"typedoc": "typedoc"
|
|
36
37
|
},
|
|
37
|
-
"gitHead": "
|
|
38
|
+
"gitHead": "5d511631992c1af8852ea79ced488867aad4a555"
|
|
38
39
|
}
|