@elyra/canvas 12.40.1 → 12.42.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.
Files changed (173) hide show
  1. package/dist/{_baseIteratee-05ccf6a8.js → _baseIteratee-148093b7.js} +3 -3
  2. package/dist/{_baseIteratee-05ccf6a8.js.map → _baseIteratee-148093b7.js.map} +1 -1
  3. package/dist/{canvas-constants-079172c0.js → canvas-constants-13b58448.js} +2 -2
  4. package/dist/{canvas-constants-079172c0.js.map → canvas-constants-13b58448.js.map} +1 -1
  5. package/dist/canvas-controller-a53943e4.js +2 -0
  6. package/dist/canvas-controller-a53943e4.js.map +1 -0
  7. package/dist/canvas-controller-cb1d7420.js +2 -0
  8. package/dist/canvas-controller-cb1d7420.js.map +1 -0
  9. package/dist/common-canvas-42027a3f.js +2 -0
  10. package/dist/common-canvas-42027a3f.js.map +1 -0
  11. package/dist/common-canvas-f758ff42.js +2 -0
  12. package/dist/common-canvas-f758ff42.js.map +1 -0
  13. package/dist/common-canvas.es.js +1 -1
  14. package/dist/common-canvas.es.js.map +1 -1
  15. package/dist/common-canvas.js +1 -1
  16. package/dist/common-canvas.js.map +1 -1
  17. package/dist/common-properties-2e1b7ec7.js +2 -0
  18. package/dist/common-properties-2e1b7ec7.js.map +1 -0
  19. package/dist/common-properties-5e8870e3.js +2 -0
  20. package/dist/common-properties-5e8870e3.js.map +1 -0
  21. package/dist/context-menu-wrapper-49f9a1af.js +2 -0
  22. package/dist/context-menu-wrapper-49f9a1af.js.map +1 -0
  23. package/dist/context-menu-wrapper-5d6a399f.js +2 -0
  24. package/dist/context-menu-wrapper-5d6a399f.js.map +1 -0
  25. package/dist/{datarecord-metadata-v3-schema-59505bc5.js → datarecord-metadata-v3-schema-98ec66e9.js} +2 -2
  26. package/dist/{datarecord-metadata-v3-schema-59505bc5.js.map → datarecord-metadata-v3-schema-98ec66e9.js.map} +1 -1
  27. package/dist/{flexible-table-5ee2a42b.js → flexible-table-35e9922a.js} +2 -2
  28. package/dist/{flexible-table-5ee2a42b.js.map → flexible-table-35e9922a.js.map} +1 -1
  29. package/dist/{flexible-table-562ae288.js → flexible-table-7c7de0f9.js} +1 -1
  30. package/dist/{flexible-table-562ae288.js.map → flexible-table-7c7de0f9.js.map} +1 -1
  31. package/dist/{icon-0390f1fe.js → icon-9edff40c.js} +2 -2
  32. package/dist/{icon-0390f1fe.js.map → icon-9edff40c.js.map} +1 -1
  33. package/dist/{index-fe8d4201.js → index-94fec521.js} +2 -2
  34. package/dist/index-94fec521.js.map +1 -0
  35. package/dist/index-e2f8a935.js +2 -0
  36. package/dist/index-e2f8a935.js.map +1 -0
  37. package/dist/{isArrayLikeObject-36898fcb.js → isArrayLikeObject-7a30aa4b.js} +2 -2
  38. package/dist/{isArrayLikeObject-36898fcb.js.map → isArrayLikeObject-7a30aa4b.js.map} +1 -1
  39. package/dist/lib/canvas-controller.es.js +1 -1
  40. package/dist/lib/canvas-controller.js +1 -1
  41. package/dist/lib/canvas.es.js +1 -1
  42. package/dist/lib/canvas.js +1 -1
  43. package/dist/lib/context-menu.es.js +1 -1
  44. package/dist/lib/context-menu.js +1 -1
  45. package/dist/lib/properties/field-picker.es.js +1 -1
  46. package/dist/lib/properties/field-picker.js +1 -1
  47. package/dist/lib/properties/flexible-table.es.js +1 -1
  48. package/dist/lib/properties/flexible-table.js +1 -1
  49. package/dist/lib/properties.es.js +1 -1
  50. package/dist/lib/properties.js +1 -1
  51. package/dist/lib/tooltip.es.js +1 -1
  52. package/dist/lib/tooltip.es.js.map +1 -1
  53. package/dist/lib/tooltip.js +1 -1
  54. package/dist/lib/tooltip.js.map +1 -1
  55. package/dist/styles/common-canvas.min.css +1 -1
  56. package/dist/styles/common-canvas.min.css.map +1 -1
  57. package/dist/toolbar-6acda0a2.js +2 -0
  58. package/dist/toolbar-6acda0a2.js.map +1 -0
  59. package/dist/toolbar-d5647da2.js +2 -0
  60. package/dist/toolbar-d5647da2.js.map +1 -0
  61. package/locales/common-properties/locales/de.json +1 -0
  62. package/locales/common-properties/locales/es.json +1 -0
  63. package/locales/common-properties/locales/fr.json +1 -0
  64. package/locales/common-properties/locales/it.json +1 -0
  65. package/locales/common-properties/locales/ja.json +1 -0
  66. package/locales/common-properties/locales/ko.json +1 -0
  67. package/locales/common-properties/locales/pt-br.json +1 -0
  68. package/locales/common-properties/locales/sv.json +1 -0
  69. package/locales/common-properties/locales/zh-CN.json +1 -0
  70. package/locales/common-properties/locales/zh-TW.json +1 -0
  71. package/package.json +12 -4
  72. package/src/color-picker/color-picker.jsx +92 -17
  73. package/src/command-actions/arrangeLayoutAction.js +7 -6
  74. package/src/command-actions/attachNodeToLinksAction.js +4 -4
  75. package/src/command-actions/collapseSuperNodeInPlaceAction.js +5 -5
  76. package/src/command-actions/colorSelectedObjectsAction.js +4 -4
  77. package/src/command-actions/commonPropertiesAction.js +1 -1
  78. package/src/command-actions/convertSuperNodeExternalToLocalAction.js +4 -4
  79. package/src/command-actions/convertSuperNodeLocalToExternalAction.js +4 -4
  80. package/src/command-actions/createAutoNodeAction.js +14 -5
  81. package/src/command-actions/createCommentAction.js +4 -10
  82. package/src/command-actions/createCommentLinkAction.js +4 -4
  83. package/src/command-actions/createNodeAction.js +13 -4
  84. package/src/command-actions/createNodeAttachLinksAction.js +4 -4
  85. package/src/command-actions/createNodeLinkAction.js +13 -4
  86. package/src/command-actions/createNodeLinkDetachedAction.js +4 -4
  87. package/src/command-actions/createNodeOnLinkAction.js +4 -4
  88. package/src/command-actions/createSuperNodeAction.js +7 -7
  89. package/src/command-actions/deconstructSuperNodeAction.js +5 -5
  90. package/src/command-actions/deleteLinkAction.js +4 -4
  91. package/src/command-actions/deleteObjectsAction.js +15 -6
  92. package/src/command-actions/disconnectObjectsAction.js +13 -4
  93. package/src/command-actions/displayPreviousPipelineAction.js +4 -4
  94. package/src/command-actions/displaySubPipelineAction.js +4 -4
  95. package/src/command-actions/editCommentAction.js +4 -4
  96. package/src/command-actions/editDecorationLabelAction.js +4 -4
  97. package/src/command-actions/expandSuperNodeInPlaceAction.js +5 -5
  98. package/src/command-actions/insertNodeIntoLinkAction.js +4 -4
  99. package/src/command-actions/moveObjectsAction.js +4 -4
  100. package/src/command-actions/pasteAction.js +16 -7
  101. package/src/command-actions/saveToPaletteAction.js +4 -4
  102. package/src/command-actions/setLinksStyleAction.js +4 -4
  103. package/src/command-actions/setNodeLabelAction.js +4 -4
  104. package/src/command-actions/setObjectsStyleAction.js +4 -4
  105. package/src/command-actions/sizeAndPositionObjectsAction.js +4 -4
  106. package/src/command-actions/updateLinkAction.js +4 -4
  107. package/src/common-canvas/canvas-controller-menu-utils.js +1 -1
  108. package/src/common-canvas/canvas-controller.js +78 -62
  109. package/src/common-canvas/cc-central-items.jsx +1 -1
  110. package/src/common-canvas/cc-context-toolbar.jsx +9 -13
  111. package/src/common-canvas/cc-toolbar.jsx +2 -0
  112. package/src/common-canvas/svg-canvas-d3.scss +1 -1
  113. package/src/common-canvas/svg-canvas-renderer.js +6 -2
  114. package/src/common-canvas/svg-canvas-utils-drag-det-link.js +8 -1
  115. package/src/common-canvas/svg-canvas-utils-drag-new-link.js +1 -1
  116. package/src/common-properties/components/table-buttons/table-buttons.scss +0 -1
  117. package/src/common-properties/components/wide-flyout/wide-flyout.scss +1 -2
  118. package/src/common-properties/constants/form-constants.js +1 -0
  119. package/src/common-properties/controls/control-factory.js +6 -1
  120. package/src/common-properties/controls/controls.scss +1 -0
  121. package/src/common-properties/controls/expression/expression-builder/expression-builder.jsx +32 -26
  122. package/src/common-properties/controls/expression/expression.jsx +146 -117
  123. package/src/common-properties/controls/expression/expression.scss +43 -45
  124. package/src/common-properties/controls/expression/languages/CLEM-hint.js +86 -159
  125. package/src/common-properties/controls/expression/languages/python-hint.js +53 -104
  126. package/src/common-properties/controls/expression/languages/r-hint.js +55 -130
  127. package/src/{toolbar/toolbar-utils.js → common-properties/controls/slider/index.js} +2 -17
  128. package/src/common-properties/controls/slider/slider.jsx +96 -0
  129. package/src/common-properties/controls/slider/slider.scss +44 -0
  130. package/src/common-properties/form/ControlInfo.js +6 -0
  131. package/src/common-properties/form/EditorForm.js +2 -0
  132. package/src/common-properties/form/ParameterInfo.js +8 -0
  133. package/src/common-properties/properties-controller.js +16 -5
  134. package/src/context-menu/common-context-menu.jsx +4 -1
  135. package/src/index.js +12 -2
  136. package/src/object-model/redux/canvas-store.js +4 -3
  137. package/src/toolbar/toolbar-action-item.jsx +90 -314
  138. package/src/toolbar/toolbar-button-item.jsx +354 -0
  139. package/src/toolbar/toolbar-divider-item.jsx +3 -4
  140. package/src/toolbar/toolbar-overflow-item.jsx +82 -36
  141. package/src/toolbar/toolbar-sub-menu-item.jsx +235 -0
  142. package/src/toolbar/toolbar-sub-menu.jsx +254 -0
  143. package/src/toolbar/toolbar-sub-panel.jsx +81 -0
  144. package/src/toolbar/toolbar-sub-utils.js +77 -0
  145. package/src/toolbar/toolbar.jsx +330 -146
  146. package/src/toolbar/toolbar.scss +22 -15
  147. package/src/tooltip/tooltip.jsx +21 -2
  148. package/stats.html +1 -1
  149. package/dist/canvas-controller-1e71b405.js +0 -2
  150. package/dist/canvas-controller-1e71b405.js.map +0 -1
  151. package/dist/canvas-controller-4bed5320.js +0 -2
  152. package/dist/canvas-controller-4bed5320.js.map +0 -1
  153. package/dist/common-canvas-318df796.js +0 -2
  154. package/dist/common-canvas-318df796.js.map +0 -1
  155. package/dist/common-canvas-d41ba910.js +0 -2
  156. package/dist/common-canvas-d41ba910.js.map +0 -1
  157. package/dist/common-properties-6e904e3b.js +0 -2
  158. package/dist/common-properties-6e904e3b.js.map +0 -1
  159. package/dist/common-properties-c91bfb31.js +0 -2
  160. package/dist/common-properties-c91bfb31.js.map +0 -1
  161. package/dist/context-menu-wrapper-3a7fdec8.js +0 -2
  162. package/dist/context-menu-wrapper-3a7fdec8.js.map +0 -1
  163. package/dist/context-menu-wrapper-fc85d853.js +0 -2
  164. package/dist/context-menu-wrapper-fc85d853.js.map +0 -1
  165. package/dist/index-8e8b8729.js +0 -2
  166. package/dist/index-8e8b8729.js.map +0 -1
  167. package/dist/index-fe8d4201.js.map +0 -1
  168. package/dist/toolbar-b01e6749.js +0 -2
  169. package/dist/toolbar-b01e6749.js.map +0 -1
  170. package/dist/toolbar-fd4e4a3a.js +0 -2
  171. package/dist/toolbar-fd4e4a3a.js.map +0 -1
  172. package/src/toolbar/toolbar-action-sub-area.jsx +0 -126
  173. package/src/toolbar/toolbar-overflow-menu.jsx +0 -77
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2017-2023 Elyra Authors
2
+ * Copyright 2017-2024 Elyra Authors
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -15,16 +15,10 @@
15
15
  */
16
16
 
17
17
  /* eslint no-useless-escape: "off" */
18
+ import { LanguageSupport, StreamLanguage } from "@codemirror/language";
19
+ import { completeFromList } from "@codemirror/autocomplete";
18
20
 
19
- let CodeMirror;
20
- function register(cm) {
21
- CodeMirror = cm;
22
- CodeMirror.registerHelper("hint", "CLEM", CLEMHint);
23
- CodeMirror.defineMode("CLEM", defineMode);
24
- CodeMirror.defineMIME("text/x-CLEM", "CLEM");
25
- }
26
-
27
- const CLEMKeywords = ("@BLANK @DIFF1 @DIFF2 @FIELD @FIELDS_BETWEEN @FIELDS_MATCHING " +
21
+ const keywords = ("@BLANK @DIFF1 @DIFF2 @FIELD @FIELDS_BETWEEN @FIELDS_MATCHING " +
28
22
  "@GLOBAL_MAX @GLOBAL_MEAN @GLOBAL_MIN @GLOBAL_SDEV @GLOBAL_SUM @INDEX @LAST_NON_BLANK " +
29
23
  "@MAX @MEAN @MIN @MULTI_RESPONSE_SET @NULL @OFFSET @PARTITION_FIELD @PREDICTED " +
30
24
  "@SDEV @SINCE @SINCE0 @SUM @TARGET @TESTING_PARTITION @THIS @TODAY @TRAINING_PARTITION " +
@@ -50,173 +44,106 @@ const CLEMKeywords = ("@BLANK @DIFF1 @DIFF2 @FIELD @FIELDS_BETWEEN @FIELDS_MATCH
50
44
  "substring_between sum_n tan tanh testbit time_before time_hours_difference time_in_hours " +
51
45
  "time_in_mins time_in_secs time_mins_difference").split(" ");
52
46
 
53
- function CLEMHint(editor, options) {
54
- return scriptHint(editor, CLEMKeywords,
55
- function(e, cur) {
56
- return e.getTokenAt(cur);
57
- },
58
- options);
59
- }
47
+ const clemKeywords = keywords.map((keyword) => ({ label: keyword, type: "keyword" }));
60
48
 
61
- function scriptHint(editor, keywords, getToken, options) {
62
- // Find the token at the cursor
63
- var cur = editor.getCursor();
64
- var token = getToken(editor, cur);
65
- if ((/\b(?:string|comment)\b/).test(token.type)) {
66
- return null;
49
+ const isSpecialChar = /[\[\]{}\(\),;\:\.]/;
50
+ const isDigit = /\d/;
51
+ const isNumberChar = /[\w\.]/;
52
+ const isWordChar = /[\w\$_]/;
53
+ const isOperatorChar = /[+\-*&%=<>!?|\/]/;
54
+
55
+ function tokenResolve(stream, state) {
56
+ const ch = stream.next();
57
+ if (ch === "#" && state.startOfLine) {
58
+ stream.skipToEnd();
59
+ return "meta";
67
60
  }
68
- token.state = CodeMirror.innerMode(editor.getMode(), token.state).state;
69
-
70
- // If it's not a 'word-style' token, ignore the token.
71
- if (!((/^[\w$_@]*$/).test(token.string))) {
72
- token = { start: cur.ch, end: cur.ch, string: "", state: token.state,
73
- type: token.string === "." ? "property" : null };
74
- } else if (token.end > cur.ch) {
75
- token.end = cur.ch;
76
- token.string = token.string.slice(0, cur.ch - token.start);
61
+
62
+ if (ch === "\"") {
63
+ tokenString(ch, stream, state);
64
+ return "string";
77
65
  }
78
66
 
79
- return { list: getAutoCompletions(token, keywords, options),
80
- from: CodeMirror.Pos(cur.line, token.start),
81
- to: CodeMirror.Pos(cur.line, token.end) };
82
- }
67
+ if (ch === "'") {
68
+ tokenVariable(ch, stream, state);
69
+ return "variable";
70
+ }
83
71
 
84
- function getAutoCompletions(token, keywords, options) {
85
- var found = [];
86
- var start = token.string;
72
+ if (isSpecialChar.test(ch)) {
73
+ return null;
74
+ }
87
75
 
88
- for (var indx = 0; indx < keywords.length; indx++) {
89
- if (keywords[indx].lastIndexOf(start, 0) === 0 && (found.indexOf(keywords[indx]) === -1)) {
90
- found.push(keywords[indx]);
91
- }
76
+ if (isDigit.test(ch)) {
77
+ stream.eatWhile(isNumberChar);
78
+ return "number";
79
+ }
80
+ if (isOperatorChar.test(ch)) {
81
+ stream.eatWhile(isOperatorChar);
82
+ return "operator";
92
83
  }
93
84
 
94
- return found;
85
+ stream.eatWhile(isWordChar);
86
+ const cur = stream.current();
87
+ if (keywords.indexOf(cur) !== -1) {
88
+ return "keyword";
89
+ }
90
+ return "variable";
95
91
  }
96
92
 
97
-
98
- function defineMode() {
99
-
100
- var keywords = ("@BLANK @DIFF1 @DIFF2 @FIELD @FIELDS_BETWEEN @FIELDS_MATCHING " +
101
- "@GLOBAL_MAX @GLOBAL_MEAN @GLOBAL_MIN @GLOBAL_SDEV @GLOBAL_SUM @INDEX @LAST_NON_BLANK " +
102
- "@MAX @MEAN @MIN @MULTI_RESPONSE_SET @NULL @OFFSET @PARTITION_FIELD @PREDICTED " +
103
- "@SDEV @SINCE @SINCE0 @SUM @TARGET @TESTING_PARTITION @THIS @TODAY @TRAINING_PARTITION " +
104
- "@VALIDATION_PARTITION abs allbutfirst allbutlast alphabefore and arccos arccosh arcsin " +
105
- "arcsinh arctan arctan2 arctanh area cdf_chisq cdf_f cdf_normal cdf_t close_to COND1 " +
106
- "and COND2 COND1 or COND2 cos cosh count_equal count_greater_than count_less_than " +
107
- "count_non_nulls count_not_equal count_nulls count_substring crosses date_before " +
108
- "date_days_difference date_from_ywd date_in_days date_in_months date_in_weeks date_in_years " +
109
- "date_iso_day date_iso_week date_iso_year date_months_difference date_weeks_difference " +
110
- "date_years_difference datetime_date datetime_day datetime_day_name datetime_day_short_name " +
111
- "datetime_hour datetime_in_seconds datetime_minute datetime_month datetime_month_name " +
112
- "datetime_month_short_name datetime_now datetime_second datetime_time datetime_timestamp " +
113
- "datetime_weekday datetime_year distance div endstring exp first_index first_non_null " +
114
- "first_non_null_index fracof hasendstring hasmidstring hasstartstring hassubstring hassubstring " +
115
- "if then else elseif endif integer_bitcount integer_leastbit integer_length intof is_date " +
116
- "is_datetime is_integer is_number is_real is_string is_time is_timestamp isalphacode " +
117
- "isendstring islowercode ismidstring isnumbercode isstartstring issubstring issubstring " +
118
- "issubstring_count issubstring_lim isuppercode last last_index last_non_null last_non_null_index " +
119
- "length locchar locchar_back log log10 lowertoupper max max_index max_n MEAN mean_n member " +
120
- "min min_index min_n negate not num_points oneof or overlap pi random random0 rem replace " +
121
- "replicate round sdev_n sign sin sinh skipchar skipchar_back soundex soundex_difference sqrt " +
122
- "startstring stb_centroid_latitude stb_centroid_longitude stripchar strmember subscrs substring " +
123
- "substring_between sum_n tan tanh testbit time_before time_hours_difference time_in_hours " +
124
- "time_in_mins time_in_secs time_mins_difference").split(" ");
125
-
126
- var isSpecialChar = /[\[\]{}\(\),;\:\.]/;
127
- var isDigit = /\d/;
128
- var isNumberChar = /[\w\.]/;
129
- var isWordChar = /[\w\$_]/;
130
-
131
- var isOperatorChar = /[+\-*&%=<>!?|\/]/;
132
-
133
- function tokenResolve(stream, state) {
134
- var ch = stream.next();
135
- if (ch === "#" && state.startOfLine) {
136
- stream.skipToEnd();
137
- return "meta";
93
+ function tokenString(quote, stream, state) {
94
+ let next;
95
+ let end = false;
96
+ while (typeof (next = stream.next()) !== "undefined") {
97
+ if (next === quote) {
98
+ end = true;
99
+ break;
138
100
  }
139
-
140
- if (ch === "\"") {
141
- tokenString(ch, stream, state);
142
- return "string";
143
- }
144
-
145
- if (ch === "'") {
146
- tokenVariable(ch, stream, state);
147
- return "variable";
148
- }
149
-
150
- if (isSpecialChar.test(ch)) {
151
- return null;
152
- }
153
-
154
- if (isDigit.test(ch)) {
155
- stream.eatWhile(isNumberChar);
156
- return "number";
157
- }
158
- if (isOperatorChar.test(ch)) {
159
- stream.eatWhile(isOperatorChar);
160
- return "operator";
161
- }
162
-
163
- stream.eatWhile(isWordChar);
164
- var cur = stream.current();
165
- if (keywords.indexOf(cur) !== -1) {
166
- return "keyword";
167
- }
168
- return "variable";
169
101
  }
170
-
171
- function tokenString(quote, stream, state) {
172
- var next;
173
- var end = false;
174
- while (typeof (next = stream.next()) !== "undefined") {
175
- if (next === quote) {
176
- end = true;
177
- break;
178
- }
179
- }
180
- if (end) {
181
- state.tokenize = null;
182
- }
183
- return "string";
102
+ if (end) {
103
+ state.tokenize = null;
184
104
  }
105
+ return "string";
106
+ }
185
107
 
186
- function tokenVariable(quote, stream, state) {
187
- var next;
188
- var end = false;
189
- while (typeof (next = stream.next()) !== "undefined") {
190
- if (next === quote) {
191
- end = true;
192
- break;
193
- }
194
- }
195
- if (end) {
196
- state.tokenize = null;
108
+ function tokenVariable(quote, stream, state) {
109
+ let next;
110
+ let end = false;
111
+ while (typeof (next = stream.next()) !== "undefined") {
112
+ if (next === quote) {
113
+ end = true;
114
+ break;
197
115
  }
198
- return "variable";
199
116
  }
117
+ if (end) {
118
+ state.tokenize = null;
119
+ }
120
+ return "variable";
121
+ }
200
122
 
201
- // Required implementation
202
-
203
- return {
204
- startState: function() {
205
- return { tokenize: null };
206
- },
207
-
208
- token: function(stream, state) {
209
- if (stream.eatSpace()) {
210
- return null;
211
- }
212
- var style = (state.tokenize || tokenResolve)(stream, state);
213
- return style;
214
- },
215
-
216
- electricChars: "{}"
217
- };
123
+ // Define CLEM language
124
+ const clemLanguage = StreamLanguage.define({
125
+ name: "CLEM",
126
+ startState: function() {
127
+ return { tokenize: null };
128
+ },
129
+ token: function(stream, state) {
130
+ if (stream.eatSpace()) {
131
+ return null;
132
+ }
133
+ const style = (state.tokenize || tokenResolve)(stream, state);
134
+ return style;
135
+ },
136
+ });
137
+
138
+ // Autocompletions
139
+ const clemCompletion = clemLanguage.data.of({
140
+ autocomplete: completeFromList(clemKeywords)
141
+ });
142
+
143
+ function clem() {
144
+ return new LanguageSupport(clemLanguage, [clemCompletion]);
218
145
  }
219
146
 
220
147
  export {
221
- register
148
+ clem
222
149
  };
@@ -1,5 +1,5 @@
1
1
  /*
2
- * Copyright 2017-2023 Elyra Authors
2
+ * Copyright 2017-2024 Elyra Authors
3
3
  *
4
4
  * Licensed under the Apache License, Version 2.0 (the "License");
5
5
  * you may not use this file except in compliance with the License.
@@ -14,110 +14,59 @@
14
14
  * limitations under the License.
15
15
  */
16
16
 
17
- let CodeMirror;
18
- function register(cm) {
19
- CodeMirror = cm;
20
- CodeMirror.registerHelper("hint", "python", pythonHint);
21
- }
22
-
23
-
24
- function forEach(arr, f) {
25
- for (var e = arr.length, i = 0; i < e; ++i) {
26
- f(arr[i]);
27
- }
28
- }
29
-
30
- function arrayContains(arr, item) {
31
- if (!Array.prototype.indexOf) {
32
- var i = arr.length;
33
- while (i--) {
34
- if (arr[i] === item) {
35
- return true;
36
- }
37
- }
38
- return false;
39
- }
40
- return arr.indexOf(item) !== -1;
41
- }
42
-
43
- function scriptHint(editor, _keywords, getToken) {
44
- var cur = editor.getCursor();
45
- var token = getToken(editor, cur);
46
- var tprop = token;
47
- var context;
48
- // ignore irregular word tokens
49
- if (!(/^[\w$_]*$/).test(token.string)) {
50
- token = tprop = { start: cur.ch, end: cur.ch, string: "", state: token.state,
51
- className: token.string === ":" ? "python-type" : null };
52
- }
53
- if (!context) {
54
- context = [];
55
- }
56
- context.push(tprop);
57
-
58
- var completionList = getCompletions(token, context);
59
- completionList.sort();
60
-
61
- return { list: completionList,
62
- from: CodeMirror.Pos(cur.line, token.start),
63
- to: CodeMirror.Pos(cur.line, token.end) };
64
- }
65
-
66
- function pythonHint(editor) {
67
- return scriptHint(editor, pythonKeywordsL, function(e, cur) {
68
- return e.getTokenAt(cur);
69
- });
70
- }
71
-
72
-
73
- var pythonKeywords = "and del from not while as elif global or with assert else if pass yield" +
74
- "break except import print class exec in raise continue finally is return def for lambda try";
75
- var pythonKeywordsL = pythonKeywords.split(" ");
76
-
77
- var pythonBuiltins = "abs divmod input open staticmethod all enumerate int ord str " +
78
- "any eval isinstance pow sum basestring execfile issubclass print super" +
79
- "bin file iter property tuple bool filter len range type" +
80
- "bytearray float list raw_input unichr callable format locals reduce unicode" +
81
- "chr frozenset long reload vars classmethod getattr map repr xrange" +
82
- "cmp globals max reversed zip compile hasattr memoryview round __import__" +
83
- "complex hash min set apply delattr help next setattr buffer" +
84
- "dict hex object slice coerce dir id oct sorted intern ";
85
- var pythonBuiltinsL = pythonBuiltins.split(" ").join("() ")
86
- .split(" ");
87
-
88
- function getCompletions(token, context) {
89
- var found = [];
90
- var start = token.string;
91
- function maybeAdd(str) {
92
- if (str.lastIndexOf(start, 0) === 0 && !arrayContains(found, str)) {
93
- found.push(str);
94
- }
95
- }
96
-
97
- function gatherCompletions(_obj) {
98
- forEach(pythonBuiltinsL, maybeAdd);
99
- forEach(pythonKeywordsL, maybeAdd);
100
- }
101
-
102
- if (context) {
103
- var obj = context.pop();
104
- var base = "";
105
-
106
- if (obj.type === "variable") {
107
- base = obj.string;
108
- } else if (obj.type === "variable-3") {
109
- base = ":" + obj.string;
110
- }
111
- while (base !== null && context.length) {
112
- base = base[context.pop().string];
113
- }
114
- if (base !== null) {
115
- gatherCompletions(base);
116
- }
117
- }
118
- return found;
17
+ const pythonKeywords = [
18
+ "and",
19
+ "del",
20
+ "not",
21
+ "as",
22
+ "elif",
23
+ "global",
24
+ "or",
25
+ "with",
26
+ "assert",
27
+ "else",
28
+ "pass",
29
+ "yield",
30
+ "break",
31
+ "except",
32
+ "print",
33
+ "in",
34
+ "raise",
35
+ "continue",
36
+ "finally",
37
+ "is",
38
+ "return",
39
+ "lambda"
40
+ ];
41
+
42
+ const pythonFunctions = [
43
+ "basestring()",
44
+ "execfile()",
45
+ "file()",
46
+ "raw_input()",
47
+ "unichr()",
48
+ "reduce()",
49
+ "unicode()",
50
+ "long()",
51
+ "reload()",
52
+ "xrange()",
53
+ "cmp()",
54
+ "apply()",
55
+ "buffer()",
56
+ "coerce()",
57
+ "intern()",
58
+ ];
59
+
60
+ function getPythonHints() {
61
+ const pythonHints = [];
62
+
63
+ pythonKeywords.forEach((keyword) => pythonHints.push({ label: keyword, type: "keyword" }));
64
+
65
+ pythonFunctions.forEach((func) => pythonHints.push({ label: func, type: "function" }));
66
+
67
+ return pythonHints;
119
68
  }
120
69
 
121
70
  export {
122
- register
71
+ getPythonHints
123
72
  };