@atlaskit/editor-core 187.18.2 → 187.19.1

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 (108) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/labs/next/presets/default.js +2 -1
  3. package/dist/cjs/plugins/base/index.js +0 -7
  4. package/dist/cjs/plugins/code-block/index.js +1 -1
  5. package/dist/cjs/plugins/code-block/pm-plugins/ide-ux.js +98 -95
  6. package/dist/cjs/plugins/composition/index.js +33 -0
  7. package/dist/cjs/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js} +8 -14
  8. package/dist/cjs/plugins/composition/pm-plugins/plugin-key.js +9 -0
  9. package/dist/cjs/plugins/media/index.js +4 -3
  10. package/dist/cjs/plugins/media/pm-plugins/alt-text/commands.js +10 -7
  11. package/dist/cjs/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
  12. package/dist/cjs/plugins/media/pm-plugins/main.js +9 -9
  13. package/dist/cjs/plugins/media/toolbar/alt-text.js +2 -2
  14. package/dist/cjs/plugins/media/toolbar/index.js +12 -11
  15. package/dist/cjs/plugins/media/utils/media-single.js +13 -13
  16. package/dist/cjs/plugins/paste/handlers.js +2 -2
  17. package/dist/cjs/plugins/paste/pm-plugins/analytics.js +2 -2
  18. package/dist/cjs/plugins/paste/pm-plugins/main.js +4 -4
  19. package/dist/cjs/plugins/placeholder/index.js +2 -2
  20. package/dist/cjs/plugins/selection/gap-cursor/styles.js +1 -1
  21. package/dist/cjs/plugins/selection/gap-cursor/utils/place-gap-cursor.js +3 -3
  22. package/dist/cjs/plugins/selection/gap-cursor/utils.js +6 -3
  23. package/dist/cjs/plugins/selection/pm-plugins/gap-cursor-main.js +3 -3
  24. package/dist/cjs/version-wrapper.js +1 -1
  25. package/dist/cjs/version.json +1 -1
  26. package/dist/es2019/labs/next/presets/default.js +2 -1
  27. package/dist/es2019/plugins/base/index.js +0 -5
  28. package/dist/es2019/plugins/code-block/index.js +1 -1
  29. package/dist/es2019/plugins/code-block/pm-plugins/ide-ux.js +107 -104
  30. package/dist/es2019/plugins/composition/index.js +23 -0
  31. package/dist/es2019/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js} +7 -12
  32. package/dist/es2019/plugins/composition/pm-plugins/plugin-key.js +2 -0
  33. package/dist/es2019/plugins/media/index.js +6 -3
  34. package/dist/es2019/plugins/media/pm-plugins/alt-text/commands.js +3 -2
  35. package/dist/es2019/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
  36. package/dist/es2019/plugins/media/pm-plugins/main.js +7 -7
  37. package/dist/es2019/plugins/media/toolbar/alt-text.js +2 -2
  38. package/dist/es2019/plugins/media/toolbar/index.js +12 -11
  39. package/dist/es2019/plugins/media/utils/media-single.js +7 -8
  40. package/dist/es2019/plugins/paste/handlers.js +2 -3
  41. package/dist/es2019/plugins/paste/pm-plugins/analytics.js +2 -2
  42. package/dist/es2019/plugins/paste/pm-plugins/main.js +4 -4
  43. package/dist/es2019/plugins/placeholder/index.js +2 -2
  44. package/dist/es2019/plugins/selection/gap-cursor/styles.js +2 -1
  45. package/dist/es2019/plugins/selection/gap-cursor/utils/place-gap-cursor.js +4 -4
  46. package/dist/es2019/plugins/selection/gap-cursor/utils.js +5 -2
  47. package/dist/es2019/plugins/selection/pm-plugins/gap-cursor-main.js +4 -4
  48. package/dist/es2019/version-wrapper.js +1 -1
  49. package/dist/es2019/version.json +1 -1
  50. package/dist/esm/labs/next/presets/default.js +2 -1
  51. package/dist/esm/plugins/base/index.js +0 -7
  52. package/dist/esm/plugins/code-block/index.js +1 -1
  53. package/dist/esm/plugins/code-block/pm-plugins/ide-ux.js +98 -95
  54. package/dist/esm/plugins/composition/index.js +25 -0
  55. package/dist/esm/plugins/{base/pm-plugins/composition.js → composition/pm-plugins/main.js} +7 -12
  56. package/dist/esm/plugins/composition/pm-plugins/plugin-key.js +2 -0
  57. package/dist/esm/plugins/media/index.js +4 -3
  58. package/dist/esm/plugins/media/pm-plugins/alt-text/commands.js +10 -7
  59. package/dist/esm/plugins/media/pm-plugins/alt-text/keymap.js +2 -2
  60. package/dist/esm/plugins/media/pm-plugins/main.js +7 -7
  61. package/dist/esm/plugins/media/toolbar/alt-text.js +2 -2
  62. package/dist/esm/plugins/media/toolbar/index.js +12 -11
  63. package/dist/esm/plugins/media/utils/media-single.js +7 -7
  64. package/dist/esm/plugins/paste/handlers.js +2 -3
  65. package/dist/esm/plugins/paste/pm-plugins/analytics.js +2 -2
  66. package/dist/esm/plugins/paste/pm-plugins/main.js +4 -4
  67. package/dist/esm/plugins/placeholder/index.js +2 -2
  68. package/dist/esm/plugins/selection/gap-cursor/styles.js +1 -1
  69. package/dist/esm/plugins/selection/gap-cursor/utils/place-gap-cursor.js +4 -4
  70. package/dist/esm/plugins/selection/gap-cursor/utils.js +5 -2
  71. package/dist/esm/plugins/selection/pm-plugins/gap-cursor-main.js +4 -4
  72. package/dist/esm/version-wrapper.js +1 -1
  73. package/dist/esm/version.json +1 -1
  74. package/dist/types/labs/next/presets/default.d.ts +16 -0
  75. package/dist/types/plugins/code-block/index.d.ts +6 -4
  76. package/dist/types/plugins/code-block/pm-plugins/ide-ux.d.ts +4 -2
  77. package/dist/types/plugins/composition/index.d.ts +8 -0
  78. package/dist/types/plugins/composition/pm-plugins/main.d.ts +4 -0
  79. package/dist/types/plugins/composition/pm-plugins/plugin-key.d.ts +6 -0
  80. package/dist/types/plugins/media/pm-plugins/alt-text/commands.d.ts +2 -1
  81. package/dist/types/plugins/media/pm-plugins/alt-text/keymap.d.ts +2 -1
  82. package/dist/types/plugins/media/toolbar/alt-text.d.ts +2 -1
  83. package/dist/types/plugins/media/utils/media-single.d.ts +3 -3
  84. package/dist/types/plugins/paste/handlers.d.ts +2 -1
  85. package/dist/types/plugins/paste/index.d.ts +3 -1
  86. package/dist/types/plugins/paste/pm-plugins/analytics.d.ts +2 -1
  87. package/dist/types/plugins/placeholder/index.d.ts +2 -1
  88. package/dist/types/plugins/selection/gap-cursor/utils.d.ts +1 -1
  89. package/dist/types-ts4.5/labs/next/presets/default.d.ts +20 -0
  90. package/dist/types-ts4.5/plugins/code-block/index.d.ts +6 -4
  91. package/dist/types-ts4.5/plugins/code-block/pm-plugins/ide-ux.d.ts +4 -2
  92. package/dist/types-ts4.5/plugins/composition/index.d.ts +8 -0
  93. package/dist/types-ts4.5/plugins/composition/pm-plugins/main.d.ts +4 -0
  94. package/dist/types-ts4.5/plugins/composition/pm-plugins/plugin-key.d.ts +6 -0
  95. package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/commands.d.ts +2 -1
  96. package/dist/types-ts4.5/plugins/media/pm-plugins/alt-text/keymap.d.ts +2 -1
  97. package/dist/types-ts4.5/plugins/media/toolbar/alt-text.d.ts +2 -1
  98. package/dist/types-ts4.5/plugins/media/utils/media-single.d.ts +3 -3
  99. package/dist/types-ts4.5/plugins/paste/handlers.d.ts +2 -1
  100. package/dist/types-ts4.5/plugins/paste/index.d.ts +3 -1
  101. package/dist/types-ts4.5/plugins/paste/pm-plugins/analytics.d.ts +2 -1
  102. package/dist/types-ts4.5/plugins/placeholder/index.d.ts +3 -1
  103. package/dist/types-ts4.5/plugins/selection/gap-cursor/utils.d.ts +1 -1
  104. package/package.json +1 -1
  105. package/report.api.md +1 -0
  106. package/tmp/api-report-tmp.d.ts +1 -1
  107. package/dist/types/plugins/base/pm-plugins/composition.d.ts +0 -9
  108. package/dist/types-ts4.5/plugins/base/pm-plugins/composition.d.ts +0 -9
@@ -16,8 +16,7 @@ var _utils3 = require("@atlaskit/editor-common/utils");
16
16
  var _mediaSingle = require("@atlaskit/editor-common/media-single");
17
17
  var _mediaCommon = require("../utils/media-common");
18
18
  var _slice = require("../../../utils/slice");
19
- var _analytics = require("../../analytics");
20
- var _analytics2 = require("@atlaskit/editor-common/analytics");
19
+ var _analytics = require("@atlaskit/editor-common/analytics");
21
20
  var _insert = require("@atlaskit/editor-common/insert");
22
21
  var _isImage = require("./is-image");
23
22
  var _position = require("../../../utils/prosemirror/position");
@@ -27,15 +26,15 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (O
27
26
  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) { (0, _defineProperty2.default)(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; }
28
27
  var getInsertMediaAnalytics = function getInsertMediaAnalytics(inputMethod, fileExtension) {
29
28
  return {
30
- action: _analytics2.ACTION.INSERTED,
31
- actionSubject: _analytics2.ACTION_SUBJECT.DOCUMENT,
32
- actionSubjectId: _analytics2.ACTION_SUBJECT_ID.MEDIA,
29
+ action: _analytics.ACTION.INSERTED,
30
+ actionSubject: _analytics.ACTION_SUBJECT.DOCUMENT,
31
+ actionSubjectId: _analytics.ACTION_SUBJECT_ID.MEDIA,
33
32
  attributes: {
34
33
  inputMethod: inputMethod,
35
34
  fileExtension: fileExtension,
36
- type: _analytics2.ACTION_SUBJECT_ID.MEDIA_SINGLE
35
+ type: _analytics.ACTION_SUBJECT_ID.MEDIA_SINGLE
37
36
  },
38
- eventType: _analytics2.EVENT_TYPE.TRACK
37
+ eventType: _analytics.EVENT_TYPE.TRACK
39
38
  };
40
39
  };
41
40
  function shouldAddParagraph(state) {
@@ -43,6 +42,7 @@ function shouldAddParagraph(state) {
43
42
  }
44
43
  function insertNodesWithOptionalParagraph(nodes) {
45
44
  var analyticsAttributes = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
45
+ var editorAnalyticsAPI = arguments.length > 2 ? arguments[2] : undefined;
46
46
  return function (state, dispatch) {
47
47
  var tr = state.tr,
48
48
  schema = state.schema;
@@ -56,7 +56,7 @@ function insertNodesWithOptionalParagraph(nodes) {
56
56
  }
57
57
  tr.replaceSelection(new _model.Slice(_model.Fragment.from(nodes), 0, openEnd));
58
58
  if (inputMethod) {
59
- (0, _analytics.addAnalytics)(state, tr, getInsertMediaAnalytics(inputMethod, fileExtension));
59
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension))(tr);
60
60
  }
61
61
  if (dispatch) {
62
62
  dispatch(tr);
@@ -68,7 +68,7 @@ var isMediaSingle = function isMediaSingle(schema, fileMimeType) {
68
68
  return !!schema.nodes.mediaSingle && (0, _isImage.isImage)(fileMimeType);
69
69
  };
70
70
  exports.isMediaSingle = isMediaSingle;
71
- var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod) {
71
+ var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inputMethod, editorAnalyticsAPI) {
72
72
  var state = view.state,
73
73
  dispatch = view.dispatch;
74
74
  var _state$schema$nodes = state.schema.nodes,
@@ -88,10 +88,10 @@ var insertMediaAsMediaSingle = function insertMediaAsMediaSingle(view, node, inp
88
88
  inputMethod: inputMethod,
89
89
  fileExtension: node.attrs.__fileMimeType
90
90
  };
91
- return insertNodesWithOptionalParagraph(nodes, analyticsAttributes)(state, dispatch);
91
+ return insertNodesWithOptionalParagraph(nodes, analyticsAttributes, editorAnalyticsAPI)(state, dispatch);
92
92
  };
93
93
  exports.insertMediaAsMediaSingle = insertMediaAsMediaSingle;
94
- var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState) {
94
+ var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inputMethod, collection, alignLeftOnInsert, newInsertionBehaviour, widthPluginState, editorAnalyticsAPI) {
95
95
  var _state$selection$$fro;
96
96
  if (collection === undefined) {
97
97
  return false;
@@ -122,7 +122,7 @@ var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inp
122
122
  insertNodesWithOptionalParagraph([node], {
123
123
  fileExtension: fileExtension,
124
124
  inputMethod: inputMethod
125
- })(state, dispatch);
125
+ }, editorAnalyticsAPI)(state, dispatch);
126
126
  } else {
127
127
  var tr = null;
128
128
  if (newInsertionBehaviour) {
@@ -133,7 +133,7 @@ var insertMediaSingleNode = function insertMediaSingleNode(view, mediaState, inp
133
133
  tr = (0, _utils.safeInsert)(content, undefined, true)(state.tr);
134
134
  }
135
135
  if (inputMethod) {
136
- tr = (0, _analytics.addAnalytics)(state, tr, getInsertMediaAnalytics(inputMethod, fileExtension));
136
+ editorAnalyticsAPI === null || editorAnalyticsAPI === void 0 ? void 0 : editorAnalyticsAPI.attachAnalyticsEvent(getInsertMediaAnalytics(inputMethod, fileExtension))(tr);
137
137
  }
138
138
  dispatch(tr);
139
139
  }
@@ -544,12 +544,12 @@ function isOnlyMediaSingle(state, slice) {
544
544
  var mediaSingle = state.schema.nodes.mediaSingle;
545
545
  return mediaSingle && slice.content.childCount === 1 && slice.content.firstChild.type === mediaSingle;
546
546
  }
547
- function handleMediaSingle(inputMethod) {
547
+ function handleMediaSingle(inputMethod, editorAnalyticsAPI) {
548
548
  return function (slice) {
549
549
  return function (state, dispatch, view) {
550
550
  if (view) {
551
551
  if (isOnlyMedia(state, slice)) {
552
- return (0, _mediaSingle.insertMediaAsMediaSingle)(view, slice.content.firstChild, inputMethod);
552
+ return (0, _mediaSingle.insertMediaAsMediaSingle)(view, slice.content.firstChild, inputMethod, editorAnalyticsAPI);
553
553
  }
554
554
  if ((0, _utils3.insideTable)(state) && isOnlyMediaSingle(state, slice)) {
555
555
  var tr = state.tr.replaceSelection(slice);
@@ -257,10 +257,10 @@ var handleCodeBlockWithAnalytics = function handleCodeBlockWithAnalytics(view, e
257
257
  }))((0, _handlers.handleCodeBlock)(text));
258
258
  };
259
259
  exports.handleCodeBlockWithAnalytics = handleCodeBlockWithAnalytics;
260
- var handleMediaSingleWithAnalytics = function handleMediaSingleWithAnalytics(view, event, slice, type) {
260
+ var handleMediaSingleWithAnalytics = function handleMediaSingleWithAnalytics(view, event, slice, type, editorAnalyticsAPI) {
261
261
  return injectAnalyticsPayloadBeforeCommand(createPasteAnalyticsPayloadBySelection(event, slice, {
262
262
  type: type
263
- }))((0, _handlers.handleMediaSingle)(_analytics.INPUT_METHOD.CLIPBOARD)(slice));
263
+ }))((0, _handlers.handleMediaSingle)(_analytics.INPUT_METHOD.CLIPBOARD, editorAnalyticsAPI)(slice));
264
264
  };
265
265
  exports.handleMediaSingleWithAnalytics = handleMediaSingleWithAnalytics;
266
266
  var handlePastePreservingMarksWithAnalytics = function handlePastePreservingMarksWithAnalytics(view, event, slice, type, pluginInjectionApi) {
@@ -112,7 +112,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
112
112
  }
113
113
  },
114
114
  handlePaste: function handlePaste(view, rawEvent, slice) {
115
- var _text, _analyticsPlugin$perf, _analyticsPlugin$perf2, _schema$nodes, _schema$nodes2, _schema$nodes3;
115
+ var _text, _analyticsPlugin$perf, _analyticsPlugin$perf2, _schema$nodes, _schema$nodes2, _schema$nodes3, _pluginInjectionApi$d4, _pluginInjectionApi$d5;
116
116
  var event = rawEvent;
117
117
  if (!event.clipboardData) {
118
118
  return false;
@@ -276,7 +276,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
276
276
  if ((0, _analytics.handleCodeBlockWithAnalytics)(view, event, slice, text)(state, dispatch)) {
277
277
  return true;
278
278
  }
279
- if ((0, _analytics.handleMediaSingleWithAnalytics)(view, event, slice, isPastedFile ? _analytics2.PasteTypes.binary : _analytics2.PasteTypes.richText)(state, dispatch, view)) {
279
+ if ((0, _analytics.handleMediaSingleWithAnalytics)(view, event, slice, isPastedFile ? _analytics2.PasteTypes.binary : _analytics2.PasteTypes.richText, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.analytics) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.actions)(state, dispatch, view)) {
280
280
  return true;
281
281
  }
282
282
  if ((0, _analytics.handleSelectedTableWithAnalytics)(view, event, slice)(state, dispatch)) {
@@ -309,7 +309,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
309
309
 
310
310
  // finally, handle rich-text copy-paste
311
311
  if (isRichText) {
312
- var _pluginInjectionApi$d4, _pluginInjectionApi$d5;
312
+ var _pluginInjectionApi$d6, _pluginInjectionApi$d7;
313
313
  // linkify the text where possible
314
314
  slice = (0, _utils.linkifyContent)(state.schema)(slice);
315
315
  if ((0, _analytics.handlePasteLinkOnSelectedTextWithAnalytics)(view, event, slice, _analytics2.PasteTypes.richText)(state, dispatch)) {
@@ -317,7 +317,7 @@ function createPlugin(schema, dispatchAnalyticsEvent, dispatch, featureFlags, pl
317
317
  }
318
318
 
319
319
  // run macro autoconvert prior to other conversions
320
- if ((0, _handlers.handleMacroAutoConvert)(text, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d4 = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d4 === void 0 ? void 0 : (_pluginInjectionApi$d5 = _pluginInjectionApi$d4.actions) === null || _pluginInjectionApi$d5 === void 0 ? void 0 : _pluginInjectionApi$d5.queueCardsFromChangedTr, cardOptions, extensionAutoConverter)(state, dispatch, view)) {
320
+ if ((0, _handlers.handleMacroAutoConvert)(text, slice, pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : (_pluginInjectionApi$d6 = pluginInjectionApi.dependencies.card) === null || _pluginInjectionApi$d6 === void 0 ? void 0 : (_pluginInjectionApi$d7 = _pluginInjectionApi$d6.actions) === null || _pluginInjectionApi$d7 === void 0 ? void 0 : _pluginInjectionApi$d7.queueCardsFromChangedTr, cardOptions, extensionAutoConverter)(state, dispatch, view)) {
321
321
  // TODO: handleMacroAutoConvert dispatch twice, so we can't use the helper
322
322
  (0, _analytics.sendPasteAnalyticsEvent)(view, event, slice, {
323
323
  type: _analytics2.PasteTypes.richText
@@ -11,7 +11,6 @@ var _utils = require("@atlaskit/editor-common/utils");
11
11
  var _state = require("@atlaskit/editor-prosemirror/state");
12
12
  var _view = require("@atlaskit/editor-prosemirror/view");
13
13
  var _utils2 = require("../type-ahead/utils");
14
- var _composition = require("../base/pm-plugins/composition");
15
14
  var pluginKey = new _state.PluginKey('placeholderPlugin');
16
15
  exports.pluginKey = pluginKey;
17
16
  function getPlaceholderState(editorState) {
@@ -108,7 +107,8 @@ function createPlugin(defaultPlaceholderText, bracketPlaceholderText, api) {
108
107
  hasPlaceholder = _getPlaceholderState.hasPlaceholder,
109
108
  placeholderText = _getPlaceholderState.placeholderText,
110
109
  pos = _getPlaceholderState.pos;
111
- if (hasPlaceholder && placeholderText && pos !== undefined && !(0, _composition.isComposing)(editorState)) {
110
+ var compositionPluginState = api === null || api === void 0 ? void 0 : api.dependencies.composition.sharedState.currentState();
111
+ if (hasPlaceholder && placeholderText && pos !== undefined && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing)) {
112
112
  return createPlaceholderDecoration(editorState, placeholderText, pos);
113
113
  }
114
114
  return;
@@ -15,5 +15,5 @@ var gapCursor = '.ProseMirror-gapcursor';
15
15
  var prosemirrorwidget = '.ProseMirror-widget';
16
16
  var wrapLeft = '[layout="wrap-left"]';
17
17
  var wrapRight = '[layout="wrap-right"]';
18
- var gapCursorStyles = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n /* =============== GAP CURSOR ================== */\n .ProseMirror {\n &.", " {\n caret-color: transparent;\n }\n\n ", " {\n display: none;\n pointer-events: none;\n position: relative;\n\n & span {\n caret-color: transparent;\n position: absolute;\n height: 100%;\n width: 100%;\n display: block;\n }\n\n & span::after {\n animation: 1s ", " step-end infinite;\n border-left: 1px solid;\n content: '';\n display: block;\n position: absolute;\n top: 0;\n height: 100%;\n }\n &.-left span::after {\n left: -3px;\n }\n &.-right span::after {\n right: -3px;\n }\n & span[layout='full-width'],\n & span[layout='wide'] {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n &", " {\n float: right;\n }\n\n /* fix vertical alignment of gap cursor */\n &:first-of-type + ul,\n &:first-of-type + span + ul,\n &:first-of-type + ol,\n &:first-of-type + span + ol,\n &:first-of-type + pre,\n &:first-of-type + span + pre,\n &:first-of-type + blockquote,\n &:first-of-type + span + blockquote {\n margin-top: 0;\n }\n }\n &.ProseMirror-focused ", " {\n display: block;\n border-color: transparent;\n }\n }\n\n /* This hack below is for two images aligned side by side */\n ", "", " + span + ", ",\n ", "", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " {\n clear: none;\n }\n\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div {\n margin-right: 0;\n margin-left: 0;\n margin-bottom: 0;\n }\n\n ", " + ", ",\n ", " + ", " {\n float: left;\n }\n\n ", " + ", " + span + ", "::after,\n ", " + ", " + span + ", "::after,\n ", " + ", " + ", "::after,\n ", " + ", " + span + ", "::after,\n ", " + ", " + ", "::after,\n ", " + ", " + span + ", "::after {\n visibility: hidden;\n display: block;\n font-size: 0;\n content: ' ';\n clear: both;\n height: 0;\n }\n\n ", " + ", " + ", " + *,\n ", " + ", " + ", " + span + *,\n ", " + ", " + ", " + *,\n ", " + ", " + ", " + span + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + ", " + * > *,\n ", " + ", " + ", " + span + * > *,\n ", " + ", " + ", " + * > *,\n ", " + ", " + ", " + span + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + *,\n ", " + ", " + span + * {\n margin-top: 0;\n }\n"])), hideCaretModifier, gapCursor, gapCursorBlink, wrapRight, gapCursor, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapRight, wrapLeft, gapCursor, wrapRight, gapCursor, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, prosemirrorwidget, gapCursor, prosemirrorwidget, gapCursor);
18
+ var gapCursorStyles = (0, _react.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n /* =============== GAP CURSOR ================== */\n .ProseMirror {\n &.", " {\n caret-color: transparent;\n }\n\n ", " {\n display: none;\n pointer-events: none;\n position: relative;\n\n & span {\n caret-color: transparent;\n position: absolute;\n height: 100%;\n width: 100%;\n display: block;\n }\n\n & span::after {\n animation: 1s ", " step-end infinite;\n border-left: 1px solid;\n content: '';\n display: block;\n position: absolute;\n top: 0;\n height: 100%;\n }\n &.-left span::after {\n left: -3px;\n }\n &.-right span::after {\n right: -3px;\n }\n & span[layout='full-width'],\n & span[layout='wide'],\n & span[layout='fixed-width'] {\n margin-left: 50%;\n transform: translateX(-50%);\n }\n &", " {\n float: right;\n }\n\n /* fix vertical alignment of gap cursor */\n &:first-of-type + ul,\n &:first-of-type + span + ul,\n &:first-of-type + ol,\n &:first-of-type + span + ol,\n &:first-of-type + pre,\n &:first-of-type + span + pre,\n &:first-of-type + blockquote,\n &:first-of-type + span + blockquote {\n margin-top: 0;\n }\n }\n &.ProseMirror-focused ", " {\n display: block;\n border-color: transparent;\n }\n }\n\n /* This hack below is for two images aligned side by side */\n ", "", " + span + ", ",\n ", "", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " + ", ",\n ", " + ", " + span ", ",\n ", " + ", " + ", ",\n ", " + ", " + span + ", ",\n ", " + ", " {\n clear: none;\n }\n\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div,\n ", " + ", " + ", " > div,\n ", " + ", " + span + ", " > div {\n margin-right: 0;\n margin-left: 0;\n margin-bottom: 0;\n }\n\n ", " + ", ",\n ", " + ", " {\n float: left;\n }\n\n ", " + ", " + span + ", "::after,\n ", " + ", " + span + ", "::after,\n ", " + ", " + ", "::after,\n ", " + ", " + span + ", "::after,\n ", " + ", " + ", "::after,\n ", " + ", " + span + ", "::after {\n visibility: hidden;\n display: block;\n font-size: 0;\n content: ' ';\n clear: both;\n height: 0;\n }\n\n ", " + ", " + ", " + *,\n ", " + ", " + ", " + span + *,\n ", " + ", " + ", " + *,\n ", " + ", " + ", " + span + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + span + ", " + *,\n ", " + ", " + ", " + * > *,\n ", " + ", " + ", " + span + * > *,\n ", " + ", " + ", " + * > *,\n ", " + ", " + ", " + span + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + span + ", " + * > *,\n ", " + ", " + *,\n ", " + ", " + span + * {\n margin-top: 0;\n }\n"])), hideCaretModifier, gapCursor, gapCursorBlink, wrapRight, gapCursor, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapRight, wrapLeft, gapCursor, wrapRight, gapCursor, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, wrapRight, gapCursor, wrapLeft, wrapLeft, gapCursor, wrapRight, wrapRight, gapCursor, wrapLeft, gapCursor, wrapLeft, wrapRight, gapCursor, wrapRight, wrapLeft, prosemirrorwidget, gapCursor, prosemirrorwidget, gapCursor);
19
19
  exports.gapCursorStyles = gapCursorStyles;
@@ -85,9 +85,9 @@ var toDOM = function toDOM(view, getPos) {
85
85
  if (nodeStart !== 0 || node && node.type.name === 'table') {
86
86
  gapCursor.style.marginTop = style.getPropertyValue('margin-top');
87
87
  }
88
- var breakoutMode = node && (0, _utils.getBreakoutModeFromTargetNode)(node);
89
- if (breakoutMode) {
90
- gapCursor.setAttribute('layout', breakoutMode);
88
+ var layoutMode = node && (0, _utils.getLayoutModeFromTargetNode)(node);
89
+ if (layoutMode) {
90
+ gapCursor.setAttribute('layout', layoutMode);
91
91
  gapCursor.style.width = "".concat(measureWidth(style), "px");
92
92
  } else {
93
93
  mutateElementStyle(gapCursor, style, selection.side);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getBreakoutModeFromTargetNode = getBreakoutModeFromTargetNode;
6
+ exports.getLayoutModeFromTargetNode = getLayoutModeFromTargetNode;
7
7
  exports.getMediaNearPos = getMediaNearPos;
8
8
  exports.isTextBlockNearPos = exports.isLeftCursor = exports.isIgnoredClick = void 0;
9
9
  var _styles = require("@atlaskit/editor-common/styles");
@@ -68,7 +68,7 @@ var isTextBlockNearPos = function isTextBlockNearPos(doc, schema, $pos, dir) {
68
68
  return false;
69
69
  };
70
70
  exports.isTextBlockNearPos = isTextBlockNearPos;
71
- function getBreakoutModeFromTargetNode(node) {
71
+ function getLayoutModeFromTargetNode(node) {
72
72
  var layout;
73
73
  if (node.attrs.layout) {
74
74
  layout = node.attrs.layout;
@@ -82,7 +82,10 @@ function getBreakoutModeFromTargetNode(node) {
82
82
  }
83
83
  }).attrs.mode;
84
84
  }
85
- if (['wide', 'full-width'].indexOf(layout) === -1) {
85
+ if (node.type.name === 'table' && node.attrs.width) {
86
+ layout = 'fixed-width';
87
+ }
88
+ if (['wide', 'full-width', 'fixed-width'].indexOf(layout) === -1) {
86
89
  return '';
87
90
  }
88
91
  return layout;
@@ -75,10 +75,10 @@ var plugin = new _safePlugin.SafePlugin({
75
75
  }
76
76
  }
77
77
  var node = isRightCursor ? $from.nodeBefore : $from.nodeAfter;
78
- var breakoutMode = node && (0, _utils2.getBreakoutModeFromTargetNode)(node);
78
+ var layoutMode = node && (0, _utils2.getLayoutModeFromTargetNode)(node);
79
79
  return _view2.DecorationSet.create(doc, [_view2.Decoration.widget(position, _placeGapCursor.toDOM, {
80
- key: "".concat(_selection.JSON_ID, "-").concat(side, "-").concat(breakoutMode),
81
- side: breakoutMode ? -1 : 0
80
+ key: "".concat(_selection.JSON_ID, "-").concat(side, "-").concat(layoutMode),
81
+ side: layoutMode ? -1 : 0
82
82
  })]);
83
83
  }
84
84
  return null;
@@ -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.18.2";
9
+ var version = "187.19.1";
10
10
  exports.version = version;
11
11
  var nextMajorVersion = function nextMajorVersion() {
12
12
  return [Number(version.split('.')[0]) + 1, 0, 0].join('.');
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-core",
3
- "version": "187.18.2",
3
+ "version": "187.19.1",
4
4
  "sideEffects": false
5
5
  }
@@ -20,6 +20,7 @@ import { analyticsPlugin as deprecatedAnalyticsPlugin } from '../../../plugins';
20
20
  import { analyticsPlugin } from '@atlaskit/editor-plugin-analytics';
21
21
  import placeholderPlugin from '../../../plugins/placeholder';
22
22
  import annotationPlugin from '../../../plugins/annotation';
23
+ import compositionPlugin from '../../../plugins/composition';
23
24
  import quickInsertPlugin from '../../../plugins/quick-insert';
24
25
  import selectionPlugin from '../../../plugins/selection';
25
26
  import codeBlockPlugin from '../../../plugins/code-block';
@@ -57,7 +58,7 @@ export function createDefaultPreset(options) {
57
58
  }]);
58
59
  }
59
60
  return builder;
60
- }).add([pastePlugin, options.paste]).add(clipboardPlugin).add(focusPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, (p, builder) => {
61
+ }).add([pastePlugin, options.paste]).add(clipboardPlugin).add(focusPlugin).add(compositionPlugin).add([basePlugin, options.base]).add(decorationsPlugin).maybeAdd(undoRedoPlugin, (p, builder) => {
61
62
  var _options$featureFlags;
62
63
  // The undo redo plugin needs to be add before the blockTypePlugin
63
64
  if ((_options$featureFlags = options.featureFlags) !== null && _options$featureFlags !== void 0 && _options$featureFlags.undoRedoButtons) {
@@ -11,7 +11,6 @@ import inlineCursorTargetPlugin from './pm-plugins/inline-cursor-target';
11
11
  import scrollGutter from './pm-plugins/scroll-gutter';
12
12
  import { keymap } from '@atlaskit/editor-common/keymaps';
13
13
  import frozenEditor from './pm-plugins/frozen-editor';
14
- import compositionPlugin from './pm-plugins/composition';
15
14
  // Chrome >= 88
16
15
  export const isChromeWithSelectionBug = browser.chrome && browser.chrome_version >= 88;
17
16
  const basePlugin = (options, api) => {
@@ -85,10 +84,6 @@ const basePlugin = (options, api) => {
85
84
  name: 'disableSpellcheckingPlugin',
86
85
  plugin: () => disableSpellcheckingPlugin(featureFlags)
87
86
  });
88
- plugins.push({
89
- name: 'compositionPlugin',
90
- plugin: () => compositionPlugin()
91
- });
92
87
  return plugins;
93
88
  },
94
89
  nodes() {
@@ -33,7 +33,7 @@ const codeBlockPlugin = (options, api) => ({
33
33
  })
34
34
  }, {
35
35
  name: 'codeBlockIDEKeyBindings',
36
- plugin: () => ideUX
36
+ plugin: () => ideUX(api)
37
37
  }, {
38
38
  name: 'codeBlockKeyMap',
39
39
  plugin: ({
@@ -9,121 +9,124 @@ import { getAutoClosingBracketInfo, shouldAutoCloseBracket } from '../ide-ux/bra
9
9
  import { getAutoClosingQuoteInfo, shouldAutoCloseQuote } from '../ide-ux/quote-handling';
10
10
  import { getEndOfCurrentLine, getStartOfCurrentLine, isCursorInsideCodeBlock, isSelectionEntirelyInsideCodeBlock, getLineInfo } from '../ide-ux/line-handling';
11
11
  import { insertIndent, outdent, indent, insertNewlineWithIndent } from '../ide-ux/commands';
12
- import { isComposing } from '../../base/pm-plugins/composition';
13
- export default new SafePlugin({
14
- props: {
15
- handleTextInput(view, from, to, text) {
16
- const {
17
- state,
18
- dispatch
19
- } = view;
20
- if (isCursorInsideCodeBlock(state) && !isComposing(state)) {
21
- const beforeText = getStartOfCurrentLine(state).text;
22
- const afterText = getEndOfCurrentLine(state).text;
23
-
24
- // If text is a closing bracket/quote and we've already inserted it, move the selection after
25
- if (isCursorBeforeClosingCharacter(afterText) && isClosingCharacter(text) && afterText.startsWith(text)) {
26
- dispatch(setTextSelection(to + text.length)(state.tr));
27
- return true;
28
- }
29
-
30
- // Automatically add right-hand side bracket when user types the left bracket
31
- if (shouldAutoCloseBracket(beforeText, afterText)) {
32
- const {
33
- left,
34
- right
35
- } = getAutoClosingBracketInfo(beforeText + text, afterText);
36
- if (left && right) {
37
- const bracketPair = state.schema.text(text + right);
38
- let tr = state.tr.replaceWith(from, to, bracketPair);
39
- dispatch(setTextSelection(from + text.length)(tr));
40
- return true;
41
- }
42
- }
43
-
44
- // Automatically add closing quote when user types a starting quote
45
- if (shouldAutoCloseQuote(beforeText, afterText)) {
46
- const {
47
- left: leftQuote,
48
- right: rightQuote
49
- } = getAutoClosingQuoteInfo(beforeText + text, afterText);
50
- if (leftQuote && rightQuote) {
51
- const quotePair = state.schema.text(text + rightQuote);
52
- let tr = state.tr.replaceWith(from, to, quotePair);
53
- dispatch(setTextSelection(from + text.length)(tr));
54
- return true;
55
- }
56
- }
57
- }
58
- return false;
59
- },
60
- handleKeyDown: keydownHandler({
61
- Backspace: (state, dispatch) => {
62
- if (isCursorInsideCodeBlock(state)) {
63
- const $cursor = getCursor(state.selection);
12
+ const ideUX = pluginInjectionApi => {
13
+ return new SafePlugin({
14
+ props: {
15
+ handleTextInput(view, from, to, text) {
16
+ const {
17
+ state,
18
+ dispatch
19
+ } = view;
20
+ const compositionPluginState = pluginInjectionApi === null || pluginInjectionApi === void 0 ? void 0 : pluginInjectionApi.dependencies.composition.sharedState.currentState();
21
+ if (isCursorInsideCodeBlock(state) && !(compositionPluginState !== null && compositionPluginState !== void 0 && compositionPluginState.isComposing)) {
64
22
  const beforeText = getStartOfCurrentLine(state).text;
65
23
  const afterText = getEndOfCurrentLine(state).text;
66
- const {
67
- left: leftBracket,
68
- right: rightBracket,
69
- hasTrailingMatchingBracket
70
- } = getAutoClosingBracketInfo(beforeText, afterText);
71
- if (leftBracket && rightBracket && hasTrailingMatchingBracket && dispatch) {
72
- dispatch(state.tr.delete($cursor.pos - leftBracket.length, $cursor.pos + rightBracket.length));
24
+
25
+ // If text is a closing bracket/quote and we've already inserted it, move the selection after
26
+ if (isCursorBeforeClosingCharacter(afterText) && isClosingCharacter(text) && afterText.startsWith(text)) {
27
+ dispatch(setTextSelection(to + text.length)(state.tr));
73
28
  return true;
74
29
  }
75
- const {
76
- left: leftQuote,
77
- right: rightQuote,
78
- hasTrailingMatchingQuote
79
- } = getAutoClosingQuoteInfo(beforeText, afterText);
80
- if (leftQuote && rightQuote && hasTrailingMatchingQuote && dispatch) {
81
- dispatch(state.tr.delete($cursor.pos - leftQuote.length, $cursor.pos + rightQuote.length));
82
- return true;
30
+
31
+ // Automatically add right-hand side bracket when user types the left bracket
32
+ if (shouldAutoCloseBracket(beforeText, afterText)) {
33
+ const {
34
+ left,
35
+ right
36
+ } = getAutoClosingBracketInfo(beforeText + text, afterText);
37
+ if (left && right) {
38
+ const bracketPair = state.schema.text(text + right);
39
+ let tr = state.tr.replaceWith(from, to, bracketPair);
40
+ dispatch(setTextSelection(from + text.length)(tr));
41
+ return true;
42
+ }
83
43
  }
84
- const {
85
- indentToken: {
86
- size,
87
- token
88
- },
89
- indentText
90
- } = getLineInfo(beforeText);
91
- if (beforeText === indentText) {
92
- if (indentText.endsWith(token.repeat(size)) && dispatch) {
93
- dispatch(state.tr.delete($cursor.pos - (size - indentText.length % size || size), $cursor.pos));
44
+
45
+ // Automatically add closing quote when user types a starting quote
46
+ if (shouldAutoCloseQuote(beforeText, afterText)) {
47
+ const {
48
+ left: leftQuote,
49
+ right: rightQuote
50
+ } = getAutoClosingQuoteInfo(beforeText + text, afterText);
51
+ if (leftQuote && rightQuote) {
52
+ const quotePair = state.schema.text(text + rightQuote);
53
+ let tr = state.tr.replaceWith(from, to, quotePair);
54
+ dispatch(setTextSelection(from + text.length)(tr));
94
55
  return true;
95
56
  }
96
57
  }
97
58
  }
98
59
  return false;
99
60
  },
100
- Enter: filter(isSelectionEntirelyInsideCodeBlock, insertNewlineWithIndent),
101
- 'Mod-]': filter(isSelectionEntirelyInsideCodeBlock, indent),
102
- 'Mod-[': filter(isSelectionEntirelyInsideCodeBlock, outdent),
103
- Tab: filter(isSelectionEntirelyInsideCodeBlock, (state, dispatch) => {
104
- if (!dispatch) {
61
+ handleKeyDown: keydownHandler({
62
+ Backspace: (state, dispatch) => {
63
+ if (isCursorInsideCodeBlock(state)) {
64
+ const $cursor = getCursor(state.selection);
65
+ const beforeText = getStartOfCurrentLine(state).text;
66
+ const afterText = getEndOfCurrentLine(state).text;
67
+ const {
68
+ left: leftBracket,
69
+ right: rightBracket,
70
+ hasTrailingMatchingBracket
71
+ } = getAutoClosingBracketInfo(beforeText, afterText);
72
+ if (leftBracket && rightBracket && hasTrailingMatchingBracket && dispatch) {
73
+ dispatch(state.tr.delete($cursor.pos - leftBracket.length, $cursor.pos + rightBracket.length));
74
+ return true;
75
+ }
76
+ const {
77
+ left: leftQuote,
78
+ right: rightQuote,
79
+ hasTrailingMatchingQuote
80
+ } = getAutoClosingQuoteInfo(beforeText, afterText);
81
+ if (leftQuote && rightQuote && hasTrailingMatchingQuote && dispatch) {
82
+ dispatch(state.tr.delete($cursor.pos - leftQuote.length, $cursor.pos + rightQuote.length));
83
+ return true;
84
+ }
85
+ const {
86
+ indentToken: {
87
+ size,
88
+ token
89
+ },
90
+ indentText
91
+ } = getLineInfo(beforeText);
92
+ if (beforeText === indentText) {
93
+ if (indentText.endsWith(token.repeat(size)) && dispatch) {
94
+ dispatch(state.tr.delete($cursor.pos - (size - indentText.length % size || size), $cursor.pos));
95
+ return true;
96
+ }
97
+ }
98
+ }
105
99
  return false;
106
- }
107
- if (isCursorInsideCodeBlock(state)) {
108
- return insertIndent(state, dispatch);
109
- }
110
- return indent(state, dispatch);
111
- }),
112
- 'Shift-Tab': filter(isSelectionEntirelyInsideCodeBlock, outdent),
113
- 'Mod-a': (state, dispatch) => {
114
- if (isSelectionEntirelyInsideCodeBlock(state)) {
115
- const {
116
- $from,
117
- $to
118
- } = state.selection;
119
- const isFullCodeBlockSelection = $from.parentOffset === 0 && $to.parentOffset === $to.parent.nodeSize - 2;
120
- if (!isFullCodeBlockSelection && dispatch) {
121
- dispatch(state.tr.setSelection(TextSelection.create(state.doc, $from.start(), $to.end())));
122
- return true;
100
+ },
101
+ Enter: filter(isSelectionEntirelyInsideCodeBlock, insertNewlineWithIndent),
102
+ 'Mod-]': filter(isSelectionEntirelyInsideCodeBlock, indent),
103
+ 'Mod-[': filter(isSelectionEntirelyInsideCodeBlock, outdent),
104
+ Tab: filter(isSelectionEntirelyInsideCodeBlock, (state, dispatch) => {
105
+ if (!dispatch) {
106
+ return false;
107
+ }
108
+ if (isCursorInsideCodeBlock(state)) {
109
+ return insertIndent(state, dispatch);
123
110
  }
111
+ return indent(state, dispatch);
112
+ }),
113
+ 'Shift-Tab': filter(isSelectionEntirelyInsideCodeBlock, outdent),
114
+ 'Mod-a': (state, dispatch) => {
115
+ if (isSelectionEntirelyInsideCodeBlock(state)) {
116
+ const {
117
+ $from,
118
+ $to
119
+ } = state.selection;
120
+ const isFullCodeBlockSelection = $from.parentOffset === 0 && $to.parentOffset === $to.parent.nodeSize - 2;
121
+ if (!isFullCodeBlockSelection && dispatch) {
122
+ dispatch(state.tr.setSelection(TextSelection.create(state.doc, $from.start(), $to.end())));
123
+ return true;
124
+ }
125
+ }
126
+ return false;
124
127
  }
125
- return false;
126
- }
127
- })
128
- }
129
- });
128
+ })
129
+ }
130
+ });
131
+ };
132
+ export default ideUX;
@@ -0,0 +1,23 @@
1
+ import createPlugin from './pm-plugins/main';
2
+ import { pluginKey } from './pm-plugins/plugin-key';
3
+ const composition = () => {
4
+ return {
5
+ name: 'composition',
6
+ getSharedState(editorState) {
7
+ var _pluginKey$getState;
8
+ if (!editorState) {
9
+ return undefined;
10
+ }
11
+ return {
12
+ isComposing: !!((_pluginKey$getState = pluginKey.getState(editorState)) !== null && _pluginKey$getState !== void 0 && _pluginKey$getState.isComposing)
13
+ };
14
+ },
15
+ pmPlugins() {
16
+ return [{
17
+ name: 'composition',
18
+ plugin: () => createPlugin()
19
+ }];
20
+ }
21
+ };
22
+ };
23
+ export default composition;
@@ -1,21 +1,16 @@
1
1
  import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
2
- import { PluginKey } from '@atlaskit/editor-prosemirror/state';
3
2
  import { ZERO_WIDTH_SPACE } from '@atlaskit/editor-common/utils';
4
- const compositionPluginKey = new PluginKey('compositionPlugin');
5
- export const isComposing = state => {
6
- var _compositionPluginKey;
7
- return !!((_compositionPluginKey = compositionPluginKey.getState(state)) !== null && _compositionPluginKey !== void 0 && _compositionPluginKey.isComposing);
8
- };
3
+ import { pluginKey } from './plugin-key';
9
4
  const isLinux = () => navigator.userAgent.indexOf('Linux') >= 0;
10
5
  export default (() => new SafePlugin({
11
- key: compositionPluginKey,
6
+ key: pluginKey,
12
7
  state: {
13
8
  init: () => ({
14
9
  isComposing: false,
15
10
  zeroWidthSpacePos: undefined
16
11
  }),
17
12
  apply: (tr, value) => {
18
- const isComposing = tr.getMeta(compositionPluginKey);
13
+ const isComposing = tr.getMeta(pluginKey);
19
14
  const zeroWidthSpacePos = tr.getMeta('zeroWidthSpacePos');
20
15
  if (typeof isComposing === 'undefined') {
21
16
  return value;
@@ -32,7 +27,7 @@ export default (() => new SafePlugin({
32
27
  const {
33
28
  tr
34
29
  } = view.state;
35
- tr.setMeta(compositionPluginKey, true);
30
+ tr.setMeta(pluginKey, true);
36
31
 
37
32
  // only apply for linux and cursor is at start of line
38
33
  if (isLinux() && view.state.selection.$from.parentOffset === 0) {
@@ -48,10 +43,10 @@ export default (() => new SafePlugin({
48
43
  const {
49
44
  tr
50
45
  } = view.state;
51
- tr.setMeta(compositionPluginKey, false);
46
+ tr.setMeta(pluginKey, false);
52
47
  if (isLinux()) {
53
- var _compositionPluginKey2;
54
- const zeroWidthSpacePos = (_compositionPluginKey2 = compositionPluginKey.getState(view.state)) === null || _compositionPluginKey2 === void 0 ? void 0 : _compositionPluginKey2.zeroWidthSpacePos;
48
+ var _pluginKey$getState;
49
+ const zeroWidthSpacePos = (_pluginKey$getState = pluginKey.getState(view.state)) === null || _pluginKey$getState === void 0 ? void 0 : _pluginKey$getState.zeroWidthSpacePos;
55
50
  if (typeof zeroWidthSpacePos !== 'undefined') {
56
51
  tr.deleteRange(zeroWidthSpacePos, zeroWidthSpacePos + 1);
57
52
  }