@atlaskit/editor-plugin-list 6.0.2 → 6.0.3

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,14 @@
1
1
  # @atlaskit/editor-plugin-list
2
2
 
3
+ ## 6.0.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`0eac5a71c3834`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/0eac5a71c3834) -
8
+ [ED-29037] Fix dynamic buttons (e.g. text style) in full page primary toolbar flickers during the
9
+ initial load
10
+ - Updated dependencies
11
+
3
12
  ## 6.0.2
4
13
 
5
14
  ### Patch Changes
@@ -13,6 +13,8 @@ var _utils = require("@atlaskit/editor-common/utils");
13
13
  var _state = require("@atlaskit/editor-prosemirror/state");
14
14
  var _utils2 = require("@atlaskit/editor-prosemirror/utils");
15
15
  var _view = require("@atlaskit/editor-prosemirror/view");
16
+ var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
17
+ var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
16
18
  var _selection2 = require("./utils/selection");
17
19
  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; }
18
20
  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; }
@@ -73,6 +75,23 @@ var getDecorations = exports.getDecorations = function getDecorations(doc, state
73
75
  });
74
76
  return _view.DecorationSet.empty.add(doc, decorations);
75
77
  };
78
+ var getListState = function getListState(doc, selection) {
79
+ var _doc$type$schema$node = doc.type.schema.nodes,
80
+ bulletList = _doc$type$schema$node.bulletList,
81
+ orderedList = _doc$type$schema$node.orderedList,
82
+ taskList = _doc$type$schema$node.taskList;
83
+ var listParent = (0, _utils2.findParentNodeOfType)([bulletList, orderedList, taskList])(selection);
84
+ var bulletListActive = !!listParent && listParent.node.type === bulletList;
85
+ var orderedListActive = !!listParent && listParent.node.type === orderedList;
86
+ var bulletListDisabled = !(bulletListActive || orderedListActive || (0, _selection2.isWrappingPossible)(bulletList, selection));
87
+ var orderedListDisabled = !(bulletListActive || orderedListActive || (0, _selection2.isWrappingPossible)(orderedList, selection));
88
+ return {
89
+ bulletListActive: bulletListActive,
90
+ bulletListDisabled: bulletListDisabled,
91
+ orderedListActive: orderedListActive,
92
+ orderedListDisabled: orderedListDisabled
93
+ };
94
+ };
76
95
  var handleDocChanged = function handleDocChanged(featureFlags) {
77
96
  return function (tr, pluginState, editorState) {
78
97
  var nextPluginState = handleSelectionChanged(tr, pluginState);
@@ -83,15 +102,11 @@ var handleDocChanged = function handleDocChanged(featureFlags) {
83
102
  };
84
103
  };
85
104
  var handleSelectionChanged = function handleSelectionChanged(tr, pluginState) {
86
- var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
87
- bulletList = _tr$doc$type$schema$n.bulletList,
88
- orderedList = _tr$doc$type$schema$n.orderedList,
89
- taskList = _tr$doc$type$schema$n.taskList;
90
- var listParent = (0, _utils2.findParentNodeOfType)([bulletList, orderedList, taskList])(tr.selection);
91
- var bulletListActive = !!listParent && listParent.node.type === bulletList;
92
- var orderedListActive = !!listParent && listParent.node.type === orderedList;
93
- var bulletListDisabled = !(bulletListActive || orderedListActive || (0, _selection2.isWrappingPossible)(bulletList, tr.selection));
94
- var orderedListDisabled = !(bulletListActive || orderedListActive || (0, _selection2.isWrappingPossible)(orderedList, tr.selection));
105
+ var _getListState = getListState(tr.doc, tr.selection),
106
+ bulletListActive = _getListState.bulletListActive,
107
+ orderedListActive = _getListState.orderedListActive,
108
+ bulletListDisabled = _getListState.bulletListDisabled,
109
+ orderedListDisabled = _getListState.orderedListDisabled;
95
110
  if (bulletListActive !== pluginState.bulletListActive || orderedListActive !== pluginState.orderedListActive || bulletListDisabled !== pluginState.bulletListDisabled || orderedListDisabled !== pluginState.orderedListDisabled) {
96
111
  var nextPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
97
112
  bulletListActive: bulletListActive,
@@ -110,7 +125,7 @@ var reducer = function reducer() {
110
125
  };
111
126
  var createInitialState = function createInitialState(featureFlags) {
112
127
  return function (state) {
113
- return _objectSpread(_objectSpread({}, initialState), {}, {
128
+ return _objectSpread(_objectSpread({}, (0, _experiments.editorExperiment)('platform_editor_toolbar_aifc', true) && (0, _expValEquals.expValEquals)('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true) ? getListState(state.doc, state.selection) : initialState), {}, {
114
129
  decorationSet: getDecorations(state.doc, state, featureFlags)
115
130
  });
116
131
  };
@@ -5,6 +5,8 @@ import { getItemCounterDigitsSize, isListNode, pluginFactory } from '@atlaskit/e
5
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
6
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
7
7
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
9
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
8
10
  import { isWrappingPossible } from './utils/selection';
9
11
  const listPluginKey = new PluginKey('listPlugin');
10
12
  export const pluginKey = listPluginKey;
@@ -63,6 +65,24 @@ export const getDecorations = (doc, state, featureFlags) => {
63
65
  });
64
66
  return DecorationSet.empty.add(doc, decorations);
65
67
  };
68
+ const getListState = (doc, selection) => {
69
+ const {
70
+ bulletList,
71
+ orderedList,
72
+ taskList
73
+ } = doc.type.schema.nodes;
74
+ const listParent = findParentNodeOfType([bulletList, orderedList, taskList])(selection);
75
+ const bulletListActive = !!listParent && listParent.node.type === bulletList;
76
+ const orderedListActive = !!listParent && listParent.node.type === orderedList;
77
+ const bulletListDisabled = !(bulletListActive || orderedListActive || isWrappingPossible(bulletList, selection));
78
+ const orderedListDisabled = !(bulletListActive || orderedListActive || isWrappingPossible(orderedList, selection));
79
+ return {
80
+ bulletListActive,
81
+ bulletListDisabled,
82
+ orderedListActive,
83
+ orderedListDisabled
84
+ };
85
+ };
66
86
  const handleDocChanged = featureFlags => (tr, pluginState, editorState) => {
67
87
  const nextPluginState = handleSelectionChanged(tr, pluginState);
68
88
  const decorationSet = getDecorations(tr.doc, editorState, featureFlags);
@@ -73,15 +93,11 @@ const handleDocChanged = featureFlags => (tr, pluginState, editorState) => {
73
93
  };
74
94
  const handleSelectionChanged = (tr, pluginState) => {
75
95
  const {
76
- bulletList,
77
- orderedList,
78
- taskList
79
- } = tr.doc.type.schema.nodes;
80
- const listParent = findParentNodeOfType([bulletList, orderedList, taskList])(tr.selection);
81
- const bulletListActive = !!listParent && listParent.node.type === bulletList;
82
- const orderedListActive = !!listParent && listParent.node.type === orderedList;
83
- const bulletListDisabled = !(bulletListActive || orderedListActive || isWrappingPossible(bulletList, tr.selection));
84
- const orderedListDisabled = !(bulletListActive || orderedListActive || isWrappingPossible(orderedList, tr.selection));
96
+ bulletListActive,
97
+ orderedListActive,
98
+ bulletListDisabled,
99
+ orderedListDisabled
100
+ } = getListState(tr.doc, tr.selection);
85
101
  if (bulletListActive !== pluginState.bulletListActive || orderedListActive !== pluginState.orderedListActive || bulletListDisabled !== pluginState.bulletListDisabled || orderedListDisabled !== pluginState.orderedListDisabled) {
86
102
  const nextPluginState = {
87
103
  ...pluginState,
@@ -99,7 +115,9 @@ const reducer = () => state => {
99
115
  };
100
116
  const createInitialState = featureFlags => state => {
101
117
  return {
102
- ...initialState,
118
+ // When plugin is initialised, editor state is defined with selection
119
+ // hence returning the list state based on the selection to avoid list button in primary toolbar flickering during initial load
120
+ ...(editorExperiment('platform_editor_toolbar_aifc', true) && expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true) ? getListState(state.doc, state.selection) : initialState),
103
121
  decorationSet: getDecorations(state.doc, state, featureFlags)
104
122
  };
105
123
  };
@@ -8,6 +8,8 @@ import { getItemCounterDigitsSize, isListNode, pluginFactory } from '@atlaskit/e
8
8
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
9
9
  import { findParentNodeOfType } from '@atlaskit/editor-prosemirror/utils';
10
10
  import { Decoration, DecorationSet } from '@atlaskit/editor-prosemirror/view';
11
+ import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
12
+ import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
11
13
  import { isWrappingPossible } from './utils/selection';
12
14
  var listPluginKey = new PluginKey('listPlugin');
13
15
  export var pluginKey = listPluginKey;
@@ -66,6 +68,23 @@ export var getDecorations = function getDecorations(doc, state, featureFlags) {
66
68
  });
67
69
  return DecorationSet.empty.add(doc, decorations);
68
70
  };
71
+ var getListState = function getListState(doc, selection) {
72
+ var _doc$type$schema$node = doc.type.schema.nodes,
73
+ bulletList = _doc$type$schema$node.bulletList,
74
+ orderedList = _doc$type$schema$node.orderedList,
75
+ taskList = _doc$type$schema$node.taskList;
76
+ var listParent = findParentNodeOfType([bulletList, orderedList, taskList])(selection);
77
+ var bulletListActive = !!listParent && listParent.node.type === bulletList;
78
+ var orderedListActive = !!listParent && listParent.node.type === orderedList;
79
+ var bulletListDisabled = !(bulletListActive || orderedListActive || isWrappingPossible(bulletList, selection));
80
+ var orderedListDisabled = !(bulletListActive || orderedListActive || isWrappingPossible(orderedList, selection));
81
+ return {
82
+ bulletListActive: bulletListActive,
83
+ bulletListDisabled: bulletListDisabled,
84
+ orderedListActive: orderedListActive,
85
+ orderedListDisabled: orderedListDisabled
86
+ };
87
+ };
69
88
  var handleDocChanged = function handleDocChanged(featureFlags) {
70
89
  return function (tr, pluginState, editorState) {
71
90
  var nextPluginState = handleSelectionChanged(tr, pluginState);
@@ -76,15 +95,11 @@ var handleDocChanged = function handleDocChanged(featureFlags) {
76
95
  };
77
96
  };
78
97
  var handleSelectionChanged = function handleSelectionChanged(tr, pluginState) {
79
- var _tr$doc$type$schema$n = tr.doc.type.schema.nodes,
80
- bulletList = _tr$doc$type$schema$n.bulletList,
81
- orderedList = _tr$doc$type$schema$n.orderedList,
82
- taskList = _tr$doc$type$schema$n.taskList;
83
- var listParent = findParentNodeOfType([bulletList, orderedList, taskList])(tr.selection);
84
- var bulletListActive = !!listParent && listParent.node.type === bulletList;
85
- var orderedListActive = !!listParent && listParent.node.type === orderedList;
86
- var bulletListDisabled = !(bulletListActive || orderedListActive || isWrappingPossible(bulletList, tr.selection));
87
- var orderedListDisabled = !(bulletListActive || orderedListActive || isWrappingPossible(orderedList, tr.selection));
98
+ var _getListState = getListState(tr.doc, tr.selection),
99
+ bulletListActive = _getListState.bulletListActive,
100
+ orderedListActive = _getListState.orderedListActive,
101
+ bulletListDisabled = _getListState.bulletListDisabled,
102
+ orderedListDisabled = _getListState.orderedListDisabled;
88
103
  if (bulletListActive !== pluginState.bulletListActive || orderedListActive !== pluginState.orderedListActive || bulletListDisabled !== pluginState.bulletListDisabled || orderedListDisabled !== pluginState.orderedListDisabled) {
89
104
  var nextPluginState = _objectSpread(_objectSpread({}, pluginState), {}, {
90
105
  bulletListActive: bulletListActive,
@@ -103,7 +118,7 @@ var reducer = function reducer() {
103
118
  };
104
119
  var createInitialState = function createInitialState(featureFlags) {
105
120
  return function (state) {
106
- return _objectSpread(_objectSpread({}, initialState), {}, {
121
+ return _objectSpread(_objectSpread({}, editorExperiment('platform_editor_toolbar_aifc', true) && expValEquals('platform_editor_toolbar_aifc_patch_3', 'isEnabled', true) ? getListState(state.doc, state.selection) : initialState), {}, {
107
122
  decorationSet: getDecorations(state.doc, state, featureFlags)
108
123
  });
109
124
  };
@@ -2,8 +2,8 @@ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import type { FeatureFlags } from '@atlaskit/editor-common/types';
4
4
  import type { Node } from '@atlaskit/editor-prosemirror/model';
5
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
6
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
7
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
8
  import type { ListState } from '../types';
9
9
  export declare const pluginKey: PluginKey<ListState>;
@@ -2,8 +2,8 @@ import type { Dispatch } from '@atlaskit/editor-common/event-dispatcher';
2
2
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
3
3
  import type { FeatureFlags } from '@atlaskit/editor-common/types';
4
4
  import type { Node } from '@atlaskit/editor-prosemirror/model';
5
- import type { EditorState } from '@atlaskit/editor-prosemirror/state';
6
5
  import { PluginKey } from '@atlaskit/editor-prosemirror/state';
6
+ import type { EditorState } from '@atlaskit/editor-prosemirror/state';
7
7
  import { DecorationSet } from '@atlaskit/editor-prosemirror/view';
8
8
  import type { ListState } from '../types';
9
9
  export declare const pluginKey: PluginKey<ListState>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-list",
3
- "version": "6.0.2",
3
+ "version": "6.0.3",
4
4
  "description": "List plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -36,11 +36,11 @@
36
36
  "@atlaskit/icon": "^28.1.0",
37
37
  "@atlaskit/platform-feature-flags": "^1.1.0",
38
38
  "@atlaskit/prosemirror-input-rules": "^3.4.0",
39
- "@atlaskit/tmp-editor-statsig": "^12.4.0",
39
+ "@atlaskit/tmp-editor-statsig": "^12.8.0",
40
40
  "@babel/runtime": "^7.0.0"
41
41
  },
42
42
  "peerDependencies": {
43
- "@atlaskit/editor-common": "^108.2.0",
43
+ "@atlaskit/editor-common": "^108.6.0",
44
44
  "react": "^18.2.0",
45
45
  "react-intl-next": "npm:react-intl@^5.18.1"
46
46
  },