flexdesk 0.16.1 → 0.17.1
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/CHANGELOG.md +112 -0
- package/LICENSE +0 -0
- package/README.md +2435 -42
- package/THIRD_PARTY_LICENSES.md +0 -0
- package/canvas.js +18 -0
- package/charts.js +21 -0
- package/core.js +14 -0
- package/css/base.css +1834 -75
- package/css/flexdesk.css +3165 -159
- package/css/overrides.css +16 -0
- package/css/reset.css +0 -0
- package/css/tokens.css +0 -0
- package/dist/canvas.js +6 -239
- package/dist/canvas.js.map +3 -3
- package/dist/charts.js +707 -18
- package/dist/charts.js.map +4 -4
- package/dist/chunk-3PHCPZHT.js +0 -0
- package/dist/chunk-3PHCPZHT.js.map +0 -0
- package/dist/chunk-4A7SJC3T.js +503 -0
- package/dist/chunk-4A7SJC3T.js.map +7 -0
- package/dist/{chunk-6JSOVNID.js → chunk-CVMCZZX2.js} +635 -10
- package/dist/chunk-CVMCZZX2.js.map +7 -0
- package/dist/chunk-D3COLZZ2.js +1311 -0
- package/dist/chunk-D3COLZZ2.js.map +7 -0
- package/dist/chunk-FOOS3T5L.js +0 -0
- package/dist/chunk-FOOS3T5L.js.map +0 -0
- package/dist/{chunk-SN4LSOAR.js → chunk-GOQLR5WR.js} +452 -2
- package/dist/chunk-GOQLR5WR.js.map +7 -0
- package/dist/{chunk-FL5KFNQH.js → chunk-HNU6MM2B.js} +52 -17
- package/dist/chunk-HNU6MM2B.js.map +7 -0
- package/dist/chunk-HYJYYEPK.js +375 -0
- package/dist/chunk-HYJYYEPK.js.map +7 -0
- package/dist/chunk-JKZLNKG6.js +2041 -0
- package/dist/chunk-JKZLNKG6.js.map +7 -0
- package/dist/chunk-JYWURG5T.js +0 -0
- package/dist/chunk-JYWURG5T.js.map +0 -0
- package/dist/{chunk-FBGP5KN5.js → chunk-LWV23YVE.js} +5073 -532
- package/dist/chunk-LWV23YVE.js.map +7 -0
- package/dist/chunk-N7HC3ADV.js +30 -0
- package/dist/chunk-N7HC3ADV.js.map +7 -0
- package/dist/{chunk-RQM5Z2MU.js → chunk-RMTRWWEO.js} +633 -311
- package/dist/chunk-RMTRWWEO.js.map +7 -0
- package/dist/{chunk-NLTOY57M.js → chunk-UURZ37SD.js} +28 -48
- package/dist/chunk-UURZ37SD.js.map +7 -0
- package/dist/{chunk-B5Q53LAJ.js → chunk-UWO43BZU.js} +2 -2
- package/dist/chunk-UWO43BZU.js.map +7 -0
- package/dist/chunk-WVFGV5FT.js +0 -0
- package/dist/chunk-WVFGV5FT.js.map +0 -0
- package/dist/core.js +170 -118
- package/dist/core.js.map +2 -2
- package/dist/editor.js +156 -70
- package/dist/editor.js.map +2 -2
- package/dist/flexdesk.css +3165 -159
- package/dist/flow.js +2789 -306
- package/dist/flow.js.map +4 -4
- package/dist/host.js +109 -3
- package/dist/host.js.map +3 -3
- package/dist/reset.css +0 -0
- package/dist/tile_registry-6WZPTUZV.js +0 -0
- package/dist/tile_registry-6WZPTUZV.js.map +0 -0
- package/dist/tiles.js +657 -234
- package/dist/tiles.js.map +4 -4
- package/dist/tokens.css +0 -0
- package/dist/widgets.js +3290 -2124
- package/dist/widgets.js.map +4 -4
- package/dist/wm.js +1227 -347
- package/dist/wm.js.map +4 -4
- package/editor.js +20 -0
- package/flow.js +21 -0
- package/host.js +14 -0
- package/package.json +12 -1
- package/src/canvas/canvas_adapter.js +5 -0
- package/src/canvas/edge_router.js +0 -0
- package/src/canvas/graph/connector_router.js +0 -0
- package/src/canvas/graph/history_service.js +0 -0
- package/src/canvas/graph/node_platform.js +0 -0
- package/src/canvas/index.js +1 -0
- package/src/canvas/layered_layout.js +244 -0
- package/src/charts/chart_types.js +0 -0
- package/src/charts/data_series_plot_window.js +0 -0
- package/src/charts/downsample.js +2 -2
- package/src/charts/plot_config.js +53 -29
- package/src/charts/plot_config_editor.js +627 -0
- package/src/charts/plot_grid.js +449 -0
- package/src/charts/plot_popout_window.js +103 -317
- package/src/charts/plotly_wrapper.js +22 -2
- package/src/charts/series_transforms.js +206 -0
- package/src/core/event_bus.js +0 -0
- package/src/core/logging.js +1 -1
- package/src/core/settings.js +105 -19
- package/src/core/state_guard.js +93 -51
- package/src/core/state_guard_config.js +85 -74
- package/src/core/state_machine.js +0 -0
- package/src/editor/editor_pane.js +3 -3
- package/src/editor/monaco_editor_factory.js +124 -60
- package/src/editor/monaco_loader.js +103 -28
- package/src/editor/notebook_search.js +0 -0
- package/src/editor/notebook_tab_bar.js +38 -52
- package/src/editor/notebook_undo_manager.js +0 -0
- package/src/editor/split_pane_container.js +6 -3
- package/src/flow/canvas_editor/connections.js +90 -0
- package/src/flow/canvas_editor/editor.js +2351 -153
- package/src/flow/canvas_editor/index.js +2 -1
- package/src/flow/canvas_editor/layout.js +119 -12
- package/src/flow/canvas_editor/strings.js +80 -0
- package/src/flow/kit/always_before.js +0 -0
- package/src/flow/kit/catalogue.js +97 -3
- package/src/flow/kit/chip_input.js +0 -0
- package/src/flow/kit/dom.js +0 -0
- package/src/flow/kit/findings.js +0 -0
- package/src/flow/kit/history.js +0 -0
- package/src/flow/kit/index.js +3 -3
- package/src/flow/kit/keys.js +7 -1
- package/src/flow/kit/logic_graph.js +97 -15
- package/src/flow/kit/references.js +0 -0
- package/src/flow/kit/settings_panel.js +0 -0
- package/src/flow/kit/settings_schema.js +2 -1
- package/src/flow/kit/step_picker.js +0 -0
- package/src/flow/kit/strings.js +3 -1
- package/src/flow/kit/value_picker.js +0 -0
- package/src/flow/kit/widgets.js +86 -109
- package/src/flow/lanes/editor.js +136 -14
- package/src/flow/lanes/index.js +3 -1
- package/src/flow/lanes/layout.js +0 -0
- package/src/flow/lanes/pipeline.js +44 -2
- package/src/flow/lanes/preview.js +0 -0
- package/src/flow/lanes/strings.js +1 -0
- package/src/flow/outline/editor.js +0 -0
- package/src/flow/outline/index.js +0 -0
- package/src/flow/outline/mapping.js +0 -0
- package/src/flow/outline/menu.js +0 -0
- package/src/flow/outline/operations.js +0 -0
- package/src/flow/outline/recognise.js +0 -0
- package/src/flow/outline/strings.js +0 -0
- package/src/help/help_modal.js +168 -42
- package/src/help/help_registry.js +12 -1
- package/src/host/external_links.js +0 -0
- package/src/host/file_picker.js +117 -0
- package/src/host/host.js +10 -2
- package/src/host/photino_host.js +9 -0
- package/src/host/photino_host.md +21 -3
- package/src/host/pywebview_host.js +10 -0
- package/src/tiles/chart_tiles.js +53 -245
- package/src/tiles/config_schema.js +8 -0
- package/src/tiles/figure_tile.js +322 -0
- package/src/tiles/layout_persistence.js +3 -3
- package/src/tiles/list_tiles.js +7 -7
- package/src/tiles/scope_picker.js +0 -0
- package/src/tiles/tile_base.js +1 -1
- package/src/tiles/tile_config_form.js +442 -0
- package/src/tiles/tile_grid.js +2 -0
- package/src/tiles/tile_registry.js +0 -0
- package/src/tiling/bottom_panel_tabs.js +67 -99
- package/src/tiling/command_palette.js +64 -19
- package/src/tiling/content_registry.js +4 -1
- package/src/tiling/desktops.js +11 -1
- package/src/tiling/entity_sources.js +0 -0
- package/src/tiling/keymap.js +403 -128
- package/src/tiling/kind_taxonomy.js +78 -0
- package/src/tiling/landing_table.js +0 -0
- package/src/tiling/loading_overlay.js +0 -0
- package/src/tiling/nav_panel.js +59 -10
- package/src/tiling/page_factory.js +5 -5
- package/src/tiling/panel_availability.js +49 -0
- package/src/tiling/panel_keys.js +0 -0
- package/src/tiling/shell.js +114 -12
- package/src/tiling/tab_strip.js +0 -0
- package/src/tiling/tile_breadcrumb.js +0 -0
- package/src/tiling/tile_renderer.js +105 -9
- package/src/tiling/tile_tab_menu.js +0 -0
- package/src/tiling/tile_tree.js +0 -0
- package/src/tiling/wm.js +562 -30
- package/src/tiling/zoom.js +0 -0
- package/src/ui/base/component_base.js +0 -0
- package/src/ui/base/controller_base.js +0 -0
- package/src/ui/base/page_base.js +0 -0
- package/src/ui/components/about_dialog.js +0 -0
- package/src/ui/components/action_dropdown.js +30 -2
- package/src/ui/components/alert_log.js +0 -0
- package/src/ui/components/alerts_pane.js +0 -0
- package/src/ui/components/attribute_list_editor.js +0 -0
- package/src/ui/components/autocomplete_field.js +0 -0
- package/src/ui/components/cell_editor_host.js +293 -0
- package/src/ui/components/cell_editors.js +480 -0
- package/src/ui/components/cell_grid.js +761 -0
- package/src/ui/components/cell_paste.js +243 -0
- package/src/ui/components/cell_selection.js +220 -0
- package/src/ui/components/choice_controls.js +351 -0
- package/src/ui/components/color_field.js +211 -0
- package/src/ui/components/color_list_field.js +210 -0
- package/src/ui/components/column_fit.js +0 -0
- package/src/ui/components/column_groups.js +314 -0
- package/src/ui/components/column_order.js +142 -0
- package/src/ui/components/computing_status_window.js +98 -25
- package/src/ui/components/confirm_dialog.js +81 -38
- package/src/ui/components/context_menu.js +2 -2
- package/src/ui/components/conversation_view.js +440 -0
- package/src/ui/components/crosstab.js +289 -0
- package/src/ui/components/data_table.js +696 -71
- package/src/ui/components/detail_header.js +22 -11
- package/src/ui/components/document_outline.js +397 -0
- package/src/ui/components/drag_reorder.js +0 -0
- package/src/ui/components/fact_table.js +0 -0
- package/src/ui/components/fill_handle.js +322 -0
- package/src/ui/components/gallery_picker.js +19 -8
- package/src/ui/components/header_actions.js +55 -0
- package/src/ui/components/inline_renamer.js +0 -0
- package/src/ui/components/job_progress.js +51 -0
- package/src/ui/components/managed_window.js +27 -4
- package/src/ui/components/menu_bar.js +745 -0
- package/src/ui/components/modal.js +449 -75
- package/src/ui/components/notification_history.js +3 -3
- package/src/ui/components/progress.js +483 -0
- package/src/ui/components/record_list.js +0 -0
- package/src/ui/components/row_activation.js +0 -0
- package/src/ui/components/section_stack.js +298 -0
- package/src/ui/components/series.js +173 -0
- package/src/ui/components/settings_view.js +634 -0
- package/src/ui/components/slide_out_panel.js +43 -6
- package/src/ui/components/slider_field.js +275 -18
- package/src/ui/components/sortable_list.js +0 -0
- package/src/ui/components/staged_edits.js +361 -0
- package/src/ui/components/staged_history.js +172 -0
- package/src/ui/components/table_filter_chips.js +0 -0
- package/src/ui/components/table_state_store.js +0 -0
- package/src/ui/components/table_structure.js +182 -0
- package/src/ui/components/table_values.js +0 -0
- package/src/ui/components/tabs.js +497 -0
- package/src/ui/components/tag_input.js +215 -0
- package/src/ui/components/toast.js +25 -8
- package/src/ui/components/toggle_field.js +175 -0
- package/src/ui/components/tree_view.js +55 -34
- package/src/ui/components/tsv.js +74 -0
- package/src/ui/components/window_taskbar.js +0 -0
- package/src/ui/components/wizard.js +563 -0
- package/src/ui/controllers/window_chrome_controller.js +2 -2
- package/src/ui/notification_center.js +375 -119
- package/src/ui/utils/auto_scrollbars.js +0 -0
- package/src/ui/utils/markdown.js +709 -0
- package/src/ui/utils/native_context_menu.js +0 -0
- package/src/ui/utils/overlay_scrollbar.js +16 -12
- package/src/ui/utils/raf_resize_observer.js +0 -0
- package/src/ui/utils/scroll_lock.js +0 -0
- package/src/ui/utils/strip_scroll.js +55 -0
- package/src/ui/utils/tooltip_service.js +0 -8
- package/tiles.js +27 -0
- package/widgets.js +69 -0
- package/wm.js +28 -0
- package/dist/chunk-6JSOVNID.js.map +0 -7
- package/dist/chunk-B5Q53LAJ.js.map +0 -7
- package/dist/chunk-FBGP5KN5.js.map +0 -7
- package/dist/chunk-FL5KFNQH.js.map +0 -7
- package/dist/chunk-NLTOY57M.js.map +0 -7
- package/dist/chunk-NNFTETK3.js +0 -633
- package/dist/chunk-NNFTETK3.js.map +0 -7
- package/dist/chunk-O5OHMWBB.js +0 -284
- package/dist/chunk-O5OHMWBB.js.map +0 -7
- package/dist/chunk-RQM5Z2MU.js.map +0 -7
- package/dist/chunk-SN4LSOAR.js.map +0 -7
- package/dist/chunk-W6FBJLPW.js +0 -367
- package/dist/chunk-W6FBJLPW.js.map +0 -7
- package/src/ui/controllers/panel_state_machine.js +0 -634
package/dist/editor.js
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
DEFAULT_TAB_DRAG_MIME,
|
|
3
|
+
NotebookTabBar,
|
|
4
|
+
getTabDragMime,
|
|
5
|
+
setTabDragMime
|
|
6
|
+
} from "./chunk-UURZ37SD.js";
|
|
7
|
+
import "./chunk-N7HC3ADV.js";
|
|
4
8
|
import "./chunk-WVFGV5FT.js";
|
|
5
9
|
import "./chunk-JYWURG5T.js";
|
|
6
10
|
|
|
@@ -112,7 +116,7 @@ var EditorPane = class {
|
|
|
112
116
|
if (this.#isExternalTabDrag(e)) {
|
|
113
117
|
e.preventDefault();
|
|
114
118
|
this.#editorContainer.classList.remove("notebook-editor-container--drop-target");
|
|
115
|
-
const filePath = e.dataTransfer.getData(
|
|
119
|
+
const filePath = e.dataTransfer.getData(getTabDragMime()) || e.dataTransfer.getData("text/plain");
|
|
116
120
|
if (filePath) {
|
|
117
121
|
this.#callbacks.onDropFromOtherPane?.(this.#id, filePath);
|
|
118
122
|
}
|
|
@@ -206,7 +210,7 @@ var EditorPane = class {
|
|
|
206
210
|
/** Check if a drag event is carrying a tab from another pane. */
|
|
207
211
|
#isExternalTabDrag(e) {
|
|
208
212
|
try {
|
|
209
|
-
return e.dataTransfer.types.includes(
|
|
213
|
+
return e.dataTransfer.types.includes(getTabDragMime());
|
|
210
214
|
} catch {
|
|
211
215
|
return false;
|
|
212
216
|
}
|
|
@@ -225,7 +229,7 @@ var EditorPane = class {
|
|
|
225
229
|
|
|
226
230
|
// src/editor/monaco_loader.js
|
|
227
231
|
var _resolveMonaco;
|
|
228
|
-
var
|
|
232
|
+
var _attempt = null;
|
|
229
233
|
var monacoReady = new Promise((resolve) => {
|
|
230
234
|
_resolveMonaco = resolve;
|
|
231
235
|
});
|
|
@@ -234,39 +238,77 @@ function injectLoaderScript(src) {
|
|
|
234
238
|
const s = document.createElement("script");
|
|
235
239
|
s.src = src;
|
|
236
240
|
s.onload = resolve;
|
|
237
|
-
s.onerror = () =>
|
|
241
|
+
s.onerror = () => {
|
|
242
|
+
s.remove?.();
|
|
243
|
+
reject(new Error(`Failed to load Monaco loader: ${src}`));
|
|
244
|
+
};
|
|
238
245
|
document.head.appendChild(s);
|
|
239
246
|
});
|
|
240
247
|
}
|
|
241
248
|
function injectMonacoCss(basePath) {
|
|
242
249
|
const id = "monaco-editor-css";
|
|
243
|
-
|
|
250
|
+
const href = `${basePath}/vs/editor/editor.main.css`;
|
|
251
|
+
const existing = document.getElementById(id);
|
|
252
|
+
if (existing) {
|
|
253
|
+
if (existing.getAttribute?.("href") !== href) existing.setAttribute?.("href", href);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
244
256
|
const link = document.createElement("link");
|
|
245
257
|
link.id = id;
|
|
246
258
|
link.rel = "stylesheet";
|
|
247
|
-
link.href =
|
|
259
|
+
link.href = href;
|
|
248
260
|
document.head.appendChild(link);
|
|
249
261
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
262
|
+
function requireEditorMain(basePath) {
|
|
263
|
+
return new Promise((resolve, reject) => {
|
|
264
|
+
window.require.config({
|
|
265
|
+
paths: { vs: `${basePath}/vs` },
|
|
266
|
+
"vs/nls": { availableLanguages: {} }
|
|
267
|
+
});
|
|
268
|
+
window.require(["vs/editor/editor.main"], () => {
|
|
269
|
+
if (window.monaco) resolve(window.monaco);
|
|
270
|
+
else reject(new Error(
|
|
271
|
+
`[twm/editor] vs/editor/editor.main loaded from ${basePath}/vs but did not set window.monaco.`
|
|
272
|
+
));
|
|
273
|
+
}, (err) => {
|
|
274
|
+
reject(new Error(
|
|
275
|
+
`[twm/editor] Failed to load Monaco from ${basePath}/vs: ${err?.message ?? err}. Monaco's AMD loader caches this failure, so it is final for this page: fix the path and reload.`
|
|
276
|
+
));
|
|
277
|
+
});
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
async function loadMonaco(basePath) {
|
|
258
281
|
injectMonacoCss(basePath);
|
|
259
282
|
if (!window.require) {
|
|
260
|
-
|
|
283
|
+
const src = `${basePath}/vs/loader.js`;
|
|
284
|
+
await injectLoaderScript(src);
|
|
285
|
+
if (!window.require) {
|
|
286
|
+
throw new Error(
|
|
287
|
+
`[twm/editor] ${src} loaded but did not define window.require; is it Monaco's vs/loader.js?`
|
|
288
|
+
);
|
|
289
|
+
}
|
|
261
290
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
291
|
+
return requireEditorMain(basePath);
|
|
292
|
+
}
|
|
293
|
+
function initMonaco(basePath) {
|
|
294
|
+
if (_attempt) return _attempt;
|
|
295
|
+
if (!basePath) {
|
|
296
|
+
return Promise.reject(new Error(
|
|
297
|
+
"[twm/editor] initMonaco() needs the path to your copy of Monaco, e.g. initMonaco('vendor/monaco'). Monaco is a peer dependency; the library does not guess where you put it."
|
|
298
|
+
));
|
|
299
|
+
}
|
|
300
|
+
const attempt = loadMonaco(basePath).then(
|
|
301
|
+
(m) => {
|
|
302
|
+
_resolveMonaco(m);
|
|
303
|
+
return m;
|
|
304
|
+
},
|
|
305
|
+
(err) => {
|
|
306
|
+
if (!window.require && _attempt === attempt) _attempt = null;
|
|
307
|
+
throw err;
|
|
308
|
+
}
|
|
309
|
+
);
|
|
310
|
+
_attempt = attempt;
|
|
311
|
+
return attempt;
|
|
270
312
|
}
|
|
271
313
|
|
|
272
314
|
// src/editor/monaco_editor_factory.js
|
|
@@ -281,7 +323,7 @@ function safeDispose(editor) {
|
|
|
281
323
|
if (e?.message !== "Canceled") throw e;
|
|
282
324
|
}
|
|
283
325
|
}
|
|
284
|
-
var
|
|
326
|
+
var DARK_THEME = {
|
|
285
327
|
base: "vs-dark",
|
|
286
328
|
inherit: true,
|
|
287
329
|
rules: [
|
|
@@ -326,7 +368,7 @@ var ECOSIM_DARK_THEME = {
|
|
|
326
368
|
"scrollbarSlider.hoverBackground": "#4a4a4d70"
|
|
327
369
|
}
|
|
328
370
|
};
|
|
329
|
-
var
|
|
371
|
+
var LIGHT_THEME = {
|
|
330
372
|
base: "vs",
|
|
331
373
|
inherit: true,
|
|
332
374
|
rules: [
|
|
@@ -359,17 +401,37 @@ var ECOSIM_LIGHT_THEME = {
|
|
|
359
401
|
"scrollbarSlider.hoverBackground": "#babbbd70"
|
|
360
402
|
}
|
|
361
403
|
};
|
|
362
|
-
var
|
|
404
|
+
var DEFAULT_EDITOR_THEME_NAMES = Object.freeze({
|
|
405
|
+
dark: "flexdesk-dark",
|
|
406
|
+
light: "flexdesk-light"
|
|
407
|
+
});
|
|
408
|
+
var _themeNames = DEFAULT_EDITOR_THEME_NAMES;
|
|
409
|
+
function setEditorThemeNames({ dark, light } = {}) {
|
|
410
|
+
_themeNames = Object.freeze({
|
|
411
|
+
dark: typeof dark === "string" && dark ? dark : DEFAULT_EDITOR_THEME_NAMES.dark,
|
|
412
|
+
light: typeof light === "string" && light ? light : DEFAULT_EDITOR_THEME_NAMES.light
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
function getEditorThemeNames() {
|
|
416
|
+
return _themeNames;
|
|
417
|
+
}
|
|
418
|
+
var _definedThemes = /* @__PURE__ */ new WeakMap();
|
|
363
419
|
function ensureThemes(monaco) {
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
420
|
+
let defined = _definedThemes.get(monaco);
|
|
421
|
+
if (!defined) {
|
|
422
|
+
defined = /* @__PURE__ */ new Set();
|
|
423
|
+
_definedThemes.set(monaco, defined);
|
|
424
|
+
}
|
|
425
|
+
for (const [name, theme] of [[_themeNames.dark, DARK_THEME], [_themeNames.light, LIGHT_THEME]]) {
|
|
426
|
+
if (defined.has(name)) continue;
|
|
427
|
+
defined.add(name);
|
|
428
|
+
monaco.editor.defineTheme(name, theme);
|
|
429
|
+
}
|
|
368
430
|
}
|
|
369
431
|
function baseOptions(overrides = {}) {
|
|
370
432
|
return {
|
|
371
433
|
language: _defaultLanguage,
|
|
372
|
-
theme:
|
|
434
|
+
theme: _themeNames.dark,
|
|
373
435
|
fontFamily: 'Consolas, "Courier New", monospace',
|
|
374
436
|
fontSize: 13,
|
|
375
437
|
lineHeight: 19.5,
|
|
@@ -422,9 +484,15 @@ function singleLineOptions(overrides = {}) {
|
|
|
422
484
|
...overrides
|
|
423
485
|
});
|
|
424
486
|
}
|
|
487
|
+
function checkMaxHeight(px) {
|
|
488
|
+
if (typeof px !== "number" || Number.isNaN(px) || px <= 0) {
|
|
489
|
+
throw new RangeError(`maxHeight must be a positive number of px or Infinity, got ${String(px)}`);
|
|
490
|
+
}
|
|
491
|
+
return px;
|
|
492
|
+
}
|
|
425
493
|
var MonacoEditorFactory = class {
|
|
426
494
|
#monaco = null;
|
|
427
|
-
#currentTheme =
|
|
495
|
+
#currentTheme = _themeNames.dark;
|
|
428
496
|
constructor() {
|
|
429
497
|
}
|
|
430
498
|
async init() {
|
|
@@ -437,23 +505,33 @@ var MonacoEditorFactory = class {
|
|
|
437
505
|
}
|
|
438
506
|
/**
|
|
439
507
|
* Set global theme for all editors.
|
|
440
|
-
* @param {
|
|
508
|
+
* @param {string} theme A theme name Monaco knows: one of
|
|
509
|
+
* getEditorThemeNames(), or one the embedder defined itself.
|
|
441
510
|
*/
|
|
442
511
|
setTheme(theme) {
|
|
443
512
|
this.#currentTheme = theme;
|
|
444
513
|
this.#monaco?.editor.setTheme(theme);
|
|
445
514
|
}
|
|
446
515
|
/**
|
|
447
|
-
* Create a full multi-line editor
|
|
516
|
+
* Create a full multi-line editor.
|
|
517
|
+
*
|
|
518
|
+
* Unless `noAutoHeight` is set, the editor sizes `container` to its content,
|
|
519
|
+
* never below `setMinHeight()` (80px by default) and never above `maxHeight`.
|
|
520
|
+
* Past the cap, Monaco scrolls internally and handles the mouse wheel; below
|
|
521
|
+
* it, Monaco leaves the wheel alone, so it reaches whatever scrolls around
|
|
522
|
+
* the editor.
|
|
448
523
|
*
|
|
449
524
|
* @param {HTMLElement} container
|
|
450
525
|
* @param {string} initialValue
|
|
451
|
-
* @param {{ language?: string, readOnly?: boolean, lineNumbers?: string } & object} [overrides]
|
|
526
|
+
* @param {{ language?: string, readOnly?: boolean, lineNumbers?: string, maxHeight?: number, noAutoHeight?: boolean } & object} [overrides]
|
|
527
|
+
* `maxHeight`: the auto-height cap in px, `Infinity` (the default) for none.
|
|
528
|
+
* `noAutoHeight`: leave the container's size to its layout; the wheel always scrolls the editor.
|
|
452
529
|
* @returns {EditorHandle}
|
|
453
530
|
*/
|
|
454
531
|
createEditor(container, initialValue = "", overrides = {}) {
|
|
455
532
|
if (!this.#monaco) throw new Error("MonacoEditorFactory not initialized");
|
|
456
|
-
const { noAutoHeight, ...editorOverrides } = overrides;
|
|
533
|
+
const { noAutoHeight, maxHeight: maxHeightOption = Infinity, ...editorOverrides } = overrides;
|
|
534
|
+
let maxHeight = checkMaxHeight(maxHeightOption);
|
|
457
535
|
const editor = this.#monaco.editor.create(container, {
|
|
458
536
|
...baseOptions({ theme: this.#currentTheme }),
|
|
459
537
|
value: initialValue,
|
|
@@ -466,24 +544,15 @@ var MonacoEditorFactory = class {
|
|
|
466
544
|
editor.updateOptions({ scrollbar: { handleMouseWheel: true } });
|
|
467
545
|
} else {
|
|
468
546
|
updateHeight = () => {
|
|
469
|
-
const maxHeightEnabled = container.closest(".notebook-editor-container")?.dataset.codeMaxHeight === "true";
|
|
470
|
-
const maxH = maxHeightEnabled ? 400 : Infinity;
|
|
471
547
|
const rawContent = editor.getContentHeight();
|
|
472
|
-
const contentHeight = Math.min(
|
|
548
|
+
const contentHeight = Math.min(maxHeight, Math.max(minHeight, rawContent));
|
|
473
549
|
container.style.height = `${contentHeight}px`;
|
|
474
550
|
editor.layout();
|
|
475
|
-
|
|
476
|
-
editor.updateOptions({ scrollbar: { handleMouseWheel: needsInternalScroll } });
|
|
551
|
+
editor.updateOptions({ scrollbar: { handleMouseWheel: rawContent > maxHeight } });
|
|
477
552
|
};
|
|
478
553
|
heightDisposable = editor.onDidContentSizeChange(updateHeight);
|
|
479
554
|
updateHeight();
|
|
480
555
|
}
|
|
481
|
-
const editorContainer = container.closest(".notebook-editor-container");
|
|
482
|
-
let maxHeightObserver = null;
|
|
483
|
-
if (updateHeight && editorContainer) {
|
|
484
|
-
maxHeightObserver = new MutationObserver(() => updateHeight());
|
|
485
|
-
maxHeightObserver.observe(editorContainer, { attributes: true, attributeFilter: ["data-code-max-height"] });
|
|
486
|
-
}
|
|
487
556
|
let findWidgetObserver = null;
|
|
488
557
|
const observeFindWidget = () => {
|
|
489
558
|
const overflowGuard = container.querySelector(".overflow-guard");
|
|
@@ -511,10 +580,14 @@ var MonacoEditorFactory = class {
|
|
|
511
580
|
setMinHeight: (h) => {
|
|
512
581
|
minHeight = h;
|
|
513
582
|
},
|
|
583
|
+
/** The auto-height cap in px, `Infinity` for none; applies at once. No effect with `noAutoHeight`. */
|
|
584
|
+
setMaxHeight: (px) => {
|
|
585
|
+
maxHeight = checkMaxHeight(px);
|
|
586
|
+
updateHeight?.();
|
|
587
|
+
},
|
|
514
588
|
updateHeight,
|
|
515
589
|
dispose: () => {
|
|
516
590
|
findWidgetObserver?.disconnect();
|
|
517
|
-
maxHeightObserver?.disconnect();
|
|
518
591
|
heightDisposable?.dispose();
|
|
519
592
|
safeDispose(editor);
|
|
520
593
|
}
|
|
@@ -598,8 +671,10 @@ var MonacoEditorFactory = class {
|
|
|
598
671
|
createDiffEditor(container, originalContent = "", modifiedContent = "", options = {}) {
|
|
599
672
|
const monaco = this.#monaco;
|
|
600
673
|
const language = options.language || "plaintext";
|
|
601
|
-
|
|
602
|
-
|
|
674
|
+
let models = {
|
|
675
|
+
original: monaco.editor.createModel(originalContent, language),
|
|
676
|
+
modified: monaco.editor.createModel(modifiedContent, language)
|
|
677
|
+
};
|
|
603
678
|
const diffEditor = monaco.editor.createDiffEditor(container, {
|
|
604
679
|
theme: this.#currentTheme,
|
|
605
680
|
readOnly: options.readOnly !== false,
|
|
@@ -613,35 +688,40 @@ var MonacoEditorFactory = class {
|
|
|
613
688
|
renderOverviewRuler: false,
|
|
614
689
|
enableSplitViewResizing: true
|
|
615
690
|
});
|
|
616
|
-
diffEditor.setModel(
|
|
691
|
+
diffEditor.setModel(models);
|
|
617
692
|
return {
|
|
618
693
|
editor: diffEditor,
|
|
619
694
|
setModels(original, modified, lang) {
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
695
|
+
const previous = models;
|
|
696
|
+
models = {
|
|
697
|
+
original: monaco.editor.createModel(original, lang || language),
|
|
698
|
+
modified: monaco.editor.createModel(modified, lang || language)
|
|
699
|
+
};
|
|
700
|
+
diffEditor.setModel(models);
|
|
701
|
+
safeDispose(previous.original);
|
|
702
|
+
safeDispose(previous.modified);
|
|
625
703
|
},
|
|
626
704
|
dispose() {
|
|
627
705
|
safeDispose(diffEditor);
|
|
628
|
-
safeDispose(
|
|
629
|
-
safeDispose(
|
|
706
|
+
safeDispose(models.original);
|
|
707
|
+
safeDispose(models.modified);
|
|
630
708
|
}
|
|
631
709
|
};
|
|
632
710
|
}
|
|
633
711
|
};
|
|
634
|
-
var
|
|
712
|
+
var _factoryPromise = null;
|
|
635
713
|
var _monacoBasePath = null;
|
|
636
714
|
function setMonacoBasePath(basePath) {
|
|
637
715
|
if (typeof basePath === "string" && basePath) _monacoBasePath = basePath;
|
|
638
716
|
}
|
|
639
|
-
|
|
640
|
-
if (!
|
|
641
|
-
initMonaco(_monacoBasePath)
|
|
642
|
-
|
|
717
|
+
function getEditorFactory() {
|
|
718
|
+
if (!_factoryPromise) {
|
|
719
|
+
_factoryPromise = initMonaco(_monacoBasePath).then(() => new MonacoEditorFactory().init()).catch((err) => {
|
|
720
|
+
_factoryPromise = null;
|
|
721
|
+
throw err;
|
|
722
|
+
});
|
|
643
723
|
}
|
|
644
|
-
return
|
|
724
|
+
return _factoryPromise;
|
|
645
725
|
}
|
|
646
726
|
|
|
647
727
|
// src/editor/notebook_search.js
|
|
@@ -1203,14 +1283,14 @@ var SplitPaneContainer = class {
|
|
|
1203
1283
|
this.#container.innerHTML = "";
|
|
1204
1284
|
if (!this.#pane1) return;
|
|
1205
1285
|
if (!this.#isSplit) {
|
|
1206
|
-
this.#pane1.
|
|
1286
|
+
this.#pane1.classList.add("split-pane");
|
|
1207
1287
|
this.#pane1.style.flex = "1 1 0";
|
|
1208
1288
|
this.#pane1.style.minWidth = "0";
|
|
1209
1289
|
this.#container.appendChild(this.#pane1);
|
|
1210
1290
|
this.#container.classList.remove("split-pane-container--split");
|
|
1211
1291
|
} else {
|
|
1212
|
-
this.#pane1.
|
|
1213
|
-
this.#pane2.
|
|
1292
|
+
this.#pane1.classList.add("split-pane");
|
|
1293
|
+
this.#pane2.classList.add("split-pane");
|
|
1214
1294
|
this.#pane1.style.minWidth = "0";
|
|
1215
1295
|
this.#pane2.style.minWidth = "0";
|
|
1216
1296
|
this.#container.appendChild(this.#pane1);
|
|
@@ -1269,6 +1349,8 @@ var SplitPaneContainer = class {
|
|
|
1269
1349
|
}
|
|
1270
1350
|
};
|
|
1271
1351
|
export {
|
|
1352
|
+
DEFAULT_EDITOR_THEME_NAMES,
|
|
1353
|
+
DEFAULT_TAB_DRAG_MIME,
|
|
1272
1354
|
EditorPane,
|
|
1273
1355
|
MonacoEditorFactory,
|
|
1274
1356
|
NotebookSearchBar,
|
|
@@ -1276,9 +1358,13 @@ export {
|
|
|
1276
1358
|
NotebookUndoManager,
|
|
1277
1359
|
SplitPaneContainer,
|
|
1278
1360
|
getEditorFactory,
|
|
1361
|
+
getEditorThemeNames,
|
|
1362
|
+
getTabDragMime,
|
|
1279
1363
|
initMonaco,
|
|
1280
1364
|
monacoReady,
|
|
1281
1365
|
setDefaultLanguage,
|
|
1282
|
-
|
|
1366
|
+
setEditorThemeNames,
|
|
1367
|
+
setMonacoBasePath,
|
|
1368
|
+
setTabDragMime
|
|
1283
1369
|
};
|
|
1284
1370
|
//# sourceMappingURL=editor.js.map
|