@atlaskit/editor-core 189.4.9 → 189.4.10
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 +6 -0
- package/dist/cjs/ui/ConfigPanel/ConfigPanel.js +11 -3
- package/dist/cjs/ui/ConfigPanel/constants.js +13 -0
- package/dist/cjs/ui/ConfigPanel/utils.js +44 -1
- package/dist/cjs/version-wrapper.js +1 -1
- package/dist/es2019/ui/ConfigPanel/ConfigPanel.js +11 -2
- package/dist/es2019/ui/ConfigPanel/constants.js +7 -0
- package/dist/es2019/ui/ConfigPanel/utils.js +35 -1
- package/dist/es2019/version-wrapper.js +1 -1
- package/dist/esm/ui/ConfigPanel/ConfigPanel.js +11 -3
- package/dist/esm/ui/ConfigPanel/constants.js +7 -0
- package/dist/esm/ui/ConfigPanel/utils.js +42 -0
- package/dist/esm/version-wrapper.js +1 -1
- package/dist/types/ui/ConfigPanel/ConfigPanel.d.ts +3 -4
- package/dist/types/ui/ConfigPanel/constants.d.ts +2 -0
- package/dist/types/ui/ConfigPanel/utils.d.ts +2 -1
- package/dist/types-ts4.5/ui/ConfigPanel/ConfigPanel.d.ts +3 -4
- package/dist/types-ts4.5/ui/ConfigPanel/constants.d.ts +2 -0
- package/dist/types-ts4.5/ui/ConfigPanel/utils.d.ts +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @atlaskit/editor-core
|
|
2
2
|
|
|
3
|
+
## 189.4.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#55514](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/55514) [`9e0ff045562e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/9e0ff045562e) - Re-add safe parameters to config panel analytic event
|
|
8
|
+
|
|
3
9
|
## 189.4.9
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
|
@@ -36,8 +36,12 @@ var _WithPluginState = _interopRequireDefault(require("../WithPluginState"));
|
|
|
36
36
|
var _FormContent = _interopRequireDefault(require("./FormContent"));
|
|
37
37
|
var _messages = require("./messages");
|
|
38
38
|
var _FormErrorBoundary = require("./FormErrorBoundary");
|
|
39
|
+
var _utils = require("./utils");
|
|
40
|
+
var _constants = require("./constants");
|
|
39
41
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
40
42
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
43
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
44
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
41
45
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
42
46
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
43
47
|
function ConfigForm(_ref) {
|
|
@@ -336,16 +340,20 @@ var ConfigPanel = /*#__PURE__*/function (_React$Component) {
|
|
|
336
340
|
value: function componentWillUnmount() {
|
|
337
341
|
var _this$props4 = this.props,
|
|
338
342
|
createAnalyticsEvent = _this$props4.createAnalyticsEvent,
|
|
339
|
-
extensionManifest = _this$props4.extensionManifest
|
|
343
|
+
extensionManifest = _this$props4.extensionManifest,
|
|
344
|
+
fields = _this$props4.fields;
|
|
345
|
+
var currentParameters = this.state.currentParameters;
|
|
340
346
|
(0, _analytics.fireAnalyticsEvent)(createAnalyticsEvent)({
|
|
341
347
|
payload: {
|
|
342
348
|
action: _analytics.ACTION.CLOSED,
|
|
343
349
|
actionSubject: _analytics.ACTION_SUBJECT.CONFIG_PANEL,
|
|
344
350
|
eventType: _analytics.EVENT_TYPE.UI,
|
|
345
|
-
attributes: {
|
|
351
|
+
attributes: _objectSpread({
|
|
346
352
|
extensionKey: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.key,
|
|
347
353
|
extensionType: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.type
|
|
348
|
-
}
|
|
354
|
+
}, extensionManifest !== null && extensionManifest !== void 0 && extensionManifest.key && _constants.ALLOWED_LOGGED_MACRO_PARAMS[extensionManifest.key] ? {
|
|
355
|
+
parameters: (0, _utils.getLoggedParameters)(extensionManifest.key, currentParameters, fields)
|
|
356
|
+
} : {})
|
|
349
357
|
}
|
|
350
358
|
});
|
|
351
359
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.ALLOWED_PARAM_TYPES = exports.ALLOWED_LOGGED_MACRO_PARAMS = void 0;
|
|
7
|
+
// Allowlist of { macroKey: parameterName[] } for analytics logging
|
|
8
|
+
var ALLOWED_LOGGED_MACRO_PARAMS = exports.ALLOWED_LOGGED_MACRO_PARAMS = {
|
|
9
|
+
children: ['all', 'first', 'depth', 'style', 'excerptType', 'sort', 'reverse'],
|
|
10
|
+
'recently-updated': ['width', 'types', 'max', 'theme', 'showProfilePic', 'hideHeading'],
|
|
11
|
+
excerpt: ['hidden']
|
|
12
|
+
};
|
|
13
|
+
var ALLOWED_PARAM_TYPES = exports.ALLOWED_PARAM_TYPES = ['enum', 'number', 'boolean'];
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports.validateRequired = exports.validate = exports.isDuplicateField = exports.getSafeParentedName = exports.getOptionFromValue = exports.getNameFromDuplicateField = void 0;
|
|
7
|
+
exports.validateRequired = exports.validate = exports.isDuplicateField = exports.getSafeParentedName = exports.getOptionFromValue = exports.getNameFromDuplicateField = exports.getLoggedParameters = void 0;
|
|
8
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
7
9
|
var _types = require("./types");
|
|
10
|
+
var _constants = require("./constants");
|
|
11
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8
13
|
var validate = exports.validate = function validate(field, value) {
|
|
9
14
|
return validateRequired(field, value);
|
|
10
15
|
};
|
|
@@ -53,4 +58,42 @@ var isDuplicateField = exports.isDuplicateField = function isDuplicateField(key)
|
|
|
53
58
|
};
|
|
54
59
|
var getNameFromDuplicateField = exports.getNameFromDuplicateField = function getNameFromDuplicateField(key) {
|
|
55
60
|
return key.replace(duplicateFieldRegex, '');
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// An overly cautious parser for sanitizing configuration parameters of UGC
|
|
64
|
+
var parseParamType = function parseParamType(paramValue, paramField) {
|
|
65
|
+
if (paramValue && paramField) {
|
|
66
|
+
if (paramField.type === 'string') {
|
|
67
|
+
if (paramField.name === 'types') {
|
|
68
|
+
// Parse types field as an array of valid content types
|
|
69
|
+
var contentTypes = ['page', 'blogpost', 'comment', 'attachment'];
|
|
70
|
+
return paramValue && paramValue.split(',').map(function (type) {
|
|
71
|
+
return type.trim();
|
|
72
|
+
}).filter(function (type) {
|
|
73
|
+
return contentTypes.includes(type);
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
if (paramField.name === 'width') {
|
|
77
|
+
return parseFloat(paramValue);
|
|
78
|
+
}
|
|
79
|
+
// Strings are very risky - return empty string in case anything slips through
|
|
80
|
+
return '';
|
|
81
|
+
}
|
|
82
|
+
if (_constants.ALLOWED_PARAM_TYPES.includes(paramField.type)) {
|
|
83
|
+
// The param types defined here are already parsed and safe to log
|
|
84
|
+
return paramValue;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// Safety net
|
|
88
|
+
return null;
|
|
89
|
+
};
|
|
90
|
+
var getLoggedParameters = exports.getLoggedParameters = function getLoggedParameters(macroKey, currentParams, macroFields) {
|
|
91
|
+
// Get the parameters only defined in the allowlist of logged macro/parameter keys
|
|
92
|
+
return Object.keys(currentParams).filter(function (paramKey) {
|
|
93
|
+
return _constants.ALLOWED_LOGGED_MACRO_PARAMS[macroKey].includes(paramKey);
|
|
94
|
+
}).reduce(function (obj, param) {
|
|
95
|
+
return _objectSpread(_objectSpread({}, obj), {}, (0, _defineProperty2.default)({}, param, parseParamType(currentParams[param], macroFields === null || macroFields === void 0 ? void 0 : macroFields.find(function (field) {
|
|
96
|
+
return field.name === param;
|
|
97
|
+
}))));
|
|
98
|
+
}, {});
|
|
56
99
|
};
|
|
@@ -21,6 +21,8 @@ import WithPluginState from '../WithPluginState';
|
|
|
21
21
|
import FormContent from './FormContent';
|
|
22
22
|
import { messages } from './messages';
|
|
23
23
|
import { FormErrorBoundary } from './FormErrorBoundary';
|
|
24
|
+
import { getLoggedParameters } from './utils';
|
|
25
|
+
import { ALLOWED_LOGGED_MACRO_PARAMS } from './constants';
|
|
24
26
|
function ConfigForm({
|
|
25
27
|
canSave,
|
|
26
28
|
errorMessage,
|
|
@@ -276,8 +278,12 @@ class ConfigPanel extends React.Component {
|
|
|
276
278
|
componentWillUnmount() {
|
|
277
279
|
const {
|
|
278
280
|
createAnalyticsEvent,
|
|
279
|
-
extensionManifest
|
|
281
|
+
extensionManifest,
|
|
282
|
+
fields
|
|
280
283
|
} = this.props;
|
|
284
|
+
const {
|
|
285
|
+
currentParameters
|
|
286
|
+
} = this.state;
|
|
281
287
|
fireAnalyticsEvent(createAnalyticsEvent)({
|
|
282
288
|
payload: {
|
|
283
289
|
action: ACTION.CLOSED,
|
|
@@ -285,7 +291,10 @@ class ConfigPanel extends React.Component {
|
|
|
285
291
|
eventType: EVENT_TYPE.UI,
|
|
286
292
|
attributes: {
|
|
287
293
|
extensionKey: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.key,
|
|
288
|
-
extensionType: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.type
|
|
294
|
+
extensionType: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.type,
|
|
295
|
+
...(extensionManifest !== null && extensionManifest !== void 0 && extensionManifest.key && ALLOWED_LOGGED_MACRO_PARAMS[extensionManifest.key] ? {
|
|
296
|
+
parameters: getLoggedParameters(extensionManifest.key, currentParameters, fields)
|
|
297
|
+
} : {})
|
|
289
298
|
}
|
|
290
299
|
}
|
|
291
300
|
});
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Allowlist of { macroKey: parameterName[] } for analytics logging
|
|
2
|
+
export const ALLOWED_LOGGED_MACRO_PARAMS = {
|
|
3
|
+
children: ['all', 'first', 'depth', 'style', 'excerptType', 'sort', 'reverse'],
|
|
4
|
+
'recently-updated': ['width', 'types', 'max', 'theme', 'showProfilePic', 'hideHeading'],
|
|
5
|
+
excerpt: ['hidden']
|
|
6
|
+
};
|
|
7
|
+
export const ALLOWED_PARAM_TYPES = ['enum', 'number', 'boolean'];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ValidationError } from './types';
|
|
2
|
+
import { ALLOWED_LOGGED_MACRO_PARAMS, ALLOWED_PARAM_TYPES } from './constants';
|
|
2
3
|
export const validate = (field, value) => {
|
|
3
4
|
return validateRequired(field, value);
|
|
4
5
|
};
|
|
@@ -36,4 +37,37 @@ export const getSafeParentedName = (name, parentName) => {
|
|
|
36
37
|
};
|
|
37
38
|
const duplicateFieldRegex = /:[0-9]+$/;
|
|
38
39
|
export const isDuplicateField = key => duplicateFieldRegex.test(key);
|
|
39
|
-
export const getNameFromDuplicateField = key => key.replace(duplicateFieldRegex, '');
|
|
40
|
+
export const getNameFromDuplicateField = key => key.replace(duplicateFieldRegex, '');
|
|
41
|
+
|
|
42
|
+
// An overly cautious parser for sanitizing configuration parameters of UGC
|
|
43
|
+
const parseParamType = (paramValue, paramField) => {
|
|
44
|
+
if (paramValue && paramField) {
|
|
45
|
+
if (paramField.type === 'string') {
|
|
46
|
+
if (paramField.name === 'types') {
|
|
47
|
+
// Parse types field as an array of valid content types
|
|
48
|
+
const contentTypes = ['page', 'blogpost', 'comment', 'attachment'];
|
|
49
|
+
return paramValue && paramValue.split(',').map(type => type.trim()).filter(type => contentTypes.includes(type));
|
|
50
|
+
}
|
|
51
|
+
if (paramField.name === 'width') {
|
|
52
|
+
return parseFloat(paramValue);
|
|
53
|
+
}
|
|
54
|
+
// Strings are very risky - return empty string in case anything slips through
|
|
55
|
+
return '';
|
|
56
|
+
}
|
|
57
|
+
if (ALLOWED_PARAM_TYPES.includes(paramField.type)) {
|
|
58
|
+
// The param types defined here are already parsed and safe to log
|
|
59
|
+
return paramValue;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
// Safety net
|
|
63
|
+
return null;
|
|
64
|
+
};
|
|
65
|
+
export const getLoggedParameters = (macroKey, currentParams, macroFields) => {
|
|
66
|
+
// Get the parameters only defined in the allowlist of logged macro/parameter keys
|
|
67
|
+
return Object.keys(currentParams).filter(paramKey => ALLOWED_LOGGED_MACRO_PARAMS[macroKey].includes(paramKey)).reduce((obj, param) => {
|
|
68
|
+
return {
|
|
69
|
+
...obj,
|
|
70
|
+
[param]: parseParamType(currentParams[param], macroFields === null || macroFields === void 0 ? void 0 : macroFields.find(field => field.name === param))
|
|
71
|
+
};
|
|
72
|
+
}, {});
|
|
73
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export const name = "@atlaskit/editor-core";
|
|
2
|
-
export const version = "189.4.
|
|
2
|
+
export const version = "189.4.10";
|
|
@@ -7,6 +7,8 @@ import _inherits from "@babel/runtime/helpers/inherits";
|
|
|
7
7
|
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
|
|
8
8
|
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
|
|
9
9
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
10
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
11
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
12
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
11
13
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
12
14
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
@@ -31,6 +33,8 @@ import WithPluginState from '../WithPluginState';
|
|
|
31
33
|
import FormContent from './FormContent';
|
|
32
34
|
import { messages } from './messages';
|
|
33
35
|
import { FormErrorBoundary } from './FormErrorBoundary';
|
|
36
|
+
import { getLoggedParameters } from './utils';
|
|
37
|
+
import { ALLOWED_LOGGED_MACRO_PARAMS } from './constants';
|
|
34
38
|
function ConfigForm(_ref) {
|
|
35
39
|
var canSave = _ref.canSave,
|
|
36
40
|
errorMessage = _ref.errorMessage,
|
|
@@ -327,16 +331,20 @@ var ConfigPanel = /*#__PURE__*/function (_React$Component) {
|
|
|
327
331
|
value: function componentWillUnmount() {
|
|
328
332
|
var _this$props4 = this.props,
|
|
329
333
|
createAnalyticsEvent = _this$props4.createAnalyticsEvent,
|
|
330
|
-
extensionManifest = _this$props4.extensionManifest
|
|
334
|
+
extensionManifest = _this$props4.extensionManifest,
|
|
335
|
+
fields = _this$props4.fields;
|
|
336
|
+
var currentParameters = this.state.currentParameters;
|
|
331
337
|
fireAnalyticsEvent(createAnalyticsEvent)({
|
|
332
338
|
payload: {
|
|
333
339
|
action: ACTION.CLOSED,
|
|
334
340
|
actionSubject: ACTION_SUBJECT.CONFIG_PANEL,
|
|
335
341
|
eventType: EVENT_TYPE.UI,
|
|
336
|
-
attributes: {
|
|
342
|
+
attributes: _objectSpread({
|
|
337
343
|
extensionKey: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.key,
|
|
338
344
|
extensionType: extensionManifest === null || extensionManifest === void 0 ? void 0 : extensionManifest.type
|
|
339
|
-
}
|
|
345
|
+
}, extensionManifest !== null && extensionManifest !== void 0 && extensionManifest.key && ALLOWED_LOGGED_MACRO_PARAMS[extensionManifest.key] ? {
|
|
346
|
+
parameters: getLoggedParameters(extensionManifest.key, currentParameters, fields)
|
|
347
|
+
} : {})
|
|
340
348
|
}
|
|
341
349
|
});
|
|
342
350
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
// Allowlist of { macroKey: parameterName[] } for analytics logging
|
|
2
|
+
export var ALLOWED_LOGGED_MACRO_PARAMS = {
|
|
3
|
+
children: ['all', 'first', 'depth', 'style', 'excerptType', 'sort', 'reverse'],
|
|
4
|
+
'recently-updated': ['width', 'types', 'max', 'theme', 'showProfilePic', 'hideHeading'],
|
|
5
|
+
excerpt: ['hidden']
|
|
6
|
+
};
|
|
7
|
+
export var ALLOWED_PARAM_TYPES = ['enum', 'number', 'boolean'];
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
1
4
|
import { ValidationError } from './types';
|
|
5
|
+
import { ALLOWED_LOGGED_MACRO_PARAMS, ALLOWED_PARAM_TYPES } from './constants';
|
|
2
6
|
export var validate = function validate(field, value) {
|
|
3
7
|
return validateRequired(field, value);
|
|
4
8
|
};
|
|
@@ -47,4 +51,42 @@ export var isDuplicateField = function isDuplicateField(key) {
|
|
|
47
51
|
};
|
|
48
52
|
export var getNameFromDuplicateField = function getNameFromDuplicateField(key) {
|
|
49
53
|
return key.replace(duplicateFieldRegex, '');
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// An overly cautious parser for sanitizing configuration parameters of UGC
|
|
57
|
+
var parseParamType = function parseParamType(paramValue, paramField) {
|
|
58
|
+
if (paramValue && paramField) {
|
|
59
|
+
if (paramField.type === 'string') {
|
|
60
|
+
if (paramField.name === 'types') {
|
|
61
|
+
// Parse types field as an array of valid content types
|
|
62
|
+
var contentTypes = ['page', 'blogpost', 'comment', 'attachment'];
|
|
63
|
+
return paramValue && paramValue.split(',').map(function (type) {
|
|
64
|
+
return type.trim();
|
|
65
|
+
}).filter(function (type) {
|
|
66
|
+
return contentTypes.includes(type);
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (paramField.name === 'width') {
|
|
70
|
+
return parseFloat(paramValue);
|
|
71
|
+
}
|
|
72
|
+
// Strings are very risky - return empty string in case anything slips through
|
|
73
|
+
return '';
|
|
74
|
+
}
|
|
75
|
+
if (ALLOWED_PARAM_TYPES.includes(paramField.type)) {
|
|
76
|
+
// The param types defined here are already parsed and safe to log
|
|
77
|
+
return paramValue;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
// Safety net
|
|
81
|
+
return null;
|
|
82
|
+
};
|
|
83
|
+
export var getLoggedParameters = function getLoggedParameters(macroKey, currentParams, macroFields) {
|
|
84
|
+
// Get the parameters only defined in the allowlist of logged macro/parameter keys
|
|
85
|
+
return Object.keys(currentParams).filter(function (paramKey) {
|
|
86
|
+
return ALLOWED_LOGGED_MACRO_PARAMS[macroKey].includes(paramKey);
|
|
87
|
+
}).reduce(function (obj, param) {
|
|
88
|
+
return _objectSpread(_objectSpread({}, obj), {}, _defineProperty({}, param, parseParamType(currentParams[param], macroFields === null || macroFields === void 0 ? void 0 : macroFields.find(function (field) {
|
|
89
|
+
return field.name === param;
|
|
90
|
+
}))));
|
|
91
|
+
}, {});
|
|
50
92
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export var name = "@atlaskit/editor-core";
|
|
2
|
-
export var version = "189.4.
|
|
2
|
+
export var version = "189.4.10";
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
3
|
-
import type { ExtensionManifest } from '@atlaskit/editor-common/extensions';
|
|
4
|
-
import {
|
|
5
|
-
import { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
3
|
+
import type { ExtensionManifest, FieldDefinition, Parameters, OnSaveCallback } from '@atlaskit/editor-common/extensions';
|
|
4
|
+
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
6
5
|
type Props = {
|
|
7
6
|
extensionManifest?: ExtensionManifest;
|
|
8
7
|
fields?: FieldDefinition[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Option, FieldDefinition } from '@atlaskit/editor-common/extensions';
|
|
1
|
+
import type { Option, FieldDefinition, Parameters } from '@atlaskit/editor-common/extensions';
|
|
2
2
|
import { ValidationError } from './types';
|
|
3
3
|
export declare const validate: <T>(field: Partial<FieldDefinition>, value: T) => ValidationError | undefined;
|
|
4
4
|
type ValidationProps = {
|
|
@@ -10,4 +10,5 @@ export declare const getOptionFromValue: (options: Option[], value: string | str
|
|
|
10
10
|
export declare const getSafeParentedName: (name: string, parentName?: string) => string;
|
|
11
11
|
export declare const isDuplicateField: (key: string) => boolean;
|
|
12
12
|
export declare const getNameFromDuplicateField: (key: string) => string;
|
|
13
|
+
export declare const getLoggedParameters: (macroKey: string, currentParams: Parameters, macroFields?: FieldDefinition[]) => {};
|
|
13
14
|
export {};
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
3
|
-
import type { ExtensionManifest } from '@atlaskit/editor-common/extensions';
|
|
4
|
-
import {
|
|
5
|
-
import { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
2
|
+
import type { WithAnalyticsEventsProps } from '@atlaskit/analytics-next';
|
|
3
|
+
import type { ExtensionManifest, FieldDefinition, Parameters, OnSaveCallback } from '@atlaskit/editor-common/extensions';
|
|
4
|
+
import type { FeatureFlags } from '@atlaskit/editor-common/types';
|
|
6
5
|
type Props = {
|
|
7
6
|
extensionManifest?: ExtensionManifest;
|
|
8
7
|
fields?: FieldDefinition[];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Option, FieldDefinition } from '@atlaskit/editor-common/extensions';
|
|
1
|
+
import type { Option, FieldDefinition, Parameters } from '@atlaskit/editor-common/extensions';
|
|
2
2
|
import { ValidationError } from './types';
|
|
3
3
|
export declare const validate: <T>(field: Partial<FieldDefinition>, value: T) => ValidationError | undefined;
|
|
4
4
|
type ValidationProps = {
|
|
@@ -10,4 +10,5 @@ export declare const getOptionFromValue: (options: Option[], value: string | str
|
|
|
10
10
|
export declare const getSafeParentedName: (name: string, parentName?: string) => string;
|
|
11
11
|
export declare const isDuplicateField: (key: string) => boolean;
|
|
12
12
|
export declare const getNameFromDuplicateField: (key: string) => string;
|
|
13
|
+
export declare const getLoggedParameters: (macroKey: string, currentParams: Parameters, macroFields?: FieldDefinition[]) => {};
|
|
13
14
|
export {};
|