@atlaskit/editor-common 72.7.2 → 72.8.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 (93) hide show
  1. package/.eslintrc.js +13 -0
  2. package/CHANGELOG.md +44 -0
  3. package/dist/cjs/analytics/types/general-events.js +1 -1
  4. package/dist/cjs/analytics/types/table-events.js +3 -1
  5. package/dist/cjs/card/index.js +20 -1
  6. package/dist/cjs/card/utils.js +54 -0
  7. package/dist/cjs/extensions/default-extension-provider.js +8 -7
  8. package/dist/cjs/extensions/extension-fields-helpers.js +12 -11
  9. package/dist/cjs/extensions/extension-handlers.js +6 -5
  10. package/dist/cjs/extensions/manifest-helpers.js +4 -3
  11. package/dist/cjs/extensions/module-helpers.js +8 -7
  12. package/dist/cjs/keymaps/index.js +6 -1
  13. package/dist/cjs/preset/builder.js +2 -1
  14. package/dist/cjs/provider-helpers/combine-providers.js +10 -9
  15. package/dist/cjs/styles/shared/panel.js +1 -0
  16. package/dist/cjs/styles/shared/shadow.js +1 -0
  17. package/dist/cjs/styles/shared/table.js +1 -0
  18. package/dist/cjs/styles/shared/tableCell.js +1 -0
  19. package/dist/cjs/ui/Caption/index.js +1 -0
  20. package/dist/cjs/ui/DropList/index.js +3 -2
  21. package/dist/cjs/ui/Expand/index.js +1 -0
  22. package/dist/cjs/ui/Layer/index.js +1 -1
  23. package/dist/cjs/ui/MediaSingle/styled.js +5 -4
  24. package/dist/cjs/ui/Messages/index.js +1 -0
  25. package/dist/cjs/ui/Popup/index.js +4 -0
  26. package/dist/cjs/ui/UnsupportedBlock/index.js +1 -0
  27. package/dist/cjs/ui/UnsupportedInline/index.js +1 -0
  28. package/dist/cjs/ui/WidthProvider/index.js +1 -1
  29. package/dist/cjs/ui-color/ColorPalette/Color/index.js +1 -1
  30. package/dist/cjs/ui-color/ColorPalette/Palettes/index.js +6 -0
  31. package/dist/cjs/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +199 -1
  32. package/dist/cjs/ui-color/ColorPalette/Palettes/panelBackgroundPalette.js +2 -1
  33. package/dist/cjs/ui-color/index.js +6 -0
  34. package/dist/cjs/ui-menu/DropdownMenu/index.js +1 -0
  35. package/dist/cjs/ui-menu/ToolbarButton/index.js +1 -0
  36. package/dist/cjs/ui-react/with-react-editor-view-outer-listeners.js +1 -0
  37. package/dist/cjs/utils/validator.js +22 -0
  38. package/dist/cjs/version.json +1 -1
  39. package/dist/cjs/with-plugin-state/index.js +9 -0
  40. package/dist/es2019/analytics/types/general-events.js +1 -1
  41. package/dist/es2019/analytics/types/table-events.js +3 -1
  42. package/dist/es2019/card/index.js +1 -1
  43. package/dist/es2019/card/utils.js +47 -0
  44. package/dist/es2019/extensions/types/field-definitions.js +0 -1
  45. package/dist/es2019/index.js +1 -1
  46. package/dist/es2019/keymaps/index.js +2 -0
  47. package/dist/es2019/preset/builder.js +2 -1
  48. package/dist/es2019/ui/DropList/index.js +2 -1
  49. package/dist/es2019/ui/MediaSingle/styled.js +3 -0
  50. package/dist/es2019/ui/Popup/index.js +5 -0
  51. package/dist/es2019/ui-color/ColorPalette/Palettes/index.js +1 -1
  52. package/dist/es2019/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +198 -0
  53. package/dist/es2019/ui-color/index.js +1 -1
  54. package/dist/es2019/ui-react/with-react-editor-view-outer-listeners.js +3 -0
  55. package/dist/es2019/utils/dom.js +0 -1
  56. package/dist/es2019/utils/validator.js +23 -0
  57. package/dist/es2019/version.json +1 -1
  58. package/dist/es2019/with-plugin-state/index.js +10 -0
  59. package/dist/esm/analytics/types/general-events.js +1 -1
  60. package/dist/esm/analytics/types/table-events.js +3 -1
  61. package/dist/esm/card/index.js +1 -1
  62. package/dist/esm/card/utils.js +45 -0
  63. package/dist/esm/extensions/default-extension-provider.js +8 -7
  64. package/dist/esm/extensions/extension-fields-helpers.js +12 -11
  65. package/dist/esm/extensions/extension-handlers.js +6 -5
  66. package/dist/esm/extensions/manifest-helpers.js +4 -3
  67. package/dist/esm/extensions/module-helpers.js +8 -7
  68. package/dist/esm/extensions/types/field-definitions.js +0 -1
  69. package/dist/esm/index.js +1 -1
  70. package/dist/esm/keymaps/index.js +2 -0
  71. package/dist/esm/preset/builder.js +2 -1
  72. package/dist/esm/provider-helpers/combine-providers.js +10 -9
  73. package/dist/esm/ui/DropList/index.js +2 -1
  74. package/dist/esm/ui/MediaSingle/styled.js +4 -4
  75. package/dist/esm/ui/Popup/index.js +4 -0
  76. package/dist/esm/ui-color/ColorPalette/Palettes/index.js +1 -1
  77. package/dist/esm/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.js +196 -0
  78. package/dist/esm/ui-color/index.js +1 -1
  79. package/dist/esm/ui-react/with-react-editor-view-outer-listeners.js +2 -0
  80. package/dist/esm/utils/dom.js +0 -1
  81. package/dist/esm/utils/validator.js +23 -0
  82. package/dist/esm/version.json +1 -1
  83. package/dist/esm/with-plugin-state/index.js +9 -0
  84. package/dist/types/analytics/types/smart-links.d.ts +1 -1
  85. package/dist/types/card/cardOptions.d.ts +2 -0
  86. package/dist/types/card/index.d.ts +1 -0
  87. package/dist/types/card/utils.d.ts +18 -0
  88. package/dist/types/keymaps/index.d.ts +2 -0
  89. package/dist/types/types/feature-flags.d.ts +7 -0
  90. package/dist/types/ui-color/ColorPalette/Palettes/index.d.ts +1 -1
  91. package/dist/types/ui-color/ColorPalette/Palettes/paletteMessagesTokenModeNames.d.ts +548 -0
  92. package/dist/types/ui-color/index.d.ts +1 -1
  93. package/package.json +9 -9
@@ -24,6 +24,11 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
24
24
  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; } }
25
25
  var DEFAULT_SAMPLING_RATE = 100;
26
26
  var DEFAULT_SLOW_THRESHOLD = 4;
27
+
28
+ // That context was exctract from the old WithPluginState from editor-core
29
+ // It was using some private types from
30
+ // - EditorAction: packages/editor/editor-core/src/actions/index.ts
31
+ // - EditorSharedConfig: packages/editor/editor-core/src/labs/next/internal/context/shared-config.tsx
27
32
  /**
28
33
  * Wraps component in a high order component that watches state changes of given plugins
29
34
  * and passes those states to the wrapped component.
@@ -133,6 +138,10 @@ var WithPluginState = /*#__PURE__*/function (_React$Component) {
133
138
  var props = maybeProps || this.props;
134
139
  return props.eventDispatcher || this.context && this.context.editorActions && this.context.editorActions._privateGetEventDispatcher() || this.context && this.context.editorSharedConfig && this.context.editorSharedConfig.eventDispatcher;
135
140
  }
141
+
142
+ /**
143
+ * Debounces setState calls in order to reduce number of re-renders caused by several plugin state changes.
144
+ */
136
145
  }, {
137
146
  key: "getPluginsStates",
138
147
  value: function getPluginsStates(plugins, editorView) {
@@ -20,4 +20,4 @@ export let BROWSER_FREEZE_INTERACTION_TYPE;
20
20
  BROWSER_FREEZE_INTERACTION_TYPE["TYPING"] = "typing";
21
21
  BROWSER_FREEZE_INTERACTION_TYPE["CLICKING"] = "clicking";
22
22
  BROWSER_FREEZE_INTERACTION_TYPE["PASTING"] = "pasting";
23
- })(BROWSER_FREEZE_INTERACTION_TYPE || (BROWSER_FREEZE_INTERACTION_TYPE = {}));
23
+ })(BROWSER_FREEZE_INTERACTION_TYPE || (BROWSER_FREEZE_INTERACTION_TYPE = {})); // TODO: https://product-fabric.atlassian.net/browse/AFP-1418
@@ -31,4 +31,6 @@ export let TABLE_BREAKOUT;
31
31
  TABLE_BREAKOUT["WIDE"] = "wide";
32
32
  TABLE_BREAKOUT["FULL_WIDTH"] = "fullWidth";
33
33
  TABLE_BREAKOUT["NORMAL"] = "normal";
34
- })(TABLE_BREAKOUT || (TABLE_BREAKOUT = {}));
34
+ })(TABLE_BREAKOUT || (TABLE_BREAKOUT = {})); //#endregion
35
+ //#region Analytic Event Payloads
36
+ //#endregion
@@ -1 +1 @@
1
- export {};
1
+ export { addLinkMetadata, getLinkMetadataFromTransaction, commandWithMetadata } from './utils';
@@ -0,0 +1,47 @@
1
+ import { LinkMetaStep } from '@atlaskit/adf-schema/steps';
2
+
3
+ /**
4
+ * Records metadata about the user action and input method relating to a transaction
5
+ * as a custom LinkStepMetadata prosemirror step so that it is preserved in
6
+ * the history for undo/redo
7
+ */
8
+ export function addLinkMetadata(initialSelection, tr, metadata) {
9
+ const {
10
+ storedMarks
11
+ } = tr;
12
+ const pos = tr.mapping.map(initialSelection.$from.pos);
13
+ tr.step(new LinkMetaStep(pos, metadata));
14
+
15
+ // When you add a new step all the storedMarks are removed it
16
+ if (storedMarks) {
17
+ tr.setStoredMarks(storedMarks);
18
+ }
19
+ return tr;
20
+ }
21
+ export function getLinkMetadataFromTransaction(tr) {
22
+ return tr.steps.reduce((metadata, step) => {
23
+ if (!(step instanceof LinkMetaStep)) {
24
+ return metadata;
25
+ }
26
+ return {
27
+ ...metadata,
28
+ ...step.getMetadata()
29
+ };
30
+ }, {});
31
+ }
32
+ /**
33
+ * Adds metadata to the transaction created from a command
34
+ * The metadata describes the user intent and input method
35
+ * for executing the command
36
+ */
37
+ export const commandWithMetadata = (command, metadata) => {
38
+ return (state, dispatch, view) => {
39
+ if (!dispatch) {
40
+ return command(state, dispatch, view);
41
+ }
42
+ return command(state, tr => {
43
+ addLinkMetadata(state.selection, tr, metadata);
44
+ dispatch(tr);
45
+ }, view);
46
+ };
47
+ };
@@ -2,7 +2,6 @@
2
2
  // Thereby they _always_ need a value for submission
3
3
  //
4
4
  // You can do that through `defaultValue`, or `isRequired: true`
5
-
6
5
  export const isFieldset = field => {
7
6
  return field.type === 'fieldset';
8
7
  };
@@ -1,2 +1,2 @@
1
- // DO NOT EMPORT ANYTHING FROM THIS FILE. USE CHILD ENTRY POINTS
1
+ // DO NOT EMPORT ANYTHING FROM THIS FILE. USE CHILD ENTRY POINTS.
2
2
  export {};
@@ -4,6 +4,8 @@ import { css, jsx } from '@emotion/react';
4
4
  import { N400 } from '@atlaskit/theme/colors';
5
5
  import { browser } from '../utils';
6
6
  export const addAltText = makeKeyMapWithCommon('Add Alt Text', 'Mod-Alt-y');
7
+ export const navToEditorToolbar = makeKeyMapWithCommon('Navigate to editor toolbar', 'Alt-F9');
8
+ export const navToFloatingToolbar = makeKeyMapWithCommon('Navigate to floating toolbar', 'Alt-F10');
7
9
  export const toggleBold = makeKeyMapWithCommon('Bold', 'Mod-b');
8
10
  export const toggleItalic = makeKeyMapWithCommon('Italic', 'Mod-i');
9
11
  export const toggleUnderline = makeKeyMapWithCommon('Underline', 'Mod-u');
@@ -71,7 +71,8 @@ export class EditorPresetBuilder {
71
71
  }) {
72
72
  this.verifyDuplicatedPlugins();
73
73
  const seen = new Set();
74
- const plugins = this.data.reverse().map(entry => {
74
+ const pluginsDataCopy = this.data.slice();
75
+ const plugins = pluginsDataCopy.reverse().map(entry => {
75
76
  const [fn, config] = this.safeEntry(entry);
76
77
  if (seen.has(fn)) {
77
78
  return null;
@@ -8,7 +8,7 @@ import { themed } from '@atlaskit/theme/components';
8
8
  import { borderRadius, gridSize } from '@atlaskit/theme/constants';
9
9
  import Layer from '../Layer';
10
10
  const packageName = "@atlaskit/editor-common";
11
- const packageVersion = "72.7.2";
11
+ const packageVersion = "72.8.0";
12
12
  const halfFocusRing = 1;
13
13
  const dropOffset = `0, ${gridSize()}px`;
14
14
  class DropList extends Component {
@@ -115,6 +115,7 @@ class DropList extends Component {
115
115
  this.triggerRef = ref;
116
116
  });
117
117
  }
118
+ /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
118
119
  /* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
119
120
 
120
121
  getChildContext() {
@@ -109,6 +109,9 @@ export const MediaSingleDimensionHelper = ({
109
109
  }
110
110
 
111
111
  width: ${pctWidth ? calcResizedWidth(layout, width || 0, containerWidth) : calcLegacyWidth(layout, width || 0, containerWidth, fullWidthMode, isResized)};
112
+ ${layout === 'full-width' && css`
113
+ min-width: 100%;
114
+ `}
112
115
  max-width: ${calcMaxWidth(layout, containerWidth)};
113
116
  float: ${float(layout)};
114
117
  margin: ${calcMargin(layout)};
@@ -151,6 +151,11 @@ export default class Popup extends React.Component {
151
151
  // get rendered and we end up with a wrong position
152
152
  this.scheduledUpdatePosition(newProps);
153
153
  }
154
+
155
+ /**
156
+ * Raf scheduled so that it also occurs after the initial update position
157
+ */
158
+
154
159
  /**
155
160
  * Cancels the initialisation of the focus trap if it has not yet occured
156
161
  * Deactivates the focus trap if it exists
@@ -1,2 +1,2 @@
1
1
  export { DEFAULT_BORDER_COLOR } from './common';
2
- export { textPaletteTooltipMessages, backgroundPaletteTooltipMessages, borderPaletteTooltipMessages } from './paletteMessagesTokenModeNames';
2
+ export { backgroundPaletteTooltipMessages, borderPaletteTooltipMessages, chartsColorPaletteTooltipMessages, textPaletteTooltipMessages } from './paletteMessagesTokenModeNames';
@@ -250,6 +250,204 @@ export const backgroundPaletteTooltipMessages = {
250
250
  light: lightBackgroundPaletteTooltipMessages,
251
251
  dark: darkBackgroundPaletteTooltipMessages
252
252
  };
253
+ export const lightChartsColorPaletteTooltipMessages = defineMessages({
254
+ // Blue color
255
+ '#7AB2FF': {
256
+ id: 'fabric.theme.subtle-blue',
257
+ defaultMessage: 'Subtle blue',
258
+ description: 'Name of a color'
259
+ },
260
+ '#247FFF': {
261
+ id: 'fabric.theme.blue',
262
+ defaultMessage: 'Blue',
263
+ description: 'Name of a color'
264
+ },
265
+ '#0055CC': {
266
+ id: 'fabric.theme.bold-blue',
267
+ defaultMessage: 'Bold blue',
268
+ description: 'Name of a color'
269
+ },
270
+ '#003884': {
271
+ id: 'fabric.theme.bolder-blue',
272
+ defaultMessage: 'Bolder blue',
273
+ description: 'Name of a color'
274
+ },
275
+ // Teal color
276
+ '#60C6D2': {
277
+ id: 'fabric.theme.subtle-teal',
278
+ defaultMessage: 'Subtle teal',
279
+ description: 'Name of a color'
280
+ },
281
+ '#1D9AAA': {
282
+ id: 'fabric.theme.teal',
283
+ defaultMessage: 'Teal',
284
+ description: 'Name of a color'
285
+ },
286
+ '#1D7F8C': {
287
+ id: 'fabric.theme.bold-teal',
288
+ defaultMessage: 'Bold teal',
289
+ description: 'Name of a color'
290
+ },
291
+ '#206B74': {
292
+ id: 'fabric.theme.bolder-teal',
293
+ defaultMessage: 'Bolder teal',
294
+ description: 'Name of a color'
295
+ },
296
+ // Green color
297
+ '#6BE1B0': {
298
+ id: 'fabric.theme.subtle-green',
299
+ defaultMessage: 'Subtle green',
300
+ description: 'Name of a color'
301
+ },
302
+ '#23A971': {
303
+ id: 'fabric.theme.green',
304
+ defaultMessage: 'Green',
305
+ description: 'Name of a color'
306
+ },
307
+ '#177D52': {
308
+ id: 'fabric.theme.bold-green',
309
+ defaultMessage: 'Bold green',
310
+ description: 'Name of a color'
311
+ },
312
+ '#055C3F': {
313
+ id: 'fabric.theme.bolder-green',
314
+ defaultMessage: 'Bolder green',
315
+ description: 'Name of a color'
316
+ },
317
+ // Yellow color
318
+ '#FFDB57': {
319
+ id: 'fabric.theme.subtle-yellow',
320
+ defaultMessage: 'Subtle yellow',
321
+ description: 'Name of a color'
322
+ },
323
+ '#FFBE33': {
324
+ id: 'fabric.theme.yellow',
325
+ defaultMessage: 'Yellow',
326
+ description: 'Name of a color'
327
+ },
328
+ '#FF9D00': {
329
+ id: 'fabric.theme.bold-yellow',
330
+ defaultMessage: 'Bold yellow',
331
+ description: 'Name of a color'
332
+ },
333
+ '#946104': {
334
+ id: 'fabric.theme.bolder-yellow',
335
+ defaultMessage: 'Bolder yellow',
336
+ description: 'Name of a color'
337
+ },
338
+ // Red color
339
+ '#FF8F73': {
340
+ id: 'fabric.theme.subtle-red',
341
+ defaultMessage: 'Subtle red',
342
+ description: 'Name of a color'
343
+ },
344
+ '#FC552C': {
345
+ id: 'fabric.theme.red',
346
+ defaultMessage: 'Red',
347
+ description: 'Name of a color.'
348
+ },
349
+ '#D32D03': {
350
+ id: 'fabric.theme.bold-red',
351
+ defaultMessage: 'Bold red',
352
+ description: 'Name of a color'
353
+ },
354
+ '#A32000': {
355
+ id: 'fabric.theme.bolder-red',
356
+ defaultMessage: 'Bolder red',
357
+ description: 'Name of a color'
358
+ },
359
+ // Orange color
360
+ '#FAA53D': {
361
+ id: 'fabric.theme.subtle-orange',
362
+ defaultMessage: 'Subtle orange',
363
+ description: 'Name of a color'
364
+ },
365
+ '#D97008': {
366
+ id: 'fabric.theme.orange',
367
+ defaultMessage: 'Orange',
368
+ description: 'Name of a color.'
369
+ },
370
+ '#B65C02': {
371
+ id: 'fabric.theme.bold-orange',
372
+ defaultMessage: 'Bold orange',
373
+ description: 'Name of a color'
374
+ },
375
+ '#974F0C': {
376
+ id: 'fabric.theme.bolder-orange',
377
+ defaultMessage: 'Bolder orange',
378
+ description: 'Name of a color'
379
+ },
380
+ // Magenta color
381
+ '#E774BB': {
382
+ id: 'fabric.theme.subtle-magenta',
383
+ defaultMessage: 'Subtle magenta',
384
+ description: 'Name of a color'
385
+ },
386
+ '#DA62AC': {
387
+ id: 'fabric.theme.magenta',
388
+ defaultMessage: 'Magenta',
389
+ description: 'Name of a color'
390
+ },
391
+ '#CD519D': {
392
+ id: 'fabric.theme.bold-magenta',
393
+ defaultMessage: 'Bold magenta',
394
+ description: 'Name of a color'
395
+ },
396
+ '#943D73': {
397
+ id: 'fabric.theme.bolder-magenta',
398
+ defaultMessage: 'Bolder magenta',
399
+ description: 'Name of a color'
400
+ },
401
+ // Purple color
402
+ '#B5A7FB': {
403
+ id: 'fabric.theme.subtle-purple',
404
+ defaultMessage: 'Subtle purple',
405
+ description: 'Name of a color'
406
+ },
407
+ '#8B77EE': {
408
+ id: 'fabric.theme.purple',
409
+ defaultMessage: 'Purple',
410
+ description: 'Name of a color'
411
+ },
412
+ '#5A43D0': {
413
+ id: 'fabric.theme.bold-purple',
414
+ defaultMessage: 'Bold purple',
415
+ description: 'Name of a color'
416
+ },
417
+ '#44368B': {
418
+ id: 'fabric.theme.bolder-purple',
419
+ defaultMessage: 'Bolder purple',
420
+ description: 'Name of a color'
421
+ },
422
+ // Gray color
423
+ '#8993A5': {
424
+ id: 'fabric.theme.subtle-gray',
425
+ defaultMessage: 'Subtle gray',
426
+ description: 'Name of a color'
427
+ },
428
+ '#8590A2': {
429
+ id: 'fabric.theme.gray',
430
+ defaultMessage: 'Gray',
431
+ description: 'Name of a color'
432
+ },
433
+ '#758195': {
434
+ id: 'fabric.theme.bold-gray',
435
+ defaultMessage: 'Bold gray',
436
+ description: 'Name of a color'
437
+ },
438
+ '#44546F': {
439
+ id: 'fabric.theme.bolder-gray',
440
+ defaultMessage: 'Bolder gray',
441
+ description: 'Name of a color'
442
+ }
443
+ });
444
+ const darkChartsColorPaletteTooltipMessages = {
445
+ ...lightChartsColorPaletteTooltipMessages
446
+ };
447
+ export const chartsColorPaletteTooltipMessages = {
448
+ light: lightChartsColorPaletteTooltipMessages,
449
+ dark: darkChartsColorPaletteTooltipMessages
450
+ };
253
451
  const lightBorderPaletteTooltipMessages = defineMessages({
254
452
  '#091E4224': {
255
453
  id: 'fabric.theme.subtle-gray',
@@ -6,6 +6,6 @@ export { default as colorPaletteMessages } from './ColorPalette/Palettes/palette
6
6
  export { panelBackgroundPalette, panelDarkModeBackgroundPalette } from './ColorPalette/Palettes/panelBackgroundPalette';
7
7
  export { lightModeStatusColorPalette, darkModeStatusColorPalette } from './ColorPalette/Palettes/statusColorPalette';
8
8
  export { textColorPalette } from './ColorPalette/Palettes/textColorPalette';
9
- export { backgroundPaletteTooltipMessages, borderPaletteTooltipMessages, textPaletteTooltipMessages } from './ColorPalette/Palettes';
9
+ export { backgroundPaletteTooltipMessages, borderPaletteTooltipMessages, chartsColorPaletteTooltipMessages, textPaletteTooltipMessages } from './ColorPalette/Palettes';
10
10
  export { DEFAULT_BORDER_COLOR } from './ColorPalette/Palettes/common';
11
11
  export { default as borderColorPalette } from './ColorPalette/Palettes/borderColorPalette';
@@ -2,6 +2,9 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  import React, { PureComponent } from 'react';
3
3
  import ReactDOM from 'react-dom';
4
4
  import ReactEditorViewContext from './ReactEditorViewContext';
5
+
6
+ // This needs exporting to be used alongisde `withReactEditorViewOuterListeners`
7
+
5
8
  class WithOutsideClick extends PureComponent {
6
9
  constructor(...args) {
7
10
  super(...args);
@@ -94,7 +94,6 @@ export function closestElement(node, s) {
94
94
  */
95
95
  // At time of writting prettier would strip the extend here.
96
96
  // prettier-ignore
97
-
98
97
  export function parsePx(pxStr) {
99
98
  if (!pxStr.endsWith('px')) {
100
99
  return undefined;
@@ -4,6 +4,29 @@ export const ADFStages = {
4
4
  FINAL: 'final',
5
5
  STAGE_0: 'stage0'
6
6
  };
7
+
8
+ /*
9
+ * An ADF Document JSON object. The document is the root node and documents are
10
+ * composed of nodes. This type accepts an array of ADNode types as content.
11
+ *
12
+ * It is basically the same as the JSONNodeDoc interface from editor-json-transformer.
13
+ *
14
+ * Do not use this type for content nodes as they require additional attributes.
15
+ *
16
+ * Use ADNode instead for content nodes (any node other than the doc).
17
+ */
18
+
19
+ /*
20
+ * An ADF Node object. This type is used as content for the ADDoc interface.
21
+
22
+ * It is basically the same as the JSONNode type from editor-json-transformer
23
+ * but the types are a little more strict.
24
+ *
25
+ * It is a serialisable form of ADFEntity.
26
+ *
27
+ * Do not use this for ADF documents - they should use the ADDoc interface.
28
+ */
29
+
7
30
  /*
8
31
  * It's important that this order follows the marks rank defined here:
9
32
  * https://product-fabric.atlassian.net/wiki/spaces/E/pages/11174043/Document+structure#Documentstructure-Rank
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-common",
3
- "version": "72.7.2",
3
+ "version": "72.8.0",
4
4
  "sideEffects": false
5
5
  }
@@ -7,6 +7,11 @@ import { analyticsEventKey, startMeasure, stopMeasure } from '../utils';
7
7
  import { getParticipantsCount } from '../utils/collab';
8
8
  const DEFAULT_SAMPLING_RATE = 100;
9
9
  const DEFAULT_SLOW_THRESHOLD = 4;
10
+
11
+ // That context was exctract from the old WithPluginState from editor-core
12
+ // It was using some private types from
13
+ // - EditorAction: packages/editor/editor-core/src/actions/index.ts
14
+ // - EditorSharedConfig: packages/editor/editor-core/src/labs/next/internal/context/shared-config.tsx
10
15
  /**
11
16
  * Wraps component in a high order component that watches state changes of given plugins
12
17
  * and passes those states to the wrapped component.
@@ -104,6 +109,11 @@ class WithPluginState extends React.Component {
104
109
  const props = maybeProps || this.props;
105
110
  return props.eventDispatcher || this.context && this.context.editorActions && this.context.editorActions._privateGetEventDispatcher() || this.context && this.context.editorSharedConfig && this.context.editorSharedConfig.eventDispatcher;
106
111
  }
112
+
113
+ /**
114
+ * Debounces setState calls in order to reduce number of re-renders caused by several plugin state changes.
115
+ */
116
+
107
117
  getPluginsStates(plugins, editorView) {
108
118
  if (!editorView || !plugins) {
109
119
  return {};
@@ -20,4 +20,4 @@ export var BROWSER_FREEZE_INTERACTION_TYPE;
20
20
  BROWSER_FREEZE_INTERACTION_TYPE["TYPING"] = "typing";
21
21
  BROWSER_FREEZE_INTERACTION_TYPE["CLICKING"] = "clicking";
22
22
  BROWSER_FREEZE_INTERACTION_TYPE["PASTING"] = "pasting";
23
- })(BROWSER_FREEZE_INTERACTION_TYPE || (BROWSER_FREEZE_INTERACTION_TYPE = {}));
23
+ })(BROWSER_FREEZE_INTERACTION_TYPE || (BROWSER_FREEZE_INTERACTION_TYPE = {})); // TODO: https://product-fabric.atlassian.net/browse/AFP-1418
@@ -31,4 +31,6 @@ export var TABLE_BREAKOUT;
31
31
  TABLE_BREAKOUT["WIDE"] = "wide";
32
32
  TABLE_BREAKOUT["FULL_WIDTH"] = "fullWidth";
33
33
  TABLE_BREAKOUT["NORMAL"] = "normal";
34
- })(TABLE_BREAKOUT || (TABLE_BREAKOUT = {}));
34
+ })(TABLE_BREAKOUT || (TABLE_BREAKOUT = {})); //#endregion
35
+ //#region Analytic Event Payloads
36
+ //#endregion
@@ -1 +1 @@
1
- export {};
1
+ export { addLinkMetadata, getLinkMetadataFromTransaction, commandWithMetadata } from './utils';
@@ -0,0 +1,45 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
3
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
+ import { LinkMetaStep } from '@atlaskit/adf-schema/steps';
5
+
6
+ /**
7
+ * Records metadata about the user action and input method relating to a transaction
8
+ * as a custom LinkStepMetadata prosemirror step so that it is preserved in
9
+ * the history for undo/redo
10
+ */
11
+ export function addLinkMetadata(initialSelection, tr, metadata) {
12
+ var storedMarks = tr.storedMarks;
13
+ var pos = tr.mapping.map(initialSelection.$from.pos);
14
+ tr.step(new LinkMetaStep(pos, metadata));
15
+
16
+ // When you add a new step all the storedMarks are removed it
17
+ if (storedMarks) {
18
+ tr.setStoredMarks(storedMarks);
19
+ }
20
+ return tr;
21
+ }
22
+ export function getLinkMetadataFromTransaction(tr) {
23
+ return tr.steps.reduce(function (metadata, step) {
24
+ if (!(step instanceof LinkMetaStep)) {
25
+ return metadata;
26
+ }
27
+ return _objectSpread(_objectSpread({}, metadata), step.getMetadata());
28
+ }, {});
29
+ }
30
+ /**
31
+ * Adds metadata to the transaction created from a command
32
+ * The metadata describes the user intent and input method
33
+ * for executing the command
34
+ */
35
+ export var commandWithMetadata = function commandWithMetadata(command, metadata) {
36
+ return function (state, dispatch, view) {
37
+ if (!dispatch) {
38
+ return command(state, dispatch, view);
39
+ }
40
+ return command(state, function (tr) {
41
+ addLinkMetadata(state.selection, tr, metadata);
42
+ dispatch(tr);
43
+ }, view);
44
+ };
45
+ };
@@ -1,7 +1,8 @@
1
+ import _typeof from "@babel/runtime/helpers/typeof";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/createClass";
4
- import _regeneratorRuntime from "@babel/runtime/regenerator";
5
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator.return && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, catch: function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
5
6
  import { getAutoConvertPatternsFromModule } from './module-helpers';
6
7
  var DefaultExtensionProvider = /*#__PURE__*/function () {
7
8
  function DefaultExtensionProvider(manifests,
@@ -24,9 +25,9 @@ var DefaultExtensionProvider = /*#__PURE__*/function () {
24
25
  }, {
25
26
  key: "getExtension",
26
27
  value: function () {
27
- var _getExtension = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(type, key) {
28
+ var _getExtension = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(type, key) {
28
29
  var extension;
29
- return _regeneratorRuntime.wrap(function _callee$(_context) {
30
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
30
31
  while (1) {
31
32
  switch (_context.prev = _context.next) {
32
33
  case 0:
@@ -58,9 +59,9 @@ var DefaultExtensionProvider = /*#__PURE__*/function () {
58
59
  }, {
59
60
  key: "search",
60
61
  value: function () {
61
- var _search = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(keyword) {
62
+ var _search = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(keyword) {
62
63
  var extensions;
63
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
64
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
64
65
  while (1) {
65
66
  switch (_context2.prev = _context2.next) {
66
67
  case 0:
@@ -86,9 +87,9 @@ var DefaultExtensionProvider = /*#__PURE__*/function () {
86
87
  }, {
87
88
  key: "getAutoConverter",
88
89
  value: function () {
89
- var _getAutoConverter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
90
+ var _getAutoConverter = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3() {
90
91
  var autoConverters;
91
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
92
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
92
93
  while (1) {
93
94
  switch (_context3.prev = _context3.next) {
94
95
  case 0: