@gradio/code 0.10.17 → 0.11.0

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # @gradio/code
2
2
 
3
+ ## 0.11.0
4
+
5
+ ### Features
6
+
7
+ - [#10643](https://github.com/gradio-app/gradio/pull/10643) [`f0a920c`](https://github.com/gradio-app/gradio/commit/f0a920c4934880645fbad783077ae9c7519856ce) - added a show_line_numbers to toggle line numbers in gr.Code(). Thanks @lalitx17!
8
+
9
+ ## 0.10.18
10
+
11
+ ### Dependency updates
12
+
13
+ - @gradio/upload@0.15.2
14
+ - @gradio/statustracker@0.10.4
15
+ - @gradio/atoms@0.13.3
16
+
3
17
  ## 0.10.17
4
18
 
5
19
  ### Dependency updates
package/Index.svelte CHANGED
@@ -39,6 +39,7 @@
39
39
  export let scale: number | null = null;
40
40
  export let min_width: number | undefined = undefined;
41
41
  export let wrap_lines = false;
42
+ export let show_line_numbers = true;
42
43
 
43
44
  export let interactive: boolean;
44
45
 
@@ -91,6 +92,7 @@
91
92
  {max_lines}
92
93
  {dark_mode}
93
94
  {wrap_lines}
95
+ {show_line_numbers}
94
96
  readonly={!interactive}
95
97
  on:blur={() => gradio.dispatch("blur")}
96
98
  on:focus={() => gradio.dispatch("focus")}
package/dist/Index.svelte CHANGED
@@ -26,6 +26,7 @@ export let loading_status;
26
26
  export let scale = null;
27
27
  export let min_width = void 0;
28
28
  export let wrap_lines = false;
29
+ export let show_line_numbers = true;
29
30
  export let interactive;
30
31
  let dark_mode = gradio.theme === "dark";
31
32
  function handle_change() {
@@ -76,6 +77,7 @@ $:
76
77
  {max_lines}
77
78
  {dark_mode}
78
79
  {wrap_lines}
80
+ {show_line_numbers}
79
81
  readonly={!interactive}
80
82
  on:blur={() => gradio.dispatch("blur")}
81
83
  on:focus={() => gradio.dispatch("focus")}
@@ -29,6 +29,7 @@ declare const __propDef: {
29
29
  scale?: (number | null) | undefined;
30
30
  min_width?: number | undefined;
31
31
  wrap_lines?: boolean | undefined;
32
+ show_line_numbers?: boolean | undefined;
32
33
  interactive: boolean;
33
34
  };
34
35
  events: {
@@ -3,7 +3,8 @@ import {
3
3
  EditorView,
4
4
  ViewUpdate,
5
5
  keymap,
6
- placeholder as placeholderExt
6
+ placeholder as placeholderExt,
7
+ lineNumbers
7
8
  } from "@codemirror/view";
8
9
  import { StateEffect, EditorState } from "@codemirror/state";
9
10
  import { indentWithTab } from "@codemirror/commands";
@@ -23,6 +24,7 @@ export let use_tab = true;
23
24
  export let readonly = false;
24
25
  export let placeholder = void 0;
25
26
  export let wrap_lines = false;
27
+ export let show_line_numbers = true;
26
28
  const dispatch = createEventDispatcher();
27
29
  let lang_extension;
28
30
  let element;
@@ -114,7 +116,8 @@ function get_extensions() {
114
116
  use_tab,
115
117
  placeholder,
116
118
  readonly,
117
- lang_extension
119
+ lang_extension,
120
+ show_line_numbers
118
121
  ),
119
122
  FontTheme,
120
123
  ...get_theme(),
@@ -159,7 +162,7 @@ function create_editor_state(_value) {
159
162
  extensions: get_extensions()
160
163
  });
161
164
  }
162
- function get_base_extensions(basic2, use_tab2, placeholder2, readonly2, lang) {
165
+ function get_base_extensions(basic2, use_tab2, placeholder2, readonly2, lang, show_line_numbers2) {
163
166
  const extensions2 = [
164
167
  EditorView.editable.of(!readonly2),
165
168
  EditorState.readOnly.of(readonly2),
@@ -177,6 +180,9 @@ function get_base_extensions(basic2, use_tab2, placeholder2, readonly2, lang) {
177
180
  if (lang) {
178
181
  extensions2.push(lang);
179
182
  }
183
+ if (show_line_numbers2) {
184
+ extensions2.push(lineNumbers());
185
+ }
180
186
  extensions2.push(EditorView.updateListener.of(handle_change));
181
187
  if (wrap_lines) {
182
188
  extensions2.push(EditorView.lineWrapping);
@@ -14,6 +14,7 @@ declare const __propDef: {
14
14
  readonly?: boolean | undefined;
15
15
  placeholder?: string | HTMLElement | null | undefined;
16
16
  wrap_lines?: boolean | undefined;
17
+ show_line_numbers?: boolean | undefined;
17
18
  };
18
19
  events: {
19
20
  change: CustomEvent<string>;
@@ -6,7 +6,6 @@ import { history, defaultKeymap, historyKeymap } from "@codemirror/commands";
6
6
  import { closeBrackets, closeBracketsKeymap, completionKeymap } from "@codemirror/autocomplete";
7
7
  import { lintKeymap } from "@codemirror/lint";
8
8
  export const basicSetup = /*@__PURE__*/ (() => [
9
- lineNumbers(),
10
9
  highlightSpecialChars(),
11
10
  history(),
12
11
  foldGutter(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gradio/code",
3
- "version": "0.10.17",
3
+ "version": "0.11.0",
4
4
  "description": "Gradio UI packages",
5
5
  "type": "module",
6
6
  "author": "",
@@ -27,12 +27,12 @@
27
27
  "cm6-theme-basic-dark": "^0.2.0",
28
28
  "cm6-theme-basic-light": "^0.2.0",
29
29
  "codemirror": "^6.0.1",
30
- "@gradio/atoms": "^0.13.2",
31
- "@gradio/icons": "^0.10.0",
32
- "@gradio/upload": "^0.15.1",
30
+ "@gradio/atoms": "^0.13.3",
31
+ "@gradio/statustracker": "^0.10.4",
32
+ "@gradio/upload": "^0.15.2",
33
+ "@gradio/wasm": "^0.17.3",
33
34
  "@gradio/utils": "^0.10.1",
34
- "@gradio/statustracker": "^0.10.3",
35
- "@gradio/wasm": "^0.17.3"
35
+ "@gradio/icons": "^0.10.0"
36
36
  },
37
37
  "main_changeset": true,
38
38
  "main": "./Index.svelte",
@@ -4,7 +4,8 @@
4
4
  EditorView,
5
5
  ViewUpdate,
6
6
  keymap,
7
- placeholder as placeholderExt
7
+ placeholder as placeholderExt,
8
+ lineNumbers
8
9
  } from "@codemirror/view";
9
10
  import { StateEffect, EditorState, type Extension } from "@codemirror/state";
10
11
  import { indentWithTab } from "@codemirror/commands";
@@ -26,6 +27,7 @@
26
27
  export let readonly = false;
27
28
  export let placeholder: string | HTMLElement | null | undefined = undefined;
28
29
  export let wrap_lines = false;
30
+ export let show_line_numbers = true;
29
31
 
30
32
  const dispatch = createEventDispatcher<{
31
33
  change: string;
@@ -131,7 +133,8 @@
131
133
  use_tab,
132
134
  placeholder,
133
135
  readonly,
134
- lang_extension
136
+ lang_extension,
137
+ show_line_numbers
135
138
  ),
136
139
  FontTheme,
137
140
  ...get_theme(),
@@ -184,7 +187,8 @@
184
187
  use_tab: boolean,
185
188
  placeholder: string | HTMLElement | null | undefined,
186
189
  readonly: boolean,
187
- lang: Extension | null | undefined
190
+ lang: Extension | null | undefined,
191
+ show_line_numbers: boolean
188
192
  ): Extension[] {
189
193
  const extensions: Extension[] = [
190
194
  EditorView.editable.of(!readonly),
@@ -205,10 +209,15 @@
205
209
  extensions.push(lang);
206
210
  }
207
211
 
212
+ if (show_line_numbers) {
213
+ extensions.push(lineNumbers());
214
+ }
215
+
208
216
  extensions.push(EditorView.updateListener.of(handle_change));
209
217
  if (wrap_lines) {
210
218
  extensions.push(EditorView.lineWrapping);
211
219
  }
220
+
212
221
  return extensions;
213
222
  }
214
223
 
@@ -25,7 +25,6 @@ import {
25
25
  import { lintKeymap } from "@codemirror/lint";
26
26
 
27
27
  export const basicSetup: Extension = /*@__PURE__*/ ((): Extension[] => [
28
- lineNumbers(),
29
28
  highlightSpecialChars(),
30
29
  history(),
31
30
  foldGutter(),