@atlaskit/editor-core 187.38.5 → 187.39.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,15 @@
1
1
  # @atlaskit/editor-core
2
2
 
3
+ ## 187.39.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`985ecca5c88`](https://bitbucket.org/atlassian/atlassian-frontend/commits/985ecca5c88) - Add new editor plugin action for the selection plugin, which allows other plugins to control the visibility of the gap cursor
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies
12
+
3
13
  ## 187.38.5
4
14
 
5
15
  ### Patch Changes
@@ -8,17 +8,29 @@ exports.selectionPlugin = exports.default = void 0;
8
8
  var _selectionMain = require("./pm-plugins/selection-main");
9
9
  var _keymap = _interopRequireDefault(require("./pm-plugins/keymap"));
10
10
  var _gapCursorMain = _interopRequireDefault(require("./pm-plugins/gap-cursor-main"));
11
+ var _gapCursorPluginKey = require("./pm-plugins/gap-cursor-plugin-key");
11
12
  var _gapCursorKeymap = _interopRequireDefault(require("./pm-plugins/gap-cursor-keymap"));
12
- var selectionPlugin = function selectionPlugin(_ref) {
13
- var options = _ref.config;
13
+ var displayGapCursor = function displayGapCursor(toggle) {
14
+ return function (_ref) {
15
+ var tr = _ref.tr;
16
+ return tr.setMeta(_gapCursorPluginKey.gapCursorPluginKey, {
17
+ displayGapCursor: toggle
18
+ });
19
+ };
20
+ };
21
+ var selectionPlugin = function selectionPlugin(_ref2) {
22
+ var options = _ref2.config;
14
23
  return {
15
24
  name: 'selection',
25
+ commands: {
26
+ displayGapCursor: displayGapCursor
27
+ },
16
28
  pmPlugins: function pmPlugins() {
17
29
  return [{
18
30
  name: 'selection',
19
- plugin: function plugin(_ref2) {
20
- var dispatch = _ref2.dispatch,
21
- dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
31
+ plugin: function plugin(_ref3) {
32
+ var dispatch = _ref3.dispatch,
33
+ dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
22
34
  return (0, _selectionMain.createPlugin)(dispatch, dispatchAnalyticsEvent, options);
23
35
  }
24
36
  }, {
@@ -20,10 +20,20 @@ var plugin = new _safePlugin.SafePlugin({
20
20
  key: _gapCursorPluginKey.gapCursorPluginKey,
21
21
  state: {
22
22
  init: function init() {
23
- return false;
23
+ return {
24
+ selectionIsGapCursor: false,
25
+ displayGapCursor: true
26
+ };
24
27
  },
25
- apply: function apply(_tr, _pluginState, _oldState, newState) {
26
- return newState.selection instanceof _selection.GapCursorSelection;
28
+ apply: function apply(tr, pluginState, _oldState, newState) {
29
+ var _meta$displayGapCurso;
30
+ var meta = tr.getMeta(_gapCursorPluginKey.gapCursorPluginKey);
31
+ var selectionIsGapCursor = newState.selection instanceof _selection.GapCursorSelection;
32
+ return {
33
+ selectionIsGapCursor: selectionIsGapCursor,
34
+ // only attempt to hide gap cursor if selection is gap cursor
35
+ displayGapCursor: selectionIsGapCursor ? (_meta$displayGapCurso = meta === null || meta === void 0 ? void 0 : meta.displayGapCursor) !== null && _meta$displayGapCurso !== void 0 ? _meta$displayGapCurso : pluginState.displayGapCursor : true
36
+ };
27
37
  }
28
38
  },
29
39
  view: function view(_view) {
@@ -40,9 +50,10 @@ var plugin = new _safePlugin.SafePlugin({
40
50
  }
41
51
  return {
42
52
  update: function update(view) {
43
- var pluginState = _gapCursorPluginKey.gapCursorPluginKey.getState(view.state);
53
+ var _gapCursorPluginKey$g = _gapCursorPluginKey.gapCursorPluginKey.getState(view.state),
54
+ selectionIsGapCursor = _gapCursorPluginKey$g.selectionIsGapCursor;
44
55
  /**
45
- * Starting with prosemirror-view 1.19.4, cursor wrapper that previousely was hiding cursor doesn't exist:
56
+ * Starting with prosemirror-view 1.19.4, cursor wrapper that previously was hiding cursor doesn't exist:
46
57
  * https://github.com/ProseMirror/prosemirror-view/commit/4a56bc7b7e61e96ef879d1dae1014ede0fc09e43
47
58
  *
48
59
  * Because it was causing issues with RTL: https://github.com/ProseMirror/prosemirror/issues/948
@@ -52,15 +63,17 @@ var plugin = new _safePlugin.SafePlugin({
52
63
  *
53
64
  * Browser support is pretty good: https://caniuse.com/#feat=css-caret-color
54
65
  */
55
- view.dom.classList.toggle(_styles.hideCaretModifier, pluginState);
66
+ view.dom.classList.toggle(_styles.hideCaretModifier, selectionIsGapCursor);
56
67
  }
57
68
  };
58
69
  },
59
70
  props: {
60
- decorations: function decorations(_ref) {
61
- var doc = _ref.doc,
62
- selection = _ref.selection;
63
- if (selection instanceof _selection.GapCursorSelection) {
71
+ decorations: function decorations(editorState) {
72
+ var doc = editorState.doc,
73
+ selection = editorState.selection;
74
+ var _gapCursorPluginKey$g2 = _gapCursorPluginKey.gapCursorPluginKey.getState(editorState),
75
+ displayGapCursor = _gapCursorPluginKey$g2.displayGapCursor;
76
+ if (selection instanceof _selection.GapCursorSelection && displayGapCursor) {
64
77
  var $from = selection.$from,
65
78
  side = selection.side;
66
79
 
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  exports.version = exports.nextMajorVersion = exports.name = void 0;
7
7
  var name = "@atlaskit/editor-core";
8
8
  exports.name = name;
9
- var version = "187.38.5";
9
+ var version = "187.39.0";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,11 +1,22 @@
1
1
  import { createPlugin } from './pm-plugins/selection-main';
2
2
  import selectionKeymapPlugin from './pm-plugins/keymap';
3
3
  import gapCursorPlugin from './pm-plugins/gap-cursor-main';
4
+ import { gapCursorPluginKey } from './pm-plugins/gap-cursor-plugin-key';
4
5
  import gapCursorKeymapPlugin from './pm-plugins/gap-cursor-keymap';
6
+ const displayGapCursor = toggle => ({
7
+ tr
8
+ }) => {
9
+ return tr.setMeta(gapCursorPluginKey, {
10
+ displayGapCursor: toggle
11
+ });
12
+ };
5
13
  export const selectionPlugin = ({
6
14
  config: options
7
15
  }) => ({
8
16
  name: 'selection',
17
+ commands: {
18
+ displayGapCursor
19
+ },
9
20
  pmPlugins() {
10
21
  return [{
11
22
  name: 'selection',
@@ -13,9 +13,19 @@ import { gapCursorPluginKey } from './gap-cursor-plugin-key';
13
13
  const plugin = new SafePlugin({
14
14
  key: gapCursorPluginKey,
15
15
  state: {
16
- init: () => false,
17
- apply: (_tr, _pluginState, _oldState, newState) => {
18
- return newState.selection instanceof GapCursorSelection;
16
+ init: () => ({
17
+ selectionIsGapCursor: false,
18
+ displayGapCursor: true
19
+ }),
20
+ apply: (tr, pluginState, _oldState, newState) => {
21
+ var _meta$displayGapCurso;
22
+ const meta = tr.getMeta(gapCursorPluginKey);
23
+ const selectionIsGapCursor = newState.selection instanceof GapCursorSelection;
24
+ return {
25
+ selectionIsGapCursor,
26
+ // only attempt to hide gap cursor if selection is gap cursor
27
+ displayGapCursor: selectionIsGapCursor ? (_meta$displayGapCurso = meta === null || meta === void 0 ? void 0 : meta.displayGapCursor) !== null && _meta$displayGapCurso !== void 0 ? _meta$displayGapCurso : pluginState.displayGapCursor : true
28
+ };
19
29
  }
20
30
  },
21
31
  view: view => {
@@ -32,9 +42,11 @@ const plugin = new SafePlugin({
32
42
  }
33
43
  return {
34
44
  update(view) {
35
- const pluginState = gapCursorPluginKey.getState(view.state);
45
+ const {
46
+ selectionIsGapCursor
47
+ } = gapCursorPluginKey.getState(view.state);
36
48
  /**
37
- * Starting with prosemirror-view 1.19.4, cursor wrapper that previousely was hiding cursor doesn't exist:
49
+ * Starting with prosemirror-view 1.19.4, cursor wrapper that previously was hiding cursor doesn't exist:
38
50
  * https://github.com/ProseMirror/prosemirror-view/commit/4a56bc7b7e61e96ef879d1dae1014ede0fc09e43
39
51
  *
40
52
  * Because it was causing issues with RTL: https://github.com/ProseMirror/prosemirror/issues/948
@@ -44,16 +56,20 @@ const plugin = new SafePlugin({
44
56
  *
45
57
  * Browser support is pretty good: https://caniuse.com/#feat=css-caret-color
46
58
  */
47
- view.dom.classList.toggle(hideCaretModifier, pluginState);
59
+ view.dom.classList.toggle(hideCaretModifier, selectionIsGapCursor);
48
60
  }
49
61
  };
50
62
  },
51
63
  props: {
52
- decorations: ({
53
- doc,
54
- selection
55
- }) => {
56
- if (selection instanceof GapCursorSelection) {
64
+ decorations: editorState => {
65
+ const {
66
+ doc,
67
+ selection
68
+ } = editorState;
69
+ const {
70
+ displayGapCursor
71
+ } = gapCursorPluginKey.getState(editorState);
72
+ if (selection instanceof GapCursorSelection && displayGapCursor) {
57
73
  const {
58
74
  $from,
59
75
  side
@@ -1,5 +1,5 @@
1
1
  export const name = "@atlaskit/editor-core";
2
- export const version = "187.38.5";
2
+ export const version = "187.39.0";
3
3
  export const nextMajorVersion = () => {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -1,17 +1,29 @@
1
1
  import { createPlugin } from './pm-plugins/selection-main';
2
2
  import selectionKeymapPlugin from './pm-plugins/keymap';
3
3
  import gapCursorPlugin from './pm-plugins/gap-cursor-main';
4
+ import { gapCursorPluginKey } from './pm-plugins/gap-cursor-plugin-key';
4
5
  import gapCursorKeymapPlugin from './pm-plugins/gap-cursor-keymap';
5
- export var selectionPlugin = function selectionPlugin(_ref) {
6
- var options = _ref.config;
6
+ var displayGapCursor = function displayGapCursor(toggle) {
7
+ return function (_ref) {
8
+ var tr = _ref.tr;
9
+ return tr.setMeta(gapCursorPluginKey, {
10
+ displayGapCursor: toggle
11
+ });
12
+ };
13
+ };
14
+ export var selectionPlugin = function selectionPlugin(_ref2) {
15
+ var options = _ref2.config;
7
16
  return {
8
17
  name: 'selection',
18
+ commands: {
19
+ displayGapCursor: displayGapCursor
20
+ },
9
21
  pmPlugins: function pmPlugins() {
10
22
  return [{
11
23
  name: 'selection',
12
- plugin: function plugin(_ref2) {
13
- var dispatch = _ref2.dispatch,
14
- dispatchAnalyticsEvent = _ref2.dispatchAnalyticsEvent;
24
+ plugin: function plugin(_ref3) {
25
+ var dispatch = _ref3.dispatch,
26
+ dispatchAnalyticsEvent = _ref3.dispatchAnalyticsEvent;
15
27
  return createPlugin(dispatch, dispatchAnalyticsEvent, options);
16
28
  }
17
29
  }, {
@@ -14,10 +14,20 @@ var plugin = new SafePlugin({
14
14
  key: gapCursorPluginKey,
15
15
  state: {
16
16
  init: function init() {
17
- return false;
17
+ return {
18
+ selectionIsGapCursor: false,
19
+ displayGapCursor: true
20
+ };
18
21
  },
19
- apply: function apply(_tr, _pluginState, _oldState, newState) {
20
- return newState.selection instanceof GapCursorSelection;
22
+ apply: function apply(tr, pluginState, _oldState, newState) {
23
+ var _meta$displayGapCurso;
24
+ var meta = tr.getMeta(gapCursorPluginKey);
25
+ var selectionIsGapCursor = newState.selection instanceof GapCursorSelection;
26
+ return {
27
+ selectionIsGapCursor: selectionIsGapCursor,
28
+ // only attempt to hide gap cursor if selection is gap cursor
29
+ displayGapCursor: selectionIsGapCursor ? (_meta$displayGapCurso = meta === null || meta === void 0 ? void 0 : meta.displayGapCursor) !== null && _meta$displayGapCurso !== void 0 ? _meta$displayGapCurso : pluginState.displayGapCursor : true
30
+ };
21
31
  }
22
32
  },
23
33
  view: function view(_view) {
@@ -34,9 +44,10 @@ var plugin = new SafePlugin({
34
44
  }
35
45
  return {
36
46
  update: function update(view) {
37
- var pluginState = gapCursorPluginKey.getState(view.state);
47
+ var _gapCursorPluginKey$g = gapCursorPluginKey.getState(view.state),
48
+ selectionIsGapCursor = _gapCursorPluginKey$g.selectionIsGapCursor;
38
49
  /**
39
- * Starting with prosemirror-view 1.19.4, cursor wrapper that previousely was hiding cursor doesn't exist:
50
+ * Starting with prosemirror-view 1.19.4, cursor wrapper that previously was hiding cursor doesn't exist:
40
51
  * https://github.com/ProseMirror/prosemirror-view/commit/4a56bc7b7e61e96ef879d1dae1014ede0fc09e43
41
52
  *
42
53
  * Because it was causing issues with RTL: https://github.com/ProseMirror/prosemirror/issues/948
@@ -46,15 +57,17 @@ var plugin = new SafePlugin({
46
57
  *
47
58
  * Browser support is pretty good: https://caniuse.com/#feat=css-caret-color
48
59
  */
49
- view.dom.classList.toggle(hideCaretModifier, pluginState);
60
+ view.dom.classList.toggle(hideCaretModifier, selectionIsGapCursor);
50
61
  }
51
62
  };
52
63
  },
53
64
  props: {
54
- decorations: function decorations(_ref) {
55
- var doc = _ref.doc,
56
- selection = _ref.selection;
57
- if (selection instanceof GapCursorSelection) {
65
+ decorations: function decorations(editorState) {
66
+ var doc = editorState.doc,
67
+ selection = editorState.selection;
68
+ var _gapCursorPluginKey$g2 = gapCursorPluginKey.getState(editorState),
69
+ displayGapCursor = _gapCursorPluginKey$g2.displayGapCursor;
70
+ if (selection instanceof GapCursorSelection && displayGapCursor) {
58
71
  var $from = selection.$from,
59
72
  side = selection.side;
60
73
 
@@ -1,5 +1,5 @@
1
1
  export var name = "@atlaskit/editor-core";
2
- export var version = "187.38.5";
2
+ export var version = "187.39.0";
3
3
  export var nextMajorVersion = function nextMajorVersion() {
4
4
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
5
5
  };
@@ -61,6 +61,9 @@ export declare function createDefaultPreset(options: EditorPresetProps & Default
61
61
  };
62
62
  }, CodeBlockOptions>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"selection", {
63
63
  pluginConfiguration: SelectionPluginOptions | undefined;
64
+ commands: {
65
+ displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
66
+ };
64
67
  }, SelectionPluginOptions | undefined>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"floatingToolbar", {
65
68
  dependencies: [import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
66
69
  pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
@@ -213,6 +216,9 @@ export declare function useDefaultPreset(props: EditorPresetProps & DefaultPrese
213
216
  };
214
217
  }, CodeBlockOptions>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"selection", {
215
218
  pluginConfiguration: SelectionPluginOptions | undefined;
219
+ commands: {
220
+ displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
221
+ };
216
222
  }, SelectionPluginOptions | undefined>, import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"floatingToolbar", {
217
223
  dependencies: [import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"featureFlags", {
218
224
  pluginConfiguration: import("@atlaskit/editor-common/types").FeatureFlags;
@@ -1,6 +1,10 @@
1
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
1
+ import type { EditorCommand, NextEditorPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { SelectionPluginOptions } from './types';
3
- export declare const selectionPlugin: NextEditorPlugin<'selection', {
3
+ type SelectionPlugin = NextEditorPlugin<'selection', {
4
4
  pluginConfiguration: SelectionPluginOptions | undefined;
5
+ commands: {
6
+ displayGapCursor: (toggle: boolean) => EditorCommand;
7
+ };
5
8
  }>;
9
+ export declare const selectionPlugin: SelectionPlugin;
6
10
  export default selectionPlugin;
@@ -1,3 +1,6 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- declare const plugin: SafePlugin<boolean>;
2
+ declare const plugin: SafePlugin<{
3
+ selectionIsGapCursor: boolean;
4
+ displayGapCursor: boolean;
5
+ }>;
3
6
  export default plugin;
@@ -84,6 +84,9 @@ export declare function createDefaultPreset(options: EditorPresetProps & Default
84
84
  }, CodeBlockOptions>,
85
85
  import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"selection", {
86
86
  pluginConfiguration: SelectionPluginOptions | undefined;
87
+ commands: {
88
+ displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
89
+ };
87
90
  }, SelectionPluginOptions | undefined>,
88
91
  import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"floatingToolbar", {
89
92
  dependencies: [
@@ -290,6 +293,9 @@ export declare function useDefaultPreset(props: EditorPresetProps & DefaultPrese
290
293
  }, CodeBlockOptions>,
291
294
  import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"selection", {
292
295
  pluginConfiguration: SelectionPluginOptions | undefined;
296
+ commands: {
297
+ displayGapCursor: (toggle: boolean) => import("@atlaskit/editor-common/types").EditorCommand;
298
+ };
293
299
  }, SelectionPluginOptions | undefined>,
294
300
  import("@atlaskit/editor-common/types").NextEditorPluginFunctionOptionalConfigDefinition<"floatingToolbar", {
295
301
  dependencies: [
@@ -1,6 +1,10 @@
1
- import type { NextEditorPlugin } from '@atlaskit/editor-common/types';
1
+ import type { EditorCommand, NextEditorPlugin } from '@atlaskit/editor-common/types';
2
2
  import type { SelectionPluginOptions } from './types';
3
- export declare const selectionPlugin: NextEditorPlugin<'selection', {
3
+ type SelectionPlugin = NextEditorPlugin<'selection', {
4
4
  pluginConfiguration: SelectionPluginOptions | undefined;
5
+ commands: {
6
+ displayGapCursor: (toggle: boolean) => EditorCommand;
7
+ };
5
8
  }>;
9
+ export declare const selectionPlugin: SelectionPlugin;
6
10
  export default selectionPlugin;
@@ -1,3 +1,6 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- declare const plugin: SafePlugin<boolean>;
2
+ declare const plugin: SafePlugin<{
3
+ selectionIsGapCursor: boolean;
4
+ displayGapCursor: boolean;
5
+ }>;
3
6
  export default plugin;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.38.5",
3
+ "version": "187.39.0",
4
4
  "description": "A package contains Atlassian editor core functionality",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -78,7 +78,7 @@
78
78
  "@atlaskit/editor-plugin-list": "^1.2.0",
79
79
  "@atlaskit/editor-plugin-placeholder": "^0.1.0",
80
80
  "@atlaskit/editor-plugin-rule": "^0.1.0",
81
- "@atlaskit/editor-plugin-table": "^2.12.0",
81
+ "@atlaskit/editor-plugin-table": "^2.13.0",
82
82
  "@atlaskit/editor-plugin-text-formatting": "^0.4.0",
83
83
  "@atlaskit/editor-plugin-type-ahead": "^0.3.0",
84
84
  "@atlaskit/editor-plugin-unsupported-content": "^0.2.0",
@@ -118,7 +118,7 @@
118
118
  "@atlaskit/textfield": "^5.6.0",
119
119
  "@atlaskit/theme": "^12.6.0",
120
120
  "@atlaskit/toggle": "^12.6.0",
121
- "@atlaskit/tokens": "^1.20.0",
121
+ "@atlaskit/tokens": "^1.21.0",
122
122
  "@atlaskit/tooltip": "^17.8.0",
123
123
  "@atlaskit/width-detector": "^4.1.0",
124
124
  "@babel/runtime": "^7.0.0",
@@ -152,7 +152,7 @@
152
152
  "@atlaskit/collab-provider": "9.12.1",
153
153
  "@atlaskit/dropdown-menu": "^11.13.0",
154
154
  "@atlaskit/editor-extension-dropbox": "^0.4.0",
155
- "@atlaskit/editor-plugin-table": "^2.12.0",
155
+ "@atlaskit/editor-plugin-table": "^2.13.0",
156
156
  "@atlaskit/flag": "^15.2.0",
157
157
  "@atlaskit/icon-object": "^6.3.0",
158
158
  "@atlaskit/inline-dialog": "^13.6.0",