@atlaskit/editor-plugin-collab-edit 11.0.8 → 11.1.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,30 @@
1
1
  # @atlaskit/editor-plugin-collab-edit
2
2
 
3
+ ## 11.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`e6053f4348753`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/e6053f4348753) -
8
+ Fix cc-markdown-mode duplication and stuck-loading issues on rich/markdown convert. Cache the
9
+ latest init payload on the native collab provider and expose it via an optional getInitPayload()
10
+ getter so editor-plugin-collab-edit can seed collabInitialised=true on a rebind (e.g. preset
11
+ rebuild) without re-running handleInit. Gate a synthetic-BE-step filter in
12
+ documentService.processSteps that neutralises NCS reconcile-generated steps tagged with the user's
13
+ userId but no clientId (prevents HelloHello duplication after a markdown-mode flip). Defensively
14
+ hide the WYSIWYG editor DOM in MarkdownModeContentComponent when the source view is active so the
15
+ floating toolbar/cursor doesn't leak through. All behaviour changes are behind the
16
+ cc-markdown-mode experiment.
17
+
18
+ ### Patch Changes
19
+
20
+ - Updated dependencies
21
+
22
+ ## 11.0.9
23
+
24
+ ### Patch Changes
25
+
26
+ - Updated dependencies
27
+
3
28
  ## 11.0.8
4
29
 
5
30
  ### Patch Changes
@@ -7,7 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.initialize = void 0;
8
8
  var _memoizeOne = _interopRequireDefault(require("memoize-one"));
9
9
  var _transform = require("@atlaskit/editor-prosemirror/transform");
10
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
10
11
  var _pluginKey = require("../main/plugin-key");
12
+ var _trackNcsInitialization = require("../track-ncs-initialization");
11
13
  var _handlers = require("./handlers");
12
14
  var initCollab = function initCollab(collabEditProvider, view) {
13
15
  if (collabEditProvider.initialize) {
@@ -56,6 +58,51 @@ var initialize = exports.initialize = function initialize(_ref) {
56
58
  */
57
59
  initCollabMemo(provider, view);
58
60
  }
61
+
62
+ // Rebind path: if the provider has already initialised (i.e. this view()
63
+ // is running because the editor preset was reconfigured or the EditorView
64
+ // was recreated mid-session, e.g. on a rich-text → markdown-mode flip),
65
+ // the provider's `init` event has already fired and won't fire again.
66
+ // Without intervention the freshly-attached collab plugin view never sees
67
+ // `collabInitialised`, so `filterTransaction` silently drops every
68
+ // doc-changing transaction and the editor appears read-only.
69
+ //
70
+ // PM `state.reconfigure` preserves plugin state by key, so in many cases
71
+ // the plugin state survives and no action is needed; we only seed when
72
+ // state was actually lost (e.g. EditorView recreated from scratch).
73
+ //
74
+ // Gated behind `cc-markdown-mode` (the same experiment that drives the
75
+ // preset rebuild on convert); when off, behaviour is unchanged. Uses
76
+ // `expValEquals` (not `*NoExposure`) so the editor's statsig client
77
+ // enrols the user — otherwise an early rebind can race the FE-side
78
+ // exposure and read the default (false), defeating the gate. The
79
+ // experiment check is last so legacy providers (no `getInitPayload`)
80
+ // short-circuit and don't fire an exposure.
81
+ if (provider.getInitPayload && (0, _expValEquals.expValEquals)('cc-markdown-mode', 'isEnabled', true)) {
82
+ var cachedInit = provider.getInitPayload();
83
+ if (cachedInit) {
84
+ // Defer one microtask so the new pluginView is fully registered
85
+ // before we dispatch (mirrors the timing of a real `init` event).
86
+ Promise.resolve().then(function () {
87
+ if (view.isDestroyed) {
88
+ return;
89
+ }
90
+ var currentCollabState = _pluginKey.pluginKey.getState(view.state);
91
+ var currentTrackState = _trackNcsInitialization.trackNCSInitializationPluginKey.getState(view.state);
92
+ // State was preserved across reconfigure → nothing to do.
93
+ if (currentCollabState !== null && currentCollabState !== void 0 && currentCollabState.isReady && currentTrackState !== null && currentTrackState !== void 0 && currentTrackState.collabInitialisedAt) {
94
+ return;
95
+ }
96
+ // Seed the freshly-attached pluginView so `isReady` flips to true,
97
+ // `data-has-collab-initialised` becomes "true", and downstream
98
+ // listeners (analytics, sweet-state, track-ncs) re-receive init.
99
+ // Note: we intentionally do NOT replay `handleInit` (which would
100
+ // call `replaceDocument`) — the document is already in the editor
101
+ // and replacing it would clobber any in-flight local steps.
102
+ view.dispatch(view.state.tr.setMeta('collabInitialised', true));
103
+ });
104
+ }
105
+ }
59
106
  return cleanup;
60
107
  };
61
108
  };
@@ -1,6 +1,8 @@
1
1
  import memoizeOne from 'memoize-one';
2
2
  import { Step } from '@atlaskit/editor-prosemirror/transform';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  import { pluginKey } from '../main/plugin-key';
5
+ import { trackNCSInitializationPluginKey } from '../track-ncs-initialization';
4
6
  import { subscribe } from './handlers';
5
7
  const initCollab = (collabEditProvider, view) => {
6
8
  if (collabEditProvider.initialize) {
@@ -43,5 +45,50 @@ export const initialize = ({
43
45
  */
44
46
  initCollabMemo(provider, view);
45
47
  }
48
+
49
+ // Rebind path: if the provider has already initialised (i.e. this view()
50
+ // is running because the editor preset was reconfigured or the EditorView
51
+ // was recreated mid-session, e.g. on a rich-text → markdown-mode flip),
52
+ // the provider's `init` event has already fired and won't fire again.
53
+ // Without intervention the freshly-attached collab plugin view never sees
54
+ // `collabInitialised`, so `filterTransaction` silently drops every
55
+ // doc-changing transaction and the editor appears read-only.
56
+ //
57
+ // PM `state.reconfigure` preserves plugin state by key, so in many cases
58
+ // the plugin state survives and no action is needed; we only seed when
59
+ // state was actually lost (e.g. EditorView recreated from scratch).
60
+ //
61
+ // Gated behind `cc-markdown-mode` (the same experiment that drives the
62
+ // preset rebuild on convert); when off, behaviour is unchanged. Uses
63
+ // `expValEquals` (not `*NoExposure`) so the editor's statsig client
64
+ // enrols the user — otherwise an early rebind can race the FE-side
65
+ // exposure and read the default (false), defeating the gate. The
66
+ // experiment check is last so legacy providers (no `getInitPayload`)
67
+ // short-circuit and don't fire an exposure.
68
+ if (provider.getInitPayload && expValEquals('cc-markdown-mode', 'isEnabled', true)) {
69
+ const cachedInit = provider.getInitPayload();
70
+ if (cachedInit) {
71
+ // Defer one microtask so the new pluginView is fully registered
72
+ // before we dispatch (mirrors the timing of a real `init` event).
73
+ Promise.resolve().then(() => {
74
+ if (view.isDestroyed) {
75
+ return;
76
+ }
77
+ const currentCollabState = pluginKey.getState(view.state);
78
+ const currentTrackState = trackNCSInitializationPluginKey.getState(view.state);
79
+ // State was preserved across reconfigure → nothing to do.
80
+ if (currentCollabState !== null && currentCollabState !== void 0 && currentCollabState.isReady && currentTrackState !== null && currentTrackState !== void 0 && currentTrackState.collabInitialisedAt) {
81
+ return;
82
+ }
83
+ // Seed the freshly-attached pluginView so `isReady` flips to true,
84
+ // `data-has-collab-initialised` becomes "true", and downstream
85
+ // listeners (analytics, sweet-state, track-ncs) re-receive init.
86
+ // Note: we intentionally do NOT replay `handleInit` (which would
87
+ // call `replaceDocument`) — the document is already in the editor
88
+ // and replacing it would clobber any in-flight local steps.
89
+ view.dispatch(view.state.tr.setMeta('collabInitialised', true));
90
+ });
91
+ }
92
+ }
46
93
  return cleanup;
47
94
  };
@@ -1,6 +1,8 @@
1
1
  import memoizeOne from 'memoize-one';
2
2
  import { Step } from '@atlaskit/editor-prosemirror/transform';
3
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
3
4
  import { pluginKey } from '../main/plugin-key';
5
+ import { trackNCSInitializationPluginKey } from '../track-ncs-initialization';
4
6
  import { subscribe } from './handlers';
5
7
  var initCollab = function initCollab(collabEditProvider, view) {
6
8
  if (collabEditProvider.initialize) {
@@ -49,6 +51,51 @@ export var initialize = function initialize(_ref) {
49
51
  */
50
52
  initCollabMemo(provider, view);
51
53
  }
54
+
55
+ // Rebind path: if the provider has already initialised (i.e. this view()
56
+ // is running because the editor preset was reconfigured or the EditorView
57
+ // was recreated mid-session, e.g. on a rich-text → markdown-mode flip),
58
+ // the provider's `init` event has already fired and won't fire again.
59
+ // Without intervention the freshly-attached collab plugin view never sees
60
+ // `collabInitialised`, so `filterTransaction` silently drops every
61
+ // doc-changing transaction and the editor appears read-only.
62
+ //
63
+ // PM `state.reconfigure` preserves plugin state by key, so in many cases
64
+ // the plugin state survives and no action is needed; we only seed when
65
+ // state was actually lost (e.g. EditorView recreated from scratch).
66
+ //
67
+ // Gated behind `cc-markdown-mode` (the same experiment that drives the
68
+ // preset rebuild on convert); when off, behaviour is unchanged. Uses
69
+ // `expValEquals` (not `*NoExposure`) so the editor's statsig client
70
+ // enrols the user — otherwise an early rebind can race the FE-side
71
+ // exposure and read the default (false), defeating the gate. The
72
+ // experiment check is last so legacy providers (no `getInitPayload`)
73
+ // short-circuit and don't fire an exposure.
74
+ if (provider.getInitPayload && expValEquals('cc-markdown-mode', 'isEnabled', true)) {
75
+ var cachedInit = provider.getInitPayload();
76
+ if (cachedInit) {
77
+ // Defer one microtask so the new pluginView is fully registered
78
+ // before we dispatch (mirrors the timing of a real `init` event).
79
+ Promise.resolve().then(function () {
80
+ if (view.isDestroyed) {
81
+ return;
82
+ }
83
+ var currentCollabState = pluginKey.getState(view.state);
84
+ var currentTrackState = trackNCSInitializationPluginKey.getState(view.state);
85
+ // State was preserved across reconfigure → nothing to do.
86
+ if (currentCollabState !== null && currentCollabState !== void 0 && currentCollabState.isReady && currentTrackState !== null && currentTrackState !== void 0 && currentTrackState.collabInitialisedAt) {
87
+ return;
88
+ }
89
+ // Seed the freshly-attached pluginView so `isReady` flips to true,
90
+ // `data-has-collab-initialised` becomes "true", and downstream
91
+ // listeners (analytics, sweet-state, track-ncs) re-receive init.
92
+ // Note: we intentionally do NOT replay `handleInit` (which would
93
+ // call `replaceDocument`) — the document is already in the editor
94
+ // and replacing it would clobber any in-flight local steps.
95
+ view.dispatch(view.state.tr.setMeta('collabInitialised', true));
96
+ });
97
+ }
98
+ }
52
99
  return cleanup;
53
100
  };
54
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-collab-edit",
3
- "version": "11.0.8",
3
+ "version": "11.1.0",
4
4
  "description": "Collab Edit plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -39,13 +39,13 @@
39
39
  "@atlaskit/frontend-utilities": "^3.2.0",
40
40
  "@atlaskit/platform-feature-flags": "^1.1.0",
41
41
  "@atlaskit/prosemirror-collab": "^0.22.0",
42
- "@atlaskit/tmp-editor-statsig": "^70.2.0",
42
+ "@atlaskit/tmp-editor-statsig": "^71.0.0",
43
43
  "@atlaskit/tokens": "^13.0.0",
44
44
  "@babel/runtime": "^7.0.0",
45
45
  "memoize-one": "^6.0.0"
46
46
  },
47
47
  "peerDependencies": {
48
- "@atlaskit/editor-common": "^114.11.0",
48
+ "@atlaskit/editor-common": "^114.13.0",
49
49
  "react": "^18.2.0",
50
50
  "react-dom": "^18.2.0"
51
51
  },