@atlaskit/adf-utils 19.0.21 → 19.0.22

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,11 @@
1
1
  # @atlaskit/adf-utils
2
2
 
3
+ ## 19.0.22
4
+
5
+ ### Patch Changes
6
+
7
+ - [#79538](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/pull-requests/79538) [`d4d91668d3ac`](https://stash.atlassian.com/projects/CONFCLOUD/repos/confluence-frontend/commits/d4d91668d3ac) - ED-22501 Update validator specs for inline-card based on feature flag
8
+
3
9
  ## 19.0.21
4
10
 
5
11
  ### Patch Changes
@@ -20,6 +20,9 @@
20
20
  "references": [
21
21
  {
22
22
  "path": "../../../monorepo-tooling/codemod-utils/afm-cc/tsconfig.json"
23
+ },
24
+ {
25
+ "path": "../../../platform/feature-flags/afm-cc/tsconfig.json"
23
26
  }
24
27
  ]
25
28
  }
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.inlineCardWithAnnotation = void 0;
7
+ // This is a custom spec we're using for inline card till the inline comments feature is fully rolled out.
8
+ var inlineCardWithAnnotation = exports.inlineCardWithAnnotation = {
9
+ props: {
10
+ type: {
11
+ type: 'enum',
12
+ values: ['inlineCard']
13
+ },
14
+ attrs: [{
15
+ props: {
16
+ url: {
17
+ type: 'string',
18
+ validatorFn: 'safeUrl'
19
+ }
20
+ }
21
+ }, {
22
+ props: {
23
+ data: {
24
+ type: 'object'
25
+ }
26
+ }
27
+ }],
28
+ marks: {
29
+ type: 'array',
30
+ items: ['annotation'],
31
+ optional: true
32
+ }
33
+ },
34
+ required: ['attrs']
35
+ };
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = void 0;
7
+ // PLEASE DO NOT ADD marks IN THIS FILE
7
8
  var _default = exports.default = {
8
9
  props: {
9
10
  type: {
@@ -10,14 +10,17 @@ exports.validator = validator;
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
12
12
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
13
14
  var specs = _interopRequireWildcard(require("./specs"));
15
+ var _inlineCardWithAnnotation = require("./custom-specs/inline-card-with-annotation");
14
16
  var _utils = require("./utils");
15
17
  var _rules = require("./rules");
16
18
  var _excluded = ["items"];
17
- 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); }
18
- 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; }
19
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
20
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
19
21
  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; }
20
22
  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; }
23
+ var INLINE_NODES_SUPPORTING_COMMENTS = ['inlineCard'];
21
24
  function mapMarksItems(spec) {
22
25
  var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (x) {
23
26
  return x;
@@ -54,8 +57,12 @@ var partitionObject = function partitionObject(obj, predicate) {
54
57
  * We denormalised the spec to save bundle size.
55
58
  */
56
59
  function createSpec(nodes, marks) {
60
+ var allowCommentsOnInlineNodes = !!(0, _platformFeatureFlags.getBooleanFF)('platform.editor.allow-inline-comments-for-inline-nodes');
57
61
  return Object.keys(specs).reduce(function (newSpecs, k) {
58
62
  var spec = _objectSpread({}, specs[k]);
63
+ if (INLINE_NODES_SUPPORTING_COMMENTS.includes(k) && allowCommentsOnInlineNodes) {
64
+ spec.props = _inlineCardWithAnnotation.inlineCardWithAnnotation.props;
65
+ }
59
66
  if (spec.props) {
60
67
  spec.props = _objectSpread({}, spec.props);
61
68
  if (spec.props.content) {
@@ -0,0 +1,29 @@
1
+ // This is a custom spec we're using for inline card till the inline comments feature is fully rolled out.
2
+ export const inlineCardWithAnnotation = {
3
+ props: {
4
+ type: {
5
+ type: 'enum',
6
+ values: ['inlineCard']
7
+ },
8
+ attrs: [{
9
+ props: {
10
+ url: {
11
+ type: 'string',
12
+ validatorFn: 'safeUrl'
13
+ }
14
+ }
15
+ }, {
16
+ props: {
17
+ data: {
18
+ type: 'object'
19
+ }
20
+ }
21
+ }],
22
+ marks: {
23
+ type: 'array',
24
+ items: ['annotation'],
25
+ optional: true
26
+ }
27
+ },
28
+ required: ['attrs']
29
+ };
@@ -1,3 +1,4 @@
1
+ // PLEASE DO NOT ADD marks IN THIS FILE
1
2
  export default {
2
3
  props: {
3
4
  type: {
@@ -1,6 +1,9 @@
1
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
1
2
  import * as specs from './specs';
3
+ import { inlineCardWithAnnotation } from './custom-specs/inline-card-with-annotation';
2
4
  import { copy, isBoolean, isDefined, isInteger, isNumber, isPlainObject, isString, makeArray } from './utils';
3
5
  import { validatorFnMap } from './rules';
6
+ const INLINE_NODES_SUPPORTING_COMMENTS = ['inlineCard'];
4
7
  function mapMarksItems(spec, fn = x => x) {
5
8
  if (spec.props && spec.props.marks) {
6
9
  const {
@@ -36,10 +39,14 @@ const partitionObject = (obj, predicate) => Object.keys(obj).reduce((acc, key) =
36
39
  * We denormalised the spec to save bundle size.
37
40
  */
38
41
  function createSpec(nodes, marks) {
42
+ const allowCommentsOnInlineNodes = !!getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes');
39
43
  return Object.keys(specs).reduce((newSpecs, k) => {
40
44
  const spec = {
41
45
  ...specs[k]
42
46
  };
47
+ if (INLINE_NODES_SUPPORTING_COMMENTS.includes(k) && allowCommentsOnInlineNodes) {
48
+ spec.props = inlineCardWithAnnotation.props;
49
+ }
43
50
  if (spec.props) {
44
51
  spec.props = {
45
52
  ...spec.props
@@ -0,0 +1,29 @@
1
+ // This is a custom spec we're using for inline card till the inline comments feature is fully rolled out.
2
+ export var inlineCardWithAnnotation = {
3
+ props: {
4
+ type: {
5
+ type: 'enum',
6
+ values: ['inlineCard']
7
+ },
8
+ attrs: [{
9
+ props: {
10
+ url: {
11
+ type: 'string',
12
+ validatorFn: 'safeUrl'
13
+ }
14
+ }
15
+ }, {
16
+ props: {
17
+ data: {
18
+ type: 'object'
19
+ }
20
+ }
21
+ }],
22
+ marks: {
23
+ type: 'array',
24
+ items: ['annotation'],
25
+ optional: true
26
+ }
27
+ },
28
+ required: ['attrs']
29
+ };
@@ -1,3 +1,4 @@
1
+ // PLEASE DO NOT ADD marks IN THIS FILE
1
2
  export default {
2
3
  props: {
3
4
  type: {
@@ -4,9 +4,12 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
4
4
  var _excluded = ["items"];
5
5
  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; }
6
6
  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; }
7
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
7
8
  import * as specs from './specs';
9
+ import { inlineCardWithAnnotation } from './custom-specs/inline-card-with-annotation';
8
10
  import { copy, isBoolean, isDefined, isInteger, isNumber, isPlainObject, isString, makeArray } from './utils';
9
11
  import { validatorFnMap } from './rules';
12
+ var INLINE_NODES_SUPPORTING_COMMENTS = ['inlineCard'];
10
13
  function mapMarksItems(spec) {
11
14
  var fn = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : function (x) {
12
15
  return x;
@@ -43,8 +46,12 @@ var partitionObject = function partitionObject(obj, predicate) {
43
46
  * We denormalised the spec to save bundle size.
44
47
  */
45
48
  function createSpec(nodes, marks) {
49
+ var allowCommentsOnInlineNodes = !!getBooleanFF('platform.editor.allow-inline-comments-for-inline-nodes');
46
50
  return Object.keys(specs).reduce(function (newSpecs, k) {
47
51
  var spec = _objectSpread({}, specs[k]);
52
+ if (INLINE_NODES_SUPPORTING_COMMENTS.includes(k) && allowCommentsOnInlineNodes) {
53
+ spec.props = inlineCardWithAnnotation.props;
54
+ }
48
55
  if (spec.props) {
49
56
  spec.props = _objectSpread({}, spec.props);
50
57
  if (spec.props.content) {
@@ -1,4 +1,4 @@
1
- import { ADFEntity, ADFEntityMark } from '../types';
1
+ import type { ADFEntity, ADFEntityMark } from '../types';
2
2
  export interface MarkValidationResult {
3
3
  valid: boolean;
4
4
  originalMark: ADFEntityMark;
@@ -0,0 +1,30 @@
1
+ export declare const inlineCardWithAnnotation: {
2
+ props: {
3
+ type: {
4
+ type: string;
5
+ values: string[];
6
+ };
7
+ attrs: ({
8
+ props: {
9
+ url: {
10
+ type: string;
11
+ validatorFn: string;
12
+ };
13
+ data?: undefined;
14
+ };
15
+ } | {
16
+ props: {
17
+ data: {
18
+ type: string;
19
+ };
20
+ url?: undefined;
21
+ };
22
+ })[];
23
+ marks: {
24
+ type: string;
25
+ items: string[];
26
+ optional: boolean;
27
+ };
28
+ };
29
+ required: string[];
30
+ };
@@ -1,3 +1,3 @@
1
- import { AttributesSpec, ValidationOptions, Validate } from '../types/validatorTypes';
1
+ import type { AttributesSpec, ValidationOptions, Validate } from '../types/validatorTypes';
2
2
  export declare function validateAttrs<T>(spec: AttributesSpec, value: T): boolean;
3
3
  export declare function validator(nodes?: Array<string>, marks?: Array<string>, options?: ValidationOptions): Validate;
@@ -1,4 +1,4 @@
1
- import { ADFEntity, ADFEntityMark } from '../types';
1
+ import type { ADFEntity, ADFEntityMark } from '../types';
2
2
  export interface MarkValidationResult {
3
3
  valid: boolean;
4
4
  originalMark: ADFEntityMark;
@@ -0,0 +1,30 @@
1
+ export declare const inlineCardWithAnnotation: {
2
+ props: {
3
+ type: {
4
+ type: string;
5
+ values: string[];
6
+ };
7
+ attrs: ({
8
+ props: {
9
+ url: {
10
+ type: string;
11
+ validatorFn: string;
12
+ };
13
+ data?: undefined;
14
+ };
15
+ } | {
16
+ props: {
17
+ data: {
18
+ type: string;
19
+ };
20
+ url?: undefined;
21
+ };
22
+ })[];
23
+ marks: {
24
+ type: string;
25
+ items: string[];
26
+ optional: boolean;
27
+ };
28
+ };
29
+ required: string[];
30
+ };
@@ -1,3 +1,3 @@
1
- import { AttributesSpec, ValidationOptions, Validate } from '../types/validatorTypes';
1
+ import type { AttributesSpec, ValidationOptions, Validate } from '../types/validatorTypes';
2
2
  export declare function validateAttrs<T>(spec: AttributesSpec, value: T): boolean;
3
3
  export declare function validator(nodes?: Array<string>, marks?: Array<string>, options?: ValidationOptions): Validate;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/adf-utils",
3
- "version": "19.0.21",
3
+ "version": "19.0.22",
4
4
  "description": "Set of utilities to traverse, modify and create ADF documents.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -43,11 +43,13 @@
43
43
  "dependencies": {
44
44
  "@atlaskit/adf-schema": "^35.5.2",
45
45
  "@atlaskit/codemod-utils": "^4.2.0",
46
+ "@atlaskit/platform-feature-flags": "^0.2.0",
46
47
  "@babel/runtime": "^7.0.0"
47
48
  },
48
49
  "devDependencies": {
49
50
  "@atlassian/adf-schema-json": "^1.0.7",
50
51
  "@atlassian/atlassian-frontend-prettier-config-1.0.1": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.1",
52
+ "@atlassian/feature-flags-test-utils": "*",
51
53
  "jscodeshift": "^0.13.0",
52
54
  "react": "^16.8.0",
53
55
  "typescript": "~4.9.5",
@@ -66,5 +68,10 @@
66
68
  ]
67
69
  }
68
70
  },
69
- "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1"
71
+ "prettier": "@atlassian/atlassian-frontend-prettier-config-1.0.1",
72
+ "platform-feature-flags": {
73
+ "platform.editor.allow-inline-comments-for-inline-nodes": {
74
+ "type": "boolean"
75
+ }
76
+ }
70
77
  }