@octaviaflow/core 3.1.0-beta.114 → 3.1.0-beta.115
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/dist/chunk-75JAQ4ZG.js +2694 -0
- package/dist/chunk-75JAQ4ZG.js.map +1 -0
- package/dist/chunk-LQVPNIO5.js +6789 -0
- package/dist/chunk-LQVPNIO5.js.map +1 -0
- package/dist/chunk-P46JGJC2.js +5619 -0
- package/dist/chunk-P46JGJC2.js.map +1 -0
- package/dist/chunk-ZALBYWCU.js +1547 -0
- package/dist/chunk-ZALBYWCU.js.map +1 -0
- package/dist/components/Accordion/Accordion.d.ts.map +1 -1
- package/dist/components/AgentAppMark/AgentAppMark.d.ts +28 -0
- package/dist/components/AgentAppMark/AgentAppMark.d.ts.map +1 -0
- package/dist/components/AgentAppMark/index.d.ts +3 -0
- package/dist/components/AgentAppMark/index.d.ts.map +1 -0
- package/dist/components/AgentCard/AgentCard.d.ts.map +1 -1
- package/dist/components/AlertCard/AlertCard.d.ts.map +1 -1
- package/dist/components/AuthCard/AuthCard.d.ts.map +1 -1
- package/dist/components/AuthScreen/AuthScreen.d.ts.map +1 -1
- package/dist/components/Badge/Badge.d.ts.map +1 -1
- package/dist/components/Banner/Banner.d.ts.map +1 -1
- package/dist/components/BarChart/BarChart.d.ts.map +1 -1
- package/dist/components/Calendar/Calendar.d.ts.map +1 -1
- package/dist/components/CalendarHeatmap/CalendarHeatmap.d.ts.map +1 -1
- package/dist/components/CalendarHeatmap/index.d.ts +1 -1
- package/dist/components/CalendarHeatmap/index.d.ts.map +1 -1
- package/dist/components/Callout/Callout.d.ts.map +1 -1
- package/dist/components/Card/Card.d.ts.map +1 -1
- package/dist/components/Catalog/Catalog.d.ts.map +1 -1
- package/dist/components/Catalog/index.d.ts +1 -1
- package/dist/components/Catalog/index.d.ts.map +1 -1
- package/dist/components/ChatAttachment/ChatAttachment.d.ts.map +1 -1
- package/dist/components/ChatAttachment/index.d.ts +1 -1
- package/dist/components/ChatAttachment/index.d.ts.map +1 -1
- package/dist/components/ChatBubble/ChatBubble.d.ts.map +1 -1
- package/dist/components/ChatCodeBlock/ChatCodeBlock.d.ts.map +1 -1
- package/dist/components/ChatDayDivider/ChatDayDivider.d.ts.map +1 -1
- package/dist/components/ChatFeedback/ChatFeedback.d.ts.map +1 -1
- package/dist/components/ChatPanel/ChatPanel.d.ts +1 -1
- package/dist/components/ChatPanel/ChatPanel.d.ts.map +1 -1
- package/dist/components/ChatScrollToBottom/ChatScrollToBottom.d.ts.map +1 -1
- package/dist/components/ChatSources/ChatSources.d.ts.map +1 -1
- package/dist/components/ChatSources/index.d.ts +1 -1
- package/dist/components/ChatSources/index.d.ts.map +1 -1
- package/dist/components/ChatSuggestions/ChatSuggestions.d.ts.map +1 -1
- package/dist/components/ChatSuggestions/index.d.ts +1 -1
- package/dist/components/ChatSuggestions/index.d.ts.map +1 -1
- package/dist/components/ChatThinking/ChatThinking.d.ts.map +1 -1
- package/dist/components/ChatThinking/index.d.ts +1 -1
- package/dist/components/ChatThinking/index.d.ts.map +1 -1
- package/dist/components/ChatThread/ChatThread.d.ts.map +1 -1
- package/dist/components/ChatThread/index.d.ts +1 -1
- package/dist/components/ChatThread/index.d.ts.map +1 -1
- package/dist/components/ChatToolTrace/ChatToolTrace.d.ts.map +1 -1
- package/dist/components/ChatToolTrace/index.d.ts +1 -1
- package/dist/components/ChatToolTrace/index.d.ts.map +1 -1
- package/dist/components/Checkbox/Checkbox.d.ts.map +1 -1
- package/dist/components/Chip/Chip.d.ts.map +1 -1
- package/dist/components/ChoiceCard/ChoiceCard.d.ts.map +1 -1
- package/dist/components/Coachmark/Coachmark.d.ts.map +1 -1
- package/dist/components/CodeEditor/CodeEditor.d.ts +15 -0
- package/dist/components/CodeEditor/CodeEditor.d.ts.map +1 -1
- package/dist/components/ColorPicker/ColorPicker.d.ts.map +1 -1
- package/dist/components/Combobox/Combobox.d.ts.map +1 -1
- package/dist/components/Combobox/index.d.ts +1 -1
- package/dist/components/Combobox/index.d.ts.map +1 -1
- package/dist/components/CommandPalette/CommandPalette.d.ts.map +1 -1
- package/dist/components/ConditionBuilder/ConditionBuilder.d.ts.map +1 -1
- package/dist/components/ConfigPanel/ConfigPanel.d.ts.map +1 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.d.ts.map +1 -1
- package/dist/components/ConnectorCard/ConnectorCard.d.ts.map +1 -1
- package/dist/components/ConnectorCard/index.d.ts +1 -1
- package/dist/components/ConnectorCard/index.d.ts.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.d.ts.map +1 -1
- package/dist/components/CountUp/CountUp.d.ts.map +1 -1
- package/dist/components/CsvViewer/CsvViewer.d.ts.map +1 -1
- package/dist/components/DataMapper/DataMapper.d.ts.map +1 -1
- package/dist/components/DataTable/DataTable.d.ts.map +1 -1
- package/dist/components/DatasetCard/DatasetCard.d.ts.map +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.d.ts.map +1 -1
- package/dist/components/Dialog/Dialog.d.ts.map +1 -1
- package/dist/components/Divider/Divider.d.ts.map +1 -1
- package/dist/components/DonutChart/DonutChart.d.ts.map +1 -1
- package/dist/components/Drawer/Drawer.d.ts.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.d.ts.map +1 -1
- package/dist/components/EmptyState/EmptyState.d.ts.map +1 -1
- package/dist/components/ExecutionConsole/ExecutionConsole.d.ts.map +1 -1
- package/dist/components/ExpressionField/ExpressionField.d.ts +21 -3
- package/dist/components/ExpressionField/ExpressionField.d.ts.map +1 -1
- package/dist/components/ExpressionField/dataRefTokens.d.ts +52 -0
- package/dist/components/ExpressionField/dataRefTokens.d.ts.map +1 -0
- package/dist/components/ExpressionField/index.d.ts +3 -2
- package/dist/components/ExpressionField/index.d.ts.map +1 -1
- package/dist/components/FeatureCard/FeatureCard.d.ts.map +1 -1
- package/dist/components/FieldPicker/FieldPicker.d.ts.map +1 -1
- package/dist/components/FieldPicker/index.d.ts +1 -1
- package/dist/components/FieldPicker/index.d.ts.map +1 -1
- package/dist/components/FileBrowser/FileBrowser.d.ts.map +1 -1
- package/dist/components/FileDropzone/FileDropzone.d.ts.map +1 -1
- package/dist/components/FileList/FileList.d.ts.map +1 -1
- package/dist/components/FilePicker/FilePicker.d.ts +6 -1
- package/dist/components/FilePicker/FilePicker.d.ts.map +1 -1
- package/dist/components/FileViewer/FileViewer.d.ts.map +1 -1
- package/dist/components/FlowMinimap/FlowMinimap.d.ts.map +1 -1
- package/dist/components/Gauge/Gauge.d.ts.map +1 -1
- package/dist/components/Grid/Grid.d.ts.map +1 -1
- package/dist/components/GroupByBuilder/index.d.ts +1 -1
- package/dist/components/GroupByBuilder/index.d.ts.map +1 -1
- package/dist/components/Heatmap/Heatmap.d.ts.map +1 -1
- package/dist/components/IconCard/IconCard.d.ts.map +1 -1
- package/dist/components/InlineMessage/InlineMessage.d.ts.map +1 -1
- package/dist/components/IntegrationCard/IntegrationCard.d.ts.map +1 -1
- package/dist/components/ItemDetail/ItemDetail.d.ts.map +1 -1
- package/dist/components/ItemDetail/index.d.ts +1 -1
- package/dist/components/ItemDetail/index.d.ts.map +1 -1
- package/dist/components/JsonViewer/JsonViewer.d.ts.map +1 -1
- package/dist/components/Kbd/Kbd.d.ts.map +1 -1
- package/dist/components/KeyValueEditor/KeyValueEditor.d.ts +22 -1
- package/dist/components/KeyValueEditor/KeyValueEditor.d.ts.map +1 -1
- package/dist/components/KeyValueEditor/index.d.ts +1 -1
- package/dist/components/KeyValueEditor/index.d.ts.map +1 -1
- package/dist/components/LinkButton/LinkButton.d.ts.map +1 -1
- package/dist/components/MetricCard/MetricCard.d.ts.map +1 -1
- package/dist/components/MonacoEditor/MonacoDiffEditor.d.ts.map +1 -1
- package/dist/components/MonacoEditor/MonacoEditor.d.ts.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.d.ts.map +1 -1
- package/dist/components/NumberInput/NumberInput.d.ts.map +1 -1
- package/dist/components/OnboardingFlow/OnboardingFlow.d.ts.map +1 -1
- package/dist/components/OrgSwitcher/OrgSwitcher.d.ts.map +1 -1
- package/dist/components/PageHeader/PageHeader.d.ts.map +1 -1
- package/dist/components/Pagination/Pagination.d.ts.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.d.ts.map +1 -1
- package/dist/components/PhoneInput/PhoneInput.d.ts.map +1 -1
- package/dist/components/PhoneInput/countries.d.ts.map +1 -1
- package/dist/components/PhoneInput/index.d.ts +1 -1
- package/dist/components/PhoneInput/index.d.ts.map +1 -1
- package/dist/components/PipelineCard/PipelineCard.d.ts +1 -1
- package/dist/components/PipelineCard/PipelineCard.d.ts.map +1 -1
- package/dist/components/PlanCard/PlanCard.d.ts.map +1 -1
- package/dist/components/PlanPicker/PlanPicker.d.ts.map +1 -1
- package/dist/components/PlanPicker/context.d.ts.map +1 -1
- package/dist/components/PresenceBar/PresenceBar.d.ts +11 -0
- package/dist/components/PresenceBar/PresenceBar.d.ts.map +1 -1
- package/dist/components/PricingCard/PricingCard.d.ts.map +1 -1
- package/dist/components/ProductCard/ProductCard.d.ts.map +1 -1
- package/dist/components/ProgressBar/ProgressBar.d.ts.map +1 -1
- package/dist/components/ProgressRing/ProgressRing.d.ts.map +1 -1
- package/dist/components/PromptInput/PromptInput.d.ts.map +1 -1
- package/dist/components/Quote/Quote.d.ts.map +1 -1
- package/dist/components/Radio/Radio.d.ts.map +1 -1
- package/dist/components/Radio/RadioGroup.d.ts.map +1 -1
- package/dist/components/RangeSlider/RangeSlider.d.ts.map +1 -1
- package/dist/components/Rating/BinaryRating.d.ts.map +1 -1
- package/dist/components/Rating/Rating.d.ts.map +1 -1
- package/dist/components/Rating/index.d.ts +1 -1
- package/dist/components/Rating/index.d.ts.map +1 -1
- package/dist/components/Resizable/Resizable.d.ts.map +1 -1
- package/dist/components/Ribbon/Ribbon.d.ts.map +1 -1
- package/dist/components/Sankey/Sankey.d.ts.map +1 -1
- package/dist/components/ScheduleBuilder/ScheduleBuilder.d.ts.map +1 -1
- package/dist/components/ScheduleBuilder/index.d.ts +1 -1
- package/dist/components/ScheduleBuilder/index.d.ts.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.d.ts.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.d.ts.map +1 -1
- package/dist/components/Select/Select.d.ts.map +1 -1
- package/dist/components/Show/Show.d.ts.map +1 -1
- package/dist/components/Skeleton/Skeleton.d.ts.map +1 -1
- package/dist/components/SlideoutPanel/SlideoutPanel.d.ts.map +1 -1
- package/dist/components/Slider/Slider.d.ts.map +1 -1
- package/dist/components/SocialButton/SocialButton.d.ts.map +1 -1
- package/dist/components/SortBuilder/index.d.ts +1 -1
- package/dist/components/SortBuilder/index.d.ts.map +1 -1
- package/dist/components/Sortable/Sortable.d.ts.map +1 -1
- package/dist/components/Sparkline/Sparkline.d.ts.map +1 -1
- package/dist/components/Spinner/Spinner.d.ts.map +1 -1
- package/dist/components/Spotlight/Spotlight.d.ts.map +1 -1
- package/dist/components/Stack/Stack.d.ts.map +1 -1
- package/dist/components/Stat/Stat.d.ts.map +1 -1
- package/dist/components/StatusList/StatusList.d.ts +1 -1
- package/dist/components/StatusList/StatusList.d.ts.map +1 -1
- package/dist/components/StatusList/index.d.ts +1 -1
- package/dist/components/StatusList/index.d.ts.map +1 -1
- package/dist/components/StatusTiles/StatusTiles.d.ts.map +1 -1
- package/dist/components/StatusTiles/index.d.ts +1 -1
- package/dist/components/StatusTiles/index.d.ts.map +1 -1
- package/dist/components/Stepper/Stepper.d.ts.map +1 -1
- package/dist/components/Switch/Switch.d.ts.map +1 -1
- package/dist/components/Table/Table.d.ts.map +1 -1
- package/dist/components/TagsInput/TagsInput.d.ts.map +1 -1
- package/dist/components/Textarea/Textarea.d.ts.map +1 -1
- package/dist/components/TimePicker/TimePicker.d.ts.map +1 -1
- package/dist/components/Timeline/Timeline.d.ts.map +1 -1
- package/dist/components/TimezonePicker/TimezonePicker.d.ts.map +1 -1
- package/dist/components/Toggle/Toggle.d.ts.map +1 -1
- package/dist/components/ToolCard/ToolCard.d.ts.map +1 -1
- package/dist/components/Tooltip/Tooltip.d.ts.map +1 -1
- package/dist/components/TraceStep/TraceStep.d.ts.map +1 -1
- package/dist/components/TreeView/TreeView.d.ts.map +1 -1
- package/dist/components/TreeView/index.d.ts +1 -1
- package/dist/components/TreeView/index.d.ts.map +1 -1
- package/dist/components/UsageMeter/UsageMeter.d.ts.map +1 -1
- package/dist/components/VersionHistory/VersionHistory.d.ts.map +1 -1
- package/dist/components/VersionHistory/index.d.ts +1 -1
- package/dist/components/VersionHistory/index.d.ts.map +1 -1
- package/dist/components/XmlViewer/XmlViewer.d.ts.map +1 -1
- package/dist/components/YamlViewer/YamlViewer.d.ts.map +1 -1
- package/dist/email/emailPalette.d.ts.map +1 -1
- package/dist/email/emailSystem.d.ts +3 -3
- package/dist/email/emailSystem.d.ts.map +1 -1
- package/dist/email/emailTemplates.d.ts +1 -1
- package/dist/email/emailTemplates.d.ts.map +1 -1
- package/dist/hooks/useRating.d.ts.map +1 -1
- package/dist/hooks/useTextareaCommands.d.ts.map +1 -1
- package/dist/hooks/useTextareaSelection.d.ts.map +1 -1
- package/dist/hooks/useTextareaTools.d.ts.map +1 -1
- package/dist/hooks/useTraceTimeline.d.ts.map +1 -1
- package/dist/index.cjs +15999 -17094
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +6 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14076 -16193
- package/dist/index.js.map +1 -1
- package/dist/marketing.cjs +580 -726
- package/dist/marketing.cjs.map +1 -1
- package/dist/marketing.js +2 -2
- package/dist/monaco.cjs +364 -389
- package/dist/monaco.cjs.map +1 -1
- package/dist/monaco.js +381 -410
- package/dist/monaco.js.map +1 -1
- package/dist/notifications/components/NotificationBell/NotificationBell.d.ts.map +1 -1
- package/dist/styles.css +1 -1
- package/dist/utils/Slot.d.ts.map +1 -1
- package/dist/utils/gradients.d.ts.map +1 -1
- package/dist/utils/useAnchoredPopover.d.ts +8 -1
- package/dist/utils/useAnchoredPopover.d.ts.map +1 -1
- package/dist/workflow/components/ConfigPanel/ConfigPanel.d.ts.map +1 -1
- package/dist/workflow/components/FlowNode/FlowNode.d.ts.map +1 -1
- package/dist/workflow/components/FxPanel/DataRefButton.d.ts +1 -1
- package/dist/workflow/components/FxPanel/DataRefButton.d.ts.map +1 -1
- package/dist/workflow/components/FxPanel/FxPanel.d.ts.map +1 -1
- package/dist/workflow/editor.d.ts +22 -0
- package/dist/workflow/editor.d.ts.map +1 -1
- package/dist/workflow/index.d.ts +6 -6
- package/dist/workflow/index.d.ts.map +1 -1
- package/dist/workflow/types.d.ts.map +1 -1
- package/dist/workflow.cjs +10310 -9355
- package/dist/workflow.cjs.map +1 -1
- package/dist/workflow.js +1932 -1963
- package/dist/workflow.js.map +1 -1
- package/package.json +2 -2
package/dist/monaco.js
CHANGED
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
} from "./chunk-ZAUUGK2Y.js";
|
|
4
4
|
|
|
5
5
|
// src/components/MonacoEditor/MonacoDiffEditor.tsx
|
|
6
|
+
import { RenewIcon, SplitIcon, SquareOutlineIcon } from "@octaviaflow/icons";
|
|
6
7
|
import {
|
|
7
8
|
forwardRef,
|
|
8
9
|
lazy,
|
|
@@ -11,11 +12,6 @@ import {
|
|
|
11
12
|
useRef,
|
|
12
13
|
useState
|
|
13
14
|
} from "react";
|
|
14
|
-
import {
|
|
15
|
-
RenewIcon,
|
|
16
|
-
SplitIcon,
|
|
17
|
-
SquareOutlineIcon
|
|
18
|
-
} from "@octaviaflow/icons";
|
|
19
15
|
|
|
20
16
|
// src/components/MonacoEditor/octaviaflowTheme.ts
|
|
21
17
|
var OCTAVIAFLOW_LIGHT = {
|
|
@@ -117,468 +113,443 @@ function LoadingPlaceholder() {
|
|
|
117
113
|
/* @__PURE__ */ jsx("span", { children: "Loading diff\u2026" })
|
|
118
114
|
] });
|
|
119
115
|
}
|
|
120
|
-
var MonacoDiffEditor = forwardRef(
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
var MonacoDiffEditor = forwardRef(
|
|
117
|
+
function MonacoDiffEditor2({
|
|
118
|
+
original,
|
|
119
|
+
modified,
|
|
120
|
+
onModifiedChange,
|
|
121
|
+
language = "plaintext",
|
|
122
|
+
renderSideBySide = true,
|
|
123
|
+
readOnly = false,
|
|
124
|
+
hideUnchangedRegions = false,
|
|
125
|
+
height = 360,
|
|
126
|
+
minHeight = 200,
|
|
127
|
+
originalLabel = "Original",
|
|
128
|
+
modifiedLabel = "Modified",
|
|
129
|
+
toolbar,
|
|
130
|
+
options,
|
|
131
|
+
onMount,
|
|
132
|
+
className,
|
|
133
|
+
theme,
|
|
134
|
+
hideToolbar = false,
|
|
135
|
+
...rest
|
|
136
|
+
}, ref) {
|
|
137
|
+
const editorRef = useRef(null);
|
|
138
|
+
const monacoRef = useRef(null);
|
|
139
|
+
const [sideBySide, setSideBySide] = useState(renderSideBySide);
|
|
140
|
+
useImperativeHandle(
|
|
141
|
+
ref,
|
|
142
|
+
() => ({
|
|
143
|
+
focus: () => editorRef.current?.getModifiedEditor().focus(),
|
|
144
|
+
getDiffEditor: () => editorRef.current,
|
|
145
|
+
getMonaco: () => monacoRef.current,
|
|
146
|
+
getOriginalValue: () => editorRef.current?.getOriginalEditor().getValue() ?? "",
|
|
147
|
+
getModifiedValue: () => editorRef.current?.getModifiedEditor().getValue() ?? "",
|
|
148
|
+
setModifiedValue: (v) => editorRef.current?.getModifiedEditor().setValue(v)
|
|
149
|
+
}),
|
|
150
|
+
[]
|
|
151
|
+
);
|
|
152
|
+
const handleMount = (diffEditor, monaco) => {
|
|
153
|
+
editorRef.current = diffEditor;
|
|
154
|
+
monacoRef.current = monaco;
|
|
155
|
+
monaco.editor.defineTheme(OCTAVIAFLOW_THEME_ID, OCTAVIAFLOW_LIGHT);
|
|
156
|
+
monaco.editor.setTheme(theme ?? OCTAVIAFLOW_THEME_ID);
|
|
157
|
+
const modifiedEditor = diffEditor.getModifiedEditor();
|
|
158
|
+
modifiedEditor.onDidChangeModelContent(() => {
|
|
159
|
+
onModifiedChange?.(modifiedEditor.getValue());
|
|
160
|
+
});
|
|
161
|
+
onMount?.(diffEditor, monaco);
|
|
162
|
+
};
|
|
163
|
+
const mergedOptions = {
|
|
164
|
+
readOnly,
|
|
165
|
+
originalEditable: false,
|
|
166
|
+
renderSideBySide: sideBySide,
|
|
167
|
+
fontFamily: "ui-monospace, SFMono-Regular, 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace",
|
|
168
|
+
fontSize: 13,
|
|
169
|
+
lineHeight: 20,
|
|
170
|
+
automaticLayout: true,
|
|
171
|
+
lineNumbersMinChars: 3,
|
|
172
|
+
lineDecorationsWidth: 6,
|
|
173
|
+
folding: true,
|
|
174
|
+
glyphMargin: false,
|
|
175
|
+
minimap: { enabled: false },
|
|
176
|
+
scrollBeyondLastLine: false,
|
|
177
|
+
smoothScrolling: true,
|
|
178
|
+
renderOverviewRuler: true,
|
|
179
|
+
diffWordWrap: "off",
|
|
180
|
+
padding: { top: 8, bottom: 8 },
|
|
181
|
+
hideUnchangedRegions: {
|
|
182
|
+
enabled: hideUnchangedRegions,
|
|
183
|
+
revealLineCount: 20,
|
|
184
|
+
minimumLineCount: 3,
|
|
185
|
+
contextLineCount: 3
|
|
186
|
+
},
|
|
187
|
+
scrollbar: {
|
|
188
|
+
verticalScrollbarSize: 8,
|
|
189
|
+
horizontalScrollbarSize: 8,
|
|
190
|
+
useShadows: false
|
|
191
|
+
},
|
|
192
|
+
...options
|
|
193
|
+
};
|
|
194
|
+
return /* @__PURE__ */ jsxs("div", { ...rest, className: cn("ods-monaco-diff", `ods-monaco-diff--${language}`, className), children: [
|
|
195
|
+
!hideToolbar && /* @__PURE__ */ jsxs("div", { className: "ods-monaco__toolbar", children: [
|
|
196
|
+
/* @__PURE__ */ jsxs("div", { className: "ods-monaco__toolbar-left", children: [
|
|
197
|
+
/* @__PURE__ */ jsxs("span", { className: "ods-monaco__lang", children: [
|
|
198
|
+
"DIFF \xB7 ",
|
|
199
|
+
language.toUpperCase()
|
|
200
|
+
] }),
|
|
201
|
+
/* @__PURE__ */ jsxs("span", { className: "ods-monaco-diff__labels", children: [
|
|
202
|
+
/* @__PURE__ */ jsx("span", { className: "ods-monaco-diff__label ods-monaco-diff__label--orig", children: originalLabel }),
|
|
203
|
+
/* @__PURE__ */ jsx("span", { className: "ods-monaco-diff__arrow", "aria-hidden": "true", children: "\u2192" }),
|
|
204
|
+
/* @__PURE__ */ jsx("span", { className: "ods-monaco-diff__label ods-monaco-diff__label--mod", children: modifiedLabel })
|
|
205
|
+
] }),
|
|
206
|
+
toolbar
|
|
207
|
+
] }),
|
|
208
|
+
/* @__PURE__ */ jsx("div", { className: "ods-monaco__toolbar-right", children: /* @__PURE__ */ jsx(
|
|
209
|
+
"button",
|
|
210
|
+
{
|
|
211
|
+
type: "button",
|
|
212
|
+
className: cn("ods-monaco__btn", sideBySide && "ods-monaco__btn--active"),
|
|
213
|
+
onClick: () => setSideBySide((s) => !s),
|
|
214
|
+
"aria-pressed": sideBySide,
|
|
215
|
+
"aria-label": sideBySide ? "Switch to inline diff" : "Switch to side-by-side",
|
|
216
|
+
title: sideBySide ? "Inline" : "Side-by-side",
|
|
217
|
+
children: sideBySide ? /* @__PURE__ */ jsx(SplitIcon, {}) : /* @__PURE__ */ jsx(SquareOutlineIcon, {})
|
|
218
|
+
}
|
|
219
|
+
) })
|
|
220
|
+
] }),
|
|
221
|
+
/* @__PURE__ */ jsx("div", { className: "ods-monaco__body", style: { minHeight }, children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(LoadingPlaceholder, {}), children: /* @__PURE__ */ jsx(
|
|
222
|
+
DiffEditor,
|
|
223
|
+
{
|
|
224
|
+
original,
|
|
225
|
+
modified,
|
|
226
|
+
language,
|
|
227
|
+
height,
|
|
228
|
+
theme: theme ?? OCTAVIAFLOW_THEME_ID,
|
|
229
|
+
options: mergedOptions,
|
|
230
|
+
onMount: handleMount,
|
|
231
|
+
loading: /* @__PURE__ */ jsx(LoadingPlaceholder, {})
|
|
232
|
+
}
|
|
233
|
+
) }) })
|
|
234
|
+
] });
|
|
235
|
+
}
|
|
236
|
+
);
|
|
237
|
+
MonacoDiffEditor.displayName = "MonacoDiffEditor";
|
|
238
|
+
|
|
239
|
+
// src/components/MonacoEditor/MonacoEditor.tsx
|
|
240
|
+
import {
|
|
241
|
+
CheckmarkIcon,
|
|
242
|
+
CopyIcon,
|
|
243
|
+
MagicWandIcon,
|
|
244
|
+
MinimapOffIcon,
|
|
245
|
+
MinimapOnIcon,
|
|
246
|
+
RenewIcon as RenewIcon2,
|
|
247
|
+
TextWrapIcon
|
|
248
|
+
} from "@octaviaflow/icons";
|
|
249
|
+
import {
|
|
250
|
+
forwardRef as forwardRef2,
|
|
251
|
+
lazy as lazy2,
|
|
252
|
+
Suspense as Suspense2,
|
|
253
|
+
useCallback,
|
|
254
|
+
useEffect,
|
|
255
|
+
useImperativeHandle as useImperativeHandle2,
|
|
256
|
+
useRef as useRef2,
|
|
257
|
+
useState as useState2
|
|
258
|
+
} from "react";
|
|
259
|
+
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
260
|
+
var Editor = lazy2(() => import("@monaco-editor/react").then((mod) => ({ default: mod.Editor })));
|
|
261
|
+
var MARKER_SEVERITY = {
|
|
262
|
+
hint: 1,
|
|
263
|
+
info: 2,
|
|
264
|
+
warning: 4,
|
|
265
|
+
error: 8
|
|
266
|
+
};
|
|
267
|
+
function LoadingPlaceholder2({ label }) {
|
|
268
|
+
return /* @__PURE__ */ jsxs2("div", { className: "ods-monaco__loading", children: [
|
|
269
|
+
/* @__PURE__ */ jsx2("span", { className: "ods-monaco__loading-spin", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(RenewIcon2, {}) }),
|
|
270
|
+
/* @__PURE__ */ jsx2("span", { children: label })
|
|
271
|
+
] });
|
|
272
|
+
}
|
|
273
|
+
var MonacoEditor = forwardRef2(function MonacoEditor2({
|
|
274
|
+
value,
|
|
275
|
+
onChange,
|
|
124
276
|
language = "plaintext",
|
|
125
|
-
renderSideBySide = true,
|
|
126
277
|
readOnly = false,
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
minHeight = 200,
|
|
130
|
-
originalLabel = "Original",
|
|
131
|
-
modifiedLabel = "Modified",
|
|
278
|
+
height = 320,
|
|
279
|
+
minHeight = 120,
|
|
132
280
|
toolbar,
|
|
281
|
+
status,
|
|
282
|
+
hideToolbar = false,
|
|
283
|
+
hideFooter = false,
|
|
284
|
+
showCopy = true,
|
|
285
|
+
showFormat = true,
|
|
286
|
+
showWordWrapToggle = true,
|
|
287
|
+
showMinimapToggle = true,
|
|
288
|
+
wordWrap: wordWrapProp,
|
|
289
|
+
minimap: minimapProp,
|
|
290
|
+
showLineNumbers = true,
|
|
291
|
+
markers,
|
|
133
292
|
options,
|
|
134
293
|
onMount,
|
|
294
|
+
onCopy,
|
|
295
|
+
copySuccessTimeoutMs = 1200,
|
|
135
296
|
className,
|
|
297
|
+
ariaLabel = "Code editor",
|
|
136
298
|
theme,
|
|
137
|
-
hideToolbar = false,
|
|
138
299
|
...rest
|
|
139
300
|
}, ref) {
|
|
140
|
-
const editorRef =
|
|
141
|
-
const monacoRef =
|
|
142
|
-
const [
|
|
143
|
-
|
|
301
|
+
const editorRef = useRef2(null);
|
|
302
|
+
const monacoRef = useRef2(null);
|
|
303
|
+
const [wordWrap, setWordWrap] = useState2(wordWrapProp ?? false);
|
|
304
|
+
const [minimap, setMinimap] = useState2(minimapProp ?? false);
|
|
305
|
+
const [copied, setCopied] = useState2(false);
|
|
306
|
+
const [cursor, setCursor] = useState2({ line: 1, column: 1 });
|
|
307
|
+
const [selection, setSelection] = useState2({ chars: 0, lines: 0 });
|
|
308
|
+
const [lineCount, setLineCount] = useState2(value.split("\n").length);
|
|
309
|
+
useImperativeHandle2(
|
|
144
310
|
ref,
|
|
145
311
|
() => ({
|
|
146
|
-
focus: () => editorRef.current?.
|
|
147
|
-
|
|
312
|
+
focus: () => editorRef.current?.focus(),
|
|
313
|
+
getEditor: () => editorRef.current,
|
|
148
314
|
getMonaco: () => monacoRef.current,
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
315
|
+
getValue: () => editorRef.current?.getValue() ?? "",
|
|
316
|
+
setValue: (v) => editorRef.current?.setValue(v),
|
|
317
|
+
format: () => editorRef.current?.getAction("editor.action.formatDocument")?.run()
|
|
152
318
|
}),
|
|
153
319
|
[]
|
|
154
320
|
);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
321
|
+
useEffect(() => {
|
|
322
|
+
if (wordWrapProp !== void 0) setWordWrap(wordWrapProp);
|
|
323
|
+
}, [wordWrapProp]);
|
|
324
|
+
useEffect(() => {
|
|
325
|
+
if (minimapProp !== void 0) setMinimap(minimapProp);
|
|
326
|
+
}, [minimapProp]);
|
|
327
|
+
useEffect(() => {
|
|
328
|
+
editorRef.current?.updateOptions({
|
|
329
|
+
wordWrap: wordWrap ? "on" : "off",
|
|
330
|
+
minimap: { enabled: minimap }
|
|
163
331
|
});
|
|
164
|
-
|
|
332
|
+
}, [wordWrap, minimap]);
|
|
333
|
+
useEffect(() => {
|
|
334
|
+
const ed = editorRef.current;
|
|
335
|
+
const monaco = monacoRef.current;
|
|
336
|
+
if (!ed || !monaco || !markers) return;
|
|
337
|
+
const model = ed.getModel();
|
|
338
|
+
if (!model) return;
|
|
339
|
+
monaco.editor.setModelMarkers(
|
|
340
|
+
model,
|
|
341
|
+
"octaviaflow",
|
|
342
|
+
markers.map((m) => ({
|
|
343
|
+
severity: MARKER_SEVERITY[m.severity ?? "error"],
|
|
344
|
+
message: m.message,
|
|
345
|
+
startLineNumber: m.line,
|
|
346
|
+
startColumn: m.column ?? 1,
|
|
347
|
+
endLineNumber: m.endLine ?? m.line,
|
|
348
|
+
endColumn: m.endColumn ?? (m.column ?? 1) + 1,
|
|
349
|
+
source: m.source
|
|
350
|
+
}))
|
|
351
|
+
);
|
|
352
|
+
}, [markers]);
|
|
353
|
+
const handleMount = useCallback(
|
|
354
|
+
(ed, monaco) => {
|
|
355
|
+
editorRef.current = ed;
|
|
356
|
+
monacoRef.current = monaco;
|
|
357
|
+
monaco.editor.defineTheme(OCTAVIAFLOW_THEME_ID, OCTAVIAFLOW_LIGHT);
|
|
358
|
+
monaco.editor.setTheme(theme ?? OCTAVIAFLOW_THEME_ID);
|
|
359
|
+
ed.onDidChangeCursorPosition((e) => {
|
|
360
|
+
setCursor({ line: e.position.lineNumber, column: e.position.column });
|
|
361
|
+
});
|
|
362
|
+
ed.onDidChangeCursorSelection((e) => {
|
|
363
|
+
const sel = e.selection;
|
|
364
|
+
if (sel.isEmpty()) {
|
|
365
|
+
setSelection({ chars: 0, lines: 0 });
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
const model2 = ed.getModel();
|
|
369
|
+
if (!model2) return;
|
|
370
|
+
const text = model2.getValueInRange(sel);
|
|
371
|
+
setSelection({
|
|
372
|
+
chars: text.length,
|
|
373
|
+
lines: text.split("\n").length
|
|
374
|
+
});
|
|
375
|
+
});
|
|
376
|
+
const model = ed.getModel();
|
|
377
|
+
if (model) {
|
|
378
|
+
setLineCount(model.getLineCount());
|
|
379
|
+
model.onDidChangeContent(() => setLineCount(model.getLineCount()));
|
|
380
|
+
}
|
|
381
|
+
onMount?.(ed, monaco);
|
|
382
|
+
},
|
|
383
|
+
[onMount, theme]
|
|
384
|
+
);
|
|
385
|
+
const handleCopy = async () => {
|
|
386
|
+
if (typeof navigator === "undefined") return;
|
|
387
|
+
try {
|
|
388
|
+
await navigator.clipboard.writeText(value);
|
|
389
|
+
setCopied(true);
|
|
390
|
+
onCopy?.(value);
|
|
391
|
+
setTimeout(() => setCopied(false), copySuccessTimeoutMs);
|
|
392
|
+
} catch {
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
const handleFormat = () => {
|
|
396
|
+
editorRef.current?.getAction("editor.action.formatDocument")?.run();
|
|
165
397
|
};
|
|
166
398
|
const mergedOptions = {
|
|
167
399
|
readOnly,
|
|
168
|
-
originalEditable: false,
|
|
169
|
-
renderSideBySide: sideBySide,
|
|
170
400
|
fontFamily: "ui-monospace, SFMono-Regular, 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace",
|
|
171
401
|
fontSize: 13,
|
|
402
|
+
fontLigatures: true,
|
|
172
403
|
lineHeight: 20,
|
|
173
|
-
|
|
404
|
+
lineNumbers: showLineNumbers ? "on" : "off",
|
|
174
405
|
lineNumbersMinChars: 3,
|
|
175
406
|
lineDecorationsWidth: 6,
|
|
176
407
|
folding: true,
|
|
177
408
|
glyphMargin: false,
|
|
178
|
-
minimap: { enabled:
|
|
409
|
+
minimap: { enabled: minimap },
|
|
410
|
+
wordWrap: wordWrap ? "on" : "off",
|
|
179
411
|
scrollBeyondLastLine: false,
|
|
180
412
|
smoothScrolling: true,
|
|
181
|
-
|
|
182
|
-
|
|
413
|
+
cursorBlinking: "smooth",
|
|
414
|
+
cursorSmoothCaretAnimation: "on",
|
|
415
|
+
renderLineHighlight: "line",
|
|
183
416
|
padding: { top: 8, bottom: 8 },
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
},
|
|
417
|
+
bracketPairColorization: { enabled: true },
|
|
418
|
+
guides: { bracketPairs: true, indentation: true },
|
|
419
|
+
automaticLayout: true,
|
|
420
|
+
tabSize: 2,
|
|
421
|
+
insertSpaces: true,
|
|
190
422
|
scrollbar: {
|
|
191
423
|
verticalScrollbarSize: 8,
|
|
192
424
|
horizontalScrollbarSize: 8,
|
|
193
425
|
useShadows: false
|
|
194
426
|
},
|
|
427
|
+
fixedOverflowWidgets: true,
|
|
428
|
+
contextmenu: true,
|
|
429
|
+
suggestOnTriggerCharacters: true,
|
|
430
|
+
quickSuggestions: { other: true, comments: false, strings: false },
|
|
431
|
+
formatOnPaste: false,
|
|
432
|
+
formatOnType: false,
|
|
433
|
+
"semanticHighlighting.enabled": true,
|
|
195
434
|
...options
|
|
196
435
|
};
|
|
197
|
-
|
|
436
|
+
const showWrapBtn = showWordWrapToggle && wordWrapProp === void 0;
|
|
437
|
+
const showMinimapBtn = showMinimapToggle && minimapProp === void 0;
|
|
438
|
+
return /* @__PURE__ */ jsxs2(
|
|
198
439
|
"div",
|
|
199
440
|
{
|
|
200
441
|
...rest,
|
|
201
442
|
className: cn(
|
|
202
|
-
"ods-monaco
|
|
203
|
-
`ods-monaco
|
|
443
|
+
"ods-monaco",
|
|
444
|
+
`ods-monaco--${language}`,
|
|
445
|
+
readOnly && "ods-monaco--readonly",
|
|
204
446
|
className
|
|
205
447
|
),
|
|
206
448
|
children: [
|
|
207
|
-
!hideToolbar && /* @__PURE__ */
|
|
208
|
-
/* @__PURE__ */
|
|
209
|
-
/* @__PURE__ */
|
|
210
|
-
"DIFF \xB7 ",
|
|
211
|
-
language.toUpperCase()
|
|
212
|
-
] }),
|
|
213
|
-
/* @__PURE__ */ jsxs("span", { className: "ods-monaco-diff__labels", children: [
|
|
214
|
-
/* @__PURE__ */ jsx("span", { className: "ods-monaco-diff__label ods-monaco-diff__label--orig", children: originalLabel }),
|
|
215
|
-
/* @__PURE__ */ jsx("span", { className: "ods-monaco-diff__arrow", "aria-hidden": "true", children: "\u2192" }),
|
|
216
|
-
/* @__PURE__ */ jsx("span", { className: "ods-monaco-diff__label ods-monaco-diff__label--mod", children: modifiedLabel })
|
|
217
|
-
] }),
|
|
449
|
+
!hideToolbar && /* @__PURE__ */ jsxs2("div", { className: "ods-monaco__toolbar", children: [
|
|
450
|
+
/* @__PURE__ */ jsxs2("div", { className: "ods-monaco__toolbar-left", children: [
|
|
451
|
+
/* @__PURE__ */ jsx2("span", { className: "ods-monaco__lang", children: language.toUpperCase() }),
|
|
218
452
|
toolbar
|
|
219
453
|
] }),
|
|
220
|
-
/* @__PURE__ */
|
|
221
|
-
"
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
454
|
+
/* @__PURE__ */ jsxs2("div", { className: "ods-monaco__toolbar-right", children: [
|
|
455
|
+
/* @__PURE__ */ jsxs2("span", { className: "ods-monaco__lines", children: [
|
|
456
|
+
lineCount,
|
|
457
|
+
" line",
|
|
458
|
+
lineCount === 1 ? "" : "s"
|
|
459
|
+
] }),
|
|
460
|
+
status && /* @__PURE__ */ jsx2("span", { className: "ods-monaco__status", children: status }),
|
|
461
|
+
showWrapBtn && /* @__PURE__ */ jsx2(
|
|
462
|
+
"button",
|
|
463
|
+
{
|
|
464
|
+
type: "button",
|
|
465
|
+
className: cn("ods-monaco__btn", wordWrap && "ods-monaco__btn--active"),
|
|
466
|
+
onClick: () => setWordWrap((w) => !w),
|
|
467
|
+
"aria-pressed": wordWrap,
|
|
468
|
+
"aria-label": "Toggle word wrap",
|
|
469
|
+
title: "Word wrap",
|
|
470
|
+
children: /* @__PURE__ */ jsx2(TextWrapIcon, {})
|
|
471
|
+
}
|
|
472
|
+
),
|
|
473
|
+
showMinimapBtn && /* @__PURE__ */ jsx2(
|
|
474
|
+
"button",
|
|
475
|
+
{
|
|
476
|
+
type: "button",
|
|
477
|
+
className: cn("ods-monaco__btn", minimap && "ods-monaco__btn--active"),
|
|
478
|
+
onClick: () => setMinimap((m) => !m),
|
|
479
|
+
"aria-pressed": minimap,
|
|
480
|
+
"aria-label": "Toggle minimap",
|
|
481
|
+
title: "Minimap",
|
|
482
|
+
children: minimap ? /* @__PURE__ */ jsx2(MinimapOnIcon, {}) : /* @__PURE__ */ jsx2(MinimapOffIcon, {})
|
|
483
|
+
}
|
|
484
|
+
),
|
|
485
|
+
showFormat && !readOnly && /* @__PURE__ */ jsx2(
|
|
486
|
+
"button",
|
|
487
|
+
{
|
|
488
|
+
type: "button",
|
|
489
|
+
className: "ods-monaco__btn",
|
|
490
|
+
onClick: handleFormat,
|
|
491
|
+
"aria-label": "Format document",
|
|
492
|
+
title: "Format (Shift+Alt+F)",
|
|
493
|
+
children: /* @__PURE__ */ jsx2(MagicWandIcon, {})
|
|
494
|
+
}
|
|
495
|
+
),
|
|
496
|
+
showCopy && /* @__PURE__ */ jsx2(
|
|
497
|
+
"button",
|
|
498
|
+
{
|
|
499
|
+
type: "button",
|
|
500
|
+
className: cn("ods-monaco__btn", copied && "ods-monaco__btn--success"),
|
|
501
|
+
onClick: handleCopy,
|
|
502
|
+
"aria-label": copied ? "Copied" : "Copy",
|
|
503
|
+
title: copied ? "Copied" : "Copy",
|
|
504
|
+
children: copied ? /* @__PURE__ */ jsx2(CheckmarkIcon, {}) : /* @__PURE__ */ jsx2(CopyIcon, {})
|
|
505
|
+
}
|
|
506
|
+
)
|
|
507
|
+
] })
|
|
235
508
|
] }),
|
|
236
|
-
/* @__PURE__ */
|
|
237
|
-
|
|
509
|
+
/* @__PURE__ */ jsx2("div", { className: "ods-monaco__body", style: { minHeight }, children: /* @__PURE__ */ jsx2(Suspense2, { fallback: /* @__PURE__ */ jsx2(LoadingPlaceholder2, { label: "Loading editor\u2026" }), children: /* @__PURE__ */ jsx2(
|
|
510
|
+
Editor,
|
|
238
511
|
{
|
|
239
|
-
|
|
240
|
-
|
|
512
|
+
value,
|
|
513
|
+
onChange: (v) => onChange?.(v ?? ""),
|
|
241
514
|
language,
|
|
242
515
|
height,
|
|
243
516
|
theme: theme ?? OCTAVIAFLOW_THEME_ID,
|
|
244
517
|
options: mergedOptions,
|
|
245
518
|
onMount: handleMount,
|
|
246
|
-
loading: /* @__PURE__ */
|
|
519
|
+
loading: /* @__PURE__ */ jsx2(LoadingPlaceholder2, { label: "Loading editor\u2026" }),
|
|
520
|
+
"aria-label": ariaLabel
|
|
247
521
|
}
|
|
248
|
-
) }) })
|
|
522
|
+
) }) }),
|
|
523
|
+
!hideFooter && /* @__PURE__ */ jsxs2("div", { className: "ods-monaco__footer", children: [
|
|
524
|
+
/* @__PURE__ */ jsxs2("span", { className: "ods-monaco__pos", children: [
|
|
525
|
+
"Ln ",
|
|
526
|
+
cursor.line,
|
|
527
|
+
", Col ",
|
|
528
|
+
cursor.column,
|
|
529
|
+
selection.chars > 0 && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
530
|
+
" ",
|
|
531
|
+
"\xB7 ",
|
|
532
|
+
selection.chars,
|
|
533
|
+
" char",
|
|
534
|
+
selection.chars === 1 ? "" : "s",
|
|
535
|
+
selection.lines > 1 && ` \xB7 ${selection.lines} lines`
|
|
536
|
+
] })
|
|
537
|
+
] }),
|
|
538
|
+
/* @__PURE__ */ jsxs2("span", { className: "ods-monaco__shortcut-hint", children: [
|
|
539
|
+
/* @__PURE__ */ jsx2("kbd", { className: "ods-monaco__kbd", children: "\u2318F" }),
|
|
540
|
+
" find",
|
|
541
|
+
/* @__PURE__ */ jsx2("span", { className: "ods-monaco__sep", children: "\xB7" }),
|
|
542
|
+
/* @__PURE__ */ jsx2("kbd", { className: "ods-monaco__kbd", children: "\u2318\u21E7F" }),
|
|
543
|
+
" replace",
|
|
544
|
+
/* @__PURE__ */ jsx2("span", { className: "ods-monaco__sep", children: "\xB7" }),
|
|
545
|
+
/* @__PURE__ */ jsx2("kbd", { className: "ods-monaco__kbd", children: "F1" }),
|
|
546
|
+
" commands"
|
|
547
|
+
] })
|
|
548
|
+
] })
|
|
249
549
|
]
|
|
250
550
|
}
|
|
251
551
|
);
|
|
252
552
|
});
|
|
253
|
-
MonacoDiffEditor.displayName = "MonacoDiffEditor";
|
|
254
|
-
|
|
255
|
-
// src/components/MonacoEditor/MonacoEditor.tsx
|
|
256
|
-
import {
|
|
257
|
-
forwardRef as forwardRef2,
|
|
258
|
-
lazy as lazy2,
|
|
259
|
-
Suspense as Suspense2,
|
|
260
|
-
useCallback,
|
|
261
|
-
useEffect,
|
|
262
|
-
useImperativeHandle as useImperativeHandle2,
|
|
263
|
-
useRef as useRef2,
|
|
264
|
-
useState as useState2
|
|
265
|
-
} from "react";
|
|
266
|
-
import {
|
|
267
|
-
CheckmarkIcon,
|
|
268
|
-
CopyIcon,
|
|
269
|
-
MagicWandIcon,
|
|
270
|
-
MinimapOffIcon,
|
|
271
|
-
MinimapOnIcon,
|
|
272
|
-
RenewIcon as RenewIcon2,
|
|
273
|
-
TextWrapIcon
|
|
274
|
-
} from "@octaviaflow/icons";
|
|
275
|
-
import { Fragment, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
276
|
-
var Editor = lazy2(
|
|
277
|
-
() => import("@monaco-editor/react").then((mod) => ({ default: mod.Editor }))
|
|
278
|
-
);
|
|
279
|
-
var MARKER_SEVERITY = {
|
|
280
|
-
hint: 1,
|
|
281
|
-
info: 2,
|
|
282
|
-
warning: 4,
|
|
283
|
-
error: 8
|
|
284
|
-
};
|
|
285
|
-
function LoadingPlaceholder2({ label }) {
|
|
286
|
-
return /* @__PURE__ */ jsxs2("div", { className: "ods-monaco__loading", children: [
|
|
287
|
-
/* @__PURE__ */ jsx2("span", { className: "ods-monaco__loading-spin", "aria-hidden": "true", children: /* @__PURE__ */ jsx2(RenewIcon2, {}) }),
|
|
288
|
-
/* @__PURE__ */ jsx2("span", { children: label })
|
|
289
|
-
] });
|
|
290
|
-
}
|
|
291
|
-
var MonacoEditor = forwardRef2(
|
|
292
|
-
function MonacoEditor2({
|
|
293
|
-
value,
|
|
294
|
-
onChange,
|
|
295
|
-
language = "plaintext",
|
|
296
|
-
readOnly = false,
|
|
297
|
-
height = 320,
|
|
298
|
-
minHeight = 120,
|
|
299
|
-
toolbar,
|
|
300
|
-
status,
|
|
301
|
-
hideToolbar = false,
|
|
302
|
-
hideFooter = false,
|
|
303
|
-
showCopy = true,
|
|
304
|
-
showFormat = true,
|
|
305
|
-
showWordWrapToggle = true,
|
|
306
|
-
showMinimapToggle = true,
|
|
307
|
-
wordWrap: wordWrapProp,
|
|
308
|
-
minimap: minimapProp,
|
|
309
|
-
showLineNumbers = true,
|
|
310
|
-
markers,
|
|
311
|
-
options,
|
|
312
|
-
onMount,
|
|
313
|
-
onCopy,
|
|
314
|
-
copySuccessTimeoutMs = 1200,
|
|
315
|
-
className,
|
|
316
|
-
ariaLabel = "Code editor",
|
|
317
|
-
theme,
|
|
318
|
-
...rest
|
|
319
|
-
}, ref) {
|
|
320
|
-
const editorRef = useRef2(null);
|
|
321
|
-
const monacoRef = useRef2(null);
|
|
322
|
-
const [wordWrap, setWordWrap] = useState2(wordWrapProp ?? false);
|
|
323
|
-
const [minimap, setMinimap] = useState2(minimapProp ?? false);
|
|
324
|
-
const [copied, setCopied] = useState2(false);
|
|
325
|
-
const [cursor, setCursor] = useState2({ line: 1, column: 1 });
|
|
326
|
-
const [selection, setSelection] = useState2({ chars: 0, lines: 0 });
|
|
327
|
-
const [lineCount, setLineCount] = useState2(value.split("\n").length);
|
|
328
|
-
useImperativeHandle2(
|
|
329
|
-
ref,
|
|
330
|
-
() => ({
|
|
331
|
-
focus: () => editorRef.current?.focus(),
|
|
332
|
-
getEditor: () => editorRef.current,
|
|
333
|
-
getMonaco: () => monacoRef.current,
|
|
334
|
-
getValue: () => editorRef.current?.getValue() ?? "",
|
|
335
|
-
setValue: (v) => editorRef.current?.setValue(v),
|
|
336
|
-
format: () => editorRef.current?.getAction("editor.action.formatDocument")?.run()
|
|
337
|
-
}),
|
|
338
|
-
[]
|
|
339
|
-
);
|
|
340
|
-
useEffect(() => {
|
|
341
|
-
if (wordWrapProp !== void 0) setWordWrap(wordWrapProp);
|
|
342
|
-
}, [wordWrapProp]);
|
|
343
|
-
useEffect(() => {
|
|
344
|
-
if (minimapProp !== void 0) setMinimap(minimapProp);
|
|
345
|
-
}, [minimapProp]);
|
|
346
|
-
useEffect(() => {
|
|
347
|
-
editorRef.current?.updateOptions({
|
|
348
|
-
wordWrap: wordWrap ? "on" : "off",
|
|
349
|
-
minimap: { enabled: minimap }
|
|
350
|
-
});
|
|
351
|
-
}, [wordWrap, minimap]);
|
|
352
|
-
useEffect(() => {
|
|
353
|
-
const ed = editorRef.current;
|
|
354
|
-
const monaco = monacoRef.current;
|
|
355
|
-
if (!ed || !monaco || !markers) return;
|
|
356
|
-
const model = ed.getModel();
|
|
357
|
-
if (!model) return;
|
|
358
|
-
monaco.editor.setModelMarkers(
|
|
359
|
-
model,
|
|
360
|
-
"octaviaflow",
|
|
361
|
-
markers.map((m) => ({
|
|
362
|
-
severity: MARKER_SEVERITY[m.severity ?? "error"],
|
|
363
|
-
message: m.message,
|
|
364
|
-
startLineNumber: m.line,
|
|
365
|
-
startColumn: m.column ?? 1,
|
|
366
|
-
endLineNumber: m.endLine ?? m.line,
|
|
367
|
-
endColumn: m.endColumn ?? (m.column ?? 1) + 1,
|
|
368
|
-
source: m.source
|
|
369
|
-
}))
|
|
370
|
-
);
|
|
371
|
-
}, [markers]);
|
|
372
|
-
const handleMount = useCallback(
|
|
373
|
-
(ed, monaco) => {
|
|
374
|
-
editorRef.current = ed;
|
|
375
|
-
monacoRef.current = monaco;
|
|
376
|
-
monaco.editor.defineTheme(OCTAVIAFLOW_THEME_ID, OCTAVIAFLOW_LIGHT);
|
|
377
|
-
monaco.editor.setTheme(theme ?? OCTAVIAFLOW_THEME_ID);
|
|
378
|
-
ed.onDidChangeCursorPosition((e) => {
|
|
379
|
-
setCursor({ line: e.position.lineNumber, column: e.position.column });
|
|
380
|
-
});
|
|
381
|
-
ed.onDidChangeCursorSelection((e) => {
|
|
382
|
-
const sel = e.selection;
|
|
383
|
-
if (sel.isEmpty()) {
|
|
384
|
-
setSelection({ chars: 0, lines: 0 });
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
const model2 = ed.getModel();
|
|
388
|
-
if (!model2) return;
|
|
389
|
-
const text = model2.getValueInRange(sel);
|
|
390
|
-
setSelection({
|
|
391
|
-
chars: text.length,
|
|
392
|
-
lines: text.split("\n").length
|
|
393
|
-
});
|
|
394
|
-
});
|
|
395
|
-
const model = ed.getModel();
|
|
396
|
-
if (model) {
|
|
397
|
-
setLineCount(model.getLineCount());
|
|
398
|
-
model.onDidChangeContent(() => setLineCount(model.getLineCount()));
|
|
399
|
-
}
|
|
400
|
-
onMount?.(ed, monaco);
|
|
401
|
-
},
|
|
402
|
-
[onMount, theme]
|
|
403
|
-
);
|
|
404
|
-
const handleCopy = async () => {
|
|
405
|
-
if (typeof navigator === "undefined") return;
|
|
406
|
-
try {
|
|
407
|
-
await navigator.clipboard.writeText(value);
|
|
408
|
-
setCopied(true);
|
|
409
|
-
onCopy?.(value);
|
|
410
|
-
setTimeout(() => setCopied(false), copySuccessTimeoutMs);
|
|
411
|
-
} catch {
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
const handleFormat = () => {
|
|
415
|
-
editorRef.current?.getAction("editor.action.formatDocument")?.run();
|
|
416
|
-
};
|
|
417
|
-
const mergedOptions = {
|
|
418
|
-
readOnly,
|
|
419
|
-
fontFamily: "ui-monospace, SFMono-Regular, 'JetBrains Mono', 'Fira Code', Menlo, Consolas, monospace",
|
|
420
|
-
fontSize: 13,
|
|
421
|
-
fontLigatures: true,
|
|
422
|
-
lineHeight: 20,
|
|
423
|
-
lineNumbers: showLineNumbers ? "on" : "off",
|
|
424
|
-
lineNumbersMinChars: 3,
|
|
425
|
-
lineDecorationsWidth: 6,
|
|
426
|
-
folding: true,
|
|
427
|
-
glyphMargin: false,
|
|
428
|
-
minimap: { enabled: minimap },
|
|
429
|
-
wordWrap: wordWrap ? "on" : "off",
|
|
430
|
-
scrollBeyondLastLine: false,
|
|
431
|
-
smoothScrolling: true,
|
|
432
|
-
cursorBlinking: "smooth",
|
|
433
|
-
cursorSmoothCaretAnimation: "on",
|
|
434
|
-
renderLineHighlight: "line",
|
|
435
|
-
padding: { top: 8, bottom: 8 },
|
|
436
|
-
bracketPairColorization: { enabled: true },
|
|
437
|
-
guides: { bracketPairs: true, indentation: true },
|
|
438
|
-
automaticLayout: true,
|
|
439
|
-
tabSize: 2,
|
|
440
|
-
insertSpaces: true,
|
|
441
|
-
scrollbar: {
|
|
442
|
-
verticalScrollbarSize: 8,
|
|
443
|
-
horizontalScrollbarSize: 8,
|
|
444
|
-
useShadows: false
|
|
445
|
-
},
|
|
446
|
-
fixedOverflowWidgets: true,
|
|
447
|
-
contextmenu: true,
|
|
448
|
-
suggestOnTriggerCharacters: true,
|
|
449
|
-
quickSuggestions: { other: true, comments: false, strings: false },
|
|
450
|
-
formatOnPaste: false,
|
|
451
|
-
formatOnType: false,
|
|
452
|
-
"semanticHighlighting.enabled": true,
|
|
453
|
-
...options
|
|
454
|
-
};
|
|
455
|
-
const showWrapBtn = showWordWrapToggle && wordWrapProp === void 0;
|
|
456
|
-
const showMinimapBtn = showMinimapToggle && minimapProp === void 0;
|
|
457
|
-
return /* @__PURE__ */ jsxs2(
|
|
458
|
-
"div",
|
|
459
|
-
{
|
|
460
|
-
...rest,
|
|
461
|
-
className: cn(
|
|
462
|
-
"ods-monaco",
|
|
463
|
-
`ods-monaco--${language}`,
|
|
464
|
-
readOnly && "ods-monaco--readonly",
|
|
465
|
-
className
|
|
466
|
-
),
|
|
467
|
-
children: [
|
|
468
|
-
!hideToolbar && /* @__PURE__ */ jsxs2("div", { className: "ods-monaco__toolbar", children: [
|
|
469
|
-
/* @__PURE__ */ jsxs2("div", { className: "ods-monaco__toolbar-left", children: [
|
|
470
|
-
/* @__PURE__ */ jsx2("span", { className: "ods-monaco__lang", children: language.toUpperCase() }),
|
|
471
|
-
toolbar
|
|
472
|
-
] }),
|
|
473
|
-
/* @__PURE__ */ jsxs2("div", { className: "ods-monaco__toolbar-right", children: [
|
|
474
|
-
/* @__PURE__ */ jsxs2("span", { className: "ods-monaco__lines", children: [
|
|
475
|
-
lineCount,
|
|
476
|
-
" line",
|
|
477
|
-
lineCount === 1 ? "" : "s"
|
|
478
|
-
] }),
|
|
479
|
-
status && /* @__PURE__ */ jsx2("span", { className: "ods-monaco__status", children: status }),
|
|
480
|
-
showWrapBtn && /* @__PURE__ */ jsx2(
|
|
481
|
-
"button",
|
|
482
|
-
{
|
|
483
|
-
type: "button",
|
|
484
|
-
className: cn(
|
|
485
|
-
"ods-monaco__btn",
|
|
486
|
-
wordWrap && "ods-monaco__btn--active"
|
|
487
|
-
),
|
|
488
|
-
onClick: () => setWordWrap((w) => !w),
|
|
489
|
-
"aria-pressed": wordWrap,
|
|
490
|
-
"aria-label": "Toggle word wrap",
|
|
491
|
-
title: "Word wrap",
|
|
492
|
-
children: /* @__PURE__ */ jsx2(TextWrapIcon, {})
|
|
493
|
-
}
|
|
494
|
-
),
|
|
495
|
-
showMinimapBtn && /* @__PURE__ */ jsx2(
|
|
496
|
-
"button",
|
|
497
|
-
{
|
|
498
|
-
type: "button",
|
|
499
|
-
className: cn(
|
|
500
|
-
"ods-monaco__btn",
|
|
501
|
-
minimap && "ods-monaco__btn--active"
|
|
502
|
-
),
|
|
503
|
-
onClick: () => setMinimap((m) => !m),
|
|
504
|
-
"aria-pressed": minimap,
|
|
505
|
-
"aria-label": "Toggle minimap",
|
|
506
|
-
title: "Minimap",
|
|
507
|
-
children: minimap ? /* @__PURE__ */ jsx2(MinimapOnIcon, {}) : /* @__PURE__ */ jsx2(MinimapOffIcon, {})
|
|
508
|
-
}
|
|
509
|
-
),
|
|
510
|
-
showFormat && !readOnly && /* @__PURE__ */ jsx2(
|
|
511
|
-
"button",
|
|
512
|
-
{
|
|
513
|
-
type: "button",
|
|
514
|
-
className: "ods-monaco__btn",
|
|
515
|
-
onClick: handleFormat,
|
|
516
|
-
"aria-label": "Format document",
|
|
517
|
-
title: "Format (Shift+Alt+F)",
|
|
518
|
-
children: /* @__PURE__ */ jsx2(MagicWandIcon, {})
|
|
519
|
-
}
|
|
520
|
-
),
|
|
521
|
-
showCopy && /* @__PURE__ */ jsx2(
|
|
522
|
-
"button",
|
|
523
|
-
{
|
|
524
|
-
type: "button",
|
|
525
|
-
className: cn(
|
|
526
|
-
"ods-monaco__btn",
|
|
527
|
-
copied && "ods-monaco__btn--success"
|
|
528
|
-
),
|
|
529
|
-
onClick: handleCopy,
|
|
530
|
-
"aria-label": copied ? "Copied" : "Copy",
|
|
531
|
-
title: copied ? "Copied" : "Copy",
|
|
532
|
-
children: copied ? /* @__PURE__ */ jsx2(CheckmarkIcon, {}) : /* @__PURE__ */ jsx2(CopyIcon, {})
|
|
533
|
-
}
|
|
534
|
-
)
|
|
535
|
-
] })
|
|
536
|
-
] }),
|
|
537
|
-
/* @__PURE__ */ jsx2("div", { className: "ods-monaco__body", style: { minHeight }, children: /* @__PURE__ */ jsx2(Suspense2, { fallback: /* @__PURE__ */ jsx2(LoadingPlaceholder2, { label: "Loading editor\u2026" }), children: /* @__PURE__ */ jsx2(
|
|
538
|
-
Editor,
|
|
539
|
-
{
|
|
540
|
-
value,
|
|
541
|
-
onChange: (v) => onChange?.(v ?? ""),
|
|
542
|
-
language,
|
|
543
|
-
height,
|
|
544
|
-
theme: theme ?? OCTAVIAFLOW_THEME_ID,
|
|
545
|
-
options: mergedOptions,
|
|
546
|
-
onMount: handleMount,
|
|
547
|
-
loading: /* @__PURE__ */ jsx2(LoadingPlaceholder2, { label: "Loading editor\u2026" }),
|
|
548
|
-
"aria-label": ariaLabel
|
|
549
|
-
}
|
|
550
|
-
) }) }),
|
|
551
|
-
!hideFooter && /* @__PURE__ */ jsxs2("div", { className: "ods-monaco__footer", children: [
|
|
552
|
-
/* @__PURE__ */ jsxs2("span", { className: "ods-monaco__pos", children: [
|
|
553
|
-
"Ln ",
|
|
554
|
-
cursor.line,
|
|
555
|
-
", Col ",
|
|
556
|
-
cursor.column,
|
|
557
|
-
selection.chars > 0 && /* @__PURE__ */ jsxs2(Fragment, { children: [
|
|
558
|
-
" ",
|
|
559
|
-
"\xB7 ",
|
|
560
|
-
selection.chars,
|
|
561
|
-
" char",
|
|
562
|
-
selection.chars === 1 ? "" : "s",
|
|
563
|
-
selection.lines > 1 && ` \xB7 ${selection.lines} lines`
|
|
564
|
-
] })
|
|
565
|
-
] }),
|
|
566
|
-
/* @__PURE__ */ jsxs2("span", { className: "ods-monaco__shortcut-hint", children: [
|
|
567
|
-
/* @__PURE__ */ jsx2("kbd", { className: "ods-monaco__kbd", children: "\u2318F" }),
|
|
568
|
-
" find",
|
|
569
|
-
/* @__PURE__ */ jsx2("span", { className: "ods-monaco__sep", children: "\xB7" }),
|
|
570
|
-
/* @__PURE__ */ jsx2("kbd", { className: "ods-monaco__kbd", children: "\u2318\u21E7F" }),
|
|
571
|
-
" replace",
|
|
572
|
-
/* @__PURE__ */ jsx2("span", { className: "ods-monaco__sep", children: "\xB7" }),
|
|
573
|
-
/* @__PURE__ */ jsx2("kbd", { className: "ods-monaco__kbd", children: "F1" }),
|
|
574
|
-
" commands"
|
|
575
|
-
] })
|
|
576
|
-
] })
|
|
577
|
-
]
|
|
578
|
-
}
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
);
|
|
582
553
|
MonacoEditor.displayName = "MonacoEditor";
|
|
583
554
|
export {
|
|
584
555
|
MonacoDiffEditor,
|