@bpmn-io/form-js-editor 1.8.0 → 1.8.2

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/dist/index.es.js CHANGED
@@ -127,6 +127,8 @@ var slice = Array.prototype.slice;
127
127
  * var sum = eventBus.fire('sum', 1, 2);
128
128
  * console.log(sum); // 3
129
129
  * ```
130
+ *
131
+ * @template [EventMap=null]
130
132
  */
131
133
  function EventBus() {
132
134
  /**
@@ -140,6 +142,8 @@ function EventBus() {
140
142
  }
141
143
 
142
144
  /**
145
+ * @overlord
146
+ *
143
147
  * Register an event listener for events with the given name.
144
148
  *
145
149
  * The callback will be invoked with `event, ...additionalArguments`
@@ -158,6 +162,25 @@ function EventBus() {
158
162
  * @param {EventBusEventCallback<T>} callback
159
163
  * @param {any} [that] callback context
160
164
  */
165
+ /**
166
+ * Register an event listener for events with the given name.
167
+ *
168
+ * The callback will be invoked with `event, ...additionalArguments`
169
+ * that have been passed to {@link EventBus#fire}.
170
+ *
171
+ * Returning false from a listener will prevent the events default action
172
+ * (if any is specified). To stop an event from being processed further in
173
+ * other listeners execute {@link Event#stopPropagation}.
174
+ *
175
+ * Returning anything but `undefined` from a listener will stop the listener propagation.
176
+ *
177
+ * @template {keyof EventMap} EventName
178
+ *
179
+ * @param {EventName} events to subscribe to
180
+ * @param {number} [priority=1000] listen priority
181
+ * @param {EventBusEventCallback<EventMap[EventName]>} callback
182
+ * @param {any} [that] callback context
183
+ */
161
184
  EventBus.prototype.on = function (events, priority, callback, that) {
162
185
  events = isArray(events) ? events : [events];
163
186
  if (isFunction(priority)) {
@@ -188,6 +211,8 @@ EventBus.prototype.on = function (events, priority, callback, that) {
188
211
  };
189
212
 
190
213
  /**
214
+ * @overlord
215
+ *
191
216
  * Register an event listener that is called only once.
192
217
  *
193
218
  * @template T
@@ -197,6 +222,16 @@ EventBus.prototype.on = function (events, priority, callback, that) {
197
222
  * @param {EventBusEventCallback<T>} callback
198
223
  * @param {any} [that] callback context
199
224
  */
225
+ /**
226
+ * Register an event listener that is called only once.
227
+ *
228
+ * @template {keyof EventMap} EventName
229
+ *
230
+ * @param {EventName} events to subscribe to
231
+ * @param {number} [priority=1000] listen priority
232
+ * @param {EventBusEventCallback<EventMap[EventName]>} callback
233
+ * @param {any} [that] callback context
234
+ */
200
235
  EventBus.prototype.once = function (events, priority, callback, that) {
201
236
  var self = this;
202
237
  if (isFunction(priority)) {
@@ -2868,9 +2903,9 @@ EditorActions.prototype.unregister = function (action) {
2868
2903
  };
2869
2904
 
2870
2905
  /**
2871
- * Returns the number of actions that are currently registered
2906
+ * Returns the identifiers of all currently registered editor actions
2872
2907
  *
2873
- * @return {number}
2908
+ * @return {string[]}
2874
2909
  */
2875
2910
  EditorActions.prototype.getActions = function () {
2876
2911
  return Object.keys(this._actions);
@@ -3123,7 +3158,7 @@ Keyboard.prototype._isEventIgnored = function (event) {
3123
3158
  if (event.defaultPrevented) {
3124
3159
  return true;
3125
3160
  }
3126
- return isInput(event.target) && this._isModifiedKeyIgnored(event);
3161
+ return (isInput(event.target) || isButton(event.target) && isKey([' ', 'Enter'], event)) && this._isModifiedKeyIgnored(event);
3127
3162
  };
3128
3163
  Keyboard.prototype._isModifiedKeyIgnored = function (event) {
3129
3164
  if (!isCmd(event)) {
@@ -3220,6 +3255,9 @@ Keyboard.prototype.isKey = isKey;
3220
3255
  function isInput(target) {
3221
3256
  return target && (matches(target, 'input, textarea') || target.contentEditable === 'true');
3222
3257
  }
3258
+ function isButton(target) {
3259
+ return target && matches(target, 'button, input[type=submit], input[type=button], a[href], [aria-role=button]');
3260
+ }
3223
3261
 
3224
3262
  var LOW_PRIORITY$1 = 500;
3225
3263
 
@@ -8943,6 +8981,14 @@ function textToLabel(text) {
8943
8981
  function isValidDotPath(path) {
8944
8982
  return /^\w+(\.\w+)*$/.test(path);
8945
8983
  }
8984
+
8985
+ /**
8986
+ * @param {string} path
8987
+ */
8988
+ function isProhibitedPath(path) {
8989
+ const prohibitedSegments = ['__proto__', 'prototype', 'constructor'];
8990
+ return path.split('.').some(segment => prohibitedSegments.includes(segment));
8991
+ }
8946
8992
  const LABELED_NON_INPUTS = ['button', 'group', 'dynamiclist', 'iframe', 'table'];
8947
8993
  const INPUTS = ['checkbox', 'checklist', 'datetime', 'number', 'radio', 'select', 'taglist', 'textfield', 'textarea'];
8948
8994
  const OPTIONS_INPUTS = ['checklist', 'radio', 'select', 'taglist'];
@@ -9882,6 +9928,9 @@ function Key$2(props) {
9882
9928
  if (hasIntegerPathSegment(value)) {
9883
9929
  return 'Must not contain numerical path segments.';
9884
9930
  }
9931
+ if (isProhibitedPath(value)) {
9932
+ return 'Must not be a prohibited path.';
9933
+ }
9885
9934
  const replacements = {
9886
9935
  [field.id]: value.split('.')
9887
9936
  };
@@ -9974,11 +10023,15 @@ function Path(props) {
9974
10023
  }
9975
10024
 
9976
10025
  // Check for integer segments in the path
9977
- const hasIntegerPathSegment = value.split('.').some(segment => /^\d+$/.test(segment));
9978
- if (hasIntegerPathSegment) {
10026
+ if (hasIntegerPathSegment(value)) {
9979
10027
  return 'Must not contain numerical path segments.';
9980
10028
  }
9981
10029
 
10030
+ // Check for special prohibited paths
10031
+ if (isProhibitedPath(value)) {
10032
+ return 'Must not be a prohibited path.';
10033
+ }
10034
+
9982
10035
  // Check for path collisions
9983
10036
  const options = {
9984
10037
  replacements: {