@atlaskit/editor-core 188.2.7 → 188.2.8

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/editor-core
2
2
 
3
+ ## 188.2.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [#41120](https://bitbucket.org/atlassian/atlassian-frontend/pull-requests/41120) [`011df0ba8ab`](https://bitbucket.org/atlassian/atlassian-frontend/commits/011df0ba8ab) - Fix media icon showing in comment editor toolbar due to state not updating.
8
+
3
9
  ## 188.2.7
4
10
 
5
11
  ### Patch Changes
@@ -32,7 +32,6 @@ var _keymapMediaSingle = _interopRequireDefault(require("./pm-plugins/keymap-med
32
32
  var _linking = _interopRequireDefault(require("./pm-plugins/linking"));
33
33
  var _keymap3 = _interopRequireDefault(require("./pm-plugins/linking/keymap"));
34
34
  var _main = require("./pm-plugins/main");
35
- var _pluginKey = require("./pm-plugins/plugin-key");
36
35
  var _toolbar = require("./toolbar");
37
36
  var _MediaPicker = require("./ui/MediaPicker");
38
37
  var _ToolbarMedia = _interopRequireDefault(require("./ui/ToolbarMedia"));
@@ -65,7 +64,7 @@ var mediaPlugin = function mediaPlugin(_ref2) {
65
64
  if (!editorState) {
66
65
  return null;
67
66
  }
68
- return _pluginKey.stateKey.getState(editorState) || null;
67
+ return _main.stateKey.getState(editorState) || null;
69
68
  },
70
69
  actions: {
71
70
  insertMediaAsMediaSingle: function insertMediaAsMediaSingle(view, node, inputMethod) {
@@ -493,8 +493,22 @@ var MediaPluginStateImplementation = exports.MediaPluginStateImplementation = /*
493
493
  });
494
494
  options.providerFactory.subscribe('contextIdentifierProvider', this.onContextIdentifierProvider);
495
495
  this.errorReporter = options.errorReporter || new _utils.ErrorReporter();
496
+ this.singletonCreatedAt = (performance || Date).now();
496
497
  }
497
498
  (0, _createClass2.default)(MediaPluginStateImplementation, [{
499
+ key: "clone",
500
+ value: function clone() {
501
+ var clonedAt = (performance || Date).now();
502
+ return new Proxy(this, {
503
+ get: function get(target, prop, receiver) {
504
+ if (prop === 'singletonCreatedAt') {
505
+ return clonedAt;
506
+ }
507
+ return Reflect.get(target, prop, receiver);
508
+ }
509
+ });
510
+ }
511
+ }, {
498
512
  key: "setIsResizing",
499
513
  value: function setIsResizing(isResizing) {
500
514
  this.isResizing = isResizing;
@@ -651,16 +665,24 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
651
665
  apply: function apply(tr, pluginState) {
652
666
  var isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
653
667
  var resizingWidth = tr.getMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY);
668
+ // Yes, I agree with you; this approach, using the clone() fuction, below is horrifying.
669
+ // However, we needed to implement this workaround to solve the singleton Media PluginState.
670
+ // The entire PluginInjectionAPI relies on the following axiom: "A PluginState that reflects a new EditorState.". We can not have the mutable singleton instance for all EditorState.
671
+ // Unfortunately, we can't implement a proper fix for this media state situation. So, we are faking a new object using a Proxy instance.
672
+ var nextPluginState = pluginState;
654
673
  if (isResizing !== undefined) {
655
674
  pluginState.setIsResizing(isResizing);
675
+ nextPluginState = nextPluginState.clone();
656
676
  }
657
677
  if (resizingWidth) {
658
678
  pluginState.setResizingWidth(resizingWidth);
679
+ nextPluginState = nextPluginState.clone();
659
680
  }
660
681
 
661
682
  // remap editing media single position if we're in collab
662
683
  if (typeof pluginState.editingMediaSinglePos === 'number') {
663
684
  pluginState.editingMediaSinglePos = tr.mapping.map(pluginState.editingMediaSinglePos);
685
+ nextPluginState = nextPluginState.clone();
664
686
  }
665
687
  var meta = tr.getMeta(_pluginKey.stateKey);
666
688
  if (meta) {
@@ -668,12 +690,13 @@ var createPlugin = exports.createPlugin = function createPlugin(_schema, options
668
690
  pluginState.updateAndDispatch({
669
691
  allowsUploads: typeof allowsUploads === 'undefined' ? pluginState.allowsUploads : allowsUploads
670
692
  });
693
+ nextPluginState = nextPluginState.clone();
671
694
  }
672
695
 
673
696
  // NOTE: We're not calling passing new state to the Editor, because we depend on the view.state reference
674
697
  // throughout the lifetime of view. We injected the view into the plugin state, because we dispatch()
675
698
  // transformations from within the plugin state (i.e. when adding a new file).
676
- return pluginState;
699
+ return nextPluginState;
677
700
  }
678
701
  },
679
702
  appendTransaction: function appendTransaction(transactions, _oldState, newState) {
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = exports.name = "@atlaskit/editor-core";
8
- var version = exports.version = "188.2.7";
8
+ var version = exports.version = "188.2.8";
9
9
  var nextMajorVersion = exports.nextMajorVersion = function nextMajorVersion() {
10
10
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
11
11
  };
@@ -18,8 +18,8 @@ import keymapPlugin from './pm-plugins/keymap';
18
18
  import keymapMediaSinglePlugin from './pm-plugins/keymap-media-single';
19
19
  import linkingPlugin from './pm-plugins/linking';
20
20
  import keymapLinkingPlugin from './pm-plugins/linking/keymap';
21
+ import { stateKey } from './pm-plugins/main';
21
22
  import { createPlugin, stateKey as pluginKey } from './pm-plugins/main';
22
- import { stateKey } from './pm-plugins/plugin-key';
23
23
  import { floatingToolbar } from './toolbar';
24
24
  import { MediaPickerComponents } from './ui/MediaPicker';
25
25
  import ToolbarMedia from './ui/ToolbarMedia';
@@ -423,6 +423,18 @@ export class MediaPluginStateImplementation {
423
423
  options.providerFactory.subscribe('mediaProvider', (_name, provider) => this.setMediaProvider(provider));
424
424
  options.providerFactory.subscribe('contextIdentifierProvider', this.onContextIdentifierProvider);
425
425
  this.errorReporter = options.errorReporter || new ErrorReporter();
426
+ this.singletonCreatedAt = (performance || Date).now();
427
+ }
428
+ clone() {
429
+ const clonedAt = (performance || Date).now();
430
+ return new Proxy(this, {
431
+ get(target, prop, receiver) {
432
+ if (prop === 'singletonCreatedAt') {
433
+ return clonedAt;
434
+ }
435
+ return Reflect.get(target, prop, receiver);
436
+ }
437
+ });
426
438
  }
427
439
  setIsResizing(isResizing) {
428
440
  this.isResizing = isResizing;
@@ -538,16 +550,24 @@ export const createPlugin = (_schema, options, reactContext, getIntl, pluginInje
538
550
  apply(tr, pluginState) {
539
551
  const isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
540
552
  const resizingWidth = tr.getMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY);
553
+ // Yes, I agree with you; this approach, using the clone() fuction, below is horrifying.
554
+ // However, we needed to implement this workaround to solve the singleton Media PluginState.
555
+ // The entire PluginInjectionAPI relies on the following axiom: "A PluginState that reflects a new EditorState.". We can not have the mutable singleton instance for all EditorState.
556
+ // Unfortunately, we can't implement a proper fix for this media state situation. So, we are faking a new object using a Proxy instance.
557
+ let nextPluginState = pluginState;
541
558
  if (isResizing !== undefined) {
542
559
  pluginState.setIsResizing(isResizing);
560
+ nextPluginState = nextPluginState.clone();
543
561
  }
544
562
  if (resizingWidth) {
545
563
  pluginState.setResizingWidth(resizingWidth);
564
+ nextPluginState = nextPluginState.clone();
546
565
  }
547
566
 
548
567
  // remap editing media single position if we're in collab
549
568
  if (typeof pluginState.editingMediaSinglePos === 'number') {
550
569
  pluginState.editingMediaSinglePos = tr.mapping.map(pluginState.editingMediaSinglePos);
570
+ nextPluginState = nextPluginState.clone();
551
571
  }
552
572
  const meta = tr.getMeta(stateKey);
553
573
  if (meta) {
@@ -557,12 +577,13 @@ export const createPlugin = (_schema, options, reactContext, getIntl, pluginInje
557
577
  pluginState.updateAndDispatch({
558
578
  allowsUploads: typeof allowsUploads === 'undefined' ? pluginState.allowsUploads : allowsUploads
559
579
  });
580
+ nextPluginState = nextPluginState.clone();
560
581
  }
561
582
 
562
583
  // NOTE: We're not calling passing new state to the Editor, because we depend on the view.state reference
563
584
  // throughout the lifetime of view. We injected the view into the plugin state, because we dispatch()
564
585
  // transformations from within the plugin state (i.e. when adding a new file).
565
- return pluginState;
586
+ return nextPluginState;
566
587
  }
567
588
  },
568
589
  appendTransaction(transactions, _oldState, newState) {
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "188.2.7";
2
+ export const version = "188.2.8";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -18,8 +18,8 @@ import keymapPlugin from './pm-plugins/keymap';
18
18
  import keymapMediaSinglePlugin from './pm-plugins/keymap-media-single';
19
19
  import linkingPlugin from './pm-plugins/linking';
20
20
  import keymapLinkingPlugin from './pm-plugins/linking/keymap';
21
+ import { stateKey } from './pm-plugins/main';
21
22
  import { createPlugin, stateKey as pluginKey } from './pm-plugins/main';
22
- import { stateKey } from './pm-plugins/plugin-key';
23
23
  import { floatingToolbar as _floatingToolbar } from './toolbar';
24
24
  import { MediaPickerComponents } from './ui/MediaPicker';
25
25
  import ToolbarMedia from './ui/ToolbarMedia';
@@ -478,8 +478,22 @@ export var MediaPluginStateImplementation = /*#__PURE__*/function () {
478
478
  });
479
479
  options.providerFactory.subscribe('contextIdentifierProvider', this.onContextIdentifierProvider);
480
480
  this.errorReporter = options.errorReporter || new ErrorReporter();
481
+ this.singletonCreatedAt = (performance || Date).now();
481
482
  }
482
483
  _createClass(MediaPluginStateImplementation, [{
484
+ key: "clone",
485
+ value: function clone() {
486
+ var clonedAt = (performance || Date).now();
487
+ return new Proxy(this, {
488
+ get: function get(target, prop, receiver) {
489
+ if (prop === 'singletonCreatedAt') {
490
+ return clonedAt;
491
+ }
492
+ return Reflect.get(target, prop, receiver);
493
+ }
494
+ });
495
+ }
496
+ }, {
483
497
  key: "setIsResizing",
484
498
  value: function setIsResizing(isResizing) {
485
499
  this.isResizing = isResizing;
@@ -636,16 +650,24 @@ export var createPlugin = function createPlugin(_schema, options, reactContext,
636
650
  apply: function apply(tr, pluginState) {
637
651
  var isResizing = tr.getMeta(MEDIA_PLUGIN_IS_RESIZING_KEY);
638
652
  var resizingWidth = tr.getMeta(MEDIA_PLUGIN_RESIZING_WIDTH_KEY);
653
+ // Yes, I agree with you; this approach, using the clone() fuction, below is horrifying.
654
+ // However, we needed to implement this workaround to solve the singleton Media PluginState.
655
+ // The entire PluginInjectionAPI relies on the following axiom: "A PluginState that reflects a new EditorState.". We can not have the mutable singleton instance for all EditorState.
656
+ // Unfortunately, we can't implement a proper fix for this media state situation. So, we are faking a new object using a Proxy instance.
657
+ var nextPluginState = pluginState;
639
658
  if (isResizing !== undefined) {
640
659
  pluginState.setIsResizing(isResizing);
660
+ nextPluginState = nextPluginState.clone();
641
661
  }
642
662
  if (resizingWidth) {
643
663
  pluginState.setResizingWidth(resizingWidth);
664
+ nextPluginState = nextPluginState.clone();
644
665
  }
645
666
 
646
667
  // remap editing media single position if we're in collab
647
668
  if (typeof pluginState.editingMediaSinglePos === 'number') {
648
669
  pluginState.editingMediaSinglePos = tr.mapping.map(pluginState.editingMediaSinglePos);
670
+ nextPluginState = nextPluginState.clone();
649
671
  }
650
672
  var meta = tr.getMeta(stateKey);
651
673
  if (meta) {
@@ -653,12 +675,13 @@ export var createPlugin = function createPlugin(_schema, options, reactContext,
653
675
  pluginState.updateAndDispatch({
654
676
  allowsUploads: typeof allowsUploads === 'undefined' ? pluginState.allowsUploads : allowsUploads
655
677
  });
678
+ nextPluginState = nextPluginState.clone();
656
679
  }
657
680
 
658
681
  // NOTE: We're not calling passing new state to the Editor, because we depend on the view.state reference
659
682
  // throughout the lifetime of view. We injected the view into the plugin state, because we dispatch()
660
683
  // transformations from within the plugin state (i.e. when adding a new file).
661
- return pluginState;
684
+ return nextPluginState;
662
685
  }
663
686
  },
664
687
  appendTransaction: function appendTransaction(transactions, _oldState, newState) {
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "188.2.7";
2
+ export var version = "188.2.8";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -54,7 +54,9 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
54
54
  mediaOptions?: MediaOptions;
55
55
  dispatch?: Dispatch;
56
56
  pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined;
57
+ singletonCreatedAt: number;
57
58
  constructor(state: EditorState, options: MediaPluginOptions, mediaOptions: MediaOptions | undefined, newInsertionBehaviour: boolean | undefined, dispatch: Dispatch | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined);
59
+ clone(): this;
58
60
  onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
59
61
  setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
60
62
  getMediaOptions: () => MediaPluginOptions;
@@ -61,4 +61,5 @@ export interface MediaPluginState {
61
61
  setView(view: EditorView): void;
62
62
  destroy(): void;
63
63
  updateAndDispatch(props: Partial<Pick<this, 'allowsUploads' | 'allUploadsFinished' | 'isFullscreen'>>): void;
64
+ clone(): MediaPluginState;
64
65
  }
@@ -54,7 +54,9 @@ export declare class MediaPluginStateImplementation implements MediaPluginState
54
54
  mediaOptions?: MediaOptions;
55
55
  dispatch?: Dispatch;
56
56
  pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined;
57
+ singletonCreatedAt: number;
57
58
  constructor(state: EditorState, options: MediaPluginOptions, mediaOptions: MediaOptions | undefined, newInsertionBehaviour: boolean | undefined, dispatch: Dispatch | undefined, pluginInjectionApi: ExtractInjectionAPI<MediaNextEditorPluginType> | undefined);
59
+ clone(): this;
58
60
  onContextIdentifierProvider: (_name: string, provider?: Promise<ContextIdentifierProvider>) => Promise<void>;
59
61
  setMediaProvider: (mediaProvider?: Promise<MediaProvider>) => Promise<void>;
60
62
  getMediaOptions: () => MediaPluginOptions;
@@ -61,4 +61,5 @@ export interface MediaPluginState {
61
61
  setView(view: EditorView): void;
62
62
  destroy(): void;
63
63
  updateAndDispatch(props: Partial<Pick<this, 'allowsUploads' | 'allUploadsFinished' | 'isFullscreen'>>): void;
64
+ clone(): MediaPluginState;
64
65
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "188.2.7",
3
+ "version": "188.2.8",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -256,6 +256,10 @@
256
256
  "platform.editor.table-sticky-scrollbar": {
257
257
  "type": "boolean"
258
258
  },
259
+ "platform.editor.table.column-controls-styles-updated": {
260
+ "type": "boolean",
261
+ "referenceOnly": "true"
262
+ },
259
263
  "platform.editor.update-table-cell-width-via-step": {
260
264
  "type": "boolean",
261
265
  "referenceOnly": "true"