@atlaskit/editor-common 111.14.3 → 111.15.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @atlaskit/editor-common
2
2
 
3
+ ## 111.15.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`aac76ca1cde5b`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/aac76ca1cde5b) -
8
+ Fix hydration error with dates in task lists
9
+ - [`9d211d563dcfb`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/9d211d563dcfb) -
10
+ Add transformer option to requestDocument core API.
11
+
12
+ ### Patch Changes
13
+
14
+ - Updated dependencies
15
+
3
16
  ## 111.14.3
4
17
 
5
18
  ### Patch Changes
@@ -19,7 +19,7 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
19
19
  function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
20
20
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
21
21
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
22
- var packageVersion = "111.14.2";
22
+ var packageVersion = "111.14.3";
23
23
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
24
24
  // Remove URL as it has UGC
25
25
  // Ignored via go/ees007
@@ -91,7 +91,7 @@ var corePlugin = exports.corePlugin = function corePlugin(_ref) {
91
91
  }
92
92
  var state = editorView.state;
93
93
  var schema = state.schema;
94
- var content = options !== null && options !== void 0 && options.skipValidation ? (0, _processRawValue.processRawValueWithoutValidation)(schema, replaceValue) : Array.isArray(replaceValue) ? (0, _processRawValue.processRawFragmentValue)(schema, replaceValue) : (0, _processRawValue.processRawValue)(schema, replaceValue);
94
+ var content = options !== null && options !== void 0 && options.skipValidation ? (0, _processRawValue.processRawValueWithoutValidation)(schema, replaceValue) : Array.isArray(replaceValue) ? (0, _processRawValue.processRawFragmentValue)(schema, replaceValue, undefined, undefined, options === null || options === void 0 ? void 0 : options.transformer) : (0, _processRawValue.processRawValue)(schema, replaceValue, undefined, undefined, options === null || options === void 0 ? void 0 : options.transformer);
95
95
 
96
96
  // Don't replace the document if it's the same document, as full size
97
97
  // replace transactions cause issues for collaborative editing and
@@ -24,7 +24,7 @@ function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.
24
24
  * @jsx jsx
25
25
  */ // eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
26
26
  var packageName = "@atlaskit/editor-common";
27
- var packageVersion = "111.14.2";
27
+ var packageVersion = "111.14.3";
28
28
  var halfFocusRing = 1;
29
29
  var dropOffset = '0, 8';
30
30
  var fadeIn = (0, _react2.keyframes)({
@@ -7,6 +7,7 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.todayTimestampInUTC = exports.timestampToUTCDate = exports.timestampToTaskContext = exports.timestampToString = exports.timestampToIsoFormat = exports.isPastDate = void 0;
8
8
  var _differenceInCalendarDays = _interopRequireDefault(require("date-fns/differenceInCalendarDays"));
9
9
  var _isBefore = _interopRequireDefault(require("date-fns/isBefore"));
10
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
10
11
  var FORMATS = /*#__PURE__*/function (FORMATS) {
11
12
  FORMATS["ISO_FORMAT"] = "YYYY-MM-DD";
12
13
  FORMATS["LOCALIZED_FORMAT"] = "LOCALIZED_FORMAT";
@@ -23,8 +24,27 @@ var timestampToUTCDate = exports.timestampToUTCDate = function timestampToUTCDat
23
24
  year: year
24
25
  };
25
26
  };
26
- var todayTimestampInUTC = exports.todayTimestampInUTC = function todayTimestampInUTC() {
27
+ var todayTimestampInUTC = exports.todayTimestampInUTC = function todayTimestampInUTC(timeZone) {
27
28
  var today = new Date(Date.now());
29
+ if (timeZone && (0, _expValEquals.expValEquals)('confluence_frontend_fix_date_hydration_error', 'isEnabled', true)) {
30
+ var _parts$find, _parts$find2, _parts$find3;
31
+ var parts = new Intl.DateTimeFormat('en-US', {
32
+ timeZone: timeZone,
33
+ year: 'numeric',
34
+ month: 'numeric',
35
+ day: 'numeric'
36
+ }).formatToParts(today);
37
+ var year = Number((_parts$find = parts.find(function (p) {
38
+ return p.type === 'year';
39
+ })) === null || _parts$find === void 0 ? void 0 : _parts$find.value);
40
+ var month = Number((_parts$find2 = parts.find(function (p) {
41
+ return p.type === 'month';
42
+ })) === null || _parts$find2 === void 0 ? void 0 : _parts$find2.value) - 1;
43
+ var day = Number((_parts$find3 = parts.find(function (p) {
44
+ return p.type === 'day';
45
+ })) === null || _parts$find3 === void 0 ? void 0 : _parts$find3.value);
46
+ return Date.UTC(year, month, day).toString();
47
+ }
28
48
  var todayInUTC = Date.UTC(today.getFullYear(), today.getMonth(), today.getDate());
29
49
  return todayInUTC.toString();
30
50
  };
@@ -58,11 +78,11 @@ var timestampToIsoFormat = exports.timestampToIsoFormat = function timestampToIs
58
78
  var date = new Date(Number(timestamp));
59
79
  return "".concat(date.getUTCFullYear(), "-").concat(addLeadingZero(date.getUTCMonth() + 1), "-").concat(addLeadingZero(date.getUTCDate()));
60
80
  };
61
- var isPastDate = exports.isPastDate = function isPastDate(timestamp) {
62
- return (0, _isBefore.default)(new Date(Number(timestamp)), new Date(Number(todayTimestampInUTC())));
81
+ var isPastDate = exports.isPastDate = function isPastDate(timestamp, timeZone) {
82
+ return (0, _isBefore.default)(new Date(Number(timestamp)), new Date(Number(todayTimestampInUTC(timeZone))));
63
83
  };
64
- var timestampToTaskContext = exports.timestampToTaskContext = function timestampToTaskContext(timestamp, intl) {
65
- var curDate = new Date(Number(todayTimestampInUTC()));
84
+ var timestampToTaskContext = exports.timestampToTaskContext = function timestampToTaskContext(timestamp, intl, timeZone) {
85
+ var curDate = new Date(Number(todayTimestampInUTC(timeZone)));
66
86
  var givenDate = new Date(Number(timestamp));
67
87
  var distance = (0, _differenceInCalendarDays.default)(givenDate, curDate);
68
88
  if (intl && [-1, 0, 1].indexOf(distance) > -1) {
@@ -4,7 +4,7 @@ import { isFedRamp } from './environment';
4
4
  import { normaliseSentryBreadcrumbs, SERIALIZABLE_ATTRIBUTES } from './normalise-sentry-breadcrumbs';
5
5
  const SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
6
6
  const packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
7
- const packageVersion = "111.14.2";
7
+ const packageVersion = "111.14.3";
8
8
  const sanitiseSentryEvents = (data, _hint) => {
9
9
  // Remove URL as it has UGC
10
10
  // Ignored via go/ees007
@@ -93,7 +93,7 @@ export const corePlugin = ({
93
93
  const {
94
94
  schema
95
95
  } = state;
96
- const content = options !== null && options !== void 0 && options.skipValidation ? processRawValueWithoutValidation(schema, replaceValue) : Array.isArray(replaceValue) ? processRawFragmentValue(schema, replaceValue) : processRawValue(schema, replaceValue);
96
+ const content = options !== null && options !== void 0 && options.skipValidation ? processRawValueWithoutValidation(schema, replaceValue) : Array.isArray(replaceValue) ? processRawFragmentValue(schema, replaceValue, undefined, undefined, options === null || options === void 0 ? void 0 : options.transformer) : processRawValue(schema, replaceValue, undefined, undefined, options === null || options === void 0 ? void 0 : options.transformer);
97
97
 
98
98
  // Don't replace the document if it's the same document, as full size
99
99
  // replace transactions cause issues for collaborative editing and
@@ -14,7 +14,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
14
14
  import { fg } from '@atlaskit/platform-feature-flags';
15
15
  import Layer from '../Layer';
16
16
  const packageName = "@atlaskit/editor-common";
17
- const packageVersion = "111.14.2";
17
+ const packageVersion = "111.14.3";
18
18
  const halfFocusRing = 1;
19
19
  const dropOffset = '0, 8';
20
20
  const fadeIn = keyframes({
@@ -1,5 +1,6 @@
1
1
  import differenceInCalendarDays from 'date-fns/differenceInCalendarDays';
2
2
  import isBefore from 'date-fns/isBefore';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  var FORMATS = /*#__PURE__*/function (FORMATS) {
4
5
  FORMATS["ISO_FORMAT"] = "YYYY-MM-DD";
5
6
  FORMATS["LOCALIZED_FORMAT"] = "LOCALIZED_FORMAT";
@@ -16,8 +17,21 @@ export const timestampToUTCDate = timestamp => {
16
17
  year
17
18
  };
18
19
  };
19
- export const todayTimestampInUTC = () => {
20
+ export const todayTimestampInUTC = timeZone => {
20
21
  const today = new Date(Date.now());
22
+ if (timeZone && expValEquals('confluence_frontend_fix_date_hydration_error', 'isEnabled', true)) {
23
+ var _parts$find, _parts$find2, _parts$find3;
24
+ const parts = new Intl.DateTimeFormat('en-US', {
25
+ timeZone,
26
+ year: 'numeric',
27
+ month: 'numeric',
28
+ day: 'numeric'
29
+ }).formatToParts(today);
30
+ const year = Number((_parts$find = parts.find(p => p.type === 'year')) === null || _parts$find === void 0 ? void 0 : _parts$find.value);
31
+ const month = Number((_parts$find2 = parts.find(p => p.type === 'month')) === null || _parts$find2 === void 0 ? void 0 : _parts$find2.value) - 1;
32
+ const day = Number((_parts$find3 = parts.find(p => p.type === 'day')) === null || _parts$find3 === void 0 ? void 0 : _parts$find3.value);
33
+ return Date.UTC(year, month, day).toString();
34
+ }
21
35
  const todayInUTC = Date.UTC(today.getFullYear(), today.getMonth(), today.getDate());
22
36
  return todayInUTC.toString();
23
37
  };
@@ -51,11 +65,11 @@ export const timestampToIsoFormat = timestamp => {
51
65
  const date = new Date(Number(timestamp));
52
66
  return `${date.getUTCFullYear()}-${addLeadingZero(date.getUTCMonth() + 1)}-${addLeadingZero(date.getUTCDate())}`;
53
67
  };
54
- export const isPastDate = timestamp => {
55
- return isBefore(new Date(Number(timestamp)), new Date(Number(todayTimestampInUTC())));
68
+ export const isPastDate = (timestamp, timeZone) => {
69
+ return isBefore(new Date(Number(timestamp)), new Date(Number(todayTimestampInUTC(timeZone))));
56
70
  };
57
- export const timestampToTaskContext = (timestamp, intl) => {
58
- const curDate = new Date(Number(todayTimestampInUTC()));
71
+ export const timestampToTaskContext = (timestamp, intl, timeZone) => {
72
+ const curDate = new Date(Number(todayTimestampInUTC(timeZone)));
59
73
  const givenDate = new Date(Number(timestamp));
60
74
  const distance = differenceInCalendarDays(givenDate, curDate);
61
75
  if (intl && [-1, 0, 1].indexOf(distance) > -1) {
@@ -10,7 +10,7 @@ import { isFedRamp } from './environment';
10
10
  import { normaliseSentryBreadcrumbs, SERIALIZABLE_ATTRIBUTES } from './normalise-sentry-breadcrumbs';
11
11
  var SENTRY_DSN = 'https://0b10c8e02fb44d8796c047b102c9bee8@o55978.ingest.sentry.io/4505129224110080';
12
12
  var packageName = 'editor-common'; // Sentry doesn't accept '/' in its releases https://docs.sentry.io/platforms/javascript/configuration/releases/
13
- var packageVersion = "111.14.2";
13
+ var packageVersion = "111.14.3";
14
14
  var sanitiseSentryEvents = function sanitiseSentryEvents(data, _hint) {
15
15
  // Remove URL as it has UGC
16
16
  // Ignored via go/ees007
@@ -86,7 +86,7 @@ export var corePlugin = function corePlugin(_ref) {
86
86
  }
87
87
  var state = editorView.state;
88
88
  var schema = state.schema;
89
- var content = options !== null && options !== void 0 && options.skipValidation ? processRawValueWithoutValidation(schema, replaceValue) : Array.isArray(replaceValue) ? processRawFragmentValue(schema, replaceValue) : processRawValue(schema, replaceValue);
89
+ var content = options !== null && options !== void 0 && options.skipValidation ? processRawValueWithoutValidation(schema, replaceValue) : Array.isArray(replaceValue) ? processRawFragmentValue(schema, replaceValue, undefined, undefined, options === null || options === void 0 ? void 0 : options.transformer) : processRawValue(schema, replaceValue, undefined, undefined, options === null || options === void 0 ? void 0 : options.transformer);
90
90
 
91
91
  // Don't replace the document if it's the same document, as full size
92
92
  // replace transactions cause issues for collaborative editing and
@@ -21,7 +21,7 @@ import withAnalyticsEvents from '@atlaskit/analytics-next/withAnalyticsEvents';
21
21
  import { fg } from '@atlaskit/platform-feature-flags';
22
22
  import Layer from '../Layer';
23
23
  var packageName = "@atlaskit/editor-common";
24
- var packageVersion = "111.14.2";
24
+ var packageVersion = "111.14.3";
25
25
  var halfFocusRing = 1;
26
26
  var dropOffset = '0, 8';
27
27
  var fadeIn = keyframes({
@@ -1,5 +1,6 @@
1
1
  import differenceInCalendarDays from 'date-fns/differenceInCalendarDays';
2
2
  import isBefore from 'date-fns/isBefore';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  var FORMATS = /*#__PURE__*/function (FORMATS) {
4
5
  FORMATS["ISO_FORMAT"] = "YYYY-MM-DD";
5
6
  FORMATS["LOCALIZED_FORMAT"] = "LOCALIZED_FORMAT";
@@ -16,8 +17,27 @@ export var timestampToUTCDate = function timestampToUTCDate(timestamp) {
16
17
  year: year
17
18
  };
18
19
  };
19
- export var todayTimestampInUTC = function todayTimestampInUTC() {
20
+ export var todayTimestampInUTC = function todayTimestampInUTC(timeZone) {
20
21
  var today = new Date(Date.now());
22
+ if (timeZone && expValEquals('confluence_frontend_fix_date_hydration_error', 'isEnabled', true)) {
23
+ var _parts$find, _parts$find2, _parts$find3;
24
+ var parts = new Intl.DateTimeFormat('en-US', {
25
+ timeZone: timeZone,
26
+ year: 'numeric',
27
+ month: 'numeric',
28
+ day: 'numeric'
29
+ }).formatToParts(today);
30
+ var year = Number((_parts$find = parts.find(function (p) {
31
+ return p.type === 'year';
32
+ })) === null || _parts$find === void 0 ? void 0 : _parts$find.value);
33
+ var month = Number((_parts$find2 = parts.find(function (p) {
34
+ return p.type === 'month';
35
+ })) === null || _parts$find2 === void 0 ? void 0 : _parts$find2.value) - 1;
36
+ var day = Number((_parts$find3 = parts.find(function (p) {
37
+ return p.type === 'day';
38
+ })) === null || _parts$find3 === void 0 ? void 0 : _parts$find3.value);
39
+ return Date.UTC(year, month, day).toString();
40
+ }
21
41
  var todayInUTC = Date.UTC(today.getFullYear(), today.getMonth(), today.getDate());
22
42
  return todayInUTC.toString();
23
43
  };
@@ -51,11 +71,11 @@ export var timestampToIsoFormat = function timestampToIsoFormat(timestamp) {
51
71
  var date = new Date(Number(timestamp));
52
72
  return "".concat(date.getUTCFullYear(), "-").concat(addLeadingZero(date.getUTCMonth() + 1), "-").concat(addLeadingZero(date.getUTCDate()));
53
73
  };
54
- export var isPastDate = function isPastDate(timestamp) {
55
- return isBefore(new Date(Number(timestamp)), new Date(Number(todayTimestampInUTC())));
74
+ export var isPastDate = function isPastDate(timestamp, timeZone) {
75
+ return isBefore(new Date(Number(timestamp)), new Date(Number(todayTimestampInUTC(timeZone))));
56
76
  };
57
- export var timestampToTaskContext = function timestampToTaskContext(timestamp, intl) {
58
- var curDate = new Date(Number(todayTimestampInUTC()));
77
+ export var timestampToTaskContext = function timestampToTaskContext(timestamp, intl, timeZone) {
78
+ var curDate = new Date(Number(todayTimestampInUTC(timeZone)));
59
79
  var givenDate = new Date(Number(timestamp));
60
80
  var distance = differenceInCalendarDays(givenDate, curDate);
61
81
  if (intl && [-1, 0, 1].indexOf(distance) > -1) {
@@ -69,12 +69,14 @@ export type CorePlugin = NextEditorPlugin<'core', {
69
69
  * @param options.addToHistory (boolean) if the replacement should be added to history. True by default
70
70
  * @param options.scrollIntoView (boolean) if the view should also scroll on replace. True by default
71
71
  * @param options.skipValidation (boolean) if the validation should be skipped. False by default
72
+ * @param options.transformer (Transformer<string>) transformer to convert the replaceValue into (example is from markdown)
72
73
  * @returns A boolean indicating whether the replacement was successful.
73
74
  */
74
75
  replaceDocument: (replaceValue: Node | Fragment | Array<Node> | Object | string, options?: {
75
76
  addToHistory?: boolean;
76
77
  scrollIntoView?: boolean;
77
78
  skipValidation?: boolean;
79
+ transformer?: Transformer<string>;
78
80
  }) => boolean;
79
81
  /**
80
82
  * Request the editor document.
@@ -9,9 +9,9 @@ export interface Date {
9
9
  year: number;
10
10
  }
11
11
  export declare const timestampToUTCDate: (timestamp: string | number) => Date;
12
- export declare const todayTimestampInUTC: () => string;
12
+ export declare const todayTimestampInUTC: (timeZone?: string) => string;
13
13
  export declare const timestampToString: (timestamp: string | number, intl: IntlShape | null, pattern?: FORMATS) => string;
14
14
  export declare const timestampToIsoFormat: (timestamp: string | number) => string;
15
- export declare const isPastDate: (timestamp: string | number) => boolean;
16
- export declare const timestampToTaskContext: (timestamp: string | number, intl: IntlShape) => string;
15
+ export declare const isPastDate: (timestamp: string | number, timeZone?: string) => boolean;
16
+ export declare const timestampToTaskContext: (timestamp: string | number, intl: IntlShape, timeZone?: string) => string;
17
17
  export {};
@@ -69,12 +69,14 @@ export type CorePlugin = NextEditorPlugin<'core', {
69
69
  * @param options.addToHistory (boolean) if the replacement should be added to history. True by default
70
70
  * @param options.scrollIntoView (boolean) if the view should also scroll on replace. True by default
71
71
  * @param options.skipValidation (boolean) if the validation should be skipped. False by default
72
+ * @param options.transformer (Transformer<string>) transformer to convert the replaceValue into (example is from markdown)
72
73
  * @returns A boolean indicating whether the replacement was successful.
73
74
  */
74
75
  replaceDocument: (replaceValue: Node | Fragment | Array<Node> | Object | string, options?: {
75
76
  addToHistory?: boolean;
76
77
  scrollIntoView?: boolean;
77
78
  skipValidation?: boolean;
79
+ transformer?: Transformer<string>;
78
80
  }) => boolean;
79
81
  /**
80
82
  * Request the editor document.
@@ -9,9 +9,9 @@ export interface Date {
9
9
  year: number;
10
10
  }
11
11
  export declare const timestampToUTCDate: (timestamp: string | number) => Date;
12
- export declare const todayTimestampInUTC: () => string;
12
+ export declare const todayTimestampInUTC: (timeZone?: string) => string;
13
13
  export declare const timestampToString: (timestamp: string | number, intl: IntlShape | null, pattern?: FORMATS) => string;
14
14
  export declare const timestampToIsoFormat: (timestamp: string | number) => string;
15
- export declare const isPastDate: (timestamp: string | number) => boolean;
16
- export declare const timestampToTaskContext: (timestamp: string | number, intl: IntlShape) => string;
15
+ export declare const isPastDate: (timestamp: string | number, timeZone?: string) => boolean;
16
+ export declare const timestampToTaskContext: (timestamp: string | number, intl: IntlShape, timeZone?: string) => string;
17
17
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "111.14.3",
3
+ "version": "111.15.0",
4
4
  "description": "A package that contains common classes and components for editor and renderer",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -81,7 +81,7 @@
81
81
  "@atlaskit/task-decision": "^19.2.0",
82
82
  "@atlaskit/textfield": "^8.2.0",
83
83
  "@atlaskit/theme": "^21.0.0",
84
- "@atlaskit/tmp-editor-statsig": "^25.4.0",
84
+ "@atlaskit/tmp-editor-statsig": "^25.5.0",
85
85
  "@atlaskit/tokens": "^11.0.0",
86
86
  "@atlaskit/tooltip": "^20.14.0",
87
87
  "@atlaskit/width-detector": "^5.0.0",