modern-monaco 0.3.8 → 0.4.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.
@@ -70,12 +70,19 @@ var Workspace = class {
70
70
  get viewState() {
71
71
  return this._viewState;
72
72
  }
73
- async openTextDocument(uri, content) {
73
+ async openTextDocument(uri, content, editor) {
74
74
  const monaco = await this._monaco.promise;
75
- return this._openTextDocument(uri, monaco.editor.getEditors()[0], void 0, content);
75
+ const getEditor = async () => {
76
+ const editors = monaco.editor.getEditors();
77
+ const editor2 = editors.find((e) => e.hasWidgetFocus() || e.hasTextFocus()) ?? editors[0];
78
+ if (!editor2) {
79
+ return new Promise((resolve) => setTimeout(() => resolve(getEditor()), 100));
80
+ }
81
+ return editor2;
82
+ };
83
+ return this._openTextDocument(monaco, editor ?? await getEditor(), uri, void 0, content);
76
84
  }
77
- async _openTextDocument(uri, editor, selectionOrPosition, readonlyContent) {
78
- const monaco = await this._monaco.promise;
85
+ async _openTextDocument(monaco, editor, uri, selectionOrPosition, readonlyContent) {
79
86
  const fs = this._fs;
80
87
  const href = normalizeURL(uri).href;
81
88
  const content = readonlyContent ?? await fs.readTextFile(href);
@@ -102,34 +109,32 @@ var Workspace = class {
102
109
  });
103
110
  Reflect.set(model, "__OB__", true);
104
111
  }
105
- if (editor) {
106
- editor.setModel(model);
107
- editor.updateOptions({ readOnly: typeof readonlyContent === "string" });
108
- if (typeof readonlyContent === "string") {
109
- const disposable = editor.onDidChangeModel(() => {
110
- model.dispose();
111
- disposable.dispose();
112
- });
112
+ editor.setModel(model);
113
+ editor.updateOptions({ readOnly: typeof readonlyContent === "string" });
114
+ if (typeof readonlyContent === "string") {
115
+ const disposable = editor.onDidChangeModel(() => {
116
+ model.dispose();
117
+ disposable.dispose();
118
+ });
119
+ }
120
+ if (selectionOrPosition) {
121
+ if ("startLineNumber" in selectionOrPosition) {
122
+ editor.setSelection(selectionOrPosition);
123
+ } else {
124
+ editor.setPosition(selectionOrPosition);
113
125
  }
114
- if (selectionOrPosition) {
115
- if ("startLineNumber" in selectionOrPosition) {
116
- editor.setSelection(selectionOrPosition);
117
- } else {
118
- editor.setPosition(selectionOrPosition);
119
- }
120
- const pos = editor.getPosition();
121
- if (pos) {
122
- const svp = editor.getScrolledVisiblePosition(new monaco.Position(pos.lineNumber - 7, pos.column));
123
- if (svp) {
124
- editor.setScrollTop(svp.top);
125
- }
126
+ const pos = editor.getPosition();
127
+ if (pos) {
128
+ const svp = editor.getScrolledVisiblePosition(new monaco.Position(pos.lineNumber - 7, pos.column));
129
+ if (svp) {
130
+ editor.setScrollTop(svp.top);
126
131
  }
127
- } else if (viewState) {
128
- editor.restoreViewState(viewState);
129
- }
130
- if (this._history.state.current !== href) {
131
- this._history.push(href);
132
132
  }
133
+ } else if (viewState) {
134
+ editor.restoreViewState(viewState);
135
+ }
136
+ if (this._history.state.current !== href) {
137
+ this._history.push(href);
133
138
  }
134
139
  return model;
135
140
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-monaco",
3
3
  "description": "A modern version of Monaco Editor",
4
- "version": "0.3.8",
4
+ "version": "0.4.1",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
7
7
  "module": "./dist/index.mjs",
@@ -70,23 +70,23 @@
70
70
  },
71
71
  "sideEffects": ["dist/index.mjs"],
72
72
  "devDependencies": {
73
- "@esm.sh/import-map": "0.1.1",
74
- "@shikijs/core": "3.22.0",
75
- "@shikijs/engine-oniguruma": "3.22.0",
76
- "@types/bun": "1.3.9",
77
- "esbuild": "0.27.3",
73
+ "@esm.sh/import-map": "0.4.0",
74
+ "@shikijs/core": "4.0.2",
75
+ "@shikijs/engine-oniguruma": "4.0.2",
76
+ "@types/bun": "1.3.13",
77
+ "esbuild": "0.28.0",
78
78
  "monaco-editor-core": "0.55.1",
79
- "tm-grammars": "1.30.8",
80
- "tm-themes": "1.11.1",
81
- "typescript": "5.9.3",
82
- "vscode-css-languageservice": "6.3.9",
83
- "vscode-html-languageservice": "5.6.1",
84
- "vscode-json-languageservice": "5.7.1",
79
+ "tm-grammars": "1.31.15",
80
+ "tm-themes": "1.12.2",
81
+ "typescript": "6.0.3",
82
+ "vscode-css-languageservice": "6.3.10",
83
+ "vscode-html-languageservice": "5.6.2",
84
+ "vscode-json-languageservice": "5.7.2",
85
85
  "vscode-languageserver-textdocument": "1.0.12",
86
86
  "vscode-languageserver-types": "3.17.5"
87
87
  },
88
88
  "peerDependencies": {
89
- "typescript": ">= 5.0.0"
89
+ "typescript": ">= 6.0.0"
90
90
  },
91
91
  "repository": {
92
92
  "type": "git",
package/types/lsp.d.ts CHANGED
@@ -53,10 +53,27 @@ export interface IReference {
53
53
  url: string;
54
54
  }
55
55
 
56
+ export interface MarkupContent {
57
+ kind: "plaintext" | "markdown";
58
+ value: string;
59
+ }
60
+
61
+ export interface BaselineStatus {
62
+ baseline: false | "low" | "high";
63
+ baseline_low_date?: string;
64
+ baseline_high_date?: string;
65
+ }
66
+
56
67
  export interface IData {
57
68
  name: string;
58
- description?: string;
69
+ description?: string | MarkupContent;
59
70
  references?: IReference[];
71
+ browsers?: string[];
72
+ status?: BaselineStatus;
73
+ }
74
+
75
+ export interface ICSSData extends IData {
76
+ values?: IData[];
60
77
  }
61
78
 
62
79
  export interface IAttributeData extends IData {
@@ -64,6 +81,11 @@ export interface IAttributeData extends IData {
64
81
  values?: IData[];
65
82
  }
66
83
 
84
+ export interface IValueSet {
85
+ name: string;
86
+ values: IData[];
87
+ }
88
+
67
89
  export interface ITagData extends IData {
68
90
  attributes: IAttributeData[];
69
91
  void?: boolean;
@@ -92,31 +114,63 @@ export interface LSPConfig extends LSPLanguageConfig {
92
114
 
93
115
  export type SeverityLevel = "error" | "warning" | "ignore";
94
116
 
117
+ export interface HTMLDataV1 {
118
+ version: 1 | 1.1;
119
+ tags?: ITagData[];
120
+ globalAttributes?: IAttributeData[];
121
+ valueSets?: IValueSet[];
122
+ }
123
+
95
124
  export interface CSSDataV1 {
96
125
  version: 1 | 1.1;
97
- properties?: (IData & Record<string, unknown>)[];
98
- atDirectives?: (IData & Record<string, unknown>)[];
99
- pseudoClasses?: (IData & Record<string, unknown>)[];
100
- pseudoElements?: (IData & Record<string, unknown>)[];
126
+ properties?: (ICSSData & Record<string, unknown>)[];
127
+ atDirectives?: (ICSSData & Record<string, unknown>)[];
128
+ pseudoClasses?: (ICSSData & Record<string, unknown>)[];
129
+ pseudoElements?: (ICSSData & Record<string, unknown>)[];
130
+ }
131
+
132
+ export interface DiagnosticsOptions {
133
+ validate?: boolean;
134
+ codesToIgnore?: (string | number)[];
135
+ filter?: (diagnostic: monacoNS.editor.IMarkerData) => boolean;
101
136
  }
102
137
 
103
138
  declare global {
104
139
  interface LSPLanguageConfig {
140
+ /** HTML language configuration. */
105
141
  html?: {
106
- attributeDefaultValue?: "empty" | "singlequotes" | "doublequotes";
142
+ /** Defines whether the standard HTML tags are shown. Default is true. */
143
+ useDefaultDataProvider?: boolean;
144
+ /** Provides a set of custom data providers. */
145
+ dataProviders?: { [providerId: string]: HTMLDataV1 };
146
+ /** Provides a set of custom HTML tags. */
107
147
  customTags?: ITagData[];
148
+ /** The default value for empty attributes. Default is "empty". */
149
+ attributeDefaultValue?: "empty" | "singlequotes" | "doublequotes";
150
+ /** Whether to hide end tag suggestions. Default is false. */
108
151
  hideEndTagSuggestions?: boolean;
152
+ /** Whether to hide auto complete proposals. Default is false. */
109
153
  hideAutoCompleteProposals?: boolean;
154
+ /** Whether to show the import map code lens. Default is true. */
155
+ importMapCodeLens?: boolean;
156
+ /** Options for the diagnostics. */
157
+ diagnosticsOptions?: DiagnosticsOptions;
110
158
  };
159
+ /** CSS language configuration. */
111
160
  css?: {
112
161
  /** Defines whether the standard CSS properties, at-directives, pseudoClasses and pseudoElements are shown. */
113
162
  useDefaultDataProvider?: boolean;
114
163
  /** Provides a set of custom data providers. */
115
164
  dataProviders?: { [providerId: string]: CSSDataV1 };
165
+ /** A list of valid properties that not defined in the standard CSS properties. */
166
+ validProperties?: string[];
167
+ /** Options for the diagnostics. */
168
+ diagnosticsOptions?: DiagnosticsOptions;
116
169
  };
170
+ /** JSON language configuration. */
117
171
  json?: {
118
- /** By default, the validator will return syntax and semantic errors. Set to false to disable the validator. */
119
- validate?: boolean;
172
+ /** Whether to show the import map code lens. Default is true. */
173
+ importMapCodeLens?: boolean;
120
174
  /** Defines whether comments are allowed or not. Default is disallowed. */
121
175
  allowComments?: boolean;
122
176
  /** A list of known schemas and/or associations of schemas to file names. */
@@ -129,12 +183,17 @@ declare global {
129
183
  schemaValidation?: SeverityLevel;
130
184
  /** The severity of problems that occurred when resolving and loading schemas. Default is "warning". */
131
185
  schemaRequest?: SeverityLevel;
186
+ /** Options for the diagnostics. */
187
+ diagnosticsOptions?: DiagnosticsOptions;
132
188
  };
189
+ /** TypeScript language configuration. */
133
190
  typescript?: {
191
+ /** The default import maps. */
192
+ importMap?: ImportMap;
134
193
  /** The compiler options. */
135
194
  compilerOptions?: ts.CompilerOptions;
136
- /** The global import maps. */
137
- importMap?: ImportMap;
195
+ /** Options for the diagnostics. */
196
+ diagnosticsOptions?: DiagnosticsOptions;
138
197
  };
139
198
  }
140
199
  }
@@ -1,2 +1,2 @@
1
- export type TextmateThemeName = "andromeeda" | "aurora-x" | "ayu-dark" | "ayu-light" | "ayu-mirage" | "catppuccin-frappe" | "catppuccin-latte" | "catppuccin-macchiato" | "catppuccin-mocha" | "dark-plus" | "dracula" | "dracula-soft" | "everforest-dark" | "everforest-light" | "github-dark" | "github-dark-default" | "github-dark-dimmed" | "github-dark-high-contrast" | "github-light" | "github-light-default" | "github-light-high-contrast" | "gruvbox-dark-hard" | "gruvbox-dark-medium" | "gruvbox-dark-soft" | "gruvbox-light-hard" | "gruvbox-light-medium" | "gruvbox-light-soft" | "horizon" | "houston" | "kanagawa-dragon" | "kanagawa-lotus" | "kanagawa-wave" | "laserwave" | "light-plus" | "material-theme" | "material-theme-darker" | "material-theme-lighter" | "material-theme-ocean" | "material-theme-palenight" | "min-dark" | "min-light" | "monokai" | "night-owl" | "night-owl-light" | "nord" | "one-dark-pro" | "one-light" | "plastic" | "poimandres" | "red" | "rose-pine" | "rose-pine-dawn" | "rose-pine-moon" | "slack-dark" | "slack-ochin" | "snazzy-light" | "solarized-dark" | "solarized-light" | "synthwave-84" | "tokyo-night" | "vesper" | "vitesse-black" | "vitesse-dark" | "vitesse-light";
2
- export type TextmateGrammarName = "abap" | "actionscript-3" | "ada" | "angular-html" | "angular-ts" | "apache" | "apex" | "apl" | "applescript" | "ara" | "asciidoc" | "asm" | "astro" | "awk" | "ballerina" | "bat" | "beancount" | "berry" | "bibtex" | "bicep" | "blade" | "bsl" | "c" | "c3" | "cadence" | "cairo" | "clarity" | "clojure" | "cmake" | "cobol" | "codeowners" | "codeql" | "coffee" | "common-lisp" | "coq" | "cpp" | "crystal" | "csharp" | "css" | "csv" | "cue" | "cypher" | "d" | "dart" | "dax" | "desktop" | "diff" | "docker" | "dotenv" | "dream-maker" | "edge" | "elixir" | "elm" | "emacs-lisp" | "erb" | "erlang" | "fennel" | "fish" | "fluent" | "fortran-fixed-form" | "fortran-free-form" | "fsharp" | "gdresource" | "gdscript" | "gdshader" | "genie" | "gherkin" | "git-commit" | "git-rebase" | "gleam" | "glimmer-js" | "glimmer-ts" | "glsl" | "gn" | "gnuplot" | "go" | "graphql" | "groovy" | "hack" | "haml" | "handlebars" | "haskell" | "haxe" | "hcl" | "hjson" | "hlsl" | "html" | "html-derivative" | "http" | "hurl" | "hxml" | "hy" | "imba" | "ini" | "java" | "javascript" | "jinja" | "jison" | "json" | "json5" | "jsonc" | "jsonl" | "jsonnet" | "jssm" | "jsx" | "julia" | "kdl" | "kotlin" | "kusto" | "latex" | "lean" | "less" | "liquid" | "llvm" | "log" | "logo" | "lua" | "luau" | "make" | "markdown" | "marko" | "matlab" | "mdc" | "mdx" | "mermaid" | "mipsasm" | "mojo" | "moonbit" | "move" | "narrat" | "nextflow" | "nginx" | "nim" | "nix" | "nushell" | "objective-c" | "objective-cpp" | "ocaml" | "odin" | "openscad" | "pascal" | "perl" | "php" | "pkl" | "plsql" | "po" | "polar" | "postcss" | "powerquery" | "powershell" | "prisma" | "prolog" | "proto" | "pug" | "puppet" | "purescript" | "python" | "qml" | "qmldir" | "qss" | "r" | "racket" | "raku" | "razor" | "reg" | "regexp" | "rel" | "riscv" | "ron" | "rosmsg" | "rst" | "ruby" | "rust" | "sas" | "sass" | "scala" | "scheme" | "scss" | "sdbl" | "shaderlab" | "shellscript" | "shellsession" | "smalltalk" | "solidity" | "soy" | "sparql" | "splunk" | "sql" | "ssh-config" | "stata" | "stylus" | "surrealql" | "svelte" | "swift" | "system-verilog" | "systemd" | "talonscript" | "tasl" | "tcl" | "templ" | "terraform" | "tex" | "toml" | "ts-tags" | "tsv" | "tsx" | "turtle" | "twig" | "typescript" | "typespec" | "typst" | "v" | "vala" | "vb" | "verilog" | "vhdl" | "viml" | "vue" | "vue-html" | "vue-vine" | "vyper" | "wasm" | "wenyan" | "wgsl" | "wikitext" | "wit" | "wolfram" | "xml" | "xsl" | "yaml" | "zenscript" | "zig";
1
+ export type TextmateThemeName = "andromeeda" | "aurora-x" | "ayu-dark" | "ayu-light" | "ayu-mirage" | "catppuccin-frappe" | "catppuccin-latte" | "catppuccin-macchiato" | "catppuccin-mocha" | "dark-plus" | "dracula" | "dracula-soft" | "everforest-dark" | "everforest-light" | "github-dark" | "github-dark-default" | "github-dark-dimmed" | "github-dark-high-contrast" | "github-light" | "github-light-default" | "github-light-high-contrast" | "gruvbox-dark-hard" | "gruvbox-dark-medium" | "gruvbox-dark-soft" | "gruvbox-light-hard" | "gruvbox-light-medium" | "gruvbox-light-soft" | "horizon" | "horizon-bright" | "houston" | "kanagawa-dragon" | "kanagawa-lotus" | "kanagawa-wave" | "laserwave" | "light-plus" | "material-theme" | "material-theme-darker" | "material-theme-lighter" | "material-theme-ocean" | "material-theme-palenight" | "min-dark" | "min-light" | "monokai" | "night-owl" | "night-owl-light" | "nord" | "one-dark-pro" | "one-light" | "plastic" | "poimandres" | "red" | "rose-pine" | "rose-pine-dawn" | "rose-pine-moon" | "slack-dark" | "slack-ochin" | "snazzy-light" | "solarized-dark" | "solarized-light" | "synthwave-84" | "tokyo-night" | "vesper" | "vitesse-black" | "vitesse-dark" | "vitesse-light";
2
+ export type TextmateGrammarName = "abap" | "actionscript-3" | "ada" | "angular-html" | "angular-ts" | "apache" | "apex" | "apl" | "applescript" | "ara" | "asciidoc" | "asm" | "astro" | "awk" | "ballerina" | "bat" | "beancount" | "berry" | "bibtex" | "bicep" | "bird2" | "blade" | "bsl" | "c" | "c3" | "cadence" | "cairo" | "clarity" | "clojure" | "cmake" | "cobol" | "codeowners" | "codeql" | "coffee" | "common-lisp" | "coq" | "cpp" | "crystal" | "csharp" | "css" | "csv" | "cue" | "cypher" | "d" | "dart" | "dax" | "desktop" | "diff" | "docker" | "dotenv" | "dream-maker" | "edge" | "elixir" | "elm" | "emacs-lisp" | "erb" | "erlang" | "fennel" | "fish" | "fluent" | "fortran-fixed-form" | "fortran-free-form" | "fsharp" | "gdresource" | "gdscript" | "gdshader" | "genie" | "gherkin" | "git-commit" | "git-rebase" | "gleam" | "glimmer-js" | "glimmer-ts" | "glsl" | "gn" | "gnuplot" | "go" | "graphql" | "groovy" | "hack" | "haml" | "handlebars" | "haskell" | "haxe" | "hcl" | "hjson" | "hlsl" | "html" | "html-derivative" | "http" | "hurl" | "hxml" | "hy" | "imba" | "ini" | "java" | "javascript" | "jinja" | "jison" | "json" | "json5" | "jsonc" | "jsonl" | "jsonnet" | "jssm" | "jsx" | "julia" | "just" | "kdl" | "kotlin" | "kusto" | "latex" | "lean" | "less" | "liquid" | "llvm" | "log" | "logo" | "lua" | "luau" | "make" | "markdown" | "marko" | "matlab" | "mdc" | "mdx" | "mermaid" | "mipsasm" | "mojo" | "moonbit" | "move" | "narrat" | "nextflow" | "nextflow-groovy" | "nginx" | "nim" | "nix" | "nushell" | "objective-c" | "objective-cpp" | "ocaml" | "odin" | "openscad" | "pascal" | "perl" | "php" | "pkl" | "plsql" | "po" | "polar" | "postcss" | "powerquery" | "powershell" | "prisma" | "prolog" | "proto" | "pug" | "puppet" | "purescript" | "python" | "qml" | "qmldir" | "qss" | "r" | "racket" | "raku" | "razor" | "reg" | "regexp" | "rel" | "riscv" | "ron" | "rosmsg" | "rst" | "ruby" | "rust" | "sas" | "sass" | "scala" | "scheme" | "scss" | "sdbl" | "shaderlab" | "shellscript" | "shellsession" | "smalltalk" | "solidity" | "soy" | "sparql" | "splunk" | "sql" | "ssh-config" | "stata" | "stylus" | "surrealql" | "svelte" | "swift" | "system-verilog" | "systemd" | "talonscript" | "tasl" | "tcl" | "templ" | "terraform" | "tex" | "toml" | "ts-tags" | "tsv" | "tsx" | "turtle" | "twig" | "typescript" | "typespec" | "typst" | "v" | "vala" | "vb" | "verilog" | "vhdl" | "viml" | "vue" | "vue-html" | "vue-vine" | "vyper" | "wasm" | "wenyan" | "wgsl" | "wikitext" | "wit" | "wolfram" | "xml" | "xsl" | "yaml" | "zenscript" | "zig";
package/types/vscode.d.ts CHANGED
@@ -229,6 +229,12 @@ export interface QuickPickOptions {
229
229
  */
230
230
  placeHolder?: string;
231
231
 
232
+ /**
233
+ * Optional text that provides instructions or context to the user.
234
+ * The prompt is displayed below the input box and above the list of items.
235
+ */
236
+ prompt?: string;
237
+
232
238
  /**
233
239
  * Set to `true` to keep the picker open when focus moves to another part of the editor or to another window.
234
240
  * This setting is ignored on iPad and is always false.
@@ -20,7 +20,7 @@ export class Workspace {
20
20
  readonly fs: FileSystem;
21
21
  readonly history: WorkspaceHistory;
22
22
  readonly viewState: WorkspaceViewState;
23
- openTextDocument(uri: string | URL, content?: string): Promise<editor.ITextModel>;
23
+ openTextDocument(uri: string | URL, content?: string, editor?: editor.ICodeEditor): Promise<editor.ITextModel>;
24
24
  showInputBox: typeof showInputBox;
25
25
  showQuickPick: typeof showQuickPick;
26
26
  }