@octaviaflow/core 3.0.1 → 3.0.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.
@@ -0,0 +1,589 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/monaco.ts
31
+ var monaco_exports = {};
32
+ __export(monaco_exports, {
33
+ MonacoDiffEditor: () => MonacoDiffEditor,
34
+ MonacoEditor: () => MonacoEditor,
35
+ OCTAVIAFLOW_LIGHT: () => OCTAVIAFLOW_LIGHT,
36
+ OCTAVIAFLOW_THEME_ID: () => OCTAVIAFLOW_THEME_ID
37
+ });
38
+ module.exports = __toCommonJS(monaco_exports);
39
+
40
+ // src/components/MonacoEditor/MonacoEditor.tsx
41
+ var import_react = require("react");
42
+
43
+ // src/utils/cn.ts
44
+ var import_clsx = require("clsx");
45
+ function cn(...inputs) {
46
+ return (0, import_clsx.clsx)(inputs);
47
+ }
48
+
49
+ // src/components/MonacoEditor/octaviaflowTheme.ts
50
+ var OCTAVIAFLOW_LIGHT = {
51
+ base: "vs",
52
+ inherit: true,
53
+ rules: [
54
+ { token: "", foreground: "161616", background: "FFFFFF" },
55
+ { token: "comment", foreground: "6F6F6F", fontStyle: "italic" },
56
+ { token: "string", foreground: "198038" },
57
+ { token: "string.key.json", foreground: "0F62FE" },
58
+ { token: "string.value.json", foreground: "198038" },
59
+ { token: "number", foreground: "0043CE" },
60
+ { token: "keyword", foreground: "8A3FFC" },
61
+ { token: "keyword.sql", foreground: "8A3FFC" },
62
+ { token: "operator", foreground: "393939" },
63
+ { token: "delimiter", foreground: "525252" },
64
+ { token: "type", foreground: "0F62FE" },
65
+ { token: "type.identifier", foreground: "0F62FE" },
66
+ { token: "identifier", foreground: "161616" },
67
+ { token: "constant", foreground: "0043CE" },
68
+ { token: "boolean", foreground: "F1C21B", fontStyle: "bold" },
69
+ { token: "tag", foreground: "DA1E28" },
70
+ { token: "attribute.name", foreground: "8A3FFC" },
71
+ { token: "attribute.value", foreground: "198038" },
72
+ { token: "regexp", foreground: "DA1E28" },
73
+ { token: "function", foreground: "0F62FE" },
74
+ { token: "variable", foreground: "161616" },
75
+ { token: "variable.parameter", foreground: "393939", fontStyle: "italic" },
76
+ { token: "namespace", foreground: "0F62FE" }
77
+ ],
78
+ colors: {
79
+ "editor.background": "#FFFFFF",
80
+ "editor.foreground": "#161616",
81
+ "editor.lineHighlightBackground": "#F4F4F4",
82
+ "editor.lineHighlightBorder": "#00000000",
83
+ "editorLineNumber.foreground": "#A8A8A8",
84
+ "editorLineNumber.activeForeground": "#0F62FE",
85
+ "editorCursor.foreground": "#0F62FE",
86
+ "editor.selectionBackground": "#D0E2FF",
87
+ "editor.selectionHighlightBackground": "#EDF5FF",
88
+ "editor.wordHighlightBackground": "#EDF5FF",
89
+ "editor.wordHighlightStrongBackground": "#D0E2FF",
90
+ "editor.findMatchBackground": "#FFD7D9",
91
+ "editor.findMatchHighlightBackground": "#FFE9EB",
92
+ "editorIndentGuide.background1": "#F4F4F4",
93
+ "editorIndentGuide.activeBackground1": "#E0E0E0",
94
+ "editorWhitespace.foreground": "#E0E0E0",
95
+ "editorBracketMatch.background": "#D0E2FF",
96
+ "editorBracketMatch.border": "#0F62FE",
97
+ "editor.foldBackground": "#F4F4F4",
98
+ "editorGutter.background": "#F4F4F4",
99
+ "editorGutter.modifiedBackground": "#0F62FE",
100
+ "editorGutter.addedBackground": "#198038",
101
+ "editorGutter.deletedBackground": "#DA1E28",
102
+ "editorWidget.background": "#FFFFFF",
103
+ "editorWidget.foreground": "#161616",
104
+ "editorWidget.border": "#E0E0E0",
105
+ "editorSuggestWidget.background": "#FFFFFF",
106
+ "editorSuggestWidget.border": "#E0E0E0",
107
+ "editorSuggestWidget.foreground": "#161616",
108
+ "editorSuggestWidget.selectedBackground": "#EDF5FF",
109
+ "editorSuggestWidget.selectedForeground": "#161616",
110
+ "editorSuggestWidget.highlightForeground": "#0F62FE",
111
+ "editorHoverWidget.background": "#FFFFFF",
112
+ "editorHoverWidget.border": "#E0E0E0",
113
+ "editorError.foreground": "#DA1E28",
114
+ "editorWarning.foreground": "#F1C21B",
115
+ "editorInfo.foreground": "#0F62FE",
116
+ "diffEditor.insertedTextBackground": "#A7F0BA40",
117
+ "diffEditor.removedTextBackground": "#FFB3B840",
118
+ "diffEditor.insertedLineBackground": "#DEFBE640",
119
+ "diffEditor.removedLineBackground": "#FFD7D940",
120
+ "scrollbar.shadow": "#00000000",
121
+ "scrollbarSlider.background": "#0F62FE20",
122
+ "scrollbarSlider.hoverBackground": "#0F62FE40",
123
+ "scrollbarSlider.activeBackground": "#0F62FE60",
124
+ "minimap.background": "#FAFAFA",
125
+ "minimap.selectionHighlight": "#0F62FE",
126
+ "minimapSlider.background": "#0F62FE15",
127
+ "minimapSlider.hoverBackground": "#0F62FE30",
128
+ "minimapSlider.activeBackground": "#0F62FE50",
129
+ "input.background": "#FFFFFF",
130
+ "input.foreground": "#161616",
131
+ "input.border": "#C6C6C6",
132
+ "inputOption.activeBorder": "#0F62FE",
133
+ "focusBorder": "#0F62FE"
134
+ }
135
+ };
136
+ var OCTAVIAFLOW_THEME_ID = "octaviaflow-light";
137
+
138
+ // src/components/MonacoEditor/MonacoEditor.tsx
139
+ var import_jsx_runtime = require("react/jsx-runtime");
140
+ var Editor = (0, import_react.lazy)(
141
+ () => import("@monaco-editor/react").then((mod) => ({ default: mod.Editor }))
142
+ );
143
+ var MARKER_SEVERITY = {
144
+ hint: 1,
145
+ info: 2,
146
+ warning: 4,
147
+ error: 8
148
+ };
149
+ function MonacoEditor({
150
+ value,
151
+ onChange,
152
+ language = "plaintext",
153
+ readOnly = false,
154
+ height = 320,
155
+ minHeight = 120,
156
+ toolbar,
157
+ status,
158
+ hideToolbar = false,
159
+ hideFooter = false,
160
+ showCopy = true,
161
+ showFormat = true,
162
+ showWordWrapToggle = true,
163
+ showMinimapToggle = true,
164
+ wordWrap: wordWrapProp,
165
+ minimap: minimapProp,
166
+ showLineNumbers = true,
167
+ markers,
168
+ options,
169
+ onMount,
170
+ style,
171
+ className,
172
+ ariaLabel = "Code editor",
173
+ theme
174
+ }) {
175
+ const editorRef = (0, import_react.useRef)(null);
176
+ const monacoRef = (0, import_react.useRef)(null);
177
+ const [wordWrap, setWordWrap] = (0, import_react.useState)(wordWrapProp ?? false);
178
+ const [minimap, setMinimap] = (0, import_react.useState)(minimapProp ?? false);
179
+ const [copied, setCopied] = (0, import_react.useState)(false);
180
+ const [cursor, setCursor] = (0, import_react.useState)({ line: 1, column: 1 });
181
+ const [selection, setSelection] = (0, import_react.useState)({ chars: 0, lines: 0 });
182
+ const [lineCount, setLineCount] = (0, import_react.useState)(value.split("\n").length);
183
+ (0, import_react.useEffect)(() => {
184
+ if (wordWrapProp !== void 0) setWordWrap(wordWrapProp);
185
+ }, [wordWrapProp]);
186
+ (0, import_react.useEffect)(() => {
187
+ if (minimapProp !== void 0) setMinimap(minimapProp);
188
+ }, [minimapProp]);
189
+ (0, import_react.useEffect)(() => {
190
+ editorRef.current?.updateOptions({
191
+ wordWrap: wordWrap ? "on" : "off",
192
+ minimap: { enabled: minimap }
193
+ });
194
+ }, [wordWrap, minimap]);
195
+ (0, import_react.useEffect)(() => {
196
+ const editor = editorRef.current;
197
+ const monaco = monacoRef.current;
198
+ if (!editor || !monaco || !markers) return;
199
+ const model = editor.getModel();
200
+ if (!model) return;
201
+ monaco.editor.setModelMarkers(
202
+ model,
203
+ "octaviaflow",
204
+ markers.map((m) => ({
205
+ severity: MARKER_SEVERITY[m.severity ?? "error"],
206
+ message: m.message,
207
+ startLineNumber: m.line,
208
+ startColumn: m.column ?? 1,
209
+ endLineNumber: m.endLine ?? m.line,
210
+ endColumn: m.endColumn ?? (m.column ?? 1) + 1,
211
+ source: m.source
212
+ }))
213
+ );
214
+ }, [markers]);
215
+ const handleMount = (0, import_react.useCallback)(
216
+ (editor, monaco) => {
217
+ editorRef.current = editor;
218
+ monacoRef.current = monaco;
219
+ monaco.editor.defineTheme(OCTAVIAFLOW_THEME_ID, OCTAVIAFLOW_LIGHT);
220
+ monaco.editor.setTheme(theme ?? OCTAVIAFLOW_THEME_ID);
221
+ editor.onDidChangeCursorPosition((e) => {
222
+ setCursor({ line: e.position.lineNumber, column: e.position.column });
223
+ });
224
+ editor.onDidChangeCursorSelection((e) => {
225
+ const sel = e.selection;
226
+ if (sel.isEmpty()) {
227
+ setSelection({ chars: 0, lines: 0 });
228
+ return;
229
+ }
230
+ const model2 = editor.getModel();
231
+ if (!model2) return;
232
+ const text = model2.getValueInRange(sel);
233
+ setSelection({
234
+ chars: text.length,
235
+ lines: text.split("\n").length
236
+ });
237
+ });
238
+ const model = editor.getModel();
239
+ if (model) {
240
+ setLineCount(model.getLineCount());
241
+ model.onDidChangeContent(() => setLineCount(model.getLineCount()));
242
+ }
243
+ onMount?.(editor, monaco);
244
+ },
245
+ [onMount, theme]
246
+ );
247
+ const handleCopy = async () => {
248
+ if (typeof navigator === "undefined") return;
249
+ try {
250
+ await navigator.clipboard.writeText(value);
251
+ setCopied(true);
252
+ setTimeout(() => setCopied(false), 1200);
253
+ } catch {
254
+ }
255
+ };
256
+ const handleFormat = () => {
257
+ editorRef.current?.getAction("editor.action.formatDocument")?.run();
258
+ };
259
+ const mergedOptions = {
260
+ readOnly,
261
+ fontFamily: "ui-monospace, SFMono-Regular, 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace",
262
+ fontSize: 13,
263
+ fontLigatures: true,
264
+ lineHeight: 20,
265
+ lineNumbers: showLineNumbers ? "on" : "off",
266
+ lineNumbersMinChars: 3,
267
+ lineDecorationsWidth: 6,
268
+ folding: true,
269
+ glyphMargin: false,
270
+ minimap: { enabled: minimap },
271
+ wordWrap: wordWrap ? "on" : "off",
272
+ scrollBeyondLastLine: false,
273
+ smoothScrolling: true,
274
+ cursorBlinking: "smooth",
275
+ cursorSmoothCaretAnimation: "on",
276
+ renderLineHighlight: "line",
277
+ padding: { top: 8, bottom: 8 },
278
+ bracketPairColorization: { enabled: true },
279
+ guides: { bracketPairs: true, indentation: true },
280
+ automaticLayout: true,
281
+ tabSize: 2,
282
+ insertSpaces: true,
283
+ scrollbar: {
284
+ verticalScrollbarSize: 8,
285
+ horizontalScrollbarSize: 8,
286
+ useShadows: false
287
+ },
288
+ fixedOverflowWidgets: true,
289
+ contextmenu: true,
290
+ suggestOnTriggerCharacters: true,
291
+ quickSuggestions: { other: true, comments: false, strings: false },
292
+ formatOnPaste: false,
293
+ formatOnType: false,
294
+ "semanticHighlighting.enabled": true,
295
+ ...options
296
+ };
297
+ const showWrapBtn = showWordWrapToggle && wordWrapProp === void 0;
298
+ const showMinimapBtn = showMinimapToggle && minimapProp === void 0;
299
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
300
+ "div",
301
+ {
302
+ className: cn(
303
+ "ods-monaco",
304
+ `ods-monaco--${language}`,
305
+ readOnly && "ods-monaco--readonly",
306
+ className
307
+ ),
308
+ style,
309
+ children: [
310
+ !hideToolbar && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ods-monaco__toolbar", children: [
311
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ods-monaco__toolbar-left", children: [
312
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ods-monaco__lang", children: language.toUpperCase() }),
313
+ toolbar
314
+ ] }),
315
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ods-monaco__toolbar-right", children: [
316
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ods-monaco__lines", children: [
317
+ lineCount,
318
+ " line",
319
+ lineCount === 1 ? "" : "s"
320
+ ] }),
321
+ status && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ods-monaco__status", children: status }),
322
+ showWrapBtn && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
323
+ "button",
324
+ {
325
+ type: "button",
326
+ className: cn("ods-monaco__btn", wordWrap && "ods-monaco__btn--active"),
327
+ onClick: () => setWordWrap((w) => !w),
328
+ "aria-pressed": wordWrap,
329
+ "aria-label": "Toggle word wrap",
330
+ title: "Word wrap",
331
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
332
+ "path",
333
+ {
334
+ d: "M2 3.5h10M2 7h7.5a2 2 0 1 1 0 4H8m0 0 1.5-1.5M8 11l1.5 1.5M2 10.5h3",
335
+ stroke: "currentColor",
336
+ strokeWidth: "1.2",
337
+ strokeLinecap: "round",
338
+ strokeLinejoin: "round"
339
+ }
340
+ ) })
341
+ }
342
+ ),
343
+ showMinimapBtn && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
344
+ "button",
345
+ {
346
+ type: "button",
347
+ className: cn("ods-monaco__btn", minimap && "ods-monaco__btn--active"),
348
+ onClick: () => setMinimap((m) => !m),
349
+ "aria-pressed": minimap,
350
+ "aria-label": "Toggle minimap",
351
+ title: "Minimap",
352
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: [
353
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "2", y: "2.5", width: "6", height: "9", rx: "0.5", stroke: "currentColor", strokeWidth: "1.2" }),
354
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "9", y: "2.5", width: "3", height: "9", rx: "0.5", fill: "currentColor", opacity: "0.25" }),
355
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M3.5 4.5h3M3.5 6.5h3M3.5 8.5h2", stroke: "currentColor", strokeWidth: "1", strokeLinecap: "round" })
356
+ ] })
357
+ }
358
+ ),
359
+ showFormat && !readOnly && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
360
+ "button",
361
+ {
362
+ type: "button",
363
+ className: "ods-monaco__btn",
364
+ onClick: handleFormat,
365
+ "aria-label": "Format document",
366
+ title: "Format (Shift+Alt+F)",
367
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: [
368
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M2.5 4h9M4 7h7.5M5.5 10H11", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" }),
369
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M2.5 7 3.5 6 2.5 5", stroke: "currentColor", strokeWidth: "1.2", strokeLinecap: "round", strokeLinejoin: "round" })
370
+ ] })
371
+ }
372
+ ),
373
+ showCopy && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
374
+ "button",
375
+ {
376
+ type: "button",
377
+ className: cn("ods-monaco__btn", copied && "ods-monaco__btn--success"),
378
+ onClick: handleCopy,
379
+ "aria-label": "Copy",
380
+ title: "Copy",
381
+ children: copied ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
382
+ "path",
383
+ {
384
+ d: "m3 7 3 3 5-6",
385
+ stroke: "currentColor",
386
+ strokeWidth: "1.6",
387
+ strokeLinecap: "round",
388
+ strokeLinejoin: "round"
389
+ }
390
+ ) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: [
391
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("rect", { x: "3", y: "3", width: "8", height: "8", rx: "1", stroke: "currentColor", strokeWidth: "1.3" }),
392
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M5 1.5h6V8", stroke: "currentColor", strokeWidth: "1.3", strokeLinecap: "round" })
393
+ ] })
394
+ }
395
+ )
396
+ ] })
397
+ ] }),
398
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "ods-monaco__body", style: { minHeight }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ods-monaco__loading", children: [
399
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ods-monaco__loading-spin", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "7", cy: "7", r: "5", stroke: "currentColor", strokeWidth: "1.4", strokeDasharray: "4 18", strokeLinecap: "round" }) }) }),
400
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Loading editor\u2026" })
401
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
402
+ Editor,
403
+ {
404
+ value,
405
+ onChange: (v) => onChange?.(v ?? ""),
406
+ language,
407
+ height,
408
+ theme: theme ?? OCTAVIAFLOW_THEME_ID,
409
+ options: mergedOptions,
410
+ onMount: handleMount,
411
+ loading: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ods-monaco__loading", children: [
412
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ods-monaco__loading-spin", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("circle", { cx: "7", cy: "7", r: "5", stroke: "currentColor", strokeWidth: "1.4", strokeDasharray: "4 18", strokeLinecap: "round" }) }) }),
413
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: "Loading editor\u2026" })
414
+ ] }),
415
+ "aria-label": ariaLabel
416
+ }
417
+ ) }) }),
418
+ !hideFooter && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "ods-monaco__footer", children: [
419
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ods-monaco__pos", children: [
420
+ "Ln ",
421
+ cursor.line,
422
+ ", Col ",
423
+ cursor.column,
424
+ selection.chars > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
425
+ " ",
426
+ "\xB7 ",
427
+ selection.chars,
428
+ " char",
429
+ selection.chars === 1 ? "" : "s",
430
+ selection.lines > 1 && ` \xB7 ${selection.lines} lines`
431
+ ] })
432
+ ] }),
433
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { className: "ods-monaco__shortcut-hint", children: [
434
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { className: "ods-monaco__kbd", children: "\u2318F" }),
435
+ " find",
436
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ods-monaco__sep", children: "\xB7" }),
437
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { className: "ods-monaco__kbd", children: "\u2318\u21E7F" }),
438
+ " replace",
439
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "ods-monaco__sep", children: "\xB7" }),
440
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)("kbd", { className: "ods-monaco__kbd", children: "F1" }),
441
+ " commands"
442
+ ] })
443
+ ] })
444
+ ]
445
+ }
446
+ );
447
+ }
448
+
449
+ // src/components/MonacoEditor/MonacoDiffEditor.tsx
450
+ var import_react2 = require("react");
451
+ var import_jsx_runtime2 = require("react/jsx-runtime");
452
+ var DiffEditor = (0, import_react2.lazy)(
453
+ () => import("@monaco-editor/react").then((mod) => ({ default: mod.DiffEditor }))
454
+ );
455
+ function MonacoDiffEditor({
456
+ original,
457
+ modified,
458
+ onModifiedChange,
459
+ language = "plaintext",
460
+ renderSideBySide = true,
461
+ readOnly = false,
462
+ hideUnchangedRegions = false,
463
+ height = 360,
464
+ minHeight = 200,
465
+ originalLabel = "Original",
466
+ modifiedLabel = "Modified",
467
+ toolbar,
468
+ options,
469
+ onMount,
470
+ style,
471
+ className,
472
+ theme,
473
+ hideToolbar = false
474
+ }) {
475
+ const editorRef = (0, import_react2.useRef)(null);
476
+ const [sideBySide, setSideBySide] = (0, import_react2.useState)(renderSideBySide);
477
+ const handleMount = (diffEditor, monaco) => {
478
+ editorRef.current = diffEditor;
479
+ monaco.editor.defineTheme(OCTAVIAFLOW_THEME_ID, OCTAVIAFLOW_LIGHT);
480
+ monaco.editor.setTheme(theme ?? OCTAVIAFLOW_THEME_ID);
481
+ const modifiedEditor = diffEditor.getModifiedEditor();
482
+ modifiedEditor.onDidChangeModelContent(() => {
483
+ onModifiedChange?.(modifiedEditor.getValue());
484
+ });
485
+ onMount?.(diffEditor, monaco);
486
+ };
487
+ const mergedOptions = {
488
+ readOnly,
489
+ originalEditable: false,
490
+ renderSideBySide: sideBySide,
491
+ fontFamily: "ui-monospace, SFMono-Regular, 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace",
492
+ fontSize: 13,
493
+ lineHeight: 20,
494
+ automaticLayout: true,
495
+ lineNumbersMinChars: 3,
496
+ lineDecorationsWidth: 6,
497
+ folding: true,
498
+ glyphMargin: false,
499
+ minimap: { enabled: false },
500
+ scrollBeyondLastLine: false,
501
+ smoothScrolling: true,
502
+ renderOverviewRuler: true,
503
+ diffWordWrap: "off",
504
+ padding: { top: 8, bottom: 8 },
505
+ hideUnchangedRegions: {
506
+ enabled: hideUnchangedRegions,
507
+ revealLineCount: 20,
508
+ minimumLineCount: 3,
509
+ contextLineCount: 3
510
+ },
511
+ scrollbar: {
512
+ verticalScrollbarSize: 8,
513
+ horizontalScrollbarSize: 8,
514
+ useShadows: false
515
+ },
516
+ ...options
517
+ };
518
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
519
+ "div",
520
+ {
521
+ className: cn("ods-monaco-diff", `ods-monaco-diff--${language}`, className),
522
+ style,
523
+ children: [
524
+ !hideToolbar && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ods-monaco__toolbar", children: [
525
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ods-monaco__toolbar-left", children: [
526
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "ods-monaco__lang", children: [
527
+ "DIFF \xB7 ",
528
+ language.toUpperCase()
529
+ ] }),
530
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("span", { className: "ods-monaco-diff__labels", children: [
531
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "ods-monaco-diff__label ods-monaco-diff__label--orig", children: originalLabel }),
532
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "ods-monaco-diff__arrow", "aria-hidden": "true", children: "\u2192" }),
533
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "ods-monaco-diff__label ods-monaco-diff__label--mod", children: modifiedLabel })
534
+ ] }),
535
+ toolbar
536
+ ] }),
537
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ods-monaco__toolbar-right", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
538
+ "button",
539
+ {
540
+ type: "button",
541
+ className: cn(
542
+ "ods-monaco__btn",
543
+ sideBySide && "ods-monaco__btn--active"
544
+ ),
545
+ onClick: () => setSideBySide((s) => !s),
546
+ "aria-pressed": sideBySide,
547
+ "aria-label": "Toggle side-by-side",
548
+ title: sideBySide ? "Inline" : "Side-by-side",
549
+ children: sideBySide ? /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: [
550
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "1.5", y: "2", width: "5", height: "10", rx: "0.5", stroke: "currentColor", strokeWidth: "1.3" }),
551
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "7.5", y: "2", width: "5", height: "10", rx: "0.5", stroke: "currentColor", strokeWidth: "1.3" })
552
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", "aria-hidden": "true", children: [
553
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { x: "1.5", y: "2", width: "11", height: "10", rx: "0.5", stroke: "currentColor", strokeWidth: "1.3" }),
554
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M1.5 7h11", stroke: "currentColor", strokeWidth: "1.3" })
555
+ ] })
556
+ }
557
+ ) })
558
+ ] }),
559
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { className: "ods-monaco__body", style: { minHeight }, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_react2.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ods-monaco__loading", children: [
560
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "ods-monaco__loading-spin", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "7", cy: "7", r: "5", stroke: "currentColor", strokeWidth: "1.4", strokeDasharray: "4 18", strokeLinecap: "round" }) }) }),
561
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Loading diff\u2026" })
562
+ ] }), children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
563
+ DiffEditor,
564
+ {
565
+ original,
566
+ modified,
567
+ language,
568
+ height,
569
+ theme: theme ?? OCTAVIAFLOW_THEME_ID,
570
+ options: mergedOptions,
571
+ onMount: handleMount,
572
+ loading: /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: "ods-monaco__loading", children: [
573
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { className: "ods-monaco__loading-spin", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("circle", { cx: "7", cy: "7", r: "5", stroke: "currentColor", strokeWidth: "1.4", strokeDasharray: "4 18", strokeLinecap: "round" }) }) }),
574
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: "Loading diff\u2026" })
575
+ ] })
576
+ }
577
+ ) }) })
578
+ ]
579
+ }
580
+ );
581
+ }
582
+ // Annotate the CommonJS export names for ESM import in node:
583
+ 0 && (module.exports = {
584
+ MonacoDiffEditor,
585
+ MonacoEditor,
586
+ OCTAVIAFLOW_LIGHT,
587
+ OCTAVIAFLOW_THEME_ID
588
+ });
589
+ //# sourceMappingURL=monaco.cjs.map