gradio-pr-bot commited on
Commit
cdad8ee
·
verified ·
1 Parent(s): 534723f

Upload folder using huggingface_hub

Browse files
6.8.1/highlightedtext/Index.svelte CHANGED
@@ -76,6 +76,7 @@
76
  interactive={gradio.shared.interactive}
77
  show_legend={gradio.props.show_legend}
78
  show_inline_category={gradio.props.show_inline_category}
 
79
  color_map={gradio.props.color_map}
80
  onselect={(detail) => gradio.dispatch("select", detail)}
81
  onchange={() => {
 
76
  interactive={gradio.shared.interactive}
77
  show_legend={gradio.props.show_legend}
78
  show_inline_category={gradio.props.show_inline_category}
79
+ show_whitespaces={gradio.props.show_whitespaces}
80
  color_map={gradio.props.color_map}
81
  onselect={(detail) => gradio.dispatch("select", detail)}
82
  onchange={() => {
6.8.1/highlightedtext/package.json CHANGED
@@ -1,6 +1,6 @@
1
  {
2
  "name": "@gradio/highlightedtext",
3
- "version": "0.11.2",
4
  "description": "Gradio UI packages",
5
  "type": "module",
6
  "author": "",
 
1
  {
2
  "name": "@gradio/highlightedtext",
3
+ "version": "0.11.3",
4
  "description": "Gradio UI packages",
5
  "type": "module",
6
  "author": "",
6.8.1/highlightedtext/shared/HighlightedText.svelte CHANGED
@@ -20,14 +20,17 @@
20
  show_legend = false,
21
  show_inline_category = true,
22
  color_map = {},
 
23
  interactive = false,
24
  onselect,
25
  onchange
26
  }: {
27
  value?: HighlightedToken[];
 
28
  show_legend?: boolean;
29
  show_inline_category?: boolean;
30
  color_map?: Record<string, string>;
 
31
  interactive?: boolean;
32
  onselect?: (data: SelectData) => void;
33
  onchange?: (data: HighlightedToken[]) => void;
@@ -77,7 +80,10 @@
77
  });
78
 
79
  function handle_selection_complete(): void {
80
- if (!selection || !selection.toString().trim()) return;
 
 
 
81
 
82
  const start = selection.getRangeAt(0).startOffset;
83
  const end = selection.getRangeAt(0).endOffset;
@@ -101,7 +107,9 @@
101
  class_or_confidence: mode === "scores" ? 1 : "label"
102
  },
103
  { token: str.substring(end), class_or_confidence: null }
104
- ].filter((e) => e.token.trim() !== "");
 
 
105
 
106
  value = [
107
  ...value.slice(0, active_element_index),
@@ -178,7 +186,7 @@
178
  {#each value as { token, class_or_confidence }, i}
179
  {@const lines = token.split("\n")}
180
  {#each lines as line, j}
181
- {#if line.trim()}
182
  {@const bg_color = get_background_color(class_or_confidence)}
183
  <span class="token-container">
184
  <span
 
20
  show_legend = false,
21
  show_inline_category = true,
22
  color_map = {},
23
+ show_whitespaces = false,
24
  interactive = false,
25
  onselect,
26
  onchange
27
  }: {
28
  value?: HighlightedToken[];
29
+
30
  show_legend?: boolean;
31
  show_inline_category?: boolean;
32
  color_map?: Record<string, string>;
33
+ show_whitespaces?: boolean;
34
  interactive?: boolean;
35
  onselect?: (data: SelectData) => void;
36
  onchange?: (data: HighlightedToken[]) => void;
 
80
  });
81
 
82
  function handle_selection_complete(): void {
83
+ if (!selection) return;
84
+ const text = selection.toString();
85
+ if (!text) return;
86
+ if (!show_whitespaces && !text.trim()) return;
87
 
88
  const start = selection.getRangeAt(0).startOffset;
89
  const end = selection.getRangeAt(0).endOffset;
 
107
  class_or_confidence: mode === "scores" ? 1 : "label"
108
  },
109
  { token: str.substring(end), class_or_confidence: null }
110
+ ].filter((e) =>
111
+ show_whitespaces ? e.token !== "" : e.token.trim() !== ""
112
+ );
113
 
114
  value = [
115
  ...value.slice(0, active_element_index),
 
186
  {#each value as { token, class_or_confidence }, i}
187
  {@const lines = token.split("\n")}
188
  {#each lines as line, j}
189
+ {#if show_whitespaces ? line !== "" : line.trim()}
190
  {@const bg_color = get_background_color(class_or_confidence)}
191
  <span class="token-container">
192
  <span
6.8.1/highlightedtext/types.ts CHANGED
@@ -12,6 +12,7 @@ export interface HighlightedTextProps {
12
  show_inline_category: boolean;
13
  color_map: Record<string, string>;
14
  combine_adjacent: boolean;
 
15
  rtl: boolean;
16
  buttons: (string | CustomButton)[] | null;
17
  }
 
12
  show_inline_category: boolean;
13
  color_map: Record<string, string>;
14
  combine_adjacent: boolean;
15
+ show_whitespaces: boolean;
16
  rtl: boolean;
17
  buttons: (string | CustomButton)[] | null;
18
  }